libmicrohttpd-1.0.1/0000755000175000017500000000000014566140221010117 5libmicrohttpd-1.0.1/MHD_config.h.in0000644000175000017500000005465114566140214012567 /* MHD_config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Define to 1 if libmicrohttpd is compiled with Basic Auth support. */ #undef BAUTH_SUPPORT /* Define to 1 if libmicrohttpd is compiled with HTTP cookie parsing support. */ #undef COOKIE_SUPPORT /* This is a Cygwin system */ #undef CYGWIN /* Define to 1 if libmicrohttpd is compiled with Digest Auth support. */ #undef DAUTH_SUPPORT /* Define to 1 to enable epoll support */ #undef EPOLL_SUPPORT /* This is a FreeBSD system */ #undef FREEBSD /* Define to '1' if '__attribute__((no_sanitize("address")))' works for pointers compare */ #undef FUNC_ATTR_NOSANITIZE_WORKS /* Define to '1' if '__attribute__((no_sanitize("pointer-compare")))' works */ #undef FUNC_ATTR_PTRCOMPARE_WORKS /* Define to '1' if '__attribute__((no_sanitize("pointer-subtract")))' works */ #undef FUNC_ATTR_PTRSUBTRACT_WORKS /* Define to '1' if cast to 'uintptr_t' works for safely processing user-poisoned pointer */ #undef FUNC_PTRCOMPARE_CAST_WORKAROUND_WORKS /* Define to `1' if host machine runs on GNU Hurd. */ #undef GNU_HURD /* Define to 1 if your system allow overriding the value of FD_SETSIZE macro */ #undef HAS_FD_SETSIZE_OVERRIDABLE /* Define to 1 if your socket type is signed */ #undef HAS_SIGNED_SOCKET /* Define to 1 if you have the 'accept4' function. */ #undef HAVE_ACCEPT4 /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define if you have usable assert() and assert.h */ #undef HAVE_ASSERT /* Define to 1 if you have the real boolean type. */ #undef HAVE_BUILTIN_TYPE_BOOL /* Define to 1 if you have the `gmtime_s' function in C11 form. */ #undef HAVE_C11_GMTIME_S /* Define to 1 if you have the usable `calloc' function. */ #undef HAVE_CALLOC /* Define to '1' if you have clock_gettime() function */ #undef HAVE_CLOCK_GETTIME /* Define to 1 if you have the 'clock_get_time' function. */ #undef HAVE_CLOCK_GET_TIME /* Define to 1 if you have the 'cpuset_getaffinity' function. */ #undef HAVE_CPUSET_GETAFFINITY /* Define to 1 if you have the 'CPU_COUNT' function. */ #undef HAVE_CPU_COUNT /* Define to 1 if you have the 'CPU_COUNT_S' function. */ #undef HAVE_CPU_COUNT_S /* Define to 1 if your compiler supports 'alignof()' */ #undef HAVE_C_ALIGNOF /* Define to 1 if C supports variable-length arrays. */ #undef HAVE_C_VARARRAYS /* Define to 1 if you have Darwin-style sendfile(2). */ #undef HAVE_DARWIN_SENDFILE /* Define to 1 if you have the declaration of `CPU_SETSIZE', and to 0 if you don't. */ #undef HAVE_DECL_CPU_SETSIZE /* Define to 1 if you have the declaration of `CTL_HW', and to 0 if you don't. */ #undef HAVE_DECL_CTL_HW /* Define to 1 if you have the declaration of `CTL_NET', and to 0 if you don't. */ #undef HAVE_DECL_CTL_NET /* Define to 1 if you have the declaration of `HW_AVAILCPU', and to 0 if you don't. */ #undef HAVE_DECL_HW_AVAILCPU /* Define to 1 if you have the declaration of `HW_NCPU', and to 0 if you don't. */ #undef HAVE_DECL_HW_NCPU /* Define to 1 if you have the declaration of `HW_NCPUONLINE', and to 0 if you don't. */ #undef HAVE_DECL_HW_NCPUONLINE /* Define to 1 if you have the declaration of `ICMPCTL_ICMPLIM', and to 0 if you don't. */ #undef HAVE_DECL_ICMPCTL_ICMPLIM /* Define to 1 if you have the declaration of `IPPROTO_ICMP', and to 0 if you don't. */ #undef HAVE_DECL_IPPROTO_ICMP /* Define to 1 if you have the declaration of `PF_INET', and to 0 if you don't. */ #undef HAVE_DECL_PF_INET /* Define to 1 if you have the declaration of `_SC_CRAY_NCPU', and to 0 if you don't. */ #undef HAVE_DECL__SC_CRAY_NCPU /* Define to 1 if you have the declaration of `_SC_NPROCESSORS_CONF', and to 0 if you don't. */ #undef HAVE_DECL__SC_NPROCESSORS_CONF /* Define to 1 if you have the declaration of `_SC_NPROCESSORS_ONLN', and to 0 if you don't. */ #undef HAVE_DECL__SC_NPROCESSORS_ONLN /* Define to 1 if you have the declaration of `_SC_NPROC_ONLN', and to 0 if you don't. */ #undef HAVE_DECL__SC_NPROC_ONLN /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_ENDIAN_H /* Define to 1 if you have the 'epoll_create1' function. */ #undef HAVE_EPOLL_CREATE1 /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the header file. */ #undef HAVE_FEATURES_H /* Define to 1 if you have the usable `fork' function. */ #undef HAVE_FORK /* Define to 1 if you have FreeBSD-style sendfile(2). */ #undef HAVE_FREEBSD_SENDFILE /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #undef HAVE_FSEEKO /* Define to 1 if you have the header file. */ #undef HAVE_GCRYPT_H /* Define to 1 if you have the 'gethrtime' function. */ #undef HAVE_GETHRTIME /* Define to 1 if you have the 'getpid' function. */ #undef HAVE_GETPID /* Define to 1 if you have the 'gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the 'gmtime_r' function. */ #undef HAVE_GMTIME_R /* Define to 1 if you have the 'gnutls_check_version' function. */ #undef HAVE_GNUTLS_CHECK_VERSION /* Define to 1 if you have the header file. */ #undef HAVE_GNUTLS_GNUTLS_H /* Define to '1' if you have IPv6 headers */ #undef HAVE_INET6 /* Define to 1 if you have the header file. */ #undef HAVE_INETLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have a functional curl library. */ #undef HAVE_LIBCURL /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have linux-style sendfile(2). */ #undef HAVE_LINUX_SENDFILE /* can use shutdown on listen sockets */ #undef HAVE_LISTEN_SHUTDOWN /* Define to 1 if you have the 'lseek64' function. */ #undef HAVE_LSEEK64 /* Define to 1 if you have the header file. */ #undef HAVE_MACHINE_ENDIAN_H /* Define to 1 if you have the header file. */ #undef HAVE_MACHINE_PARAM_H /* Define to 1 if you have the 'magic_open' function. */ #undef HAVE_MAGIC_OPEN /* Define to 1 if you have the 'memmem' function. */ #undef HAVE_MEMMEM /* Define to 1 to enable support for text messages. */ #undef HAVE_MESSAGES /* Define to 1 if you have the 'nanosleep' function. */ #undef HAVE_NANOSLEEP /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_ICMP_VAR_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_SYSTM_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IP_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IP_ICMP_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_H /* Define if you have usable pipe2(2) function */ #undef HAVE_PIPE2_FUNC /* Define to 1 if you have the 'poll' function. */ #undef HAVE_POLL /* Define to 1 if you have the header file. */ #undef HAVE_POLL_H /* Define to 1 if libmicrohttpd is compiled with postprocessor support. */ #undef HAVE_POSTPROCESSOR /* Define to 1 if you have the 'pread' function. */ #undef HAVE_PREAD /* Define to 1 if you have the 'pread64' function. */ #undef HAVE_PREAD64 /* Define to 1 if you have the 'pstat_getdynamic' function. */ #undef HAVE_PSTAT_GETDYNAMIC /* Define if you have IBM i form (or Solaris form) of pthread_attr_setname_np(3) function. */ #undef HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI /* Define if you have NetBSD form (or OSF1 form) of pthread_attr_setname_np(3) function. */ #undef HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_H /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_NP_H /* Have PTHREAD_PRIO_INHERIT. */ #undef HAVE_PTHREAD_PRIO_INHERIT /* Define if you have Darwin form of pthread_setname_np(3) function. */ #undef HAVE_PTHREAD_SETNAME_NP_DARWIN /* Define if you have GNU/Linux form of pthread_setname_np(3) function. */ #undef HAVE_PTHREAD_SETNAME_NP_GNU /* Define if you have NetBSD form (or OSF1 form) of pthread_setname_np(3) function. */ #undef HAVE_PTHREAD_SETNAME_NP_NETBSD /* Define if you have FreeBSD form of pthread_set_name_np(3) function. */ #undef HAVE_PTHREAD_SET_NAME_NP_FREEBSD /* Define to 1 if you have the pthread_sigmask(3) function. */ #undef HAVE_PTHREAD_SIGMASK /* Define to 1 if you have the 'rand' function. */ #undef HAVE_RAND /* Define to 1 if you have the 'random' function. */ #undef HAVE_RANDOM /* Define to 1 if you have the header file. */ #undef HAVE_SANITIZER_ASAN_INTERFACE_H /* Define to 1 if you have the 'sched_getaffinity' function. */ #undef HAVE_SCHED_GETAFFINITY /* Define to 1 if you have the 'sched_getaffinity_np' function. */ #undef HAVE_SCHED_GETAFFINITY_NP /* Define to 1 if you have the header file. */ #undef HAVE_SCHED_H /* Define to 1 if you have the header file. */ #undef HAVE_SDKDDKVER_H /* Define to 1 if you have the 'sendfile64' function. */ #undef HAVE_SENDFILE64 /* Define to '1' if your have sendmsg() function */ #undef HAVE_SENDMSG /* Define to 1 if you have the header file. */ #undef HAVE_SIGNAL_H /* Define to 1 if you have the 'snprintf' function. */ #undef HAVE_SNPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_SOCKLIB_H /* SOCK_NONBLOCK is defined in a socket header */ #undef HAVE_SOCK_NONBLOCK /* Define to 1 if you have Solaris-style sendfile(3). */ #undef HAVE_SOLARIS_SENDFILE /* Define to 1 if you have the header file. */ #undef HAVE_STDALIGN_H /* Define to 1 if you have the header file and defines 'bool' type. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDIO_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if `sin6_len' is a member of `struct sockaddr_in6'. */ #undef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN /* Define to 1 if `sin_len' is a member of `struct sockaddr_in'. */ #undef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN /* Define to 1 if `sa_len' is a member of `struct sockaddr'. */ #undef HAVE_STRUCT_SOCKADDR_SA_LEN /* Define to 1 if `ss_len' is a member of `struct sockaddr_storage'. */ #undef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN /* Define to 1 if you have the 'sysconf' function. */ #undef HAVE_SYSCONF /* Define to 1 if you have the 'sysctl' function. */ #undef HAVE_SYSCTL /* Define to 1 if you have the 'sysctlbyname' function. */ #undef HAVE_SYSCTLBYNAME /* Define to 1 if you have the header file. */ #undef HAVE_SYS_BYTEORDER_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_CPUSET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_ENDIAN_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_ISA_DEFS_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MACHINE_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MMAN_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MSG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PSTAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SYSCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS__CPUSET_H /* Define to 1 if you have the 'timespec_get' function. */ #undef HAVE_TIMESPEC_GET /* Define to 1 if you have the header file. */ #undef HAVE_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the 'usleep' function. */ #undef HAVE_USLEEP /* Define to 1 if you have the 'vxCpuEnabledGet' function. */ #undef HAVE_VXCPUENABLEDGET /* Define to 1 if you have the header file. */ #undef HAVE_VXCPULIB_H /* Define to 1 if you have the `gmtime_s' function in W32 form. */ #undef HAVE_W32_GMTIME_S /* Define to 1 if you have the usable `waitpid' function. */ #undef HAVE_WAITPID /* Define to 1 if you have the header file. */ #undef HAVE_WINDOWS_H /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK2_H /* Define to 1 if you have the 'writev' function. */ #undef HAVE_WRITEV /* Define to 1 if you have the header file. */ #undef HAVE_WS2TCPIP_H /* Define to 1 if you have the 'WSAPoll' function. */ #undef HAVE_WSAPOLL /* Define to 1 if you have the header file. */ #undef HAVE_ZLIB_H /* Define to 1 if you have the '__asan_address_is_poisoned' function. */ #undef HAVE___ASAN_ADDRESS_IS_POISONED /* Define to 1 if you have the '__asan_region_is_poisoned' function. */ #undef HAVE___ASAN_REGION_IS_POISONED /* Define to 1 if your compiler supports __FUNCTION__ magic-macro. */ #undef HAVE___FUNCTION__ /* Define to 1 if your compiler supports __func__ magic-macro. */ #undef HAVE___FUNC__ /* Define to 1 if your compiler supports __PRETTY_FUNCTION__ magic-macro. */ #undef HAVE___PRETTY_FUNCTION__ /* Define to 1 if libmicrohttpd is compiled with HTTPS support. */ #undef HTTPS_SUPPORT /* Define to 1 if your C compiler supports inline functions. */ #undef INLINE_FUNC /* Defined if libcurl supports AsynchDNS */ #undef LIBCURL_FEATURE_ASYNCHDNS /* Defined if libcurl supports IDN */ #undef LIBCURL_FEATURE_IDN /* Defined if libcurl supports IPv6 */ #undef LIBCURL_FEATURE_IPV6 /* Defined if libcurl supports KRB4 */ #undef LIBCURL_FEATURE_KRB4 /* Defined if libcurl supports libz */ #undef LIBCURL_FEATURE_LIBZ /* Defined if libcurl supports NTLM */ #undef LIBCURL_FEATURE_NTLM /* Defined if libcurl supports SSL */ #undef LIBCURL_FEATURE_SSL /* Defined if libcurl supports SSPI */ #undef LIBCURL_FEATURE_SSPI /* Defined if libcurl supports DICT */ #undef LIBCURL_PROTOCOL_DICT /* Defined if libcurl supports FILE */ #undef LIBCURL_PROTOCOL_FILE /* Defined if libcurl supports FTP */ #undef LIBCURL_PROTOCOL_FTP /* Defined if libcurl supports FTPS */ #undef LIBCURL_PROTOCOL_FTPS /* Defined if libcurl supports HTTP */ #undef LIBCURL_PROTOCOL_HTTP /* Defined if libcurl supports HTTPS */ #undef LIBCURL_PROTOCOL_HTTPS /* Defined if libcurl supports IMAP */ #undef LIBCURL_PROTOCOL_IMAP /* Defined if libcurl supports LDAP */ #undef LIBCURL_PROTOCOL_LDAP /* Defined if libcurl supports POP3 */ #undef LIBCURL_PROTOCOL_POP3 /* Defined if libcurl supports RTSP */ #undef LIBCURL_PROTOCOL_RTSP /* Defined if libcurl supports SMTP */ #undef LIBCURL_PROTOCOL_SMTP /* Defined if libcurl supports TELNET */ #undef LIBCURL_PROTOCOL_TELNET /* Defined if libcurl supports TFTP */ #undef LIBCURL_PROTOCOL_TFTP /* This is a Linux kernel */ #undef LINUX /* Define to the sub-directory where libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Define to '1' if you have address sanitizer enabled */ #undef MHD_ASAN_ACTIVE /* Define to '1' if user memory poison is used */ #undef MHD_ASAN_POISON_ACTIVE /* The default HTTP Digest Auth default maximum nc (nonce count) value */ #undef MHD_DAUTH_DEF_MAX_NC_ /* The default HTTP Digest Auth default nonce timeout value (in seconds) */ #undef MHD_DAUTH_DEF_TIMEOUT_ /* Define to '1' to use fast (and larger) code version */ #undef MHD_FAVOR_FAST_CODE /* Define to '1' to use compact code version */ #undef MHD_FAVOR_SMALL_CODE /* Define to '1' if CPU_COUNT_S() function expects max CPU number as 'size' parameter */ #undef MHD_FUNC_CPU_COUNT_S_GETS_CPUS /* Define to 1 if you have suitable libmagic. */ #undef MHD_HAVE_LIBMAGIC /* Define to 1 if you have __builtin_bswap32() builtin function */ #undef MHD_HAVE___BUILTIN_BSWAP32 /* Define to 1 if you have __builtin_bswap64() builtin function */ #undef MHD_HAVE___BUILTIN_BSWAP64 /* Define to `1' if HTTPS require initialisation of libgcrypt */ #undef MHD_HTTPS_REQUIRE_GCRYPT /* Define to 1 if libmicrohttpd is compiled with MD5 hashing support. */ #undef MHD_MD5_SUPPORT /* Define to 1 if libmicrohttpd is compiled with MD5 hashing by TLS library. */ #undef MHD_MD5_TLSLIB /* Define to 1 to disable setting name on generated threads */ #undef MHD_NO_THREAD_NAMES /* tls plugins */ #undef MHD_PLUGIN_INSTALL_PREFIX /* Define to 1 if libmicrohttpd is compiled with SHA-256 hashing support. */ #undef MHD_SHA256_SUPPORT /* Define to 1 if libmicrohttpd is compiled with SHA-256 hashing by TLS library. */ #undef MHD_SHA256_TLSLIB /* Define to 1 if libmicrohttpd is compiled with SHA-512/256 hashing support. */ #undef MHD_SHA512_256_SUPPORT /* Define to system default value of FD_SETSIZE macro */ #undef MHD_SYS_FD_SETSIZE_ /* Define if you have usable `getsockname' function. */ #undef MHD_USE_GETSOCKNAME /* Define if you have usable PAGESIZE macro */ #undef MHD_USE_PAGESIZE_MACRO /* Define if you have PAGESIZE macro usable for static init */ #undef MHD_USE_PAGESIZE_MACRO_STATIC /* Define if you have usable PAGE_SIZE macro */ #undef MHD_USE_PAGE_SIZE_MACRO /* Define if you have PAGE_SIZE macro usable for static init */ #undef MHD_USE_PAGE_SIZE_MACRO_STATIC /* define to use pthreads */ #undef MHD_USE_POSIX_THREADS /* Define to 1 if you have properly working tsearch(), tfind() and tdelete() functions. */ #undef MHD_USE_SYS_TSEARCH /* define to use W32 threads */ #undef MHD_USE_W32_THREADS /* This is a MinGW system */ #undef MINGW /* This is a NetBSD system */ #undef NETBSD /* This is an OpenBSD system */ #undef OPENBSD /* This is a OS/390 system */ #undef OS390 /* This is an OS X system */ #undef OSX /* Some strange OS */ #undef OTHEROS /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to necessary symbol if this constant uses a non-standard name on your system. */ #undef PTHREAD_CREATE_JOINABLE /* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT /* The size of `int64_t', as computed by sizeof. */ #undef SIZEOF_INT64_T /* The size of `size_t', as computed by sizeof. */ #undef SIZEOF_SIZE_T /* The size of `tv_sec' member of `struct timeval', as computed by sizeof */ #undef SIZEOF_STRUCT_TIMEVAL_TV_SEC /* The size of `uint64_t', as computed by sizeof. */ #undef SIZEOF_UINT64_T /* The size of `unsigned int', as computed by sizeof. */ #undef SIZEOF_UNSIGNED_INT /* The size of `unsigned long long', as computed by sizeof. */ #undef SIZEOF_UNSIGNED_LONG_LONG /* This is a Solaris system */ #undef SOLARIS /* This is a BSD system */ #undef SOMEBSD /* Define to 1 if all of the C90 standard headers exist (not just the ones required in a freestanding environment). This macro is provided for backward compatibility; new code need not use it. */ #undef STDC_HEADERS /* Define to 1 if libmicrohttpd is compiled with HTTP Upgrade support. */ #undef UPGRADE_SUPPORT /* Define to 1 if your kernel supports IPv6 and IPv6 is enabled and useful for testing. */ #undef USE_IPV6_TESTING /* Version number of package */ #undef VERSION /* This is a Windows system */ #undef WINDOWS /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ #undef _LARGEFILE_SOURCE /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* defines how to decorate public symbols while building the library */ #undef _MHD_EXTERN /* Define to 1 to enable "heavy" test paths. */ #undef _MHD_HEAVY_TESTS /* Define to use eventFD for inter-thread communication */ #undef _MHD_ITC_EVENTFD /* Define to use pipe for inter-thread communication */ #undef _MHD_ITC_PIPE /* Define to use socketpair for inter-thread communication */ #undef _MHD_ITC_SOCKETPAIR /* Define to supported 'noreturn' function declaration */ #undef _MHD_NORETURN /* Define to 1 to enable "very heavy" test paths. */ #undef _MHD_VHEAVY_TESTS /* Define to prefix which will be used with MHD static inline functions. */ #undef _MHD_static_inline /* Need with solaris or errno does not work */ #undef _REENTRANT /* Define to 1 if C does not support variable-length arrays, and if the compiler does not already define this. */ #undef __STDC_NO_VLA__ /* Define to type name which will be used as boolean type. */ #undef bool /* Define curl_free() as free() if our version of curl lacks curl_free. */ #undef curl_free /* Define to value interpreted by compiler as boolean "false", if "false" is not defined by system headers. */ #undef false /* Define to value interpreted by compiler as boolean "true", if "true" is not defined by system headers. */ #undef true libmicrohttpd-1.0.1/aclocal.m40000644000175000017500000012514314566140135011711 # generated automatically by aclocal 1.16.5 -*- Autoconf -*- # Copyright (C) 1996-2021 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],, [m4_warning([this file was generated for autoconf 2.71. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # Copyright (C) 2002-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.16.5], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.16.5])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. AS_CASE([$CONFIG_FILES], [*\'*], [eval set x "$CONFIG_FILES"], [*], [set x $CONFIG_FILES]) shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`AS_DIRNAME(["$am_mf"])` am_filepart=`AS_BASENAME(["$am_mf"])` AM_RUN_LOG([cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles]) || am_rc=$? done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments for automatic dependency tracking. If GNU make was not used, consider re-running the configure script with MAKE="gmake" (or whatever is necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi AS_UNSET([am_dirpart]) AS_UNSET([am_filepart]) AS_UNSET([am_mf]) AS_UNSET([am_rc]) rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking is enabled. # This creates each '.Po' and '.Plo' makefile fragment that we'll need in # order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl m4_ifdef([_$0_ALREADY_INIT], [m4_fatal([$0 expanded multiple times ]m4_defn([_$0_ALREADY_INIT]))], [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) # Variables for tags utilities; see am/tags.am if test -z "$CTAGS"; then CTAGS=ctags fi AC_SUBST([CTAGS]) if test -z "$ETAGS"; then ETAGS=etags fi AC_SUBST([ETAGS]) if test -z "$CSCOPE"; then CSCOPE=cscope fi AC_SUBST([CSCOPE]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check whether make has an 'include' directive that can support all # the idioms we need for our automatic dependency tracking code. AC_DEFUN([AM_MAKE_INCLUDE], [AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) AS_CASE([$?:`cat confinc.out 2>/dev/null`], ['0:this is the am__doit target'], [AS_CASE([$s], [BSD], [am__include='.include' am__quote='"'], [am__include='include' am__quote=''])]) if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* AC_MSG_RESULT([${_am_result}]) AC_SUBST([am__include])]) AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/ac_define_dir.m4]) m4_include([m4/ax_append_compile_flags.m4]) m4_include([m4/ax_append_flag.m4]) m4_include([m4/ax_append_link_flags.m4]) m4_include([m4/ax_check_compile_flag.m4]) m4_include([m4/ax_check_link_flag.m4]) m4_include([m4/ax_count_cpus.m4]) m4_include([m4/ax_have_epoll.m4]) m4_include([m4/ax_pthread.m4]) m4_include([m4/ax_require_defined.m4]) m4_include([m4/c_backported.m4]) m4_include([m4/libcurl.m4]) m4_include([m4/libgcrypt.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) m4_include([m4/mhd_append_flag_to_var.m4]) m4_include([m4/mhd_check_add_cc_cflag.m4]) m4_include([m4/mhd_check_add_cc_cflags.m4]) m4_include([m4/mhd_check_add_cc_ldflag.m4]) m4_include([m4/mhd_check_add_cc_ldflags.m4]) m4_include([m4/mhd_check_cc_cflag.m4]) m4_include([m4/mhd_check_func.m4]) m4_include([m4/mhd_check_func_gettimeofday.m4]) m4_include([m4/mhd_check_link_run.m4]) m4_include([m4/mhd_find_add_cc_cflag.m4]) m4_include([m4/mhd_find_add_cc_cflag_ifelse.m4]) m4_include([m4/mhd_find_lib.m4]) m4_include([m4/mhd_norm_expd.m4]) m4_include([m4/mhd_prepend_flag_to_var.m4]) m4_include([m4/mhd_shutdown_socket_trigger.m4]) m4_include([m4/mhd_sys_extentions.m4]) m4_include([m4/pkg.m4]) libmicrohttpd-1.0.1/configure0000755000175000017500000543430514566140140011764 #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.71 for GNU libmicrohttpd 1.0.1. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, # Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="as_nop=: if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else \$as_nop case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ) then : else \$as_nop exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 blah=\$(echo \$(echo blah)) test x\"\$blah\" = xblah || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" if (eval "$as_required") 2>/dev/null then : as_have_required=yes else $as_nop as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null then : else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$as_shell as_have_required=yes if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null then : break 2 fi fi done;; esac as_found=false done IFS=$as_save_IFS if $as_found then : else $as_nop if { test -f "$SHELL" || test -f "$SHELL.exe"; } && as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$SHELL as_have_required=yes fi fi if test "x$CONFIG_SHELL" != x then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno then : printf "%s\n" "$0: This script requires a shell more modern than all" printf "%s\n" "$0: the shells that I found on your system." if test ${ZSH_VERSION+y} ; then printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." else printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and $0: libmicrohttpd@gnu.org about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='GNU libmicrohttpd' PACKAGE_TARNAME='libmicrohttpd' PACKAGE_VERSION='1.0.1' PACKAGE_STRING='GNU libmicrohttpd 1.0.1' PACKAGE_BUGREPORT='libmicrohttpd@gnu.org' PACKAGE_URL='https://www.gnu.org/software/libmicrohttpd/' # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_STDIO_H # include #endif #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_header_c_list= ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS HAVE_EXPERIMENTAL_FALSE HAVE_EXPERIMENTAL_TRUE MHD_PLUGIN_INSTALL_PREFIX MHD_AUX_DIR EMPTY_VAR ac_configure_args CPPFLAGS_ac LDFLAGS_ac CFLAGS_ac MHD_LIBDEPS_PKGCFG MHD_REQ_PRIVATE MHD_TLS_LIBDEPS MHD_TLS_LIB_LDFLAGS MHD_TLS_LIB_CFLAGS MHD_TLS_LIB_CPPFLAGS MHD_LIBDEPS MHD_LIB_LDFLAGS MHD_LIB_CFLAGS MHD_LIB_CPPFLAGS HEAVY_TESTS_NOTPARALLEL CPU_COUNT TESTS_ENVIRONMENT_ac AM_LSAN_OPTIONS AM_UBSAN_OPTIONS AM_ASAN_OPTIONS USE_SANITIZERS_FALSE USE_SANITIZERS_TRUE FORCE_USE_ZZUF_SOCAT_FALSE FORCE_USE_ZZUF_SOCAT_TRUE RUN_ZZUF_TESTS_FALSE RUN_ZZUF_TESTS_TRUE SOCAT ZZUF MHD_REAL_CPU_COUNT USE_COVERAGE_FALSE USE_COVERAGE_TRUE HAVE_FORK_WAITPID_FALSE HAVE_FORK_WAITPID_TRUE ENABLE_SHA512_256_FALSE ENABLE_SHA512_256_TRUE ENABLE_SHA256_EXT_FALSE ENABLE_SHA256_EXT_TRUE ENABLE_SHA256_FALSE ENABLE_SHA256_TRUE ENABLE_MD5_EXT_FALSE ENABLE_MD5_EXT_TRUE ENABLE_MD5_FALSE ENABLE_MD5_TRUE ENABLE_COOKIE_FALSE ENABLE_COOKIE_TRUE ENABLE_UPGRADE_FALSE ENABLE_UPGRADE_TRUE HAVE_ANYAUTH_FALSE HAVE_ANYAUTH_TRUE ENABLE_DAUTH_FALSE ENABLE_DAUTH_TRUE ENABLE_BAUTH_FALSE ENABLE_BAUTH_TRUE USE_UPGRADE_TLS_TESTS_FALSE USE_UPGRADE_TLS_TESTS_TRUE HAVE_GNUTLS_MTHREAD_BROKEN_FALSE HAVE_GNUTLS_MTHREAD_BROKEN_TRUE GNUTLS_LDFLAGS GNUTLS_CPPFLAGS HTTPS_REQUIRE_GCRYPT_FALSE HTTPS_REQUIRE_GCRYPT_TRUE ENABLE_HTTPS_FALSE ENABLE_HTTPS_TRUE HAVE_GNUTLS_SNI_FALSE HAVE_GNUTLS_SNI_TRUE HAVE_GNUTLS_FALSE HAVE_GNUTLS_TRUE LIBGCRYPT_LIBS LIBGCRYPT_CFLAGS LIBGCRYPT_CONFIG GNUTLS_LIBS GNUTLS_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG HAVE_POSTPROCESSOR_FALSE HAVE_POSTPROCESSOR_TRUE HAVE_MESSAGES_FALSE HAVE_MESSAGES_TRUE MHD_HAVE_LIBMAGIC_FALSE MHD_HAVE_LIBMAGIC_TRUE RUN_LIBCURL_TESTS_FALSE RUN_LIBCURL_TESTS_TRUE LIBCURL LIBCURL_CPPFLAGS _libcurl_config HIDDEN_VISIBILITY_CFLAGS HAVE_ZLIB_FALSE HAVE_ZLIB_TRUE MHD_HAVE_TLS_PLUGIN_FALSE MHD_HAVE_TLS_PLUGIN_TRUE MHD_HAVE_EPOLL_FALSE MHD_HAVE_EPOLL_TRUE TESTS_STRESS_OS_FALSE TESTS_STRESS_OS_TRUE VHEAVY_TESTS_FALSE VHEAVY_TESTS_TRUE HEAVY_TESTS_FALSE HEAVY_TESTS_TRUE BUILD_TOOLS_FALSE BUILD_TOOLS_TRUE BUILD_EXAMPLES_FALSE BUILD_EXAMPLES_TRUE BUILD_DOC_FALSE BUILD_DOC_TRUE W32_STATIC_LIB_FALSE W32_STATIC_LIB_TRUE HAVE_MAKEINFO_BINARY_FALSE HAVE_MAKEINFO_BINARY_TRUE HAVE_MAKEINFO_BINARY HAVE_CURL_BINARY_FALSE HAVE_CURL_BINARY_TRUE HAVE_CURL_BINARY NEED_SYS_FD_SET_SIZE_VALUE_FALSE NEED_SYS_FD_SET_SIZE_VALUE_TRUE HAVE_LISTEN_SHUTDOWN_FALSE HAVE_LISTEN_SHUTDOWN_TRUE USE_EXPORT_FILE_FALSE USE_EXPORT_FILE_TRUE USE_MS_LIB_TOOL_FALSE USE_MS_LIB_TOOL_TRUE W32_SHARED_LIB_EXP_FALSE W32_SHARED_LIB_EXP_TRUE HAVE_W32_FALSE HAVE_W32_TRUE DISABLE_THREADS_FALSE DISABLE_THREADS_TRUE USE_THREADS_FALSE USE_THREADS_TRUE USE_W32_THREADS_FALSE USE_W32_THREADS_TRUE USE_POSIX_THREADS_FALSE USE_POSIX_THREADS_TRUE HAVE_POSIX_THREADS_FALSE HAVE_POSIX_THREADS_TRUE PTHREAD_CFLAGS PTHREAD_LIBS PTHREAD_CXX PTHREAD_CC ax_pthread_config W32CRT CYGWIN_TARGET_FALSE CYGWIN_TARGET_TRUE lt_cv_objdir MS_LIB_TOOL MHD_USE_SYS_TSEARCH_FALSE MHD_USE_SYS_TSEARCH_TRUE RC LT_SYS_LIBRARY_PATH OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR FILECMD NM ac_ct_DUMPBIN DUMPBIN LD EGREP SED LIBTOOL OBJDUMP DLLTOOL AS CPP am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC host_os host_vendor host_cpu host build_os build_vendor build_cpu build LN_S FGREP GREP AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V CSCOPE ETAGS CTAGS am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM MHD_W32_DLL_SUFF PACKAGE_VERSION_SUBMINOR PACKAGE_VERSION_MINOR PACKAGE_VERSION_MAJOR LIB_VERSION_AGE LIB_VERSION_REVISION LIB_VERSION_CURRENT target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL am__quote' ac_subst_files='' ac_user_opts=' enable_option_checking enable_build_type enable_silent_rules enable_dependency_tracking enable_shared enable_static with_pic enable_fast_install with_aix_soname with_gnu_ld with_sysroot enable_libtool_lock enable_compact_code enable_compiler_hardening enable_linker_hardening with_threads enable_thread_names enable_doc enable_examples enable_tools enable_heavy_tests enable_poll enable_epoll enable_itc enable_curl with_libcurl enable_largefile enable_sendfile enable_messages enable_postprocessor enable_https with_gnutls with_libgcrypt_prefix enable_bauth enable_dauth enable_dauth_def_timeout enable_dauth_def_max_nc enable_httpupgrade enable_cookie enable_md5 enable_sha256 enable_sha512_256 enable_coverage enable_asserts enable_sanitizers enable_experimental ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP LT_SYS_LIBRARY_PATH PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR GNUTLS_CFLAGS GNUTLS_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures GNU libmicrohttpd 1.0.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/libmicrohttpd] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of GNU libmicrohttpd 1.0.1:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-build-type=TYPE enable build TYPE, a set of configuration parameters; individual settings (asserts, sanitizers, compiler and linker flags) can be overridden by additional configure parameters (debug, debugger, neutral, release, release-compact, release-hardened) [neutral] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-compact-code enable use of a reduced size version of the code, resulting in smaller binaries with a slight performance hit [auto] --enable-compiler-hardening enable compiler security checks --enable-linker-hardening enable linker security fixups --disable-thread-names do not set names on MHD generated threads [auto] --disable-doc do not build any documentation --disable-examples do not build any examples --disable-tools do not build testing and demo tools --enable-heavy-tests[=SCOPE] use SCOPE of heavy tests in test-suite. WARNING: a dedicated host with minimal number of background processes and no network activity is recommended to enable. (basic, full) --enable-poll[=ARG] enable poll support (yes, no, auto) [auto] --enable-epoll[=ARG] enable epoll support (yes, no, auto) [auto] --enable-itc=TYPE use TYPE of inter-thread communication (pipe, socketpair, eventfd) [auto] --disable-curl disable cURL based testcases --disable-largefile omit support for large files --disable-sendfile disable usage of sendfile() for HTTP connections [auto] --disable-messages disable error, warning messages and text bodies for automatic HTTP responses (to reduce the binary size) --disable-postprocessor disable MHD PostProcessor functionality --enable-https enable HTTPS support (yes, no, auto)[auto] --disable-bauth disable HTTP Basic Authentication support --disable-dauth disable HTTP Digest Authentication support --enable-dauth-def-timeout=NNN set default Digest Auth nonce validity time to NNN seconds --enable-dauth-def-max-nc=NNN set default Digest Auth maximum nc (nonce count) value to NNN --disable-httpupgrade disable HTTP "Upgrade" support --disable-cookie disable HTTP cookie parsing support --enable-md5=TYPE enable TYPE of MD5 hashing code (yes, no, builtin, tlslib) [yes if dauth enabled] --enable-sha256=TYPE enable TYPE of SHA-256 hashing code (yes, no, builtin, tlslib) [yes if dauth enabled] --disable-sha512-256 disable SHA-512/256 hashing support for Digest Authentication --enable-coverage compile the library with code coverage support --enable-asserts enable test build with debug asserts --enable-sanitizers[=address,undefined,leak,user-poison] enable run-time sanitizers, specify the list of types of sanitizers to enable, leave the list empty (or set to "auto") to enable all supported and available sanitizers, or specify "auto-fallback" to use sanitizers even without installed sanitizer run-time library --enable-experimental enable compiling experimental code Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-aix-soname=aix|svr4|both shared library versioning (aka "SONAME") variant to provide on AIX, [default=aix]. --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-threads=LIB choose threading library (posix, w32, auto, none) [auto] --with-libcurl=PREFIX look for the curl library in PREFIX/lib and headers in PREFIX/include --with-gnutls[=PFX] use GnuTLS for HTTPS support, optional PFX overrides pkg-config data for GnuTLS headers (PFX/include) and libs (PFX/lib) --with-libgcrypt-prefix=PFX prefix where LIBGCRYPT is installed (optional) Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor LT_SYS_LIBRARY_PATH User-defined run-time library search path. PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path GNUTLS_CFLAGS C compiler flags for GNUTLS, overriding pkg-config GNUTLS_LIBS linker flags for GNUTLS, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . GNU libmicrohttpd home page: . General help using GNU software: . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for configure.gnu first; this name is used for a wrapper for # Metaconfig's "Configure" on case-insensitive file systems. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF GNU libmicrohttpd configure 1.0.1 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (void); below. */ #include #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (void); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main (void) { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_check_decl LINENO SYMBOL VAR INCLUDES EXTRA-OPTIONS FLAG-VAR # ------------------------------------------------------------------ # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. Pass EXTRA-OPTIONS to the compiler, using FLAG-VAR. ac_fn_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 printf %s "checking whether $as_decl_name is declared... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` eval ac_save_FLAGS=\$$6 as_fn_append $6 " $5" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext eval $6=\$ac_save_FLAGS fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_check_decl # ac_fn_c_try_run LINENO # ---------------------- # Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that # executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: program exited with status $ac_status" >&5 printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_hi=$ac_mid; break else $as_nop as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_lo=$ac_mid; break else $as_nop as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done else $as_nop ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_hi=$ac_mid else $as_nop as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval (void) { return $2; } static unsigned long int ulongval (void) { return $2; } #include #include int main (void) { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO" then : echo >>conftest.val; read $3 &5 printf %s "checking for $2.$3... " >&6; } if eval test \${$4+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main (void) { static $2 ac_aggr; if (ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$4=yes" else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main (void) { static $2 ac_aggr; if (sizeof ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$4=yes" else $as_nop eval "$4=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$4 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member ac_configure_args_raw= for ac_arg do case $ac_arg in *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append ac_configure_args_raw " '$ac_arg'" done case $ac_configure_args_raw in *$as_nl*) ac_safe_unquote= ;; *) ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. ac_unsafe_a="$ac_unsafe_z#~" ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; esac cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by GNU libmicrohttpd $as_me 1.0.1, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac printf "%s\n" "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Sanitize IFS. IFS=" "" $as_nl" # Save into config.log some information that might help in debugging. { echo printf "%s\n" "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo printf "%s\n" "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then printf "%s\n" "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then printf "%s\n" "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && printf "%s\n" "$as_me: caught signal $ac_signal" printf "%s\n" "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h printf "%s\n" "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then ac_site_files="$CONFIG_SITE" elif test "x$prefix" != xNONE; then ac_site_files="$prefix/share/config.site $prefix/etc/config.site" else ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi for ac_site_file in $ac_site_files do case $ac_site_file in #( */*) : ;; #( *) : ac_site_file=./$ac_site_file ;; esac if test -f "$ac_site_file" && test -r "$ac_site_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 printf "%s\n" "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 printf "%s\n" "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Test code for whether the C compiler supports C89 (global declarations) ac_c_conftest_c89_globals=' /* Does the compiler advertise C89 conformance? Do not test the value of __STDC__, because some compilers set it to 0 while being otherwise adequately conformant. */ #if !defined __STDC__ # error "Compiler does not advertise C89 conformance" #endif #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ struct buf { int x; }; struct buf * (*rcsopen) (struct buf *, struct stat *, int); static char *e (char **p, int i) { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* C89 style stringification. */ #define noexpand_stringify(a) #a const char *stringified = noexpand_stringify(arbitrary+token=sequence); /* C89 style token pasting. Exercises some of the corner cases that e.g. old MSVC gets wrong, but not very hard. */ #define noexpand_concat(a,b) a##b #define expand_concat(a,b) noexpand_concat(a,b) extern int vA; extern int vbee; #define aye A #define bee B int *pvA = &expand_concat(v,aye); int *pvbee = &noexpand_concat(v,bee); /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not \xHH hex character constants. These do not provoke an error unfortunately, instead are silently treated as an "x". The following induces an error, until -std is added to get proper ANSI mode. Curiously \x00 != x always comes out true, for an array size at least. It is necessary to write \x00 == 0 to get something that is true only with -std. */ int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) '\''x'\'' int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), int, int);' # Test code for whether the C compiler supports C89 (body of main). ac_c_conftest_c89_main=' ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); ' # Test code for whether the C compiler supports C99 (global declarations) ac_c_conftest_c99_globals=' // Does the compiler advertise C99 conformance? #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L # error "Compiler does not advertise C99 conformance" #endif #include extern int puts (const char *); extern int printf (const char *, ...); extern int dprintf (int, const char *, ...); extern void *malloc (size_t); extern void free (void *); // Check varargs macros. These examples are taken from C99 6.10.3.5. // dprintf is used instead of fprintf to avoid needing to declare // FILE and stderr. #define debug(...) dprintf (2, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK #error "your preprocessor is broken" #endif #if BIG_OK #else #error "your preprocessor is broken" #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) continue; return 0; } // Check varargs and va_copy. static bool test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str = ""; int number = 0; float fnumber = 0; while (*format) { switch (*format++) { case '\''s'\'': // string str = va_arg (args_copy, const char *); break; case '\''d'\'': // int number = va_arg (args_copy, int); break; case '\''f'\'': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); return *str && number && fnumber; } ' # Test code for whether the C compiler supports C99 (body of main). ac_c_conftest_c99_main=' // Check bool. _Bool success = false; success |= (argc != 0); // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[0] = argv[0][0]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\'' || dynamic_array[ni.number - 1] != 543); ' # Test code for whether the C compiler supports C11 (global declarations) ac_c_conftest_c11_globals=' // Does the compiler advertise C11 conformance? #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L # error "Compiler does not advertise C11 conformance" #endif // Check _Alignas. char _Alignas (double) aligned_as_double; char _Alignas (0) no_special_alignment; extern char aligned_as_int; char _Alignas (0) _Alignas (int) aligned_as_int; // Check _Alignof. enum { int_alignment = _Alignof (int), int_array_alignment = _Alignof (int[100]), char_alignment = _Alignof (char) }; _Static_assert (0 < -_Alignof (int), "_Alignof is signed"); // Check _Noreturn. _Noreturn int does_not_return (void) { for (;;) continue; } // Check _Static_assert. struct test_static_assert { int x; _Static_assert (sizeof (int) <= sizeof (long int), "_Static_assert does not work in struct"); long int y; }; // Check UTF-8 literals. #define u8 syntax error! char const utf8_literal[] = u8"happens to be ASCII" "another string"; // Check duplicate typedefs. typedef long *long_ptr; typedef long int *long_ptr; typedef long_ptr long_ptr; // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. struct anonymous { union { struct { int i; int j; }; struct { int k; long int l; } w; }; int m; } v1; ' # Test code for whether the C compiler supports C11 (body of main). ac_c_conftest_c11_main=' _Static_assert ((offsetof (struct anonymous, i) == offsetof (struct anonymous, w.k)), "Anonymous union alignment botch"); v1.i = 2; v1.w.k = 5; ok |= v1.i != 5; ' # Test code for whether the C compiler supports C11 (complete). ac_c_conftest_c11_program="${ac_c_conftest_c89_globals} ${ac_c_conftest_c99_globals} ${ac_c_conftest_c11_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} ${ac_c_conftest_c99_main} ${ac_c_conftest_c11_main} return ok; } " # Test code for whether the C compiler supports C99 (complete). ac_c_conftest_c99_program="${ac_c_conftest_c89_globals} ${ac_c_conftest_c99_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} ${ac_c_conftest_c99_main} return ok; } " # Test code for whether the C compiler supports C89 (complete). ac_c_conftest_c89_program="${ac_c_conftest_c89_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} return ok; } " mhd_undef_all_extensions=" #ifdef _GNU_SOURCE #undef _GNU_SOURCE #endif #ifdef _XOPEN_SOURCE #undef _XOPEN_SOURCE #endif #ifdef _XOPEN_SOURCE_EXTENDED #undef _XOPEN_SOURCE_EXTENDED #endif #ifdef _XOPEN_VERSION #undef _XOPEN_VERSION #endif #ifdef _POSIX_C_SOURCE #undef _POSIX_C_SOURCE #endif #ifdef _POSIX_SOURCE #undef _POSIX_SOURCE #endif #ifdef _DEFAULT_SOURCE #undef _DEFAULT_SOURCE #endif #ifdef _BSD_SOURCE #undef _BSD_SOURCE #endif #ifdef _SVID_SOURCE #undef _SVID_SOURCE #endif #ifdef __EXTENSIONS__ #undef __EXTENSIONS__ #endif #ifdef _ALL_SOURCE #undef _ALL_SOURCE #endif #ifdef _TANDEM_SOURCE #undef _TANDEM_SOURCE #endif #ifdef _DARWIN_C_SOURCE #undef _DARWIN_C_SOURCE #endif #ifdef __BSD_VISIBLE #undef __BSD_VISIBLE #endif #ifdef _NETBSD_SOURCE #undef _NETBSD_SOURCE #endif " as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H" as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H" as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H" as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" as_fn_append ac_header_c_list " errno.h errno_h HAVE_ERRNO_H" as_fn_append ac_header_c_list " limits.h limits_h HAVE_LIMITS_H" as_fn_append ac_header_c_list " fcntl.h fcntl_h HAVE_FCNTL_H" # Auxiliary files required by this configure script. ac_aux_files="ltmain.sh compile config.guess config.sub missing install-sh" # Locations in which to look for auxiliary files. ac_aux_dir_candidates="${srcdir}/build-aux" # Search for a directory containing all of the required auxiliary files, # $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates. # If we don't find one directory that contains all the files we need, # we report the set of missing files from the *first* directory in # $ac_aux_dir_candidates and give up. ac_missing_aux_files="" ac_first_candidate=: printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in $ac_aux_dir_candidates do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac as_found=: printf "%s\n" "$as_me:${as_lineno-$LINENO}: trying $as_dir" >&5 ac_aux_dir_found=yes ac_install_sh= for ac_aux in $ac_aux_files do # As a special case, if "install-sh" is required, that requirement # can be satisfied by any of "install-sh", "install.sh", or "shtool", # and $ac_install_sh is set appropriately for whichever one is found. if test x"$ac_aux" = x"install-sh" then if test -f "${as_dir}install-sh"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install-sh found" >&5 ac_install_sh="${as_dir}install-sh -c" elif test -f "${as_dir}install.sh"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install.sh found" >&5 ac_install_sh="${as_dir}install.sh -c" elif test -f "${as_dir}shtool"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}shtool found" >&5 ac_install_sh="${as_dir}shtool install -c" else ac_aux_dir_found=no if $ac_first_candidate; then ac_missing_aux_files="${ac_missing_aux_files} install-sh" else break fi fi else if test -f "${as_dir}${ac_aux}"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}${ac_aux} found" >&5 else ac_aux_dir_found=no if $ac_first_candidate; then ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}" else break fi fi fi done if test "$ac_aux_dir_found" = yes; then ac_aux_dir="$as_dir" break fi ac_first_candidate=false as_found=false done IFS=$as_save_IFS if $as_found then : else $as_nop as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. if test -f "${ac_aux_dir}config.guess"; then ac_config_guess="$SHELL ${ac_aux_dir}config.guess" fi if test -f "${ac_aux_dir}config.sub"; then ac_config_sub="$SHELL ${ac_aux_dir}config.sub" fi if test -f "$ac_aux_dir/configure"; then ac_configure="$SHELL ${ac_aux_dir}configure" fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu MHD_AUX_DIR='build-aux' # Must be set to the same value as in the previous line ac_config_headers="$ac_config_headers MHD_config.h" LIB_VERSION_CURRENT=74 LIB_VERSION_REVISION=1 LIB_VERSION_AGE=62 PACKAGE_VERSION_MAJOR='1' PACKAGE_VERSION_MINOR='0' PACKAGE_VERSION_SUBMINOR='1' as_fn_arith $LIB_VERSION_CURRENT - $LIB_VERSION_AGE && MHD_W32_DLL_SUFF=$as_val ac_config_files="$ac_config_files src/microhttpd/microhttpd_dll_res.rc" MHD_LIB_CPPFLAGS="" MHD_LIB_CFLAGS="" MHD_LIB_LDFLAGS="" MHD_LIBDEPS="" # for pkg-config MHD_REQ_PRIVATE='' MHD_LIBDEPS_PKGCFG='' if test -z "$CC" && test -z "$CPP" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether z/OS special settings are required" >&5 printf %s "checking whether z/OS special settings are required... " >&6; } if test `uname -s` = "OS/390" then : # configure binaries for z/OS if test -z "$CC" then : CC=`pwd`"/contrib/xcc" chmod +x $CC || true fi if test -z "$CPP" then : CPP="c89 -E" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for build type" >&5 printf %s "checking for build type... " >&6; } # Check whether --enable-build-type was given. if test ${enable_build_type+y} then : enableval=$enable_build_type; else $as_nop enable_build_type=neutral fi if test "x${enable_build_type}" = "x" then : enable_build_type="neutral" fi if test "x$enable_build_type" = x"no" then : enable_build_type="neutral" fi if test "x$enable_build_type" = x"yes" then : as_fn_error $? "Missing TYPE for --enable-build-type=" "$LINENO" 5 fi case ${enable_build_type} in #( debug) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: debug. Defaults: enable asserts, sanitizers (if any supported), debug information, compiler optimisation for debugging" >&5 printf "%s\n" "debug. Defaults: enable asserts, sanitizers (if any supported), debug information, compiler optimisation for debugging" >&6; } ;; #( debugger) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: debugger. Defaults: enable asserts, disable sanitizers, debug information, no compiler optimisation, static lib" >&5 printf "%s\n" "debugger. Defaults: enable asserts, disable sanitizers, debug information, no compiler optimisation, static lib" >&6; } ;; #( neutral) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: neutral. Defaults: use only user-specified compiler and linker flags" >&5 printf "%s\n" "neutral. Defaults: use only user-specified compiler and linker flags" >&6; } ;; #( release) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: release. Defaults: disable asserts, enable compiler optimisations" >&5 printf "%s\n" "release. Defaults: disable asserts, enable compiler optimisations" >&6; } ;; #( release-compact) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: release-compact. Defaults: disable asserts, enable compiler optimisations for size, enable compact code" >&5 printf "%s\n" "release-compact. Defaults: disable asserts, enable compiler optimisations for size, enable compact code" >&6; } ;; #( release-hardened) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: release-hardened. Defaults: disable asserts, enable compiler optimisations, enable linker and compiler hardening" >&5 printf "%s\n" "release-hardened. Defaults: disable asserts, enable compiler optimisations, enable linker and compiler hardening" >&6; } ;; #( *) : as_fn_error $? "Unknown build type: ${enable_build_type}" "$LINENO" 5 ;; esac if test "x$enable_build_type" = x"neutral" then : : else $as_nop # For all non-neutral build types do not use automatic "-g -O2" for CFLAGS if test -z "${CFLAGS}" then : CFLAGS="" fi fi if test "x$enable_build_type" = x"debugger" then : # Build only static version unless something else is specified by the user if test -z "${enable_static}" || test "x${enable_static}" = "xyes" then : if test -z "${enable_shared}" then : enable_shared="no" enable_static="yes" fi else $as_nop case ${enable_static} in #( *libmicrohttpd*) : if test -z "${enable_shared}" then : enable_shared="no" fi ;; #( *) : ;; esac fi fi case ${enable_build_type} in #( debug|debugger) : if test -z "${enable_silent_rules}" then : enable_silent_rules="yes" fi ;; #( *) : ;; esac am__api_version='1.16' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 printf %s "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if test ${ac_cv_path_install+y} then : printf %s "(cached) " >&6 else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac # Account for fact that we put trailing slashes in our PATH walk. case $as_dir in #(( ./ | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir/" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test ${ac_cv_path_install+y}; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 printf "%s\n" "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 printf %s "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`printf "%s\n" "$program_transform_name" | sed "$ac_script"` # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 printf "%s\n" "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_STRIP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 printf "%s\n" "$STRIP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_STRIP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 printf "%s\n" "$ac_ct_STRIP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a race-free mkdir -p" >&5 printf %s "checking for a race-free mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if test ${ac_cv_path_mkdir+y} then : printf %s "(cached) " >&6 else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext" || continue case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir ('*'coreutils) '* | \ 'BusyBox '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test ${ac_cv_path_mkdir+y}; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 printf "%s\n" "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_AWK+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 printf "%s\n" "$AWK" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$AWK" && break done { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval test \${ac_cv_prog_make_${ac_make}_set+y} then : printf %s "(cached) " >&6 else $as_nop cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } SET_MAKE= else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test ${enable_silent_rules+y} then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 printf %s "checking whether $am_make supports nested variables... " >&6; } if test ${am_cv_make_support_nested_variables+y} then : printf %s "(cached) " >&6 else $as_nop if printf "%s\n" 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 printf "%s\n" "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='libmicrohttpd' VERSION='1.0.1' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h printf "%s\n" "#define VERSION \"$VERSION\"" >>confdefs.h # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # Variables for tags utilities; see am/tags.am if test -z "$CTAGS"; then CTAGS=ctags fi if test -z "$ETAGS"; then ETAGS=etags fi if test -z "$CSCOPE"; then CSCOPE=cscope fi # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi # Checks for programs. for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_AWK+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 printf "%s\n" "$AWK" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$AWK" && break done { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 printf %s "checking for grep that handles long lines and -e... " >&6; } if test ${ac_cv_path_GREP+y} then : printf %s "(cached) " >&6 else $as_nop if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in grep ggrep do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" printf "%s\n" 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 printf "%s\n" "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 printf %s "checking for fgrep... " >&6; } if test ${ac_cv_path_FGREP+y} then : printf %s "(cached) " >&6 else $as_nop if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in fgrep do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" printf "%s\n" 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 printf "%s\n" "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 printf %s "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 printf "%s\n" "no, using $LN_S" >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval test \${ac_cv_prog_make_${ac_make}_set+y} then : printf %s "(cached) " >&6 else $as_nop cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } SET_MAKE= else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi # Make sure we can run config.sub. $SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 printf %s "checking build system type... " >&6; } if test ${ac_cv_build+y} then : printf %s "(cached) " >&6 else $as_nop ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 printf "%s\n" "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 printf %s "checking host system type... " >&6; } if test ${ac_cv_host+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 printf "%s\n" "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Find C compiler and compiler options to support # the latest C standard (C11). Fallback to C99 and C89 # if later C versions are not supported. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. set dummy ${ac_tool_prefix}clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "clang", so it can be a program name with args. set dummy clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi fi test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion -version; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 printf %s "checking whether the C compiler works... " >&6; } ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else $as_nop ac_file='' fi if test -z "$ac_file" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 printf %s "checking for C compiler default output file name... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 printf "%s\n" "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 printf %s "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else $as_nop { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 printf "%s\n" "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 printf %s "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 printf "%s\n" "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 printf %s "checking for suffix of object files... " >&6; } if test ${ac_cv_objext+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 printf "%s\n" "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 printf %s "checking whether the compiler supports GNU C... " >&6; } if test ${ac_cv_c_compiler_gnu+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_compiler_gnu=yes else $as_nop ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } ac_compiler_gnu=$ac_cv_c_compiler_gnu if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+y} ac_save_CFLAGS=$CFLAGS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 printf %s "checking whether $CC accepts -g... " >&6; } if test ${ac_cv_prog_cc_g+y} then : printf %s "(cached) " >&6 else $as_nop ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes else $as_nop CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 printf "%s\n" "$ac_cv_prog_cc_g" >&6; } if test $ac_test_CFLAGS; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi ac_prog_cc_stdc=no if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 printf %s "checking for $CC option to enable C11 features... " >&6; } if test ${ac_cv_prog_cc_c11+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c11=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c11_program _ACEOF for ac_arg in '' -std=gnu11 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c11=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c11" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c11" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c11" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } CC="$CC $ac_cv_prog_cc_c11" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 ac_prog_cc_stdc=c11 fi fi if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 printf %s "checking for $CC option to enable C99 features... " >&6; } if test ${ac_cv_prog_cc_c99+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c99_program _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c99" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c99" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } CC="$CC $ac_cv_prog_cc_c99" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 ac_prog_cc_stdc=c99 fi fi if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 printf %s "checking for $CC option to enable C89 features... " >&6; } if test ${ac_cv_prog_cc_c89+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c89_program _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c89" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c89" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } CC="$CC $ac_cv_prog_cc_c89" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 ac_prog_cc_stdc=c89 fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 printf %s "checking whether $CC understands -c and -o together... " >&6; } if test ${am_cv_prog_cc_c_o+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 printf "%s\n" "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 printf %s "checking whether ${MAKE-make} supports the include directive... " >&6; } cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } case $?:`cat confinc.out 2>/dev/null` in #( '0:this is the am__doit target') : case $s in #( BSD) : am__include='.include' am__quote='"' ;; #( *) : am__include='include' am__quote='' ;; esac ;; #( *) : ;; esac if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 printf "%s\n" "${_am_result}" >&6; } # Check whether --enable-dependency-tracking was given. if test ${enable_dependency_tracking+y} then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 printf %s "checking dependency style of $depcc... " >&6; } if test ${am_cv_CC_dependencies_compiler_type+y} then : printf %s "(cached) " >&6 else $as_nop if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 printf "%s\n" "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi # Workaround for libgcrypt if test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x" then : SYSROOT="$lt_sysroot" fi user_CFLAGS="$CFLAGS" user_LDFLAGS="$LDFLAGS" user_CPPFLAGS="$CPPFLAGS" CFLAGS_ac="" LDFLAGS_ac="" CPPFLAGS_ac="" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 printf %s "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test ${ac_cv_prog_CPP+y} then : printf %s "(cached) " >&6 else $as_nop # Double quotes because $CC needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO" then : else $as_nop # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : # Broken: success on invalid input. continue else $as_nop # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 printf "%s\n" "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO" then : else $as_nop # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : # Broken: success on invalid input. continue else $as_nop # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok then : else $as_nop { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of stdio.h" >&5 printf %s "checking for presence of stdio.h... " >&6; } if test ${mhd_cv_header_stdio_h_present+y} then : printf %s "(cached) " >&6 else $as_nop cat > conftest.$ac_ext <<_ACEOF #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : mhd_cv_header_stdio_h_present="yes" else $as_nop mhd_cv_header_stdio_h_present="no" fi rm -f conftest.err conftest.i rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_header_stdio_h_present" >&5 printf "%s\n" "$mhd_cv_header_stdio_h_present" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of wchar.h" >&5 printf %s "checking for presence of wchar.h... " >&6; } if test ${mhd_cv_header_wchar_h_present+y} then : printf %s "(cached) " >&6 else $as_nop cat > conftest.$ac_ext <<_ACEOF #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : mhd_cv_header_wchar_h_present="yes" else $as_nop mhd_cv_header_wchar_h_present="no" fi rm -f conftest.err conftest.i rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_header_wchar_h_present" >&5 printf "%s\n" "$mhd_cv_header_wchar_h_present" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of stdlib.h" >&5 printf %s "checking for presence of stdlib.h... " >&6; } if test ${mhd_cv_header_stdlib_h_present+y} then : printf %s "(cached) " >&6 else $as_nop cat > conftest.$ac_ext <<_ACEOF #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : mhd_cv_header_stdlib_h_present="yes" else $as_nop mhd_cv_header_stdlib_h_present="no" fi rm -f conftest.err conftest.i rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_header_stdlib_h_present" >&5 printf "%s\n" "$mhd_cv_header_stdlib_h_present" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of string.h" >&5 printf %s "checking for presence of string.h... " >&6; } if test ${mhd_cv_header_string_h_present+y} then : printf %s "(cached) " >&6 else $as_nop cat > conftest.$ac_ext <<_ACEOF #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : mhd_cv_header_string_h_present="yes" else $as_nop mhd_cv_header_string_h_present="no" fi rm -f conftest.err conftest.i rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_header_string_h_present" >&5 printf "%s\n" "$mhd_cv_header_string_h_present" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of strings.h" >&5 printf %s "checking for presence of strings.h... " >&6; } if test ${mhd_cv_header_strings_h_present+y} then : printf %s "(cached) " >&6 else $as_nop cat > conftest.$ac_ext <<_ACEOF #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : mhd_cv_header_strings_h_present="yes" else $as_nop mhd_cv_header_strings_h_present="no" fi rm -f conftest.err conftest.i rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_header_strings_h_present" >&5 printf "%s\n" "$mhd_cv_header_strings_h_present" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of stdint.h" >&5 printf %s "checking for presence of stdint.h... " >&6; } if test ${mhd_cv_header_stdint_h_present+y} then : printf %s "(cached) " >&6 else $as_nop cat > conftest.$ac_ext <<_ACEOF #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : mhd_cv_header_stdint_h_present="yes" else $as_nop mhd_cv_header_stdint_h_present="no" fi rm -f conftest.err conftest.i rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_header_stdint_h_present" >&5 printf "%s\n" "$mhd_cv_header_stdint_h_present" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of fcntl.h" >&5 printf %s "checking for presence of fcntl.h... " >&6; } if test ${mhd_cv_header_fcntl_h_present+y} then : printf %s "(cached) " >&6 else $as_nop cat > conftest.$ac_ext <<_ACEOF #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : mhd_cv_header_fcntl_h_present="yes" else $as_nop mhd_cv_header_fcntl_h_present="no" fi rm -f conftest.err conftest.i rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_header_fcntl_h_present" >&5 printf "%s\n" "$mhd_cv_header_fcntl_h_present" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of sys/types.h" >&5 printf %s "checking for presence of sys/types.h... " >&6; } if test ${mhd_cv_header_sys_types_h_present+y} then : printf %s "(cached) " >&6 else $as_nop cat > conftest.$ac_ext <<_ACEOF #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : mhd_cv_header_sys_types_h_present="yes" else $as_nop mhd_cv_header_sys_types_h_present="no" fi rm -f conftest.err conftest.i rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_header_sys_types_h_present" >&5 printf "%s\n" "$mhd_cv_header_sys_types_h_present" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of time.h" >&5 printf %s "checking for presence of time.h... " >&6; } if test ${mhd_cv_header_time_h_present+y} then : printf %s "(cached) " >&6 else $as_nop cat > conftest.$ac_ext <<_ACEOF #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : mhd_cv_header_time_h_present="yes" else $as_nop mhd_cv_header_time_h_present="no" fi rm -f conftest.err conftest.i rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_header_time_h_present" >&5 printf "%s\n" "$mhd_cv_header_time_h_present" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for presence of unistd.h" >&5 printf %s "checking for presence of unistd.h... " >&6; } if test ${mhd_cv_header_unistd_h_present+y} then : printf %s "(cached) " >&6 else $as_nop cat > conftest.$ac_ext <<_ACEOF #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : mhd_cv_header_unistd_h_present="yes" else $as_nop mhd_cv_header_unistd_h_present="no" fi rm -f conftest.err conftest.i rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_header_unistd_h_present" >&5 printf "%s\n" "$mhd_cv_header_unistd_h_present" >&6; } if test -z "$mhd_basic_headers_includes" then : if test "x$mhd_cv_header_stdio_h_present" = x"yes" then : mhd_basic_headers_includes="\ #include " else $as_nop mhd_basic_headers_includes="" fi if test "x$mhd_cv_header_sys_types_h_present" = x"yes" then : mhd_basic_headers_includes="${mhd_basic_headers_includes}\ #include " fi if test "x$mhd_cv_header_wchar_h_present" = x"yes" then : mhd_basic_headers_includes="${mhd_basic_headers_includes}\ #include " fi if test "x$mhd_cv_header_stdlib_h_present" = x"yes" then : mhd_basic_headers_includes="${mhd_basic_headers_includes}\ #include " fi if test "x$mhd_cv_header_string_h_present" = x"yes" then : mhd_basic_headers_includes="${mhd_basic_headers_includes}\ #include " fi if test "x$mhd_cv_header_strings_h_present" = x"yes" then : mhd_basic_headers_includes="${mhd_basic_headers_includes}\ #include " fi if test "x$mhd_cv_header_stdint_h_present" = x"yes" then : mhd_basic_headers_includes="${mhd_basic_headers_includes}\ #include " fi if test "x$mhd_cv_header_fcntl_h_present" = x"yes" then : mhd_basic_headers_includes="${mhd_basic_headers_includes}\ #include " fi if test "x$mhd_cv_header_time_h_present" = x"yes" then : mhd_basic_headers_includes="${mhd_basic_headers_includes}\ #include " fi if test "x$mhd_cv_header_unistd_h_present" = x"yes" then : mhd_basic_headers_includes="${mhd_basic_headers_includes}\ #include " fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu mhd_mse_sys_ext_defines="" mhd_mse_sys_ext_flags="" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _GNU_SOURCE is already defined" >&5 printf %s "checking whether _GNU_SOURCE is already defined... " >&6; } if test ${mhd_cv_macro__gnu_source_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef _GNU_SOURCE #error _GNU_SOURCE is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__gnu_source_defined="yes" else $as_nop mhd_cv_macro__gnu_source_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__gnu_source_defined" >&5 printf "%s\n" "$mhd_cv_macro__gnu_source_defined" >&6; } if test "x$mhd_cv_macro__gnu_source_defined" = x"yes" then : mhd_cv_macro_add__gnu_source="no" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept _GNU_SOURCE" >&5 printf %s "checking whether headers accept _GNU_SOURCE... " >&6; } if test ${mhd_cv_define__gnu_source_accepted+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define _GNU_SOURCE 1 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define__gnu_source_accepted="yes" else $as_nop mhd_cv_define__gnu_source_accepted="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define__gnu_source_accepted" >&5 printf "%s\n" "$mhd_cv_define__gnu_source_accepted" >&6; } if test "x$mhd_cv_define__gnu_source_accepted" = x"yes" then : mhd_cv_macro_add__gnu_source="yes" else $as_nop mhd_cv_macro_add__gnu_source="no" fi fi if test "x$mhd_cv_macro_add__gnu_source" = x"yes" then : mhd_mse_sys_ext_defines="${mhd_mse_sys_ext_defines}#define _GNU_SOURCE 1 " if test "x${mhd_mse_sys_ext_flags}" = "x" then : mhd_mse_sys_ext_flags="_GNU_SOURCE" else $as_nop mhd_mse_sys_ext_flags="${mhd_mse_sys_ext_flags} _GNU_SOURCE" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to try __BSD_VISIBLE macro" >&5 printf %s "checking whether to try __BSD_VISIBLE macro... " >&6; } if test ${mhd_cv_macro_try___bsd_visible+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Warning: test with inverted logic! */ #ifdef __FreeBSD__ #error Target FreeBSD choke me now; #endif /* __FreeBSD__ */ #ifdef __ANDROID__ #include #ifndef __ANDROID_API_O__ #error Target is Android NDK before R14 choke me now; #endif /* ! __ANDROID_API_O__ */ #endif /* __ANDROID__ */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro_try___bsd_visible="no" else $as_nop mhd_cv_macro_try___bsd_visible="yes" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_try___bsd_visible" >&5 printf "%s\n" "$mhd_cv_macro_try___bsd_visible" >&6; } if test "x$mhd_cv_macro_try___bsd_visible" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether __BSD_VISIBLE is already defined" >&5 printf %s "checking whether __BSD_VISIBLE is already defined... " >&6; } if test ${mhd_cv_macro___bsd_visible_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} /* Warning: test with inverted logic! */ #ifdef __BSD_VISIBLE #error __BSD_VISIBLE is defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro___bsd_visible_defined="no" else $as_nop mhd_cv_macro___bsd_visible_defined="yes" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro___bsd_visible_defined" >&5 printf "%s\n" "$mhd_cv_macro___bsd_visible_defined" >&6; } if test "x$mhd_cv_macro___bsd_visible_defined" = x"yes" then : : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept __BSD_VISIBLE" >&5 printf %s "checking whether headers accept __BSD_VISIBLE... " >&6; } if test ${mhd_cv_define___bsd_visible_accepted+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define __BSD_VISIBLE 1 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define___bsd_visible_accepted="yes" else $as_nop mhd_cv_define___bsd_visible_accepted="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define___bsd_visible_accepted" >&5 printf "%s\n" "$mhd_cv_define___bsd_visible_accepted" >&6; } if test "x$mhd_cv_define___bsd_visible_accepted" = x"yes" then : mhd_mse_sys_ext_defines="${mhd_mse_sys_ext_defines}#define __BSD_VISIBLE 1 " if test "x${mhd_mse_sys_ext_flags}" = "x" then : mhd_mse_sys_ext_flags="__BSD_VISIBLE" else $as_nop mhd_mse_sys_ext_flags="${mhd_mse_sys_ext_flags} __BSD_VISIBLE" fi fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to try _DARWIN_C_SOURCE macro" >&5 printf %s "checking whether to try _DARWIN_C_SOURCE macro... " >&6; } if test ${mhd_cv_macro___apple___defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef __APPLE__ #error __APPLE__ is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro___apple___defined="yes" else $as_nop mhd_cv_macro___apple___defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro___apple___defined" >&5 printf "%s\n" "$mhd_cv_macro___apple___defined" >&6; } if test "x$mhd_cv_macro___apple___defined" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _DARWIN_C_SOURCE is already defined" >&5 printf %s "checking whether _DARWIN_C_SOURCE is already defined... " >&6; } if test ${mhd_cv_macro__darwin_c_source_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef _DARWIN_C_SOURCE #error _DARWIN_C_SOURCE is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__darwin_c_source_defined="yes" else $as_nop mhd_cv_macro__darwin_c_source_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__darwin_c_source_defined" >&5 printf "%s\n" "$mhd_cv_macro__darwin_c_source_defined" >&6; } if test "x$mhd_cv_macro__darwin_c_source_defined" = x"yes" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept _DARWIN_C_SOURCE" >&5 printf %s "checking whether headers accept _DARWIN_C_SOURCE... " >&6; } if test ${mhd_cv_define__darwin_c_source_accepted+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define _DARWIN_C_SOURCE 1 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define__darwin_c_source_accepted="yes" else $as_nop mhd_cv_define__darwin_c_source_accepted="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define__darwin_c_source_accepted" >&5 printf "%s\n" "$mhd_cv_define__darwin_c_source_accepted" >&6; } if test "x$mhd_cv_define__darwin_c_source_accepted" = x"yes" then : mhd_mse_sys_ext_defines="${mhd_mse_sys_ext_defines}#define _DARWIN_C_SOURCE 1 " if test "x${mhd_mse_sys_ext_flags}" = "x" then : mhd_mse_sys_ext_flags="_DARWIN_C_SOURCE" else $as_nop mhd_mse_sys_ext_flags="${mhd_mse_sys_ext_flags} _DARWIN_C_SOURCE" fi fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to try __EXTENSIONS__ macro" >&5 printf %s "checking whether to try __EXTENSIONS__ macro... " >&6; } if test ${mhd_cv_macro___sun_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef __sun #error __sun is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro___sun_defined="yes" else $as_nop mhd_cv_macro___sun_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro___sun_defined" >&5 printf "%s\n" "$mhd_cv_macro___sun_defined" >&6; } if test "x$mhd_cv_macro___sun_defined" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether __EXTENSIONS__ is already defined" >&5 printf %s "checking whether __EXTENSIONS__ is already defined... " >&6; } if test ${mhd_cv_macro___extensions___defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef __EXTENSIONS__ #error __EXTENSIONS__ is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro___extensions___defined="yes" else $as_nop mhd_cv_macro___extensions___defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro___extensions___defined" >&5 printf "%s\n" "$mhd_cv_macro___extensions___defined" >&6; } if test "x$mhd_cv_macro___extensions___defined" = x"yes" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept __EXTENSIONS__" >&5 printf %s "checking whether headers accept __EXTENSIONS__... " >&6; } if test ${mhd_cv_define___extensions___accepted+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define __EXTENSIONS__ 1 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define___extensions___accepted="yes" else $as_nop mhd_cv_define___extensions___accepted="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define___extensions___accepted" >&5 printf "%s\n" "$mhd_cv_define___extensions___accepted" >&6; } if test "x$mhd_cv_define___extensions___accepted" = x"yes" then : mhd_mse_sys_ext_defines="${mhd_mse_sys_ext_defines}#define __EXTENSIONS__ 1 " if test "x${mhd_mse_sys_ext_flags}" = "x" then : mhd_mse_sys_ext_flags="__EXTENSIONS__" else $as_nop mhd_mse_sys_ext_flags="${mhd_mse_sys_ext_flags} __EXTENSIONS__" fi fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to try _NETBSD_SOURCE macro" >&5 printf %s "checking whether to try _NETBSD_SOURCE macro... " >&6; } if test ${mhd_cv_macro___netbsd___defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef __NetBSD__ #error __NetBSD__ is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro___netbsd___defined="yes" else $as_nop mhd_cv_macro___netbsd___defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro___netbsd___defined" >&5 printf "%s\n" "$mhd_cv_macro___netbsd___defined" >&6; } if test "x$mhd_cv_macro___netbsd___defined" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _NETBSD_SOURCE is already defined" >&5 printf %s "checking whether _NETBSD_SOURCE is already defined... " >&6; } if test ${mhd_cv_macro__netbsd_source_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef _NETBSD_SOURCE #error _NETBSD_SOURCE is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__netbsd_source_defined="yes" else $as_nop mhd_cv_macro__netbsd_source_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__netbsd_source_defined" >&5 printf "%s\n" "$mhd_cv_macro__netbsd_source_defined" >&6; } if test "x$mhd_cv_macro__netbsd_source_defined" = x"yes" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept _NETBSD_SOURCE" >&5 printf %s "checking whether headers accept _NETBSD_SOURCE... " >&6; } if test ${mhd_cv_define__netbsd_source_accepted+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define _NETBSD_SOURCE 1 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define__netbsd_source_accepted="yes" else $as_nop mhd_cv_define__netbsd_source_accepted="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define__netbsd_source_accepted" >&5 printf "%s\n" "$mhd_cv_define__netbsd_source_accepted" >&6; } if test "x$mhd_cv_define__netbsd_source_accepted" = x"yes" then : mhd_mse_sys_ext_defines="${mhd_mse_sys_ext_defines}#define _NETBSD_SOURCE 1 " if test "x${mhd_mse_sys_ext_flags}" = "x" then : mhd_mse_sys_ext_flags="_NETBSD_SOURCE" else $as_nop mhd_mse_sys_ext_flags="${mhd_mse_sys_ext_flags} _NETBSD_SOURCE" fi fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to try _BSD_SOURCE macro" >&5 printf %s "checking whether to try _BSD_SOURCE macro... " >&6; } if test ${mhd_cv_macro___openbsd___defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef __OpenBSD__ #error __OpenBSD__ is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro___openbsd___defined="yes" else $as_nop mhd_cv_macro___openbsd___defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro___openbsd___defined" >&5 printf "%s\n" "$mhd_cv_macro___openbsd___defined" >&6; } if test "x$mhd_cv_macro___openbsd___defined" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _BSD_SOURCE is already defined" >&5 printf %s "checking whether _BSD_SOURCE is already defined... " >&6; } if test ${mhd_cv_macro__bsd_source_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef _BSD_SOURCE #error _BSD_SOURCE is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__bsd_source_defined="yes" else $as_nop mhd_cv_macro__bsd_source_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__bsd_source_defined" >&5 printf "%s\n" "$mhd_cv_macro__bsd_source_defined" >&6; } if test "x$mhd_cv_macro__bsd_source_defined" = x"yes" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept _BSD_SOURCE" >&5 printf %s "checking whether headers accept _BSD_SOURCE... " >&6; } if test ${mhd_cv_define__bsd_source_accepted+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define _BSD_SOURCE 1 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define__bsd_source_accepted="yes" else $as_nop mhd_cv_define__bsd_source_accepted="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define__bsd_source_accepted" >&5 printf "%s\n" "$mhd_cv_define__bsd_source_accepted" >&6; } if test "x$mhd_cv_define__bsd_source_accepted" = x"yes" then : mhd_mse_sys_ext_defines="${mhd_mse_sys_ext_defines}#define _BSD_SOURCE 1 " if test "x${mhd_mse_sys_ext_flags}" = "x" then : mhd_mse_sys_ext_flags="_BSD_SOURCE" else $as_nop mhd_mse_sys_ext_flags="${mhd_mse_sys_ext_flags} _BSD_SOURCE" fi fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to try _TANDEM_SOURCE macro" >&5 printf %s "checking whether to try _TANDEM_SOURCE macro... " >&6; } if test ${mhd_cv_macro___tandem_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef __TANDEM #error __TANDEM is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro___tandem_defined="yes" else $as_nop mhd_cv_macro___tandem_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro___tandem_defined" >&5 printf "%s\n" "$mhd_cv_macro___tandem_defined" >&6; } if test "x$mhd_cv_macro___tandem_defined" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _TANDEM_SOURCE is already defined" >&5 printf %s "checking whether _TANDEM_SOURCE is already defined... " >&6; } if test ${mhd_cv_macro__tandem_source_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef _TANDEM_SOURCE #error _TANDEM_SOURCE is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__tandem_source_defined="yes" else $as_nop mhd_cv_macro__tandem_source_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__tandem_source_defined" >&5 printf "%s\n" "$mhd_cv_macro__tandem_source_defined" >&6; } if test "x$mhd_cv_macro__tandem_source_defined" = x"yes" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept _TANDEM_SOURCE" >&5 printf %s "checking whether headers accept _TANDEM_SOURCE... " >&6; } if test ${mhd_cv_define__tandem_source_accepted+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define _TANDEM_SOURCE 1 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define__tandem_source_accepted="yes" else $as_nop mhd_cv_define__tandem_source_accepted="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define__tandem_source_accepted" >&5 printf "%s\n" "$mhd_cv_define__tandem_source_accepted" >&6; } if test "x$mhd_cv_define__tandem_source_accepted" = x"yes" then : mhd_mse_sys_ext_defines="${mhd_mse_sys_ext_defines}#define _TANDEM_SOURCE 1 " if test "x${mhd_mse_sys_ext_flags}" = "x" then : mhd_mse_sys_ext_flags="_TANDEM_SOURCE" else $as_nop mhd_mse_sys_ext_flags="${mhd_mse_sys_ext_flags} _TANDEM_SOURCE" fi fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to try _ALL_SOURCE macro" >&5 printf %s "checking whether to try _ALL_SOURCE macro... " >&6; } if test ${mhd_cv_macro_try__all_source+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if !defined(__TOS_MVS__) && !defined (__INTERIX) #error Target is not z/OS, AIX or Interix choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro_try__all_source="yes" else $as_nop mhd_cv_macro_try__all_source="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_try__all_source" >&5 printf "%s\n" "$mhd_cv_macro_try__all_source" >&6; } if test "x$mhd_cv_macro_try__all_source" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _ALL_SOURCE is already defined" >&5 printf %s "checking whether _ALL_SOURCE is already defined... " >&6; } if test ${mhd_cv_macro__all_source_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef _ALL_SOURCE #error _ALL_SOURCE is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__all_source_defined="yes" else $as_nop mhd_cv_macro__all_source_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__all_source_defined" >&5 printf "%s\n" "$mhd_cv_macro__all_source_defined" >&6; } if test "x$mhd_cv_macro__all_source_defined" = x"yes" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept _ALL_SOURCE" >&5 printf %s "checking whether headers accept _ALL_SOURCE... " >&6; } if test ${mhd_cv_define__all_source_accepted+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define _ALL_SOURCE 1 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define__all_source_accepted="yes" else $as_nop mhd_cv_define__all_source_accepted="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define__all_source_accepted" >&5 printf "%s\n" "$mhd_cv_define__all_source_accepted" >&6; } if test "x$mhd_cv_define__all_source_accepted" = x"yes" then : mhd_mse_sys_ext_defines="${mhd_mse_sys_ext_defines}#define _ALL_SOURCE 1 " if test "x${mhd_mse_sys_ext_flags}" = "x" then : mhd_mse_sys_ext_flags="_ALL_SOURCE" else $as_nop mhd_mse_sys_ext_flags="${mhd_mse_sys_ext_flags} _ALL_SOURCE" fi fi fi fi mhd_mse_xopen_features="" mhd_mse_xopen_defines="" mhd_mse_xopen_flags="" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_SOURCE is already defined" >&5 printf %s "checking whether _XOPEN_SOURCE is already defined... " >&6; } if test ${mhd_cv_macro__xopen_source_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef _XOPEN_SOURCE #error _XOPEN_SOURCE is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__xopen_source_defined="yes" else $as_nop mhd_cv_macro__xopen_source_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__xopen_source_defined" >&5 printf "%s\n" "$mhd_cv_macro__xopen_source_defined" >&6; } if test "x$mhd_cv_macro__xopen_source_defined" = x"no" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking headers for POSIX.1-2008/SUSv4 features" >&5 printf %s "checking headers for POSIX.1-2008/SUSv4 features... " >&6; } if test ${mhd_cv_headers_posix2008+y} then : printf %s "(cached) " >&6 else $as_nop { mhd_cpsxfs_tmp_features_available=; unset mhd_cpsxfs_tmp_features_available;} { mhd_cpsxfs_tmp_extentions_allowed=; unset mhd_cpsxfs_tmp_extentions_allowed;} { mhd_cpsxfs_tmp_src_xopen_allowed=; unset mhd_cpsxfs_tmp_src_xopen_allowed;} { mhd_cpsxfs_tmp_features_disableable=; unset mhd_cpsxfs_tmp_features_disableable;} mhd_cpsxf_tmp_src_variable=" /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ /* Check will be passed if ALL features are available * and failed if ANY feature is not available. */ int main() { #ifndef stpncpy (void) stpncpy; #endif #ifndef strnlen (void) strnlen; #endif #if !defined(__NetBSD__) && !defined(__OpenBSD__) /* NetBSD and OpenBSD didn't implement wcsnlen() for some reason. */ #ifndef wcsnlen (void) wcsnlen; #endif #endif #ifdef __CYGWIN__ /* The only depend function on Cygwin, but missing on some other platforms */ #ifndef strndup (void) strndup; #endif #endif #ifndef __sun /* illumos forget to uncomment some _XPG7 macros. */ #ifndef renameat (void) renameat; #endif #ifndef getline (void) getline; #endif #endif /* ! __sun */ /* gmtime_r() becomes mandatory only in POSIX.1-2008. */ #ifndef gmtime_r (void) gmtime_r; #endif /* unsetenv() actually defined in POSIX.1-2001 so it * must be present with _XOPEN_SOURCE == 700 too. */ #ifndef unsetenv (void) unsetenv; #endif return 0; } " mhd_cpsxf_tmp_defs_variable=" ${mhd_mse_sys_ext_defines} " cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_undef_all_extensions $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with undefined all extensions and without _XOPEN_SOURCE" >&5 mhd_cpsxfs_tmp_features_available="yes" # VAR-FEATURES-AVAILABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 700 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions and with _XOPEN_SOURCE=700" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_undef_all_extensions #define _POSIX_C_SOURCE 1 #define _ANSI_SOURCE 1 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with disabled extensions, with _POSIX_C_SOURCE=1 and _ANSI_SOURCE=1" >&5 mhd_cpsxfs_tmp_features_disableable="no" # VAR-FEATURES-DISABLEABLE-YES_NO else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with disabled extensions, with _POSIX_C_SOURCE=1 and _ANSI_SOURCE=1" >&5 mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions and with _XOPEN_SOURCE=700" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="not allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions" >&5 mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 700 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE=700" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="required" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 700 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="not allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE=700" >&5 mhd_cpsxfs_tmp_extentions_allowed="not allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED mhd_cpsxfs_tmp_src_xopen_allowed="not allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with undefined all extensions and without _XOPEN_SOURCE" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions" >&5 mhd_cpsxfs_tmp_features_available="yes" # VAR-FEATURES-AVAILABLE-YES_NO mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work by default" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT by default" >&5 mhd_cpsxfs_tmp_extentions_allowed="required" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 700 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions and _XOPEN_SOURCE=700" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions and _XOPEN_SOURCE=700" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="not allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 700 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE=700" >&5 mhd_cpsxfs_tmp_features_available="yes" # VAR-FEATURES-AVAILABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="required" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 700 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE=700 and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE=700 and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="not allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE=700" >&5 mhd_cpsxfs_tmp_features_available="no" # VAR-FEATURES-AVAILABLE-YES_NO fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { mhd_cpsxf_tmp_defs_variable=; unset mhd_cpsxf_tmp_defs_variable;} { mhd_cpsxf_tmp_src_variable=; unset mhd_cpsxf_tmp_src_variable;} if test "x$mhd_cpsxfs_tmp_features_available" = x"yes" then : if test "x$mhd_cpsxfs_tmp_features_disableable" = x"yes" then : if test "x$mhd_cpsxfs_tmp_extentions_allowed" = x"required" then : if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"allowed" then : mhd_cv_headers_posix2008="available, activated by extension macro, works with _XOPEN_SOURCE=700" else $as_nop mhd_cv_headers_posix2008="available, activated by extension macro, does not work with _XOPEN_SOURCE=700" fi else $as_nop if test "x$mhd_cpsxfs_tmp_extentions_allowed" = x"allowed" then : if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"required" then : mhd_cv_headers_posix2008="available, activated by _XOPEN_SOURCE=700, works with extension macro" else $as_nop if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"allowed" then : mhd_cv_headers_posix2008="available, works with _XOPEN_SOURCE=700, works with extension macro" else $as_nop mhd_cv_headers_posix2008="available, works with extension macro, does not work with _XOPEN_SOURCE=700" fi fi else $as_nop if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"required" then : mhd_cv_headers_posix2008="available, activated by _XOPEN_SOURCE=700, does not work with extension macro" else $as_nop if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"allowed" then : mhd_cv_headers_posix2008="available, works with _XOPEN_SOURCE=700, does not work with extension macro" else $as_nop mhd_cv_headers_posix2008="available, does not work with _XOPEN_SOURCE=700, does not work with extension macro" fi fi fi fi else $as_nop mhd_cv_headers_posix2008="available, works always" fi else $as_nop mhd_cv_headers_posix2008="not available" fi { mhd_cpsxfs_tmp_features_disableable=; unset mhd_cpsxfs_tmp_features_disableable;} { mhd_cpsxfs_tmp_src_xopen_allowed=; unset mhd_cpsxfs_tmp_src_xopen_allowed;} { mhd_cpsxfs_tmp_extentions_allowed=; unset mhd_cpsxfs_tmp_extentions_allowed;} { mhd_cpsxfs_tmp_features_available=; unset mhd_cpsxfs_tmp_features_available;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_headers_posix2008" >&5 printf "%s\n" "$mhd_cv_headers_posix2008" >&6; } if `echo "${mhd_cv_headers_posix2008}" | $GREP '^available' >/dev/null 2>&1` then : if `echo "${mhd_cv_headers_posix2008}" | $FGREP 'does not work with _XOPEN_SOURCE' >/dev/null 2>&1` then : : else $as_nop mhd_mse_xopen_defines="${mhd_mse_xopen_defines}#define _XOPEN_SOURCE 700 " if test "x${mhd_mse_xopen_flags}" = "x" then : mhd_mse_xopen_flags="_XOPEN_SOURCE=700" else $as_nop mhd_mse_xopen_flags="${mhd_mse_xopen_flags} _XOPEN_SOURCE=700" fi fi mhd_mse_xopen_features="${mhd_cv_headers_posix2008}" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking headers for POSIX.1-2001/SUSv3 features" >&5 printf %s "checking headers for POSIX.1-2001/SUSv3 features... " >&6; } if test ${mhd_cv_headers_posix2001+y} then : printf %s "(cached) " >&6 else $as_nop { mhd_cpsxfs_tmp_features_available=; unset mhd_cpsxfs_tmp_features_available;} { mhd_cpsxfs_tmp_extentions_allowed=; unset mhd_cpsxfs_tmp_extentions_allowed;} { mhd_cpsxfs_tmp_src_xopen_allowed=; unset mhd_cpsxfs_tmp_src_xopen_allowed;} { mhd_cpsxfs_tmp_features_disableable=; unset mhd_cpsxfs_tmp_features_disableable;} mhd_cpsxf_tmp_src_variable=" /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ /* Check will be passed if ALL features are available * and failed if ANY feature is not available. */ int main() { #ifndef setenv (void) setenv; #endif #ifndef __NetBSD__ #ifndef vsscanf (void) vsscanf; #endif #endif /* Availability of next features varies, but they all must be present * on platform with support for _XOPEN_SOURCE = 600. */ /* vsnprintf() should be available with _XOPEN_SOURCE >= 500, but some platforms * provide it only with _POSIX_C_SOURCE >= 200112 (autodefined when * _XOPEN_SOURCE >= 600) where specification of vsnprintf() is aligned with * ISO C99 while others platforms defined it with even earlier standards. */ #ifndef vsnprintf (void) vsnprintf; #endif /* On platforms that prefer POSIX over X/Open, fseeko() is available * with _POSIX_C_SOURCE >= 200112 (autodefined when _XOPEN_SOURCE >= 600). * On other platforms it should be available with _XOPEN_SOURCE >= 500. */ #ifndef fseeko (void) fseeko; #endif /* F_GETOWN must be defined with _XOPEN_SOURCE >= 600, but some platforms * define it with _XOPEN_SOURCE >= 500. */ #ifndef F_GETOWN #error F_GETOWN is not defined choke me now; #endif return 0; } " mhd_cpsxf_tmp_defs_variable=" ${mhd_mse_sys_ext_defines} " cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_undef_all_extensions $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with undefined all extensions and without _XOPEN_SOURCE" >&5 mhd_cpsxfs_tmp_features_available="yes" # VAR-FEATURES-AVAILABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 600 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions and with _XOPEN_SOURCE=600" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_undef_all_extensions #define _POSIX_C_SOURCE 1 #define _ANSI_SOURCE 1 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with disabled extensions, with _POSIX_C_SOURCE=1 and _ANSI_SOURCE=1" >&5 mhd_cpsxfs_tmp_features_disableable="no" # VAR-FEATURES-DISABLEABLE-YES_NO else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with disabled extensions, with _POSIX_C_SOURCE=1 and _ANSI_SOURCE=1" >&5 mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions and with _XOPEN_SOURCE=600" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="not allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions" >&5 mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 600 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE=600" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="required" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 600 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="not allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE=600" >&5 mhd_cpsxfs_tmp_extentions_allowed="not allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED mhd_cpsxfs_tmp_src_xopen_allowed="not allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with undefined all extensions and without _XOPEN_SOURCE" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions" >&5 mhd_cpsxfs_tmp_features_available="yes" # VAR-FEATURES-AVAILABLE-YES_NO mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work by default" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT by default" >&5 mhd_cpsxfs_tmp_extentions_allowed="required" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 600 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions and _XOPEN_SOURCE=600" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions and _XOPEN_SOURCE=600" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="not allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 600 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE=600" >&5 mhd_cpsxfs_tmp_features_available="yes" # VAR-FEATURES-AVAILABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="required" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 600 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE=600 and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE=600 and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="not allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE=600" >&5 mhd_cpsxfs_tmp_features_available="no" # VAR-FEATURES-AVAILABLE-YES_NO fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { mhd_cpsxf_tmp_defs_variable=; unset mhd_cpsxf_tmp_defs_variable;} { mhd_cpsxf_tmp_src_variable=; unset mhd_cpsxf_tmp_src_variable;} if test "x$mhd_cpsxfs_tmp_features_available" = x"yes" then : if test "x$mhd_cpsxfs_tmp_features_disableable" = x"yes" then : if test "x$mhd_cpsxfs_tmp_extentions_allowed" = x"required" then : if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"allowed" then : mhd_cv_headers_posix2001="available, activated by extension macro, works with _XOPEN_SOURCE=600" else $as_nop mhd_cv_headers_posix2001="available, activated by extension macro, does not work with _XOPEN_SOURCE=600" fi else $as_nop if test "x$mhd_cpsxfs_tmp_extentions_allowed" = x"allowed" then : if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"required" then : mhd_cv_headers_posix2001="available, activated by _XOPEN_SOURCE=600, works with extension macro" else $as_nop if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"allowed" then : mhd_cv_headers_posix2001="available, works with _XOPEN_SOURCE=600, works with extension macro" else $as_nop mhd_cv_headers_posix2001="available, works with extension macro, does not work with _XOPEN_SOURCE=600" fi fi else $as_nop if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"required" then : mhd_cv_headers_posix2001="available, activated by _XOPEN_SOURCE=600, does not work with extension macro" else $as_nop if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"allowed" then : mhd_cv_headers_posix2001="available, works with _XOPEN_SOURCE=600, does not work with extension macro" else $as_nop mhd_cv_headers_posix2001="available, does not work with _XOPEN_SOURCE=600, does not work with extension macro" fi fi fi fi else $as_nop mhd_cv_headers_posix2001="available, works always" fi else $as_nop mhd_cv_headers_posix2001="not available" fi { mhd_cpsxfs_tmp_features_disableable=; unset mhd_cpsxfs_tmp_features_disableable;} { mhd_cpsxfs_tmp_src_xopen_allowed=; unset mhd_cpsxfs_tmp_src_xopen_allowed;} { mhd_cpsxfs_tmp_extentions_allowed=; unset mhd_cpsxfs_tmp_extentions_allowed;} { mhd_cpsxfs_tmp_features_available=; unset mhd_cpsxfs_tmp_features_available;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_headers_posix2001" >&5 printf "%s\n" "$mhd_cv_headers_posix2001" >&6; } if `echo "${mhd_cv_headers_posix2001}" | $GREP '^available' >/dev/null 2>&1` then : if `echo "${mhd_cv_headers_posix2001}" | $FGREP 'does not work with _XOPEN_SOURCE' >/dev/null 2>&1` then : : else $as_nop mhd_mse_xopen_defines="${mhd_mse_xopen_defines}#define _XOPEN_SOURCE 600 " if test "x${mhd_mse_xopen_flags}" = "x" then : mhd_mse_xopen_flags="_XOPEN_SOURCE=600" else $as_nop mhd_mse_xopen_flags="${mhd_mse_xopen_flags} _XOPEN_SOURCE=600" fi fi mhd_mse_xopen_features="${mhd_cv_headers_posix2001}" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking headers for SUSv2/XPG5 features" >&5 printf %s "checking headers for SUSv2/XPG5 features... " >&6; } if test ${mhd_cv_headers_susv2+y} then : printf %s "(cached) " >&6 else $as_nop { mhd_cpsxfs_tmp_features_available=; unset mhd_cpsxfs_tmp_features_available;} { mhd_cpsxfs_tmp_extentions_allowed=; unset mhd_cpsxfs_tmp_extentions_allowed;} { mhd_cpsxfs_tmp_src_xopen_allowed=; unset mhd_cpsxfs_tmp_src_xopen_allowed;} { mhd_cpsxfs_tmp_features_disableable=; unset mhd_cpsxfs_tmp_features_disableable;} mhd_cpsxf_tmp_src_variable=" /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ /* Check will be passed if ALL features are available * and failed if ANY feature is not available. */ int main() { /* It's not easy to write reliable test for _XOPEN_SOURCE = 500 as * platforms not always precisely follow this standard and some * functions are already deprecated in later standards. */ /* Availability of next features varies, but they all must be present * on platform with correct support for _XOPEN_SOURCE = 500. */ /* Mandatory with _XOPEN_SOURCE >= 500 but as XSI extension available * with much older standards. */ #ifndef ftruncate (void) ftruncate; #endif /* Added with _XOPEN_SOURCE >= 500 but was available in some standards * before. XSI extension. */ #ifndef pread (void) pread; #endif #ifndef __APPLE__ /* Actually comes from XPG4v2 and must be available * with _XOPEN_SOURCE >= 500 as well. */ #ifndef symlink (void) symlink; #endif /* Actually comes from XPG4v2 and must be available * with _XOPEN_SOURCE >= 500 as well. XSI extension. */ #ifndef strdup (void) strdup; #endif #endif /* ! __APPLE__ */ return 0; } " mhd_cpsxf_tmp_defs_variable=" ${mhd_mse_sys_ext_defines} " cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_undef_all_extensions $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with undefined all extensions and without _XOPEN_SOURCE" >&5 mhd_cpsxfs_tmp_features_available="yes" # VAR-FEATURES-AVAILABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 500 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions and with _XOPEN_SOURCE=500" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_undef_all_extensions #define _POSIX_C_SOURCE 1 #define _ANSI_SOURCE 1 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with disabled extensions, with _POSIX_C_SOURCE=1 and _ANSI_SOURCE=1" >&5 mhd_cpsxfs_tmp_features_disableable="no" # VAR-FEATURES-DISABLEABLE-YES_NO else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with disabled extensions, with _POSIX_C_SOURCE=1 and _ANSI_SOURCE=1" >&5 mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions and with _XOPEN_SOURCE=500" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="not allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions" >&5 mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 500 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE=500" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="required" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 500 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="not allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE=500" >&5 mhd_cpsxfs_tmp_extentions_allowed="not allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED mhd_cpsxfs_tmp_src_xopen_allowed="not allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with undefined all extensions and without _XOPEN_SOURCE" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions" >&5 mhd_cpsxfs_tmp_features_available="yes" # VAR-FEATURES-AVAILABLE-YES_NO mhd_cpsxfs_tmp_features_disableable="yes" # VAR-FEATURES-DISABLEABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work by default" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT by default" >&5 mhd_cpsxfs_tmp_extentions_allowed="required" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 500 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with extensions and _XOPEN_SOURCE=500" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions and _XOPEN_SOURCE=500" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="not allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with extensions" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 500 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE=500" >&5 mhd_cpsxfs_tmp_features_available="yes" # VAR-FEATURES-AVAILABLE-YES_NO cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="allowed" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT by default" >&5 mhd_cpsxfs_tmp_src_xopen_allowed="required" # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $mhd_cpsxf_tmp_defs_variable #define _XOPEN_SOURCE 500 $mhd_cpsxf_tmp_src_variable _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features work with _XOPEN_SOURCE=500 and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE=500 and extensions" >&5 mhd_cpsxfs_tmp_extentions_allowed="not allowed" # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checked features DO NOT work with _XOPEN_SOURCE=500" >&5 mhd_cpsxfs_tmp_features_available="no" # VAR-FEATURES-AVAILABLE-YES_NO fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { mhd_cpsxf_tmp_defs_variable=; unset mhd_cpsxf_tmp_defs_variable;} { mhd_cpsxf_tmp_src_variable=; unset mhd_cpsxf_tmp_src_variable;} if test "x$mhd_cpsxfs_tmp_features_available" = x"yes" then : if test "x$mhd_cpsxfs_tmp_features_disableable" = x"yes" then : if test "x$mhd_cpsxfs_tmp_extentions_allowed" = x"required" then : if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"allowed" then : mhd_cv_headers_susv2="available, activated by extension macro, works with _XOPEN_SOURCE=500" else $as_nop mhd_cv_headers_susv2="available, activated by extension macro, does not work with _XOPEN_SOURCE=500" fi else $as_nop if test "x$mhd_cpsxfs_tmp_extentions_allowed" = x"allowed" then : if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"required" then : mhd_cv_headers_susv2="available, activated by _XOPEN_SOURCE=500, works with extension macro" else $as_nop if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"allowed" then : mhd_cv_headers_susv2="available, works with _XOPEN_SOURCE=500, works with extension macro" else $as_nop mhd_cv_headers_susv2="available, works with extension macro, does not work with _XOPEN_SOURCE=500" fi fi else $as_nop if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"required" then : mhd_cv_headers_susv2="available, activated by _XOPEN_SOURCE=500, does not work with extension macro" else $as_nop if test "x$mhd_cpsxfs_tmp_src_xopen_allowed" = x"allowed" then : mhd_cv_headers_susv2="available, works with _XOPEN_SOURCE=500, does not work with extension macro" else $as_nop mhd_cv_headers_susv2="available, does not work with _XOPEN_SOURCE=500, does not work with extension macro" fi fi fi fi else $as_nop mhd_cv_headers_susv2="available, works always" fi else $as_nop mhd_cv_headers_susv2="not available" fi { mhd_cpsxfs_tmp_features_disableable=; unset mhd_cpsxfs_tmp_features_disableable;} { mhd_cpsxfs_tmp_src_xopen_allowed=; unset mhd_cpsxfs_tmp_src_xopen_allowed;} { mhd_cpsxfs_tmp_extentions_allowed=; unset mhd_cpsxfs_tmp_extentions_allowed;} { mhd_cpsxfs_tmp_features_available=; unset mhd_cpsxfs_tmp_features_available;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_headers_susv2" >&5 printf "%s\n" "$mhd_cv_headers_susv2" >&6; } if `echo "${mhd_cv_headers_susv2}" | $GREP '^available' >/dev/null 2>&1` then : if `echo "${mhd_cv_headers_susv2}" | $FGREP 'does not work with _XOPEN_SOURCE' >/dev/null 2>&1` then : : else $as_nop mhd_mse_xopen_defines="${mhd_mse_xopen_defines}#define _XOPEN_SOURCE 500 " if test "x${mhd_mse_xopen_flags}" = "x" then : mhd_mse_xopen_flags="_XOPEN_SOURCE=500" else $as_nop mhd_mse_xopen_flags="${mhd_mse_xopen_flags} _XOPEN_SOURCE=500" fi fi mhd_mse_xopen_features="${mhd_cv_headers_susv2}" else $as_nop mhd_mse_xopen_features="${mhd_cv_headers_susv2}" fi fi fi fi if test "x${mhd_cv_macro__xopen_source_defined}" = "xno" && \ test "x${mhd_cv_macro__xopen_source_def_fiveh}" = "xno" || \ test "x${mhd_mse_xopen_features}" = "xnot available" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_SOURCE is already defined" >&5 printf %s "checking whether _XOPEN_SOURCE is already defined... " >&6; } if test ${mhd_cv_macro__xopen_source_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef _XOPEN_SOURCE #error _XOPEN_SOURCE is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__xopen_source_defined="yes" else $as_nop mhd_cv_macro__xopen_source_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__xopen_source_defined" >&5 printf "%s\n" "$mhd_cv_macro__xopen_source_defined" >&6; } if test "x$mhd_cv_macro__xopen_source_defined" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether predefined value of _XOPEN_SOURCE is more or equal 500" >&5 printf %s "checking whether predefined value of _XOPEN_SOURCE is more or equal 500... " >&6; } if test ${mhd_cv_macro__xopen_source_def_fiveh+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #if _XOPEN_SOURCE+0 < 500 #error Value of _XOPEN_SOURCE is less than 500 choke me now; #endif int main (void) { int i = 0; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__xopen_source_def_fiveh="yes" else $as_nop mhd_cv_macro__xopen_source_def_fiveh="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__xopen_source_def_fiveh" >&5 printf "%s\n" "$mhd_cv_macro__xopen_source_def_fiveh" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept _XOPEN_SOURCE with value 1" >&5 printf %s "checking whether headers accept _XOPEN_SOURCE with value 1... " >&6; } if test ${mhd_cv_define__xopen_source_accepted_1+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define _XOPEN_SOURCE 1 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define__xopen_source_accepted_1="yes" else $as_nop mhd_cv_define__xopen_source_accepted_1="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define__xopen_source_accepted_1" >&5 printf "%s\n" "$mhd_cv_define__xopen_source_accepted_1" >&6; } if test "x$mhd_cv_define__xopen_source_accepted_1" = x"yes" then : mhd_mse_xopen_defines="${mhd_mse_xopen_defines}#define _XOPEN_SOURCE 1 " if test "x${mhd_mse_xopen_flags}" = "x" then : mhd_mse_xopen_flags="_XOPEN_SOURCE=1" else $as_nop mhd_mse_xopen_flags="${mhd_mse_xopen_flags} _XOPEN_SOURCE=1" fi fi fi if test "x${mhd_cv_define__xopen_source_accepted_1}" = "xyes" || \ test "x${mhd_cv_macro__xopen_source_def_fiveh}" = "xno" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_SOURCE_EXTENDED is already defined" >&5 printf %s "checking whether _XOPEN_SOURCE_EXTENDED is already defined... " >&6; } if test ${mhd_cv_macro__xopen_source_extended_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef _XOPEN_SOURCE_EXTENDED #error _XOPEN_SOURCE_EXTENDED is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__xopen_source_extended_defined="yes" else $as_nop mhd_cv_macro__xopen_source_extended_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__xopen_source_extended_defined" >&5 printf "%s\n" "$mhd_cv_macro__xopen_source_extended_defined" >&6; } if test "x$mhd_cv_macro__xopen_source_extended_defined" = x"yes" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept _XOPEN_SOURCE_EXTENDED" >&5 printf %s "checking whether headers accept _XOPEN_SOURCE_EXTENDED... " >&6; } if test ${mhd_cv_define__xopen_source_extended_accepted+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define _XOPEN_SOURCE_EXTENDED 1 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define__xopen_source_extended_accepted="yes" else $as_nop mhd_cv_define__xopen_source_extended_accepted="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define__xopen_source_extended_accepted" >&5 printf "%s\n" "$mhd_cv_define__xopen_source_extended_accepted" >&6; } if test "x$mhd_cv_define__xopen_source_extended_accepted" = x"yes" then : mhd_mse_xopen_defines="${mhd_mse_xopen_defines}#define _XOPEN_SOURCE_EXTENDED 1 " if test "x${mhd_mse_xopen_flags}" = "x" then : mhd_mse_xopen_flags="_XOPEN_SOURCE_EXTENDED" else $as_nop mhd_mse_xopen_flags="${mhd_mse_xopen_flags} _XOPEN_SOURCE_EXTENDED" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_VERSION is already defined" >&5 printf %s "checking whether _XOPEN_VERSION is already defined... " >&6; } if test ${mhd_cv_macro__xopen_version_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #ifndef _XOPEN_VERSION #error _XOPEN_VERSION is not defined choke me now; #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro__xopen_version_defined="yes" else $as_nop mhd_cv_macro__xopen_version_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__xopen_version_defined" >&5 printf "%s\n" "$mhd_cv_macro__xopen_version_defined" >&6; } if test "x$mhd_cv_macro__xopen_version_defined" = x"yes" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for value of _XOPEN_VERSION accepted by headers" >&5 printf %s "checking for value of _XOPEN_VERSION accepted by headers... " >&6; } if test ${mhd_cv_define__xopen_version_accepted+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define _XOPEN_VERSION 4 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define__xopen_version_accepted="4" else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} #define _XOPEN_VERSION 3 /* Start of MHD basic test includes */ $mhd_basic_headers_includes /* End of MHD basic test includes */ int main (void) { int i = 1; i++; if(i) return i ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_define__xopen_version_accepted="3" else $as_nop mhd_cv_define__xopen_version_accepted="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_define__xopen_version_accepted" >&5 printf "%s\n" "$mhd_cv_define__xopen_version_accepted" >&6; } if test "x$mhd_cv_define__xopen_version_accepted" = x"no" then : : else $as_nop mhd_mse_xopen_defines="${mhd_mse_xopen_defines}#define _XOPEN_VERSION ${mhd_cv_define__xopen_version_accepted} " if test "x${mhd_mse_xopen_flags}" = "x" then : mhd_mse_xopen_flags="_XOPEN_VERSION=${mhd_cv_define__xopen_version_accepted}" else $as_nop mhd_mse_xopen_flags="${mhd_mse_xopen_flags} _XOPEN_VERSION=${mhd_cv_define__xopen_version_accepted}" fi fi fi fi fi fi fi mhd_mse_sys_features_src=" #ifdef __APPLE__ #include #else #error No useful system features. choke me now; #endif int main() { #ifdef __APPLE__ #ifndef sendfile (void) sendfile; #endif #endif return 0; } " { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for useful system-specific features" >&5 printf %s "checking for useful system-specific features... " >&6; } if test ${mhd_cv_headers_useful_features_present+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} ${mhd_mse_sys_features_src} _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_headers_useful_features_present="yes" else $as_nop mhd_cv_headers_useful_features_present="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_headers_useful_features_present" >&5 printf "%s\n" "$mhd_cv_headers_useful_features_present" >&6; } if test "x$mhd_cv_headers_useful_features_present" = x"yes" then : if test "x${mhd_mse_xopen_flags}" = "x" then : : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether useful system-specific features works with ${mhd_mse_xopen_flags}" >&5 printf %s "checking whether useful system-specific features works with ${mhd_mse_xopen_flags}... " >&6; } if test ${mhd_cv_headers_useful_features_works_xopen+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${mhd_mse_sys_ext_defines} ${mhd_mse_xopen_defines} ${mhd_mse_sys_features_src} _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_headers_useful_features_works_xopen="yes" else $as_nop mhd_cv_headers_useful_features_works_xopen="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_headers_useful_features_works_xopen" >&5 printf "%s\n" "$mhd_cv_headers_useful_features_works_xopen" >&6; } fi fi if test "x${mhd_cv_headers_useful_features_present}" = "xyes" && \ test "x${mhd_cv_headers_useful_features_works_xopen}" = "xno" && \ test "x${mhd_mse_xopen_flags}" != "x" then : if `echo "${mhd_mse_xopen_features}" | $FGREP ', activated by _XOPEN_SOURCE' >/dev/null 2>&1` then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: _XOPEN_SOURCE macro is required to activate all headers symbols, however some useful system-specific features does not work with _XOPEN_SOURCE. _XOPEN_SOURCE macro will not be used." >&5 printf "%s\n" "$as_me: WARNING: _XOPEN_SOURCE macro is required to activate all headers symbols, however some useful system-specific features does not work with _XOPEN_SOURCE. _XOPEN_SOURCE macro will not be used." >&2;} fi { mhd_mse_xopen_defines=; unset mhd_mse_xopen_defines;} { mhd_mse_xopen_flags=; unset mhd_mse_xopen_flags;} { mhd_mse_xopen_values=; unset mhd_mse_xopen_values;} fi { mhd_mse_sys_features_src=; unset mhd_mse_sys_features_src;} { mhd_mse_xopen_defines=; unset mhd_mse_xopen_defines;} { mhd_mse_sys_ext_defines=; unset mhd_mse_sys_ext_defines;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for final set of defined symbols" >&5 printf %s "checking for final set of defined symbols... " >&6; } for mhd_mse_Flag in ${mhd_mse_sys_ext_flags} ${mhd_mse_xopen_flags} do as_fn_append CPPFLAGS_ac " -D$mhd_mse_Flag" done { mhd_mse_Flag=; unset mhd_mse_Flag;} mhd_mse_result=`echo ${mhd_mse_sys_ext_flags} ${mhd_mse_xopen_flags}` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${mhd_mse_result}" >&5 printf "%s\n" "${mhd_mse_result}" >&6; } { mhd_mse_result=; unset mhd_mse_result;} { mhd_mse_xopen_flags=; unset mhd_mse_xopen_flags;} { mhd_mse_sys_ext_flags=; unset mhd_mse_sys_ext_flags;} ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" case `pwd` in *\ * | *\ *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 printf "%s\n" "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.7' macro_revision='2.4.7' ltmain=$ac_aux_dir/ltmain.sh # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 printf %s "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case $ECHO in printf*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: printf" >&5 printf "%s\n" "printf" >&6; } ;; print*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 printf "%s\n" "print -r" >&6; } ;; *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: cat" >&5 printf "%s\n" "cat" >&6; } ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 printf %s "checking for a sed that does not truncate output... " >&6; } if test ${ac_cv_path_SED+y} then : printf %s "(cached) " >&6 else $as_nop ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in sed gsed do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" printf "%s\n" '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 printf "%s\n" "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 printf %s "checking for egrep... " >&6; } if test ${ac_cv_path_EGREP+y} then : printf %s "(cached) " >&6 else $as_nop if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in egrep do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" printf "%s\n" 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 printf "%s\n" "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test ${with_gnu_ld+y} then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else $as_nop with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 printf %s "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 printf %s "checking for GNU ld... " >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 printf %s "checking for non-GNU ld... " >&6; } fi if test ${lt_cv_path_LD+y} then : printf %s "(cached) " >&6 else $as_nop if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 printf "%s\n" "$LD" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 printf %s "checking if the linker ($LD) is GNU ld... " >&6; } if test ${lt_cv_prog_gnu_ld+y} then : printf %s "(cached) " >&6 else $as_nop # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 printf %s "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if test ${lt_cv_path_NM+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | $SED '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | $SED '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 printf "%s\n" "$lt_cv_path_NM" >&6; } if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_DUMPBIN+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 printf "%s\n" "$DUMPBIN" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_DUMPBIN+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 printf "%s\n" "$ac_ct_DUMPBIN" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols -headers /dev/null 2>&1 | $SED '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 printf %s "checking the name lister ($NM) interface... " >&6; } if test ${lt_cv_nm_interface+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 printf "%s\n" "$lt_cv_nm_interface" >&6; } # find the maximum length of command line arguments { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 printf %s "checking the maximum length of command line arguments... " >&6; } if test ${lt_cv_sys_max_cmd_len+y} then : printf %s "(cached) " >&6 else $as_nop i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | msys* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | $SED 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n "$lt_cv_sys_max_cmd_len"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 printf "%s\n" "$lt_cv_sys_max_cmd_len" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5 printf "%s\n" "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 printf %s "checking how to convert $build file names to $host format... " >&6; } if test ${lt_cv_to_host_file_cmd+y} then : printf %s "(cached) " >&6 else $as_nop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* | *-*-msys* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* | *-*-msys* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* | *-*-msys* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 printf "%s\n" "$lt_cv_to_host_file_cmd" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 printf %s "checking how to convert $build file names to toolchain format... " >&6; } if test ${lt_cv_to_tool_file_cmd+y} then : printf %s "(cached) " >&6 else $as_nop #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 printf "%s\n" "$lt_cv_to_tool_file_cmd" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 printf %s "checking for $LD option to reload object files... " >&6; } if test ${lt_cv_ld_reload_flag+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_ld_reload_flag='-r' fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 printf "%s\n" "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | msys* | mingw* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi ;; darwin*) if test yes = "$GCC"; then reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}file", so it can be a program name with args. set dummy ${ac_tool_prefix}file; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_FILECMD+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$FILECMD"; then ac_cv_prog_FILECMD="$FILECMD" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_FILECMD="${ac_tool_prefix}file" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi FILECMD=$ac_cv_prog_FILECMD if test -n "$FILECMD"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $FILECMD" >&5 printf "%s\n" "$FILECMD" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_FILECMD"; then ac_ct_FILECMD=$FILECMD # Extract the first word of "file", so it can be a program name with args. set dummy file; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_FILECMD+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_FILECMD"; then ac_cv_prog_ac_ct_FILECMD="$ac_ct_FILECMD" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_FILECMD="file" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_FILECMD=$ac_cv_prog_ac_ct_FILECMD if test -n "$ac_ct_FILECMD"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FILECMD" >&5 printf "%s\n" "$ac_ct_FILECMD" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_FILECMD" = x; then FILECMD=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac FILECMD=$ac_ct_FILECMD fi else FILECMD="$ac_cv_prog_FILECMD" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_OBJDUMP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 printf "%s\n" "$OBJDUMP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_OBJDUMP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 printf "%s\n" "$ac_ct_OBJDUMP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 printf %s "checking how to recognize dependent libraries... " >&6; } if test ${lt_cv_deplibs_check_method+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='$FILECMD -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin* | msys*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|coff-arm|coff-arm64|coff-i386|coff-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly* | midnightbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=$FILECMD case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; os2*) lt_cv_deplibs_check_method=pass_all ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 printf "%s\n" "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_DLLTOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 printf "%s\n" "$DLLTOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_DLLTOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 printf "%s\n" "$ac_ct_DLLTOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 printf %s "checking how to associate runtime and link libraries... " >&6; } if test ${lt_cv_sharedlib_from_linklib_cmd+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | msys* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 printf "%s\n" "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_AR+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 printf "%s\n" "$AR" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_AR+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 printf "%s\n" "$ac_ct_AR" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} # Use ARFLAGS variable as AR's operation code to sync the variable naming with # Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have # higher priority because thats what people were doing historically (setting # ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS # variable obsoleted/removed. test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr} lt_ar_flags=$AR_FLAGS # Make AR_FLAGS overridable by 'make ARFLAGS='. Don't try to run-time override # by AR_FLAGS because that was never working and AR_FLAGS is about to die. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 printf %s "checking for archiver @FILE support... " >&6; } if test ${lt_cv_ar_at_file+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 printf "%s\n" "$lt_cv_ar_at_file" >&6; } if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_STRIP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 printf "%s\n" "$STRIP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_STRIP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 printf "%s\n" "$ac_ct_STRIP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_RANLIB+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 printf "%s\n" "$RANLIB" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_RANLIB+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 printf "%s\n" "$ac_ct_RANLIB" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 printf %s "checking command to parse $NM output from $compiler object... " >&6; } if test ${lt_cv_sys_global_symbol_pipe+y} then : printf %s "(cached) " >&6 else $as_nop # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | msys* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="$SED -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="$SED -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="$SED -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="$SED -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++ or ICC, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="$SED -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | $SED '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5 if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 printf "%s\n" "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 printf %s "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test ${with_sysroot+y} then : withval=$with_sysroot; else $as_nop with_sysroot=no fi lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | $SED -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 printf "%s\n" "$with_sysroot" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 printf "%s\n" "${lt_sysroot:-no}" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 printf %s "checking for a working dd... " >&6; } if test ${ac_cv_path_lt_DD+y} then : printf %s "(cached) " >&6 else $as_nop printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} if test -z "$lt_DD"; then ac_path_lt_DD_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in dd do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_lt_DD="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_lt_DD" || continue if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: fi $ac_path_lt_DD_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_lt_DD"; then : fi else ac_cv_path_lt_DD=$lt_DD fi rm -f conftest.i conftest2.i conftest.out fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 printf "%s\n" "$ac_cv_path_lt_DD" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 printf %s "checking how to truncate binary pipes... " >&6; } if test ${lt_cv_truncate_bin+y} then : printf %s "(cached) " >&6 else $as_nop printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 printf "%s\n" "$lt_cv_truncate_bin" >&6; } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # Check whether --enable-libtool-lock was given. if test ${enable_libtool_lock+y} then : enableval=$enable_libtool_lock; fi test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `$FILECMD conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test yes = "$lt_cv_prog_gnu_ld"; then case `$FILECMD conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `$FILECMD conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then emul=elf case `$FILECMD conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `$FILECMD conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `$FILECMD conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `$FILECMD conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `$FILECMD conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 printf %s "checking whether the C compiler needs -belf... " >&6; } if test ${lt_cv_cc_needs_belf+y} then : printf %s "(cached) " >&6 else $as_nop ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : lt_cv_cc_needs_belf=yes else $as_nop lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 printf "%s\n" "$lt_cv_cc_needs_belf" >&6; } if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `$FILECMD conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_MANIFEST_TOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 printf "%s\n" "$MANIFEST_TOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_MANIFEST_TOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 printf "%s\n" "$ac_ct_MANIFEST_TOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if test ${lt_cv_path_mainfest_tool+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; } if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_DSYMUTIL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 printf "%s\n" "$DSYMUTIL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_DSYMUTIL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 printf "%s\n" "$ac_ct_DSYMUTIL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_NMEDIT+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 printf "%s\n" "$NMEDIT" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_NMEDIT+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 printf "%s\n" "$ac_ct_NMEDIT" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_LIPO+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 printf "%s\n" "$LIPO" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_LIPO+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 printf "%s\n" "$ac_ct_LIPO" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_OTOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 printf "%s\n" "$OTOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_OTOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 printf "%s\n" "$ac_ct_OTOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_OTOOL64+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 printf "%s\n" "$OTOOL64" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_OTOOL64+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 printf "%s\n" "$ac_ct_OTOOL64" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 printf %s "checking for -single_module linker flag... " >&6; } if test ${lt_cv_apple_cc_single_mod+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 printf %s "checking for -exported_symbols_list linker flag... " >&6; } if test ${lt_cv_ld_exported_symbols_list+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : lt_cv_ld_exported_symbols_list=yes else $as_nop lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 printf "%s\n" "$lt_cv_ld_exported_symbols_list" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 printf %s "checking for -force_load linker flag... " >&6; } if test ${lt_cv_ld_force_load+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR $AR_FLAGS libconftest.a conftest.o" >&5 $AR $AR_FLAGS libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 printf "%s\n" "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) case $MACOSX_DEPLOYMENT_TARGET,$host in 10.[012],*|,*powerpc*-darwin[5-8]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; *) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } ac_header= ac_cache= for ac_item in $ac_header_c_list do if test $ac_cache; then ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then printf "%s\n" "#define $ac_item 1" >> confdefs.h fi ac_header= ac_cache= elif test $ac_header; then ac_cache=$ac_item else ac_header=$ac_item fi done if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes then : printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes then : printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h fi # Set options enable_win32_dll=yes case $host in *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_AS+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$AS"; then ac_cv_prog_AS="$AS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_AS="${ac_tool_prefix}as" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AS=$ac_cv_prog_AS if test -n "$AS"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 printf "%s\n" "$AS" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_AS"; then ac_ct_AS=$AS # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_AS+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_AS"; then ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AS="as" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AS=$ac_cv_prog_ac_ct_AS if test -n "$ac_ct_AS"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 printf "%s\n" "$ac_ct_AS" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_AS" = x; then AS="false" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AS=$ac_ct_AS fi else AS="$ac_cv_prog_AS" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_DLLTOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 printf "%s\n" "$DLLTOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_DLLTOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 printf "%s\n" "$ac_ct_DLLTOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_OBJDUMP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 printf "%s\n" "$OBJDUMP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_OBJDUMP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 printf "%s\n" "$ac_ct_OBJDUMP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi ;; esac test -z "$AS" && AS=as test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$OBJDUMP" && OBJDUMP=objdump enable_dlopen=no # Check whether --enable-shared was given. if test ${enable_shared+y} then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac else $as_nop enable_shared=yes fi # Check whether --enable-static was given. if test ${enable_static+y} then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac else $as_nop enable_static=yes fi # Check whether --with-pic was given. if test ${with_pic+y} then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac else $as_nop pic_mode=default fi # Check whether --enable-fast-install was given. if test ${enable_fast_install+y} then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac else $as_nop enable_fast_install=yes fi shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[5-9]*,yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 printf %s "checking which variant of shared library versioning to provide... " >&6; } # Check whether --with-aix-soname was given. if test ${with_aix_soname+y} then : withval=$with_aix_soname; case $withval in aix|svr4|both) ;; *) as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 ;; esac lt_cv_with_aix_soname=$with_aix_soname else $as_nop if test ${lt_cv_with_aix_soname+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_with_aix_soname=aix fi with_aix_soname=$lt_cv_with_aix_soname fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 printf "%s\n" "$with_aix_soname" >&6; } if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, # the AIX toolchain works better with OBJECT_MODE set (default 32). if test 64 = "${OBJECT_MODE-32}"; then shared_archive_member_spec=shr_64 else shared_archive_member_spec=shr fi fi ;; *) with_aix_soname=aix ;; esac # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 printf %s "checking for objdir... " >&6; } if test ${lt_cv_objdir+y} then : printf %s "(cached) " >&6 else $as_nop rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 printf "%s\n" "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir printf "%s\n" "#define LT_OBJDIR \"$lt_cv_objdir/\"" >>confdefs.h case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC and # ICC, which need '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o func_cc_basename $compiler cc_basename=$func_cc_basename_result # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 printf %s "checking for ${ac_tool_prefix}file... " >&6; } if test ${lt_cv_path_MAGIC_CMD+y} then : printf %s "(cached) " >&6 else $as_nop case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/${ac_tool_prefix}file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 printf "%s\n" "$MAGIC_CMD" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for file" >&5 printf %s "checking for file... " >&6; } if test ${lt_cv_path_MAGIC_CMD+y} then : printf %s "(cached) " >&6 else $as_nop case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 printf "%s\n" "$MAGIC_CMD" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC=$CC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test yes = "$GCC"; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 printf %s "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if test ${lt_cv_prog_compiler_rtti_exceptions+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 printf "%s\n" "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test yes = "$GCC"; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi lt_prog_compiler_pic='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | msys* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; esac ;; mingw* | cygwin* | msys* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # flang / f18. f95 an alias for gfortran or flang on Debian flang* | f18* | f95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | $SED 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 printf %s "checking for $compiler option to produce PIC... " >&6; } if test ${lt_cv_prog_compiler_pic+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if test ${lt_cv_prog_compiler_pic_works+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if test ${lt_cv_prog_compiler_static_works+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_static_works=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; } if test yes = "$lt_cv_prog_compiler_static_works"; then : else lt_prog_compiler_static= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test ${lt_cv_prog_compiler_c_o+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test ${lt_cv_prog_compiler_c_o+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 printf %s "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 printf "%s\n" "$hard_links" >&6; } if test no = "$hard_links"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | msys* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++ or Intel C++ Compiler. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' export_dynamic_flag_spec='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | msys* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='$wl--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' file_list_spec='@' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs=yes ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes file_list_spec='@' ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in tcc*) hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' export_dynamic_flag_spec='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test no = "$ld_shlibs"; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # traditional, no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. hardcode_direct=no hardcode_direct_absolute=no ;; esac if test yes = "$GCC"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi export_dynamic_flag_spec='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if test ${lt_cv_aix_libpath_+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if test ${lt_cv_aix_libpath_+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' $wl-bernotok' allow_undefined_flag=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | msys* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++ or Intel C++ Compiler. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl* | icl*) # Native MSVC or ICC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC and ICC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test yes = "$lt_cv_ld_force_load"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" archive_expsym_cmds="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" module_expsym_cmds="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly* | midnightbsd*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test yes = "$GCC"; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 printf %s "checking if $CC understands -b... " >&6; } if test ${lt_cv_prog_compiler__b+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler__b=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 printf "%s\n" "$lt_cv_prog_compiler__b" >&6; } if test yes = "$lt_cv_prog_compiler__b"; then archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 printf %s "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if test ${lt_cv_irix_exported_symbol+y} then : printf %s "(cached) " >&6 else $as_nop save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : lt_cv_irix_exported_symbol=yes else $as_nop lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } if test yes = "$lt_cv_irix_exported_symbol"; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi link_all_deplibs=no else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; linux*) case $cc_basename in tcc*) # Fabrice Bellard et al's Tiny C Compiler ld_shlibs=yes archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' ;; esac ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' else archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='$wl-rpath,$libdir' fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes file_list_spec='@' ;; osf3*) if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test yes = "$GCC"; then wlarc='$wl' archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='$wl-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='$wl-z,text' allow_undefined_flag='$wl-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='$wl-Blargedynsym' ;; esac fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 printf "%s\n" "$ld_shlibs" >&6; } test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 printf %s "checking whether -lc should be explicitly linked in... " >&6; } if test ${lt_cv_archive_cmds_need_lc+y} then : printf %s "(cached) " >&6 else $as_nop $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 printf "%s\n" "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 printf %s "checking dynamic linker characteristics... " >&6; } if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([A-Za-z]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a(lib.so.V)' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | msys* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin* | msys*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | $SED -e 's/^lib/msys-/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl* | *,icl*) # Native MSVC or ICC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin* | msys*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC and ICC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly* | midnightbsd*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. hardcode_libdir_flag_spec='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if test ${lt_cv_shlibpath_overrides_runpath+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 printf "%s\n" "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 printf %s "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test yes = "$hardcode_automatic"; then # We can hardcode non-existent directories. if test no != "$hardcode_direct" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && test no != "$hardcode_minus_L"; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 printf "%s\n" "$hardcode_action" >&6; } if test relink = "$hardcode_action" || test yes = "$inherit_rpath"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin* | msys*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 printf %s "checking for dlopen in -ldl... " >&6; } if test ${ac_cv_lib_dl_dlopen+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. The 'extern "C"' is for builds by C++ compilers; although this is not generally supported in C code supporting it here has little cost and some practical benefit (sr 110532). */ #ifdef __cplusplus extern "C" #endif char dlopen (void); int main (void) { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_dl_dlopen=yes else $as_nop ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else $as_nop lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes then : lt_cv_dlopen=shl_load else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 printf %s "checking for shl_load in -ldld... " >&6; } if test ${ac_cv_lib_dld_shl_load+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. The 'extern "C"' is for builds by C++ compilers; although this is not generally supported in C code supporting it here has little cost and some practical benefit (sr 110532). */ #ifdef __cplusplus extern "C" #endif char shl_load (void); int main (void) { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_dld_shl_load=yes else $as_nop ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes then : lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld else $as_nop ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes then : lt_cv_dlopen=dlopen else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 printf %s "checking for dlopen in -ldl... " >&6; } if test ${ac_cv_lib_dl_dlopen+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. The 'extern "C"' is for builds by C++ compilers; although this is not generally supported in C code supporting it here has little cost and some practical benefit (sr 110532). */ #ifdef __cplusplus extern "C" #endif char dlopen (void); int main (void) { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_dl_dlopen=yes else $as_nop ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 printf %s "checking for dlopen in -lsvld... " >&6; } if test ${ac_cv_lib_svld_dlopen+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. The 'extern "C"' is for builds by C++ compilers; although this is not generally supported in C code supporting it here has little cost and some practical benefit (sr 110532). */ #ifdef __cplusplus extern "C" #endif char dlopen (void); int main (void) { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_svld_dlopen=yes else $as_nop ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 printf "%s\n" "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 printf %s "checking for dld_link in -ldld... " >&6; } if test ${ac_cv_lib_dld_dld_link+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. The 'extern "C"' is for builds by C++ compilers; although this is not generally supported in C code supporting it here has little cost and some practical benefit (sr 110532). */ #ifdef __cplusplus extern "C" #endif char dld_link (void); int main (void) { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_dld_dld_link=yes else $as_nop ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 printf "%s\n" "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes then : lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi fi fi fi fi fi ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 printf %s "checking whether a program can dlopen itself... " >&6; } if test ${lt_cv_dlopen_self+y} then : printf %s "(cached) " >&6 else $as_nop if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 printf "%s\n" "$lt_cv_dlopen_self" >&6; } if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 printf %s "checking whether a statically linked program can dlopen itself... " >&6; } if test ${lt_cv_dlopen_self_static+y} then : printf %s "(cached) " >&6 else $as_nop if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 printf "%s\n" "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 printf %s "checking whether stripping libraries is possible... " >&6; } if test -z "$STRIP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } else if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then old_striplib="$STRIP --strip-debug" striplib="$STRIP --strip-unneeded" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else case $host_os in darwin*) # FIXME - insert some real tests, host_os isn't really good enough striplib="$STRIP -x" old_striplib="$STRIP -S" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } ;; freebsd*) if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then old_striplib="$STRIP --strip-debug" striplib="$STRIP --strip-unneeded" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi ;; *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } ;; esac fi fi # Report what library types will actually be built { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 printf %s "checking if libtool supports shared libraries... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 printf "%s\n" "$can_build_shared" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 printf %s "checking whether to build shared libraries... " >&6; } test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 printf "%s\n" "$enable_shared" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 printf %s "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 printf "%s\n" "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=$lt_save_CC ac_config_commands="$ac_config_commands libtool" # Only expand once: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. set dummy ${ac_tool_prefix}windres; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_RC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$RC"; then ac_cv_prog_RC="$RC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_RC="${ac_tool_prefix}windres" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RC=$ac_cv_prog_RC if test -n "$RC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RC" >&5 printf "%s\n" "$RC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_RC"; then ac_ct_RC=$RC # Extract the first word of "windres", so it can be a program name with args. set dummy windres; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_RC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_RC"; then ac_cv_prog_ac_ct_RC="$ac_ct_RC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RC="windres" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RC=$ac_cv_prog_ac_ct_RC if test -n "$ac_ct_RC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RC" >&5 printf "%s\n" "$ac_ct_RC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_RC" = x; then RC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RC=$ac_ct_RC fi else RC="$ac_cv_prog_RC" fi # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o objext_RC=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code=$lt_simple_compile_test_code # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC compiler_RC=$CC func_cc_basename $compiler cc_basename=$func_cc_basename_result lt_cv_prog_compiler_c_o_RC=yes if test -n "$compiler"; then : fi GCC=$lt_save_GCC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS # Check whether --enable-compact-code was given. if test ${enable_compact_code+y} then : enableval=$enable_compact_code; else $as_nop enable_compact_code=auto fi if test "x${enable_compact_code}" = "x" then : enable_compact_code="auto" fi { compact_code_MSG=; unset compact_code_MSG;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5 printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; } if test ${ac_cv_c_undeclared_builtin_options+y} then : printf %s "(cached) " >&6 else $as_nop ac_save_CFLAGS=$CFLAGS ac_cv_c_undeclared_builtin_options='cannot detect' for ac_arg in '' -fno-builtin; do CFLAGS="$ac_save_CFLAGS $ac_arg" # This test program should *not* compile successfully. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { (void) strchr; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop # This test program should compile successfully. # No library function is consistently available on # freestanding implementations, so test against a dummy # declaration. Include always-available headers on the # off chance that they somehow elicit warnings. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include extern void ac_decl (int, char *); int main (void) { (void) ac_decl (0, (char *) 0); (void) ac_decl; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : if test x"$ac_arg" = x then : ac_cv_c_undeclared_builtin_options='none needed' else $as_nop ac_cv_c_undeclared_builtin_options=$ac_arg fi break fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done CFLAGS=$ac_save_CFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5 printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; } case $ac_cv_c_undeclared_builtin_options in #( 'cannot detect') : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot make $CC report undeclared builtins See \`config.log' for more details" "$LINENO" 5; } ;; #( 'none needed') : ac_c_undeclared_builtin_options='' ;; #( *) : ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;; esac case ${enable_compact_code} in #( auto) : # Parameter not set. # Check preprocessor macros ac_fn_check_decl "$LINENO" "MHD_FAVOR_SMALL_CODE" "ac_cv_have_decl_MHD_FAVOR_SMALL_CODE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_MHD_FAVOR_SMALL_CODE" = xyes then : enable_compact_code="yes" compact_code_MSG="enabled by preprocessor macro" fi ac_fn_check_decl "$LINENO" "MHD_FAVOR_FAST_CODE" "ac_cv_have_decl_MHD_FAVOR_FAST_CODE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_MHD_FAVOR_FAST_CODE" = xyes then : if test "x$enable_compact_code" = x"yes" then : as_fn_error $? "Both MHD_FAVOR_SMALL_CODE and MHD_FAVOR_FAST_CODE macros are defined" "$LINENO" 5 fi enable_compact_code="no" compact_code_MSG="set by preprocessor macro" fi if test "x$enable_compact_code" = x"auto" then : # No preference by preprocessor macros { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether compiler is configured to optimize for size" >&5 printf %s "checking whether compiler is configured to optimize for size... " >&6; } if test ${mhd_cv_cc_optim_size+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __OPTIMIZE_SIZE__ #error Looks like compiler does not optimize for size choke me now #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_cc_optim_size="yes" else $as_nop mhd_cv_cc_optim_size="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_optim_size" >&5 printf "%s\n" "$mhd_cv_cc_optim_size" >&6; } if test "x$mhd_cv_cc_optim_size" = x"yes" then : enable_compact_code="yes" compact_code_MSG="enabled automatically as compiler optimizes for size" printf "%s\n" "#define MHD_FAVOR_SMALL_CODE 1" >>confdefs.h fi fi if test "x$enable_compact_code" = x"auto" then : # No preference by preprocessor macros and compiler flags case ${enable_build_type} in #( *-compact) : enable_compact_code="yes" compact_code_MSG="enabled by --enable-build-type=${enable_build_type}" printf "%s\n" "#define MHD_FAVOR_SMALL_CODE 1" >>confdefs.h ;; #( *) : ;; esac fi if test "x$enable_compact_code" = x"auto" then : # No preference enable_compact_code="no" compact_code_MSG="by default" printf "%s\n" "#define MHD_FAVOR_FAST_CODE 1" >>confdefs.h fi ;; #( yes) : compact_code_MSG="enabled by configure parameter" ac_fn_check_decl "$LINENO" "MHD_FAVOR_SMALL_CODE" "ac_cv_have_decl_MHD_FAVOR_SMALL_CODE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_MHD_FAVOR_SMALL_CODE" = xyes then : else $as_nop printf "%s\n" "#define MHD_FAVOR_SMALL_CODE 1" >>confdefs.h fi ac_fn_check_decl "$LINENO" "MHD_FAVOR_FAST_CODE" "ac_cv_have_decl_MHD_FAVOR_FAST_CODE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_MHD_FAVOR_FAST_CODE" = xyes then : as_fn_error $? "MHD_FAVOR_FAST_CODE macro is defined, --enable-compact-code could not be used" "$LINENO" 5 fi ;; #( no) : compact_code_MSG="disabled by configure parameter" ac_fn_check_decl "$LINENO" "MHD_FAVOR_FAST_CODE" "ac_cv_have_decl_MHD_FAVOR_FAST_CODE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_MHD_FAVOR_FAST_CODE" = xyes then : else $as_nop printf "%s\n" "#define MHD_FAVOR_FAST_CODE 1" >>confdefs.h fi ac_fn_check_decl "$LINENO" "MHD_FAVOR_SMALL_CODE" "ac_cv_have_decl_MHD_FAVOR_SMALL_CODE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_MHD_FAVOR_SMALL_CODE" = xyes then : as_fn_error $? "MHD_FAVOR_SMALL_CODE macro is defined, --disable-compact-code could not be used" "$LINENO" 5 fi ;; #( *) : as_fn_error $? "Unknown parameter value: --enable-compact-code=${enable_compact_code}" "$LINENO" 5 ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use a reduced size version of the code" >&5 printf %s "checking whether to use a reduced size version of the code... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${enable_compact_code} (${compact_code_MSG})" >&5 printf "%s\n" "${enable_compact_code} (${compact_code_MSG})" >&6; } CFLAGS="${user_CFLAGS}" # Compiler options to always enable (if supported) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC flag to warn on unknown -W parameters" >&5 printf %s "checking for $CC flag to warn on unknown -W parameters... " >&6; } if test ${mhd_cv_cc_flag_Wwarn+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flagwarn_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes mhd_find_cc_Wwarn_save_CFLAGS="$CFLAGS" { mhd_cv_cc_flag_Wwarn=; unset mhd_cv_cc_flag_Wwarn;} for mhd_cv_cc_flag_Wwarn in '' '-Wunknown-warning-option' '-Werror=unknown-warning-option' ; do if test "x$mhd_cv_cc_flag_Wwarn" = x"unknown" then : break fi # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF CFLAGS="-Wmhd-noexist-flag $mhd_find_cc_Wwarn_save_CFLAGS $mhd_cv_cc_flag_Wwarn" if ac_fn_c_try_link "$LINENO" then : else $as_nop # Compile and link failed if test flag and non-existing flag added CFLAGS="$mhd_find_cc_Wwarn_save_CFLAGS $mhd_cv_cc_flag_Wwarn" if ac_fn_c_try_link "$LINENO" then : # Compile and link succeed if only test flag added break fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext done CFLAGS="$mhd_find_cc_Wwarn_save_CFLAGS" if test "x$mhd_cv_cc_flag_Wwarn" = x"unknown" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: No suitable flags detected. Check whether default flags are correct." >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : : else $as_nop # Compile and link fails (or warns) with default flags { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Compiler warns (of fails) with default flags!" >&5 printf "%s\n" "$as_me: WARNING: Compiler warns (of fails) with default flags!" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Check whether compiler and compiler flags are correct." >&5 printf "%s\n" "$as_me: WARNING: Check whether compiler and compiler flags are correct." >&2;} fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi CFLAGS="$mhd_find_cc_Wwarn_save_CFLAGS" { mhd_find_cc_Wwarn_save_CFLAGS=; unset mhd_find_cc_Wwarn_save_CFLAGS;} ac_c_werror_flag="$mhd_check_cc_flagwarn_save_c_werror_flag" { mhd_check_cc_flagwarn_save_c_werror_flag=; unset mhd_check_cc_flagwarn_save_c_werror_flag;} fi if test -z "$mhd_cv_cc_flag_Wwarn" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_flag_Wwarn" >&5 printf "%s\n" "$mhd_cv_cc_flag_Wwarn" >&6; } fi if test "x$mhd_cv_cc_flag_Wwarn" = x"unknown" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Unable to find compiler flags to warn on unsupported -W options. Final compiler options may be suboptimal." >&5 printf "%s\n" "$as_me: WARNING: Unable to find compiler flags to warn on unsupported -W options. Final compiler options may be suboptimal." >&2;} fi mhd_xFLAGS_params_warn='' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wunused-command-line-argument flag" >&5 printf %s "checking whether $CC supports -Wunused-command-line-argument flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wunused_command_line_argument+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="-Wunused-command-line-argument $CFLAGS ${mhd_cv_cc_flag_Wwarn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunused_command_line_argument="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${mhd_check_cc_flag_save_CFLAGS} ${mhd_cv_cc_flag_Wwarn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunused_command_line_argument="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="-Wunused-command-line-argument ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunused_command_line_argument="yes" else $as_nop mhd_cv_cc_cfl_supp__Wunused_command_line_argument="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wunused_command_line_argument" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wunused_command_line_argument" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wunused_command_line_argument" = x"yes" then : if test -z "${mhd_xFLAGS_params_warn}" then : mhd_xFLAGS_params_warn="-Wunused-command-line-argument" else $as_nop mhd_xFLAGS_params_warn="${mhd_xFLAGS_params_warn} -Wunused-command-line-argument" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wignored-optimization-argument flag" >&5 printf %s "checking whether $CC supports -Wignored-optimization-argument flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wignored_optimization_argument+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="-Wignored-optimization-argument $CFLAGS ${mhd_cv_cc_flag_Wwarn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wignored_optimization_argument="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${mhd_check_cc_flag_save_CFLAGS} ${mhd_cv_cc_flag_Wwarn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wignored_optimization_argument="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="-Wignored-optimization-argument ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wignored_optimization_argument="yes" else $as_nop mhd_cv_cc_cfl_supp__Wignored_optimization_argument="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wignored_optimization_argument" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wignored_optimization_argument" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wignored_optimization_argument" = x"yes" then : if test -z "${mhd_xFLAGS_params_warn}" then : mhd_xFLAGS_params_warn="-Wignored-optimization-argument" else $as_nop mhd_xFLAGS_params_warn="${mhd_xFLAGS_params_warn} -Wignored-optimization-argument" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Winvalid-command-line-argument flag" >&5 printf %s "checking whether $CC supports -Winvalid-command-line-argument flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Winvalid_command_line_argument+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="-Winvalid-command-line-argument $CFLAGS ${mhd_cv_cc_flag_Wwarn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Winvalid_command_line_argument="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${mhd_check_cc_flag_save_CFLAGS} ${mhd_cv_cc_flag_Wwarn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Winvalid_command_line_argument="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="-Winvalid-command-line-argument ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Winvalid_command_line_argument="yes" else $as_nop mhd_cv_cc_cfl_supp__Winvalid_command_line_argument="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Winvalid_command_line_argument" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Winvalid_command_line_argument" >&6; } if test "x$mhd_cv_cc_cfl_supp__Winvalid_command_line_argument" = x"yes" then : if test -z "${mhd_xFLAGS_params_warn}" then : mhd_xFLAGS_params_warn="-Winvalid-command-line-argument" else $as_nop mhd_xFLAGS_params_warn="${mhd_xFLAGS_params_warn} -Winvalid-command-line-argument" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wunknown-argument flag" >&5 printf %s "checking whether $CC supports -Wunknown-argument flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wunknown_argument+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="-Wunknown-argument $CFLAGS ${mhd_cv_cc_flag_Wwarn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunknown_argument="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${mhd_check_cc_flag_save_CFLAGS} ${mhd_cv_cc_flag_Wwarn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunknown_argument="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="-Wunknown-argument ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunknown_argument="yes" else $as_nop mhd_cv_cc_cfl_supp__Wunknown_argument="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wunknown_argument" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wunknown_argument" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wunknown_argument" = x"yes" then : if test -z "${mhd_xFLAGS_params_warn}" then : mhd_xFLAGS_params_warn="-Wunknown-argument" else $as_nop mhd_xFLAGS_params_warn="${mhd_xFLAGS_params_warn} -Wunknown-argument" fi fi if test -z "$mhd_cv_cc_flag_Wwarn" then : mhd_xFLAGS_params_warn="${mhd_xFLAGS_params_warn}" elif test -z "${mhd_xFLAGS_params_warn}" then : mhd_xFLAGS_params_warn="$mhd_cv_cc_flag_Wwarn" else $as_nop mhd_xFLAGS_params_warn="$mhd_cv_cc_flag_Wwarn ${mhd_xFLAGS_params_warn}" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fno-strict-aliasing flag" >&5 printf %s "checking whether $CC supports -fno-strict-aliasing flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fno_strict_aliasing+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fno-strict-aliasing ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fno_strict_aliasing="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fno_strict_aliasing="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fno-strict-aliasing ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fno_strict_aliasing="yes" else $as_nop mhd_cv_cc_cfl_supp__fno_strict_aliasing="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fno_strict_aliasing" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fno_strict_aliasing" >&6; } if test "x$mhd_cv_cc_cfl_supp__fno_strict_aliasing" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fno-strict-aliasing" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fno-strict-aliasing" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -qnoansialias flag" >&5 printf %s "checking whether $CC supports -qnoansialias flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__qnoansialias+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -qnoansialias ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__qnoansialias="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__qnoansialias="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -qnoansialias ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__qnoansialias="yes" else $as_nop mhd_cv_cc_cfl_supp__qnoansialias="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__qnoansialias" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__qnoansialias" >&6; } if test "x$mhd_cv_cc_cfl_supp__qnoansialias" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-qnoansialias" else $as_nop CFLAGS_ac="${CFLAGS_ac} -qnoansialias" fi fi fi # '-qlonglong' is XLC option for C89, not used with C99 or later { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -qlonglong flag" >&5 printf %s "checking whether $CC supports -qlonglong flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__qlonglong+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -qlonglong ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__qlonglong="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__qlonglong="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -qlonglong ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__qlonglong="yes" else $as_nop mhd_cv_cc_cfl_supp__qlonglong="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__qlonglong" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__qlonglong" >&6; } if test "x$mhd_cv_cc_cfl_supp__qlonglong" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-qlonglong" else $as_nop CFLAGS_ac="${CFLAGS_ac} -qlonglong" fi fi # Set basic optimisation flags if test "x$enable_build_type" = x"neutral" then : else $as_nop # Any non-neutral build types { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether workarounds for clang or clang-based compiler are required" >&5 printf %s "checking whether workarounds for clang or clang-based compiler are required... " >&6; } if test ${mhd_cv_cc_clang_based+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if ! defined(__clang__) && ! defined(__llvm__) #error Compiler is not clang-based choke me now #endif _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_cc_clang_based="yes" else $as_nop mhd_cv_cc_clang_based="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_clang_based" >&5 printf "%s\n" "$mhd_cv_cc_clang_based" >&6; } fi case ${enable_build_type} in #( debug|debugger) : # Debug build or build for walking with debugger CFLAGS="${user_CFLAGS}" if test "x$enable_build_type" = x"debug" then : # Clang has ASAN (pointer compare) broken when '-Og' optimisations are used if test "x${enable_sanitizers}" != "xno" && test "x${mhd_cv_cc_clang_based}" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -O0 flag" >&5 printf %s "checking whether $CC supports -O0 flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__O0+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -O0 ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O0="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O0="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -O0 ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O0="yes" else $as_nop mhd_cv_cc_cfl_supp__O0="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__O0" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__O0" >&6; } if test "x$mhd_cv_cc_cfl_supp__O0" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-O0" else $as_nop CFLAGS_ac="${CFLAGS_ac} -O0" fi fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Og flag" >&5 printf %s "checking whether $CC supports -Og flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Og+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Og ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Og="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Og="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Og ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Og="yes" else $as_nop mhd_cv_cc_cfl_supp__Og="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Og" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Og" >&6; } if test "x$mhd_cv_cc_cfl_supp__Og" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Og" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Og" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -O0 flag" >&5 printf %s "checking whether $CC supports -O0 flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__O0+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -O0 ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O0="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O0="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -O0 ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O0="yes" else $as_nop mhd_cv_cc_cfl_supp__O0="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__O0" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__O0" >&6; } if test "x$mhd_cv_cc_cfl_supp__O0" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-O0" else $as_nop CFLAGS_ac="${CFLAGS_ac} -O0" fi fi fi fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -O0 flag" >&5 printf %s "checking whether $CC supports -O0 flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__O0+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -O0 ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O0="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O0="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -O0 ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O0="yes" else $as_nop mhd_cv_cc_cfl_supp__O0="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__O0" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__O0" >&6; } if test "x$mhd_cv_cc_cfl_supp__O0" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-O0" else $as_nop CFLAGS_ac="${CFLAGS_ac} -O0" fi fi fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ;; #( *) : ;; esac case ${enable_build_type} in #( release|release-*) : # All release types if test "x$enable_build_type" = x"release-compact" then : CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" ac_fn_check_decl "$LINENO" "MHD_FAVOR_SMALL_CODE" "ac_cv_have_decl_MHD_FAVOR_SMALL_CODE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_MHD_FAVOR_SMALL_CODE" = xyes then : else $as_nop ac_fn_check_decl "$LINENO" "MHD_FAVOR_FAST_CODE" "ac_cv_have_decl_MHD_FAVOR_FAST_CODE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_MHD_FAVOR_FAST_CODE" = xyes then : else $as_nop if test -z "${CPPFLAGS_ac}" then : CPPFLAGS_ac="-DMHD_FAVOR_SMALL_CODE=1" else $as_nop CPPFLAGS_ac="${CPPFLAGS_ac} -DMHD_FAVOR_SMALL_CODE=1" fi fi fi CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${user_CFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Oz flag" >&5 printf %s "checking whether $CC supports -Oz flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Oz+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Oz ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Oz="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Oz="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Oz ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Oz="yes" else $as_nop mhd_cv_cc_cfl_supp__Oz="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Oz" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Oz" >&6; } if test "x$mhd_cv_cc_cfl_supp__Oz" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Oz" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Oz" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Os flag" >&5 printf %s "checking whether $CC supports -Os flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Os+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Os ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Os="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Os="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Os ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Os="yes" else $as_nop mhd_cv_cc_cfl_supp__Os="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Os" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Os" >&6; } if test "x$mhd_cv_cc_cfl_supp__Os" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Os" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Os" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -O flag" >&5 printf %s "checking whether $CC supports -O flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__O+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -O ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -O ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O="yes" else $as_nop mhd_cv_cc_cfl_supp__O="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__O" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__O" >&6; } if test "x$mhd_cv_cc_cfl_supp__O" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-O" else $as_nop CFLAGS_ac="${CFLAGS_ac} -O" fi fi fi fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" else $as_nop # All non-compact release types CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" ac_fn_check_decl "$LINENO" "MHD_FAVOR_SMALL_CODE" "ac_cv_have_decl_MHD_FAVOR_SMALL_CODE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_MHD_FAVOR_SMALL_CODE" = xyes then : else $as_nop ac_fn_check_decl "$LINENO" "MHD_FAVOR_FAST_CODE" "ac_cv_have_decl_MHD_FAVOR_FAST_CODE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_MHD_FAVOR_FAST_CODE" = xyes then : else $as_nop if test -z "${CPPFLAGS_ac}" then : CPPFLAGS_ac="-DMHD_FAVOR_FAST_CODE=1" else $as_nop CPPFLAGS_ac="${CPPFLAGS_ac} -DMHD_FAVOR_FAST_CODE=1" fi fi fi CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${user_CFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -O2 flag" >&5 printf %s "checking whether $CC supports -O2 flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__O2+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -O2 ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O2="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O2="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -O2 ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O2="yes" else $as_nop mhd_cv_cc_cfl_supp__O2="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__O2" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__O2" >&6; } if test "x$mhd_cv_cc_cfl_supp__O2" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-O2" else $as_nop CFLAGS_ac="${CFLAGS_ac} -O2" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -O flag" >&5 printf %s "checking whether $CC supports -O flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__O+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -O ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -O ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__O="yes" else $as_nop mhd_cv_cc_cfl_supp__O="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__O" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__O" >&6; } if test "x$mhd_cv_cc_cfl_supp__O" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-O" else $as_nop CFLAGS_ac="${CFLAGS_ac} -O" fi fi fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" fi ;; #( *) : ;; esac if test "x$enable_build_type" = x"neutral" then : else $as_nop # Any non-neutral build types { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wall flag" >&5 printf %s "checking whether $CC supports -Wall flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wall+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wall ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wall="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wall="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wall ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wall="yes" else $as_nop mhd_cv_cc_cfl_supp__Wall="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wall" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wall" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wall" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wall" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wall" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wnull-dereference flag" >&5 printf %s "checking whether $CC supports -Wnull-dereference flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wnull_dereference+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wnull-dereference ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnull_dereference="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnull_dereference="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wnull-dereference ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnull_dereference="yes" else $as_nop mhd_cv_cc_cfl_supp__Wnull_dereference="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wnull_dereference" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wnull_dereference" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wnull_dereference" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wnull-dereference" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wnull-dereference" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wdeclaration-after-statement flag" >&5 printf %s "checking whether $CC supports -Wdeclaration-after-statement flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wdeclaration_after_statement+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wdeclaration-after-statement ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdeclaration_after_statement="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdeclaration_after_statement="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wdeclaration-after-statement ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdeclaration_after_statement="yes" else $as_nop mhd_cv_cc_cfl_supp__Wdeclaration_after_statement="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wdeclaration_after_statement" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wdeclaration_after_statement" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wdeclaration_after_statement" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wdeclaration-after-statement" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wdeclaration-after-statement" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wimplicit flag" >&5 printf %s "checking whether $CC supports -Wimplicit flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wimplicit+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wimplicit ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wimplicit="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wimplicit="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wimplicit ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wimplicit="yes" else $as_nop mhd_cv_cc_cfl_supp__Wimplicit="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wimplicit" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wimplicit" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wimplicit" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wimplicit" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wimplicit" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wnested-externs flag" >&5 printf %s "checking whether $CC supports -Wnested-externs flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wnested_externs+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wnested-externs ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnested_externs="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnested_externs="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wnested-externs ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnested_externs="yes" else $as_nop mhd_cv_cc_cfl_supp__Wnested_externs="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wnested_externs" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wnested_externs" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wnested_externs" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wnested-externs" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wnested-externs" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wredundant-decls flag" >&5 printf %s "checking whether $CC supports -Wredundant-decls flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wredundant_decls+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wredundant-decls ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wredundant_decls="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wredundant_decls="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wredundant-decls ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wredundant_decls="yes" else $as_nop mhd_cv_cc_cfl_supp__Wredundant_decls="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wredundant_decls" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wredundant_decls" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wredundant_decls" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wredundant-decls" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wredundant-decls" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wtrampolines flag" >&5 printf %s "checking whether $CC supports -Wtrampolines flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wtrampolines+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wtrampolines ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wtrampolines="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wtrampolines="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wtrampolines ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wtrampolines="yes" else $as_nop mhd_cv_cc_cfl_supp__Wtrampolines="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wtrampolines" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wtrampolines" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wtrampolines" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wtrampolines" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wtrampolines" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wunsafe-loop-optimizations flag" >&5 printf %s "checking whether $CC supports -Wunsafe-loop-optimizations flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wunsafe_loop_optimizations+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wunsafe-loop-optimizations ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunsafe_loop_optimizations="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunsafe_loop_optimizations="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wunsafe-loop-optimizations ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunsafe_loop_optimizations="yes" else $as_nop mhd_cv_cc_cfl_supp__Wunsafe_loop_optimizations="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wunsafe_loop_optimizations" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wunsafe_loop_optimizations" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wunsafe_loop_optimizations" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wunsafe-loop-optimizations" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wunsafe-loop-optimizations" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wpoison-system-directories flag" >&5 printf %s "checking whether $CC supports -Wpoison-system-directories flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wpoison_system_directories+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wpoison-system-directories ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wpoison_system_directories="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wpoison_system_directories="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wpoison-system-directories ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wpoison_system_directories="yes" else $as_nop mhd_cv_cc_cfl_supp__Wpoison_system_directories="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wpoison_system_directories" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wpoison_system_directories" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wpoison_system_directories" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wpoison-system-directories" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wpoison-system-directories" fi fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${user_LDFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--warn-common flag" >&5 printf %s "checking whether $CC supports -Wl,--warn-common flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl___warn_common+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,--warn-common ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___warn_common="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___warn_common="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,--warn-common ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___warn_common="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl___warn_common="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl___warn_common" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl___warn_common" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl___warn_common" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,--warn-common" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,--warn-common" fi fi LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" fi case ${enable_build_type} in #( debug|debugger) : # Debug build or build for walking with debugger CFLAGS="${user_CFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -ggdb3 flag" >&5 printf %s "checking whether $CC supports -ggdb3 flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__ggdb3+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -ggdb3 ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ggdb3="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ggdb3="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -ggdb3 ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ggdb3="yes" else $as_nop mhd_cv_cc_cfl_supp__ggdb3="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__ggdb3" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__ggdb3" >&6; } if test "x$mhd_cv_cc_cfl_supp__ggdb3" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-ggdb3" else $as_nop CFLAGS_ac="${CFLAGS_ac} -ggdb3" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -g3 flag" >&5 printf %s "checking whether $CC supports -g3 flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__g3+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -g3 ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__g3="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__g3="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -g3 ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__g3="yes" else $as_nop mhd_cv_cc_cfl_supp__g3="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__g3" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__g3" >&6; } if test "x$mhd_cv_cc_cfl_supp__g3" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-g3" else $as_nop CFLAGS_ac="${CFLAGS_ac} -g3" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -ggdb flag" >&5 printf %s "checking whether $CC supports -ggdb flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__ggdb+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -ggdb ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ggdb="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ggdb="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -ggdb ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ggdb="yes" else $as_nop mhd_cv_cc_cfl_supp__ggdb="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__ggdb" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__ggdb" >&6; } if test "x$mhd_cv_cc_cfl_supp__ggdb" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-ggdb" else $as_nop CFLAGS_ac="${CFLAGS_ac} -ggdb" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -g flag" >&5 printf %s "checking whether $CC supports -g flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__g+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -g ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__g="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__g="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -g ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__g="yes" else $as_nop mhd_cv_cc_cfl_supp__g="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__g" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__g" >&6; } if test "x$mhd_cv_cc_cfl_supp__g" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-g" else $as_nop CFLAGS_ac="${CFLAGS_ac} -g" fi fi fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wextra flag" >&5 printf %s "checking whether $CC supports -Wextra flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wextra+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wextra ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wextra="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wextra="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wextra ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wextra="yes" else $as_nop mhd_cv_cc_cfl_supp__Wextra="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wextra" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wextra" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wextra" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wextra" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wextra" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wdouble-promotion flag" >&5 printf %s "checking whether $CC supports -Wdouble-promotion flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wdouble_promotion+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wdouble-promotion ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdouble_promotion="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdouble_promotion="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wdouble-promotion ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdouble_promotion="yes" else $as_nop mhd_cv_cc_cfl_supp__Wdouble_promotion="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wdouble_promotion" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wdouble_promotion" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wdouble_promotion" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wdouble-promotion" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wdouble-promotion" fi fi { mhd_cc_found_flag=; unset mhd_cc_found_flag;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat=2 flag" >&5 printf %s "checking whether $CC supports -Wformat=2 flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wformat_2+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wformat=2 ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_2="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_2="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wformat=2 ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_2="yes" else $as_nop mhd_cv_cc_cfl_supp__Wformat_2="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wformat_2" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wformat_2" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wformat_2" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wformat=2" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wformat=2" fi mhd_cc_found_flag="-Wformat=2" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat flag" >&5 printf %s "checking whether $CC supports -Wformat flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wformat+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wformat ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wformat ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat="yes" else $as_nop mhd_cv_cc_cfl_supp__Wformat="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wformat" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wformat" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wformat" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wformat" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wformat" fi mhd_cc_found_flag="-Wformat" fi fi if test -n "${mhd_cc_found_flag}" then : # clang produce warning when string pointer is used as a format specifier for v*printf() function if test "x$mhd_cv_cc_clang_based" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-format-nonliteral flag" >&5 printf %s "checking whether $CC supports -Wno-format-nonliteral flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wno_format_nonliteral+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wno-format-nonliteral ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wno_format_nonliteral="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wno_format_nonliteral="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wno-format-nonliteral ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wno_format_nonliteral="yes" else $as_nop mhd_cv_cc_cfl_supp__Wno_format_nonliteral="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wno_format_nonliteral" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wno_format_nonliteral" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wno_format_nonliteral" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wno-format-nonliteral" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wno-format-nonliteral" fi fi fi fi { mhd_cc_found_flag=; unset mhd_cc_found_flag;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat-overflow flag" >&5 printf %s "checking whether $CC supports -Wformat-overflow flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wformat_overflow+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wformat-overflow ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_overflow="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_overflow="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wformat-overflow ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_overflow="yes" else $as_nop mhd_cv_cc_cfl_supp__Wformat_overflow="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wformat_overflow" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wformat_overflow" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wformat_overflow" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wformat-overflow" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wformat-overflow" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat-truncation flag" >&5 printf %s "checking whether $CC supports -Wformat-truncation flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wformat_truncation+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wformat-truncation ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_truncation="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_truncation="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wformat-truncation ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_truncation="yes" else $as_nop mhd_cv_cc_cfl_supp__Wformat_truncation="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wformat_truncation" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wformat_truncation" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wformat_truncation" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wformat-truncation" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wformat-truncation" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat-security flag" >&5 printf %s "checking whether $CC supports -Wformat-security flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wformat_security+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wformat-security ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_security="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_security="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wformat-security ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_security="yes" else $as_nop mhd_cv_cc_cfl_supp__Wformat_security="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wformat_security" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wformat_security" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wformat_security" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wformat-security" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wformat-security" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat-signedness flag" >&5 printf %s "checking whether $CC supports -Wformat-signedness flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wformat_signedness+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wformat-signedness ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_signedness="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_signedness="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wformat-signedness ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_signedness="yes" else $as_nop mhd_cv_cc_cfl_supp__Wformat_signedness="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wformat_signedness" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wformat_signedness" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wformat_signedness" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wformat-signedness" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wformat-signedness" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wmissing-include-dirs flag" >&5 printf %s "checking whether $CC supports -Wmissing-include-dirs flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wmissing_include_dirs+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wmissing-include-dirs ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_include_dirs="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_include_dirs="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wmissing-include-dirs ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_include_dirs="yes" else $as_nop mhd_cv_cc_cfl_supp__Wmissing_include_dirs="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wmissing_include_dirs" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wmissing_include_dirs" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wmissing_include_dirs" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wmissing-include-dirs" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wmissing-include-dirs" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wshift-overflow=2 flag" >&5 printf %s "checking whether $CC supports -Wshift-overflow=2 flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wshift_overflow_2+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wshift-overflow=2 ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshift_overflow_2="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshift_overflow_2="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wshift-overflow=2 ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshift_overflow_2="yes" else $as_nop mhd_cv_cc_cfl_supp__Wshift_overflow_2="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wshift_overflow_2" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wshift_overflow_2" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wshift_overflow_2" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wshift-overflow=2" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wshift-overflow=2" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wstringop-overflow=4 flag" >&5 printf %s "checking whether $CC supports -Wstringop-overflow=4 flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wstringop_overflow_4+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wstringop-overflow=4 ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstringop_overflow_4="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstringop_overflow_4="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wstringop-overflow=4 ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstringop_overflow_4="yes" else $as_nop mhd_cv_cc_cfl_supp__Wstringop_overflow_4="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wstringop_overflow_4" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wstringop_overflow_4" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wstringop_overflow_4" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wstringop-overflow=4" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wstringop-overflow=4" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Walloc-zero flag" >&5 printf %s "checking whether $CC supports -Walloc-zero flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Walloc_zero+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Walloc-zero ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Walloc_zero="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Walloc_zero="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Walloc-zero ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Walloc_zero="yes" else $as_nop mhd_cv_cc_cfl_supp__Walloc_zero="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Walloc_zero" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Walloc_zero" >&6; } if test "x$mhd_cv_cc_cfl_supp__Walloc_zero" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Walloc-zero" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Walloc-zero" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wduplicated-branches flag" >&5 printf %s "checking whether $CC supports -Wduplicated-branches flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wduplicated_branches+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wduplicated-branches ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wduplicated_branches="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wduplicated_branches="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wduplicated-branches ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wduplicated_branches="yes" else $as_nop mhd_cv_cc_cfl_supp__Wduplicated_branches="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wduplicated_branches" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wduplicated_branches" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wduplicated_branches" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wduplicated-branches" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wduplicated-branches" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wduplicated-cond flag" >&5 printf %s "checking whether $CC supports -Wduplicated-cond flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wduplicated_cond+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wduplicated-cond ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wduplicated_cond="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wduplicated_cond="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wduplicated-cond ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wduplicated_cond="yes" else $as_nop mhd_cv_cc_cfl_supp__Wduplicated_cond="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wduplicated_cond" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wduplicated_cond" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wduplicated_cond" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wduplicated-cond" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wduplicated-cond" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wfloat-equal flag" >&5 printf %s "checking whether $CC supports -Wfloat-equal flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wfloat_equal+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wfloat-equal ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wfloat_equal="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wfloat_equal="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wfloat-equal ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wfloat_equal="yes" else $as_nop mhd_cv_cc_cfl_supp__Wfloat_equal="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wfloat_equal" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wfloat_equal" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wfloat_equal" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wfloat-equal" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wfloat-equal" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wshadow flag" >&5 printf %s "checking whether $CC supports -Wshadow flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wshadow+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wshadow ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshadow="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshadow="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wshadow ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshadow="yes" else $as_nop mhd_cv_cc_cfl_supp__Wshadow="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wshadow" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wshadow" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wshadow" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wshadow" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wshadow" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wpointer-arith flag" >&5 printf %s "checking whether $CC supports -Wpointer-arith flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wpointer_arith+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wpointer-arith ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wpointer_arith="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wpointer_arith="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wpointer-arith ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wpointer_arith="yes" else $as_nop mhd_cv_cc_cfl_supp__Wpointer_arith="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wpointer_arith" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wpointer_arith" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wpointer_arith" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wpointer-arith" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wpointer-arith" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wshadow-all flag" >&5 printf %s "checking whether $CC supports -Wshadow-all flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wshadow_all+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wshadow-all ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshadow_all="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshadow_all="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wshadow-all ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshadow_all="yes" else $as_nop mhd_cv_cc_cfl_supp__Wshadow_all="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wshadow_all" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wshadow_all" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wshadow_all" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wshadow-all" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wshadow-all" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wshadow flag" >&5 printf %s "checking whether $CC supports -Wshadow flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wshadow+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wshadow ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshadow="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshadow="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wshadow ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshadow="yes" else $as_nop mhd_cv_cc_cfl_supp__Wshadow="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wshadow" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wshadow" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wshadow" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wshadow" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wshadow" fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wbad-function-cast flag" >&5 printf %s "checking whether $CC supports -Wbad-function-cast flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wbad_function_cast+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wbad-function-cast ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbad_function_cast="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbad_function_cast="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wbad-function-cast ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbad_function_cast="yes" else $as_nop mhd_cv_cc_cfl_supp__Wbad_function_cast="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wbad_function_cast" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wbad_function_cast" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wbad_function_cast" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wbad-function-cast" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wbad-function-cast" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wcast-qual flag" >&5 printf %s "checking whether $CC supports -Wcast-qual flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wcast_qual+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wcast-qual ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_qual="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_qual="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wcast-qual ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_qual="yes" else $as_nop mhd_cv_cc_cfl_supp__Wcast_qual="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wcast_qual" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wcast_qual" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wcast_qual" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wcast-qual" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wcast-qual" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wwrite-strings flag" >&5 printf %s "checking whether $CC supports -Wwrite-strings flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wwrite_strings+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wwrite-strings ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wwrite_strings="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wwrite_strings="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wwrite-strings ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wwrite_strings="yes" else $as_nop mhd_cv_cc_cfl_supp__Wwrite_strings="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wwrite_strings" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wwrite_strings" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wwrite_strings" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wwrite-strings" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wwrite-strings" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wconversion flag" >&5 printf %s "checking whether $CC supports -Wconversion flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wconversion+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wconversion ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wconversion="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wconversion="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wconversion ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wconversion="yes" else $as_nop mhd_cv_cc_cfl_supp__Wconversion="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wconversion" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wconversion" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wconversion" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wconversion" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wconversion" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wcast-align=strict flag" >&5 printf %s "checking whether $CC supports -Wcast-align=strict flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wcast_align_strict+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wcast-align=strict ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_align_strict="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_align_strict="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wcast-align=strict ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_align_strict="yes" else $as_nop mhd_cv_cc_cfl_supp__Wcast_align_strict="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wcast_align_strict" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wcast_align_strict" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wcast_align_strict" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wcast-align=strict" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wcast-align=strict" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wcast-align flag" >&5 printf %s "checking whether $CC supports -Wcast-align flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wcast_align+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wcast-align ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_align="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_align="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wcast-align ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_align="yes" else $as_nop mhd_cv_cc_cfl_supp__Wcast_align="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wcast_align" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wcast_align" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wcast_align" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wcast-align" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wcast-align" fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wjump-misses-init flag" >&5 printf %s "checking whether $CC supports -Wjump-misses-init flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wjump_misses_init+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wjump-misses-init ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wjump_misses_init="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wjump_misses_init="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wjump-misses-init ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wjump_misses_init="yes" else $as_nop mhd_cv_cc_cfl_supp__Wjump_misses_init="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wjump_misses_init" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wjump_misses_init" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wjump_misses_init" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wjump-misses-init" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wjump-misses-init" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wlogical-op flag" >&5 printf %s "checking whether $CC supports -Wlogical-op flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wlogical_op+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wlogical-op ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wlogical_op="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wlogical_op="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wlogical-op ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wlogical_op="yes" else $as_nop mhd_cv_cc_cfl_supp__Wlogical_op="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wlogical_op" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wlogical_op" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wlogical_op" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wlogical-op" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wlogical-op" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Waggregate-return flag" >&5 printf %s "checking whether $CC supports -Waggregate-return flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Waggregate_return+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Waggregate-return ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Waggregate_return="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Waggregate_return="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Waggregate-return ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Waggregate_return="yes" else $as_nop mhd_cv_cc_cfl_supp__Waggregate_return="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Waggregate_return" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Waggregate_return" >&6; } if test "x$mhd_cv_cc_cfl_supp__Waggregate_return" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Waggregate-return" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Waggregate-return" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wstrict-prototypes flag" >&5 printf %s "checking whether $CC supports -Wstrict-prototypes flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wstrict_prototypes+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wstrict-prototypes ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstrict_prototypes="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstrict_prototypes="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wstrict-prototypes ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstrict_prototypes="yes" else $as_nop mhd_cv_cc_cfl_supp__Wstrict_prototypes="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wstrict_prototypes" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wstrict_prototypes" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wstrict_prototypes" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wstrict-prototypes" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wstrict-prototypes" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wold-style-definition flag" >&5 printf %s "checking whether $CC supports -Wold-style-definition flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wold_style_definition+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wold-style-definition ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wold_style_definition="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wold_style_definition="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wold-style-definition ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wold_style_definition="yes" else $as_nop mhd_cv_cc_cfl_supp__Wold_style_definition="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wold_style_definition" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wold_style_definition" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wold_style_definition" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wold-style-definition" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wold-style-definition" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wmissing-declarations flag" >&5 printf %s "checking whether $CC supports -Wmissing-declarations flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wmissing_declarations+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wmissing-declarations ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_declarations="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_declarations="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wmissing-declarations ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_declarations="yes" else $as_nop mhd_cv_cc_cfl_supp__Wmissing_declarations="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wmissing_declarations" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wmissing_declarations" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wmissing_declarations" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wmissing-declarations" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wmissing-declarations" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wmissing-prototypes flag" >&5 printf %s "checking whether $CC supports -Wmissing-prototypes flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wmissing_prototypes+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wmissing-prototypes ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_prototypes="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_prototypes="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wmissing-prototypes ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_prototypes="yes" else $as_nop mhd_cv_cc_cfl_supp__Wmissing_prototypes="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wmissing_prototypes" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wmissing_prototypes" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wmissing_prototypes" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wmissing-prototypes" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wmissing-prototypes" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wuninitialized flag" >&5 printf %s "checking whether $CC supports -Wuninitialized flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wuninitialized+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wuninitialized ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wuninitialized="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wuninitialized="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wuninitialized ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wuninitialized="yes" else $as_nop mhd_cv_cc_cfl_supp__Wuninitialized="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wuninitialized" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wuninitialized" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wuninitialized" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wuninitialized" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wuninitialized" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Winit-self flag" >&5 printf %s "checking whether $CC supports -Winit-self flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Winit_self+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Winit-self ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Winit_self="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Winit_self="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Winit-self ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Winit_self="yes" else $as_nop mhd_cv_cc_cfl_supp__Winit_self="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Winit_self" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Winit_self" >&6; } if test "x$mhd_cv_cc_cfl_supp__Winit_self" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Winit-self" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Winit-self" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wshift-negative-value flag" >&5 printf %s "checking whether $CC supports -Wshift-negative-value flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wshift_negative_value+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wshift-negative-value ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshift_negative_value="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshift_negative_value="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wshift-negative-value ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshift_negative_value="yes" else $as_nop mhd_cv_cc_cfl_supp__Wshift_negative_value="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wshift_negative_value" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wshift_negative_value" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wshift_negative_value" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wshift-negative-value" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wshift-negative-value" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wswitch-enum flag" >&5 printf %s "checking whether $CC supports -Wswitch-enum flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wswitch_enum+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wswitch-enum ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wswitch_enum="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wswitch_enum="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wswitch-enum ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wswitch_enum="yes" else $as_nop mhd_cv_cc_cfl_supp__Wswitch_enum="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wswitch_enum" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wswitch_enum" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wswitch_enum" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wswitch-enum" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wswitch-enum" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wstrict-overflow=4 flag" >&5 printf %s "checking whether $CC supports -Wstrict-overflow=4 flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wstrict_overflow_4+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wstrict-overflow=4 ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstrict_overflow_4="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstrict_overflow_4="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wstrict-overflow=4 ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstrict_overflow_4="yes" else $as_nop mhd_cv_cc_cfl_supp__Wstrict_overflow_4="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wstrict_overflow_4" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wstrict_overflow_4" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wstrict_overflow_4" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wstrict-overflow=4" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wstrict-overflow=4" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wstrict-overflow flag" >&5 printf %s "checking whether $CC supports -Wstrict-overflow flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wstrict_overflow+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wstrict-overflow ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstrict_overflow="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstrict_overflow="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wstrict-overflow ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstrict_overflow="yes" else $as_nop mhd_cv_cc_cfl_supp__Wstrict_overflow="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wstrict_overflow" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wstrict_overflow" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wstrict_overflow" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wstrict-overflow" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wstrict-overflow" fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wnormalized=nfkc flag" >&5 printf %s "checking whether $CC supports -Wnormalized=nfkc flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wnormalized_nfkc+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wnormalized=nfkc ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnormalized_nfkc="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnormalized_nfkc="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wnormalized=nfkc ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnormalized_nfkc="yes" else $as_nop mhd_cv_cc_cfl_supp__Wnormalized_nfkc="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wnormalized_nfkc" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wnormalized_nfkc" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wnormalized_nfkc" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wnormalized=nfkc" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wnormalized=nfkc" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wnormalized flag" >&5 printf %s "checking whether $CC supports -Wnormalized flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wnormalized+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wnormalized ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnormalized="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnormalized="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wnormalized ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnormalized="yes" else $as_nop mhd_cv_cc_cfl_supp__Wnormalized="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wnormalized" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wnormalized" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wnormalized" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wnormalized" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wnormalized" fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Walloca flag" >&5 printf %s "checking whether $CC supports -Walloca flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Walloca+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Walloca ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Walloca="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Walloca="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Walloca ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Walloca="yes" else $as_nop mhd_cv_cc_cfl_supp__Walloca="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Walloca" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Walloca" >&6; } if test "x$mhd_cv_cc_cfl_supp__Walloca" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Walloca" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Walloca" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wbidi-chars=any flag" >&5 printf %s "checking whether $CC supports -Wbidi-chars=any flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wbidi_chars_any+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wbidi-chars=any ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbidi_chars_any="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbidi_chars_any="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wbidi-chars=any ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbidi_chars_any="yes" else $as_nop mhd_cv_cc_cfl_supp__Wbidi_chars_any="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wbidi_chars_any" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wbidi_chars_any" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wbidi_chars_any" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wbidi-chars=any" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wbidi-chars=any" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Warray-bounds flag" >&5 printf %s "checking whether $CC supports -Warray-bounds flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Warray_bounds+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Warray-bounds ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Warray_bounds="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Warray_bounds="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Warray-bounds ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Warray_bounds="yes" else $as_nop mhd_cv_cc_cfl_supp__Warray_bounds="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Warray_bounds" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Warray_bounds" >&6; } if test "x$mhd_cv_cc_cfl_supp__Warray_bounds" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Warray-bounds" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Warray-bounds" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wpacked flag" >&5 printf %s "checking whether $CC supports -Wpacked flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wpacked+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wpacked ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wpacked="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wpacked="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wpacked ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wpacked="yes" else $as_nop mhd_cv_cc_cfl_supp__Wpacked="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wpacked" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wpacked" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wpacked" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wpacked" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wpacked" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wvariadic-macros flag" >&5 printf %s "checking whether $CC supports -Wvariadic-macros flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wvariadic_macros+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wvariadic-macros ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wvariadic_macros="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wvariadic_macros="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wvariadic-macros ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wvariadic_macros="yes" else $as_nop mhd_cv_cc_cfl_supp__Wvariadic_macros="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wvariadic_macros" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wvariadic_macros" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wvariadic_macros" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wvariadic-macros" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wvariadic-macros" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wundef flag" >&5 printf %s "checking whether $CC supports -Wundef flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wundef+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wundef ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wundef="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wundef="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wundef ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wundef="yes" else $as_nop mhd_cv_cc_cfl_supp__Wundef="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wundef" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wundef" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wundef" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wundef" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wundef" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wanon-enum-enum-conversion flag" >&5 printf %s "checking whether $CC supports -Wanon-enum-enum-conversion flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wanon_enum_enum_conversion+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wanon-enum-enum-conversion ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wanon_enum_enum_conversion="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wanon_enum_enum_conversion="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wanon-enum-enum-conversion ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wanon_enum_enum_conversion="yes" else $as_nop mhd_cv_cc_cfl_supp__Wanon_enum_enum_conversion="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wanon_enum_enum_conversion" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wanon_enum_enum_conversion" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wanon_enum_enum_conversion" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wanon-enum-enum-conversion" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wanon-enum-enum-conversion" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Warray-bounds-pointer-arithmetic flag" >&5 printf %s "checking whether $CC supports -Warray-bounds-pointer-arithmetic flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Warray_bounds_pointer_arithmetic+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Warray-bounds-pointer-arithmetic ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Warray_bounds_pointer_arithmetic="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Warray_bounds_pointer_arithmetic="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Warray-bounds-pointer-arithmetic ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Warray_bounds_pointer_arithmetic="yes" else $as_nop mhd_cv_cc_cfl_supp__Warray_bounds_pointer_arithmetic="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Warray_bounds_pointer_arithmetic" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Warray_bounds_pointer_arithmetic" >&6; } if test "x$mhd_cv_cc_cfl_supp__Warray_bounds_pointer_arithmetic" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Warray-bounds-pointer-arithmetic" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Warray-bounds-pointer-arithmetic" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wassign-enum flag" >&5 printf %s "checking whether $CC supports -Wassign-enum flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wassign_enum+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wassign-enum ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wassign_enum="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wassign_enum="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wassign-enum ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wassign_enum="yes" else $as_nop mhd_cv_cc_cfl_supp__Wassign_enum="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wassign_enum" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wassign_enum" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wassign_enum" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wassign-enum" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wassign-enum" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wbit-int-extension flag" >&5 printf %s "checking whether $CC supports -Wbit-int-extension flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wbit_int_extension+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wbit-int-extension ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbit_int_extension="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbit_int_extension="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wbit-int-extension ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbit_int_extension="yes" else $as_nop mhd_cv_cc_cfl_supp__Wbit_int_extension="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wbit_int_extension" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wbit_int_extension" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wbit_int_extension" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wbit-int-extension" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wbit-int-extension" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wbitfield-enum-conversion flag" >&5 printf %s "checking whether $CC supports -Wbitfield-enum-conversion flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wbitfield_enum_conversion+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wbitfield-enum-conversion ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbitfield_enum_conversion="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbitfield_enum_conversion="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wbitfield-enum-conversion ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbitfield_enum_conversion="yes" else $as_nop mhd_cv_cc_cfl_supp__Wbitfield_enum_conversion="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wbitfield_enum_conversion" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wbitfield_enum_conversion" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wbitfield_enum_conversion" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wbitfield-enum-conversion" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wbitfield-enum-conversion" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wparentheses flag" >&5 printf %s "checking whether $CC supports -Wparentheses flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wparentheses+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wparentheses ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wparentheses="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wparentheses="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wparentheses ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wparentheses="yes" else $as_nop mhd_cv_cc_cfl_supp__Wparentheses="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wparentheses" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wparentheses" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wparentheses" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wparentheses" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wparentheses" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wbool-operation flag" >&5 printf %s "checking whether $CC supports -Wbool-operation flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wbool_operation+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wbool-operation ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbool_operation="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbool_operation="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wbool-operation ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbool_operation="yes" else $as_nop mhd_cv_cc_cfl_supp__Wbool_operation="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wbool_operation" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wbool_operation" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wbool_operation" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wbool-operation" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wbool-operation" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wcast-function-type flag" >&5 printf %s "checking whether $CC supports -Wcast-function-type flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wcast_function_type+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wcast-function-type ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_function_type="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_function_type="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wcast-function-type ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcast_function_type="yes" else $as_nop mhd_cv_cc_cfl_supp__Wcast_function_type="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wcast_function_type" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wcast_function_type" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wcast_function_type" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wcast-function-type" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wcast-function-type" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wcomma flag" >&5 printf %s "checking whether $CC supports -Wcomma flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wcomma+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wcomma ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcomma="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcomma="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wcomma ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcomma="yes" else $as_nop mhd_cv_cc_cfl_supp__Wcomma="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wcomma" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wcomma" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wcomma" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wcomma" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wcomma" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wcomment flag" >&5 printf %s "checking whether $CC supports -Wcomment flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wcomment+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wcomment ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcomment="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcomment="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wcomment ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcomment="yes" else $as_nop mhd_cv_cc_cfl_supp__Wcomment="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wcomment" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wcomment" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wcomment" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wcomment" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wcomment" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wcompound-token-split flag" >&5 printf %s "checking whether $CC supports -Wcompound-token-split flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wcompound_token_split+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wcompound-token-split ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcompound_token_split="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcompound_token_split="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wcompound-token-split ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wcompound_token_split="yes" else $as_nop mhd_cv_cc_cfl_supp__Wcompound_token_split="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wcompound_token_split" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wcompound_token_split" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wcompound_token_split" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wcompound-token-split" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wcompound-token-split" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wconditional-uninitialized flag" >&5 printf %s "checking whether $CC supports -Wconditional-uninitialized flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wconditional_uninitialized+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wconditional-uninitialized ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wconditional_uninitialized="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wconditional_uninitialized="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wconditional-uninitialized ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wconditional_uninitialized="yes" else $as_nop mhd_cv_cc_cfl_supp__Wconditional_uninitialized="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wconditional_uninitialized" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wconditional_uninitialized" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wconditional_uninitialized" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wconditional-uninitialized" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wconditional-uninitialized" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wdeprecated flag" >&5 printf %s "checking whether $CC supports -Wdeprecated flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wdeprecated+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wdeprecated ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdeprecated="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdeprecated="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wdeprecated ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdeprecated="yes" else $as_nop mhd_cv_cc_cfl_supp__Wdeprecated="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wdeprecated" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wdeprecated" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wdeprecated" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wdeprecated" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wdeprecated" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wdocumentation-pedantic flag" >&5 printf %s "checking whether $CC supports -Wdocumentation-pedantic flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wdocumentation_pedantic+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wdocumentation-pedantic ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdocumentation_pedantic="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdocumentation_pedantic="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wdocumentation-pedantic ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wdocumentation_pedantic="yes" else $as_nop mhd_cv_cc_cfl_supp__Wdocumentation_pedantic="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wdocumentation_pedantic" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wdocumentation_pedantic" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wdocumentation_pedantic" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wdocumentation-pedantic" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wdocumentation-pedantic" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wempty-init-stmt flag" >&5 printf %s "checking whether $CC supports -Wempty-init-stmt flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wempty_init_stmt+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wempty-init-stmt ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wempty_init_stmt="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wempty_init_stmt="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wempty-init-stmt ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wempty_init_stmt="yes" else $as_nop mhd_cv_cc_cfl_supp__Wempty_init_stmt="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wempty_init_stmt" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wempty_init_stmt" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wempty_init_stmt" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wempty-init-stmt" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wempty-init-stmt" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wenum-conversion flag" >&5 printf %s "checking whether $CC supports -Wenum-conversion flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wenum_conversion+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wenum-conversion ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wenum_conversion="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wenum_conversion="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wenum-conversion ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wenum_conversion="yes" else $as_nop mhd_cv_cc_cfl_supp__Wenum_conversion="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wenum_conversion" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wenum_conversion" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wenum_conversion" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wenum-conversion" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wenum-conversion" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wexpansion-to-defined flag" >&5 printf %s "checking whether $CC supports -Wexpansion-to-defined flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wexpansion_to_defined+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wexpansion-to-defined ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wexpansion_to_defined="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wexpansion_to_defined="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wexpansion-to-defined ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wexpansion_to_defined="yes" else $as_nop mhd_cv_cc_cfl_supp__Wexpansion_to_defined="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wexpansion_to_defined" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wexpansion_to_defined" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wexpansion_to_defined" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wexpansion-to-defined" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wexpansion-to-defined" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wflexible-array-extensions flag" >&5 printf %s "checking whether $CC supports -Wflexible-array-extensions flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wflexible_array_extensions+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wflexible-array-extensions ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wflexible_array_extensions="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wflexible_array_extensions="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wflexible-array-extensions ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wflexible_array_extensions="yes" else $as_nop mhd_cv_cc_cfl_supp__Wflexible_array_extensions="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wflexible_array_extensions" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wflexible_array_extensions" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wflexible_array_extensions" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wflexible-array-extensions" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wflexible-array-extensions" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wloop-analysis flag" >&5 printf %s "checking whether $CC supports -Wloop-analysis flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wloop_analysis+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wloop-analysis ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wloop_analysis="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wloop_analysis="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wloop-analysis ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wloop_analysis="yes" else $as_nop mhd_cv_cc_cfl_supp__Wloop_analysis="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wloop_analysis" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wloop_analysis" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wloop_analysis" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wloop-analysis" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wloop-analysis" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat-pedantic flag" >&5 printf %s "checking whether $CC supports -Wformat-pedantic flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wformat_pedantic+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wformat-pedantic ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_pedantic="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_pedantic="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wformat-pedantic ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_pedantic="yes" else $as_nop mhd_cv_cc_cfl_supp__Wformat_pedantic="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wformat_pedantic" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wformat_pedantic" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wformat_pedantic" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wformat-pedantic" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wformat-pedantic" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat-type-confusion flag" >&5 printf %s "checking whether $CC supports -Wformat-type-confusion flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wformat_type_confusion+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wformat-type-confusion ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_type_confusion="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_type_confusion="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wformat-type-confusion ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_type_confusion="yes" else $as_nop mhd_cv_cc_cfl_supp__Wformat_type_confusion="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wformat_type_confusion" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wformat_type_confusion" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wformat_type_confusion" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wformat-type-confusion" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wformat-type-confusion" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wfour-char-constants flag" >&5 printf %s "checking whether $CC supports -Wfour-char-constants flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wfour_char_constants+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wfour-char-constants ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wfour_char_constants="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wfour_char_constants="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wfour-char-constants ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wfour_char_constants="yes" else $as_nop mhd_cv_cc_cfl_supp__Wfour_char_constants="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wfour_char_constants" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wfour_char_constants" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wfour_char_constants" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wfour-char-constants" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wfour-char-constants" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgcc-compat flag" >&5 printf %s "checking whether $CC supports -Wgcc-compat flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgcc_compat+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgcc-compat ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgcc_compat="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgcc_compat="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgcc-compat ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgcc_compat="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgcc_compat="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgcc_compat" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgcc_compat" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgcc_compat" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgcc-compat" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgcc-compat" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-anonymous-struct flag" >&5 printf %s "checking whether $CC supports -Wgnu-anonymous-struct flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_anonymous_struct+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-anonymous-struct ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_anonymous_struct="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_anonymous_struct="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-anonymous-struct ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_anonymous_struct="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_anonymous_struct="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_anonymous_struct" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_anonymous_struct" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_anonymous_struct" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-anonymous-struct" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-anonymous-struct" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-compound-literal-initializer flag" >&5 printf %s "checking whether $CC supports -Wgnu-compound-literal-initializer flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_compound_literal_initializer+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-compound-literal-initializer ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_compound_literal_initializer="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_compound_literal_initializer="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-compound-literal-initializer ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_compound_literal_initializer="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_compound_literal_initializer="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_compound_literal_initializer" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_compound_literal_initializer" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_compound_literal_initializer" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-compound-literal-initializer" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-compound-literal-initializer" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-conditional-omitted-operand flag" >&5 printf %s "checking whether $CC supports -Wgnu-conditional-omitted-operand flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_conditional_omitted_operand+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-conditional-omitted-operand ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_conditional_omitted_operand="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_conditional_omitted_operand="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-conditional-omitted-operand ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_conditional_omitted_operand="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_conditional_omitted_operand="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_conditional_omitted_operand" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_conditional_omitted_operand" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_conditional_omitted_operand" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-conditional-omitted-operand" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-conditional-omitted-operand" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-designator flag" >&5 printf %s "checking whether $CC supports -Wgnu-designator flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_designator+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-designator ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_designator="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_designator="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-designator ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_designator="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_designator="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_designator" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_designator" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_designator" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-designator" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-designator" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-empty-initializer flag" >&5 printf %s "checking whether $CC supports -Wgnu-empty-initializer flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_empty_initializer+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-empty-initializer ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_empty_initializer="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_empty_initializer="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-empty-initializer ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_empty_initializer="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_empty_initializer="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_empty_initializer" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_empty_initializer" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_empty_initializer" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-empty-initializer" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-empty-initializer" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-empty-struct flag" >&5 printf %s "checking whether $CC supports -Wgnu-empty-struct flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_empty_struct+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-empty-struct ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_empty_struct="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_empty_struct="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-empty-struct ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_empty_struct="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_empty_struct="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_empty_struct" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_empty_struct" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_empty_struct" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-empty-struct" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-empty-struct" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-flexible-array-initializer flag" >&5 printf %s "checking whether $CC supports -Wgnu-flexible-array-initializer flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_flexible_array_initializer+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-flexible-array-initializer ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_flexible_array_initializer="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_flexible_array_initializer="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-flexible-array-initializer ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_flexible_array_initializer="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_flexible_array_initializer="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_flexible_array_initializer" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_flexible_array_initializer" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_flexible_array_initializer" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-flexible-array-initializer" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-flexible-array-initializer" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-folding-constant flag" >&5 printf %s "checking whether $CC supports -Wgnu-folding-constant flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_folding_constant+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-folding-constant ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_folding_constant="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_folding_constant="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-folding-constant ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_folding_constant="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_folding_constant="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_folding_constant" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_folding_constant" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_folding_constant" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-folding-constant" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-folding-constant" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-null-pointer-arithmetic flag" >&5 printf %s "checking whether $CC supports -Wgnu-null-pointer-arithmetic flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_null_pointer_arithmetic+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-null-pointer-arithmetic ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_null_pointer_arithmetic="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_null_pointer_arithmetic="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-null-pointer-arithmetic ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_null_pointer_arithmetic="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_null_pointer_arithmetic="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_null_pointer_arithmetic" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_null_pointer_arithmetic" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_null_pointer_arithmetic" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-null-pointer-arithmetic" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-null-pointer-arithmetic" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-pointer-arith flag" >&5 printf %s "checking whether $CC supports -Wgnu-pointer-arith flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_pointer_arith+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-pointer-arith ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_pointer_arith="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_pointer_arith="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-pointer-arith ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_pointer_arith="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_pointer_arith="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_pointer_arith" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_pointer_arith" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_pointer_arith" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-pointer-arith" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-pointer-arith" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-redeclared-enum flag" >&5 printf %s "checking whether $CC supports -Wgnu-redeclared-enum flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_redeclared_enum+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-redeclared-enum ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_redeclared_enum="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_redeclared_enum="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-redeclared-enum ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_redeclared_enum="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_redeclared_enum="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_redeclared_enum" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_redeclared_enum" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_redeclared_enum" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-redeclared-enum" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-redeclared-enum" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-union-cast flag" >&5 printf %s "checking whether $CC supports -Wgnu-union-cast flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_union_cast+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-union-cast ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_union_cast="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_union_cast="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-union-cast ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_union_cast="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_union_cast="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_union_cast" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_union_cast" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_union_cast" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-union-cast" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-union-cast" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wgnu-variable-sized-type-not-at-end flag" >&5 printf %s "checking whether $CC supports -Wgnu-variable-sized-type-not-at-end flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wgnu_variable_sized_type_not_at_end+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wgnu-variable-sized-type-not-at-end ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_variable_sized_type_not_at_end="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_variable_sized_type_not_at_end="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wgnu-variable-sized-type-not-at-end ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wgnu_variable_sized_type_not_at_end="yes" else $as_nop mhd_cv_cc_cfl_supp__Wgnu_variable_sized_type_not_at_end="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wgnu_variable_sized_type_not_at_end" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wgnu_variable_sized_type_not_at_end" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wgnu_variable_sized_type_not_at_end" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wgnu-variable-sized-type-not-at-end" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wgnu-variable-sized-type-not-at-end" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Widiomatic-parentheses flag" >&5 printf %s "checking whether $CC supports -Widiomatic-parentheses flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Widiomatic_parentheses+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Widiomatic-parentheses ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Widiomatic_parentheses="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Widiomatic_parentheses="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Widiomatic-parentheses ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Widiomatic_parentheses="yes" else $as_nop mhd_cv_cc_cfl_supp__Widiomatic_parentheses="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Widiomatic_parentheses" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Widiomatic_parentheses" >&6; } if test "x$mhd_cv_cc_cfl_supp__Widiomatic_parentheses" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Widiomatic-parentheses" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Widiomatic-parentheses" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wmissing-noreturn flag" >&5 printf %s "checking whether $CC supports -Wmissing-noreturn flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wmissing_noreturn+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wmissing-noreturn ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_noreturn="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_noreturn="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wmissing-noreturn ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_noreturn="yes" else $as_nop mhd_cv_cc_cfl_supp__Wmissing_noreturn="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wmissing_noreturn" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wmissing_noreturn" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wmissing_noreturn" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wmissing-noreturn" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wmissing-noreturn" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wmissing-variable-declarations flag" >&5 printf %s "checking whether $CC supports -Wmissing-variable-declarations flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wmissing_variable_declarations+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wmissing-variable-declarations ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_variable_declarations="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_variable_declarations="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wmissing-variable-declarations ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wmissing_variable_declarations="yes" else $as_nop mhd_cv_cc_cfl_supp__Wmissing_variable_declarations="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wmissing_variable_declarations" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wmissing_variable_declarations" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wmissing_variable_declarations" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wmissing-variable-declarations" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wmissing-variable-declarations" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wnested-anon-types flag" >&5 printf %s "checking whether $CC supports -Wnested-anon-types flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wnested_anon_types+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wnested-anon-types ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnested_anon_types="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnested_anon_types="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wnested-anon-types ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnested_anon_types="yes" else $as_nop mhd_cv_cc_cfl_supp__Wnested_anon_types="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wnested_anon_types" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wnested_anon_types" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wnested_anon_types" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wnested-anon-types" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wnested-anon-types" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wnewline-eof flag" >&5 printf %s "checking whether $CC supports -Wnewline-eof flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wnewline_eof+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wnewline-eof ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnewline_eof="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnewline_eof="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wnewline-eof ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wnewline_eof="yes" else $as_nop mhd_cv_cc_cfl_supp__Wnewline_eof="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wnewline_eof" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wnewline_eof" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wnewline_eof" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wnewline-eof" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wnewline-eof" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wover-aligned flag" >&5 printf %s "checking whether $CC supports -Wover-aligned flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wover_aligned+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wover-aligned ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wover_aligned="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wover_aligned="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wover-aligned ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wover_aligned="yes" else $as_nop mhd_cv_cc_cfl_supp__Wover_aligned="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wover_aligned" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wover_aligned" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wover_aligned" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wover-aligned" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wover-aligned" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wredundant-parens flag" >&5 printf %s "checking whether $CC supports -Wredundant-parens flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wredundant_parens+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wredundant-parens ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wredundant_parens="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wredundant_parens="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wredundant-parens ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wredundant_parens="yes" else $as_nop mhd_cv_cc_cfl_supp__Wredundant_parens="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wredundant_parens" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wredundant_parens" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wredundant_parens" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wredundant-parens" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wredundant-parens" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wshift-sign-overflow flag" >&5 printf %s "checking whether $CC supports -Wshift-sign-overflow flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wshift_sign_overflow+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wshift-sign-overflow ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshift_sign_overflow="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshift_sign_overflow="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wshift-sign-overflow ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wshift_sign_overflow="yes" else $as_nop mhd_cv_cc_cfl_supp__Wshift_sign_overflow="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wshift_sign_overflow" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wshift_sign_overflow" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wshift_sign_overflow" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wshift-sign-overflow" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wshift-sign-overflow" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wtautological-compare flag" >&5 printf %s "checking whether $CC supports -Wtautological-compare flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wtautological_compare+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wtautological-compare ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wtautological_compare="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wtautological_compare="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wtautological-compare ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wtautological_compare="yes" else $as_nop mhd_cv_cc_cfl_supp__Wtautological_compare="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wtautological_compare" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wtautological_compare" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wtautological_compare" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wtautological-compare" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wtautological-compare" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wunaligned-access flag" >&5 printf %s "checking whether $CC supports -Wunaligned-access flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wunaligned_access+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wunaligned-access ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunaligned_access="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunaligned_access="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wunaligned-access ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunaligned_access="yes" else $as_nop mhd_cv_cc_cfl_supp__Wunaligned_access="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wunaligned_access" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wunaligned_access" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wunaligned_access" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wunaligned-access" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wunaligned-access" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wunused flag" >&5 printf %s "checking whether $CC supports -Wunused flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wunused+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wunused ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunused="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunused="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wunused ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wunused="yes" else $as_nop mhd_cv_cc_cfl_supp__Wunused="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wunused" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wunused" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wunused" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wunused" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wunused" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wzero-as-null-pointer-constant flag" >&5 printf %s "checking whether $CC supports -Wzero-as-null-pointer-constant flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wzero_as_null_pointer_constant+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wzero-as-null-pointer-constant ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wzero_as_null_pointer_constant="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wzero_as_null_pointer_constant="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wzero-as-null-pointer-constant ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wzero_as_null_pointer_constant="yes" else $as_nop mhd_cv_cc_cfl_supp__Wzero_as_null_pointer_constant="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wzero_as_null_pointer_constant" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wzero_as_null_pointer_constant" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wzero_as_null_pointer_constant" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wzero-as-null-pointer-constant" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wzero-as-null-pointer-constant" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wzero-length-array flag" >&5 printf %s "checking whether $CC supports -Wzero-length-array flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wzero_length_array+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wzero-length-array ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wzero_length_array="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wzero_length_array="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wzero-length-array ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wzero_length_array="yes" else $as_nop mhd_cv_cc_cfl_supp__Wzero_length_array="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wzero_length_array" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wzero_length_array" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wzero_length_array" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wzero-length-array" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wzero-length-array" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wused-but-marked-unused flag" >&5 printf %s "checking whether $CC supports -Wused-but-marked-unused flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wused_but_marked_unused+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wused-but-marked-unused ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wused_but_marked_unused="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wused_but_marked_unused="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wused-but-marked-unused ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wused_but_marked_unused="yes" else $as_nop mhd_cv_cc_cfl_supp__Wused_but_marked_unused="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wused_but_marked_unused" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wused_but_marked_unused" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wused_but_marked_unused" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC -Wused-but-marked-unused works with system headers" >&5 printf %s "checking whether $CC -Wused-but-marked-unused works with system headers... " >&6; } if test ${mhd_cv_wused_but_marked_unused_sys_header+y} then : printf %s "(cached) " >&6 else $as_nop SAVE_ac_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag="yes" CFLAGS="${CFLAGS_ac} -Wused-but-marked-unused ${user_CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { char buf[16]; return (int) snprintf(buf, 16, "test"); } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_wused_but_marked_unused_sys_header="yes" else $as_nop mhd_cv_wused_but_marked_unused_sys_header="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_c_werror_flag="$SAVE_ac_c_werror_flag" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_wused_but_marked_unused_sys_header" >&5 printf "%s\n" "$mhd_cv_wused_but_marked_unused_sys_header" >&6; } if test "x$mhd_cv_wused_but_marked_unused_sys_header" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wused-but-marked-unused" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wused-but-marked-unused" fi fi fi # # Removed flags: # # -Wdisabled-macro-expansion - warns about macros from system headers CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${user_LDFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--enable-long-section-names flag" >&5 printf %s "checking whether $CC supports -Wl,--enable-long-section-names flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl___enable_long_section_names+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,--enable-long-section-names ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___enable_long_section_names="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___enable_long_section_names="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,--enable-long-section-names ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___enable_long_section_names="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl___enable_long_section_names="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl___enable_long_section_names" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl___enable_long_section_names" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl___enable_long_section_names" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,--enable-long-section-names" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,--enable-long-section-names" fi fi LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ;; #( *) : ;; esac case ${enable_build_type} in #( release|release-*) : # All release types CFLAGS="${user_CFLAGS}" if test "x$enable_build_type" = x"release-compact" then : else $as_nop # All non-compact release types { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fsched-pressure flag" >&5 printf %s "checking whether $CC supports -fsched-pressure flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fsched_pressure+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fsched-pressure ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fsched_pressure="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fsched_pressure="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fsched-pressure ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fsched_pressure="yes" else $as_nop mhd_cv_cc_cfl_supp__fsched_pressure="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fsched_pressure" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fsched_pressure" >&6; } if test "x$mhd_cv_cc_cfl_supp__fsched_pressure" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fsched-pressure" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fsched-pressure" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fira-loop-pressure flag" >&5 printf %s "checking whether $CC supports -fira-loop-pressure flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fira_loop_pressure+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fira-loop-pressure ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fira_loop_pressure="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fira_loop_pressure="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fira-loop-pressure ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fira_loop_pressure="yes" else $as_nop mhd_cv_cc_cfl_supp__fira_loop_pressure="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fira_loop_pressure" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fira_loop_pressure" >&6; } if test "x$mhd_cv_cc_cfl_supp__fira_loop_pressure" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fira-loop-pressure" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fira-loop-pressure" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fmerge-all-constants flag" >&5 printf %s "checking whether $CC supports -fmerge-all-constants flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fmerge_all_constants+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fmerge-all-constants ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fmerge_all_constants="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fmerge_all_constants="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fmerge-all-constants ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fmerge_all_constants="yes" else $as_nop mhd_cv_cc_cfl_supp__fmerge_all_constants="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fmerge_all_constants" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fmerge_all_constants" >&6; } if test "x$mhd_cv_cc_cfl_supp__fmerge_all_constants" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fmerge-all-constants" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fmerge-all-constants" fi fi # These flags may improve size, recheck with LTO and linker garbage collection { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -ftree-partial-pre flag" >&5 printf %s "checking whether $CC supports -ftree-partial-pre flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__ftree_partial_pre+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -ftree-partial-pre ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftree_partial_pre="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftree_partial_pre="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -ftree-partial-pre ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftree_partial_pre="yes" else $as_nop mhd_cv_cc_cfl_supp__ftree_partial_pre="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__ftree_partial_pre" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__ftree_partial_pre" >&6; } if test "x$mhd_cv_cc_cfl_supp__ftree_partial_pre" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-ftree-partial-pre" else $as_nop CFLAGS_ac="${CFLAGS_ac} -ftree-partial-pre" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fgcse-after-reload flag" >&5 printf %s "checking whether $CC supports -fgcse-after-reload flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fgcse_after_reload+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fgcse-after-reload ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fgcse_after_reload="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fgcse_after_reload="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fgcse-after-reload ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fgcse_after_reload="yes" else $as_nop mhd_cv_cc_cfl_supp__fgcse_after_reload="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fgcse_after_reload" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fgcse_after_reload" >&6; } if test "x$mhd_cv_cc_cfl_supp__fgcse_after_reload" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fgcse-after-reload" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fgcse-after-reload" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fipa-pta flag" >&5 printf %s "checking whether $CC supports -fipa-pta flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fipa_pta+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fipa-pta ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fipa_pta="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fipa_pta="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fipa-pta ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fipa_pta="yes" else $as_nop mhd_cv_cc_cfl_supp__fipa_pta="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fipa_pta" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fipa_pta" >&6; } if test "x$mhd_cv_cc_cfl_supp__fipa_pta" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fipa-pta" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fipa-pta" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fisolate-erroneous-paths-attribute flag" >&5 printf %s "checking whether $CC supports -fisolate-erroneous-paths-attribute flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fisolate_erroneous_paths_attribute+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fisolate-erroneous-paths-attribute ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fisolate_erroneous_paths_attribute="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fisolate_erroneous_paths_attribute="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fisolate-erroneous-paths-attribute ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fisolate_erroneous_paths_attribute="yes" else $as_nop mhd_cv_cc_cfl_supp__fisolate_erroneous_paths_attribute="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fisolate_erroneous_paths_attribute" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fisolate_erroneous_paths_attribute" >&6; } if test "x$mhd_cv_cc_cfl_supp__fisolate_erroneous_paths_attribute" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fisolate-erroneous-paths-attribute" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fisolate-erroneous-paths-attribute" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -ffinite-loops flag" >&5 printf %s "checking whether $CC supports -ffinite-loops flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__ffinite_loops+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -ffinite-loops ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ffinite_loops="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ffinite_loops="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -ffinite-loops ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ffinite_loops="yes" else $as_nop mhd_cv_cc_cfl_supp__ffinite_loops="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__ffinite_loops" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__ffinite_loops" >&6; } if test "x$mhd_cv_cc_cfl_supp__ffinite_loops" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-ffinite-loops" else $as_nop CFLAGS_ac="${CFLAGS_ac} -ffinite-loops" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -floop-nest-optimize flag" >&5 printf %s "checking whether $CC supports -floop-nest-optimize flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__floop_nest_optimize+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -floop-nest-optimize ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__floop_nest_optimize="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__floop_nest_optimize="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -floop-nest-optimize ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__floop_nest_optimize="yes" else $as_nop mhd_cv_cc_cfl_supp__floop_nest_optimize="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__floop_nest_optimize" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__floop_nest_optimize" >&6; } if test "x$mhd_cv_cc_cfl_supp__floop_nest_optimize" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-floop-nest-optimize" else $as_nop CFLAGS_ac="${CFLAGS_ac} -floop-nest-optimize" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fpredictive-commoning flag" >&5 printf %s "checking whether $CC supports -fpredictive-commoning flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fpredictive_commoning+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fpredictive-commoning ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fpredictive_commoning="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fpredictive_commoning="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fpredictive-commoning ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fpredictive_commoning="yes" else $as_nop mhd_cv_cc_cfl_supp__fpredictive_commoning="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fpredictive_commoning" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fpredictive_commoning" >&6; } if test "x$mhd_cv_cc_cfl_supp__fpredictive_commoning" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fpredictive-commoning" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fpredictive-commoning" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -frename-registers flag" >&5 printf %s "checking whether $CC supports -frename-registers flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__frename_registers+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -frename-registers ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__frename_registers="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__frename_registers="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -frename-registers ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__frename_registers="yes" else $as_nop mhd_cv_cc_cfl_supp__frename_registers="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__frename_registers" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__frename_registers" >&6; } if test "x$mhd_cv_cc_cfl_supp__frename_registers" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-frename-registers" else $as_nop CFLAGS_ac="${CFLAGS_ac} -frename-registers" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -ftree-loop-distribute-patterns flag" >&5 printf %s "checking whether $CC supports -ftree-loop-distribute-patterns flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__ftree_loop_distribute_patterns+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -ftree-loop-distribute-patterns ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftree_loop_distribute_patterns="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftree_loop_distribute_patterns="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -ftree-loop-distribute-patterns ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftree_loop_distribute_patterns="yes" else $as_nop mhd_cv_cc_cfl_supp__ftree_loop_distribute_patterns="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__ftree_loop_distribute_patterns" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__ftree_loop_distribute_patterns" >&6; } if test "x$mhd_cv_cc_cfl_supp__ftree_loop_distribute_patterns" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-ftree-loop-distribute-patterns" else $as_nop CFLAGS_ac="${CFLAGS_ac} -ftree-loop-distribute-patterns" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fpeel-loops flag" >&5 printf %s "checking whether $CC supports -fpeel-loops flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fpeel_loops+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fpeel-loops ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fpeel_loops="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fpeel_loops="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fpeel-loops ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fpeel_loops="yes" else $as_nop mhd_cv_cc_cfl_supp__fpeel_loops="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fpeel_loops" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fpeel_loops" >&6; } if test "x$mhd_cv_cc_cfl_supp__fpeel_loops" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fpeel-loops" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fpeel-loops" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fsplit-loops flag" >&5 printf %s "checking whether $CC supports -fsplit-loops flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fsplit_loops+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fsplit-loops ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fsplit_loops="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fsplit_loops="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fsplit-loops ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fsplit_loops="yes" else $as_nop mhd_cv_cc_cfl_supp__fsplit_loops="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fsplit_loops" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fsplit_loops" >&6; } if test "x$mhd_cv_cc_cfl_supp__fsplit_loops" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fsplit-loops" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fsplit-loops" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -ftree-vectorize flag" >&5 printf %s "checking whether $CC supports -ftree-vectorize flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__ftree_vectorize+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -ftree-vectorize ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftree_vectorize="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftree_vectorize="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -ftree-vectorize ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftree_vectorize="yes" else $as_nop mhd_cv_cc_cfl_supp__ftree_vectorize="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__ftree_vectorize" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__ftree_vectorize" >&6; } if test "x$mhd_cv_cc_cfl_supp__ftree_vectorize" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-ftree-vectorize" else $as_nop CFLAGS_ac="${CFLAGS_ac} -ftree-vectorize" fi fi fi if test "x$enable_build_type" = x"release-hardened" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat-security flag" >&5 printf %s "checking whether $CC supports -Wformat-security flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wformat_security+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wformat-security ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_security="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_security="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wformat-security ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wformat_security="yes" else $as_nop mhd_cv_cc_cfl_supp__Wformat_security="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wformat_security" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wformat_security" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wformat_security" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wformat-security" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wformat-security" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wstack-protector flag" >&5 printf %s "checking whether $CC supports -Wstack-protector flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wstack_protector+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wstack-protector ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstack_protector="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstack_protector="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wstack-protector ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wstack_protector="yes" else $as_nop mhd_cv_cc_cfl_supp__Wstack_protector="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wstack_protector" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wstack_protector" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wstack_protector" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wstack-protector" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wstack-protector" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wuninitialized flag" >&5 printf %s "checking whether $CC supports -Wuninitialized flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wuninitialized+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wuninitialized ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wuninitialized="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wuninitialized="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wuninitialized ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wuninitialized="yes" else $as_nop mhd_cv_cc_cfl_supp__Wuninitialized="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wuninitialized" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wuninitialized" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wuninitialized" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wuninitialized" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wuninitialized" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Winit-self flag" >&5 printf %s "checking whether $CC supports -Winit-self flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Winit_self+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Winit-self ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Winit_self="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Winit_self="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Winit-self ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Winit_self="yes" else $as_nop mhd_cv_cc_cfl_supp__Winit_self="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Winit_self" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Winit_self" >&6; } if test "x$mhd_cv_cc_cfl_supp__Winit_self" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Winit-self" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Winit-self" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Walloc-zero flag" >&5 printf %s "checking whether $CC supports -Walloc-zero flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Walloc_zero+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Walloc-zero ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Walloc_zero="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Walloc_zero="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Walloc-zero ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Walloc_zero="yes" else $as_nop mhd_cv_cc_cfl_supp__Walloc_zero="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Walloc_zero" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Walloc_zero" >&6; } if test "x$mhd_cv_cc_cfl_supp__Walloc_zero" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Walloc-zero" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Walloc-zero" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wbidi-chars=any flag" >&5 printf %s "checking whether $CC supports -Wbidi-chars=any flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wbidi_chars_any+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wbidi-chars=any ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbidi_chars_any="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbidi_chars_any="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wbidi-chars=any ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wbidi_chars_any="yes" else $as_nop mhd_cv_cc_cfl_supp__Wbidi_chars_any="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wbidi_chars_any" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wbidi_chars_any" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wbidi_chars_any" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wbidi-chars=any" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wbidi-chars=any" fi fi fi if test "x$enable_build_type" = x"release" then : # Flags are not suitable for 'compact' and for 'hardened' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -ffast-math flag" >&5 printf %s "checking whether $CC supports -ffast-math flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__ffast_math+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -ffast-math ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ffast_math="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ffast_math="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -ffast-math ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ffast_math="yes" else $as_nop mhd_cv_cc_cfl_supp__ffast_math="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__ffast_math" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__ffast_math" >&6; } if test "x$mhd_cv_cc_cfl_supp__ffast_math" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-ffast-math" else $as_nop CFLAGS_ac="${CFLAGS_ac} -ffast-math" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fno-trapping-math flag" >&5 printf %s "checking whether $CC supports -fno-trapping-math flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fno_trapping_math+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fno-trapping-math ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fno_trapping_math="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fno_trapping_math="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fno-trapping-math ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fno_trapping_math="yes" else $as_nop mhd_cv_cc_cfl_supp__fno_trapping_math="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fno_trapping_math" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fno_trapping_math" >&6; } if test "x$mhd_cv_cc_cfl_supp__fno_trapping_math" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fno-trapping-math" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fno-trapping-math" fi fi fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" # W32-specific LDFLAGS="${user_LDFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--disable-long-section-names flag" >&5 printf %s "checking whether $CC supports -Wl,--disable-long-section-names flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl___disable_long_section_names+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,--disable-long-section-names ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___disable_long_section_names="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___disable_long_section_names="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,--disable-long-section-names ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___disable_long_section_names="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl___disable_long_section_names="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl___disable_long_section_names" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl___disable_long_section_names" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl___disable_long_section_names" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,--disable-long-section-names" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,--disable-long-section-names" fi fi LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ;; #( *) : ;; esac CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" # Additional flags are checked and added at the end of 'configure' # Check for headers that are ALWAYS required # Check for basic optional headers ac_fn_c_check_header_compile "$LINENO" "stddef.h" "ac_cv_header_stddef_h" "$ac_includes_default " if test "x$ac_cv_header_stddef_h" = xyes then : printf "%s\n" "#define HAVE_STDDEF_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default " if test "x$ac_cv_header_stdlib_h" = xyes then : printf "%s\n" "#define HAVE_STDLIB_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default " if test "x$ac_cv_header_inttypes_h" = xyes then : printf "%s\n" "#define HAVE_INTTYPES_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/types.h" "ac_cv_header_sys_types_h" "$ac_includes_default " if test "x$ac_cv_header_sys_types_h" = xyes then : printf "%s\n" "#define HAVE_SYS_TYPES_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/stat.h" "ac_cv_header_sys_stat_h" "$ac_includes_default " if test "x$ac_cv_header_sys_stat_h" = xyes then : printf "%s\n" "#define HAVE_SYS_STAT_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default " if test "x$ac_cv_header_unistd_h" = xyes then : printf "%s\n" "#define HAVE_UNISTD_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/uio.h" "ac_cv_header_sys_uio_h" "$ac_includes_default " if test "x$ac_cv_header_sys_uio_h" = xyes then : printf "%s\n" "#define HAVE_SYS_UIO_H 1" >>confdefs.h fi # Check for clock-specific optional headers ac_fn_c_check_header_compile "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default " if test "x$ac_cv_header_sys_time_h" = xyes then : printf "%s\n" "#define HAVE_SYS_TIME_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default " if test "x$ac_cv_header_time_h" = xyes then : printf "%s\n" "#define HAVE_TIME_H 1" >>confdefs.h fi # Check for system information and parameters optional headers ac_fn_c_check_header_compile "$LINENO" "endian.h" "ac_cv_header_endian_h" "$ac_includes_default " if test "x$ac_cv_header_endian_h" = xyes then : printf "%s\n" "#define HAVE_ENDIAN_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "machine/endian.h" "ac_cv_header_machine_endian_h" "$ac_includes_default " if test "x$ac_cv_header_machine_endian_h" = xyes then : printf "%s\n" "#define HAVE_MACHINE_ENDIAN_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/endian.h" "ac_cv_header_sys_endian_h" "$ac_includes_default " if test "x$ac_cv_header_sys_endian_h" = xyes then : printf "%s\n" "#define HAVE_SYS_ENDIAN_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/byteorder.h" "ac_cv_header_sys_byteorder_h" "$ac_includes_default " if test "x$ac_cv_header_sys_byteorder_h" = xyes then : printf "%s\n" "#define HAVE_SYS_BYTEORDER_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/machine.h" "ac_cv_header_sys_machine_h" "$ac_includes_default " if test "x$ac_cv_header_sys_machine_h" = xyes then : printf "%s\n" "#define HAVE_SYS_MACHINE_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "machine/param.h" "ac_cv_header_machine_param_h" "$ac_includes_default " if test "x$ac_cv_header_machine_param_h" = xyes then : printf "%s\n" "#define HAVE_MACHINE_PARAM_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default " if test "x$ac_cv_header_sys_param_h" = xyes then : printf "%s\n" "#define HAVE_SYS_PARAM_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/isa_defs.h" "ac_cv_header_sys_isa_defs_h" "$ac_includes_default " if test "x$ac_cv_header_sys_isa_defs_h" = xyes then : printf "%s\n" "#define HAVE_SYS_ISA_DEFS_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/ioctl.h" "ac_cv_header_sys_ioctl_h" "$ac_includes_default " if test "x$ac_cv_header_sys_ioctl_h" = xyes then : printf "%s\n" "#define HAVE_SYS_IOCTL_H 1" >>confdefs.h fi # Check for network and sockets optional headers ac_fn_c_check_header_compile "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_sys_socket_h" = xyes then : printf "%s\n" "#define HAVE_SYS_SOCKET_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/select.h" "ac_cv_header_sys_select_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_sys_select_h" = xyes then : printf "%s\n" "#define HAVE_SYS_SELECT_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/in_systm.h" "ac_cv_header_netinet_in_systm_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_netinet_in_systm_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IN_SYSTM_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_netinet_in_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IN_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "arpa/inet.h" "ac_cv_header_arpa_inet_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_arpa_inet_h" = xyes then : printf "%s\n" "#define HAVE_ARPA_INET_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/ip.h" "ac_cv_header_netinet_ip_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_netinet_ip_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IP_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/tcp.h" "ac_cv_header_netinet_tcp_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_netinet_tcp_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_TCP_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_net_if_h" = xyes then : printf "%s\n" "#define HAVE_NET_IF_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netdb.h" "ac_cv_header_netdb_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_netdb_h" = xyes then : printf "%s\n" "#define HAVE_NETDB_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sockLib.h" "ac_cv_header_sockLib_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_sockLib_h" = xyes then : printf "%s\n" "#define HAVE_SOCKLIB_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "inetLib.h" "ac_cv_header_inetLib_h" "$ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ " if test "x$ac_cv_header_inetLib_h" = xyes then : printf "%s\n" "#define HAVE_INETLIB_H 1" >>confdefs.h fi # Check for other optional headers ac_fn_c_check_header_compile "$LINENO" "sys/msg.h" "ac_cv_header_sys_msg_h" "$ac_includes_default " if test "x$ac_cv_header_sys_msg_h" = xyes then : printf "%s\n" "#define HAVE_SYS_MSG_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default " if test "x$ac_cv_header_sys_mman_h" = xyes then : printf "%s\n" "#define HAVE_SYS_MMAN_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "signal.h" "ac_cv_header_signal_h" "$ac_includes_default " if test "x$ac_cv_header_signal_h" = xyes then : printf "%s\n" "#define HAVE_SIGNAL_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "search.h" "ac_cv_header_search_h" "$ac_includes_default " if test "x$ac_cv_header_search_h" = xyes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for proper tsearch(), tfind() and tdelete()" >&5 printf %s "checking for proper tsearch(), tfind() and tdelete()... " >&6; } if test ${mhd_cv_sys_tsearch_usable+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include static int cmp_func(const void *p1, const void *p2) { return (*((const int *)p1)) - (*((const int *)p2)); } int main(void) { int ret = 0; void *root_ptr = NULL; int element1 = 1; int **element_ptr_ptr1; int **element_ptr_ptr2; element_ptr_ptr1 = (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func); if (NULL == element_ptr_ptr1) { fprintf (stderr, "NULL pointer has been returned when tsearch() called for the first time.\n"); return ++ret; } if (*element_ptr_ptr1 != &element1) { fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the first time.\n"); return ++ret; } if (NULL == root_ptr) { fprintf (stderr, "Root pointer has not been set by tsearch().\n"); return ++ret; } element_ptr_ptr2 = (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func); if (NULL == element_ptr_ptr2) { fprintf (stderr, "NULL pointer has been returned when tsearch() called for the second time.\n"); return ++ret; } if (*element_ptr_ptr2 != &element1) { fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the second time.\n"); ++ret; } if (element_ptr_ptr2 != element_ptr_ptr1) { fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n"); ++ret; } element_ptr_ptr2 = (int **) tfind ((void*) &element1, &root_ptr, &cmp_func); if (NULL == element_ptr_ptr2) { fprintf (stderr, "NULL pointer has been returned by tfind().\n"); ++ret; } if (*element_ptr_ptr2 != &element1) { fprintf (stderr, "Wrong pointer has been returned when by tfind().\n"); ++ret; } if (element_ptr_ptr2 != element_ptr_ptr1) { fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n"); ++ret; } element_ptr_ptr1 = (int **) tdelete ((void*) &element1, &root_ptr, &cmp_func); if (NULL == element_ptr_ptr1) { fprintf (stderr, "NULL pointer has been returned by tdelete().\n"); ++ret; } if (NULL != root_ptr) { fprintf (stderr, "Root pointer has not been set to NULL by tdelete().\n"); ++ret; } return ret; } _ACEOF if test "x$cross_compiling" = x"yes" then : if ac_fn_c_try_link "$LINENO" then : case $host_os in #( openbsd*) : # Some OpenBSD versions have wrong return value for tdelete() mhd_cv_sys_tsearch_usable='assuming no' ;; #( netbsd*) : # NetBSD had leaked root node for years mhd_cv_sys_tsearch_usable='assuming no' ;; #( *) : mhd_cv_sys_tsearch_usable='assuming yes' ;; esac else $as_nop mhd_cv_sys_tsearch_usable='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext else $as_nop if test "$cross_compiling" = yes then : # Dummy placeholder else $as_nop if ac_fn_c_try_run "$LINENO" then : mhd_cv_sys_tsearch_usable='yes' else $as_nop mhd_cv_sys_tsearch_usable='no' fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam fi fi rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_sys_tsearch_usable" >&5 printf "%s\n" "$mhd_cv_sys_tsearch_usable" >&6; } if test "x$mhd_cv_sys_tsearch_usable" = "xyes" || test "x$mhd_cv_sys_tsearch_usable" = "xassuming yes" then : printf "%s\n" "#define MHD_USE_SYS_TSEARCH 1" >>confdefs.h fi fi if test "x$mhd_cv_sys_tsearch_usable" = "xyes" || test "x$mhd_cv_sys_tsearch_usable" = "xassuming yes"; then MHD_USE_SYS_TSEARCH_TRUE= MHD_USE_SYS_TSEARCH_FALSE='#' else MHD_USE_SYS_TSEARCH_TRUE='#' MHD_USE_SYS_TSEARCH_FALSE= fi # Optional headers used for tests ac_fn_c_check_header_compile "$LINENO" "sys/sysctl.h" "ac_cv_header_sys_sysctl_h" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ " if test "x$ac_cv_header_sys_sysctl_h" = xyes then : printf "%s\n" "#define HAVE_SYS_SYSCTL_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/ip_icmp.h" "ac_cv_header_netinet_ip_icmp_h" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ " if test "x$ac_cv_header_netinet_ip_icmp_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IP_ICMP_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/icmp_var.h" "ac_cv_header_netinet_icmp_var_h" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ " if test "x$ac_cv_header_netinet_icmp_var_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_ICMP_VAR_H 1" >>confdefs.h fi # Check whether --enable-compiler-hardening was given. if test ${enable_compiler_hardening+y} then : enableval=$enable_compiler_hardening; else $as_nop case ${enable_build_type} in #( *-hardened) : enable_compiler_hardening='yes' ;; #( *) : enable_compiler_hardening='no' ;; esac fi if test "x$enable_compiler_hardening" = x"yes" then : CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" ac_fn_check_decl "$LINENO" "_FORTIFY_SOURCE" "ac_cv_have_decl__FORTIFY_SOURCE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl__FORTIFY_SOURCE" = xyes then : if test -z "${CPPFLAGS_ac}" then : CPPFLAGS_ac="-U_FORTIFY_SOURCE" else $as_nop CPPFLAGS_ac="${CPPFLAGS_ac} -U_FORTIFY_SOURCE" fi fi if test -z "${CPPFLAGS_ac}" then : CPPFLAGS_ac="-D_FORTIFY_SOURCE=2" else $as_nop CPPFLAGS_ac="${CPPFLAGS_ac} -D_FORTIFY_SOURCE=2" fi CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${user_CFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fstack-protector-strong flag" >&5 printf %s "checking whether $CC supports -fstack-protector-strong flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fstack_protector_strong+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fstack-protector-strong ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_protector_strong="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_protector_strong="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fstack-protector-strong ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_protector_strong="yes" else $as_nop mhd_cv_cc_cfl_supp__fstack_protector_strong="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fstack_protector_strong" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fstack_protector_strong" >&6; } if test "x$mhd_cv_cc_cfl_supp__fstack_protector_strong" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fstack-protector-strong" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fstack-protector-strong" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fstack-protector-all flag" >&5 printf %s "checking whether $CC supports -fstack-protector-all flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fstack_protector_all+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fstack-protector-all ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_protector_all="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_protector_all="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fstack-protector-all ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_protector_all="yes" else $as_nop mhd_cv_cc_cfl_supp__fstack_protector_all="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fstack_protector_all" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fstack_protector_all" >&6; } if test "x$mhd_cv_cc_cfl_supp__fstack_protector_all" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fstack-protector-all" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fstack-protector-all" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fstack-protector flag" >&5 printf %s "checking whether $CC supports -fstack-protector flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fstack_protector+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fstack-protector ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_protector="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_protector="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fstack-protector ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_protector="yes" else $as_nop mhd_cv_cc_cfl_supp__fstack_protector="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fstack_protector" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fstack_protector" >&6; } if test "x$mhd_cv_cc_cfl_supp__fstack_protector" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fstack-protector" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fstack-protector" fi fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fstack-clash-protection flag" >&5 printf %s "checking whether $CC supports -fstack-clash-protection flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fstack_clash_protection+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fstack-clash-protection ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_clash_protection="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_clash_protection="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fstack-clash-protection ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fstack_clash_protection="yes" else $as_nop mhd_cv_cc_cfl_supp__fstack_clash_protection="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fstack_clash_protection" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fstack_clash_protection" >&6; } if test "x$mhd_cv_cc_cfl_supp__fstack_clash_protection" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fstack-clash-protection" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fstack-clash-protection" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -ftrivial-auto-var-init=pattern flag" >&5 printf %s "checking whether $CC supports -ftrivial-auto-var-init=pattern flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_pattern+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -ftrivial-auto-var-init=pattern ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_pattern="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_pattern="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -ftrivial-auto-var-init=pattern ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_pattern="yes" else $as_nop mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_pattern="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_pattern" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_pattern" >&6; } if test "x$mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_pattern" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-ftrivial-auto-var-init=pattern" else $as_nop CFLAGS_ac="${CFLAGS_ac} -ftrivial-auto-var-init=pattern" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -ftrivial-auto-var-init=zero flag" >&5 printf %s "checking whether $CC supports -ftrivial-auto-var-init=zero flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_zero+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -ftrivial-auto-var-init=zero ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_zero="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_zero="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -ftrivial-auto-var-init=zero ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_zero="yes" else $as_nop mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_zero="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_zero" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_zero" >&6; } if test "x$mhd_cv_cc_cfl_supp__ftrivial_auto_var_init_zero" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-ftrivial-auto-var-init=zero" else $as_nop CFLAGS_ac="${CFLAGS_ac} -ftrivial-auto-var-init=zero" fi fi fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" if test "x${enable_static}" = "xyes" && test "x${pic_mode}" != "xyes" then : # PIE static lib can be used within non-PIE application, but # PIE static lib cannot be used in non-PIE shared lib. Let's assume # that static lib will not be used in shared lib # All "pie" flags will be used automatically by libtool only # for static library objects. CFLAGS="${user_CFLAGS}" # Perform tests here with "-pie" enabled LDFLAGS="${LDFLAGS_ac} -pie ${user_LDFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fPIE flag" >&5 printf %s "checking whether $CC supports -fPIE flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fPIE+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fPIE ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fPIE="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fPIE="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fPIE ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fPIE="yes" else $as_nop mhd_cv_cc_cfl_supp__fPIE="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fPIE" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fPIE" >&6; } if test "x$mhd_cv_cc_cfl_supp__fPIE" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fPIE" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fPIE" fi if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-pie" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -pie" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fpie flag" >&5 printf %s "checking whether $CC supports -fpie flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fpie+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fpie ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fpie="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fpie="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fpie ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fpie="yes" else $as_nop mhd_cv_cc_cfl_supp__fpie="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fpie" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fpie" >&6; } if test "x$mhd_cv_cc_cfl_supp__fpie" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-fpie" else $as_nop CFLAGS_ac="${CFLAGS_ac} -fpie" fi if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-pie" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -pie" fi fi fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" fi # Linker hardening options # Currently these options are ELF specific, they don't work on Darwin and W32 # Check whether --enable-linker-hardening was given. if test ${enable_linker_hardening+y} then : enableval=$enable_linker_hardening; else $as_nop case ${enable_build_type} in #( *-hardened) : enable_linker_hardening='yes' ;; #( *) : enable_linker_hardening='no' ;; esac fi if test "x$enable_linker_hardening" = x"yes" then : CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${user_LDFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,-z,relro flag" >&5 printf %s "checking whether $CC supports -Wl,-z,relro flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl__z_relro+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,-z,relro ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl__z_relro="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl__z_relro="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,-z,relro ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl__z_relro="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl__z_relro="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl__z_relro" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl__z_relro" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl__z_relro" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,-z,relro" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,-z,relro" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,-z,now flag" >&5 printf %s "checking whether $CC supports -Wl,-z,now flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl__z_now+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,-z,now ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl__z_now="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl__z_now="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,-z,now ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl__z_now="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl__z_now="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl__z_now" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl__z_now" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl__z_now" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,-z,now" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,-z,now" fi fi fi # Actually should be "noexec" by default, but let's try to enforce it. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,-z,noexecstack flag" >&5 printf %s "checking whether $CC supports -Wl,-z,noexecstack flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl__z_noexecstack+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,-z,noexecstack ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl__z_noexecstack="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl__z_noexecstack="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,-z,noexecstack ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl__z_noexecstack="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl__z_noexecstack="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl__z_noexecstack" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl__z_noexecstack" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl__z_noexecstack" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,-z,noexecstack" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,-z,noexecstack" fi fi # W32-specific. Some are enabled by default, but they will be enfored to be sure. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--large-address-aware flag" >&5 printf %s "checking whether $CC supports -Wl,--large-address-aware flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl___large_address_aware+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,--large-address-aware ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___large_address_aware="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___large_address_aware="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,--large-address-aware ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___large_address_aware="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl___large_address_aware="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl___large_address_aware" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl___large_address_aware" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl___large_address_aware" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,--large-address-aware" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,--large-address-aware" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--enable-auto-image-base flag" >&5 printf %s "checking whether $CC supports -Wl,--enable-auto-image-base flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl___enable_auto_image_base+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,--enable-auto-image-base ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___enable_auto_image_base="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___enable_auto_image_base="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,--enable-auto-image-base ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___enable_auto_image_base="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl___enable_auto_image_base="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl___enable_auto_image_base" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl___enable_auto_image_base" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl___enable_auto_image_base" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,--enable-auto-image-base" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,--enable-auto-image-base" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--dynamicbase flag" >&5 printf %s "checking whether $CC supports -Wl,--dynamicbase flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl___dynamicbase+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,--dynamicbase ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___dynamicbase="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___dynamicbase="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,--dynamicbase ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___dynamicbase="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl___dynamicbase="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl___dynamicbase" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl___dynamicbase" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl___dynamicbase" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,--dynamicbase" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,--dynamicbase" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--nxcompat flag" >&5 printf %s "checking whether $CC supports -Wl,--nxcompat flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl___nxcompat+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,--nxcompat ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___nxcompat="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___nxcompat="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,--nxcompat ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___nxcompat="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl___nxcompat="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl___nxcompat" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl___nxcompat" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl___nxcompat" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,--nxcompat" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,--nxcompat" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--high-entropy-va flag" >&5 printf %s "checking whether $CC supports -Wl,--high-entropy-va flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl___high_entropy_va+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,--high-entropy-va ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___high_entropy_va="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___high_entropy_va="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,--high-entropy-va ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___high_entropy_va="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl___high_entropy_va="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl___high_entropy_va" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl___high_entropy_va" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl___high_entropy_va" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,--high-entropy-va" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,--high-entropy-va" fi fi LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" fi ac_fn_c_check_header_compile "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default " if test "x$ac_cv_header_stdbool_h" = xyes then : ac_fn_c_check_type "$LINENO" "bool" "ac_cv_type_bool" " #include " if test "x$ac_cv_type_bool" = xyes then : printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h printf "%s\n" "#define HAVE_BUILTIN_TYPE_BOOL 1" >>confdefs.h else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Header is present, but \"bool\" type cannot be detected. Check compiler flags." >&5 printf "%s\n" "$as_me: WARNING: Header is present, but \"bool\" type cannot be detected. Check compiler flags." >&2;} printf "%s\n" "#define bool int" >>confdefs.h fi else $as_nop ac_fn_c_check_type "$LINENO" "bool" "ac_cv_type_bool" " " if test "x$ac_cv_type_bool" = xyes then : printf "%s\n" "#define HAVE_BUILTIN_TYPE_BOOL 1" >>confdefs.h else $as_nop ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" " " if test "x$ac_cv_type__Bool" = xyes then : printf "%s\n" "#define HAVE_BUILTIN_TYPE_BOOL 1" >>confdefs.h printf "%s\n" "#define bool _Bool" >>confdefs.h else $as_nop printf "%s\n" "#define bool int" >>confdefs.h fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether \"true\" is defined or builtin" >&5 printf %s "checking whether \"true\" is defined or builtin... " >&6; } if test ${mhd_cv_macro_true_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_STDBOOL_H #include #endif int main (void) { #if defined(true) /* dummy */ #else (void)true; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro_true_defined='yes' else $as_nop mhd_cv_macro_true_defined='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_true_defined" >&5 printf "%s\n" "$mhd_cv_macro_true_defined" >&6; } if test "x$mhd_cv_macro_true_defined" = x"yes" then : : else $as_nop printf "%s\n" "#define true (!0)" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether \"false\" is defined or builtin" >&5 printf %s "checking whether \"false\" is defined or builtin... " >&6; } if test ${mhd_cv_macro_false_defined+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_STDBOOL_H #include #endif int main (void) { #if !defined(false) (void)false; #else /* dummy */ #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro_false_defined='yes' else $as_nop mhd_cv_macro_false_defined='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_false_defined" >&5 printf "%s\n" "$mhd_cv_macro_false_defined" >&6; } if test "x$mhd_cv_macro_false_defined" = x"yes" then : : else $as_nop printf "%s\n" "#define false 0" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether \"true\" and \"false\" could be used" >&5 printf %s "checking whether \"true\" and \"false\" could be used... " >&6; } if test ${mhd_cv_macro_true_false_valid+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_STDBOOL_H #include #endif int main (void) { int var1[true ? 1 : -1] = { 1 }; int var2[false ? -1 : 1] = { 2 }; int var3[!true ? -1 : 1] = { 3 }; int var4[!false ? 1 : -1] = { 4 }; if (var1[0] == var2[0] || var3[0] == var4[0]) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_macro_true_false_valid='yes' else $as_nop mhd_cv_macro_true_false_valid='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_true_false_valid" >&5 printf "%s\n" "$mhd_cv_macro_true_false_valid" >&6; } if test "x$mhd_cv_macro_true_false_valid" = x"yes" then : : else $as_nop as_fn_error $? "Value of \"true\" or value of \"false\" is not valid. Check config.log for details." "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Werror=attributes" >&5 printf %s "checking whether C compiler accepts -Werror=attributes... " >&6; } if test ${ax_cv_check_cflags___Werror_attributes+y} then : printf %s "(cached) " >&6 else $as_nop ax_check_save_flags=$CFLAGS CFLAGS="$CFLAGS -Werror=attributes" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ax_cv_check_cflags___Werror_attributes=yes else $as_nop ax_cv_check_cflags___Werror_attributes=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext CFLAGS=$ax_check_save_flags fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Werror_attributes" >&5 printf "%s\n" "$ax_cv_check_cflags___Werror_attributes" >&6; } if test "x$ax_cv_check_cflags___Werror_attributes" = xyes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Werror=attributes actually works" >&5 printf %s "checking whether -Werror=attributes actually works... " >&6; } CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -Werror=attributes" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ __attribute__((non_existing_attrb_dummy)) static int SimpleFunc(void) {return 3;} int main (void) { int r = SimpleFunc(); if (r) return r; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } errattr_CFLAGS="" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } errattr_CFLAGS="-Werror=attributes" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" else $as_nop errattr_CFLAGS="" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function inline keywords supported by $CC" >&5 printf %s "checking for function inline keywords supported by $CC... " >&6; } CFLAGS="${CFLAGS_ac} ${user_CFLAGS} $errattr_CFLAGS" inln_prfx="none" # Prefer always inline functions for inln_prfx_chk in InlineWithAttr __forceinline inline __inline__ __inline _inline _Inline do # Try to link to avoid "symbol undefined" problems at build time if test "x$inln_prfx_chk" = "xInlineWithAttr" then : if test "x$errattr_CFLAGS" = "x" then : # Skip test with attribute as negative result can't be detected inln_prfx_chk="__forceinline" # use next value else $as_nop inln_prfx_chk="inline __attribute__((always_inline))" fi fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus #error This test is only for C. choke me #endif #ifdef HAVE_STDBOOL_H #include #endif static $inln_prfx_chk bool cmpfn(int x, int y) { return x > y; } static $inln_prfx_chk int sumfn(int x, int y) { return x + y; } int main (void) { int a = 1, b = 100, c; if (cmpfn(a, b)) c = sumfn(a, b); else c = 0 - sumfn(a, b); if (c) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : inln_prfx="$inln_prfx_chk" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext test "x$inln_prfx" != "xnone" && break done if test "x$inln_prfx" != "xnone" then : printf "%s\n" "#define INLINE_FUNC 1" >>confdefs.h printf "%s\n" "#define _MHD_static_inline static $inln_prfx" >>confdefs.h else $as_nop printf "%s\n" "#define _MHD_static_inline static" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $inln_prfx" >&5 printf "%s\n" "$inln_prfx" >&6; } CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ac_fn_c_check_header_compile "$LINENO" "stdalign.h" "ac_cv_header_stdalign_h" "$ac_includes_default " if test "x$ac_cv_header_stdalign_h" = xyes then : printf "%s\n" "#define HAVE_STDALIGN_H 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C11 'alignof()' support" >&5 printf %s "checking for C11 'alignof()' support... " >&6; } if test ${mhd_cv_c_alignof+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_STDALIGN_H #include #endif int main (void) { int var1[(alignof(int) >= 2) ? 1 : -1]; int var2[alignof(unsigned int) - 1]; int var3[(alignof(char) > 0) ? 1 : -1]; int var4[(alignof(long) >= 4) ? 1 : -1]; /* Mute compiler warnings */ var1[0] = var2[0] = var3[0] = 0; var4[0] = 1; if (var1[0] + var2[0] + var3[0] == var4[0]) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_STDALIGN_H #include #endif int main (void) { /* Should fail if 'alignof()' works */ int var1[alignof(nonexisting_type) - 1]; /* Mute compiler warnings */ var1[0] = 1; if (var1[0] + 1 == 1) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_c_alignof='no' else $as_nop mhd_cv_c_alignof='yes' fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop mhd_cv_c_alignof='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_c_alignof" >&5 printf "%s\n" "$mhd_cv_c_alignof" >&6; } if test "x$mhd_cv_c_alignof" = x"yes" then : printf "%s\n" "#define HAVE_C_ALIGNOF 1" >>confdefs.h fi # Check system type { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for target host OS" >&5 printf %s "checking for target host OS... " >&6; } os_is_windows="no" os_is_native_w32="no" case "$host_os" in #( *darwin* | *rhapsody* | *macosx*) : printf "%s\n" "#define OSX 1" >>confdefs.h mhd_host_os='Darwin' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } ;; #( kfreebsd*-gnu) : printf "%s\n" "#define SOMEBSD 1" >>confdefs.h printf "%s\n" "#define FREEBSD 1" >>confdefs.h mhd_host_os='FreeBSD kernel with GNU userland' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } ;; #( freebsd*) : printf "%s\n" "#define SOMEBSD 1" >>confdefs.h printf "%s\n" "#define FREEBSD 1" >>confdefs.h mhd_host_os='FreeBSD' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } ;; #( openbsd*) : printf "%s\n" "#define SOMEBSD 1" >>confdefs.h printf "%s\n" "#define OPENBSD 1" >>confdefs.h mhd_host_os='OpenBSD' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } ;; #( netbsd*) : printf "%s\n" "#define SOMEBSD 1" >>confdefs.h printf "%s\n" "#define NETBSD 1" >>confdefs.h mhd_host_os='NetBSD' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } ;; #( *solaris*) : printf "%s\n" "#define SOLARIS 1" >>confdefs.h printf "%s\n" "#define _REENTRANT 1" >>confdefs.h mhd_host_os='Solaris' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } ;; #( *linux*) : printf "%s\n" "#define LINUX 1" >>confdefs.h mhd_host_os='Linux' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } ;; #( *cygwin*) : printf "%s\n" "#define CYGWIN 1" >>confdefs.h mhd_host_os='Windows/Cygwin' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } os_is_windows="yes" ;; #( *mingw*) : printf "%s\n" "#define MINGW 1" >>confdefs.h printf "%s\n" "#define WINDOWS 1" >>confdefs.h mhd_host_os='Windows/MinGW' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } for ac_header in winsock2.h ws2tcpip.h do : as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes" then : cat >>confdefs.h <<_ACEOF #define `printf "%s\n" "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF else $as_nop as_fn_error $? "Winsock2 headers are required for W32" "$LINENO" 5 fi done { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for MS lib utility" >&5 printf %s "checking for MS lib utility... " >&6; } if test ${ac_cv_use_ms_lib_tool+y} then : printf %s "(cached) " >&6 else $as_nop mslibcheck=`lib 2>&1` if echo "$mslibcheck" | $GREP -e '^Microsoft (R) Library Manager' - >/dev/null then : ac_cv_use_ms_lib_tool=yes else $as_nop ac_cv_use_ms_lib_tool=no fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_use_ms_lib_tool" >&5 printf "%s\n" "$ac_cv_use_ms_lib_tool" >&6; } if test "x$ac_cv_use_ms_lib_tool" = "xyes" then : MS_LIB_TOOL=lib fi os_is_windows="yes" os_is_native_w32="yes" ;; #( *openedition*) : printf "%s\n" "#define OS390 1" >>confdefs.h mhd_host_os='OS/390' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } ;; #( gnu*) : printf "%s\n" "#define GNU_HURD 1" >>confdefs.h mhd_host_os='GNU Hurd' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_host_os" >&5 printf "%s\n" "$mhd_host_os" >&6; } ;; #( *) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unrecognised OS" >&5 printf "%s\n" "unrecognised OS" >&6; } mhd_host_os="${host_os}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Unrecognised OS $host_os" >&5 printf "%s\n" "$as_me: WARNING: Unrecognised OS $host_os" >&2;} printf "%s\n" "#define OTHEROS 1" >>confdefs.h ;; esac if test "x$os_is_windows" = "xyes" && \ test "x${os_is_native_w32}" != "xyes"; then CYGWIN_TARGET_TRUE= CYGWIN_TARGET_FALSE='#' else CYGWIN_TARGET_TRUE='#' CYGWIN_TARGET_FALSE= fi if test "x$os_is_windows" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether target W32 version is specified by precompiler defines" >&5 printf %s "checking whether target W32 version is specified by precompiler defines... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Note: check logic is reversed for easy log reading */ #ifdef WINVER #error WINVER is defined choke me now; #endif #ifdef _WIN32_WINNT #error _WIN32_WINNT is defined choke me now; #endif #ifdef NTDDI #error NTDDI is defined choke me now; #endif int main (void) { (void)0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_w32_ver_preselect=no else $as_nop mhd_w32_ver_preselect=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${mhd_w32_ver_preselect}" >&5 printf "%s\n" "${mhd_w32_ver_preselect}" >&6; } ac_fn_c_check_header_compile "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default " if test "x$ac_cv_header_windows_h" = xyes then : printf "%s\n" "#define HAVE_WINDOWS_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sdkddkver.h" "ac_cv_header_sdkddkver_h" "$ac_includes_default " if test "x$ac_cv_header_sdkddkver_h" = xyes then : printf "%s\n" "#define HAVE_SDKDDKVER_H 1" >>confdefs.h fi if test "x$mhd_w32_ver_preselect" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for specified target W32 version" >&5 printf %s "checking for specified target W32 version... " >&6; } { mhd_w32_ver=; unset mhd_w32_ver;} { mhd_w32_ver_msg=; unset mhd_w32_ver_msg;} cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if _WIN32_WINNT+0 < 0x0501 /* Check before headers inclusion */ #error _WIN32_WINNT is less than 0x0501 choke me now; #endif #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #if _WIN32_WINNT+0 < 0x0501 #error _WIN32_WINNT is less than 0x0501 choke me now; #endif int main (void) { (void)0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: pre-WinXP" >&5 printf "%s\n" "pre-WinXP" >&6; } as_fn_error $? "libmicrohttpd cannot be compiled for Windows version before Windows XP" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #if _WIN32_WINNT+0 == 0x0501 #error _WIN32_WINNT is 0x0501 choke me now; #endif #if _WIN32_WINNT+0 == 0x0502 #error _WIN32_WINNT is 0x0502 choke me now; #endif int main (void) { (void)0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop mhd_w32_ver="WinXP" mhd_w32_ver_msg="WinXP (selected by precompiler flags)" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext if test ${mhd_w32_ver+y} then : else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #if _WIN32_WINNT+0 < 0x0600 #error _WIN32_WINNT is less than 0x0600 but greater than 0x0502 choke me now; #endif int main (void) { (void)0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop as_fn_error $? "_WIN32_WINNT value is wrong (less than 0x0600 but greater than 0x0502)" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #if _WIN32_WINNT+0 == 0x0600 #error _WIN32_WINNT is 0x0600 choke me now; #endif int main (void) { (void)0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop mhd_w32_ver="Vista" mhd_w32_ver_msg="Vista (selected by precompiler flags)" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test ${mhd_w32_ver+y} then : else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #if _WIN32_WINNT+0 > 0x0600 #error _WIN32_WINNT is greater than 0x0600 choke me now; #endif int main (void) { (void)0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_w32_ver="unknown" mhd_w32_ver_msg="unknown (cannot be detected)" else $as_nop mhd_w32_ver="newer than Vista" mhd_w32_ver_msg="newer than Vista (selected by precompiler flags)" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${mhd_w32_ver}" >&5 printf "%s\n" "${mhd_w32_ver}" >&6; } else $as_nop mhd_w32_ver="Vista" mhd_w32_ver_msg="Vista (default, override by CPPFLAGS=-D_WIN32_WINNT=0xNNNN)" CPPFLAGS_ac="${CPPFLAGS_ac} -D_WIN32_WINNT=0x0600" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether headers accept _WIN32_WINNT=0x0600" >&5 printf %s "checking whether headers accept _WIN32_WINNT=0x0600... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #include int main (void) { (void)0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } as_fn_error $? "Headers do not accept _WIN32_WINNT=0x0600. Consider override target W32 version by CPPFLAGS=-D_WIN32_WINNT=0xNNNN" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi if test "x${os_is_windows}" = "xyes" && test "x${os_is_native_w32}" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking W32 run-time library type" >&5 printf %s "checking W32 run-time library type... " >&6; } if test ${mhd_cv_wctr_type+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if defined(_UCRT) #define CRT_STR "MHDMARKER: UCRT run-time library in use!" #endif #if defined(__MSVCRT_VERSION__) #if (__MSVCRT_VERSION__ >= 0xE00) && (__MSVCRT_VERSION__ < 0x1000) #define CRT_STR "MHDMARKER: UCRT run-time library in use!" #endif #if (__MSVCRT_VERSION__ > 0x1400) #define CRT_STR "MHDMARKER: UCRT run-time library in use!" #endif #endif #ifndef CRT_STR #define CRT_STR "MHDMARKER: MSVCRT run-time library in use!" #endif int main(void) { printf ("%\n", CRT_STR); return 0; } _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "MHDMARKER: UCRT run-time library in use!" >/dev/null 2>&1 then : mhd_cv_wctr_type="ucrt" else $as_nop mhd_cv_wctr_type="msvcrt" fi rm -rf conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_wctr_type" >&5 printf "%s\n" "$mhd_cv_wctr_type" >&6; } mhd_host_os="${mhd_host_os}-${mhd_cv_wctr_type}" if test "x$mhd_cv_wctr_type" = x"msvcrt" then : # Use CFLAGS here to override user-supplied wrong CPPFLAGS. Durty trick, but choice is limited. for flag in -U__USE_MINGW_ANSI_STDIO -D__USE_MINGW_ANSI_STDIO=0; do as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags__$flag" | $as_tr_sh` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 printf %s "checking whether C compiler accepts $flag... " >&6; } if eval test \${$as_CACHEVAR+y} then : printf %s "(cached) " >&6 else $as_nop ax_check_save_flags=$CFLAGS CFLAGS="$CFLAGS $flag" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$as_CACHEVAR=yes" else $as_nop eval "$as_CACHEVAR=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext CFLAGS=$ax_check_save_flags fi eval ac_res=\$$as_CACHEVAR { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_CACHEVAR"\" = x"yes" then : if test ${CFLAGS_ac+y} then : case " $CFLAGS_ac " in #( *" $flag "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CFLAGS_ac already contains \$flag"; } >&5 (: CFLAGS_ac already contains $flag) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append CFLAGS_ac " $flag" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CFLAGS_ac=\"\$CFLAGS_ac\""; } >&5 (: CFLAGS_ac="$CFLAGS_ac") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop CFLAGS_ac=$flag { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : CFLAGS_ac=\"\$CFLAGS_ac\""; } >&5 (: CFLAGS_ac="$CFLAGS_ac") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi else $as_nop : fi done W32CRT=MSVCRT else $as_nop W32CRT=UCRT fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${user_LDFLAGS}" case $mhd_w32_ver in #( WinXP) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--major-subsystem-version,5,--minor-subsystem-version,1 flag" >&5 printf %s "checking whether $CC supports -Wl,--major-subsystem-version,5,--minor-subsystem-version,1 flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_5___minor_subsystem_version_1+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,--major-subsystem-version,5,--minor-subsystem-version,1 ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_5___minor_subsystem_version_1="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_5___minor_subsystem_version_1="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,--major-subsystem-version,5,--minor-subsystem-version,1 ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_5___minor_subsystem_version_1="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_5___minor_subsystem_version_1="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_5___minor_subsystem_version_1" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_5___minor_subsystem_version_1" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_5___minor_subsystem_version_1" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,--major-subsystem-version,5,--minor-subsystem-version,1" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,--major-subsystem-version,5,--minor-subsystem-version,1" fi fi ;; #( Vista) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--major-subsystem-version,6,--minor-subsystem-version,0 flag" >&5 printf %s "checking whether $CC supports -Wl,--major-subsystem-version,6,--minor-subsystem-version,0 flag... " >&6; } if test ${mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_6___minor_subsystem_version_0+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_LDFLAGS="${LDFLAGS}" LDFLAGS="${LDFLAGS_ac} -Wl,--major-subsystem-version,6,--minor-subsystem-version,0 ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_6___minor_subsystem_version_0="yes" else $as_nop # Compile and link failed with test flag added LDFLAGS="${LDFLAGS_ac} ${mhd_check_cc_flag_save_LDFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_6___minor_subsystem_version_0="no" else $as_nop # Compile and link failed with test flag removed as well LDFLAGS="${LDFLAGS_ac} -Wl,--major-subsystem-version,6,--minor-subsystem-version,0 ${mhd_check_cc_flag_save_LDFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_6___minor_subsystem_version_0="yes" else $as_nop mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_6___minor_subsystem_version_0="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" LDFLAGS="${mhd_check_cc_flag_save_LDFLAGS}" { mhd_check_cc_flag_save_LDFLAGS=; unset mhd_check_cc_flag_save_LDFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_6___minor_subsystem_version_0" >&5 printf "%s\n" "$mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_6___minor_subsystem_version_0" >&6; } if test "x$mhd_cv_cc_lfl_supp__Wl___major_subsystem_version_6___minor_subsystem_version_0" = x"yes" then : if test -z "${LDFLAGS_ac}" then : LDFLAGS_ac="-Wl,--major-subsystem-version,6,--minor-subsystem-version,0" else $as_nop LDFLAGS_ac="${LDFLAGS_ac} -Wl,--major-subsystem-version,6,--minor-subsystem-version,0" fi fi ;; #( *) : ;; esac LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" # Check whether --with-threads was given. if test ${with_threads+y} then : withval=$with_threads; else $as_nop with_threads='auto' fi case $with_threads in #( win32) : with_threads='w32' ;; #( pthreads) : with_threads='posix' ;; #( posix) : : ;; #( w32) : : ;; #( none) : with_threads='none' ;; #( no) : with_threads='none' ;; #( auto) : : ;; #( *) : as_fn_error $? "incorrect parameter \"$with_threads\" specified for --with-threads" "$LINENO" 5 ;; esac # Check for posix threads support, regardless of configure parameters as # testsuite uses only posix threads. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ax_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on Tru64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ax_pthread_save_CC="$CC" ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" if test "x$PTHREAD_CC" != "x" then : CC="$PTHREAD_CC" fi if test "x$PTHREAD_CXX" != "x" then : CXX="$PTHREAD_CXX" fi CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS" >&5 printf %s "checking for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. The 'extern "C"' is for builds by C++ compilers; although this is not generally supported in C code supporting it here has little cost and some practical benefit (sr 110532). */ #ifdef __cplusplus extern "C" #endif char pthread_join (void); int main (void) { return pthread_join (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ax_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 printf "%s\n" "$ax_pthread_ok" >&6; } if test "x$ax_pthread_ok" = "xno"; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi CC="$ax_pthread_save_CC" CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$ax_pthread_save_LIBS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items with a "," contain both # C compiler flags (before ",") and linker flags (after ","). Other items # starting with a "-" are C compiler flags, and remaining items are # library names, except for "none" which indicates that we try without # any flags at all, and "pthread-config" which is a program returning # the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 # (Note: HP C rejects this with "bad form for `-t' option") # -pthreads: Solaris/gcc (Note: HP C also rejects) # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads and # -D_REENTRANT too), HP C (must be checked before -lpthread, which # is present but should not be used directly; and before -mthreads, # because the compiler interprets this as "-mt" + "-hreads") # -mthreads: Mingw32/gcc, Lynx/gcc # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case $host_os in freebsd*) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) ax_pthread_flags="-kthread lthread $ax_pthread_flags" ;; hpux*) # From the cc(1) man page: "[-mt] Sets various -D flags to enable # multi-threading and also sets -lpthread." ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" ;; openedition*) # IBM z/OS requires a feature-test macro to be defined in order to # enable POSIX threads at all, so give the user a hint if this is # not set. (We don't define these ourselves, as they can affect # other portions of the system API in unpredictable ways.) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) AX_PTHREAD_ZOS_MISSING # endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "AX_PTHREAD_ZOS_MISSING" >/dev/null 2>&1 then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support." >&5 printf "%s\n" "$as_me: WARNING: IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support." >&2;} fi rm -rf conftest* ;; solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (N.B.: The stubs are missing # pthread_cleanup_push, or rather a function called by this macro, # so we could check for that, but who knows whether they'll stub # that too in a future libc.) So we'll check first for the # standard Solaris way of linking pthreads (-mt -lpthread). ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags" ;; esac # Are we compiling with Clang? { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC is Clang" >&5 printf %s "checking whether $CC is Clang... " >&6; } if test ${ax_cv_PTHREAD_CLANG+y} then : printf %s "(cached) " >&6 else $as_nop ax_cv_PTHREAD_CLANG=no # Note that Autoconf sets GCC=yes for Clang as well as GCC if test "x$GCC" = "xyes"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Note: Clang 2.7 lacks __clang_[a-z]+__ */ # if defined(__clang__) && defined(__llvm__) AX_PTHREAD_CC_IS_CLANG # endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "AX_PTHREAD_CC_IS_CLANG" >/dev/null 2>&1 then : ax_cv_PTHREAD_CLANG=yes fi rm -rf conftest* fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_CLANG" >&5 printf "%s\n" "$ax_cv_PTHREAD_CLANG" >&6; } ax_pthread_clang="$ax_cv_PTHREAD_CLANG" # GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) # Note that for GCC and Clang -pthread generally implies -lpthread, # except when -nostdlib is passed. # This is problematic using libtool to build C++ shared libraries with pthread: # [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 # [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 # [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 # To solve this, first try -pthread together with -lpthread for GCC if test "x$GCC" = "xyes" then : ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags" fi # Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first if test "x$ax_pthread_clang" = "xyes" then : ax_pthread_flags="-pthread,-lpthread -pthread" fi # The presence of a feature test macro requesting re-entrant function # definitions is, on some systems, a strong hint that pthreads support is # correctly enabled case $host_os in darwin* | hpux* | linux* | osf* | solaris*) ax_pthread_check_macro="_REENTRANT" ;; aix*) ax_pthread_check_macro="_THREAD_SAFE" ;; *) ax_pthread_check_macro="--" ;; esac if test "x$ax_pthread_check_macro" = "x--" then : ax_pthread_check_cond=0 else $as_nop ax_pthread_check_cond="!defined($ax_pthread_check_macro)" fi if test "x$ax_pthread_ok" = "xno"; then for ax_pthread_try_flag in $ax_pthread_flags; do case $ax_pthread_try_flag in none) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 printf %s "checking whether pthreads work without any flags... " >&6; } ;; *,*) PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with \"$PTHREAD_CFLAGS\" and \"$PTHREAD_LIBS\"" >&5 printf %s "checking whether pthreads work with \"$PTHREAD_CFLAGS\" and \"$PTHREAD_LIBS\"... " >&6; } ;; -*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $ax_pthread_try_flag" >&5 printf %s "checking whether pthreads work with $ax_pthread_try_flag... " >&6; } PTHREAD_CFLAGS="$ax_pthread_try_flag" ;; pthread-config) # Extract the first word of "pthread-config", so it can be a program name with args. set dummy pthread-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ax_pthread_config+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ax_pthread_config"; then ac_cv_prog_ax_pthread_config="$ax_pthread_config" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ax_pthread_config="yes" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_ax_pthread_config" && ac_cv_prog_ax_pthread_config="no" fi fi ax_pthread_config=$ac_cv_prog_ax_pthread_config if test -n "$ax_pthread_config"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_config" >&5 printf "%s\n" "$ax_pthread_config" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ax_pthread_config" = "xno" then : continue fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$ax_pthread_try_flag" >&5 printf %s "checking for the pthreads library -l$ax_pthread_try_flag... " >&6; } PTHREAD_LIBS="-l$ax_pthread_try_flag" ;; esac ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include # if $ax_pthread_check_cond # error "$ax_pthread_check_macro must be defined" # endif static void *some_global = NULL; static void routine(void *a) { /* To avoid any unused-parameter or unused-but-set-parameter warning. */ some_global = a; } static void *start_routine(void *a) { return a; } int main (void) { pthread_t th; pthread_attr_t attr; pthread_create(&th, 0, start_routine, 0); pthread_join(th, 0); pthread_attr_init(&attr); pthread_cleanup_push(routine, 0); pthread_cleanup_pop(0) /* ; */ ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ax_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$ax_pthread_save_LIBS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5 printf "%s\n" "$ax_pthread_ok" >&6; } if test "x$ax_pthread_ok" = "xyes" then : break fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Clang needs special handling, because older versions handle the -pthread # option in a rather... idiosyncratic way if test "x$ax_pthread_clang" = "xyes"; then # Clang takes -pthread; it has never supported any other flag # (Note 1: This will need to be revisited if a system that Clang # supports has POSIX threads in a separate library. This tends not # to be the way of modern systems, but it's conceivable.) # (Note 2: On some systems, notably Darwin, -pthread is not needed # to get POSIX threads support; the API is always present and # active. We could reasonably leave PTHREAD_CFLAGS empty. But # -pthread does define _REENTRANT, and while the Darwin headers # ignore this macro, third-party headers might not.) # However, older versions of Clang make a point of warning the user # that, in an invocation where only linking and no compilation is # taking place, the -pthread option has no effect ("argument unused # during compilation"). They expect -pthread to be passed in only # when source code is being compiled. # # Problem is, this is at odds with the way Automake and most other # C build frameworks function, which is that the same flags used in # compilation (CFLAGS) are also used in linking. Many systems # supported by AX_PTHREAD require exactly this for POSIX threads # support, and in fact it is often not straightforward to specify a # flag that is used only in the compilation phase and not in # linking. Such a scenario is extremely rare in practice. # # Even though use of the -pthread flag in linking would only print # a warning, this can be a nuisance for well-run software projects # that build with -Werror. So if the active version of Clang has # this misfeature, we search for an option to squash it. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread" >&5 printf %s "checking whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread... " >&6; } if test ${ax_cv_PTHREAD_CLANG_NO_WARN_FLAG+y} then : printf %s "(cached) " >&6 else $as_nop ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown # Create an alternate version of $ac_link that compiles and # links in two steps (.c -> .o, .o -> exe) instead of one # (.c -> exe), because the warning occurs only in the second # step ax_pthread_save_ac_link="$ac_link" ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' ax_pthread_link_step=`printf "%s\n" "$ac_link" | sed "$ax_pthread_sed"` ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" ax_pthread_save_CFLAGS="$CFLAGS" for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do if test "x$ax_pthread_try" = "xunknown" then : break fi CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" ac_link="$ax_pthread_save_ac_link" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void){return 0;} _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_link="$ax_pthread_2step_ac_link" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void){return 0;} _ACEOF if ac_fn_c_try_link "$LINENO" then : break fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext done ac_link="$ax_pthread_save_ac_link" CFLAGS="$ax_pthread_save_CFLAGS" if test "x$ax_pthread_try" = "x" then : ax_pthread_try=no fi ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" >&5 printf "%s\n" "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" >&6; } case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in no | unknown) ;; *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; esac fi # $ax_pthread_clang = yes # Various other checks: if test "x$ax_pthread_ok" = "xyes"; then ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 printf %s "checking for joinable pthread attribute... " >&6; } if test ${ax_cv_PTHREAD_JOINABLE_ATTR+y} then : printf %s "(cached) " >&6 else $as_nop ax_cv_PTHREAD_JOINABLE_ATTR=unknown for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { int attr = $ax_pthread_attr; return attr /* ; */ ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext done fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_JOINABLE_ATTR" >&5 printf "%s\n" "$ax_cv_PTHREAD_JOINABLE_ATTR" >&6; } if test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ test "x$ax_pthread_joinable_attr_defined" != "xyes" then : printf "%s\n" "#define PTHREAD_CREATE_JOINABLE $ax_cv_PTHREAD_JOINABLE_ATTR" >>confdefs.h ax_pthread_joinable_attr_defined=yes fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether more special flags are required for pthreads" >&5 printf %s "checking whether more special flags are required for pthreads... " >&6; } if test ${ax_cv_PTHREAD_SPECIAL_FLAGS+y} then : printf %s "(cached) " >&6 else $as_nop ax_cv_PTHREAD_SPECIAL_FLAGS=no case $host_os in solaris*) ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_SPECIAL_FLAGS" >&5 printf "%s\n" "$ax_cv_PTHREAD_SPECIAL_FLAGS" >&6; } if test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ test "x$ax_pthread_special_flags_added" != "xyes" then : PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" ax_pthread_special_flags_added=yes fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5 printf %s "checking for PTHREAD_PRIO_INHERIT... " >&6; } if test ${ax_cv_PTHREAD_PRIO_INHERIT+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { int i = PTHREAD_PRIO_INHERIT; return i; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ax_cv_PTHREAD_PRIO_INHERIT=yes else $as_nop ax_cv_PTHREAD_PRIO_INHERIT=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_PRIO_INHERIT" >&5 printf "%s\n" "$ax_cv_PTHREAD_PRIO_INHERIT" >&6; } if test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ test "x$ax_pthread_prio_inherit_defined" != "xyes" then : printf "%s\n" "#define HAVE_PTHREAD_PRIO_INHERIT 1" >>confdefs.h ax_pthread_prio_inherit_defined=yes fi CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$ax_pthread_save_LIBS" # More AIX lossage: compile with *_r variant if test "x$GCC" != "xyes"; then case $host_os in aix*) case "x/$CC" in #( x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6) : #handle absolute path differently from PATH based program lookup case "x$CC" in #( x/*) : if as_fn_executable_p ${CC}_r then : PTHREAD_CC="${CC}_r" fi if test "x${CXX}" != "x" then : if as_fn_executable_p ${CXX}_r then : PTHREAD_CXX="${CXX}_r" fi fi ;; #( *) : for ac_prog in ${CC}_r do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_PTHREAD_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$PTHREAD_CC"; then ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_PTHREAD_CC="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PTHREAD_CC=$ac_cv_prog_PTHREAD_CC if test -n "$PTHREAD_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 printf "%s\n" "$PTHREAD_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$PTHREAD_CC" && break done test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" if test "x${CXX}" != "x" then : for ac_prog in ${CXX}_r do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_PTHREAD_CXX+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$PTHREAD_CXX"; then ac_cv_prog_PTHREAD_CXX="$PTHREAD_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_PTHREAD_CXX="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PTHREAD_CXX=$ac_cv_prog_PTHREAD_CXX if test -n "$PTHREAD_CXX"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CXX" >&5 printf "%s\n" "$PTHREAD_CXX" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$PTHREAD_CXX" && break done test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" fi ;; esac ;; #( *) : ;; esac ;; esac fi fi test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test "x$ax_pthread_ok" = "xyes"; then mhd_have_posix_threads='yes' printf "%s\n" "#define HAVE_PTHREAD_H 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pthread_sigmask(3) is available" >&5 printf %s "checking whether pthread_sigmask(3) is available... " >&6; } if test ${mhd_cv_func_pthread_sigmask+y} then : printf %s "(cached) " >&6 else $as_nop save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="${CFLAGS_ac} ${PTHREAD_CFLAGS} ${user_CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { sigset_t nset, oset; sigemptyset (&nset); sigaddset (&nset, SIGPIPE); if (0 != pthread_sigmask(SIG_BLOCK, &nset, &oset)) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_pthread_sigmask="yes" else $as_nop mhd_cv_func_pthread_sigmask="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="${save_LIBS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_pthread_sigmask" >&5 printf "%s\n" "$mhd_cv_func_pthread_sigmask" >&6; } if test "x$mhd_cv_func_pthread_sigmask" = x"yes" then : printf "%s\n" "#define HAVE_PTHREAD_SIGMASK 1" >>confdefs.h fi : else ax_pthread_ok=no mhd_have_posix_threads='no' fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "x$mhd_have_posix_threads" = "xyes"; then HAVE_POSIX_THREADS_TRUE= HAVE_POSIX_THREADS_FALSE='#' else HAVE_POSIX_THREADS_TRUE='#' HAVE_POSIX_THREADS_FALSE= fi mhd_have_w32_threads='no' if test "x$with_threads" = "xauto" then : if test "x$os_is_windows" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for W32 threads" >&5 printf %s "checking for W32 threads... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_have_w32_threads='yes' else $as_nop mhd_have_w32_threads='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_have_w32_threads" >&5 printf "%s\n" "$mhd_have_w32_threads" >&6; } fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for threading lib to use with libmicrohttpd ($with_threads)" >&5 printf %s "checking for threading lib to use with libmicrohttpd ($with_threads)... " >&6; } if test "x$with_threads" = "xposix" then : # forced posix threads if test "x$mhd_have_posix_threads" = "xyes" then : USE_THREADS='posix' else $as_nop if test "x$os_is_windows" = "xyes" then : as_fn_error $? "Posix threads are not available. Try to configure --with-threads=auto" "$LINENO" 5 else $as_nop as_fn_error $? "No threading lib is available. Consider installing pthreads" "$LINENO" 5 fi fi fi if test "x$with_threads" = "xw32" then : # forced w32 threads if test "x$mhd_have_w32_threads" = "xyes" then : USE_THREADS='w32' else $as_nop as_fn_error $? "W32 threads are not available. Try to configure --with-threads=auto" "$LINENO" 5 fi fi if test "x$with_threads" = "xauto" then : # automatic threads lib selection if test "x$os_is_native_w32" = "xyes" && test "x$mhd_have_w32_threads" = "xyes" then : USE_THREADS='w32' elif test "x$mhd_have_posix_threads" = "xyes" then : USE_THREADS='posix' elif test "x$mhd_have_w32_threads" = "xyes" then : USE_THREADS='w32' else $as_nop as_fn_error $? "No threading lib is available. Consider installing pthreads" "$LINENO" 5 fi fi if test "x$with_threads" = "xnone" then : USE_THREADS='none' fi if test "x$USE_THREADS" = "xposix" then : CC="$PTHREAD_CC" printf "%s\n" "#define MHD_USE_POSIX_THREADS 1" >>confdefs.h MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS" MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS" MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG" else $as_nop if test "x$USE_THREADS" = "xw32" then : printf "%s\n" "#define MHD_USE_W32_THREADS 1" >>confdefs.h fi fi if test "x$USE_THREADS" = "xposix"; then USE_POSIX_THREADS_TRUE= USE_POSIX_THREADS_FALSE='#' else USE_POSIX_THREADS_TRUE='#' USE_POSIX_THREADS_FALSE= fi if test "x$USE_THREADS" = "xw32"; then USE_W32_THREADS_TRUE= USE_W32_THREADS_FALSE='#' else USE_W32_THREADS_TRUE='#' USE_W32_THREADS_FALSE= fi if test "x$USE_THREADS" != "xnone"; then USE_THREADS_TRUE= USE_THREADS_FALSE='#' else USE_THREADS_TRUE='#' USE_THREADS_FALSE= fi if test "x$USE_THREADS" = "xnone"; then DISABLE_THREADS_TRUE= DISABLE_THREADS_FALSE='#' else DISABLE_THREADS_TRUE='#' DISABLE_THREADS_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $USE_THREADS" >&5 printf "%s\n" "$USE_THREADS" >&6; } # Check whether --enable-thread-names was given. if test ${enable_thread_names+y} then : enableval=$enable_thread_names; else $as_nop enable_thread_names='auto' fi if test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix" then : # Check for thread name function HAVE_THREAD_NAME_FUNC="no" SAVE_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="${CFLAGS_ac} $PTHREAD_CFLAGS ${user_CFLAGS}" ac_fn_c_check_header_compile "$LINENO" "pthread_np.h" "ac_cv_header_pthread_np_h" " $ac_includes_default #include " if test "x$ac_cv_header_pthread_np_h" = xyes then : printf "%s\n" "#define HAVE_PTHREAD_NP_H 1" >>confdefs.h fi # Try to find how to set thread name by thread attributes. # If pthread_attr_setname_np(3) is not declared, it's not possible to detect # form of pthread_attr_setname_np(3) due to C "feature" "implicit declaration". ac_fn_check_decl "$LINENO" "pthread_attr_setname_np" "ac_cv_have_decl_pthread_attr_setname_np" " #include #ifdef HAVE_PTHREAD_NP_H #include #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_pthread_attr_setname_np" = xyes then : fi if test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_attr_setname_np(3) in NetBSD or OSF1 form" >&5 printf %s "checking for pthread_attr_setname_np(3) in NetBSD or OSF1 form... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_PTHREAD_NP_H #include #endif int main (void) { pthread_attr_t thr_attr; pthread_attr_init(&thr_attr); pthread_attr_setname_np(&thr_attr, "name", 0); pthread_attr_destroy(&thr_attr); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD 1" >>confdefs.h HAVE_THREAD_NAME_FUNC="yes" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi if test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_attr_setname_np(3) in IBM i or Solaris form" >&5 printf %s "checking for pthread_attr_setname_np(3) in IBM i or Solaris form... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_PTHREAD_NP_H #include #endif int main (void) { pthread_attr_t thr_attr; pthread_attr_init(&thr_attr); pthread_attr_setname_np(&thr_attr, "name"); pthread_attr_destroy(&thr_attr); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI 1" >>confdefs.h HAVE_THREAD_NAME_FUNC="yes" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi # Try to find how to set thread name for started thread - less convenient # than setting name by attributes. # If pthread_setname_np(3) is not declared, it's not possible to detect # form of pthread_setname_np(3) due to C "feature" "implicit declaration". if test "x$HAVE_THREAD_NAME_FUNC" != "xyes" then : ac_fn_check_decl "$LINENO" "pthread_setname_np" "ac_cv_have_decl_pthread_setname_np" " #include #ifdef HAVE_PTHREAD_NP_H #include #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_pthread_setname_np" = xyes then : fi fi if test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_setname_np(3) in NetBSD or OSF1 form" >&5 printf %s "checking for pthread_setname_np(3) in NetBSD or OSF1 form... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_PTHREAD_NP_H #include #endif int main (void) { int res = pthread_setname_np(pthread_self(), "name", 0); if (res) return res; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_PTHREAD_SETNAME_NP_NETBSD 1" >>confdefs.h HAVE_THREAD_NAME_FUNC="yes" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi if test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_setname_np(3) in GNU/Linux form" >&5 printf %s "checking for pthread_setname_np(3) in GNU/Linux form... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_PTHREAD_NP_H #include #endif int main (void) { int res = pthread_setname_np(pthread_self(), "name"); if (res) return res; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_PTHREAD_SETNAME_NP_GNU 1" >>confdefs.h HAVE_THREAD_NAME_FUNC="yes" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi if test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_setname_np(3) in Darwin form" >&5 printf %s "checking for pthread_setname_np(3) in Darwin form... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_PTHREAD_NP_H #include #endif int main (void) { int res = pthread_setname_np("name"); if (res) return res; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_PTHREAD_SETNAME_NP_DARWIN 1" >>confdefs.h HAVE_THREAD_NAME_FUNC="yes" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi if test "x$HAVE_THREAD_NAME_FUNC" != "xyes" then : ac_fn_check_decl "$LINENO" "pthread_set_name_np" "ac_cv_have_decl_pthread_set_name_np" " #include #ifdef HAVE_PTHREAD_NP_H #include #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_pthread_set_name_np" = xyes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_set_name_np(3) in FreeBSD form" >&5 printf %s "checking for pthread_set_name_np(3) in FreeBSD form... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_PTHREAD_NP_H #include #endif int main (void) { pthread_set_name_np(pthread_self(), "name"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_PTHREAD_SET_NAME_NP_FREEBSD 1" >>confdefs.h HAVE_THREAD_NAME_FUNC="yes" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi fi LIBS="$SAVE_LIBS" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" fi if test "x$enable_thread_names" != "xno" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable thread names" >&5 printf %s "checking whether to enable thread names... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifdef MHD_NO_THREAD_NAMES #error Thread names are disabled. choke me #endif /* Keep in sync with mhd_threads.h */ #if defined(MHD_USE_POSIX_THREADS) && (defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) || \ defined(HAVE_PTHREAD_SETNAME_NP_GNU) || defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || \ defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) ) (void) 0; /* no-op */ #elif defined(MHD_USE_W32_THREADS) && defined(_MSC_FULL_VER) (void) 0; /* no-op */ #else #error No thread name function is available. choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : enable_thread_names='yes' else $as_nop if test "x$enable_thread_names" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } as_fn_error $? "thread names was explicitly requested, but thread name function is not available" "$LINENO" 5 fi enable_thread_names='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_thread_names" >&5 printf "%s\n" "$enable_thread_names" >&6; } fi if test "x$enable_thread_names" = "xno" then : printf "%s\n" "#define MHD_NO_THREAD_NAMES 1" >>confdefs.h fi if test "x$os_is_native_w32" = "xyes"; then HAVE_W32_TRUE= HAVE_W32_FALSE='#' else HAVE_W32_TRUE='#' HAVE_W32_FALSE= fi w32_shared_lib_exp=no if test "x$enable_shared" = "xyes" && test "x$os_is_native_w32" = "xyes" then : if test "x$ac_cv_use_ms_lib_tool" = "xyes" || test -n "$DLLTOOL" then : w32_shared_lib_exp=yes use_expfile="no" if test "x$ac_cv_use_ms_lib_tool" = x"yes" then : use_expfile="yes" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $DLLTOOL supports export file generation" >&5 printf %s "checking whether $DLLTOOL supports export file generation... " >&6; } if test ${mhd_cv_dlltool_expfile+y} then : printf %s "(cached) " >&6 else $as_nop if { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$DLLTOOL -e conftest.exp >&2 "; } >&5 ($DLLTOOL -e conftest.exp >&2 ) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : if test -f conftest.exp then : mhd_cv_dlltool_expfile="yes" else $as_nop mhd_cv_dlltool_expfile="no" fi else $as_nop mhd_cv_dlltool_expfile="no" fi rm -f conftest.exp fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_dlltool_expfile" >&5 printf "%s\n" "$mhd_cv_dlltool_expfile" >&6; } use_expfile="${mhd_cv_dlltool_expfile}" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: GNU dlltool or MS lib.exe is required for creating shared library export on W32" >&5 printf "%s\n" "$as_me: WARNING: GNU dlltool or MS lib.exe is required for creating shared library export on W32" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Export library libmicrohttpd.lib will not be created" >&5 printf "%s\n" "$as_me: WARNING: Export library libmicrohttpd.lib will not be created" >&2;} fi fi if test "x$w32_shared_lib_exp" = "xyes"; then W32_SHARED_LIB_EXP_TRUE= W32_SHARED_LIB_EXP_FALSE='#' else W32_SHARED_LIB_EXP_TRUE='#' W32_SHARED_LIB_EXP_FALSE= fi if test "x$ac_cv_use_ms_lib_tool" = "xyes"; then USE_MS_LIB_TOOL_TRUE= USE_MS_LIB_TOOL_FALSE='#' else USE_MS_LIB_TOOL_TRUE='#' USE_MS_LIB_TOOL_FALSE= fi if test "x$use_expfile" = "xyes"; then USE_EXPORT_FILE_TRUE= USE_EXPORT_FILE_FALSE='#' else USE_EXPORT_FILE_TRUE='#' USE_EXPORT_FILE_FALSE= fi # Expansion of MHD_FIND_LIB macro starts here if test ${mhd_cv_find_lib_socket+y} then : else $as_nop ac_fn_check_decl "$LINENO" "socket" "ac_cv_have_decl_socket" " #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_socket" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing function socket" >&5 printf %s "checking for library containing function socket... " >&6; } if test ${mhd_cv_find_lib_socket+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_socket" = x"yes" then : mhd_find_lib_SAVE_LIBS="$LIBS" mhd_find_lib_CHECK_LIBS=" $LIBS" # Reuse the same source file cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif int main(void) { (void)socket(0, 0, 0); return 0; } _ACEOF for mhd_find_lib_LIB in '' socket ws2_32 xnet do if test -z "${mhd_find_lib_LIB}" then : LIBS="${mhd_find_lib_CHECK_LIBS}" else $as_nop LIBS="-l${mhd_find_lib_LIB} ${mhd_find_lib_CHECK_LIBS}" fi if ac_fn_c_try_link "$LINENO" then : if test -z "${mhd_find_lib_LIB}" then : mhd_cv_find_lib_socket="none required" else $as_nop mhd_cv_find_lib_socket="-l${mhd_find_lib_LIB}" fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${mhd_cv_find_lib_socket+y} then : break fi done { mhd_find_lib_LIB=; unset mhd_find_lib_LIB;} rm -f conftest.$ac_ext LIBS="${mhd_find_lib_SAVE_LIBS}" { mhd_find_lib_SAVE_LIBS=; unset mhd_find_lib_SAVE_LIBS;} fi if test ${mhd_cv_find_lib_socket+y} then : : else $as_nop mhd_cv_find_lib_socket="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_find_lib_socket" >&5 printf "%s\n" "$mhd_cv_find_lib_socket" >&6; } if test "x${mhd_cv_find_lib_socket}" != "xno" then : if test "x$mhd_cv_find_lib_socket" = x"none required" then : : else $as_nop if test -z "$LIBS" then : LIBS="${mhd_cv_find_lib_socket}" else $as_nop LIBS="${mhd_cv_find_lib_socket} $LIBS" fi fi if test "x$mhd_cv_find_lib_socket" = x"none required" then : else $as_nop MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_socket} $MHD_LIBDEPS_PKGCFG" fi else $as_nop as_fn_error $? "cannot find header or library required for function socket()" "$LINENO" 5 fi # Expansion of _MHD_FIND_LIB_BODY macro ends here ac_fn_c_check_header_compile "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" if test "x$ac_cv_header_sys_time_h" = xyes then : printf "%s\n" "#define HAVE_SYS_TIME_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default" if test "x$ac_cv_header_time_h" = xyes then : printf "%s\n" "#define HAVE_TIME_H 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_gettimeofday+y} then : else $as_nop ac_fn_check_decl "$LINENO" "gettimeofday" "ac_cv_have_decl_gettimeofday" " #ifdef HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_gettimeofday" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function gettimeofday" >&5 printf %s "checking for function gettimeofday... " >&6; } if test ${mhd_cv_func_gettimeofday+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_gettimeofday" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ int main(void) { struct timeval tv; if (0 != gettimeofday (&tv, (void*) 0)) return 1; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_gettimeofday="yes" else $as_nop mhd_cv_func_gettimeofday="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_gettimeofday="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_gettimeofday" >&5 printf "%s\n" "$mhd_cv_func_gettimeofday" >&6; } if test "x$mhd_cv_func_gettimeofday" = x"yes" then : printf "%s\n" "#define HAVE_GETTIMEOFDAY 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_usleep+y} then : else $as_nop ac_fn_check_decl "$LINENO" "usleep" "ac_cv_have_decl_usleep" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_usleep" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function usleep" >&5 printf %s "checking for function usleep... " >&6; } if test ${mhd_cv_func_usleep+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_usleep" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { usleep(100000); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_usleep="yes" else $as_nop mhd_cv_func_usleep="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_usleep="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_usleep" >&5 printf "%s\n" "$mhd_cv_func_usleep" >&6; } if test "x$mhd_cv_func_usleep" = x"yes" then : printf "%s\n" "#define HAVE_USLEEP 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_nanosleep+y} then : else $as_nop ac_fn_check_decl "$LINENO" "nanosleep" "ac_cv_have_decl_nanosleep" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_nanosleep" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function nanosleep" >&5 printf %s "checking for function nanosleep... " >&6; } if test ${mhd_cv_func_nanosleep+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_nanosleep" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { struct timespec ts2, ts1 = {0, 0}; nanosleep(&ts1, &ts2); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_nanosleep="yes" else $as_nop mhd_cv_func_nanosleep="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_nanosleep="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_nanosleep" >&5 printf "%s\n" "$mhd_cv_func_nanosleep" >&6; } if test "x$mhd_cv_func_nanosleep" = x"yes" then : printf "%s\n" "#define HAVE_NANOSLEEP 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here ac_fn_c_check_header_compile "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default " if test "x$ac_cv_header_string_h" = xyes then : printf "%s\n" "#define HAVE_STRING_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/types.h" "ac_cv_header_sys_types_h" "$ac_includes_default " if test "x$ac_cv_header_sys_types_h" = xyes then : printf "%s\n" "#define HAVE_SYS_TYPES_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default " if test "x$ac_cv_header_sys_socket_h" = xyes then : printf "%s\n" "#define HAVE_SYS_SOCKET_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default " if test "x$ac_cv_header_netinet_in_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IN_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default " if test "x$ac_cv_header_time_h" = xyes then : printf "%s\n" "#define HAVE_TIME_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/select.h" "ac_cv_header_sys_select_h" "$ac_includes_default " if test "x$ac_cv_header_sys_select_h" = xyes then : printf "%s\n" "#define HAVE_SYS_SELECT_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/tcp.h" "ac_cv_header_netinet_tcp_h" "$ac_includes_default " if test "x$ac_cv_header_netinet_tcp_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_TCP_H 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether shutdown of listen socket triggers select()" >&5 printf %s "checking whether shutdown of listen socket triggers select()... " >&6; } if test ${mhd_cv_host_shtdwn_trgr_select+y} then : printf %s "(cached) " >&6 else $as_nop # On Linux shutdown of listen socket always trigger select(). # On Windows select() always ignore shutdown of listen socket. # On other paltforms result may vary depending on platform version. case $host_os in #( linux | linux-* | *-linux | *-linux-*) : mhd_cv_host_shtdwn_trgr_select='yes' ;; #( mingw*) : mhd_cv_host_shtdwn_trgr_select='no' ;; #( cygwin* | msys*) : mhd_cv_host_shtdwn_trgr_select='no' ;; #( winnt* | interix*) : mhd_cv_host_shtdwn_trgr_select='no' ;; #( mks) : mhd_cv_host_shtdwn_trgr_select='no' ;; #( uwin) : mhd_cv_host_shtdwn_trgr_select='no' ;; #( *) : mhd_cv_host_shtdwn_trgr_select='maybe' ;; esac if test "x$mhd_cv_host_shtdwn_trgr_select" = x"maybe" then : ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu MHD_CST_SAVE_CC="$CC" MHD_CST_SAVE_CFLAGS="$CFLAGS" MHD_CST_SAVE_LIBS="$LIBS" CC="$PTHREAD_CC" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" if test "$cross_compiling" = yes then : mhd_cv_host_shtdwn_trgr_select='guessing no' else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_TIME_H # include #endif #ifdef HAVE_STRING_H # include #endif #if !defined(_WIN32) || defined(__CYGWIN__) # ifdef HAVE_SYS_TYPES_H # include # endif # ifdef HAVE_SYS_SOCKET_H # include # endif # ifdef HAVE_NETINET_IN_H # include # endif # ifdef HAVE_SYS_TIME_H # include # endif # ifdef HAVE_SYS_SELECT_H # include # endif # ifdef HAVE_NETINET_TCP_H # include # endif typedef int MHD_socket; # define MHD_INVALID_SOCKET (-1) # define MHD_POSIX_SOCKETS 1 #else # include # include # include typedef SOCKET MHD_socket; # define MHD_INVALID_SOCKET (INVALID_SOCKET) # define MHD_WINSOCK_SOCKETS 1 #endif #include #ifndef SHUT_RD # define SHUT_RD 0 #endif #ifndef SHUT_WR # define SHUT_WR 1 #endif #ifndef SHUT_RDWR # define SHUT_RDWR 2 #endif #ifndef NULL # define NULL ((void*)0) #endif #ifdef HAVE_GETTIMEOFDAY # if defined(_WIN32) && !defined(__CYGWIN__) # undef HAVE_GETTIMEOFDAY # endif #endif #ifdef HAVE_NANOSLEEP static const struct timespec sm_tmout = {0, 1000}; # define short_sleep() nanosleep(&sm_tmout, NULL) #elif defined(HAVE_USLEEP) # define short_sleep() usleep(1) #else # define short_sleep() (void)0 #endif static volatile int going_select = 0; static volatile int select_ends = 0; static volatile int gerror = 0; static int timeout_mils; #ifndef HAVE_GETTIMEOFDAY static volatile long long select_elapsed_time = 0; static long long time_chk(void) { long long ret = time(NULL); if (-1 == ret) gerror = 4; return ret; } #endif static void* select_thrd_func(void* param) { #ifndef HAVE_GETTIMEOFDAY long long start, stop; #endif fd_set rs; struct timeval tmot = {0, 0}; MHD_socket fd = *((MHD_socket*)param); FD_ZERO(&rs); FD_SET(fd, &rs); tmot.tv_usec = timeout_mils * 1000; #ifndef HAVE_GETTIMEOFDAY start = time_chk(); #endif going_select = 1; if (0 > select ((int)(fd) + 1, &rs, NULL, NULL, &tmot)) gerror = 5; #ifndef HAVE_GETTIMEOFDAY stop = time_chk(); select_elapsed_time = stop - start; #endif select_ends = 1; return NULL; } static MHD_socket create_socket(void) { return socket (AF_INET, SOCK_STREAM, 0); } static void close_socket(MHD_socket fd) { #ifdef MHD_POSIX_SOCKETS close(fd); #else closesocket(fd); #endif } static MHD_socket create_socket_listen(int port) { MHD_socket fd; struct sockaddr_in sock_addr; fd = create_socket(); if (MHD_INVALID_SOCKET == fd) return fd; memset (&sock_addr, 0, sizeof (struct sockaddr_in)); sock_addr.sin_family = AF_INET; sock_addr.sin_port = htons(port); sock_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); if (bind (fd, (const struct sockaddr*) &sock_addr, sizeof(sock_addr)) < 0 || listen(fd, SOMAXCONN) < 0) { close_socket(fd); return MHD_INVALID_SOCKET; } return fd; } #ifdef HAVE_GETTIMEOFDAY #define diff_time(tv1, tv2) ((long long)(tv1.tv_sec-tv2.tv_sec)*10000 + (long long)(tv1.tv_usec-tv2.tv_usec)/100) #else #define diff_time(tv1, tv2) ((long long)(tv1-tv2)) #endif static long long test_run_select(int timeout_millsec, int use_shutdown, long long delay_before_shutdown) { pthread_t select_thrd; MHD_socket fd; #ifdef HAVE_GETTIMEOFDAY struct timeval start, stop; #else long long start; #endif fd = create_socket_listen(0); if (MHD_INVALID_SOCKET == fd) return -7; going_select = 0; select_ends = 0; gerror = 0; timeout_mils = timeout_millsec; if (0 != pthread_create (&select_thrd, NULL, select_thrd_func, (void*)&fd)) return -8; while (!going_select) {short_sleep();} #ifdef HAVE_GETTIMEOFDAY gettimeofday (&start, NULL); #else start = time_chk(); #endif if (use_shutdown) { #ifdef HAVE_GETTIMEOFDAY struct timeval current; do {short_sleep(); gettimeofday(¤t, NULL); } while (delay_before_shutdown > diff_time(current, start)); #else while (delay_before_shutdown > time_chk() - start) {short_sleep();} #endif shutdown(fd, SHUT_RDWR); } #ifdef HAVE_GETTIMEOFDAY while (!select_ends) {short_sleep();} gettimeofday (&stop, NULL); #endif if (0 != pthread_join(select_thrd, NULL)) return -9; close_socket(fd); if (gerror) return -10; #ifdef HAVE_GETTIMEOFDAY return (long long)diff_time(stop, start); #else return select_elapsed_time; #endif } static int test_it(void) { long long duration2; #ifdef HAVE_GETTIMEOFDAY long long duration0, duration1; duration0 = test_run_select(0, 0, 0); if (0 > duration0) return -duration0; duration1 = test_run_select(50, 0, 0); if (0 > duration1) return -duration1 + 20; duration2 = test_run_select(500, 1, (duration0 + duration1) / 2); if (0 > duration2) return -duration2 + 40; if (duration1 * 2 > duration2) { /* Check second time to be sure. */ duration2 = test_run_select(500, 1, (duration0 + duration1) / 2); if (0 > duration2) return -duration2 + 60; if (duration1 * 2 > duration2) return 0; } #else duration2 = test_run_select(5000, 1, 2); if (0 > duration2) return -duration2 + 80; if (4 > duration2) { /* Check second time to be sure. */ duration2 = test_run_select(5000, 1, 2); if (0 > duration2) return -duration2 + 100; if (4 > duration2) return 0; } #endif return 1; } static int init(void) { #ifdef MHD_WINSOCK_SOCKETS WSADATA wsa_data; if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data) || MAKEWORD(2, 2) != wsa_data.wVersion) { WSACleanup(); return 0; } #endif /* MHD_WINSOCK_SOCKETS */ return 1; } static void cleanup(void) { #ifdef MHD_WINSOCK_SOCKETS WSACleanup(); #endif /* MHD_WINSOCK_SOCKETS */ } int main(void) { int res; if (!init()) return 19; res = test_it(); cleanup(); if (gerror) return gerror; return res; } _ACEOF if ac_fn_c_try_run "$LINENO" then : mhd_cv_host_shtdwn_trgr_select='yes' else $as_nop mhd_cv_host_shtdwn_trgr_select='no' fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi CC="$MHD_CST_SAVE_CC" CFLAGS="$MHD_CST_SAVE_CFLAGS" LIBS="$MHD_CST_SAVE_LIBS" { MHD_CST_SAVE_CC=; unset MHD_CST_SAVE_CC;} { MHD_CST_SAVE_CFLAGS=; unset MHD_CST_SAVE_CFLAGS;} { MHD_CST_SAVE_LIBS=; unset MHD_CST_SAVE_LIBS;} ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_host_shtdwn_trgr_select" >&5 printf "%s\n" "$mhd_cv_host_shtdwn_trgr_select" >&6; } if test "x$mhd_cv_host_shtdwn_trgr_select" = "xyes" then : printf "%s\n" "#define HAVE_LISTEN_SHUTDOWN 1" >>confdefs.h elif test "x$mhd_cv_host_shtdwn_trgr_select" = "xno" then : fi if test "x$mhd_cv_host_shtdwn_trgr_select" = "xyes"; then HAVE_LISTEN_SHUTDOWN_TRUE= HAVE_LISTEN_SHUTDOWN_FALSE='#' else HAVE_LISTEN_SHUTDOWN_TRUE='#' HAVE_LISTEN_SHUTDOWN_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for system default FD_SETSIZE value" >&5 printf %s "checking for system default FD_SETSIZE value... " >&6; } if test ${mhd_cv_sys_fd_setsize_value+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -UFD_SETSIZE" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS} -UFD_SETSIZE" if ac_fn_c_compute_int "$LINENO" "FD_SETSIZE" "mhd_cv_sys_fd_setsize_value" " #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif " then : else $as_nop mhd_cv_sys_fd_setsize_value="unknown" fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" if test "x${mhd_cv_sys_fd_setsize_value}" != "xunknown" && \ test "${mhd_cv_sys_fd_setsize_value}" -eq "0" \ then : mhd_cv_sys_fd_setsize_value="unknown" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_sys_fd_setsize_value" >&5 printf "%s\n" "$mhd_cv_sys_fd_setsize_value" >&6; } if test "x$mhd_cv_sys_fd_setsize_value" = x"unknown" then : : else $as_nop printf "%s\n" "#define MHD_SYS_FD_SETSIZE_ ${mhd_cv_sys_fd_setsize_value}" >>confdefs.h fi if test "x${mhd_cv_sys_fd_setsize_value}" = "xunknown"; then NEED_SYS_FD_SET_SIZE_VALUE_TRUE= NEED_SYS_FD_SET_SIZE_VALUE_FALSE='#' else NEED_SYS_FD_SET_SIZE_VALUE_TRUE='#' NEED_SYS_FD_SET_SIZE_VALUE_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for current FD_SETSIZE value" >&5 printf %s "checking for current FD_SETSIZE value... " >&6; } if test ${mhd_cv_fd_setsize_value+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" if test "x${cross_compiling}" != "xno" && test "x${mhd_cv_sys_fd_setsize_value}" != "xunknown" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif #define DETECTED_FD_SETZIE_VALUE ${mhd_cv_sys_fd_setsize_value} #if (FD_SETSIZE) != (DETECTED_FD_SETZIE_VALUE) #error The current default FD_SETSIZE value is different from ${mhd_cv_sys_fd_setsize_value} choke me here now #endif /* (FD_SETSIZE) != (DETECTED_FD_SETZIE_VALUE) */ #if (FD_SETSIZE) != (${mhd_cv_sys_fd_setsize_value}) #error The current default FD_SETSIZE value is different from ${mhd_cv_sys_fd_setsize_value} choke me here now #endif /* (FD_SETSIZE) != (${mhd_cv_sys_fd_setsize_value}) */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_fd_setsize_value="${mhd_cv_sys_fd_setsize_value}" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test ${mhd_cv_fd_setsize_value+y} then : : else $as_nop if ac_fn_c_compute_int "$LINENO" "FD_SETSIZE" "mhd_cv_fd_setsize_value" " #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif " then : else $as_nop mhd_cv_fd_setsize_value="unknown" fi fi if test "x${mhd_cv_fd_setsize_value}" != "xunknown" && \ test "${mhd_cv_fd_setsize_value}" -eq "0" then : mhd_cv_fd_setsize_value="unknown" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_fd_setsize_value" >&5 printf "%s\n" "$mhd_cv_fd_setsize_value" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether FD_SETSIZE is overridable" >&5 printf %s "checking whether FD_SETSIZE is overridable... " >&6; } if test ${mhd_cv_fd_setsize_overridable+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$mhd_cv_fd_setsize_value" = x"unknown" then : if test "x$mhd_cv_sys_fd_setsize_value" = x"unknown" then : # Assume the most popular FD_SETSIZE value base_fd_setsize=1024 else $as_nop base_fd_setsize="${mhd_cv_sys_fd_setsize_value}" fi base_min_fd_setsize="${base_fd_setsize}" else $as_nop if test "x$mhd_cv_sys_fd_setsize_value" = x"unknown" then : base_fd_setsize="${mhd_cv_fd_setsize_value}" base_min_fd_setsize="${base_fd_setsize}" else $as_nop if test "${mhd_cv_fd_setsize_value}" -ge "${mhd_cv_sys_fd_setsize_value}" then : base_fd_setsize="${mhd_cv_fd_setsize_value}" base_min_fd_setsize="${mhd_cv_sys_fd_setsize_value}" else $as_nop base_fd_setsize="${mhd_cv_sys_fd_setsize_value}" base_min_fd_setsize="${mhd_cv_fd_setsize_value}" fi fi fi # Use two times larger FD_SETSIZE value for test as_fn_arith ${base_fd_setsize} '+' ${base_fd_setsize} && test_fd_setsize=$as_val if test "${test_fd_setsize}" -lt "128" then : test_fd_setsize=128 fi test_type_fd_setsize="larger" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" printf "%s\n" "$as_me:${as_lineno-$LINENO}: testing whether FD_SETSIZE test value (${test_fd_setsize}) is suitable for 'int' type" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { static int test_arr1[(((long long)${test_fd_setsize}) != ((int)${test_fd_setsize})) ? -1 : 1]; static int test_arr2[(0 > ((int)${test_fd_setsize})) ? -1 : 1]; test_arr1[0] = 0; test_arr2[0] = 0; if (test_arr1[0] != test_arr2[0]) return 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: The selected test FD_SETSIZE value (${test_fd_setsize}) is too large for 'int' type" >&5 as_fn_arith ${base_min_fd_setsize} '/' '2' && test_fd_setsize=$as_val test_type_fd_setsize="smaller" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext printf "%s\n" "$as_me:${as_lineno-$LINENO}: will try ${test_fd_setsize} as FD_SETSIZE value" >&5 if test "x${cross_compiling}" = "xno" && test "x${test_type_fd_setsize}" = "xlarger" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: will try ${test_fd_setsize} as FD_SETSIZE value with run test" >&5 if test "$cross_compiling" = yes then : # Not used when cross-compiling else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef FD_SETSIZE #undef FD_SETSIZE #endif /* FD_SETSIZE */ #define FD_SETSIZE ${test_fd_setsize} #define MY_TEST_FD_SETSIZE ${test_fd_setsize} #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #define MHD_TEST_SOCKET_TYPE SOCKET #else #define MHD_TEST_SOCKET_TYPE int #endif #ifdef HAVE_SYS_SELECT_H #include #endif #include #include /* Test for mismatch by macro check */ #if (FD_SETSIZE) != (MY_TEST_FD_SETSIZE) #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize} choke me here now; #endif /* (FD_SETSIZE) != (MY_TEST_FD_SETSIZE) */ /* Additional test for mismatch by macro check */ #if (FD_SETSIZE) != (${test_fd_setsize}) #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize} choke me here now; #endif /* (FD_SETSIZE) != (${test_fd_setsize}) */ static unsigned long var_fd_setsize_value = FD_SETSIZE; static unsigned long var_my_test_fd_setsize_value = MY_TEST_FD_SETSIZE; int main(void) { fd_set fds_num_one_copy; fd_set fds_num_three_copy; fd_set test_fdsets[6]; int i; int ret = 0; #if defined(_WIN32) && ! defined(__CYGWIN__) WSADATA wsa_data; if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data)) return 21; if (MAKEWORD(2, 2) != wsa_data.wVersion) { WSACleanup(); return 22; } #endif /* _WIN32 && ! __CYGWIN__ */ /* Init with zeros to make sure that slack areas are equal */ memset(test_fdsets, 0, sizeof(test_fdsets)); /* Correctly init fd_sets */ for (i = 0; i < 6; ++i) FD_ZERO(test_fdsets + i); /* Make copies of zero-inited fd_sets */ memcpy(&fds_num_one_copy, test_fdsets + 1, sizeof(fd_set)); memcpy(&fds_num_three_copy, test_fdsets + 3, sizeof(fd_set)); if (var_fd_setsize_value != var_my_test_fd_setsize_value) { fprintf (stderr, "System headers redefined FD_SETSIZE to another value (%lu).\n", (unsigned long) FD_SETSIZE); ret = 2; } else { /* Set (almost) all FDs in test_fdset[2] */ for (i = 1; i < FD_SETSIZE; ++i) FD_SET((MHD_TEST_SOCKET_TYPE)i, test_fdsets + 2); if (! FD_ISSET((MHD_TEST_SOCKET_TYPE)1, test_fdsets + 2)) { fprintf (stderr, "FD number one in original fd_set is unset, while should be set.\n"); ret |= 3; } if (! FD_ISSET((MHD_TEST_SOCKET_TYPE)(FD_SETSIZE - 1), test_fdsets + 2)) { fprintf (stderr, "FD number %lu in original fd_set is unset, while should be set.\n", (unsigned long) FD_SETSIZE); ret |= 3; } if (FD_ISSET((MHD_TEST_SOCKET_TYPE)1, test_fdsets + 1)) { fprintf (stderr, "FD number one in the first fd_set is unset, while should be set.\n"); ret |= 4; } if (FD_ISSET((MHD_TEST_SOCKET_TYPE)(FD_SETSIZE - 1), test_fdsets + 1)) { fprintf (stderr, "FD number %lu in the first fd_set is unset, while should be set.\n", (unsigned long) FD_SETSIZE); ret |= 4; } if (0 != memcmp (&fds_num_one_copy, test_fdsets + 1, sizeof(fd_set))) { fprintf (stderr, "The first fd_set has been altered.\n"); ret |= 4; } if (FD_ISSET((MHD_TEST_SOCKET_TYPE)1, test_fdsets + 3)) { fprintf (stderr, "FD number one in the third fd_set is unset, while should be set.\n"); ret |= 8; } if (FD_ISSET((MHD_TEST_SOCKET_TYPE)(FD_SETSIZE - 1), test_fdsets + 3)) { fprintf (stderr, "FD number %lu in the third fd_set is unset, while should be set.\n", (unsigned long) FD_SETSIZE); ret |= 8; } if (0 != memcmp (&fds_num_three_copy, test_fdsets + 3, sizeof(fd_set))) { fprintf (stderr, "The third fd_set has been altered.\n"); ret |= 8; } } #if defined(_WIN32) && ! defined(__CYGWIN__) WSACleanup(); #endif /* _WIN32 && ! __CYGWIN__ */ return ret; } _ACEOF if ac_fn_c_try_run "$LINENO" then : mhd_cv_fd_setsize_overridable="yes" else $as_nop mhd_cv_fd_setsize_overridable="no" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi else $as_nop printf "%s\n" "$as_me:${as_lineno-$LINENO}: will try ${test_fd_setsize} as FD_SETSIZE with simple compile test" >&5 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef FD_SETSIZE #undef FD_SETSIZE #endif /* FD_SETSIZE */ #define FD_SETSIZE ${test_fd_setsize} #define MY_TEST_FD_SETSIZE ${test_fd_setsize} #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif /* Test for mismatch by macro check */ #if (FD_SETSIZE) != (MY_TEST_FD_SETSIZE) #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize} choke me here now #endif /* (FD_SETSIZE) != (MY_TEST_FD_SETSIZE) */ /* Additional test for mismatch by macro check */ #if (FD_SETSIZE) != (${test_fd_setsize}) #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize} choke me here now #endif /* (FD_SETSIZE) != (${test_fd_setsize}) */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : printf "%s\n" "$as_me:${as_lineno-$LINENO}: comple test succeed, will check whether another FD_SETSIZE value changes the size of 'fd_set'" >&5 # Check current size of fd_set printf "%s\n" "$as_me:${as_lineno-$LINENO}: find the sizeof(fd_setsize) with current default (${mhd_cv_fd_setsize_value}) FD_SETSIZE value" >&5 if ac_fn_c_compute_int "$LINENO" "sizeof(fd_set)" "sizeof_cur_fd_set" " #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif " then : else $as_nop sizeof_cur_fd_set="unknown" fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: the sizeof(fd_setsize) with current default (${mhd_cv_fd_setsize_value}) FD_SETSIZE value is ${sizeof_cur_fd_set}" >&5 # Check the size of fd_set with redefined FD_SETSIZE printf "%s\n" "$as_me:${as_lineno-$LINENO}: find the sizeof(fd_setsize) with redefined (${test_fd_setsize}) FD_SETSIZE value" >&5 if ac_fn_c_compute_int "$LINENO" "sizeof(fd_set)" "sizeof_mod_fd_set" " #ifdef FD_SETSIZE #undef FD_SETSIZE #endif /* FD_SETSIZE */ #define FD_SETSIZE ${test_fd_setsize} #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif " then : else $as_nop sizeof_mod_fd_set="unknown" fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: the sizeof(fd_setsize) with redefined (${test_fd_setsize}) FD_SETSIZE value is ${sizeof_mod_fd_set}" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: detected sizes of 'fd_set': '${sizeof_cur_fd_set}' (by default), '${sizeof_mod_fd_set}' with modified FD_SETSIZE" >&5 if test "x${sizeof_cur_fd_set}" != "x${sizeof_mod_fd_set}" then : mhd_cv_fd_setsize_overridable="yes" else $as_nop mhd_cv_fd_setsize_overridable="no" fi { sizeof_mod_fd_set=; unset sizeof_mod_fd_set;} { sizeof_cur_fd_set=; unset sizeof_cur_fd_set;} else $as_nop mhd_cv_fd_setsize_overridable="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { test_type_fd_setsize=; unset test_type_fd_setsize;} { test_fd_setsize=; unset test_fd_setsize;} { base_min_fd_setsize=; unset base_min_fd_setsize;} { base_fd_setsize=; unset base_fd_setsize;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_fd_setsize_overridable" >&5 printf "%s\n" "$mhd_cv_fd_setsize_overridable" >&6; } if test "x$mhd_cv_fd_setsize_overridable" = x"no" then : if test "x$os_is_native_w32" = x"yes" then : as_fn_error $? "Non-overridable FD_SETSIZE detected for native W32 build. FD_SETSIZE is overridable on W32." "$LINENO" 5 fi if test "x${mhd_cv_fd_setsize_value}" != "xunknown" && test "x${mhd_cv_sys_fd_setsize_value}" != "xunknown" && test "${mhd_cv_fd_setsize_value}" -ne "${mhd_cv_sys_fd_setsize_value}" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Detected non-overridable FD_SETSIZE, but the toolchain uses FD_SETSIZE (${mhd_cv_fd_setsize_value}) different from system default (${mhd_cv_sys_fd_setsize_value})" >&5 printf "%s\n" "$as_me: WARNING: Detected non-overridable FD_SETSIZE, but the toolchain uses FD_SETSIZE (${mhd_cv_fd_setsize_value}) different from system default (${mhd_cv_sys_fd_setsize_value})" >&2;} fi else $as_nop printf "%s\n" "#define HAS_FD_SETSIZE_OVERRIDABLE 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether socket value is a signed type" >&5 printf %s "checking whether socket value is a signed type... " >&6; } if test ${mhd_cv_socket_signed+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif /* Keep in sync with microhttpd.h */ #if ! defined(_WIN32) || defined(_SYS_TYPES_FD_SET) typedef int MHD_socket; #else /* defined(_WIN32) && ! defined(_SYS_TYPES_FD_SET) */ typedef SOCKET MHD_socket; #endif /* defined(_WIN32) && ! defined(_SYS_TYPES_FD_SET) */ int main(void) { int test_arr[2 - 5*(!!(0 < ((MHD_socket)-1)))]; test_arr[1] = 0; return test_arr[1]; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_socket_signed="yes" else $as_nop mhd_cv_socket_signed="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_socket_signed" >&5 printf "%s\n" "$mhd_cv_socket_signed" >&6; } if test "x$mhd_cv_socket_signed" = x"yes" then : printf "%s\n" "#define HAS_SIGNED_SOCKET 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_writev+y} then : else $as_nop ac_fn_check_decl "$LINENO" "writev" "ac_cv_have_decl_writev" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_writev" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function writev" >&5 printf %s "checking for function writev... " >&6; } if test ${mhd_cv_func_writev+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_writev" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { struct iovec iov[2]; char some_str[4] = "OK\n"; iov[0].iov_base = (void *) some_str; iov[0].iov_len = 3; if (0 > writev(1, iov, 1)) return 2; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_writev="yes" else $as_nop mhd_cv_func_writev="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_writev="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_writev" >&5 printf "%s\n" "$mhd_cv_func_writev" >&6; } if test "x$mhd_cv_func_writev" = x"yes" then : printf "%s\n" "#define HAVE_WRITEV 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_FIND_LIB macro starts here if test ${mhd_cv_find_lib_sendmsg+y} then : else $as_nop ac_fn_check_decl "$LINENO" "sendmsg" "ac_cv_have_decl_sendmsg" " #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #ifdef HAVE_SYS_UIO_H #include #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_sendmsg" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing function sendmsg" >&5 printf %s "checking for library containing function sendmsg... " >&6; } if test ${mhd_cv_find_lib_sendmsg+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_sendmsg" = x"yes" then : mhd_find_lib_SAVE_LIBS="$LIBS" mhd_find_lib_CHECK_LIBS="$MHD_LIBDEPS $LIBS" # Reuse the same source file cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #ifdef HAVE_SYS_UIO_H #include #endif int main(void) { struct msghdr msg; struct iovec iov; unsigned int i; char some_str[5] = "test"; iov.iov_base = (void*)some_str; iov.iov_len = 4; for (i = 0; i < (unsigned int) sizeof(msg); i++) { *(((unsigned char *)&msg) + i) = 0; } msg.msg_iov = &iov; msg.msg_iovlen = 1; if (0 > sendmsg(1, &msg, 0)) return -1; return 0; } _ACEOF for mhd_find_lib_LIB in '' socket do if test -z "${mhd_find_lib_LIB}" then : LIBS="${mhd_find_lib_CHECK_LIBS}" else $as_nop LIBS="-l${mhd_find_lib_LIB} ${mhd_find_lib_CHECK_LIBS}" fi if ac_fn_c_try_link "$LINENO" then : if test -z "${mhd_find_lib_LIB}" then : mhd_cv_find_lib_sendmsg="none required" else $as_nop mhd_cv_find_lib_sendmsg="-l${mhd_find_lib_LIB}" fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${mhd_cv_find_lib_sendmsg+y} then : break fi done { mhd_find_lib_LIB=; unset mhd_find_lib_LIB;} rm -f conftest.$ac_ext LIBS="${mhd_find_lib_SAVE_LIBS}" { mhd_find_lib_SAVE_LIBS=; unset mhd_find_lib_SAVE_LIBS;} fi if test ${mhd_cv_find_lib_sendmsg+y} then : : else $as_nop mhd_cv_find_lib_sendmsg="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_find_lib_sendmsg" >&5 printf "%s\n" "$mhd_cv_find_lib_sendmsg" >&6; } if test "x${mhd_cv_find_lib_sendmsg}" != "xno" then : if test "x$mhd_cv_find_lib_sendmsg" = x"none required" then : : else $as_nop if test -z "$MHD_LIBDEPS" then : MHD_LIBDEPS="${mhd_cv_find_lib_sendmsg}" else $as_nop MHD_LIBDEPS="${mhd_cv_find_lib_sendmsg} $MHD_LIBDEPS" fi fi printf "%s\n" "#define HAVE_SENDMSG 1" >>confdefs.h if test "x$mhd_cv_find_lib_sendmsg" = x"none required" then : else $as_nop MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_sendmsg} $MHD_LIBDEPS_PKGCFG" fi fi # Expansion of _MHD_FIND_LIB_BODY macro ends here { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 printf %s "checking whether byte ordering is bigendian... " >&6; } if test ${ac_cv_c_bigendian+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO" then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \\ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \\ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_bigendian=yes else $as_nop ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_bigendian=yes else $as_nop ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ unsigned short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; unsigned short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } unsigned short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; unsigned short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } int main (int argc, char **argv) { /* Intimidate the compiler so that it does not optimize the arrays away. */ char *p = argv[0]; ascii_mm[1] = *p++; ebcdic_mm[1] = *p++; ascii_ii[1] = *p++; ebcdic_ii[1] = *p++; return use_ascii (argc) == use_ebcdic (*p); } _ACEOF if ac_fn_c_try_link "$LINENO" then : if grep BIGenDianSyS conftest$ac_exeext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest$ac_exeext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main (void) { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_c_bigendian=no else $as_nop ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 printf "%s\n" "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) printf "%s\n" "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) printf "%s\n" "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for variable-length arrays" >&5 printf %s "checking for variable-length arrays... " >&6; } if test ${ac_cv_c_vararrays+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __STDC_NO_VLA__ #error __STDC_NO_VLA__ not defined choke me now #endif _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined' else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Test for VLA support. This test is partly inspired from examples in the C standard. Use at least two VLA functions to detect the GCC 3.4.3 bug described in: https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html */ #ifdef __STDC_NO_VLA__ syntax error; #else extern int n; static int B[100]; int fvla (int m, int C[m][m]); static int simple (int count, int all[static count]) { return all[count - 1]; } int fvla (int m, int C[m][m]) { typedef int VLA[m][m]; VLA x; int D[m]; static int (*q)[m] = &B; int (*s)[n] = q; (void) simple; return C && &x[0][0] == &D[0] && &D[0] == s[0]; } #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_vararrays=yes else $as_nop ac_cv_c_vararrays=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_vararrays" >&5 printf "%s\n" "$ac_cv_c_vararrays" >&6; } if test "$ac_cv_c_vararrays" = yes; then printf "%s\n" "#define HAVE_C_VARARRAYS 1" >>confdefs.h elif test "$ac_cv_c_vararrays" = no; then printf "%s\n" "#define __STDC_NO_VLA__ 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether __func__ magic-macro is available" >&5 printf %s "checking whether __func__ magic-macro is available... " >&6; } if test ${mhd_cv_macro___func___avail+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { const char *funcname = __func__ ; if (NULL == funcname) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_macro___func___avail="yes" else $as_nop mhd_cv_macro___func___avail="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro___func___avail" >&5 printf "%s\n" "$mhd_cv_macro___func___avail" >&6; } if test "x$mhd_cv_macro___func___avail" = x"yes" then : printf "%s\n" "#define HAVE___FUNC__ 1" >>confdefs.h else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether __FUNCTION__ magic-macro is available" >&5 printf %s "checking whether __FUNCTION__ magic-macro is available... " >&6; } if test ${mhd_cv_macro___function___avail+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { const char *funcname = __FUNCTION__ ; if (NULL == funcname) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_macro___function___avail="yes" else $as_nop mhd_cv_macro___function___avail="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro___function___avail" >&5 printf "%s\n" "$mhd_cv_macro___function___avail" >&6; } if test "x$mhd_cv_macro___function___avail" = x"yes" then : printf "%s\n" "#define HAVE___FUNCTION__ 1" >>confdefs.h else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether __PRETTY_FUNCTION__ magic-macro is available" >&5 printf %s "checking whether __PRETTY_FUNCTION__ magic-macro is available... " >&6; } if test ${mhd_cv_macro___pretty_function___avail+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { const char *funcname = __PRETTY_FUNCTION__ ; if (NULL == funcname) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_macro___pretty_function___avail="yes" else $as_nop mhd_cv_macro___pretty_function___avail="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro___pretty_function___avail" >&5 printf "%s\n" "$mhd_cv_macro___pretty_function___avail" >&6; } if test "x$mhd_cv_macro___pretty_function___avail" = x"yes" then : printf "%s\n" "#define HAVE___PRETTY_FUNCTION__ 1" >>confdefs.h fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether __builtin_bswap32() is available" >&5 printf %s "checking whether __builtin_bswap32() is available... " >&6; } if test ${mhd_cv_func___builtin_bswap32_avail+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { uint32_t a = 1; uint32_t b = __builtin_bswap32(a); a = b; (void) a; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func___builtin_bswap32_avail="yes" else $as_nop mhd_cv_func___builtin_bswap32_avail="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func___builtin_bswap32_avail" >&5 printf "%s\n" "$mhd_cv_func___builtin_bswap32_avail" >&6; } if test "x$mhd_cv_func___builtin_bswap32_avail" = "xyes" then : printf "%s\n" "#define MHD_HAVE___BUILTIN_BSWAP32 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether __builtin_bswap64() is available" >&5 printf %s "checking whether __builtin_bswap64() is available... " >&6; } if test ${mhd_cv_func___builtin_bswap64_avail+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { uint64_t a = 1; uint64_t b = __builtin_bswap64(a); a = b; (void) a; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func___builtin_bswap64_avail="yes" else $as_nop mhd_cv_func___builtin_bswap64_avail="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func___builtin_bswap64_avail" >&5 printf "%s\n" "$mhd_cv_func___builtin_bswap64_avail" >&6; } if test "x$mhd_cv_func___builtin_bswap64_avail" = "xyes" then : printf "%s\n" "#define MHD_HAVE___BUILTIN_BSWAP64 1" >>confdefs.h fi # Extract the first word of "curl", so it can be a program name with args. set dummy curl; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_HAVE_CURL_BINARY+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$HAVE_CURL_BINARY"; then ac_cv_prog_HAVE_CURL_BINARY="$HAVE_CURL_BINARY" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_HAVE_CURL_BINARY="yes" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_HAVE_CURL_BINARY" && ac_cv_prog_HAVE_CURL_BINARY="no" fi fi HAVE_CURL_BINARY=$ac_cv_prog_HAVE_CURL_BINARY if test -n "$HAVE_CURL_BINARY"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $HAVE_CURL_BINARY" >&5 printf "%s\n" "$HAVE_CURL_BINARY" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$HAVE_CURL_BINARY" = "xyes"; then HAVE_CURL_BINARY_TRUE= HAVE_CURL_BINARY_FALSE='#' else HAVE_CURL_BINARY_TRUE='#' HAVE_CURL_BINARY_FALSE= fi # Extract the first word of "makeinfo", so it can be a program name with args. set dummy makeinfo; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_HAVE_MAKEINFO_BINARY+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$HAVE_MAKEINFO_BINARY"; then ac_cv_prog_HAVE_MAKEINFO_BINARY="$HAVE_MAKEINFO_BINARY" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_HAVE_MAKEINFO_BINARY="yes" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_HAVE_MAKEINFO_BINARY" && ac_cv_prog_HAVE_MAKEINFO_BINARY="no" fi fi HAVE_MAKEINFO_BINARY=$ac_cv_prog_HAVE_MAKEINFO_BINARY if test -n "$HAVE_MAKEINFO_BINARY"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $HAVE_MAKEINFO_BINARY" >&5 printf "%s\n" "$HAVE_MAKEINFO_BINARY" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$HAVE_MAKEINFO_BINARY" = "xyes"; then HAVE_MAKEINFO_BINARY_TRUE= HAVE_MAKEINFO_BINARY_FALSE='#' else HAVE_MAKEINFO_BINARY_TRUE='#' HAVE_MAKEINFO_BINARY_FALSE= fi if test "x$os_is_native_w32" = "xyes" && test "x$enable_static" = "xyes"; then W32_STATIC_LIB_TRUE= W32_STATIC_LIB_FALSE='#' else W32_STATIC_LIB_TRUE='#' W32_STATIC_LIB_FALSE= fi # Check whether --enable-doc was given. if test ${enable_doc+y} then : enableval=$enable_doc; else $as_nop enable_doc=yes fi test "x$enable_doc" = "xno" || enable_doc=yes if test "x$enable_doc" = "xyes"; then BUILD_DOC_TRUE= BUILD_DOC_FALSE='#' else BUILD_DOC_TRUE='#' BUILD_DOC_FALSE= fi # Check whether --enable-examples was given. if test ${enable_examples+y} then : enableval=$enable_examples; else $as_nop enable_examples=yes fi test "x$enable_examples" = "xno" || enable_examples=yes if test "x$enable_examples" = "xyes"; then BUILD_EXAMPLES_TRUE= BUILD_EXAMPLES_FALSE='#' else BUILD_EXAMPLES_TRUE='#' BUILD_EXAMPLES_FALSE= fi # Check whether --enable-tools was given. if test ${enable_tools+y} then : enableval=$enable_tools; else $as_nop enable_tools=yes fi test "x$enable_tools" = "xyes" || enable_tools=no if test "x$enable_tools" = "xyes"; then BUILD_TOOLS_TRUE= BUILD_TOOLS_FALSE='#' else BUILD_TOOLS_TRUE='#' BUILD_TOOLS_FALSE= fi # Check whether --enable-heavy-tests was given. if test ${enable_heavy_tests+y} then : enableval=$enable_heavy_tests; else $as_nop enable_heavy_tests=no fi use_heavy_tests="no" use_vheavy_tests="no" use_heavy_tests_MSG="no" case ${enable_heavy_tests} in #( yes|basic) : enable_heavy_tests="basic" use_heavy_tests="yes" use_vheavy_tests="no" use_heavy_tests_MSG="yes, basic heavy tests (a dedicated host is recommended)" ;; #( all|full) : enable_heavy_tests="full" use_heavy_tests="yes" use_vheavy_tests="yes" use_heavy_tests_MSG="yes, full set of heavy tests (a dedicated host is recommended)" ;; #( no) : use_heavy_tests="no" use_vheavy_tests="no" use_heavy_tests_MSG="no" ;; #( *) : as_fn_error $? "Unknown parameter value: --enable-heavy-tests=${enable_heavy_tests}" "$LINENO" 5 ;; esac if test "x$use_heavy_tests" = x"yes" then : HEAVY_TESTS_NOTPARALLEL='.NOTPARALLEL:' printf "%s\n" "#define _MHD_HEAVY_TESTS 1" >>confdefs.h if test "x$use_vheavy_tests" = x"yes" then : printf "%s\n" "#define _MHD_VHEAVY_TESTS 1" >>confdefs.h fi else $as_nop HEAVY_TESTS_NOTPARALLEL=" " fi if test "x$use_heavy_tests" = "xyes"; then HEAVY_TESTS_TRUE= HEAVY_TESTS_FALSE='#' else HEAVY_TESTS_TRUE='#' HEAVY_TESTS_FALSE= fi if test "x$use_vheavy_tests" = "xyes"; then VHEAVY_TESTS_TRUE= VHEAVY_TESTS_FALSE='#' else VHEAVY_TESTS_TRUE='#' VHEAVY_TESTS_FALSE= fi if false; then TESTS_STRESS_OS_TRUE= TESTS_STRESS_OS_FALSE='#' else TESTS_STRESS_OS_TRUE='#' TESTS_STRESS_OS_FALSE= fi # Check whether --enable-poll was given. if test ${enable_poll+y} then : enableval=$enable_poll; enable_poll=${enableval} else $as_nop enable_poll='auto' fi if test "$enable_poll" != "no" then : if test "$os_is_native_w32" != "yes" then : for ac_header in poll.h do : ac_fn_c_check_header_compile "$LINENO" "poll.h" "ac_cv_header_poll_h" "$ac_includes_default " if test "x$ac_cv_header_poll_h" = xyes then : printf "%s\n" "#define HAVE_POLL_H 1" >>confdefs.h # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_poll+y} then : else $as_nop ac_fn_check_decl "$LINENO" "poll" "ac_cv_have_decl_poll" " #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_poll" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function poll" >&5 printf %s "checking for function poll... " >&6; } if test ${mhd_cv_func_poll+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_poll" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { struct pollfd fds[2]; fds[0].fd = 0; fds[0].events = POLLIN; if (0 > poll(fds, 1, 0)) return 2; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_poll="yes" else $as_nop mhd_cv_func_poll="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_poll="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_poll" >&5 printf "%s\n" "$mhd_cv_func_poll" >&6; } if test "x$mhd_cv_func_poll" = x"yes" then : printf "%s\n" "#define HAVE_POLL 1" >>confdefs.h have_poll='yes' else $as_nop have_poll='no' fi # Expansion of MHD_CHECK_FUNC macro ends here fi done else $as_nop # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_WSAPoll+y} then : else $as_nop ac_fn_check_decl "$LINENO" "WSAPoll" "ac_cv_have_decl_WSAPoll" " #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_WSAPoll" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function WSAPoll" >&5 printf %s "checking for function WSAPoll... " >&6; } if test ${mhd_cv_func_WSAPoll+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_WSAPoll" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { WSAPOLLFD fda[2]; WSAPoll(fda, 2, 0); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_WSAPoll="yes" else $as_nop mhd_cv_func_WSAPoll="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_WSAPoll="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_WSAPoll" >&5 printf "%s\n" "$mhd_cv_func_WSAPoll" >&6; } if test "x$mhd_cv_func_WSAPoll" = x"yes" then : printf "%s\n" "#define HAVE_WSAPOLL 1" >>confdefs.h have_poll='yes' printf "%s\n" "#define HAVE_POLL 1" >>confdefs.h else $as_nop have_poll='no' fi # Expansion of MHD_CHECK_FUNC macro ends here fi if test "$enable_poll" = "yes" && test "$have_poll" != "yes" then : as_fn_error $? "Support for poll was explicitly requested but cannot be enabled on this platform." "$LINENO" 5 fi enable_poll="$have_poll" fi # Check whether --enable-epoll was given. if test ${enable_epoll+y} then : enableval=$enable_epoll; enable_epoll=${enableval} else $as_nop enable_epoll='auto' fi if test "$enable_epoll" != "no" then : ax_have_epoll_cppflags="${CPPFLAGS}" ac_fn_c_check_header_compile "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default " if test "x$ac_cv_header_linux_version_h" = xyes then : CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Linux epoll(7) interface" >&5 printf %s "checking for Linux epoll(7) interface... " >&6; } if test ${ax_cv_have_epoll+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_LINUX_VERSION_H # include # if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45) # error linux kernel version is too old to have epoll # endif #endif int main (void) { int fd; struct epoll_event ev; fd = epoll_create(128); epoll_wait(fd, &ev, 1, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ax_cv_have_epoll=yes else $as_nop ax_cv_have_epoll=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi CPPFLAGS="${ax_have_epoll_cppflags}" if test "${ax_cv_have_epoll}" = "yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "${ax_cv_have_epoll}" = "yes" then : printf "%s\n" "#define EPOLL_SUPPORT 1" >>confdefs.h enable_epoll='yes' else $as_nop if test "$enable_epoll" = "yes" then : as_fn_error $? "Support for epoll was explicitly requested but cannot be enabled on this platform." "$LINENO" 5 fi enable_epoll='no' fi fi if test "x$enable_epoll" = xyes; then MHD_HAVE_EPOLL_TRUE= MHD_HAVE_EPOLL_FALSE='#' else MHD_HAVE_EPOLL_TRUE='#' MHD_HAVE_EPOLL_FALSE= fi if test "x$enable_epoll" = "xyes" then : # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_epoll_create1+y} then : else $as_nop ac_fn_check_decl "$LINENO" "epoll_create1" "ac_cv_have_decl_epoll_create1" " #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_epoll_create1" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function epoll_create1" >&5 printf %s "checking for function epoll_create1... " >&6; } if test ${mhd_cv_func_epoll_create1+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_epoll_create1" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { if (0 > epoll_create1(EPOLL_CLOEXEC)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_epoll_create1="yes" else $as_nop mhd_cv_func_epoll_create1="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_epoll_create1="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_epoll_create1" >&5 printf "%s\n" "$mhd_cv_func_epoll_create1" >&6; } if test "x$mhd_cv_func_epoll_create1" = x"yes" then : printf "%s\n" "#define HAVE_EPOLL_CREATE1 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for supported 'noreturn' keyword" >&5 printf %s "checking for supported 'noreturn' keyword... " >&6; } if test ${mhd_cv_decl_noreturn+y} then : printf %s "(cached) " >&6 else $as_nop mhd_cv_decl_noreturn="none" CFLAGS="${CFLAGS_ac} ${user_CFLAGS} ${errattr_CFLAGS}" for decl_noret in '_Noreturn' '__attribute__((__noreturn__))' '__declspec(noreturn)' do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_STDLIB_H #include #endif ${decl_noret} static void myexitfunc(int code) { #ifdef HAVE_STDLIB_H exit (code); #else (void)code; #endif } int main (int argc, char *const *argv) { (void) argv; if (argc > 2) myexitfunc (2); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_decl_noreturn="${decl_noret}" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test "x${mhd_cv_decl_noreturn}" != "xnone" then : break fi done CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_decl_noreturn" >&5 printf "%s\n" "$mhd_cv_decl_noreturn" >&6; } if test "x$mhd_cv_decl_noreturn" = x"none" then : printf "%s\n" "#define _MHD_NORETURN /**/" >>confdefs.h else $as_nop printf "%s\n" "#define _MHD_NORETURN ${mhd_cv_decl_noreturn}" >>confdefs.h fi # Check for types sizes # Types sizes are used as an indirect indication of maximum allowed values for types # which is used to exclude by preprocessor some compiler checks for values clips # Assuming no staffing or uniform staffing for integer types { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of tv_sec member of struct timeval" >&5 printf %s "checking size of tv_sec member of struct timeval... " >&6; } if test ${mhd_cv_size_timeval_tv_sec+y} then : printf %s "(cached) " >&6 else $as_nop if ac_fn_c_compute_int "$LINENO" "((long int)sizeof(test_var.tv_sec))" "mhd_cv_size_timeval_tv_sec" " #ifdef HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ #if HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ static struct timeval test_var; " then : else $as_nop # The size is used only to exclude additional checks/comparison in code # to avoid compiler warnings. With larger size MHD code will use # additional checks which ensure that value will fit but it may produce # a harmless compiler warning. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: The size cannot be determined, assuming 8." >&5 printf "%s\n" "$as_me: WARNING: The size cannot be determined, assuming 8." >&2;} mhd_cv_size_timeval_tv_sec=8 fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_size_timeval_tv_sec" >&5 printf "%s\n" "$mhd_cv_size_timeval_tv_sec" >&6; } printf "%s\n" "#define SIZEOF_STRUCT_TIMEVAL_TV_SEC $mhd_cv_size_timeval_tv_sec" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of int64_t" >&5 printf %s "checking size of int64_t... " >&6; } if test ${ac_cv_sizeof_int64_t+y} then : printf %s "(cached) " >&6 else $as_nop if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int64_t))" "ac_cv_sizeof_int64_t" "#include " then : else $as_nop if test "$ac_cv_type_int64_t" = yes; then { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int64_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int64_t=0 fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int64_t" >&5 printf "%s\n" "$ac_cv_sizeof_int64_t" >&6; } printf "%s\n" "#define SIZEOF_INT64_T $ac_cv_sizeof_int64_t" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of uint64_t" >&5 printf %s "checking size of uint64_t... " >&6; } if test ${ac_cv_sizeof_uint64_t+y} then : printf %s "(cached) " >&6 else $as_nop if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (uint64_t))" "ac_cv_sizeof_uint64_t" "#include " then : else $as_nop if test "$ac_cv_type_uint64_t" = yes; then { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (uint64_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_uint64_t=0 fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_uint64_t" >&5 printf "%s\n" "$ac_cv_sizeof_uint64_t" >&6; } printf "%s\n" "#define SIZEOF_UINT64_T $ac_cv_sizeof_uint64_t" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 printf %s "checking size of int... " >&6; } if test ${ac_cv_sizeof_int+y} then : printf %s "(cached) " >&6 else $as_nop if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "#include " then : else $as_nop if test "$ac_cv_type_int" = yes; then { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int=0 fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 printf "%s\n" "$ac_cv_sizeof_int" >&6; } printf "%s\n" "#define SIZEOF_INT $ac_cv_sizeof_int" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of unsigned int" >&5 printf %s "checking size of unsigned int... " >&6; } if test ${ac_cv_sizeof_unsigned_int+y} then : printf %s "(cached) " >&6 else $as_nop if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned int))" "ac_cv_sizeof_unsigned_int" "#include " then : else $as_nop if test "$ac_cv_type_unsigned_int" = yes; then { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (unsigned int) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_unsigned_int=0 fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_int" >&5 printf "%s\n" "$ac_cv_sizeof_unsigned_int" >&6; } printf "%s\n" "#define SIZEOF_UNSIGNED_INT $ac_cv_sizeof_unsigned_int" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of unsigned long long" >&5 printf %s "checking size of unsigned long long... " >&6; } if test ${ac_cv_sizeof_unsigned_long_long+y} then : printf %s "(cached) " >&6 else $as_nop if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned long long))" "ac_cv_sizeof_unsigned_long_long" "#include " then : else $as_nop if test "$ac_cv_type_unsigned_long_long" = yes; then { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (unsigned long long) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_unsigned_long_long=0 fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_long_long" >&5 printf "%s\n" "$ac_cv_sizeof_unsigned_long_long" >&6; } printf "%s\n" "#define SIZEOF_UNSIGNED_LONG_LONG $ac_cv_sizeof_unsigned_long_long" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5 printf %s "checking size of size_t... " >&6; } if test ${ac_cv_sizeof_size_t+y} then : printf %s "(cached) " >&6 else $as_nop if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" " #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #include " then : else $as_nop if test "$ac_cv_type_size_t" = yes; then { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (size_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_size_t=0 fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5 printf "%s\n" "$ac_cv_sizeof_size_t" >&6; } printf "%s\n" "#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t" >>confdefs.h for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes then : printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h have_tlsplugin=yes else $as_nop have_tlsplugin=no fi done if test "x$have_tlsplugin" = xyes; then MHD_HAVE_TLS_PLUGIN_TRUE= MHD_HAVE_TLS_PLUGIN_FALSE='#' else MHD_HAVE_TLS_PLUGIN_TRUE='#' MHD_HAVE_TLS_PLUGIN_FALSE= fi for ac_header in zlib.h do : ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default " if test "x$ac_cv_header_zlib_h" = xyes then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h have_zlib=yes else $as_nop have_zlib=no fi done if test "x$have_zlib" = xyes; then HAVE_ZLIB_TRUE= HAVE_ZLIB_FALSE='#' else HAVE_ZLIB_TRUE='#' HAVE_ZLIB_FALSE= fi # Check for generic functions # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_random+y} then : else $as_nop ac_fn_check_decl "$LINENO" "random" "ac_cv_have_decl_random" " $ac_includes_default #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_random" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function random" >&5 printf %s "checking for function random... " >&6; } if test ${mhd_cv_func_random+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_random" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #include int main(void) { long int r = random(); (void)r; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_random="yes" else $as_nop mhd_cv_func_random="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_random="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_random" >&5 printf "%s\n" "$mhd_cv_func_random" >&6; } if test "x$mhd_cv_func_random" = x"yes" then : printf "%s\n" "#define HAVE_RANDOM 1" >>confdefs.h else $as_nop # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_rand+y} then : else $as_nop ac_fn_check_decl "$LINENO" "rand" "ac_cv_have_decl_rand" " $ac_includes_default #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_rand" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function rand" >&5 printf %s "checking for function rand... " >&6; } if test ${mhd_cv_func_rand+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_rand" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #include int main(void) { int r = rand(); (void)r; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_rand="yes" else $as_nop mhd_cv_func_rand="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_rand="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_rand" >&5 printf "%s\n" "$mhd_cv_func_rand" >&6; } if test "x$mhd_cv_func_rand" = x"yes" then : printf "%s\n" "#define HAVE_RAND 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here fi # Expansion of MHD_CHECK_FUNC macro ends here ac_fn_c_check_member "$LINENO" "struct sockaddr" "sa_len" "ac_cv_member_struct_sockaddr_sa_len" " #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif " if test "x$ac_cv_member_struct_sockaddr_sa_len" = xyes then : printf "%s\n" "#define HAVE_STRUCT_SOCKADDR_SA_LEN 1" >>confdefs.h fi ac_fn_c_check_member "$LINENO" "struct sockaddr_storage" "ss_len" "ac_cv_member_struct_sockaddr_storage_ss_len" " #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif " if test "x$ac_cv_member_struct_sockaddr_storage_ss_len" = xyes then : printf "%s\n" "#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1" >>confdefs.h fi ac_fn_c_check_member "$LINENO" "struct sockaddr_in" "sin_len" "ac_cv_member_struct_sockaddr_in_sin_len" " #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif " if test "x$ac_cv_member_struct_sockaddr_in_sin_len" = xyes then : printf "%s\n" "#define HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1" >>confdefs.h fi ac_fn_c_check_member "$LINENO" "struct sockaddr_in6" "sin6_len" "ac_cv_member_struct_sockaddr_in6_sin6_len" " #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif " if test "x$ac_cv_member_struct_sockaddr_in6_sin6_len" = xyes then : printf "%s\n" "#define HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working getsockname()" >&5 printf %s "checking for working getsockname()... " >&6; } if test ${mhd_cv_getsockname_usable+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NETINET_IP_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif static void zr_mem(void *ptr, socklen_t size) { char *mem = ptr; while(size--) {mem[0] = 0; mem++;} } int main(void) { const socklen_t c_addr_size = (socklen_t)sizeof(struct sockaddr_in); struct sockaddr_in sa; socklen_t addr_size; int ret = 1; #if !defined(_WIN32) || defined(__CYGWIN__) int sckt; const int invld_sckt = -1; #else SOCKET sckt; const SOCKET invld_sckt = INVALID_SOCKET; WSADATA wsa_data; if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data) || MAKEWORD(2, 2) != wsa_data.wVersion) return 20; #endif sckt = socket (PF_INET, SOCK_STREAM, 0); if (invld_sckt != sckt) { zr_mem(&sa, c_addr_size); sa.sin_family = AF_INET; #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sa.sin_len = c_addr_size; #endif if (0 == bind (sckt, (struct sockaddr *)&sa, c_addr_size)) { if (0 == listen (sckt, 1)) { addr_size = c_addr_size; if (0 == getsockname (sckt, (struct sockaddr *)&sa, &addr_size)) { if (c_addr_size >= addr_size) { if (0 != ntohs(sa.sin_port)) { ret = 0; } else ret = 7; } else ret = 6; } else ret = 5; } else ret = 4; } else ret = 3; } else ret = 2; #if !defined(_WIN32) || defined(__CYGWIN__) close (sckt); #else closesocket (sckt); WSACleanup(); #endif return ret; } _ACEOF if test "x$cross_compiling" = x"yes" then : if ac_fn_c_try_link "$LINENO" then : mhd_cv_getsockname_usable='assuming yes' else $as_nop mhd_cv_getsockname_usable='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext else $as_nop if test "$cross_compiling" = yes then : # Dummy placeholder else $as_nop if ac_fn_c_try_run "$LINENO" then : mhd_cv_getsockname_usable='yes' else $as_nop mhd_cv_getsockname_usable='no' fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam fi fi rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_getsockname_usable" >&5 printf "%s\n" "$mhd_cv_getsockname_usable" >&6; } if test "x$mhd_cv_getsockname_usable" = "xyes" || test "x$mhd_cv_getsockname_usable" = "xassuming yes" then : printf "%s\n" "#define MHD_USE_GETSOCKNAME 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for usable PAGESIZE macro" >&5 printf %s "checking for usable PAGESIZE macro... " >&6; } if test ${mhd_cv_macro_pagesize_usable+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifndef PAGESIZE #error No PAGESIZE macro defined choke me now #endif int main (void) { long pgsz = PAGESIZE + 0; if (1 > pgsz) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_macro_pagesize_usable="yes" else $as_nop mhd_cv_macro_pagesize_usable="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_pagesize_usable" >&5 printf "%s\n" "$mhd_cv_macro_pagesize_usable" >&6; } if test "x$mhd_cv_macro_pagesize_usable" = x"yes" then : printf "%s\n" "#define MHD_USE_PAGESIZE_MACRO 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether PAGESIZE macro could be used for static init" >&5 printf %s "checking whether PAGESIZE macro could be used for static init... " >&6; } if test ${mhd_cv_macro_pagesize_usable_static+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifndef PAGESIZE #error No PAGESIZE macro defined choke me now #endif static long ac_pgsz = PAGESIZE + 0; int main (void) { if (1 > ac_pgsz) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_macro_pagesize_usable_static="yes" else $as_nop mhd_cv_macro_pagesize_usable_static="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_pagesize_usable_static" >&5 printf "%s\n" "$mhd_cv_macro_pagesize_usable_static" >&6; } if test "x$mhd_cv_macro_pagesize_usable_static" = x"yes" then : printf "%s\n" "#define MHD_USE_PAGESIZE_MACRO_STATIC 1" >>confdefs.h fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for usable PAGE_SIZE macro" >&5 printf %s "checking for usable PAGE_SIZE macro... " >&6; } if test ${mhd_cv_macro_page_size_usable+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifndef PAGE_SIZE #error No PAGE_SIZE macro defined choke me now #endif int main (void) { long pgsz = PAGE_SIZE + 0; if (1 > pgsz) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_macro_page_size_usable="yes" else $as_nop mhd_cv_macro_page_size_usable="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_page_size_usable" >&5 printf "%s\n" "$mhd_cv_macro_page_size_usable" >&6; } if test "x$mhd_cv_macro_page_size_usable" = x"yes" then : printf "%s\n" "#define MHD_USE_PAGE_SIZE_MACRO 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether PAGE_SIZE macro could be used for static init" >&5 printf %s "checking whether PAGE_SIZE macro could be used for static init... " >&6; } if test ${mhd_cv_macro_page_size_usable_static+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifndef PAGE_SIZE #error No PAGE_SIZE macro defined choke me now #endif static long ac_pgsz = PAGE_SIZE + 0; int main (void) { if (1 > ac_pgsz) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_macro_page_size_usable_static="yes" else $as_nop mhd_cv_macro_page_size_usable_static="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_page_size_usable_static" >&5 printf "%s\n" "$mhd_cv_macro_page_size_usable_static" >&6; } if test "x$mhd_cv_macro_page_size_usable_static" = x"yes" then : printf "%s\n" "#define MHD_USE_PAGE_SIZE_MACRO_STATIC 1" >>confdefs.h fi fi fi # Check for inter-thread signaling type # Check whether --enable-itc was given. if test ${enable_itc+y} then : enableval=$enable_itc; else $as_nop enable_itc='auto' fi case $enable_itc in #( pipe) : : ;; #( socketpair) : : ;; #( eventfd) : : ;; #( auto) : if test "x$os_is_windows" = x"yes" then : enable_itc='socketpair' fi ;; #( eventFD) : enable_itc='eventfd' ;; #( socket) : enable_itc='socketpair' ;; #( no) : as_fn_error $? "inter-thread communication cannot be disabled" "$LINENO" 5 ;; #( *) : as_fn_error $? "unrecognized type \"$enable_itc\" of inter-thread communication specified by \"--enable-itc=$enable_itc\"" "$LINENO" 5 ;; esac { use_itc=; unset use_itc;} if test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working eventfd(2)" >&5 printf %s "checking for working eventfd(2)... " >&6; } if test ${mhd_cv_eventfd_usable+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { unsigned char buf[8]; int ret; int efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); if (0 > efd) return 2; ret = 0; buf[3] = 1; if (8 != write(efd, buf, 8)) ret = 3; else { if (8 != read(efd, buf, 8)) ret = 4; } close(efd); return ret; } _ACEOF if test "x$cross_compiling" = x"yes" then : if ac_fn_c_try_link "$LINENO" then : mhd_cv_eventfd_usable='assuming no' else $as_nop mhd_cv_eventfd_usable='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext else $as_nop if test "$cross_compiling" = yes then : # Dummy placeholder else $as_nop if ac_fn_c_try_run "$LINENO" then : mhd_cv_eventfd_usable='yes' else $as_nop mhd_cv_eventfd_usable='no' fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam fi fi rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_eventfd_usable" >&5 printf "%s\n" "$mhd_cv_eventfd_usable" >&6; } if test "x$mhd_cv_eventfd_usable" = "xyes" || test "x$mhd_cv_eventfd_usable" = "xassuming yes" then : use_itc='eventfd' enable_itc="$use_itc" printf "%s\n" "#define _MHD_ITC_EVENTFD 1" >>confdefs.h fi if test "x$mhd_cv_eventfd_usable" = "xno" || test "x$mhd_cv_eventfd_usable" = "xassuming no" then : if test "x$enable_itc" = x"eventfd" then : as_fn_error $? "eventfd(2) is not usable, consider using other type of inter-thread communication" "$LINENO" 5 fi fi if test "x$mhd_cv_eventfd_usable" = x"assuming no" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: if you have 'eventfd' support enabled on your target system consider overriding test result by \"mhd_cv_eventfd_usable=yes\" configure parameter" >&5 printf "%s\n" "$as_me: WARNING: if you have 'eventfd' support enabled on your target system consider overriding test result by \"mhd_cv_eventfd_usable=yes\" configure parameter" >&2;} fi fi if test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto" then : if test "x$os_is_native_w32" = x"yes" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pipe(3) is usable" >&5 printf %s "checking whether pipe(3) is usable... " >&6; } if test ${mhd_cv_pipe_usable+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #ifdef HAVE_UNISTD_H #include #endif int main (void) { int arr[2]; int res; res = pipe(arr); if (res != 0) return 33; close (arr[0]); close (arr[1]); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_pipe_usable='yes' else $as_nop mhd_cv_pipe_usable='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_pipe_usable" >&5 printf "%s\n" "$mhd_cv_pipe_usable" >&6; } if test "x$mhd_cv_pipe_usable" = x"yes" then : use_itc='pipe' enable_itc="$use_itc" printf "%s\n" "#define _MHD_ITC_PIPE 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pipe2(2) is usable" >&5 printf %s "checking whether pipe2(2) is usable... " >&6; } if test ${mhd_cv_pipe2_usable+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_UNISTD_H #include #endif int main (void) { int arr[2]; int res; res = pipe2(arr, O_CLOEXEC | O_NONBLOCK); if (res != 0) return 33; close (arr[0]); close (arr[1]); ; return 0; } _ACEOF if test "x$cross_compiling" = x"yes" then : if ac_fn_c_try_link "$LINENO" then : # Cross-compiling case ${host_os} in #( kfreebsd*-gnu) : mhd_cv_pipe2_usable='assuming no' ;; #( *) : mhd_cv_pipe2_usable='assuming yes' ;; esac else $as_nop mhd_cv_pipe2_usable='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext else $as_nop if test "$cross_compiling" = yes then : # Dummy placeholder else $as_nop if ac_fn_c_try_run "$LINENO" then : mhd_cv_pipe2_usable='yes' else $as_nop mhd_cv_pipe2_usable='no' fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam fi fi rm -f conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_pipe2_usable" >&5 printf "%s\n" "$mhd_cv_pipe2_usable" >&6; } if test "x$mhd_cv_pipe2_usable" = "xyes" || test "x$mhd_cv_pipe2_usable" = "xassuming yes" then : printf "%s\n" "#define HAVE_PIPE2_FUNC 1" >>confdefs.h fi else $as_nop if test "x$enable_itc" = x"pipe" then : as_fn_error $? "pipe(3) is not usable, consider using other type of inter-thread communication" "$LINENO" 5 fi fi fi fi if test "x$enable_itc" = "xsocketpair" || test "x$enable_itc" = "xauto" then : if test "x$os_is_native_w32" = x"yes" then : mhd_cv_socketpair_usable='yes' else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether socketpair(3) is usable" >&5 printf %s "checking whether socketpair(3) is usable... " >&6; } if test ${mhd_cv_socketpair_usable+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif int main (void) { int arr[2]; int res; #if defined(AF_LOCAL) res = socketpair(AF_LOCAL, SOCK_STREAM, 0, arr); #elif defined(AF_UNIX) res = socketpair(AF_UNIX, SOCK_STREAM, 0, arr); #else #error AF_LOCAL and AF_UNIX are both undefined choke me now; #endif if (res != 0) return 1 ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_socketpair_usable='yes' else $as_nop mhd_cv_socketpair_usable='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_socketpair_usable" >&5 printf "%s\n" "$mhd_cv_socketpair_usable" >&6; } fi if test "x$mhd_cv_socketpair_usable" = x"yes" then : use_itc='socketpair' enable_itc="$use_itc" printf "%s\n" "#define _MHD_ITC_SOCKETPAIR 1" >>confdefs.h else $as_nop if test "x$enable_itc" = x"socketpair" then : as_fn_error $? "socketpair(3) is not usable, consider using other type of inter-thread communication" "$LINENO" 5 fi fi fi if test -z "$use_itc" then : as_fn_error $? "cannot find usable type of inter-thread communication" "$LINENO" 5 fi # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_accept4+y} then : else $as_nop ac_fn_check_decl "$LINENO" "accept4" "ac_cv_have_decl_accept4" " #if defined(HAVE_SYS_TYPES_H) # include #endif #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_accept4" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function accept4" >&5 printf %s "checking for function accept4... " >&6; } if test ${mhd_cv_func_accept4+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_accept4" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined(HAVE_SYS_TYPES_H) # include #endif #include int main(void) { struct sockaddr sk_addr; socklen_t addr_size; if (0 > accept4(0, &sk_addr, &addr_size, 0)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_accept4="yes" else $as_nop mhd_cv_func_accept4="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_accept4="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_accept4" >&5 printf "%s\n" "$mhd_cv_func_accept4" >&6; } if test "x$mhd_cv_func_accept4" = x"yes" then : printf "%s\n" "#define HAVE_ACCEPT4 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_gmtime_r+y} then : else $as_nop ac_fn_check_decl "$LINENO" "gmtime_r" "ac_cv_have_decl_gmtime_r" " #if defined(HAVE_SYS_TYPES_H) # include #endif #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_gmtime_r" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function gmtime_r" >&5 printf %s "checking for function gmtime_r... " >&6; } if test ${mhd_cv_func_gmtime_r+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_gmtime_r" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined(HAVE_SYS_TYPES_H) # include #endif #include int main(void) { time_t timer = (time_t) 0; struct tm res; if (&res != gmtime_r(&timer, &res)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_gmtime_r="yes" else $as_nop mhd_cv_func_gmtime_r="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_gmtime_r="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_gmtime_r" >&5 printf "%s\n" "$mhd_cv_func_gmtime_r" >&6; } if test "x$mhd_cv_func_gmtime_r" = x"yes" then : printf "%s\n" "#define HAVE_GMTIME_R 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_memmem+y} then : else $as_nop ac_fn_check_decl "$LINENO" "memmem" "ac_cv_have_decl_memmem" " #if defined(HAVE_STDDEF_H) # include #elif defined(HAVE_STDLIB_H) # include #endif /* HAVE_STDLIB_H */ #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_memmem" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function memmem" >&5 printf %s "checking for function memmem... " >&6; } if test ${mhd_cv_func_memmem+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_memmem" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined(HAVE_STDDEF_H) # include #elif defined(HAVE_STDLIB_H) # include #endif /* HAVE_STDLIB_H */ #include int main(void) { const char *haystack = "abc"; size_t hslen = 3; const char *needle = "b"; size_t needlelen = 1; if ((haystack + 1) != memmem(haystack, hslen, needle, needlelen)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_memmem="yes" else $as_nop mhd_cv_func_memmem="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_memmem="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_memmem" >&5 printf "%s\n" "$mhd_cv_func_memmem" >&6; } if test "x$mhd_cv_func_memmem" = x"yes" then : printf "%s\n" "#define HAVE_MEMMEM 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_snprintf+y} then : else $as_nop ac_fn_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" " #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_snprintf" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function snprintf" >&5 printf %s "checking for function snprintf... " >&6; } if test ${mhd_cv_func_snprintf+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_snprintf" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { char buf[2]; if (1 != snprintf(buf, 2, "a")) return 3; /* Do not use the next check to avoid compiler warning */ /* if (4 != snprintf(buf, 2, "abcd")) return 4; */ return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_snprintf="yes" else $as_nop mhd_cv_func_snprintf="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_snprintf="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_snprintf" >&5 printf "%s\n" "$mhd_cv_func_snprintf" >&6; } if test "x$mhd_cv_func_snprintf" = x"yes" then : printf "%s\n" "#define HAVE_SNPRINTF 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here ac_fn_check_decl "$LINENO" "gmtime_s" "ac_cv_have_decl_gmtime_s" "#define __STDC_WANT_LIB_EXT1__ 1 #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_gmtime_s" = xyes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether gmtime_s is in C11 form" >&5 printf %s "checking whether gmtime_s is in C11 form... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define __STDC_WANT_LIB_EXT1__ 1 #include #ifdef __cplusplus extern "C" #endif struct tm* gmtime_s(const time_t* time, struct tm* result); int main (void) { static struct tm res; static time_t t = 0; gmtime_s (&t, &res); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_C11_GMTIME_S 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether gmtime_s is in W32 form" >&5 printf %s "checking whether gmtime_s is in W32 form... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef __cplusplus extern "C" #endif errno_t gmtime_s(struct tm* _tm, const time_t* time); int main (void) { static struct tm res; static time_t t = 0; gmtime_s (&res, &t); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_W32_GMTIME_S 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi ac_fn_check_decl "$LINENO" "SOCK_NONBLOCK" "ac_cv_have_decl_SOCK_NONBLOCK" " #if defined(HAVE_SYS_TYPES_H) # include #endif #if defined(HAVE_SYS_SOCKET_H) # include #elif defined(HAVE_WINSOCK2_H) # include #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_SOCK_NONBLOCK" = xyes then : printf "%s\n" "#define HAVE_SOCK_NONBLOCK 1" >>confdefs.h fi # Expansion of MHD_FIND_LIB macro starts here if test ${mhd_cv_find_lib_clock_gettime+y} then : else $as_nop ac_fn_check_decl "$LINENO" "clock_gettime" "ac_cv_have_decl_clock_gettime" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_clock_gettime" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing function clock_gettime" >&5 printf %s "checking for library containing function clock_gettime... " >&6; } if test ${mhd_cv_find_lib_clock_gettime+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_clock_gettime" = x"yes" then : mhd_find_lib_SAVE_LIBS="$LIBS" mhd_find_lib_CHECK_LIBS="$MHD_LIBDEPS $LIBS" # Reuse the same source file cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { struct timespec tp; if (0 > clock_gettime(CLOCK_REALTIME, &tp)) return 3; return 0; } _ACEOF for mhd_find_lib_LIB in '' rt do if test -z "${mhd_find_lib_LIB}" then : LIBS="${mhd_find_lib_CHECK_LIBS}" else $as_nop LIBS="-l${mhd_find_lib_LIB} ${mhd_find_lib_CHECK_LIBS}" fi if ac_fn_c_try_link "$LINENO" then : if test -z "${mhd_find_lib_LIB}" then : mhd_cv_find_lib_clock_gettime="none required" else $as_nop mhd_cv_find_lib_clock_gettime="-l${mhd_find_lib_LIB}" fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${mhd_cv_find_lib_clock_gettime+y} then : break fi done { mhd_find_lib_LIB=; unset mhd_find_lib_LIB;} rm -f conftest.$ac_ext LIBS="${mhd_find_lib_SAVE_LIBS}" { mhd_find_lib_SAVE_LIBS=; unset mhd_find_lib_SAVE_LIBS;} fi if test ${mhd_cv_find_lib_clock_gettime+y} then : : else $as_nop mhd_cv_find_lib_clock_gettime="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_find_lib_clock_gettime" >&5 printf "%s\n" "$mhd_cv_find_lib_clock_gettime" >&6; } if test "x${mhd_cv_find_lib_clock_gettime}" != "xno" then : if test "x$mhd_cv_find_lib_clock_gettime" = x"none required" then : : else $as_nop if test -z "$MHD_LIBDEPS" then : MHD_LIBDEPS="${mhd_cv_find_lib_clock_gettime}" else $as_nop MHD_LIBDEPS="${mhd_cv_find_lib_clock_gettime} $MHD_LIBDEPS" fi fi printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h if test "x$mhd_cv_find_lib_clock_gettime" = x"none required" then : else $as_nop MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_clock_gettime} $MHD_LIBDEPS_PKGCFG" fi fi # Expansion of _MHD_FIND_LIB_BODY macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_clock_get_time+y} then : else $as_nop ac_fn_check_decl "$LINENO" "clock_get_time" "ac_cv_have_decl_clock_get_time" " #include #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_clock_get_time" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function clock_get_time" >&5 printf %s "checking for function clock_get_time... " >&6; } if test ${mhd_cv_func_clock_get_time+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_clock_get_time" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { clock_serv_t cs; mach_timespec_t mt; host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs); clock_get_time(cs, &mt); mach_port_deallocate(mach_task_self(), cs); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_clock_get_time="yes" else $as_nop mhd_cv_func_clock_get_time="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_clock_get_time="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_clock_get_time" >&5 printf "%s\n" "$mhd_cv_func_clock_get_time" >&6; } if test "x$mhd_cv_func_clock_get_time" = x"yes" then : printf "%s\n" "#define HAVE_CLOCK_GET_TIME 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_gethrtime+y} then : else $as_nop ac_fn_check_decl "$LINENO" "gethrtime" "ac_cv_have_decl_gethrtime" " #ifdef HAVE_SYS_TIME_H /* Solaris define gethrtime() in sys/time.h */ #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H /* HP-UX define gethrtime() in time.h */ #include #endif /* HAVE_TIME_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_gethrtime" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function gethrtime" >&5 printf %s "checking for function gethrtime... " >&6; } if test ${mhd_cv_func_gethrtime+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_gethrtime" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TIME_H /* Solaris define gethrtime() in sys/time.h */ #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H /* HP-UX define gethrtime() in time.h */ #include #endif /* HAVE_TIME_H */ int main(void) { hrtime_t hrt = gethrtime(); if (0 == hrt) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_gethrtime="yes" else $as_nop mhd_cv_func_gethrtime="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_gethrtime="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_gethrtime" >&5 printf "%s\n" "$mhd_cv_func_gethrtime" >&6; } if test "x$mhd_cv_func_gethrtime" = x"yes" then : printf "%s\n" "#define HAVE_GETHRTIME 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here if test "x$ac_cv_header_time_h" = x"yes" then : # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_timespec_get+y} then : else $as_nop ac_fn_check_decl "$LINENO" "timespec_get" "ac_cv_have_decl_timespec_get" " #include #ifndef TIME_UTC #error TIME_UTC must be defined to use timespec_get() choke me now #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_timespec_get" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function timespec_get" >&5 printf %s "checking for function timespec_get... " >&6; } if test ${mhd_cv_func_timespec_get+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_timespec_get" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef TIME_UTC #error TIME_UTC must be defined to use timespec_get() choke me now #endif int main(void) { struct timespec ts; if (TIME_UTC != timespec_get (&ts, TIME_UTC)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_timespec_get="yes" else $as_nop mhd_cv_func_timespec_get="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_timespec_get="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_timespec_get" >&5 printf "%s\n" "$mhd_cv_func_timespec_get" >&6; } if test "x$mhd_cv_func_timespec_get" = x"yes" then : printf "%s\n" "#define HAVE_TIMESPEC_GET 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here fi ac_fn_c_check_header_compile "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" if test "x$ac_cv_header_sys_time_h" = xyes then : printf "%s\n" "#define HAVE_SYS_TIME_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default" if test "x$ac_cv_header_time_h" = xyes then : printf "%s\n" "#define HAVE_TIME_H 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_gettimeofday+y} then : else $as_nop ac_fn_check_decl "$LINENO" "gettimeofday" "ac_cv_have_decl_gettimeofday" " #ifdef HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_gettimeofday" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function gettimeofday" >&5 printf %s "checking for function gettimeofday... " >&6; } if test ${mhd_cv_func_gettimeofday+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_gettimeofday" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ int main(void) { struct timeval tv; if (0 != gettimeofday (&tv, (void*) 0)) return 1; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_gettimeofday="yes" else $as_nop mhd_cv_func_gettimeofday="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_gettimeofday="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_gettimeofday" >&5 printf "%s\n" "$mhd_cv_func_gettimeofday" >&6; } if test "x$mhd_cv_func_gettimeofday" = x"yes" then : printf "%s\n" "#define HAVE_GETTIMEOFDAY 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # IPv6 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for IPv6" >&5 printf %s "checking for IPv6... " >&6; } if test ${mhd_cv_have_inet6+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif int main (void) { int af=AF_INET6; int pf=PF_INET6; struct sockaddr_in6 sa; printf("%d %d %p\n", af, pf, (void*) &sa); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_have_inet6="yes" else $as_nop mhd_cv_have_inet6="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_have_inet6" >&5 printf "%s\n" "$mhd_cv_have_inet6" >&6; } if test "x$mhd_cv_have_inet6" = x"yes" then : printf "%s\n" "#define HAVE_INET6 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_sysconf+y} then : else $as_nop ac_fn_check_decl "$LINENO" "sysconf" "ac_cv_have_decl_sysconf" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_sysconf" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function sysconf" >&5 printf %s "checking for function sysconf... " >&6; } if test ${mhd_cv_func_sysconf+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_sysconf" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { long a = sysconf(0); if (a) return 1; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_sysconf="yes" else $as_nop mhd_cv_func_sysconf="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_sysconf="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_sysconf" >&5 printf "%s\n" "$mhd_cv_func_sysconf" >&6; } if test "x$mhd_cv_func_sysconf" = x"yes" then : printf "%s\n" "#define HAVE_SYSCONF 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_sysctl+y} then : else $as_nop ac_fn_check_decl "$LINENO" "sysctl" "ac_cv_have_decl_sysctl" " #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #if defined(HAVE_STDDEF_H) #include #elif defined(HAVE_STDLIB_H) #include #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_sysctl" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function sysctl" >&5 printf %s "checking for function sysctl... " >&6; } if test ${mhd_cv_func_sysctl+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_sysctl" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #if defined(HAVE_STDDEF_H) #include #elif defined(HAVE_STDLIB_H) #include #endif int main(void) { int mib[2] = {0, 0}; /* Avoid any platform-specific values */ if (sysctl(mib, 2, NULL, NULL, NULL, 0)) return 1; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_sysctl="yes" else $as_nop mhd_cv_func_sysctl="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_sysctl="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_sysctl" >&5 printf "%s\n" "$mhd_cv_func_sysctl" >&6; } if test "x$mhd_cv_func_sysctl" = x"yes" then : printf "%s\n" "#define HAVE_SYSCTL 1" >>confdefs.h ac_fn_check_decl "$LINENO" "CTL_NET" "ac_cv_have_decl_CTL_NET" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ #ifdef HAVE_NETINET_ICMP_VAR_H #include #endif /* HAVE_NETINET_ICMP_VAR_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_CTL_NET" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_CTL_NET $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "PF_INET" "ac_cv_have_decl_PF_INET" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ #ifdef HAVE_NETINET_ICMP_VAR_H #include #endif /* HAVE_NETINET_ICMP_VAR_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_PF_INET" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_PF_INET $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "IPPROTO_ICMP" "ac_cv_have_decl_IPPROTO_ICMP" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ #ifdef HAVE_NETINET_ICMP_VAR_H #include #endif /* HAVE_NETINET_ICMP_VAR_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_IPPROTO_ICMP" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_IPPROTO_ICMP $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "ICMPCTL_ICMPLIM" "ac_cv_have_decl_ICMPCTL_ICMPLIM" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ #ifdef HAVE_NETINET_ICMP_VAR_H #include #endif /* HAVE_NETINET_ICMP_VAR_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_ICMPCTL_ICMPLIM" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_ICMPCTL_ICMPLIM $ac_have_decl" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_sysctlbyname+y} then : else $as_nop ac_fn_check_decl "$LINENO" "sysctlbyname" "ac_cv_have_decl_sysctlbyname" " #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #if defined(HAVE_STDDEF_H) #include #elif defined(HAVE_STDLIB_H) #include #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_sysctlbyname" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function sysctlbyname" >&5 printf %s "checking for function sysctlbyname... " >&6; } if test ${mhd_cv_func_sysctlbyname+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_sysctlbyname" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #if defined(HAVE_STDDEF_H) #include #elif defined(HAVE_STDLIB_H) #include #endif int main(void) { sysctlbyname("test", NULL, NULL, NULL, 0); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_sysctlbyname="yes" else $as_nop mhd_cv_func_sysctlbyname="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_sysctlbyname="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_sysctlbyname" >&5 printf "%s\n" "$mhd_cv_func_sysctlbyname" >&6; } if test "x$mhd_cv_func_sysctlbyname" = x"yes" then : printf "%s\n" "#define HAVE_SYSCTLBYNAME 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_usleep+y} then : else $as_nop ac_fn_check_decl "$LINENO" "usleep" "ac_cv_have_decl_usleep" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_usleep" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function usleep" >&5 printf %s "checking for function usleep... " >&6; } if test ${mhd_cv_func_usleep+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_usleep" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { usleep(100000); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_usleep="yes" else $as_nop mhd_cv_func_usleep="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_usleep="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_usleep" >&5 printf "%s\n" "$mhd_cv_func_usleep" >&6; } if test "x$mhd_cv_func_usleep" = x"yes" then : printf "%s\n" "#define HAVE_USLEEP 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_nanosleep+y} then : else $as_nop ac_fn_check_decl "$LINENO" "nanosleep" "ac_cv_have_decl_nanosleep" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_nanosleep" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function nanosleep" >&5 printf %s "checking for function nanosleep... " >&6; } if test ${mhd_cv_func_nanosleep+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_nanosleep" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { struct timespec ts2, ts1 = {0, 0}; nanosleep(&ts1, &ts2); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_nanosleep="yes" else $as_nop mhd_cv_func_nanosleep="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_nanosleep="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_nanosleep" >&5 printf "%s\n" "$mhd_cv_func_nanosleep" >&6; } if test "x$mhd_cv_func_nanosleep" = x"yes" then : printf "%s\n" "#define HAVE_NANOSLEEP 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here HIDDEN_VISIBILITY_CFLAGS="" CFLAGS="${user_CFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fvisibility=hidden flag" >&5 printf %s "checking whether $CC supports -fvisibility=hidden flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__fvisibility_hidden+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -fvisibility=hidden ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fvisibility_hidden="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fvisibility_hidden="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -fvisibility=hidden ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__fvisibility_hidden="yes" else $as_nop mhd_cv_cc_cfl_supp__fvisibility_hidden="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__fvisibility_hidden" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__fvisibility_hidden" >&6; } if test "x$mhd_cv_cc_cfl_supp__fvisibility_hidden" = x"yes" then : # NOTE: require setting of errattr_CFLAGS above CFLAGS="${CFLAGS_ac} -fvisibility=hidden ${user_CFLAGS} ${errattr_CFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports __attribute__((visibility(\"default\")))" >&5 printf %s "checking whether $CC supports __attribute__((visibility(\"default\")))... " >&6; } if test ${mhd_cv_cc_attr_visibility+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ extern __attribute__((visibility("default"))) int test_extrn_func(void); int test_extrn_func(void) {return 0;} _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_cc_attr_visibility="yes" else $as_nop mhd_cv_cc_attr_visibility="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_attr_visibility" >&5 printf "%s\n" "$mhd_cv_cc_attr_visibility" >&6; } if test "x$mhd_cv_cc_attr_visibility" = x"yes" then : HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden" if test "x$os_is_native_w32" = "xyes" && test "x$enable_shared" = "xyes" then : printf "%s\n" "#define _MHD_EXTERN __attribute__((visibility(\"default\"))) __declspec(dllexport) extern" >>confdefs.h else $as_nop printf "%s\n" "#define _MHD_EXTERN __attribute__((visibility(\"default\"))) extern" >>confdefs.h fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $CC supports -fvisibility, but does not support __attribute__((visibility(\"default\"))). Check compiler and compiler flags." >&5 printf "%s\n" "$as_me: WARNING: $CC supports -fvisibility, but does not support __attribute__((visibility(\"default\"))). Check compiler and compiler flags." >&2;} printf "%s\n" "#define _MHD_EXTERN extern" >>confdefs.h fi else $as_nop printf "%s\n" "#define _MHD_EXTERN extern" >>confdefs.h fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" # libcurl (required for testing) # Check whether --enable-curl was given. if test ${enable_curl+y} then : enableval=$enable_curl; enable_curl=${enableval} fi curl=0 if test "$enable_curl" != "no" then : # Check whether --with-libcurl was given. if test ${with_libcurl+y} then : withval=$with_libcurl; _libcurl_with=$withval else $as_nop _libcurl_with=yes fi if test "$_libcurl_with" != "no" ; then for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_AWK+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 printf "%s\n" "$AWK" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$AWK" && break done _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[1]+256*A[2]+A[3]; print X;}'" _libcurl_try_link=yes if test -d "$_libcurl_with" ; then LIBCURL_CPPFLAGS="-I$withval/include" _libcurl_ldflags="-L$withval/lib" # Extract the first word of "curl-config", so it can be a program name with args. set dummy curl-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path__libcurl_config+y} then : printf %s "(cached) " >&6 else $as_nop case $_libcurl_config in [\\/]* | ?:[\\/]*) ac_cv_path__libcurl_config="$_libcurl_config" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in "$withval/bin" do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path__libcurl_config="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi _libcurl_config=$ac_cv_path__libcurl_config if test -n "$_libcurl_config"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $_libcurl_config" >&5 printf "%s\n" "$_libcurl_config" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi else # Extract the first word of "curl-config", so it can be a program name with args. set dummy curl-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path__libcurl_config+y} then : printf %s "(cached) " >&6 else $as_nop case $_libcurl_config in [\\/]* | ?:[\\/]*) ac_cv_path__libcurl_config="$_libcurl_config" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path__libcurl_config="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi _libcurl_config=$ac_cv_path__libcurl_config if test -n "$_libcurl_config"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $_libcurl_config" >&5 printf "%s\n" "$_libcurl_config" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test x$_libcurl_config != "x" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the version of libcurl" >&5 printf %s "checking for the version of libcurl... " >&6; } if test ${libcurl_cv_lib_curl_version+y} then : printf %s "(cached) " >&6 else $as_nop libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $2}'` fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_curl_version" >&5 printf "%s\n" "$libcurl_cv_lib_curl_version" >&6; } _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse` _libcurl_wanted=`echo 7.16.4 | $_libcurl_version_parse` if test $_libcurl_wanted -gt 0 ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libcurl >= version 7.16.4" >&5 printf %s "checking for libcurl >= version 7.16.4... " >&6; } if test ${libcurl_cv_lib_version_ok+y} then : printf %s "(cached) " >&6 else $as_nop if test $_libcurl_version -ge $_libcurl_wanted ; then libcurl_cv_lib_version_ok=yes else libcurl_cv_lib_version_ok=no fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_version_ok" >&5 printf "%s\n" "$libcurl_cv_lib_version_ok" >&6; } fi if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then if test x"$LIBCURL_CPPFLAGS" = "x" ; then LIBCURL_CPPFLAGS=`$_libcurl_config --cflags` fi if test x"$LIBCURL" = "x" ; then LIBCURL=`$_libcurl_config --libs` # This is so silly, but Apple actually has a bug in their # curl-config script. Fixed in Tiger, but there are still # lots of Panther installs around. case "${host}" in powerpc-apple-darwin7*) LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'` ;; esac fi # All curl-config scripts support --feature _libcurl_features=`$_libcurl_config --feature` # Is it modern enough to have --protocols? (7.12.4) if test $_libcurl_version -ge 461828 ; then _libcurl_protocols=`$_libcurl_config --protocols` fi else _libcurl_try_link=no fi unset _libcurl_wanted fi if test $_libcurl_try_link = yes ; then # we didn't find curl-config, so let's see if the user-supplied # link line (or failing that, "-lcurl") is enough. LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether libcurl is usable" >&5 printf %s "checking whether libcurl is usable... " >&6; } if test ${libcurl_cv_lib_curl_usable+y} then : printf %s "(cached) " >&6 else $as_nop _libcurl_save_cppflags=$CPPFLAGS CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS" _libcurl_save_libs=$LIBS LIBS="$LIBCURL $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { /* Try and use a few common options to force a failure if we are missing symbols or can't link. */ int x; curl_easy_setopt(NULL,CURLOPT_URL,NULL); x=CURL_ERROR_SIZE; x=CURLOPT_WRITEFUNCTION; x=CURLOPT_WRITEDATA; x=CURLOPT_ERRORBUFFER; x=CURLOPT_STDERR; x=CURLOPT_VERBOSE; if (x) {;} ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : libcurl_cv_lib_curl_usable=yes else $as_nop libcurl_cv_lib_curl_usable=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext CPPFLAGS=$_libcurl_save_cppflags LIBS=$_libcurl_save_libs unset _libcurl_save_cppflags unset _libcurl_save_libs fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_curl_usable" >&5 printf "%s\n" "$libcurl_cv_lib_curl_usable" >&6; } if test $libcurl_cv_lib_curl_usable = yes ; then # Does curl_free() exist in this version of libcurl? # If not, fake it with free() _libcurl_save_cppflags=$CPPFLAGS CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS" _libcurl_save_libs=$LIBS LIBS="$LIBS $LIBCURL" ac_fn_check_decl "$LINENO" "curl_free" "ac_cv_have_decl_curl_free" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_curl_free" = xyes then : else $as_nop printf "%s\n" "#define curl_free free" >>confdefs.h fi CPPFLAGS=$_libcurl_save_cppflags LIBS=$_libcurl_save_libs unset _libcurl_save_cppflags unset _libcurl_save_libs printf "%s\n" "#define HAVE_LIBCURL 1" >>confdefs.h for _libcurl_feature in $_libcurl_features ; do cat >>confdefs.h <<_ACEOF #define `printf "%s\n" "libcurl_feature_$_libcurl_feature" | $as_tr_cpp` 1 _ACEOF eval `printf "%s\n" "libcurl_feature_$_libcurl_feature" | $as_tr_sh`=yes done if test "x$_libcurl_protocols" = "x" ; then # We don't have --protocols, so just assume that all # protocols are available _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP" if test x$libcurl_feature_SSL = xyes ; then _libcurl_protocols="$_libcurl_protocols HTTPS" # FTPS wasn't standards-compliant until version # 7.11.0 (0x070b00 == 461568) if test $_libcurl_version -ge 461568; then _libcurl_protocols="$_libcurl_protocols FTPS" fi fi # RTSP, IMAP, POP3 and SMTP were added in # 7.20.0 (0x071400 == 463872) if test $_libcurl_version -ge 463872; then _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP" fi fi for _libcurl_protocol in $_libcurl_protocols ; do cat >>confdefs.h <<_ACEOF #define `printf "%s\n" "libcurl_protocol_$_libcurl_protocol" | $as_tr_cpp` 1 _ACEOF eval `printf "%s\n" "libcurl_protocol_$_libcurl_protocol" | $as_tr_sh`=yes done else unset LIBCURL unset LIBCURL_CPPFLAGS fi fi unset _libcurl_try_link unset _libcurl_version_parse unset _libcurl_config unset _libcurl_feature unset _libcurl_features unset _libcurl_protocol unset _libcurl_protocols unset _libcurl_version unset _libcurl_ldflags fi if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then # This is the IF-NO path if test "x$enable_curl" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cURL-based tests cannot be enabled because libcurl is missing" >&5 printf "%s\n" "$as_me: WARNING: cURL-based tests cannot be enabled because libcurl is missing" >&2;} fi enable_curl=no else # This is the IF-YES path enable_curl=yes fi unset _libcurl_with fi if test "x$enable_curl" = "xyes"; then RUN_LIBCURL_TESTS_TRUE= RUN_LIBCURL_TESTS_FALSE='#' else RUN_LIBCURL_TESTS_TRUE='#' RUN_LIBCURL_TESTS_FALSE= fi if test "x$enable_curl" = "xyes" then : MSG_CURL="yes" else $as_nop MSG_CURL="no, many unit tests will not run" fi # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_magic_open+y} then : else $as_nop ac_fn_check_decl "$LINENO" "magic_open" "ac_cv_have_decl_magic_open" " #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_magic_open" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function magic_open" >&5 printf %s "checking for function magic_open... " >&6; } if test ${mhd_cv_func_magic_open+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_magic_open" = x"yes" then : mhd_check_func_SAVE_LIBS="$LIBS" LIBS="-lmagic $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { char var_data[256]; const char *var_mime; magic_t var_magic = magic_open (MAGIC_MIME_TYPE); (void)magic_load (var_magic, "filename"); var_data[0] = 0; var_mime = magic_buffer (var_magic, var_data, 1); if (! var_mime) return 1; magic_close (var_magic); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_magic_open="yes" else $as_nop mhd_cv_func_magic_open="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="${mhd_check_func_SAVE_LIBS}" { mhd_check_func_SAVE_LIBS=; unset mhd_check_func_SAVE_LIBS;} else $as_nop mhd_cv_func_magic_open="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_magic_open" >&5 printf "%s\n" "$mhd_cv_func_magic_open" >&6; } if test "x$mhd_cv_func_magic_open" = x"yes" then : printf "%s\n" "#define HAVE_MAGIC_OPEN 1" >>confdefs.h printf "%s\n" "#define MHD_HAVE_LIBMAGIC 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here if test "x$mhd_cv_func_magic_open" = "xyes"; then MHD_HAVE_LIBMAGIC_TRUE= MHD_HAVE_LIBMAGIC_FALSE='#' else MHD_HAVE_LIBMAGIC_TRUE='#' MHD_HAVE_LIBMAGIC_FALSE= fi # large file support (> 4 GB) # Check whether --enable-largefile was given. if test ${enable_largefile+y} then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 printf %s "checking for special C compiler options needed for large files... " >&6; } if test ${ac_cv_sys_largefile_CC+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : break fi rm -f core conftest.err conftest.$ac_objext conftest.beam CC="$CC -n32" if ac_fn_c_try_compile "$LINENO" then : ac_cv_sys_largefile_CC=' -n32'; break fi rm -f core conftest.err conftest.$ac_objext conftest.beam break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 printf "%s\n" "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 printf %s "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } if test ${ac_cv_sys_file_offset_bits+y} then : printf %s "(cached) " >&6 else $as_nop while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_sys_file_offset_bits=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_sys_file_offset_bits=64; break fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 printf "%s\n" "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) printf "%s\n" "#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits" >>confdefs.h ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 printf %s "checking for _LARGE_FILES value needed for large files... " >&6; } if test ${ac_cv_sys_large_files+y} then : printf %s "(cached) " >&6 else $as_nop while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_sys_large_files=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_sys_large_files=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 printf "%s\n" "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) printf "%s\n" "#define _LARGE_FILES $ac_cv_sys_large_files" >>confdefs.h ;; esac rm -rf conftest* fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5 printf %s "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; } if test ${ac_cv_sys_largefile_source+y} then : printf %s "(cached) " >&6 else $as_nop while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* for off_t */ #include int main (void) { int (*fp) (FILE *, off_t, int) = fseeko; return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_sys_largefile_source=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGEFILE_SOURCE 1 #include /* for off_t */ #include int main (void) { int (*fp) (FILE *, off_t, int) = fseeko; return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_sys_largefile_source=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext ac_cv_sys_largefile_source=unknown break done fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5 printf "%s\n" "$ac_cv_sys_largefile_source" >&6; } case $ac_cv_sys_largefile_source in #( no | unknown) ;; *) printf "%s\n" "#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source" >>confdefs.h ;; esac rm -rf conftest* # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug # in glibc 2.1.3, but that breaks too many other things. # If you want fseeko and ftello with glibc, upgrade to a fixed glibc. if test $ac_cv_sys_largefile_source != unknown; then printf "%s\n" "#define HAVE_FSEEKO 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_lseek64+y} then : else $as_nop ac_fn_check_decl "$LINENO" "lseek64" "ac_cv_have_decl_lseek64" " #if defined(HAVE_SYS_TYPES_H) # include #endif #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_lseek64" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function lseek64" >&5 printf %s "checking for function lseek64... " >&6; } if test ${mhd_cv_func_lseek64+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_lseek64" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined(HAVE_SYS_TYPES_H) # include #endif #include int main(void) { if (((off64_t) -1) == lseek64(0, (off64_t) 0, SEEK_SET)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_lseek64="yes" else $as_nop mhd_cv_func_lseek64="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_lseek64="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_lseek64" >&5 printf "%s\n" "$mhd_cv_func_lseek64" >&6; } if test "x$mhd_cv_func_lseek64" = x"yes" then : printf "%s\n" "#define HAVE_LSEEK64 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_pread64+y} then : else $as_nop ac_fn_check_decl "$LINENO" "pread64" "ac_cv_have_decl_pread64" " #if defined(HAVE_SYS_TYPES_H) # include #endif #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_pread64" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function pread64" >&5 printf %s "checking for function pread64... " >&6; } if test ${mhd_cv_func_pread64+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_pread64" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined(HAVE_SYS_TYPES_H) # include #endif #include int main(void) { char buf[5]; if (0 > pread64(0, (void *) buf, 1, (off64_t) 0)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_pread64="yes" else $as_nop mhd_cv_func_pread64="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_pread64="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_pread64" >&5 printf "%s\n" "$mhd_cv_func_pread64" >&6; } if test "x$mhd_cv_func_pread64" = x"yes" then : printf "%s\n" "#define HAVE_PREAD64 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_pread+y} then : else $as_nop ac_fn_check_decl "$LINENO" "pread" "ac_cv_have_decl_pread" " #if defined(HAVE_SYS_TYPES_H) # include #endif #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_pread" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function pread" >&5 printf %s "checking for function pread... " >&6; } if test ${mhd_cv_func_pread+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_pread" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined(HAVE_SYS_TYPES_H) # include #endif #include int main(void) { char buf[5]; if (0 > pread(0, (void *) buf, 1, 0)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_pread="yes" else $as_nop mhd_cv_func_pread="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_pread="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_pread" >&5 printf "%s\n" "$mhd_cv_func_pread" >&6; } if test "x$mhd_cv_func_pread" = x"yes" then : printf "%s\n" "#define HAVE_PREAD 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # check for various sendfile functions # Check whether --enable-sendfile was given. if test ${enable_sendfile+y} then : enableval=$enable_sendfile; else $as_nop enable_sendfile="auto" fi case $enable_sendfile in #( auto | yes) : found_sendfile="no" ;; #( no) : found_sendfile="disabled" ;; #( *) : as_fn_error $? "unknown value specified: --enable-sendfile=$enable_sendfile" "$LINENO" 5 ;; esac if test "x$found_sendfile" = x"no" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Linux-style sendfile(2)" >&5 printf %s "checking for Linux-style sendfile(2)... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include static void empty_func(void) { /* Check for declaration */ (void)sendfile; } /* Declare again to check form match */ ssize_t sendfile(int, int, off_t*, size_t); int main (void) { int fd1=0, fd2=2; off_t o = 0; size_t s = 5; ssize_t r; r = sendfile (fd1, fd2, &o, s); if (r) empty_func(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_LINUX_SENDFILE 1" >>confdefs.h found_sendfile="yes, Linux-style" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_sendfile64+y} then : else $as_nop ac_fn_check_decl "$LINENO" "sendfile64" "ac_cv_have_decl_sendfile64" " #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_sendfile64" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function sendfile64" >&5 printf %s "checking for function sendfile64... " >&6; } if test ${mhd_cv_func_sendfile64+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_sendfile64" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { off64_t f_offset = (off64_t) 0; if (0 > sendfile64 (0, 1, &f_offset, 1)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_sendfile64="yes" else $as_nop mhd_cv_func_sendfile64="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_sendfile64="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_sendfile64" >&5 printf "%s\n" "$mhd_cv_func_sendfile64" >&6; } if test "x$mhd_cv_func_sendfile64" = x"yes" then : printf "%s\n" "#define HAVE_SENDFILE64 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi if test "x$found_sendfile" = x"no" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for FreeBSD-style sendfile(2)" >&5 printf %s "checking for FreeBSD-style sendfile(2)... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include static void empty_func(void) { /* Check for declaration */ (void)sendfile; } /* Declare again to check form match */ int sendfile(int, int, off_t, size_t, struct sf_hdtr*, off_t*, int); int main (void) { int fd1=0, fd2=1; off_t o = 0; size_t s = 5; off_t r1; int r2; r2 = sendfile (fd1, fd2, o, s, (void*)0, &r1, 0); if (r2) empty_func(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_FREEBSD_SENDFILE 1" >>confdefs.h found_sendfile="yes, FreeBSD-style" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi if test "x$found_sendfile" = x"no" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Darwin-style sendfile(2)" >&5 printf %s "checking for Darwin-style sendfile(2)... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include static void empty_func(void) { /* Check for declaration */ (void)sendfile; } /* Declare again to check form match */ int sendfile(int, int, off_t, off_t*, struct sf_hdtr *, int); int main (void) { int fd=0, s=1; off_t o = 0; off_t l = 5; int r; r = sendfile (fd, s, o, &l, (void*)0, 0); if (r) empty_func(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_DARWIN_SENDFILE 1" >>confdefs.h found_sendfile="yes, Darwin-style" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi if test "x$found_sendfile" = x"no" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Solaris-style sendfile(3)" >&5 printf %s "checking for Solaris-style sendfile(3)... " >&6; } SAVE_LIBS="$LIBS" LIBS="-lsendfile $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include static void empty_func(void) { /* Check for declaration */ (void)sendfile; } /* Declare again to check form match */ ssize_t sendfile(int out_fd, int in_fd, off_t *off, size_t len); int main (void) { int fd1=0, fd2=1; off_t o = 0; size_t l = 5; ssize_t r; r = sendfile (fd1, fd2, &o, l); if (r) empty_func(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_SOLARIS_SENDFILE 1" >>confdefs.h found_sendfile="yes, Solaris-style" MHD_LIBDEPS="-lsendfile $MHD_LIBDEPS" MHD_LIBDEPS_PKGCFG="-lsendfile $MHD_LIBDEPS_PKGCFG" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_sendfile64+y} then : else $as_nop ac_fn_check_decl "$LINENO" "sendfile64" "ac_cv_have_decl_sendfile64" " #include #include #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_sendfile64" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function sendfile64" >&5 printf %s "checking for function sendfile64... " >&6; } if test ${mhd_cv_func_sendfile64+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_sendfile64" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main(void) { off64_t f_offset = (off64_t) 0; if (0 > sendfile64 (0, 1, &f_offset, 1)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_sendfile64="yes" else $as_nop mhd_cv_func_sendfile64="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_sendfile64="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_sendfile64" >&5 printf "%s\n" "$mhd_cv_func_sendfile64" >&6; } if test "x$mhd_cv_func_sendfile64" = x"yes" then : printf "%s\n" "#define HAVE_SENDFILE64 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="$SAVE_LIBS" fi if test "x$found_sendfile" = "xno" && test "x$enable_sendfile" = "xyes" then : as_fn_error $? "sendfile() usage was requested by configure parameter, but no usable sendfile() function is detected" "$LINENO" 5 fi # optional: enable error and informational messages { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to generate text messages" >&5 printf %s "checking whether to generate text messages... " >&6; } # Check whether --enable-messages was given. if test ${enable_messages+y} then : enableval=$enable_messages; enable_messages=${enableval} else $as_nop enable_messages=yes fi if test "x$enable_messages" = "xyes" then : printf "%s\n" "#define HAVE_MESSAGES 1" >>confdefs.h else $as_nop enable_messages=no fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_messages" >&5 printf "%s\n" "$enable_messages" >&6; } if test "x$enable_messages" != "xno"; then HAVE_MESSAGES_TRUE= HAVE_MESSAGES_FALSE='#' else HAVE_MESSAGES_TRUE='#' HAVE_MESSAGES_FALSE= fi # optional: have postprocessor? { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable postprocessor" >&5 printf %s "checking whether to enable postprocessor... " >&6; } # Check whether --enable-postprocessor was given. if test ${enable_postprocessor+y} then : enableval=$enable_postprocessor; enable_postprocessor=${enableval} else $as_nop enable_postprocessor=yes fi if test "x$enable_postprocessor" != "xno" then : enable_postprocessor=yes printf "%s\n" "#define HAVE_POSTPROCESSOR 1" >>confdefs.h fi if test "x$enable_postprocessor" != "xno"; then HAVE_POSTPROCESSOR_TRUE= HAVE_POSTPROCESSOR_FALSE='#' else HAVE_POSTPROCESSOR_TRUE='#' HAVE_POSTPROCESSOR_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_postprocessor" >&5 printf "%s\n" "$enable_postprocessor" >&6; } have_gnutls=no have_gnutls_sni=no have_gcrypt=no { GNUTLS_CPPFLAGS=; unset GNUTLS_CPPFLAGS;} { GNUTLS_LDFLAGS=; unset GNUTLS_LDFLAGS;} # optional: HTTPS support. Enabled by default # Check whether --enable-https was given. if test ${enable_https+y} then : enableval=$enable_https; enable_https=${enableval} fi if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_PKG_CONFIG+y} then : printf %s "(cached) " >&6 else $as_nop case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 printf "%s\n" "$PKG_CONFIG" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_ac_pt_PKG_CONFIG+y} then : printf %s "(cached) " >&6 else $as_nop case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 printf "%s\n" "$ac_pt_PKG_CONFIG" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 printf %s "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } PKG_CONFIG="" fi fi if test "x$enable_https" != "xno" then : # # Next block is large unindented block # # gnutls have_gnutls_pkgcfg=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to find GnuTLS library" >&5 printf %s "checking how to find GnuTLS library... " >&6; } # Check whether --with-gnutls was given. if test ${with_gnutls+y} then : withval=$with_gnutls; case $with_gnutls in #( no) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: GnuTLS disabled" >&5 printf "%s\n" "GnuTLS disabled" >&6; } { GNUTLS_CPPFLAGS=; unset GNUTLS_CPPFLAGS;} { GNUTLS_CFLAGS=; unset GNUTLS_CFLAGS;} { GNUTLS_LDFLAGS=; unset GNUTLS_LDFLAGS;} { GNUTLS_LIBS=; unset GNUTLS_LIBS;} ;; #( yes) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: automatically, forced" >&5 printf "%s\n" "automatically, forced" >&6; } ;; #( *) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -I$with_gnutls/include -L$with_gnutls/lib -lgnutls" >&5 printf "%s\n" "-I$with_gnutls/include -L$with_gnutls/lib -lgnutls" >&6; } SAVE_LIBS="$LIBS" LDFLAGS="${LDFLAGS_ac} -L$with_gnutls/lib ${user_LDFLAGS}" CPPFLAGS="${CPPFLAGS_ac} -I$with_gnutls/include ${user_CPPFLAGS}" have_gnutls_pkgcfg=no # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_gnutls_check_version+y} then : else $as_nop ac_fn_check_decl "$LINENO" "gnutls_check_version" "ac_cv_have_decl_gnutls_check_version" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_gnutls_check_version" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function gnutls_check_version" >&5 printf %s "checking for function gnutls_check_version... " >&6; } if test ${mhd_cv_func_gnutls_check_version+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_gnutls_check_version" = x"yes" then : mhd_check_func_SAVE_LIBS="$LIBS" LIBS="-lgnutls $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { if(!gnutls_check_version("2.0.0")) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_gnutls_check_version="yes" else $as_nop mhd_cv_func_gnutls_check_version="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="${mhd_check_func_SAVE_LIBS}" { mhd_check_func_SAVE_LIBS=; unset mhd_check_func_SAVE_LIBS;} else $as_nop mhd_cv_func_gnutls_check_version="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_gnutls_check_version" >&5 printf "%s\n" "$mhd_cv_func_gnutls_check_version" >&6; } if test "x$mhd_cv_func_gnutls_check_version" = x"yes" then : printf "%s\n" "#define HAVE_GNUTLS_CHECK_VERSION 1" >>confdefs.h GNUTLS_CPPFLAGS="-I$with_gnutls/include" GNUTLS_LDFLAGS="-L$with_gnutls/lib" GNUTLS_LIBS="-lgnutls" have_gnutls=yes else $as_nop as_fn_error $? "can't find usable libgnutls at specified prefix $with_gnutls" "$LINENO" 5 fi # Expansion of MHD_CHECK_FUNC macro ends here CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" LIBS="$SAVE_LIBS" ;; esac else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: automatically" >&5 printf "%s\n" "automatically" >&6; } fi if test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes" then : pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnutls" >&5 printf %s "checking for gnutls... " >&6; } if test -n "$GNUTLS_CFLAGS"; then pkg_cv_GNUTLS_CFLAGS="$GNUTLS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnutls\""; } >&5 ($PKG_CONFIG --exists --print-errors "gnutls") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GNUTLS_CFLAGS=`$PKG_CONFIG --cflags "gnutls" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$GNUTLS_LIBS"; then pkg_cv_GNUTLS_LIBS="$GNUTLS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnutls\""; } >&5 ($PKG_CONFIG --exists --print-errors "gnutls") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GNUTLS_LIBS=`$PKG_CONFIG --libs "gnutls" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then GNUTLS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnutls" 2>&1` else GNUTLS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnutls" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GNUTLS_PKG_ERRORS" >&5 # check for GnuTLS at default paths have_gnutls_pkgcfg='no' for ac_header in gnutls/gnutls.h do : ac_fn_c_check_header_compile "$LINENO" "gnutls/gnutls.h" "ac_cv_header_gnutls_gnutls_h" "$ac_includes_default " if test "x$ac_cv_header_gnutls_gnutls_h" = xyes then : printf "%s\n" "#define HAVE_GNUTLS_GNUTLS_H 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnutls_priority_set in -lgnutls" >&5 printf %s "checking for gnutls_priority_set in -lgnutls... " >&6; } if test ${ac_cv_lib_gnutls_gnutls_priority_set+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lgnutls $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. The 'extern "C"' is for builds by C++ compilers; although this is not generally supported in C code supporting it here has little cost and some practical benefit (sr 110532). */ #ifdef __cplusplus extern "C" #endif char gnutls_priority_set (void); int main (void) { return gnutls_priority_set (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_gnutls_gnutls_priority_set=yes else $as_nop ac_cv_lib_gnutls_gnutls_priority_set=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gnutls_gnutls_priority_set" >&5 printf "%s\n" "$ac_cv_lib_gnutls_gnutls_priority_set" >&6; } if test "x$ac_cv_lib_gnutls_gnutls_priority_set" = xyes then : GNUTLS_LIBS="-lgnutls" have_gnutls=yes fi fi done elif test $pkg_failed = untried; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } # check for GnuTLS at default paths have_gnutls_pkgcfg='no' for ac_header in gnutls/gnutls.h do : ac_fn_c_check_header_compile "$LINENO" "gnutls/gnutls.h" "ac_cv_header_gnutls_gnutls_h" "$ac_includes_default " if test "x$ac_cv_header_gnutls_gnutls_h" = xyes then : printf "%s\n" "#define HAVE_GNUTLS_GNUTLS_H 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnutls_priority_set in -lgnutls" >&5 printf %s "checking for gnutls_priority_set in -lgnutls... " >&6; } if test ${ac_cv_lib_gnutls_gnutls_priority_set+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lgnutls $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. The 'extern "C"' is for builds by C++ compilers; although this is not generally supported in C code supporting it here has little cost and some practical benefit (sr 110532). */ #ifdef __cplusplus extern "C" #endif char gnutls_priority_set (void); int main (void) { return gnutls_priority_set (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_gnutls_gnutls_priority_set=yes else $as_nop ac_cv_lib_gnutls_gnutls_priority_set=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gnutls_gnutls_priority_set" >&5 printf "%s\n" "$ac_cv_lib_gnutls_gnutls_priority_set" >&6; } if test "x$ac_cv_lib_gnutls_gnutls_priority_set" = xyes then : GNUTLS_LIBS="-lgnutls" have_gnutls=yes fi fi done else GNUTLS_CFLAGS=$pkg_cv_GNUTLS_CFLAGS GNUTLS_LIBS=$pkg_cv_GNUTLS_LIBS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } have_gnutls_pkgcfg='yes' SAVE_LIBS="$LIBS" CFLAGS="${CFLAGS_ac} $GNUTLS_CFLAGS ${user_CFLAGS}" LIBS="$GNUTLS_LIBS $LIBS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether GnuTLS is usable" >&5 printf %s "checking whether GnuTLS is usable... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { gnutls_session_t session; gnutls_priority_t priorities; gnutls_global_init(); gnutls_priority_init(&priorities, "NORMAL", NULL); gnutls_init(&session, GNUTLS_SERVER); gnutls_priority_set(session, priorities); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } have_gnutls=yes # GNUTLS_CFLAGS is actually CPPFLAGS GNUTLS_CPPFLAGS="$GNUTLS_CFLAGS" # GNUTLS_LDFLAGS is a combination of LDFLAGS and LIBS GNUTLS_LDFLAGS="$GNUTLS_LIBS" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } have_gnutls=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test "x$have_gnutls" != "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config reports that GnuTLS is present, but GnuTLS can't be used" >&5 printf "%s\n" "$as_me: WARNING: pkg-config reports that GnuTLS is present, but GnuTLS can't be used" >&2;} { GNUTLS_CPPFLAGS=; unset GNUTLS_CPPFLAGS;} { GNUTLS_CFLAGS=; unset GNUTLS_CFLAGS;} { GNUTLS_LDFLAGS=; unset GNUTLS_LDFLAGS;} { GNUTLS_LIBS=; unset GNUTLS_LIBS;} fi CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" LIBS="$SAVE_LIBS" fi fi have_gcrypt='unknown' if test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes" then : # Check whether --with-libgcrypt-prefix was given. if test ${with_libgcrypt_prefix+y} then : withval=$with_libgcrypt_prefix; libgcrypt_config_prefix="$withval" else $as_nop libgcrypt_config_prefix="" fi if test x"${LIBGCRYPT_CONFIG}" = x ; then if test x"${libgcrypt_config_prefix}" != x ; then LIBGCRYPT_CONFIG="${libgcrypt_config_prefix}/bin/libgcrypt-config" fi fi use_gpgrt_config="" if test x"${LIBGCRYPT_CONFIG}" = x -a x"$GPGRT_CONFIG" != x -a "$GPGRT_CONFIG" != "no"; then if $GPGRT_CONFIG libgcrypt --exists; then LIBGCRYPT_CONFIG="$GPGRT_CONFIG libgcrypt" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Use gpgrt-config as libgcrypt-config" >&5 printf "%s\n" "$as_me: Use gpgrt-config as libgcrypt-config" >&6;} use_gpgrt_config=yes fi fi if test -z "$use_gpgrt_config"; then if test x"${LIBGCRYPT_CONFIG}" = x ; then case "${SYSROOT}" in /*) if test -x "${SYSROOT}/bin/libgcrypt-config" ; then LIBGCRYPT_CONFIG="${SYSROOT}/bin/libgcrypt-config" fi ;; '') ;; *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring \$SYSROOT as it is not an absolute path." >&5 printf "%s\n" "$as_me: WARNING: Ignoring \$SYSROOT as it is not an absolute path." >&2;} ;; esac fi # Extract the first word of "libgcrypt-config", so it can be a program name with args. set dummy libgcrypt-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_LIBGCRYPT_CONFIG+y} then : printf %s "(cached) " >&6 else $as_nop case $LIBGCRYPT_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_LIBGCRYPT_CONFIG="$LIBGCRYPT_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_LIBGCRYPT_CONFIG="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_LIBGCRYPT_CONFIG" && ac_cv_path_LIBGCRYPT_CONFIG="no" ;; esac fi LIBGCRYPT_CONFIG=$ac_cv_path_LIBGCRYPT_CONFIG if test -n "$LIBGCRYPT_CONFIG"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIBGCRYPT_CONFIG" >&5 printf "%s\n" "$LIBGCRYPT_CONFIG" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi tmp=1.2.2 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` else req_libgcrypt_api=0 min_libgcrypt_version="$tmp" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for LIBGCRYPT - version >= $min_libgcrypt_version" >&5 printf %s "checking for LIBGCRYPT - version >= $min_libgcrypt_version... " >&6; } ok=no if test "$LIBGCRYPT_CONFIG" != "no" ; then req_major=`echo $min_libgcrypt_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'` req_minor=`echo $min_libgcrypt_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'` req_micro=`echo $min_libgcrypt_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'` if test -z "$use_gpgrt_config"; then libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` else libgcrypt_config_version=`$LIBGCRYPT_CONFIG --modversion` fi major=`echo $libgcrypt_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'` minor=`echo $libgcrypt_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'` micro=`echo $libgcrypt_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'` if test "$major" -gt "$req_major"; then ok=yes else if test "$major" -eq "$req_major"; then if test "$minor" -gt "$req_minor"; then ok=yes else if test "$minor" -eq "$req_minor"; then if test "$micro" -ge "$req_micro"; then ok=yes fi fi fi fi fi fi if test $ok = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes ($libgcrypt_config_version)" >&5 printf "%s\n" "yes ($libgcrypt_config_version)" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test $ok = yes; then # If we have a recent libgcrypt, we should also check that the # API is compatible if test "$req_libgcrypt_api" -gt 0 ; then if test -z "$use_gpgrt_config"; then tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` else tmp=`$LIBGCRYPT_CONFIG --variable=api_version 2>/dev/null || echo 0` fi if test "$tmp" -gt 0 ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking LIBGCRYPT API version" >&5 printf %s "checking LIBGCRYPT API version... " >&6; } if test "$req_libgcrypt_api" -eq "$tmp" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: okay" >&5 printf "%s\n" "okay" >&6; } else ok=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: does not match. want=$req_libgcrypt_api got=$tmp" >&5 printf "%s\n" "does not match. want=$req_libgcrypt_api got=$tmp" >&6; } fi fi fi fi if test $ok = yes; then LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` have_gcrypt=yes if test -z "$use_gpgrt_config"; then libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none` else libgcrypt_config_host=`$LIBGCRYPT_CONFIG --variable=host 2>/dev/null || echo none` fi if test x"$libgcrypt_config_host" != xnone ; then if test x"$libgcrypt_config_host" != x"$host" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** *** The config script \"$LIBGCRYPT_CONFIG\" was *** built for $libgcrypt_config_host and thus may not match the *** used host $host. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script or use \$SYSROOT. ***" >&5 printf "%s\n" "$as_me: WARNING: *** *** The config script \"$LIBGCRYPT_CONFIG\" was *** built for $libgcrypt_config_host and thus may not match the *** used host $host. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script or use \$SYSROOT. ***" >&2;} gpg_config_script_warn="$gpg_config_script_warn libgcrypt" fi fi else LIBGCRYPT_CFLAGS="" LIBGCRYPT_LIBS="" have_gcrypt=no fi if test "x$have_gcrypt" = "xyes" then : SAVE_LIBS="$LIBS" CFLAGS="${CFLAGS_ac} $LIBGCRYPT_CFLAGS ${user_CFLAGS}" # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both CPPFLAGS="${CPPFLAGS_ac} $LIBGCRYPT_CFLAGS ${user_CPPFLAGS}" for ac_header in gcrypt.h do : ac_fn_c_check_header_compile "$LINENO" "gcrypt.h" "ac_cv_header_gcrypt_h" "$ac_includes_default " if test "x$ac_cv_header_gcrypt_h" = xyes then : printf "%s\n" "#define HAVE_GCRYPT_H 1" >>confdefs.h else $as_nop have_gcrypt=no fi done # Check for GnuTLS with gcrypt flags LDFLAGS="${LDFLAGS_ac} ${LIBGCRYPT_LIBS} ${user_LDFLAGS}" # A bit of hack: unset cache variable to force recheck { ac_cv_header_gnutls_gnutls_h=; unset ac_cv_header_gnutls_gnutls_h;} for ac_header in gnutls/gnutls.h do : ac_fn_c_check_header_compile "$LINENO" "gnutls/gnutls.h" "ac_cv_header_gnutls_gnutls_h" "$ac_includes_default " if test "x$ac_cv_header_gnutls_gnutls_h" = xyes then : printf "%s\n" "#define HAVE_GNUTLS_GNUTLS_H 1" >>confdefs.h { ac_cv_lib_gnutls_gnutls_priority_set=; unset ac_cv_lib_gnutls_gnutls_priority_set;} # A bit of hack: unset cache variable to force recheck { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnutls_priority_set in -lgnutls" >&5 printf %s "checking for gnutls_priority_set in -lgnutls... " >&6; } if test ${ac_cv_lib_gnutls_gnutls_priority_set+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lgnutls $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. The 'extern "C"' is for builds by C++ compilers; although this is not generally supported in C code supporting it here has little cost and some practical benefit (sr 110532). */ #ifdef __cplusplus extern "C" #endif char gnutls_priority_set (void); int main (void) { return gnutls_priority_set (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_gnutls_gnutls_priority_set=yes else $as_nop ac_cv_lib_gnutls_gnutls_priority_set=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gnutls_gnutls_priority_set" >&5 printf "%s\n" "$ac_cv_lib_gnutls_gnutls_priority_set" >&6; } if test "x$ac_cv_lib_gnutls_gnutls_priority_set" = xyes then : GNUTLS_CPPFLAGS="$LIBGCRYPT_CFLAGS" GNUTLS_CFLAGS="$LIBGCRYPT_CFLAGS" GNUTLS_LDFLAGS="$LIBGCRYPT_LIBS" GNUTLS_LIBS="-lgnutls" have_gnutls=yes fi fi done CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" LIBS="$SAVE_LIBS" fi fi if test "x$have_gnutls" != "xyes" && test "x$with_gnutls" = "xyes" then : as_fn_error $? "can't find usable libgnutls" "$LINENO" 5 fi if test "x$have_gnutls" = "xyes" then : SAVE_LIBS="$LIBS" CPPFLAGS="${CPPFLAGS_ac} ${GNUTLS_CPPFLAGS} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${GNUTLS_CFLAGS} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${GNUTLS_LDFLAGS} ${user_LDFLAGS}" LIBS="$GNUTLS_LIBS $LIBS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnutls_privkey_import_x509_raw()" >&5 printf %s "checking for gnutls_privkey_import_x509_raw()... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { gnutls_datum_t data; gnutls_privkey_t key = 0; #ifndef gnutls_load_file (void)gnutls_load_file; /* Check for declaration. */ #endif #ifndef gnutls_privkey_import_x509_raw (void)gnutls_privkey_import_x509_raw; /* Check for declaration. */ #endif gnutls_load_file("key.pem", &data); gnutls_privkey_import_x509_raw(key, &data, GNUTLS_X509_FMT_PEM, NULL, 0); gnutls_free(data.data); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : have_gnutls_sni=yes else $as_nop have_gnutls_sni=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gnutls_sni" >&5 printf "%s\n" "$have_gnutls_sni" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether GnuTLS require libgcrypt initialisation" >&5 printf %s "checking whether GnuTLS require libgcrypt initialisation... " >&6; } if test ${mhd_cv_gcrypt_required+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { #if !defined(GNUTLS_VERSION_NUMBER) || GNUTLS_VERSION_NUMBER+0 <= 0x020c14 #error Old versions of GnuTLS require libgcript initialisation choke me now #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_gcrypt_required='no' else $as_nop mhd_cv_gcrypt_required='yes' fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_gcrypt_required" >&5 printf "%s\n" "$mhd_cv_gcrypt_required" >&6; } CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" LIBS="$SAVE_LIBS" else $as_nop { GNUTLS_CPPFLAGS=; unset GNUTLS_CPPFLAGS;} { GNUTLS_LDFLAGS=; unset GNUTLS_LDFLAGS;} fi if test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" = "xunknown" then : # Check whether --with-libgcrypt-prefix was given. if test ${with_libgcrypt_prefix+y} then : withval=$with_libgcrypt_prefix; libgcrypt_config_prefix="$withval" else $as_nop libgcrypt_config_prefix="" fi if test x"${LIBGCRYPT_CONFIG}" = x ; then if test x"${libgcrypt_config_prefix}" != x ; then LIBGCRYPT_CONFIG="${libgcrypt_config_prefix}/bin/libgcrypt-config" fi fi use_gpgrt_config="" if test x"${LIBGCRYPT_CONFIG}" = x -a x"$GPGRT_CONFIG" != x -a "$GPGRT_CONFIG" != "no"; then if $GPGRT_CONFIG libgcrypt --exists; then LIBGCRYPT_CONFIG="$GPGRT_CONFIG libgcrypt" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Use gpgrt-config as libgcrypt-config" >&5 printf "%s\n" "$as_me: Use gpgrt-config as libgcrypt-config" >&6;} use_gpgrt_config=yes fi fi if test -z "$use_gpgrt_config"; then if test x"${LIBGCRYPT_CONFIG}" = x ; then case "${SYSROOT}" in /*) if test -x "${SYSROOT}/bin/libgcrypt-config" ; then LIBGCRYPT_CONFIG="${SYSROOT}/bin/libgcrypt-config" fi ;; '') ;; *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring \$SYSROOT as it is not an absolute path." >&5 printf "%s\n" "$as_me: WARNING: Ignoring \$SYSROOT as it is not an absolute path." >&2;} ;; esac fi # Extract the first word of "libgcrypt-config", so it can be a program name with args. set dummy libgcrypt-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_LIBGCRYPT_CONFIG+y} then : printf %s "(cached) " >&6 else $as_nop case $LIBGCRYPT_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_LIBGCRYPT_CONFIG="$LIBGCRYPT_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_LIBGCRYPT_CONFIG="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_LIBGCRYPT_CONFIG" && ac_cv_path_LIBGCRYPT_CONFIG="no" ;; esac fi LIBGCRYPT_CONFIG=$ac_cv_path_LIBGCRYPT_CONFIG if test -n "$LIBGCRYPT_CONFIG"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIBGCRYPT_CONFIG" >&5 printf "%s\n" "$LIBGCRYPT_CONFIG" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi tmp=1.2.2 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` else req_libgcrypt_api=0 min_libgcrypt_version="$tmp" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for LIBGCRYPT - version >= $min_libgcrypt_version" >&5 printf %s "checking for LIBGCRYPT - version >= $min_libgcrypt_version... " >&6; } ok=no if test "$LIBGCRYPT_CONFIG" != "no" ; then req_major=`echo $min_libgcrypt_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'` req_minor=`echo $min_libgcrypt_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'` req_micro=`echo $min_libgcrypt_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'` if test -z "$use_gpgrt_config"; then libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` else libgcrypt_config_version=`$LIBGCRYPT_CONFIG --modversion` fi major=`echo $libgcrypt_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'` minor=`echo $libgcrypt_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'` micro=`echo $libgcrypt_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'` if test "$major" -gt "$req_major"; then ok=yes else if test "$major" -eq "$req_major"; then if test "$minor" -gt "$req_minor"; then ok=yes else if test "$minor" -eq "$req_minor"; then if test "$micro" -ge "$req_micro"; then ok=yes fi fi fi fi fi fi if test $ok = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes ($libgcrypt_config_version)" >&5 printf "%s\n" "yes ($libgcrypt_config_version)" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test $ok = yes; then # If we have a recent libgcrypt, we should also check that the # API is compatible if test "$req_libgcrypt_api" -gt 0 ; then if test -z "$use_gpgrt_config"; then tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` else tmp=`$LIBGCRYPT_CONFIG --variable=api_version 2>/dev/null || echo 0` fi if test "$tmp" -gt 0 ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking LIBGCRYPT API version" >&5 printf %s "checking LIBGCRYPT API version... " >&6; } if test "$req_libgcrypt_api" -eq "$tmp" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: okay" >&5 printf "%s\n" "okay" >&6; } else ok=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: does not match. want=$req_libgcrypt_api got=$tmp" >&5 printf "%s\n" "does not match. want=$req_libgcrypt_api got=$tmp" >&6; } fi fi fi fi if test $ok = yes; then LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` have_gcrypt=yes if test -z "$use_gpgrt_config"; then libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none` else libgcrypt_config_host=`$LIBGCRYPT_CONFIG --variable=host 2>/dev/null || echo none` fi if test x"$libgcrypt_config_host" != xnone ; then if test x"$libgcrypt_config_host" != x"$host" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: *** *** The config script \"$LIBGCRYPT_CONFIG\" was *** built for $libgcrypt_config_host and thus may not match the *** used host $host. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script or use \$SYSROOT. ***" >&5 printf "%s\n" "$as_me: WARNING: *** *** The config script \"$LIBGCRYPT_CONFIG\" was *** built for $libgcrypt_config_host and thus may not match the *** used host $host. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script or use \$SYSROOT. ***" >&2;} gpg_config_script_warn="$gpg_config_script_warn libgcrypt" fi fi else LIBGCRYPT_CFLAGS="" LIBGCRYPT_LIBS="" have_gcrypt=no fi if test "x$have_gcrypt" = "xyes" then : CFLAGS="${CFLAGS_ac} ${LIBGCRYPT_CFLAGS} ${user_CFLAGS}" # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both CPPFLAGS="${CPPFLAGS_ac} ${LIBGCRYPT_CFLAGS} ${user_CPPFLAGS}" for ac_header in gcrypt.h do : ac_fn_c_check_header_compile "$LINENO" "gcrypt.h" "ac_cv_header_gcrypt_h" "$ac_includes_default " if test "x$ac_cv_header_gcrypt_h" = xyes then : printf "%s\n" "#define HAVE_GCRYPT_H 1" >>confdefs.h else $as_nop have_gcrypt=no fi done CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" fi fi { crypt_missing=; unset crypt_missing;} if test "x$have_gnutls" = "xyes" then : if test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" != "xyes" then : crypt_missing="required libgcrypt" if test "x$enable_https" = "xyes" then : as_fn_error $? "HTTPS support cannot be enabled without $crypt_missing." "$LINENO" 5 fi enable_https=no MSG_HTTPS="no (lacking $crypt_missing)" { LIBGCRYPT_CFLAGS=; unset LIBGCRYPT_CFLAGS;} { LIBGCRYPT_LIBS=; unset LIBGCRYPT_LIBS;} { GNUTLS_CPPFLAGS=; unset GNUTLS_CPPFLAGS;} { GNUTLS_CFLAGS=; unset GNUTLS_CFLAGS;} { GNUTLS_LDFLAGS=; unset GNUTLS_LDFLAGS;} { GNUTLS_LIBS=; unset GNUTLS_LIBS;} else $as_nop printf "%s\n" "#define HTTPS_SUPPORT 1" >>confdefs.h enable_https=yes if test "x$mhd_cv_gcrypt_required" = "xyes" then : MSG_HTTPS="yes (using libgnutls and libgcrypt)" MHD_TLS_LIB_CPPFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CPPFLAGS" MHD_TLS_LIB_CFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CFLAGS" MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS" MHD_TLS_LIBDEPS="$GNUTLS_LIBS $LIBGCRYPT_LIBS" printf "%s\n" "#define MHD_HTTPS_REQUIRE_GCRYPT 1" >>confdefs.h else $as_nop MSG_HTTPS="yes (using libgnutls)" { LIBGCRYPT_CFLAGS=; unset LIBGCRYPT_CFLAGS;} { LIBGCRYPT_LIBS=; unset LIBGCRYPT_LIBS;} MHD_TLS_LIB_CPPFLAGS="$GNUTLS_CPPFLAGS" MHD_TLS_LIB_CFLAGS="$GNUTLS_CFLAGS" MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS" MHD_TLS_LIBDEPS="$GNUTLS_LIBS" fi if test "x$have_gnutls_pkgcfg" = "xyes" then : # remove GnuTLS from private libs in .pc file as it defined in Requires.private MHD_REQ_PRIVATE='gnutls' if test "x$mhd_cv_gcrypt_required" = "xyes" then : MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG" fi else $as_nop MHD_REQ_PRIVATE='' if test "x$mhd_cv_gcrypt_required" = "xyes" then : MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG" fi MHD_LIBDEPS_PKGCFG="$GNUTLS_LIBS $MHD_LIBDEPS_PKGCFG" fi fi else $as_nop crypt_missing="libgnutls" if test "x$enable_https" = "xyes" then : as_fn_error $? "HTTPS support cannot be enabled without $crypt_missing." "$LINENO" 5 fi enable_https=no MSG_HTTPS="no (lacking $crypt_missing)" { LIBGCRYPT_CFLAGS=; unset LIBGCRYPT_CFLAGS;} { LIBGCRYPT_LIBS=; unset LIBGCRYPT_LIBS;} { GNUTLS_CPPFLAGS=; unset GNUTLS_CPPFLAGS;} { GNUTLS_CFLAGS=; unset GNUTLS_CFLAGS;} { GNUTLS_LDFLAGS=; unset GNUTLS_LDFLAGS;} { GNUTLS_LIBS=; unset GNUTLS_LIBS;} fi else $as_nop MSG_HTTPS="no (disabled)" fi # # End of large unindented block # { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to support HTTPS" >&5 printf %s "checking whether to support HTTPS... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MSG_HTTPS" >&5 printf "%s\n" "$MSG_HTTPS" >&6; } if test "x$have_gnutls" = "xyes"; then HAVE_GNUTLS_TRUE= HAVE_GNUTLS_FALSE='#' else HAVE_GNUTLS_TRUE='#' HAVE_GNUTLS_FALSE= fi if test "x$have_gnutls_sni" = "xyes"; then HAVE_GNUTLS_SNI_TRUE= HAVE_GNUTLS_SNI_FALSE='#' else HAVE_GNUTLS_SNI_TRUE='#' HAVE_GNUTLS_SNI_FALSE= fi if test "x$enable_https" = "xyes"; then ENABLE_HTTPS_TRUE= ENABLE_HTTPS_FALSE='#' else ENABLE_HTTPS_TRUE='#' ENABLE_HTTPS_FALSE= fi if test "x$enable_https" = "xyes" && test "x$mhd_cv_gcrypt_required" = "xyes"; then HTTPS_REQUIRE_GCRYPT_TRUE= HTTPS_REQUIRE_GCRYPT_FALSE='#' else HTTPS_REQUIRE_GCRYPT_TRUE='#' HTTPS_REQUIRE_GCRYPT_FALSE= fi if test "x$have_gnutls" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GnuTLS quirks" >&5 printf %s "checking for GnuTLS quirks... " >&6; } if test ${mhd_cv_gnutls_mthread_broken+y} then : printf %s "(cached) " >&6 else $as_nop mhd_cv_gnutls_mthread_broken="no" if test -r /etc/redhat-release then : if $FGREP ' release 6.' /etc/redhat-release >/dev/null || $FGREP '(Santiago)' /etc/redhat-release >/dev/null then : mhd_cv_gnutls_mthread_broken="found" fi fi if test "x$mhd_cv_gnutls_mthread_broken" = x"no" then : if command -v rpm >/dev/null then : if test "r`rpm -E '%{rhel}' 2>/dev/null`" = "r6" then : mhd_cv_gnutls_mthread_broken="found" fi fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_gnutls_mthread_broken" >&5 printf "%s\n" "$mhd_cv_gnutls_mthread_broken" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gnutls-cli binary" >&5 printf %s "checking for gnutls-cli binary... " >&6; } if test ${mhd_cv_gnutls_cli+y} then : printf %s "(cached) " >&6 else $as_nop mhd_cv_gnutls_cli="no" if command -v gnutls-cli >/dev/null 2>&1 then : if { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: gnutls-cli --version >&2"; } >&5 (gnutls-cli --version >&2) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : mhd_cv_gnutls_cli="yes" fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_gnutls_cli" >&5 printf "%s\n" "$mhd_cv_gnutls_cli" >&6; } fi if test "x${mhd_cv_gnutls_mthread_broken}" = "xfound"; then HAVE_GNUTLS_MTHREAD_BROKEN_TRUE= HAVE_GNUTLS_MTHREAD_BROKEN_FALSE='#' else HAVE_GNUTLS_MTHREAD_BROKEN_TRUE='#' HAVE_GNUTLS_MTHREAD_BROKEN_FALSE= fi if test "x${mhd_cv_gnutls_mthread_broken}" = "xno" || test "x${mhd_cv_gnutls_cli}" = "xyes"; then USE_UPGRADE_TLS_TESTS_TRUE= USE_UPGRADE_TLS_TESTS_FALSE='#' else USE_UPGRADE_TLS_TESTS_TRUE='#' USE_UPGRADE_TLS_TESTS_FALSE= fi # optional: HTTP Basic Auth support. Enabled by default { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to support HTTP Basic authentication" >&5 printf %s "checking whether to support HTTP Basic authentication... " >&6; } # Check whether --enable-bauth was given. if test ${enable_bauth+y} then : enableval=$enable_bauth; enable_bauth=${enableval} else $as_nop enable_bauth=yes fi if test "x$enable_bauth" != "xno" then : enable_bauth=yes printf "%s\n" "#define BAUTH_SUPPORT 1" >>confdefs.h fi if test "x$enable_bauth" != "xno"; then ENABLE_BAUTH_TRUE= ENABLE_BAUTH_FALSE='#' else ENABLE_BAUTH_TRUE='#' ENABLE_BAUTH_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_bauth" >&5 printf "%s\n" "$enable_bauth" >&6; } # optional: HTTP Digest Auth support. Enabled by default { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to support HTTP Digest authentication" >&5 printf %s "checking whether to support HTTP Digest authentication... " >&6; } # Check whether --enable-dauth was given. if test ${enable_dauth+y} then : enableval=$enable_dauth; enable_dauth="${enableval}" else $as_nop enable_dauth="yes" fi if test "x$enable_dauth" != "xno" then : enable_dauth=yes printf "%s\n" "#define DAUTH_SUPPORT 1" >>confdefs.h fi if test "x$enable_dauth" != "xno"; then ENABLE_DAUTH_TRUE= ENABLE_DAUTH_FALSE='#' else ENABLE_DAUTH_TRUE='#' ENABLE_DAUTH_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_dauth" >&5 printf "%s\n" "$enable_dauth" >&6; } if test "x$enable_dauth" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Digest Authentication default nonce timeout value" >&5 printf %s "checking for Digest Authentication default nonce timeout value... " >&6; } # Check whether --enable-dauth-def-timeout was given. if test ${enable_dauth_def_timeout+y} then : enableval=$enable_dauth_def_timeout; enable_dauth_def_timeout="${enableval}" else $as_nop enable_dauth_def_timeout="" fi if test "x$enable_dauth_def_timeout" = x"no" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Default Diget Auth nonce validity time cannot be disabled, --disable-dauth-def-timeout parameter is ignored" >&5 printf "%s\n" "$as_me: WARNING: Default Diget Auth nonce validity time cannot be disabled, --disable-dauth-def-timeout parameter is ignored" >&2;} enable_dauth_def_timeout="" fi if test -z "${enable_dauth_def_timeout}" then : enable_dauth_def_timeout="90" enable_dauth_def_timeout_MSG="${enable_dauth_def_timeout} seconds (default)" else $as_nop if test "x${enable_dauth_def_timeout}" = "x`echo ${enable_dauth_def_timeout}|${SED-sed} 's/[^0-9]//g'`" && \ test "${enable_dauth_def_timeout}" -ge "0" 2>/dev/null then : : else $as_nop as_fn_error $? "Invalid parameter --enable-dauth-def-timeout=${enable_dauth_def_timeout}. Timeout value must be a positive integer." "$LINENO" 5 fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { static int arr[((int) 2) - 4 * (int)(${enable_dauth_def_timeout} != ((unsigned int)${enable_dauth_def_timeout}))]; (void) arr; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop as_fn_error $? "The value specified by --enable-dauth-def-timeout=${enable_dauth_def_timeout} is too large." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext enable_dauth_def_timeout_MSG="${enable_dauth_def_timeout} seconds (set by parameter)" fi printf "%s\n" "#define MHD_DAUTH_DEF_TIMEOUT_ ${enable_dauth_def_timeout}" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${enable_dauth_def_timeout_MSG}" >&5 printf "%s\n" "${enable_dauth_def_timeout_MSG}" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Digest Authentication default maximum nc value" >&5 printf %s "checking for Digest Authentication default maximum nc value... " >&6; } # Check whether --enable-dauth-def-max-nc was given. if test ${enable_dauth_def_max_nc+y} then : enableval=$enable_dauth_def_max_nc; enable_dauth_def_max_nc="${enableval}" else $as_nop enable_dauth_def_max_nc="" fi if test "x$enable_dauth_def_max_nc" = x"no" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Default Diget Auth maximum nc cannot be disabled, --disable-dauth-def-max-nc parameter is ignored" >&5 printf "%s\n" "$as_me: WARNING: Default Diget Auth maximum nc cannot be disabled, --disable-dauth-def-max-nc parameter is ignored" >&2;} enable_dauth_def_max_nc="" fi if test -z "${enable_dauth_def_max_nc}" then : enable_dauth_def_max_nc="1000" enable_dauth_def_max_nc_MSG="${enable_dauth_def_max_nc} (default)" else $as_nop if test "x${enable_dauth_def_max_nc}" = "x`echo ${enable_dauth_def_max_nc}|${SED-sed} 's/[^0-9]//g'`" && \ test "${enable_dauth_def_max_nc}" -ge "0" 2>/dev/null then : : else $as_nop as_fn_error $? "Invalid parameter --enable-dauth-def-max-nc=${enable_dauth_def_max_nc}. The value must be a positive integer." "$LINENO" 5 fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { static int arr[((int) 2) - 4 * (int)(${enable_dauth_def_max_nc} != ((uint32_t)${enable_dauth_def_max_nc}))]; (void) arr; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop as_fn_error $? "The value specified by --enable-dauth-def-max-nc=${enable_dauth_def_max_nc} is too large." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext enable_dauth_def_max_nc_MSG="${enable_dauth_def_max_nc} (set by parameter)" fi printf "%s\n" "#define MHD_DAUTH_DEF_MAX_NC_ ${enable_dauth_def_max_nc}" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${enable_dauth_def_max_nc_MSG}" >&5 printf "%s\n" "${enable_dauth_def_max_nc_MSG}" >&6; } dauth_defs_MSG="timeout: ${enable_dauth_def_timeout_MSG}, max nc: ${enable_dauth_def_max_nc_MSG}" else $as_nop dauth_defs_MSG="N/A" fi if test "x$enable_bauth" != "xno" || test "x$enable_dauth" != "xno"; then HAVE_ANYAUTH_TRUE= HAVE_ANYAUTH_FALSE='#' else HAVE_ANYAUTH_TRUE='#' HAVE_ANYAUTH_FALSE= fi # optional: HTTP "Upgrade" support. Enabled by default { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to support HTTP \"Upgrade\"" >&5 printf %s "checking whether to support HTTP \"Upgrade\"... " >&6; } # Check whether --enable-httpupgrade was given. if test ${enable_httpupgrade+y} then : enableval=$enable_httpupgrade; if test "x$enable_httpupgrade" = x"no" then : else $as_nop enable_httpupgrade='yes' fi else $as_nop enable_httpupgrade='yes' fi if test "x$enable_httpupgrade" = x"yes" then : printf "%s\n" "#define UPGRADE_SUPPORT 1" >>confdefs.h fi if test "x$enable_httpupgrade" = "xyes"; then ENABLE_UPGRADE_TRUE= ENABLE_UPGRADE_FALSE='#' else ENABLE_UPGRADE_TRUE='#' ENABLE_UPGRADE_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_httpupgrade" >&5 printf "%s\n" "$enable_httpupgrade" >&6; } # optional: HTTP cookie parsing support. Enabled by default { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to support HTTP cookie parsing" >&5 printf %s "checking whether to support HTTP cookie parsing... " >&6; } # Check whether --enable-cookie was given. if test ${enable_cookie+y} then : enableval=$enable_cookie; if test "x$enable_cookie" = x"no" then : else $as_nop enable_cookie='yes' fi else $as_nop enable_cookie='yes' fi if test "x$enable_cookie" = x"yes" then : printf "%s\n" "#define COOKIE_SUPPORT 1" >>confdefs.h fi if test "x$enable_cookie" = "xyes"; then ENABLE_COOKIE_TRUE= ENABLE_COOKIE_FALSE='#' else ENABLE_COOKIE_TRUE='#' ENABLE_COOKIE_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_cookie" >&5 printf "%s\n" "$enable_cookie" >&6; } # optional: MD5 support for Digest Auth. Enabled by default. # Check whether --enable-md5 was given. if test ${enable_md5+y} then : enableval=$enable_md5; if test "x$enable_md5" = x"internal" then : enable_md5='builtin' fi if test "x$enable_md5" = x"built-in" then : enable_md5='builtin' fi if test "x$enable_dauth" = x"yes" then : else $as_nop if test "x$enable_md5" = x"no" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: The parameter --enable-md5=${enable_md5} is ignored as Digest Authentication is disabled" >&5 printf "%s\n" "$as_me: WARNING: The parameter --enable-md5=${enable_md5} is ignored as Digest Authentication is disabled" >&2;} enable_md5='no' fi fi else $as_nop enable_md5="${enable_dauth}" fi case ${enable_md5} in #( yes|tlslib) : if test "x${enable_compact_code}" != "xno" || test "x$enable_md5" = "xtlslib" then : if test "x$enable_https" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether GnuTLS supports MD5 hashing" >&5 printf %s "checking whether GnuTLS supports MD5 hashing... " >&6; } if test ${mhd_cv_gnutls_md5+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${GNUTLS_CFLAGS} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${MHD_TLS_LIB_CPPFLAGS} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${MHD_TLS_LIB_CFLAGS} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${MHD_TLS_LIB_LDFLAGS} ${user_LDFLAGS}" save_LIBS="$LIBS" LIBS="${MHD_TLS_LIBDEPS} ${LIBS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { gnutls_hash_hd_t hash_handle; unsigned char digest[16]; int exit_code; if (0 == gnutls_hash_init(&hash_handle, GNUTLS_DIG_MD5)) { if (0 == gnutls_hash(hash_handle, "", 1)) { gnutls_hash_output(hash_handle, digest); if (0x93 == digest[0]) exit_code = 0; else exit_code = 7; } else exit_code = 5; gnutls_hash_deinit(hash_handle, (void *)0); } else exit_code = 2; if (exit_code) return exit_code; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_gnutls_md5='yes' else $as_nop mhd_cv_gnutls_md5='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="${save_LIBS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_gnutls_md5" >&5 printf "%s\n" "$mhd_cv_gnutls_md5" >&6; } if test "x$mhd_cv_gnutls_md5" = x"no" then : if test "x$enable_md5" = x"tlslib" then : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "TLS library MD5 implementation is not available See \`config.log' for more details" "$LINENO" 5; } fi enable_md5="builtin" else $as_nop enable_md5="tlslib" fi else $as_nop if test "x$enable_md5" = x"tlslib" then : as_fn_error $? "HTTPS is not enabled, TLS library MD5 implementation cannot be used" "$LINENO" 5 fi enable_md5="builtin" fi else $as_nop enable_md5="builtin" fi ;; #( *) : ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to support MD5" >&5 printf %s "checking whether to support MD5... " >&6; } { enable_md5_MSG=; unset enable_md5_MSG;} case ${enable_md5} in #( builtin) : enable_md5_MSG='yes, built-in' ;; #( tlslib) : enable_md5_MSG='yes, external (TLS library)' ;; #( no) : enable_md5_MSG='no' ;; #( yes) : as_fn_error $? "configure internal error: unexpected variable value" "$LINENO" 5 ;; #( *) : as_fn_error $? "Unrecognized parameter --enable-md5=${enable_md5}" "$LINENO" 5 ;; esac if test "x${enable_md5}" = "xbuiltin" || test "x${enable_md5}" = "xtlslib" then : printf "%s\n" "#define MHD_MD5_SUPPORT 1" >>confdefs.h fi if test "x${enable_md5}" = "xtlslib" then : printf "%s\n" "#define MHD_MD5_TLSLIB 1" >>confdefs.h fi if test "x${enable_md5}" = "xbuiltin" || test "x${enable_md5}" = "xtlslib" ; then ENABLE_MD5_TRUE= ENABLE_MD5_FALSE='#' else ENABLE_MD5_TRUE='#' ENABLE_MD5_FALSE= fi if test "x${enable_md5}" = "xtlslib" ; then ENABLE_MD5_EXT_TRUE= ENABLE_MD5_EXT_FALSE='#' else ENABLE_MD5_EXT_TRUE='#' ENABLE_MD5_EXT_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${enable_md5_MSG}" >&5 printf "%s\n" "${enable_md5_MSG}" >&6; } # optional: SHA-256 support for Digest Auth. Enabled by default. # Check whether --enable-sha256 was given. if test ${enable_sha256+y} then : enableval=$enable_sha256; if test "x$enable_sha256" = x"internal" then : enable_sha256='builtin' fi if test "x$enable_sha256" = x"built-in" then : enable_sha256='builtin' fi if test "x$enable_dauth" = x"yes" then : else $as_nop if test "x$enable_sha256" = x"no" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: The parameter --enable-sha256=${enable_sha256} is ignored as Digest Authentication is disabled" >&5 printf "%s\n" "$as_me: WARNING: The parameter --enable-sha256=${enable_sha256} is ignored as Digest Authentication is disabled" >&2;} enable_sha256='no' fi fi else $as_nop enable_sha256="${enable_dauth}" fi case ${enable_sha256} in #( yes|tlslib) : if test "x${enable_compact_code}" != "xno" || test "x$enable_sha256" = "xtlslib" then : if test "x$enable_https" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether GnuTLS supports sha256 hashing" >&5 printf %s "checking whether GnuTLS supports sha256 hashing... " >&6; } if test ${mhd_cv_gnutls_sha256+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${GNUTLS_CFLAGS} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${MHD_TLS_LIB_CPPFLAGS} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${MHD_TLS_LIB_CFLAGS} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${MHD_TLS_LIB_LDFLAGS} ${user_LDFLAGS}" save_LIBS="$LIBS" LIBS="${MHD_TLS_LIBDEPS} ${LIBS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { gnutls_hash_hd_t hash_handle; unsigned char digest[32]; int exit_code; if (0 == gnutls_hash_init(&hash_handle, GNUTLS_DIG_SHA256)) { if (0 == gnutls_hash(hash_handle, "", 1)) { gnutls_hash_output(hash_handle, digest); if (0x6e == digest[0]) exit_code = 0; else exit_code = 7; } else exit_code = 5; gnutls_hash_deinit(hash_handle, (void *)0); } else exit_code = 2; if (exit_code) return exit_code; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_gnutls_sha256='yes' else $as_nop mhd_cv_gnutls_sha256='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="${save_LIBS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_gnutls_sha256" >&5 printf "%s\n" "$mhd_cv_gnutls_sha256" >&6; } if test "x$mhd_cv_gnutls_sha256" = x"no" then : if test "x$enable_sha256" = x"tlslib" then : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "TLS library SHA-256 implementation is not available See \`config.log' for more details" "$LINENO" 5; } fi enable_sha256="builtin" else $as_nop enable_sha256="tlslib" fi else $as_nop if test "x$enable_sha256" = x"tlslib" then : as_fn_error $? "HTTPS is not enabled, TLS library SHA-256 implementation cannot be used" "$LINENO" 5 fi enable_sha256="builtin" fi else $as_nop enable_sha256="builtin" fi ;; #( *) : ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to support SHA-256" >&5 printf %s "checking whether to support SHA-256... " >&6; } { enable_sha256_MSG=; unset enable_sha256_MSG;} case ${enable_sha256} in #( builtin) : enable_sha256_MSG='yes, built-in' ;; #( tlslib) : enable_sha256_MSG='yes, external (TLS library)' ;; #( no) : enable_sha256_MSG='no' ;; #( yes) : as_fn_error $? "configure internal error: unexpected variable value" "$LINENO" 5 ;; #( *) : as_fn_error $? "Unrecognized parameter --enable-sha256=${enable_sha256}" "$LINENO" 5 ;; esac if test "x${enable_sha256}" = "xbuiltin" || test "x${enable_sha256}" = "xtlslib" then : printf "%s\n" "#define MHD_SHA256_SUPPORT 1" >>confdefs.h fi if test "x${enable_sha256}" = "xtlslib" then : printf "%s\n" "#define MHD_SHA256_TLSLIB 1" >>confdefs.h fi if test "x${enable_sha256}" = "xbuiltin" || test "x${enable_sha256}" = "xtlslib" ; then ENABLE_SHA256_TRUE= ENABLE_SHA256_FALSE='#' else ENABLE_SHA256_TRUE='#' ENABLE_SHA256_FALSE= fi if test "x${enable_sha256}" = "xtlslib" ; then ENABLE_SHA256_EXT_TRUE= ENABLE_SHA256_EXT_FALSE='#' else ENABLE_SHA256_EXT_TRUE='#' ENABLE_SHA256_EXT_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${enable_sha256_MSG}" >&5 printf "%s\n" "${enable_sha256_MSG}" >&6; } # optional: SHA-512/256 support for Digest Auth. Enabled by default. # Check whether --enable-sha512-256 was given. if test ${enable_sha512_256+y} then : enableval=$enable_sha512_256; if test "x$enable_sha512_256" = x"yes" then : if test "x$enable_dauth" = x"yes" then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: The parameter --enable-sha512-256 is ignored as Digest Authentication is disabled" >&5 printf "%s\n" "$as_me: WARNING: The parameter --enable-sha512-256 is ignored as Digest Authentication is disabled" >&2;} enable_sha512_256='no' fi else $as_nop enable_sha512_256='no' fi else $as_nop enable_sha512_256="${enable_dauth}" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to support SHA-512/256" >&5 printf %s "checking whether to support SHA-512/256... " >&6; } { enable_sha512_256_MSG=; unset enable_sha512_256_MSG;} case ${enable_sha512_256} in #( yes) : enable_sha512_256_MSG='yes, built-in' ;; #( no) : enable_sha512_256_MSG='no' ;; #( *) : as_fn_error $? "Unrecognized parameter --enable-sha512-256=${enable_sha512_256}" "$LINENO" 5 ;; esac if test "x$enable_sha512_256" = x"yes" then : printf "%s\n" "#define MHD_SHA512_256_SUPPORT 1" >>confdefs.h fi if test "x${enable_sha512_256}" = "xyes"; then ENABLE_SHA512_256_TRUE= ENABLE_SHA512_256_FALSE='#' else ENABLE_SHA512_256_TRUE='#' ENABLE_SHA512_256_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${enable_sha512_256_MSG}" >&5 printf "%s\n" "${enable_sha512_256_MSG}" >&6; } if test "x$enable_dauth" != "xno" then : if test "x${enable_md5}" = "xno" && test "x${enable_sha256}" = "xno" && test "x${enable_sha512_256}" != "xyes" then : as_fn_error $? "At least one hashing algorithm must be enabled if Digest Auth is enabled" "$LINENO" 5 fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for calloc()" >&5 printf %s "checking for calloc()... " >&6; } if test ${mhd_cv_have_func_calloc+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { void * ptr = calloc(1, 2); if (ptr) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_have_func_calloc='yes' else $as_nop mhd_cv_have_func_calloc='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_have_func_calloc" >&5 printf "%s\n" "$mhd_cv_have_func_calloc" >&6; } if test "x$mhd_cv_have_func_calloc" = x"yes" then : printf "%s\n" "#define HAVE_CALLOC 1" >>confdefs.h fi # Some systems have IPv6 disabled in kernel at run-time if test "x${mhd_cv_have_inet6}" = "xyes" && test "x${cross_compiling}" = "xno" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether IPv6 could be used for testing" >&5 printf %s "checking whether IPv6 could be used for testing... " >&6; } if test ${mhd_cv_ipv6_for_testing+y} then : printf %s "(cached) " >&6 else $as_nop if test "$cross_compiling" = yes then : mhd_cv_ipv6_for_testing="no" else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NETINET_IP_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #ifdef HAVE_NETINET_TCP_H #include #endif static void zr_mem(void *ptr, socklen_t size) { char *mem = ptr; while(size--) {mem[0] = 0; mem++;} } int main(void) { int ret = 30; struct sockaddr_in6 sa; #if !defined(_WIN32) || defined(__CYGWIN__) int sckt; const int invld_sckt = -1; #else SOCKET sckt; const SOCKET invld_sckt = INVALID_SOCKET; WSADATA wsa_data; WSAStartup(MAKEWORD(2, 2), &wsa_data); #endif zr_mem(&sa, sizeof(sa)); sa.sin6_family = AF_INET6; sa.sin6_port = 0; sa.sin6_addr = in6addr_loopback; #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN sa.sin6_len = sizeof(sa); #endif sckt = socket (PF_INET6, SOCK_STREAM, 0); if (invld_sckt != sckt) { if (0 == bind (sckt, (struct sockaddr *)&sa, sizeof(sa))) { if (0 == listen (sckt, 1)) ret = 0; else ret = 1; /* listen() failed */ } else ret = 2; /* bind() failed */ #if !defined(_WIN32) || defined(__CYGWIN__) close (sckt); #else closesocket (sckt); #endif } else ret = 3; /* socket() failed */ #if defined(_WIN32) && !defined(__CYGWIN__) WSACleanup(); #endif return ret; } _ACEOF if ac_fn_c_try_run "$LINENO" then : mhd_cv_ipv6_for_testing="yes" else $as_nop mhd_cv_ipv6_for_testing="no" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_ipv6_for_testing" >&5 printf "%s\n" "$mhd_cv_ipv6_for_testing" >&6; } fi if test "x$mhd_cv_ipv6_for_testing" = x"yes" then : printf "%s\n" "#define USE_IPV6_TESTING 1" >>confdefs.h fi if test "x$enable_tools" = x"yes" then : ac_fn_c_check_header_compile "$LINENO" "features.h" "ac_cv_header_features_h" "$ac_includes_default " if test "x$ac_cv_header_features_h" = xyes then : printf "%s\n" "#define HAVE_FEATURES_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/pstat.h" "ac_cv_header_sys_pstat_h" "$ac_includes_default " if test "x$ac_cv_header_sys_pstat_h" = xyes then : printf "%s\n" "#define HAVE_SYS_PSTAT_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "vxCpuLib.h" "ac_cv_header_vxCpuLib_h" "$ac_includes_default " if test "x$ac_cv_header_vxCpuLib_h" = xyes then : printf "%s\n" "#define HAVE_VXCPULIB_H 1" >>confdefs.h fi ac_fn_check_decl "$LINENO" "_SC_NPROCESSORS_ONLN" "ac_cv_have_decl__SC_NPROCESSORS_ONLN" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl__SC_NPROCESSORS_ONLN" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL__SC_NPROCESSORS_ONLN $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "_SC_NPROC_ONLN" "ac_cv_have_decl__SC_NPROC_ONLN" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl__SC_NPROC_ONLN" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL__SC_NPROC_ONLN $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "_SC_CRAY_NCPU" "ac_cv_have_decl__SC_CRAY_NCPU" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl__SC_CRAY_NCPU" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL__SC_CRAY_NCPU $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "_SC_NPROCESSORS_CONF" "ac_cv_have_decl__SC_NPROCESSORS_CONF" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl__SC_NPROCESSORS_CONF" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL__SC_NPROCESSORS_CONF $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "CTL_HW" "ac_cv_have_decl_CTL_HW" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_CTL_HW" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_CTL_HW $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "HW_NCPUONLINE" "ac_cv_have_decl_HW_NCPUONLINE" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_HW_NCPUONLINE" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_HW_NCPUONLINE $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "HW_NCPU" "ac_cv_have_decl_HW_NCPU" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_HW_NCPU" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_HW_NCPU $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "HW_AVAILCPU" "ac_cv_have_decl_HW_AVAILCPU" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_HW_AVAILCPU" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_HW_AVAILCPU $ac_have_decl" >>confdefs.h # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_pstat_getdynamic+y} then : else $as_nop ac_fn_check_decl "$LINENO" "pstat_getdynamic" "ac_cv_have_decl_pstat_getdynamic" " #include #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_pstat_getdynamic" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function pstat_getdynamic" >&5 printf %s "checking for function pstat_getdynamic... " >&6; } if test ${mhd_cv_func_pstat_getdynamic+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_pstat_getdynamic" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { struct pst_dynamic psd_data; if (1 != pstat_getdynamic(&psd_data, sizeof(psd_data), (size_t)1, 0)) return 2; if (0 >= psd_data.psd_proc_cnt) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_pstat_getdynamic="yes" else $as_nop mhd_cv_func_pstat_getdynamic="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_pstat_getdynamic="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_pstat_getdynamic" >&5 printf "%s\n" "$mhd_cv_func_pstat_getdynamic" >&6; } if test "x$mhd_cv_func_pstat_getdynamic" = x"yes" then : printf "%s\n" "#define HAVE_PSTAT_GETDYNAMIC 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_vxCpuEnabledGet+y} then : else $as_nop ac_fn_check_decl "$LINENO" "vxCpuEnabledGet" "ac_cv_have_decl_vxCpuEnabledGet" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_vxCpuEnabledGet" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function vxCpuEnabledGet" >&5 printf %s "checking for function vxCpuEnabledGet... " >&6; } if test ${mhd_cv_func_vxCpuEnabledGet+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_vxCpuEnabledGet" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { cpuset_t enb_set; enb_set = vxCpuEnabledGet(); (void) enb_set; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_vxCpuEnabledGet="yes" else $as_nop mhd_cv_func_vxCpuEnabledGet="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_vxCpuEnabledGet="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_vxCpuEnabledGet" >&5 printf "%s\n" "$mhd_cv_func_vxCpuEnabledGet" >&6; } if test "x$mhd_cv_func_vxCpuEnabledGet" = x"yes" then : printf "%s\n" "#define HAVE_VXCPUENABLEDGET 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here ac_fn_c_check_header_compile "$LINENO" "sched.h" "ac_cv_header_sched_h" "$ac_includes_default " if test "x$ac_cv_header_sched_h" = xyes then : printf "%s\n" "#define HAVE_SCHED_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/_cpuset.h" "ac_cv_header_sys__cpuset_h" "$ac_includes_default " if test "x$ac_cv_header_sys__cpuset_h" = xyes then : printf "%s\n" "#define HAVE_SYS__CPUSET_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/cpuset.h" "ac_cv_header_sys_cpuset_h" "$ac_includes_default " if test "x$ac_cv_header_sys_cpuset_h" = xyes then : printf "%s\n" "#define HAVE_SYS_CPUSET_H 1" >>confdefs.h fi # glibc / Linux kernel # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_getpid+y} then : else $as_nop ac_fn_check_decl "$LINENO" "getpid" "ac_cv_have_decl_getpid" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_getpid" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function getpid" >&5 printf %s "checking for function getpid... " >&6; } if test ${mhd_cv_func_getpid+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_getpid" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #include int main(void) { pid_t cur_pid; cur_pid = getpid(); (void) &cur_pid; /* Mute possible warning */ return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_getpid="yes" else $as_nop mhd_cv_func_getpid="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_getpid="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_getpid" >&5 printf "%s\n" "$mhd_cv_func_getpid" >&6; } if test "x$mhd_cv_func_getpid" = x"yes" then : printf "%s\n" "#define HAVE_GETPID 1" >>confdefs.h # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_sched_getaffinity+y} then : else $as_nop ac_fn_check_decl "$LINENO" "sched_getaffinity" "ac_cv_have_decl_sched_getaffinity" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #include #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_sched_getaffinity" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function sched_getaffinity" >&5 printf %s "checking for function sched_getaffinity... " >&6; } if test ${mhd_cv_func_sched_getaffinity+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_sched_getaffinity" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #include #include int main(void) { cpu_set_t cur_set; if (0 != sched_getaffinity(getpid(), sizeof(cur_set), &cur_set)) return 2; if (0 == CPU_SET (0, &cur_set)) return 3; /* Actually this could be a valid result */ return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_sched_getaffinity="yes" else $as_nop mhd_cv_func_sched_getaffinity="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_sched_getaffinity="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_sched_getaffinity" >&5 printf "%s\n" "$mhd_cv_func_sched_getaffinity" >&6; } if test "x$mhd_cv_func_sched_getaffinity" = x"yes" then : printf "%s\n" "#define HAVE_SCHED_GETAFFINITY 1" >>confdefs.h # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_CPU_COUNT+y} then : else $as_nop ac_fn_check_decl "$LINENO" "CPU_COUNT" "ac_cv_have_decl_CPU_COUNT" " #include #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_CPU_COUNT" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function CPU_COUNT" >&5 printf %s "checking for function CPU_COUNT... " >&6; } if test ${mhd_cv_func_CPU_COUNT+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_CPU_COUNT" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { cpu_set_t cur_set; CPU_ZERO(&cur_set); if (0 != CPU_COUNT(&cur_set)) return 2; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_CPU_COUNT="yes" else $as_nop mhd_cv_func_CPU_COUNT="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_CPU_COUNT="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_CPU_COUNT" >&5 printf "%s\n" "$mhd_cv_func_CPU_COUNT" >&6; } if test "x$mhd_cv_func_CPU_COUNT" = x"yes" then : printf "%s\n" "#define HAVE_CPU_COUNT 1" >>confdefs.h # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_CPU_COUNT_S+y} then : else $as_nop ac_fn_check_decl "$LINENO" "CPU_COUNT_S" "ac_cv_have_decl_CPU_COUNT_S" " #include #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_CPU_COUNT_S" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function CPU_COUNT_S" >&5 printf %s "checking for function CPU_COUNT_S... " >&6; } if test ${mhd_cv_func_CPU_COUNT_S+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_CPU_COUNT_S" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { static const unsigned int set_size_cpus = 2048u; const size_t set_size_bytes = (size_t) CPU_ALLOC_SIZE(set_size_cpus); cpu_set_t *p_set; p_set = CPU_ALLOC(set_size_cpus); if (!p_set) return 2; CPU_ZERO_S(set_size_bytes, p_set); if (0 != CPU_COUNT_S(set_size_bytes, p_set)) { CPU_FREE(p_set); return 3; } CPU_FREE(p_set); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_CPU_COUNT_S="yes" else $as_nop mhd_cv_func_CPU_COUNT_S="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_CPU_COUNT_S="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_CPU_COUNT_S" >&5 printf "%s\n" "$mhd_cv_func_CPU_COUNT_S" >&6; } if test "x$mhd_cv_func_CPU_COUNT_S" = x"yes" then : printf "%s\n" "#define HAVE_CPU_COUNT_S 1" >>confdefs.h ac_fn_check_decl "$LINENO" "CPU_SETSIZE" "ac_cv_have_decl_CPU_SETSIZE" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_CPU_SETSIZE" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_CPU_SETSIZE $ac_have_decl" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here fi # Expansion of MHD_CHECK_FUNC macro ends here fi # Expansion of MHD_CHECK_FUNC macro ends here # NetBSD # Should work only with -lrt, but actually works without it. # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_sched_getaffinity_np+y} then : else $as_nop ac_fn_check_decl "$LINENO" "sched_getaffinity_np" "ac_cv_have_decl_sched_getaffinity_np" " #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #include #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_sched_getaffinity_np" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function sched_getaffinity_np" >&5 printf %s "checking for function sched_getaffinity_np... " >&6; } if test ${mhd_cv_func_sched_getaffinity_np+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_sched_getaffinity_np" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #include #include int main(void) { cpuset_t *cpuset_ptr; cpuid_t cpu_num = 0; cpuset_ptr = cpuset_create(); if (!cpuset_ptr) return 2; if (0 != sched_getaffinity_np(getpid(), cpuset_size(cpuset_ptr), cpuset_ptr)) { cpuset_destroy(cpuset_ptr); return 3; } if (0 >= cpuset_isset(cpu_num, cpuset_ptr)) { cpuset_destroy(cpuset_ptr); return 4; /* Actually this could be a valid result */ } cpuset_destroy(cpuset_ptr); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_sched_getaffinity_np="yes" else $as_nop mhd_cv_func_sched_getaffinity_np="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_sched_getaffinity_np="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_sched_getaffinity_np" >&5 printf "%s\n" "$mhd_cv_func_sched_getaffinity_np" >&6; } if test "x$mhd_cv_func_sched_getaffinity_np" = x"yes" then : printf "%s\n" "#define HAVE_SCHED_GETAFFINITY_NP 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here fi # Expansion of MHD_CHECK_FUNC macro ends here # FreeBSD # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_cpuset_getaffinity+y} then : else $as_nop ac_fn_check_decl "$LINENO" "cpuset_getaffinity" "ac_cv_have_decl_cpuset_getaffinity" " #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_cpuset_getaffinity" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function cpuset_getaffinity" >&5 printf %s "checking for function cpuset_getaffinity... " >&6; } if test ${mhd_cv_func_cpuset_getaffinity+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_cpuset_getaffinity" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #include int main(void) { cpuset_t cur_mask; if (0 != cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, (id_t) -1, sizeof(cur_mask), &cur_mask)) return 2; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_cpuset_getaffinity="yes" else $as_nop mhd_cv_func_cpuset_getaffinity="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_cpuset_getaffinity="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_cpuset_getaffinity" >&5 printf "%s\n" "$mhd_cv_func_cpuset_getaffinity" >&6; } if test "x$mhd_cv_func_cpuset_getaffinity" = x"yes" then : printf "%s\n" "#define HAVE_CPUSET_GETAFFINITY 1" >>confdefs.h # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_CPU_COUNT+y} then : else $as_nop ac_fn_check_decl "$LINENO" "CPU_COUNT" "ac_cv_have_decl_CPU_COUNT" " #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS__CPUSET_H #include #endif /* HAVE_SYS_PARAM_H */ #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_CPU_COUNT" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function CPU_COUNT" >&5 printf %s "checking for function CPU_COUNT... " >&6; } if test ${mhd_cv_func_CPU_COUNT+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_CPU_COUNT" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS__CPUSET_H #include #endif /* HAVE_SYS_PARAM_H */ #include int main(void) { cpuset_t test_mask; CPU_ZERO(&test_mask); if (0 != CPU_COUNT(&test_mask)) return 2; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_CPU_COUNT="yes" else $as_nop mhd_cv_func_CPU_COUNT="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_CPU_COUNT="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_CPU_COUNT" >&5 printf "%s\n" "$mhd_cv_func_CPU_COUNT" >&6; } if test "x$mhd_cv_func_CPU_COUNT" = x"yes" then : printf "%s\n" "#define HAVE_CPU_COUNT 1" >>confdefs.h # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func_CPU_COUNT_S+y} then : else $as_nop ac_fn_check_decl "$LINENO" "CPU_COUNT_S" "ac_cv_have_decl_CPU_COUNT_S" " #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS__CPUSET_H #include #endif /* HAVE_SYS_PARAM_H */ #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_CPU_COUNT_S" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function CPU_COUNT_S" >&5 printf %s "checking for function CPU_COUNT_S... " >&6; } if test ${mhd_cv_func_CPU_COUNT_S+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl_CPU_COUNT_S" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS__CPUSET_H #include #endif /* HAVE_SYS_PARAM_H */ #include int main(void) { static const unsigned int max_cpu_num = 2048u; cpuset_t *mask_ptr; mask_ptr = CPU_ALLOC(max_cpu_num); if (! mask_ptr) return 2; if (0 != cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, (id_t) -1, CPU_ALLOC_SIZE(max_cpu_num), mask_ptr)) { CPU_FREE(mask_ptr); return 3; } if (0 == CPU_COUNT_S(CPU_ALLOC_SIZE(max_cpu_num), &test_mask)) { CPU_FREE(mask_ptr); return 4; } CPU_FREE(mask_ptr); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func_CPU_COUNT_S="yes" else $as_nop mhd_cv_func_CPU_COUNT_S="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func_CPU_COUNT_S="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_CPU_COUNT_S" >&5 printf "%s\n" "$mhd_cv_func_CPU_COUNT_S" >&6; } if test "x$mhd_cv_func_CPU_COUNT_S" = x"yes" then : printf "%s\n" "#define HAVE_CPU_COUNT_S 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here fi # Expansion of MHD_CHECK_FUNC macro ends here fi # Expansion of MHD_CHECK_FUNC macro ends here if test "x$mhd_cv_func_CPU_COUNT_S" = x"yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether CPU_COUNT_S() expects max CPU number as 'size' parameter" >&5 printf %s "checking whether CPU_COUNT_S() expects max CPU number as 'size' parameter... " >&6; } if test ${mhd_cv_func_cpu_count_s_cpus+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$cross-compiling" = x"yes" then : mhd_cv_func_cpu_count_s_cpus="assuming no" else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS__CPUSET_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_CPUSET_H #include #endif /* HAVE_SYS_CPUSET_H */ #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_SCHED_H #include #endif /* HAVE_SCHED_H */ #include #ifdef HAVE_SCHED_GETAFFINITY #define TEST_CPUSET_TYPE cpu_set_t #else /* ! HAVE_SCHED_GETAFFINITY */ #define TEST_CPUSET_TYPE cpuset_t #endif /* ! HAVE_SCHED_GETAFFINITY */ int main (void) { TEST_CPUSET_TYPE *p_testset; /* The size of the cpuset that is larger then the test cpuset (in CPUs) */ static const unsigned int testset_size_oversized_cpus = (8 * sizeof(long)) * 1024; const size_t testset_size_oversized_bytes = CPU_ALLOC_SIZE(testset_size_oversized_cpus); /* The size of the test cpuset in number of CPUs */ const unsigned int testset_size_cpus = (unsigned int) testset_size_oversized_bytes; /* The size of the test cpuset in bytes */ const size_t testset_size_bytes = CPU_ALLOC_SIZE(testset_size_cpus); /* The last one CPU in the test set */ const unsigned int test_cpu_num1 = testset_size_cpus - 1; /* The penultimate CPU in the test set */ const unsigned int test_cpu_num2 = testset_size_cpus - 2; /* The CPU numbers that should be cleared */ const unsigned int test_cpu_clear1 = testset_size_cpus - 3; const unsigned int test_cpu_clear2 = testset_size_cpus - 4; unsigned int count_res; int ret = 0; /* Allocate oversize area to ensure that memory outside the buffer is not used */ p_testset = CPU_ALLOC(testset_size_oversized_cpus); if (! p_testset) { fprintf (stderr, "Error allocating memory.\n"); return 99; } /* Set the some CPU numbers and then clear them */ CPU_SET_S(test_cpu_clear1, testset_size_bytes, p_testset); CPU_SET_S(test_cpu_clear2, testset_size_bytes, p_testset); CPU_ZERO_S(testset_size_bytes, p_testset); /* Set two CPUs on */ CPU_SET_S(test_cpu_num1, testset_size_bytes, p_testset); CPU_SET_S(test_cpu_num2, testset_size_bytes, p_testset); count_res = (unsigned int) CPU_COUNT_S(testset_size_bytes, p_testset); if (0 == count_res) { fprintf (stderr, "Full cpuset cannot be read by CPU_COUNT_S() when using the number of bytes as the size parameter.\n"); /* Set the some CPU numbers and then clear them */ CPU_SET_S(test_cpu_clear1, testset_size_cpus, p_testset); CPU_SET_S(test_cpu_clear2, testset_size_cpus, p_testset); CPU_ZERO_S(testset_size_cpus, p_testset); /* Set two CPUs on */ CPU_SET_S(test_cpu_num1, testset_size_cpus, p_testset); CPU_SET_S(test_cpu_num2, testset_size_cpus, p_testset); count_res = (unsigned int) CPU_COUNT_S(testset_size_cpus, p_testset); if (2 == count_res) { fprintf (stderr, "Full cpuset is read by CPU_COUNT_S() only when using the maximum CPU number as the size parameter.\n"); ret = 3; } else { fprintf (stderr, "Wrong result returned by CPU_COUNT_S() when using the maximum CPU number as the size parameter.\n"); fprintf (stderr, "Number of 'enabled' CPUs: 2\n"); fprintf (stderr, "Number of counted CPUs: %u\n", count_res); fprintf (stderr, "CPU_COUNT_S() could be unreliable.\n"); ret = 70; } } else if (2 == count_res) { fprintf (stderr, "Full cpuset is read by CPU_COUNT_S() when using the number of bytes as the size parameter.\n"); } else { fprintf (stderr, "Wrong result returned by CPU_COUNT_S() when using the number of bytes as the size parameter.\n"); fprintf (stderr, "Number of 'enabled' CPUs: 2\n"); fprintf (stderr, "Number of counted CPUs: %u\n", count_res); fprintf (stderr, "CPU_COUNT_S() could be unreliable.\n"); ret = 71; } CPU_FREE(p_testset); if (0 != ret) return ret; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { echo "$as_me:$LINENO: ./conftest$EXEEXT" >&5 (./conftest$EXEEXT) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } count_test_res=$? if test $count_test_res -eq 0 then : mhd_cv_func_cpu_count_s_cpus="no" elif test $count_test_res -eq 3 then : mhd_cv_func_cpu_count_s_cpus="yes" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Unexpected value returned by CPU_COUNT_S() test program. Please report to ${PACKAGE_BUGREPORT}" >&5 printf "%s\n" "$as_me: WARNING: Unexpected value returned by CPU_COUNT_S() test program. Please report to ${PACKAGE_BUGREPORT}" >&2;} mhd_cv_func_cpu_count_s_cpus="assuming no" fi else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Cannot build CPU_COUNT_S() test program. Please report to ${PACKAGE_BUGREPORT}" >&5 printf "%s\n" "$as_me: WARNING: Cannot build CPU_COUNT_S() test program. Please report to ${PACKAGE_BUGREPORT}" >&2;} mhd_cv_func_cpu_count_s_cpus="assuming no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_cpu_count_s_cpus" >&5 printf "%s\n" "$mhd_cv_func_cpu_count_s_cpus" >&6; } if test "x$mhd_cv_func_cpu_count_s_cpus" = x"yes" then : printf "%s\n" "#define MHD_FUNC_CPU_COUNT_S_GETS_CPUS 1" >>confdefs.h fi fi fi # Check for fork() and waitpid(). They are used for tests. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fork()" >&5 printf %s "checking for fork()... " >&6; } mhd_have_fork_waitpid='no' cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif int main (void) { pid_t p = fork (); if (0 == p) return 1; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_FORK 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for waitpid()" >&5 printf %s "checking for waitpid()... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #include int main (void) { pid_t p = fork (); if (0 == p) return 1; waitpid (p, (void*)0, 0) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_WAITPID 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } mhd_have_fork_waitpid='yes' else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test "x$mhd_have_fork_waitpid" = "xyes"; then HAVE_FORK_WAITPID_TRUE= HAVE_FORK_WAITPID_FALSE='#' else HAVE_FORK_WAITPID_TRUE='#' HAVE_FORK_WAITPID_FALSE= fi # gcov compilation { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to compile with support for code coverage analysis" >&5 printf %s "checking whether to compile with support for code coverage analysis... " >&6; } # Check whether --enable-coverage was given. if test ${enable_coverage+y} then : enableval=$enable_coverage; use_gcov=${enableval} else $as_nop use_gcov=no fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $use_gcov" >&5 printf "%s\n" "$use_gcov" >&6; } if test "x$use_gcov" = "xyes"; then USE_COVERAGE_TRUE= USE_COVERAGE_FALSE='#' else USE_COVERAGE_TRUE='#' USE_COVERAGE_FALSE= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the number of available CPUs" >&5 printf %s "checking the number of available CPUs... " >&6; } CPU_COUNT="0" # Try generic methods # 'getconf' is POSIX utility, but '_NPROCESSORS_ONLN' and # 'NPROCESSORS_ONLN' are platform-specific command -v getconf >/dev/null 2>&1 && \ CPU_COUNT=`getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null` || CPU_COUNT="0" if test "$CPU_COUNT" -gt "0" 2>/dev/null || ! command -v nproc >/dev/null 2>&1 then : : # empty else $as_nop # 'nproc' is part of GNU Coreutils and is widely available CPU_COUNT=`OMP_NUM_THREADS='' nproc 2>/dev/null` || CPU_COUNT=`nproc 2>/dev/null` || CPU_COUNT="0" fi if test "$CPU_COUNT" -gt "0" 2>/dev/null then : : # empty else $as_nop # Try platform-specific preferred methods case $host_os in #( *linux*) : CPU_COUNT=`lscpu -p 2>/dev/null | $EGREP -e '^[0-9]+,' -c` || CPU_COUNT="0" ;; #( *darwin*) : CPU_COUNT=`sysctl -n hw.logicalcpu 2>/dev/null` || CPU_COUNT="0" ;; #( freebsd*) : command -v sysctl >/dev/null 2>&1 && CPU_COUNT=`sysctl -n kern.smp.cpus 2>/dev/null` || CPU_COUNT="0" ;; #( netbsd*) : command -v sysctl >/dev/null 2>&1 && CPU_COUNT=`sysctl -n hw.ncpuonline 2>/dev/null` || CPU_COUNT="0" ;; #( solaris*) : command -v psrinfo >/dev/null 2>&1 && CPU_COUNT=`psrinfo 2>/dev/null | $EGREP -e '^[0-9].*on-line' -c 2>/dev/null` || CPU_COUNT="0" ;; #( mingw*) : CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^[0-9]+/' -c` || CPU_COUNT="0" ;; #( msys*) : CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^[0-9]+/' -c` || CPU_COUNT="0" ;; #( cygwin*) : CPU_COUNT=`ls -qpU1 /proc/registry/HKEY_LOCAL_MACHINE/HARDWARE/DESCRIPTION/System/CentralProcessor/ 2>/dev/null | $EGREP -e '^[0-9]+/' -c` || CPU_COUNT="0" ;; #( *) : ;; esac fi if test "$CPU_COUNT" -gt "0" 2>/dev/null || ! command -v sysctl >/dev/null 2>&1 then : : # empty else $as_nop # Try less preferred generic method # 'hw.ncpu' exist on many platforms, but not on GNU/Linux CPU_COUNT=`sysctl -n hw.ncpu 2>/dev/null` || CPU_COUNT="0" fi if test "$CPU_COUNT" -gt "0" 2>/dev/null then : : # empty else $as_nop # Try platform-specific fallback methods # They can be less accurate and slower then preferred methods case $host_os in #( *linux*) : CPU_COUNT=`$EGREP -e '^processor' -c /proc/cpuinfo 2>/dev/null` || CPU_COUNT="0" ;; #( *darwin*) : CPU_COUNT=`system_profiler SPHardwareDataType 2>/dev/null | $EGREP -i -e 'number of cores:'|cut -d : -f 2 -s|tr -d ' '` || CPU_COUNT="0" ;; #( freebsd*) : CPU_COUNT=`dmesg 2>/dev/null| $EGREP -e '^cpu[0-9]+: '|sort -u|$EGREP -e '^' -c` || CPU_COUNT="0" ;; #( netbsd*) : CPU_COUNT=`command -v cpuctl >/dev/null 2>&1 && cpuctl list 2>/dev/null| $EGREP -e '^[0-9]+ .* online ' -c` || \ CPU_COUNT=`dmesg 2>/dev/null| $EGREP -e '^cpu[0-9]+ at'|sort -u|$EGREP -e '^' -c` || CPU_COUNT="0" ;; #( solaris*) : command -v kstat >/dev/null 2>&1 && CPU_COUNT=`kstat -m cpu_info -s state -p 2>/dev/null | $EGREP -c -e 'on-line'` || \ CPU_COUNT=`kstat -m cpu_info 2>/dev/null | $EGREP -c -e 'module: cpu_info'` || CPU_COUNT="0" ;; #( mingw*) : if CPU_COUNT=`reg query 'HKLM\\Hardware\\Description\\System\\CentralProcessor' 2>/dev/null | $EGREP -e '\\\\[0-9]+$' -c` then : : # empty else $as_nop test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS" fi ;; #( msys*) : test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS" ;; #( cygwin*) : test "$NUMBER_OF_PROCESSORS" -gt "0" 2>/dev/null && CPU_COUNT="$NUMBER_OF_PROCESSORS" ;; #( *) : ;; esac fi if test "x$CPU_COUNT" != "x0" && test "$CPU_COUNT" -gt 0 2>/dev/null then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPU_COUNT" >&5 printf "%s\n" "$CPU_COUNT" >&6; } else $as_nop CPU_COUNT="1" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unable to detect (assuming 1)" >&5 printf "%s\n" "unable to detect (assuming 1)" >&6; } fi MHD_REAL_CPU_COUNT=${CPU_COUNT} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for number of CPU cores to use in tests" >&5 printf %s "checking for number of CPU cores to use in tests... " >&6; } if test "x$use_heavy_tests" = x"yes" then : # Enable usage of many core if heavy tests are enabled if test "$CPU_COUNT" -gt "32" then : CPU_COUNT="32" fi else $as_nop # Limit usage to just a few cores if heavy tests are not enabled if test "$CPU_COUNT" -gt "6" then : CPU_COUNT="6" fi if test "$CPU_COUNT" -lt "2" then : CPU_COUNT="2" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPU_COUNT" >&5 printf "%s\n" "$CPU_COUNT" >&6; } # Check whether --enable-asserts was given. if test ${enable_asserts+y} then : enableval=$enable_asserts; else $as_nop enable_asserts='auto' fi { use_asserts_MSG=; unset use_asserts_MSG;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether NDEBUG macro is defined" >&5 printf %s "checking whether NDEBUG macro is defined... " >&6; } if test ${mhd_cv_macro_ndebug_def+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef NDEBUG #error NDEBUG is NOT defined chome me now #endif int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_macro_ndebug_def='yes' else $as_nop mhd_cv_macro_ndebug_def='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_ndebug_def" >&5 printf "%s\n" "$mhd_cv_macro_ndebug_def" >&6; } if test "x$enable_asserts" = x"yes" then : if test "x$mhd_cv_macro_ndebug_def" = x"yes" then : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Parameter --enable-asserts is specified, but NDEBUG macro is defined as well See \`config.log' for more details" "$LINENO" 5; } fi use_asserts_MSG="yes, enabled by configure parameter" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _DEBUG macro is defined" >&5 printf %s "checking whether _DEBUG macro is defined... " >&6; } if test ${mhd_cv_macro__debug_def+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef _DEBUG #error _DEBUG is NOT defined chome me now #endif int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_macro__debug_def='yes' else $as_nop mhd_cv_macro__debug_def='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro__debug_def" >&5 printf "%s\n" "$mhd_cv_macro__debug_def" >&6; } if test "x$enable_asserts" = x"no" then : if test "x$mhd_cv_macro__debug_def" = x"yes" then : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Parameter --disable-asserts is specified, but _DEBUG macro is defined as well See \`config.log' for more details" "$LINENO" 5; } fi use_asserts_MSG="no, set by configure parameter" fi if test "x${mhd_cv_macro_ndebug_def}" = "xyes" && test "x${mhd_cv_macro__debug_def}" = "xyes" then : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Both NDEBUG and _DEBUG macros are defined See \`config.log' for more details" "$LINENO" 5; } fi if test "x$enable_asserts" = x"auto" then : if test "x$mhd_cv_macro_ndebug_def" = x"yes" then : enable_asserts="no" use_asserts_MSG="no, set by NDEBUG preprocessor macro" fi fi if test "x$enable_asserts" = x"auto" then : if test "x$mhd_cv_macro__debug_def" = x"yes" then : enable_asserts="yes" use_asserts_MSG="yes, enabled by _DEBUG preprocessor macro" fi fi if test "x$enable_asserts" = x"auto" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether DEBUG macro is defined" >&5 printf %s "checking whether DEBUG macro is defined... " >&6; } if test ${mhd_cv_macro_debug_def+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef DEBUG #error DEBUG is NOT defined chome me now #endif int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_macro_debug_def='yes' else $as_nop mhd_cv_macro_debug_def='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_macro_debug_def" >&5 printf "%s\n" "$mhd_cv_macro_debug_def" >&6; } if test "x$mhd_cv_macro_debug_def" = x"yes" then : enable_asserts="yes" use_asserts_MSG="yes, enabled by DEBUG preprocessor macro" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable debug asserts" >&5 printf %s "checking whether to enable debug asserts... " >&6; } if test "x$enable_asserts" = x"auto" then : case ${enable_build_type} in #( debug|debugger) : enable_asserts="yes" use_asserts_MSG="yes, enabled by --enable-bulid-type=${enable_build_type}" ;; #( *) : enable_asserts="no" use_asserts_MSG="no" ;; esac fi case $enable_asserts in #( yes) : : ;; #( no) : : ;; #( *) : enable_asserts='no' ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${use_asserts_MSG=no}" >&5 printf "%s\n" "${use_asserts_MSG=no}" >&6; } if test "x$enable_asserts" = x"yes" then : if test "x$mhd_cv_macro__debug_def" = x"yes" then : : else $as_nop if test -z "${CPPFLAGS_ac}" then : CPPFLAGS_ac="-D_DEBUG=1" else $as_nop CPPFLAGS_ac="-D_DEBUG=1 ${CPPFLAGS_ac}" fi CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether system assert() is available" >&5 printf %s "checking whether system assert() is available... " >&6; } if test ${mhd_cv_sys_assert_avail+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include static int pos_val(void) {return 5;} static int neg_val(void) {return -5;} int main(void) { int pos_var = pos_val(), neg_var = neg_val(); assert(neg_var > pos_var); /* Must trigger assert. */ return pos_var + neg_var; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_sys_assert_avail='yes' else $as_nop mhd_cv_sys_assert_avail='no' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_sys_assert_avail" >&5 printf "%s\n" "$mhd_cv_sys_assert_avail" >&6; } if test "x$mhd_cv_sys_assert_avail" = x"no" then : else $as_nop printf "%s\n" "#define HAVE_ASSERT 1" >>confdefs.h fi else $as_nop if test "x$mhd_cv_macro_ndebug_def" = x"yes" then : : else $as_nop if test -z "${CPPFLAGS_ac}" then : CPPFLAGS_ac="-DNDEBUG=1" else $as_nop CPPFLAGS_ac="-DNDEBUG=1 ${CPPFLAGS_ac}" fi CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" fi fi { enabled_sanitizers=; unset enabled_sanitizers;} TESTS_ENVIRONMENT_ac="" AM_ASAN_OPTIONS="" AM_UBSAN_OPTIONS="" AM_LSAN_OPTIONS="" { ASAN_OPTIONS=; unset ASAN_OPTIONS;} { UBSAN_OPTIONS=; unset UBSAN_OPTIONS;} { LSAN_OPTIONS=; unset LSAN_OPTIONS;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable run-time sanitizers" >&5 printf %s "checking whether to enable run-time sanitizers... " >&6; } # Check whether --enable-sanitizers was given. if test ${enable_sanitizers+y} then : enableval=$enable_sanitizers; else $as_nop case ${enable_build_type} in #( debug) : enable_sanitizers='auto-optional' ;; #( *) : enable_sanitizers='no' ;; esac fi if test "x${enable_sanitizers}" = "x" then : enable_sanitizers="auto" fi if test "x$enable_sanitizers" = x"yes" then : enable_sanitizers="auto" fi if test "x$enable_sanitizers" = x"autofallback" then : enable_sanitizers="auto-fallback" fi if test "x$enable_sanitizers" = x"autooptional" then : enable_sanitizers="auto-optional" fi if test "x${enable_sanitizers}" = "xno" then : enable_sanitizers="no" enable_san_address="no" enable_san_undef="no" enable_san_leak="no" enable_san_upoison="no" elif test "x${enable_sanitizers}" = "xauto" || test "x${enable_sanitizers}" = "xauto-optional" then : if test "x$enable_compiler_hardening" = x"yes" then : if test "x$enable_sanitizers" = x"auto" then : as_fn_error $? "sanitizers cannot be enabled with compiler hardnening" "$LINENO" 5 else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: sanitizers cannot be enabled with compiler hardnening" >&5 printf "%s\n" "$as_me: WARNING: sanitizers cannot be enabled with compiler hardnening" >&2;} fi enable_sanitizers="no" enable_san_address="no" enable_san_undef="no" enable_san_leak="no" enable_san_upoison="no" else $as_nop enable_san_address="auto" enable_san_undef="auto" enable_san_leak="auto" enable_san_upoison="auto" fi elif test "x${enable_sanitizers}" = "xauto-fallback" then : enable_san_address="auto" enable_san_undef="auto-fallback" enable_san_leak="auto" enable_san_upoison="auto" else $as_nop { san=; unset san;} enable_san_address="no" enable_san_undef="no" enable_san_leak="no" enable_san_upoison="no" for san in `printf "%s\n" ${enable_sanitizers} | tr ',' ' '` do case $san in #( address) : enable_san_address="yes" ;; #( undefined) : enable_san_undef="yes" ;; #( leak) : enable_san_leak="yes" ;; #( user-poison|user_poison) : enable_san_upoison="yes" ;; #( no|yes|auto|auto-fallback|autofallback) : as_fn_error $? "\"$san\" cannot be used with other options for --enable-sanitizers=" "$LINENO" 5 ;; #( *) : as_fn_error $? "Unknown parameter \"$san\" for --enable-sanitizers=" "$LINENO" 5 ;; esac done if test "x${enable_san_upoison}" = "xyes" && test "x${enable_san_address}" = "xno" then : as_fn_error $? "User memory poisoning cannot be used without address sanitizer" "$LINENO" 5 fi enable_sanitizers="selected" fi case ${enable_sanitizers} in #( selected) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: selected" >&5 printf "%s\n" "selected" >&6; } ;; #( auto) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, detect and use supported sanitizers" >&5 printf "%s\n" "yes, detect and use supported sanitizers" >&6; } ;; #( auto-fallback) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, detect and use supported sanitizers even without run-time lib" >&5 printf "%s\n" "yes, detect and use supported sanitizers even without run-time lib" >&6; } ;; #( auto-optional) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, detect and use supported sanitizers if any" >&5 printf "%s\n" "yes, detect and use supported sanitizers if any" >&6; } ;; #( *) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } ;; esac if test "x$enable_sanitizers" = x"no" then : : else $as_nop { san_FLAGS=; unset san_FLAGS;} # the sanitizer flags to be added to both CFLAGS and LDFLAGS { san_CFLAGS=; unset san_CFLAGS;} # the sanitizer flags to be added to CFLAGS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether '-fsanitize=' works for $CC" >&5 printf %s "checking whether '-fsanitize=' works for $CC... " >&6; } if test ${mhd_cv_cc_sanitizer_works+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} -fsanitize=wrongFeatureName ${user_CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : mhd_cv_cc_sanitizer_works=no else $as_nop mhd_cv_cc_sanitizer_works=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_sanitizer_works" >&5 printf "%s\n" "$mhd_cv_cc_sanitizer_works" >&6; } if test "x$mhd_cv_cc_sanitizer_works" = x"yes" then : if test "x$enable_san_address" = x"no" then : : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for address sanitizer" >&5 printf %s "checking for address sanitizer... " >&6; } if test ${mhd_cv_cc_sanitizer_address+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=address ${user_CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_sanitizer_address=yes else $as_nop mhd_cv_cc_sanitizer_address=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_sanitizer_address" >&5 printf "%s\n" "$mhd_cv_cc_sanitizer_address" >&6; } if test "x$mhd_cv_cc_sanitizer_address" = x"yes" then : printf "%s\n" "#define MHD_ASAN_ACTIVE 1" >>confdefs.h if test ${san_FLAGS+y} then : case " $san_FLAGS " in #( *" -fsanitize=address "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS already contains -fsanitize=address"; } >&5 (: san_FLAGS already contains -fsanitize=address) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_FLAGS " -fsanitize=address" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_FLAGS=-fsanitize=address { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }address" if test "x$enable_san_leak" = x"no" then : : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether leak detect is not rejected by address sanitizer" >&5 printf %s "checking whether leak detect is not rejected by address sanitizer... " >&6; } if test ${mhd_cv_cc_sanitizer_address_leak+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${user_CFLAGS}" ASAN_OPTIONS="exitcode=88:detect_leaks=1:halt_on_error=1" export ASAN_OPTIONS if test "$cross_compiling" = yes then : # Cross-compiling with sanitizers? mhd_cv_cc_sanitizer_address_leak='assuming no' else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO" then : mhd_cv_cc_sanitizer_address_leak=yes else $as_nop mhd_cv_cc_sanitizer_address_leak=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi { ASAN_OPTIONS=; unset ASAN_OPTIONS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_sanitizer_address_leak" >&5 printf "%s\n" "$mhd_cv_cc_sanitizer_address_leak" >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pointer compare sanitizer" >&5 printf %s "checking for pointer compare sanitizer... " >&6; } if test ${mhd_cv_cc_sanitizer_pointer_compare+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-compare ${user_CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_sanitizer_pointer_compare=yes else $as_nop mhd_cv_cc_sanitizer_pointer_compare=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_sanitizer_pointer_compare" >&5 printf "%s\n" "$mhd_cv_cc_sanitizer_pointer_compare" >&6; } if test "x$mhd_cv_cc_sanitizer_pointer_compare" = x"yes" then : if test ${san_FLAGS+y} then : case " $san_FLAGS " in #( *" -fsanitize=pointer-compare "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS already contains -fsanitize=pointer-compare"; } >&5 (: san_FLAGS already contains -fsanitize=pointer-compare) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_FLAGS " -fsanitize=pointer-compare" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_FLAGS=-fsanitize=pointer-compare { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer compare" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pointer subtract sanitizer" >&5 printf %s "checking for pointer subtract sanitizer... " >&6; } if test ${mhd_cv_cc_sanitizer_pointer_subtract+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-subtract ${user_CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_sanitizer_pointer_subtract=yes else $as_nop mhd_cv_cc_sanitizer_pointer_subtract=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_sanitizer_pointer_subtract" >&5 printf "%s\n" "$mhd_cv_cc_sanitizer_pointer_subtract" >&6; } if test "x$mhd_cv_cc_sanitizer_pointer_subtract" = x"yes" then : if test ${san_FLAGS+y} then : case " $san_FLAGS " in #( *" -fsanitize=pointer-subtract "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS already contains -fsanitize=pointer-subtract"; } >&5 (: san_FLAGS already contains -fsanitize=pointer-subtract) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_FLAGS " -fsanitize=pointer-subtract" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_FLAGS=-fsanitize=pointer-subtract { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer subtract" fi if test "x$enable_san_upoison" = x"no" then : : else $as_nop ac_fn_c_check_header_compile "$LINENO" "sanitizer/asan_interface.h" "ac_cv_header_sanitizer_asan_interface_h" "$ac_includes_default " if test "x$ac_cv_header_sanitizer_asan_interface_h" = xyes then : printf "%s\n" "#define HAVE_SANITIZER_ASAN_INTERFACE_H 1" >>confdefs.h fi if test "x$ac_cv_header_sanitizer_asan_interface_h" = x"yes" then : CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}" # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func___asan_address_is_poisoned+y} then : else $as_nop ac_fn_check_decl "$LINENO" "__asan_address_is_poisoned" "ac_cv_have_decl___asan_address_is_poisoned" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl___asan_address_is_poisoned" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function __asan_address_is_poisoned" >&5 printf %s "checking for function __asan_address_is_poisoned... " >&6; } if test ${mhd_cv_func___asan_address_is_poisoned+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl___asan_address_is_poisoned" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { int a_var=1; if(__asan_address_is_poisoned((void*) &a_var)) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func___asan_address_is_poisoned="yes" else $as_nop mhd_cv_func___asan_address_is_poisoned="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func___asan_address_is_poisoned="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func___asan_address_is_poisoned" >&5 printf "%s\n" "$mhd_cv_func___asan_address_is_poisoned" >&6; } if test "x$mhd_cv_func___asan_address_is_poisoned" = x"yes" then : printf "%s\n" "#define HAVE___ASAN_ADDRESS_IS_POISONED 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here # Expansion of MHD_CHECK_FUNC macro starts here if test ${mhd_cv_func___asan_region_is_poisoned+y} then : else $as_nop ac_fn_check_decl "$LINENO" "__asan_region_is_poisoned" "ac_cv_have_decl___asan_region_is_poisoned" "#include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl___asan_region_is_poisoned" = xyes then : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for function __asan_region_is_poisoned" >&5 printf %s "checking for function __asan_region_is_poisoned... " >&6; } if test ${mhd_cv_func___asan_region_is_poisoned+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$ac_cv_have_decl___asan_region_is_poisoned" = x"yes" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { int a_var=1; if(((void*) 0) != __asan_region_is_poisoned((void*) &a_var, sizeof(a_var))) return 3; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_func___asan_region_is_poisoned="yes" else $as_nop mhd_cv_func___asan_region_is_poisoned="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext else $as_nop mhd_cv_func___asan_region_is_poisoned="no" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func___asan_region_is_poisoned" >&5 printf "%s\n" "$mhd_cv_func___asan_region_is_poisoned" >&6; } if test "x$mhd_cv_func___asan_region_is_poisoned" = x"yes" then : printf "%s\n" "#define HAVE___ASAN_REGION_IS_POISONED 1" >>confdefs.h fi # Expansion of MHD_CHECK_FUNC macro ends here { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether special function attribute is needed for user-poison" >&5 printf %s "checking whether special function attribute is needed for user-poison... " >&6; } if test ${mhd_cv_func_u_p_attribute_needed+y} then : printf %s "(cached) " >&6 else $as_nop ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1" export ASAN_OPTIONS CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}" if test "$cross_compiling" = yes then : # Cross-compiling with sanitizers?? mhd_cv_func_up_attribute_needed='assuming no' else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include static const size_t first_pos = 0; static const size_t mid_pos = 64; static const size_t last_pos = 128; static const size_t zone_size = 16; static const size_t buf_size = 128 + 16; static int ptr_compare(void *ptr1, uint8_t *ptr2) { if ((((uintptr_t) (uint8_t *)ptr1) >= ((uintptr_t)ptr2))) return ((char *) ptr1)[0] < ((char *) ptr2)[0]; return ((char *) ptr1)[0] > ((char *) ptr2)[0]; } static int ptr_subtract(void *ptr1, uint8_t *ptr2) { return ((size_t)(((uintptr_t)(uint8_t*)ptr1) - ((uintptr_t)ptr2))) <= last_pos; } int main(int argc, char *argv[]) { char *buf = (char*) malloc (buf_size); char *a; char *b; int ret; (void) argv; if (NULL == buf) return 10; ASAN_POISON_MEMORY_REGION (buf + first_pos + zone_size, mid_pos - first_pos - zone_size); ASAN_POISON_MEMORY_REGION (buf + mid_pos + zone_size, last_pos - mid_pos - zone_size); if (0 < argc) a = buf + last_pos; else a = buf + first_pos; b = buf + mid_pos; *a = '0'; *b = '9'; if (ptr_compare((void *)a, (uint8_t*) b)) { if (ptr_subtract((void *)a, (uint8_t*) b)) ret = 0; else ret = 10; } else ret = 5; ASAN_UNPOISON_MEMORY_REGION (buf, buf_size); free (buf); return ret; } _ACEOF if ac_fn_c_try_run "$LINENO" then : mhd_cv_func_u_p_attribute_needed="no" else $as_nop mhd_cv_func_u_p_attribute_needed="yes" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi { ASAN_OPTIONS=; unset ASAN_OPTIONS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_u_p_attribute_needed" >&5 printf "%s\n" "$mhd_cv_func_u_p_attribute_needed" >&6; } fi if test "x$mhd_cv_func_u_p_attribute_needed" = x"yes" then : : else $as_nop printf "%s\n" "#define FUNC_PTRCOMPARE_CAST_WORKAROUND_WORKS 1" >>confdefs.h fi if test "x${mhd_cv_func_u_p_attribute_needed}" = "xyes" && test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether '__attribute__((no_sanitize(\"pointer-compare\")))' and '__attribute__((no_sanitize(\"pointer-subtract\")))' work" >&5 printf %s "checking whether '__attribute__((no_sanitize(\"pointer-compare\")))' and '__attribute__((no_sanitize(\"pointer-subtract\")))' work... " >&6; } if test ${mhd_cv_func_attribute_nosanitize_ptr+y} then : printf %s "(cached) " >&6 else $as_nop ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1" export ASAN_OPTIONS CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}" if test "$cross_compiling" = yes then : # Cross-compiling with sanitizers?? mhd_cv_func_attribute_nosanitize_ptr='assuming no' else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include static const size_t first_pos = 0; static const size_t mid_pos = 64; static const size_t last_pos = 128; static const size_t zone_size = 16; static const size_t buf_size = 128 + 16; __attribute__((no_sanitize("pointer-compare"))) static int ptr_compare(void *ptr1, uint8_t *ptr2) { if ((((const uint8_t*)ptr1) >= ((const uint8_t*)ptr2))) return ((char *) ptr1)[0] < ((char *) ptr2)[0]; return ((char *) ptr1)[0] > ((char *) ptr2)[0]; } __attribute__((no_sanitize("pointer-subtract"))) static int ptr_subtract(void *ptr1, uint8_t *ptr2) { return ((size_t)(((const uint8_t*)ptr1) - \ ((const uint8_t*)ptr2))) <= last_pos; } int main(int argc, char *argv[]) { char *buf = (char*) malloc (buf_size); char *a; char *b; int ret; (void) argv; if (NULL == buf) return 10; ASAN_POISON_MEMORY_REGION (buf + first_pos + zone_size, mid_pos - first_pos - zone_size); ASAN_POISON_MEMORY_REGION (buf + mid_pos + zone_size, last_pos - mid_pos - zone_size); if (0 < argc) a = buf + last_pos; else a = buf + first_pos; b = buf + mid_pos; *a = '0'; *b = '9'; if (ptr_compare((void *)a, (uint8_t*) b)) { if (ptr_subtract((void *)a, (uint8_t*) b)) ret = 0; else ret = 10; } else ret = 5; ASAN_UNPOISON_MEMORY_REGION (buf, buf_size); free (buf); return ret; } _ACEOF if ac_fn_c_try_run "$LINENO" then : mhd_cv_func_attribute_nosanitize_ptr=yes else $as_nop mhd_cv_func_attribute_nosanitize_ptr=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi { ASAN_OPTIONS=; unset ASAN_OPTIONS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_attribute_nosanitize_ptr" >&5 printf "%s\n" "$mhd_cv_func_attribute_nosanitize_ptr" >&6; } if test "x$mhd_cv_func_attribute_nosanitize_ptr" = x"yes" then : printf "%s\n" "#define FUNC_ATTR_PTRCOMPARE_WORKS 1" >>confdefs.h printf "%s\n" "#define FUNC_ATTR_PTRSUBTRACT_WORKS 1" >>confdefs.h else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether '__attribute__((no_sanitize(\"address\")))' works for pointers compare" >&5 printf %s "checking whether '__attribute__((no_sanitize(\"address\")))' works for pointers compare... " >&6; } if test ${mhd_cv_func_attribute_nosanitize_addr+y} then : printf %s "(cached) " >&6 else $as_nop ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1" export ASAN_OPTIONS CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}" if test "$cross_compiling" = yes then : # Cross-compiling with sanitizers?? mhd_cv_func_attribute_nosanitize_addr='assuming no' else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include static const size_t first_pos = 0; static const size_t mid_pos = 64; static const size_t last_pos = 128; static const size_t zone_size = 16; static const size_t buf_size = 128 + 16; __attribute__((no_sanitize("address"))) static int ptr_compare(void *ptr1, uint8_t *ptr2) { if ((((const uint8_t*)ptr1) >= ((const uint8_t*)ptr2))) return ((char *) ptr1)[0] < ((char *) ptr2)[0]; return ((char *) ptr1)[0] > ((char *) ptr2)[0]; } __attribute__((no_sanitize("address"))) static int ptr_subtract(void *ptr1, uint8_t *ptr2) { return ((size_t)(((const uint8_t*)ptr1) - \ ((const uint8_t*)ptr2))) <= last_pos; } int main(int argc, char *argv[]) { char *buf = (char*) malloc (buf_size); char *a; char *b; int ret; (void) argv; if (NULL == buf) return 10; ASAN_POISON_MEMORY_REGION (buf + first_pos + zone_size, mid_pos - first_pos - zone_size); ASAN_POISON_MEMORY_REGION (buf + mid_pos + zone_size, last_pos - mid_pos - zone_size); if (0 < argc) a = buf + last_pos; else a = buf + first_pos; b = buf + mid_pos; *a = '0'; *b = '9'; if (ptr_compare((void *)a, (uint8_t*) b)) { if (ptr_subtract((void *)a, (uint8_t*) b)) ret = 0; else ret = 10; } else ret = 5; ASAN_UNPOISON_MEMORY_REGION (buf, buf_size); free (buf); return ret; } _ACEOF if ac_fn_c_try_run "$LINENO" then : mhd_cv_func_attribute_nosanitize_addr=yes else $as_nop mhd_cv_func_attribute_nosanitize_addr=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi { ASAN_OPTIONS=; unset ASAN_OPTIONS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_func_attribute_nosanitize_addr" >&5 printf "%s\n" "$mhd_cv_func_attribute_nosanitize_addr" >&6; } if test "x$mhd_cv_func_attribute_nosanitize_addr" = x"yes" then : printf "%s\n" "#define FUNC_ATTR_NOSANITIZE_WORKS 1" >>confdefs.h fi fi fi fi fi if test "x${enable_san_address}" = "xyes" && test "x${mhd_cv_cc_sanitizer_address}" != "xyes" then : as_fn_error $? "Address sanitizer cannot be enabled" "$LINENO" 5 fi enable_san_address="${mhd_cv_cc_sanitizer_address}" fi if test "x$enable_san_undef" = x"no" then : : else $as_nop test_undf_prog=' #include static void func_out_b(char *arr) { arr[0] = 0; arr[16] = 2; } static unsigned int int_deref(void *ptr) { return (*((unsigned int*)ptr)) + 2; } static int func1(void) { char chr[16]; func_out_b (chr); return (int) (int_deref(chr + 1) + int_deref(chr + 2)); } int main(void) { unsigned long ulvar; signed char ch1; ulvar = -1 * func1(); ch1 = ulvar * 6UL; printf("%lu\n", ulvar + ch1); return 0; } ' { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for undefined behavior sanitizer" >&5 printf %s "checking for undefined behavior sanitizer... " >&6; } if test ${mhd_cv_cc_sanitizer_undefined+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined ${user_CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${test_undf_prog} _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_sanitizer_undefined=yes else $as_nop mhd_cv_cc_sanitizer_undefined=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_sanitizer_undefined" >&5 printf "%s\n" "$mhd_cv_cc_sanitizer_undefined" >&6; } if test "x$mhd_cv_cc_sanitizer_undefined" = x"yes" then : if test ${san_FLAGS+y} then : case " $san_FLAGS " in #( *" -fsanitize=undefined "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS already contains -fsanitize=undefined"; } >&5 (: san_FLAGS already contains -fsanitize=undefined) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_FLAGS " -fsanitize=undefined" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_FLAGS=-fsanitize=undefined { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined" else $as_nop case ${enable_san_undef} in #( yes|auto-fallback) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for undefined behavior sanitizer with '-fsanitize-undefined-trap-on-error'" >&5 printf %s "checking for undefined behavior sanitizer with '-fsanitize-undefined-trap-on-error'... " >&6; } if test ${mhd_cv_cc_sanitizer_undefined_trap+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-undefined-trap-on-error ${user_CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${test_undf_prog} _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_sanitizer_undefined_trap=yes else $as_nop mhd_cv_cc_sanitizer_undefined_trap=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_sanitizer_undefined_trap" >&5 printf "%s\n" "$mhd_cv_cc_sanitizer_undefined_trap" >&6; } if test "x$mhd_cv_cc_sanitizer_undefined_trap" = x"yes" then : if test ${san_FLAGS+y} then : case " $san_FLAGS " in #( *" -fsanitize=undefined "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS already contains -fsanitize=undefined"; } >&5 (: san_FLAGS already contains -fsanitize=undefined) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_FLAGS " -fsanitize=undefined" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_FLAGS=-fsanitize=undefined { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi if test ${san_FLAGS+y} then : case " $san_FLAGS " in #( *" -fsanitize-undefined-trap-on-error "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS already contains -fsanitize-undefined-trap-on-error"; } >&5 (: san_FLAGS already contains -fsanitize-undefined-trap-on-error) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_FLAGS " -fsanitize-undefined-trap-on-error" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_FLAGS=-fsanitize-undefined-trap-on-error { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Enabled sanitizer without run-time library, error reporting will be limited" >&5 printf "%s\n" "$as_me: WARNING: Enabled sanitizer without run-time library, error reporting will be limited" >&2;} else $as_nop if test -z "${enabled_sanitizers}" then : # Last resort { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for undefined behavior sanitizer with '-fsanitize-trap=all'" >&5 printf %s "checking for undefined behavior sanitizer with '-fsanitize-trap=all'... " >&6; } if test ${mhd_cv_cc_sanitizer_undefined_trap_all+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all ${user_CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${test_undf_prog} _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_sanitizer_undefined_trap_all=yes else $as_nop mhd_cv_cc_sanitizer_undefined_trap_all=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_sanitizer_undefined_trap_all" >&5 printf "%s\n" "$mhd_cv_cc_sanitizer_undefined_trap_all" >&6; } if test "x$mhd_cv_cc_sanitizer_undefined_trap_all" = x"yes" then : if test ${san_FLAGS+y} then : case " $san_FLAGS " in #( *" -fsanitize=undefined "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS already contains -fsanitize=undefined"; } >&5 (: san_FLAGS already contains -fsanitize=undefined) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_FLAGS " -fsanitize=undefined" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_FLAGS=-fsanitize=undefined { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi if test ${san_FLAGS+y} then : case " $san_FLAGS " in #( *" -fsanitize-trap=all "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS already contains -fsanitize-trap=all"; } >&5 (: san_FLAGS already contains -fsanitize-trap=all) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_FLAGS " -fsanitize-trap=all" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_FLAGS=-fsanitize-trap=all { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all ${user_CFLAGS}" enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Enabled sanitizer without run-time library, error reporting will be limited" >&5 printf "%s\n" "$as_me: WARNING: Enabled sanitizer without run-time library, error reporting will be limited" >&2;} fi fi fi case "$enabled_sanitizers" in #( *undefined) : if test "x$mhd_cv_cc_sanitizer_undefined" = x"yes" then : else $as_nop # A workaround for broken clang which is trying to use UBSan lib # even when instructed to not use it CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}" for flag in -fsanitize-trap=implicit-conversion; do as_CACHEVAR=`printf "%s\n" "ax_cv_check_ldflags__$flag" | $as_tr_sh` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts $flag" >&5 printf %s "checking whether the linker accepts $flag... " >&6; } if eval test \${$as_CACHEVAR+y} then : printf %s "(cached) " >&6 else $as_nop ax_check_save_flags=$LDFLAGS LDFLAGS="$LDFLAGS $flag" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${test_undf_prog} _ACEOF if ac_fn_c_try_link "$LINENO" then : eval "$as_CACHEVAR=yes" else $as_nop eval "$as_CACHEVAR=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$ax_check_save_flags fi eval ac_res=\$$as_CACHEVAR { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_CACHEVAR"\" = x"yes" then : if test ${san_FLAGS+y} then : case " $san_FLAGS " in #( *" $flag "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS already contains \$flag"; } >&5 (: san_FLAGS already contains $flag) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_FLAGS " $flag" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_FLAGS=$flag { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi else $as_nop : fi done fi ;; #( *) : ;; esac ;; #( *) : ;; esac fi case "$enabled_sanitizers" in #( *undefined) : CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}" for flag in -fsanitize=bounds-strict -fsanitize=local-bounds -fsanitize=implicit-conversion -fsanitize=nullability-arg; do as_CACHEVAR=`printf "%s\n" "ax_cv_check_ldflags__$flag" | $as_tr_sh` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts $flag" >&5 printf %s "checking whether the linker accepts $flag... " >&6; } if eval test \${$as_CACHEVAR+y} then : printf %s "(cached) " >&6 else $as_nop ax_check_save_flags=$LDFLAGS LDFLAGS="$LDFLAGS $flag" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ ${test_undf_prog} _ACEOF if ac_fn_c_try_link "$LINENO" then : eval "$as_CACHEVAR=yes" else $as_nop eval "$as_CACHEVAR=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$ax_check_save_flags fi eval ac_res=\$$as_CACHEVAR { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_CACHEVAR"\" = x"yes" then : if test ${san_CFLAGS+y} then : case " $san_CFLAGS " in #( *" $flag "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS already contains \$flag"; } >&5 (: san_CFLAGS already contains $flag) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_CFLAGS " $flag" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS=\"\$san_CFLAGS\""; } >&5 (: san_CFLAGS="$san_CFLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_CFLAGS=$flag { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS=\"\$san_CFLAGS\""; } >&5 (: san_CFLAGS="$san_CFLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi else $as_nop : fi done ;; #( *) : ;; esac { test_undf_prog=; unset test_undf_prog;} case "$enabled_sanitizers" in #( *undefined) : enable_san_undef="yes" ;; #( *) : if test "x$enable_san_undef" = xyes then : as_fn_error $? "Undefined behavior sanitizer cannot be enabled" "$LINENO" 5 fi enable_san_undef="no" ;; esac fi if test "x$enable_san_leak" = x"no" then : : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for leak sanitizer" >&5 printf %s "checking for leak sanitizer... " >&6; } if test ${mhd_cv_cc_sanitizer_leak+y} then : printf %s "(cached) " >&6 else $as_nop CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=leak ${user_CFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_sanitizer_leak=yes else $as_nop mhd_cv_cc_sanitizer_leak=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_sanitizer_leak" >&5 printf "%s\n" "$mhd_cv_cc_sanitizer_leak" >&6; } if test "x$mhd_cv_cc_sanitizer_leak" = x"yes" then : if test ${san_FLAGS+y} then : case " $san_FLAGS " in #( *" -fsanitize=leak "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS already contains -fsanitize=leak"; } >&5 (: san_FLAGS already contains -fsanitize=leak) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_FLAGS " -fsanitize=leak" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_FLAGS=-fsanitize=leak { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_FLAGS=\"\$san_FLAGS\""; } >&5 (: san_FLAGS="$san_FLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }leak" fi if test "x${enable_san_leak}" = "xyes" && test "x${mhd_cv_cc_sanitizer_leak}" != "xyes" then : as_fn_error $? "User poison cannot be enabled" "$LINENO" 5 fi enable_san_leak="${mhd_cv_cc_sanitizer_leak}" fi if test -z "${enabled_sanitizers}" then : if test "x$enable_sanitizers" = x"auto-optional" then : san_FLAGS="" san_CFLAGS="" else $as_nop as_fn_error $? "cannot find any sanitizer supported by $CC" "$LINENO" 5 fi else $as_nop if test "x$enable_san_upoison" = x"no" then : : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable user memory poisoning" >&5 printf %s "checking whether to enable user memory poisoning... " >&6; } if test "x${mhd_cv_cc_sanitizer_address}" = "xyes" && test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes" && \ (test "x${mhd_cv_func_u_p_attribute_needed}" != "xyes" || test "x${mhd_cv_func_attribute_nosanitize_ptr}" = "xyes" || \ test "x${mhd_cv_func_attribute_nosanitize_addr}" = "xyes") then : printf "%s\n" "#define MHD_ASAN_POISON_ACTIVE 1" >>confdefs.h enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }user-poison" enable_san_upoison="yes" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } if test "x$enable_san_upoison" = x"yes" then : as_fn_error $? "User memory poisoning cannot be enabled" "$LINENO" 5 fi enable_san_upoison="no" fi fi if test "x$enable_san_address" = x"yes" then : CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}" ac_fn_check_decl "$LINENO" "_FORTIFY_SOURCE" "ac_cv_have_decl__FORTIFY_SOURCE" "/* no includes */ " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl__FORTIFY_SOURCE" = xyes then : if test -z "${CPPFLAGS_ac}" then : CPPFLAGS_ac="-U_FORTIFY_SOURCE" else $as_nop CPPFLAGS_ac="${CPPFLAGS_ac} -U_FORTIFY_SOURCE" fi fi if test ${san_CFLAGS+y} then : case " $san_CFLAGS " in #( *" -D_FORTIFY_SOURCE=0 "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS already contains -D_FORTIFY_SOURCE=0"; } >&5 (: san_CFLAGS already contains -D_FORTIFY_SOURCE=0) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_CFLAGS " -D_FORTIFY_SOURCE=0" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS=\"\$san_CFLAGS\""; } >&5 (: san_CFLAGS="$san_CFLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_CFLAGS=-D_FORTIFY_SOURCE=0 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS=\"\$san_CFLAGS\""; } >&5 (: san_CFLAGS="$san_CFLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi else $as_nop case $enable_sanitizers in #( auto|auto-fallback) : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $CC does not support address sanitizer" >&5 printf "%s\n" "$as_me: WARNING: $CC does not support address sanitizer" >&2;} ;; #( *) : ;; esac fi CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}" # Always stop on sanitizer error for flag in -fno-sanitize-recover=all; do as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags__$flag" | $as_tr_sh` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 printf %s "checking whether C compiler accepts $flag... " >&6; } if eval test \${$as_CACHEVAR+y} then : printf %s "(cached) " >&6 else $as_nop ax_check_save_flags=$CFLAGS CFLAGS="$CFLAGS $flag" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$as_CACHEVAR=yes" else $as_nop eval "$as_CACHEVAR=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext CFLAGS=$ax_check_save_flags fi eval ac_res=\$$as_CACHEVAR { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_CACHEVAR"\" = x"yes" then : if test ${san_CFLAGS+y} then : case " $san_CFLAGS " in #( *" $flag "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS already contains \$flag"; } >&5 (: san_CFLAGS already contains $flag) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_CFLAGS " $flag" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS=\"\$san_CFLAGS\""; } >&5 (: san_CFLAGS="$san_CFLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_CFLAGS=$flag { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS=\"\$san_CFLAGS\""; } >&5 (: san_CFLAGS="$san_CFLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi else $as_nop : fi done # Get a better output for sanitizers error reporting for flag in -fno-omit-frame-pointer -fno-optimize-sibling-calls; do as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags__$flag" | $as_tr_sh` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 printf %s "checking whether C compiler accepts $flag... " >&6; } if eval test \${$as_CACHEVAR+y} then : printf %s "(cached) " >&6 else $as_nop ax_check_save_flags=$CFLAGS CFLAGS="$CFLAGS $flag" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$as_CACHEVAR=yes" else $as_nop eval "$as_CACHEVAR=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext CFLAGS=$ax_check_save_flags fi eval ac_res=\$$as_CACHEVAR { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_CACHEVAR"\" = x"yes" then : if test ${san_CFLAGS+y} then : case " $san_CFLAGS " in #( *" $flag "*) : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS already contains \$flag"; } >&5 (: san_CFLAGS already contains $flag) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; #( *) : as_fn_append san_CFLAGS " $flag" { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS=\"\$san_CFLAGS\""; } >&5 (: san_CFLAGS="$san_CFLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } ;; esac else $as_nop san_CFLAGS=$flag { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: : san_CFLAGS=\"\$san_CFLAGS\""; } >&5 (: san_CFLAGS="$san_CFLAGS") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } fi else $as_nop : fi done if test "x$enable_san_address" = x"yes" then : AM_ASAN_OPTIONS="exitcode=88:strict_string_checks=1:detect_stack_use_after_return=1" AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:check_initialization_order=1:strict_init_order=1:redzone=64" AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:max_free_fill_size=1024:detect_invalid_pointer_pairs=3" AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:handle_ioctl=1:halt_on_error=1" if test "x$enable_san_upoison" = x"yes" then : AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:allow_user_poisoning=1" fi if test "x$enable_san_leak" = x"yes" then : if test "x$mhd_cv_cc_sanitizer_address_leak" = x"yes" then : AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=1" fi else $as_nop AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=0" fi fi if test "x$enable_san_undef" = xyes then : AM_UBSAN_OPTIONS="exitcode=87:print_stacktrace=1:halt_on_error=1" fi if test "x$enable_san_leak" = x"yes" then : AM_LSAN_OPTIONS="use_unaligned=1" fi TESTS_ENVIRONMENT_ac='\ ASAN_OPTIONS="$(AM_ASAN_OPTIONS)" ; export ASAN_OPTIONS ; \ UBSAN_OPTIONS="$(AM_UBSAN_OPTIONS)" ; export UBSAN_OPTIONS ; \ LSAN_OPTIONS="$(AM_LSAN_OPTIONS)" ; export LSAN_OPTIONS ;' fi fi CFLAGS_ac="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" fi # fuzzing tests run_zzuf_tests="no" zzuf_socat_mandatory="no" if test "x$use_heavy_tests" = x"yes" then : if test "x$enable_curl" = x"yes" then : # Extract the first word of "zzuf", so it can be a program name with args. set dummy zzuf; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_ZZUF+y} then : printf %s "(cached) " >&6 else $as_nop case $ZZUF in [\\/]* | ?:[\\/]*) ac_cv_path_ZZUF="$ZZUF" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_ZZUF="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_ZZUF" && ac_cv_path_ZZUF="no" ;; esac fi ZZUF=$ac_cv_path_ZZUF if test -n "$ZZUF"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ZZUF" >&5 printf "%s\n" "$ZZUF" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ZZUF" = x"no" then : run_zzuf_tests="no" run_zzuf_tests_MSG="no, zzuf tool not found" else $as_nop # Extract the first word of "socat", so it can be a program name with args. set dummy socat; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_SOCAT+y} then : printf %s "(cached) " >&6 else $as_nop case $SOCAT in [\\/]* | ?:[\\/]*) ac_cv_path_SOCAT="$SOCAT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_SOCAT="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_SOCAT" && ac_cv_path_SOCAT="no" ;; esac fi SOCAT=$ac_cv_path_SOCAT if test -n "$SOCAT"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SOCAT" >&5 printf "%s\n" "$SOCAT" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x${ac_cv_func_accept4}" = "xyes" && test "x${enable_asserts}" = "xno" then : zzuf_socat_mandatory="yes" if test "x$SOCAT" = x"no" then : run_zzuf_tests_MSG="no, socat not found, but required for fuzzing tests on this platform without asserts enabled" else $as_nop run_zzuf_tests="yes" run_zzuf_tests_MSG="yes, with zzuf and socat tools" fi elif test -n "${enabled_sanitizers}" then : zzuf_socat_mandatory="yes" if test "x$SOCAT" = x"no" then : run_zzuf_tests_MSG="no, socat not found, but required for fuzzing tests when sanitizers enabled" else $as_nop run_zzuf_tests="yes" run_zzuf_tests_MSG="yes, with zzuf and socat tools" fi else $as_nop run_zzuf_tests="yes" run_zzuf_tests_MSG="yes, with zzuf tool" fi fi else $as_nop run_zzuf_tests="no" run_zzuf_tests_MSG="no, tests with libcurl are not enabled" fi else $as_nop run_zzuf_tests="no" run_zzuf_tests_MSG="no, heavy tests are not enabled" fi if test "x$run_zzuf_tests" = "xyes"; then RUN_ZZUF_TESTS_TRUE= RUN_ZZUF_TESTS_FALSE='#' else RUN_ZZUF_TESTS_TRUE='#' RUN_ZZUF_TESTS_FALSE= fi if test "x$zzuf_socat_mandatory" = "xyes"; then FORCE_USE_ZZUF_SOCAT_TRUE= FORCE_USE_ZZUF_SOCAT_FALSE='#' else FORCE_USE_ZZUF_SOCAT_TRUE='#' FORCE_USE_ZZUF_SOCAT_FALSE= fi # Final flags that may interfere with autoconf detections case ${enable_build_type} in #( debug|debugger) : # Debug build or build for walking with debugger CFLAGS="${user_CFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wextra-semi flag" >&5 printf %s "checking whether $CC supports -Wextra-semi flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wextra_semi+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wextra-semi ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wextra_semi="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wextra_semi="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wextra-semi ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wextra_semi="yes" else $as_nop mhd_cv_cc_cfl_supp__Wextra_semi="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wextra_semi" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wextra_semi" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wextra_semi" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wextra-semi" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wextra-semi" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wextra-semi-stmt flag" >&5 printf %s "checking whether $CC supports -Wextra-semi-stmt flag... " >&6; } if test ${mhd_cv_cc_cfl_supp__Wextra_semi_stmt+y} then : printf %s "(cached) " >&6 else $as_nop mhd_check_cc_flag_save_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS_ac} -Wextra-semi-stmt ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag=yes # Reuse the same source for all the checks here cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wextra_semi_stmt="yes" else $as_nop # Compile and link failed with test flag added CFLAGS="${CFLAGS_ac} ${mhd_check_cc_flag_save_CFLAGS} ${mhd_xFLAGS_params_warn}" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wextra_semi_stmt="no" else $as_nop # Compile and link failed with test flag removed as well CFLAGS="${CFLAGS_ac} -Wextra-semi-stmt ${mhd_check_cc_flag_save_CFLAGS}" ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" if ac_fn_c_try_link "$LINENO" then : mhd_cv_cc_cfl_supp__Wextra_semi_stmt="yes" else $as_nop mhd_cv_cc_cfl_supp__Wextra_semi_stmt="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag" CFLAGS="${mhd_check_cc_flag_save_CFLAGS}" { mhd_check_cc_flag_save_CFLAGS=; unset mhd_check_cc_flag_save_CFLAGS;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $mhd_cv_cc_cfl_supp__Wextra_semi_stmt" >&5 printf "%s\n" "$mhd_cv_cc_cfl_supp__Wextra_semi_stmt" >&6; } if test "x$mhd_cv_cc_cfl_supp__Wextra_semi_stmt" = x"yes" then : if test -z "${CFLAGS_ac}" then : CFLAGS_ac="-Wextra-semi-stmt" else $as_nop CFLAGS_ac="${CFLAGS_ac} -Wextra-semi-stmt" fi fi CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ;; #( *) : ;; esac if test -n "$enabled_sanitizers" && test "x$mhd_cv_cc_sanitizer_works" = "xyes"; then USE_SANITIZERS_TRUE= USE_SANITIZERS_FALSE='#' else USE_SANITIZERS_TRUE='#' USE_SANITIZERS_FALSE= fi MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS" # for pkg-config # Restore flags as set by the user CFLAGS="${user_CFLAGS}" LDFLAGS="${user_LDFLAGS}" CPPFLAGS="${user_CPPFLAGS}" # Configure-defined flags # Used for 'po' directory staff ac_config_files="$ac_config_files po/po-configure.ac" ac_config_commands="$ac_config_commands po/Makefile.in" ac_config_commands="$ac_config_commands po-directories" # We define the paths here, because MinGW/GCC expands paths # passed through the command line ("-DDIR=..."). This would # lead to hard-coded paths ("C:\mingw\mingw\bin...") that do # not contain the actual installation. prefix_NONE= exec_prefix_NONE= test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix eval ac_define_dir="\"$libdir/libmicrohttpd\"" eval ac_define_dir="\"$ac_define_dir\"" MHD_PLUGIN_INSTALL_PREFIX="$ac_define_dir" printf "%s\n" "#define MHD_PLUGIN_INSTALL_PREFIX \"$ac_define_dir\"" >>confdefs.h test "$prefix_NONE" && prefix=NONE test "$exec_prefix_NONE" && exec_prefix=NONE # should experimental code be compiled (code that may not yet compile)? { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to compile experimental code" >&5 printf %s "checking whether to compile experimental code... " >&6; } # Check whether --enable-experimental was given. if test ${enable_experimental+y} then : enableval=$enable_experimental; enable_experimental=${enableval} else $as_nop enable_experimental=no fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_experimental" >&5 printf "%s\n" "$enable_experimental" >&6; } if test "x$enable_experimental" = "xyes"; then HAVE_EXPERIMENTAL_TRUE= HAVE_EXPERIMENTAL_FALSE='#' else HAVE_EXPERIMENTAL_TRUE='#' HAVE_EXPERIMENTAL_FALSE= fi ac_config_files="$ac_config_files libmicrohttpd.pc w32/common/microhttpd_dll_res_vc.rc Makefile contrib/Makefile doc/Makefile doc/doxygen/libmicrohttpd.doxy doc/doxygen/Makefile doc/examples/Makefile m4/Makefile src/Makefile src/include/Makefile src/lib/Makefile src/microhttpd/Makefile src/microhttpd_ws/Makefile src/examples/Makefile src/tools/Makefile src/testcurl/Makefile src/testcurl/https/Makefile src/testzzuf/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 printf "%s\n" "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 printf %s "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: done" >&5 printf "%s\n" "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${MHD_USE_SYS_TSEARCH_TRUE}" && test -z "${MHD_USE_SYS_TSEARCH_FALSE}"; then as_fn_error $? "conditional \"MHD_USE_SYS_TSEARCH\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CYGWIN_TARGET_TRUE}" && test -z "${CYGWIN_TARGET_FALSE}"; then as_fn_error $? "conditional \"CYGWIN_TARGET\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_POSIX_THREADS_TRUE}" && test -z "${HAVE_POSIX_THREADS_FALSE}"; then as_fn_error $? "conditional \"HAVE_POSIX_THREADS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_POSIX_THREADS_TRUE}" && test -z "${USE_POSIX_THREADS_FALSE}"; then as_fn_error $? "conditional \"USE_POSIX_THREADS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_W32_THREADS_TRUE}" && test -z "${USE_W32_THREADS_FALSE}"; then as_fn_error $? "conditional \"USE_W32_THREADS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_THREADS_TRUE}" && test -z "${USE_THREADS_FALSE}"; then as_fn_error $? "conditional \"USE_THREADS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DISABLE_THREADS_TRUE}" && test -z "${DISABLE_THREADS_FALSE}"; then as_fn_error $? "conditional \"DISABLE_THREADS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_W32_TRUE}" && test -z "${HAVE_W32_FALSE}"; then as_fn_error $? "conditional \"HAVE_W32\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${W32_SHARED_LIB_EXP_TRUE}" && test -z "${W32_SHARED_LIB_EXP_FALSE}"; then as_fn_error $? "conditional \"W32_SHARED_LIB_EXP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_MS_LIB_TOOL_TRUE}" && test -z "${USE_MS_LIB_TOOL_FALSE}"; then as_fn_error $? "conditional \"USE_MS_LIB_TOOL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_EXPORT_FILE_TRUE}" && test -z "${USE_EXPORT_FILE_FALSE}"; then as_fn_error $? "conditional \"USE_EXPORT_FILE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_LISTEN_SHUTDOWN_TRUE}" && test -z "${HAVE_LISTEN_SHUTDOWN_FALSE}"; then as_fn_error $? "conditional \"HAVE_LISTEN_SHUTDOWN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${NEED_SYS_FD_SET_SIZE_VALUE_TRUE}" && test -z "${NEED_SYS_FD_SET_SIZE_VALUE_FALSE}"; then as_fn_error $? "conditional \"NEED_SYS_FD_SET_SIZE_VALUE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_CURL_BINARY_TRUE}" && test -z "${HAVE_CURL_BINARY_FALSE}"; then as_fn_error $? "conditional \"HAVE_CURL_BINARY\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_MAKEINFO_BINARY_TRUE}" && test -z "${HAVE_MAKEINFO_BINARY_FALSE}"; then as_fn_error $? "conditional \"HAVE_MAKEINFO_BINARY\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${W32_STATIC_LIB_TRUE}" && test -z "${W32_STATIC_LIB_FALSE}"; then as_fn_error $? "conditional \"W32_STATIC_LIB\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_DOC_TRUE}" && test -z "${BUILD_DOC_FALSE}"; then as_fn_error $? "conditional \"BUILD_DOC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_EXAMPLES_TRUE}" && test -z "${BUILD_EXAMPLES_FALSE}"; then as_fn_error $? "conditional \"BUILD_EXAMPLES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${BUILD_TOOLS_TRUE}" && test -z "${BUILD_TOOLS_FALSE}"; then as_fn_error $? "conditional \"BUILD_TOOLS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HEAVY_TESTS_TRUE}" && test -z "${HEAVY_TESTS_FALSE}"; then as_fn_error $? "conditional \"HEAVY_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${VHEAVY_TESTS_TRUE}" && test -z "${VHEAVY_TESTS_FALSE}"; then as_fn_error $? "conditional \"VHEAVY_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${TESTS_STRESS_OS_TRUE}" && test -z "${TESTS_STRESS_OS_FALSE}"; then as_fn_error $? "conditional \"TESTS_STRESS_OS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${MHD_HAVE_EPOLL_TRUE}" && test -z "${MHD_HAVE_EPOLL_FALSE}"; then as_fn_error $? "conditional \"MHD_HAVE_EPOLL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${MHD_HAVE_TLS_PLUGIN_TRUE}" && test -z "${MHD_HAVE_TLS_PLUGIN_FALSE}"; then as_fn_error $? "conditional \"MHD_HAVE_TLS_PLUGIN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_ZLIB_TRUE}" && test -z "${HAVE_ZLIB_FALSE}"; then as_fn_error $? "conditional \"HAVE_ZLIB\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${RUN_LIBCURL_TESTS_TRUE}" && test -z "${RUN_LIBCURL_TESTS_FALSE}"; then as_fn_error $? "conditional \"RUN_LIBCURL_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${MHD_HAVE_LIBMAGIC_TRUE}" && test -z "${MHD_HAVE_LIBMAGIC_FALSE}"; then as_fn_error $? "conditional \"MHD_HAVE_LIBMAGIC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_MESSAGES_TRUE}" && test -z "${HAVE_MESSAGES_FALSE}"; then as_fn_error $? "conditional \"HAVE_MESSAGES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_POSTPROCESSOR_TRUE}" && test -z "${HAVE_POSTPROCESSOR_FALSE}"; then as_fn_error $? "conditional \"HAVE_POSTPROCESSOR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_GNUTLS_TRUE}" && test -z "${HAVE_GNUTLS_FALSE}"; then as_fn_error $? "conditional \"HAVE_GNUTLS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_GNUTLS_SNI_TRUE}" && test -z "${HAVE_GNUTLS_SNI_FALSE}"; then as_fn_error $? "conditional \"HAVE_GNUTLS_SNI\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_HTTPS_TRUE}" && test -z "${ENABLE_HTTPS_FALSE}"; then as_fn_error $? "conditional \"ENABLE_HTTPS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HTTPS_REQUIRE_GCRYPT_TRUE}" && test -z "${HTTPS_REQUIRE_GCRYPT_FALSE}"; then as_fn_error $? "conditional \"HTTPS_REQUIRE_GCRYPT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_GNUTLS_MTHREAD_BROKEN_TRUE}" && test -z "${HAVE_GNUTLS_MTHREAD_BROKEN_FALSE}"; then as_fn_error $? "conditional \"HAVE_GNUTLS_MTHREAD_BROKEN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_UPGRADE_TLS_TESTS_TRUE}" && test -z "${USE_UPGRADE_TLS_TESTS_FALSE}"; then as_fn_error $? "conditional \"USE_UPGRADE_TLS_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_BAUTH_TRUE}" && test -z "${ENABLE_BAUTH_FALSE}"; then as_fn_error $? "conditional \"ENABLE_BAUTH\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_DAUTH_TRUE}" && test -z "${ENABLE_DAUTH_FALSE}"; then as_fn_error $? "conditional \"ENABLE_DAUTH\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_ANYAUTH_TRUE}" && test -z "${HAVE_ANYAUTH_FALSE}"; then as_fn_error $? "conditional \"HAVE_ANYAUTH\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_UPGRADE_TRUE}" && test -z "${ENABLE_UPGRADE_FALSE}"; then as_fn_error $? "conditional \"ENABLE_UPGRADE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_COOKIE_TRUE}" && test -z "${ENABLE_COOKIE_FALSE}"; then as_fn_error $? "conditional \"ENABLE_COOKIE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_MD5_TRUE}" && test -z "${ENABLE_MD5_FALSE}"; then as_fn_error $? "conditional \"ENABLE_MD5\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_MD5_EXT_TRUE}" && test -z "${ENABLE_MD5_EXT_FALSE}"; then as_fn_error $? "conditional \"ENABLE_MD5_EXT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_SHA256_TRUE}" && test -z "${ENABLE_SHA256_FALSE}"; then as_fn_error $? "conditional \"ENABLE_SHA256\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_SHA256_EXT_TRUE}" && test -z "${ENABLE_SHA256_EXT_FALSE}"; then as_fn_error $? "conditional \"ENABLE_SHA256_EXT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_SHA512_256_TRUE}" && test -z "${ENABLE_SHA512_256_FALSE}"; then as_fn_error $? "conditional \"ENABLE_SHA512_256\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_FORK_WAITPID_TRUE}" && test -z "${HAVE_FORK_WAITPID_FALSE}"; then as_fn_error $? "conditional \"HAVE_FORK_WAITPID\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_COVERAGE_TRUE}" && test -z "${USE_COVERAGE_FALSE}"; then as_fn_error $? "conditional \"USE_COVERAGE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${RUN_ZZUF_TESTS_TRUE}" && test -z "${RUN_ZZUF_TESTS_FALSE}"; then as_fn_error $? "conditional \"RUN_ZZUF_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${FORCE_USE_ZZUF_SOCAT_TRUE}" && test -z "${FORCE_USE_ZZUF_SOCAT_FALSE}"; then as_fn_error $? "conditional \"FORCE_USE_ZZUF_SOCAT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${USE_SANITIZERS_TRUE}" && test -z "${USE_SANITIZERS_FALSE}"; then as_fn_error $? "conditional \"USE_SANITIZERS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_EXPERIMENTAL_TRUE}" && test -z "${HAVE_EXPERIMENTAL_FALSE}"; then as_fn_error $? "conditional \"HAVE_EXPERIMENTAL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by GNU libmicrohttpd $as_me 1.0.1, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to . GNU libmicrohttpd home page: . General help using GNU software: ." _ACEOF ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ GNU libmicrohttpd config.status 1.0.1 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" Copyright (C) 2021 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) printf "%s\n" "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) printf "%s\n" "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) printf "%s\n" "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX printf "%s\n" "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' FILECMD='`$ECHO "$FILECMD" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' lt_ar_flags='`$ECHO "$lt_ar_flags" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LD_RC='`$ECHO "$LD_RC" | $SED "$delay_single_quote_subst"`' reload_flag_RC='`$ECHO "$reload_flag_RC" | $SED "$delay_single_quote_subst"`' reload_cmds_RC='`$ECHO "$reload_cmds_RC" | $SED "$delay_single_quote_subst"`' old_archive_cmds_RC='`$ECHO "$old_archive_cmds_RC" | $SED "$delay_single_quote_subst"`' compiler_RC='`$ECHO "$compiler_RC" | $SED "$delay_single_quote_subst"`' GCC_RC='`$ECHO "$GCC_RC" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_RC='`$ECHO "$lt_prog_compiler_no_builtin_flag_RC" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic_RC='`$ECHO "$lt_prog_compiler_pic_RC" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl_RC='`$ECHO "$lt_prog_compiler_wl_RC" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static_RC='`$ECHO "$lt_prog_compiler_static_RC" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_RC='`$ECHO "$lt_cv_prog_compiler_c_o_RC" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc_RC='`$ECHO "$archive_cmds_need_lc_RC" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_RC='`$ECHO "$enable_shared_with_static_runtimes_RC" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec_RC='`$ECHO "$export_dynamic_flag_spec_RC" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec_RC='`$ECHO "$whole_archive_flag_spec_RC" | $SED "$delay_single_quote_subst"`' compiler_needs_object_RC='`$ECHO "$compiler_needs_object_RC" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds_RC='`$ECHO "$old_archive_from_new_cmds_RC" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_RC='`$ECHO "$old_archive_from_expsyms_cmds_RC" | $SED "$delay_single_quote_subst"`' archive_cmds_RC='`$ECHO "$archive_cmds_RC" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds_RC='`$ECHO "$archive_expsym_cmds_RC" | $SED "$delay_single_quote_subst"`' module_cmds_RC='`$ECHO "$module_cmds_RC" | $SED "$delay_single_quote_subst"`' module_expsym_cmds_RC='`$ECHO "$module_expsym_cmds_RC" | $SED "$delay_single_quote_subst"`' with_gnu_ld_RC='`$ECHO "$with_gnu_ld_RC" | $SED "$delay_single_quote_subst"`' allow_undefined_flag_RC='`$ECHO "$allow_undefined_flag_RC" | $SED "$delay_single_quote_subst"`' no_undefined_flag_RC='`$ECHO "$no_undefined_flag_RC" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_RC='`$ECHO "$hardcode_libdir_flag_spec_RC" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator_RC='`$ECHO "$hardcode_libdir_separator_RC" | $SED "$delay_single_quote_subst"`' hardcode_direct_RC='`$ECHO "$hardcode_direct_RC" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute_RC='`$ECHO "$hardcode_direct_absolute_RC" | $SED "$delay_single_quote_subst"`' hardcode_minus_L_RC='`$ECHO "$hardcode_minus_L_RC" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var_RC='`$ECHO "$hardcode_shlibpath_var_RC" | $SED "$delay_single_quote_subst"`' hardcode_automatic_RC='`$ECHO "$hardcode_automatic_RC" | $SED "$delay_single_quote_subst"`' inherit_rpath_RC='`$ECHO "$inherit_rpath_RC" | $SED "$delay_single_quote_subst"`' link_all_deplibs_RC='`$ECHO "$link_all_deplibs_RC" | $SED "$delay_single_quote_subst"`' always_export_symbols_RC='`$ECHO "$always_export_symbols_RC" | $SED "$delay_single_quote_subst"`' export_symbols_cmds_RC='`$ECHO "$export_symbols_cmds_RC" | $SED "$delay_single_quote_subst"`' exclude_expsyms_RC='`$ECHO "$exclude_expsyms_RC" | $SED "$delay_single_quote_subst"`' include_expsyms_RC='`$ECHO "$include_expsyms_RC" | $SED "$delay_single_quote_subst"`' prelink_cmds_RC='`$ECHO "$prelink_cmds_RC" | $SED "$delay_single_quote_subst"`' postlink_cmds_RC='`$ECHO "$postlink_cmds_RC" | $SED "$delay_single_quote_subst"`' file_list_spec_RC='`$ECHO "$file_list_spec_RC" | $SED "$delay_single_quote_subst"`' hardcode_action_RC='`$ECHO "$hardcode_action_RC" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in AS \ DLLTOOL \ OBJDUMP \ SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ FILECMD \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ sharedlib_from_linklib_cmd \ AR \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_import \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ lt_cv_nm_interface \ nm_file_list_spec \ lt_cv_truncate_bin \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib \ LD_RC \ reload_flag_RC \ compiler_RC \ lt_prog_compiler_no_builtin_flag_RC \ lt_prog_compiler_pic_RC \ lt_prog_compiler_wl_RC \ lt_prog_compiler_static_RC \ lt_cv_prog_compiler_c_o_RC \ export_dynamic_flag_spec_RC \ whole_archive_flag_spec_RC \ compiler_needs_object_RC \ with_gnu_ld_RC \ allow_undefined_flag_RC \ no_undefined_flag_RC \ hardcode_libdir_flag_spec_RC \ hardcode_libdir_separator_RC \ exclude_expsyms_RC \ include_expsyms_RC \ file_list_spec_RC; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ configure_time_dlsearch_path \ configure_time_lt_sys_library_path \ reload_cmds_RC \ old_archive_cmds_RC \ old_archive_from_new_cmds_RC \ old_archive_from_expsyms_cmds_RC \ archive_cmds_RC \ archive_expsym_cmds_RC \ module_cmds_RC \ module_expsym_cmds_RC \ export_symbols_cmds_RC \ prelink_cmds_RC \ postlink_cmds_RC; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "MHD_config.h") CONFIG_HEADERS="$CONFIG_HEADERS MHD_config.h" ;; "src/microhttpd/microhttpd_dll_res.rc") CONFIG_FILES="$CONFIG_FILES src/microhttpd/microhttpd_dll_res.rc" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "po/po-configure.ac") CONFIG_FILES="$CONFIG_FILES po/po-configure.ac" ;; "po/Makefile.in") CONFIG_COMMANDS="$CONFIG_COMMANDS po/Makefile.in" ;; "po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;; "libmicrohttpd.pc") CONFIG_FILES="$CONFIG_FILES libmicrohttpd.pc" ;; "w32/common/microhttpd_dll_res_vc.rc") CONFIG_FILES="$CONFIG_FILES w32/common/microhttpd_dll_res_vc.rc" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "contrib/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "doc/doxygen/libmicrohttpd.doxy") CONFIG_FILES="$CONFIG_FILES doc/doxygen/libmicrohttpd.doxy" ;; "doc/doxygen/Makefile") CONFIG_FILES="$CONFIG_FILES doc/doxygen/Makefile" ;; "doc/examples/Makefile") CONFIG_FILES="$CONFIG_FILES doc/examples/Makefile" ;; "m4/Makefile") CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "src/include/Makefile") CONFIG_FILES="$CONFIG_FILES src/include/Makefile" ;; "src/lib/Makefile") CONFIG_FILES="$CONFIG_FILES src/lib/Makefile" ;; "src/microhttpd/Makefile") CONFIG_FILES="$CONFIG_FILES src/microhttpd/Makefile" ;; "src/microhttpd_ws/Makefile") CONFIG_FILES="$CONFIG_FILES src/microhttpd_ws/Makefile" ;; "src/examples/Makefile") CONFIG_FILES="$CONFIG_FILES src/examples/Makefile" ;; "src/tools/Makefile") CONFIG_FILES="$CONFIG_FILES src/tools/Makefile" ;; "src/testcurl/Makefile") CONFIG_FILES="$CONFIG_FILES src/testcurl/Makefile" ;; "src/testcurl/https/Makefile") CONFIG_FILES="$CONFIG_FILES src/testcurl/https/Makefile" ;; "src/testzzuf/Makefile") CONFIG_FILES="$CONFIG_FILES src/testzzuf/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 printf "%s\n" "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`printf "%s\n" "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 printf "%s\n" "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. case $CONFIG_FILES in #( *\'*) : eval set x "$CONFIG_FILES" ;; #( *) : set x $CONFIG_FILES ;; #( *) : ;; esac shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`printf "%s\n" "$am_mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`$as_dirname -- "$am_mf" || $as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$am_mf" : 'X\(//\)[^/]' \| \ X"$am_mf" : 'X\(//\)$' \| \ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$am_mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` am_filepart=`$as_basename -- "$am_mf" || $as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ X"$am_mf" : 'X\(//\)$' \| \ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$am_mf" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` { echo "$as_me:$LINENO: cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles" >&5 (cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } || am_rc=$? done if test $am_rc -ne 0; then { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Something went wrong bootstrapping makefile fragments for automatic dependency tracking. If GNU make was not used, consider re-running the configure script with MAKE=\"gmake\" (or whatever is necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking). See \`config.log' for more details" "$LINENO" 5; } fi { am_dirpart=; unset am_dirpart;} { am_filepart=; unset am_filepart;} { am_mf=; unset am_mf;} { am_rc=; unset am_rc;} rm -f conftest-deps.mk } ;; "libtool":C) # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 # Copyright (C) 2014 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program or library that is built # using GNU Libtool, you may include this file under the same # distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # The names of the tagged configurations supported by this script. available_tags='RC ' # Configured defaults for sys_lib_dlsearch_path munging. : \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Assembler program. AS=$lt_AS # DLL creation program. DLLTOOL=$lt_DLLTOOL # Object dumper program. OBJDUMP=$lt_OBJDUMP # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shared archive member basename,for filename based shared library versioning on AIX. shared_archive_member_spec=$shared_archive_member_spec # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # A file(cmd) program that detects file types. FILECMD=$lt_FILECMD # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive (by configure). lt_ar_flags=$lt_ar_flags # Flags to create an archive. AR_FLAGS=\${ARFLAGS-"\$lt_ar_flags"} # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm into a list of symbols to manually relocate. global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # The name lister interface. nm_interface=$lt_lt_cv_nm_interface # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and where our libraries should be installed. lt_sysroot=$lt_sysroot # Command to truncate a binary pipe. lt_truncate_bin=$lt_lt_cv_truncate_bin # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Detected run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path # Explicit LT_SYS_LIBRARY_PATH set during ./configure time. configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF cat <<'_LT_EOF' >> "$cfgfile" # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # ### END FUNCTIONS SHARED WITH CONFIGURE _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain=$ac_aux_dir/ltmain.sh # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? $SED '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" cat <<_LT_EOF >> "$ofile" # ### BEGIN LIBTOOL TAG CONFIG: RC # The linker used to build libraries. LD=$lt_LD_RC # How to create reloadable object files. reload_flag=$lt_reload_flag_RC reload_cmds=$lt_reload_cmds_RC # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds_RC # A language specific compiler. CC=$lt_compiler_RC # Is the compiler the GNU compiler? with_gcc=$GCC_RC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_RC # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_RC # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_RC # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_RC # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object_RC # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds_RC archive_expsym_cmds=$lt_archive_expsym_cmds_RC # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds_RC module_expsym_cmds=$lt_module_expsym_cmds_RC # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld_RC # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_RC # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_RC # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_RC # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute_RC # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L_RC # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_RC # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic_RC # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath_RC # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_RC # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols_RC # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_RC # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_RC # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_RC # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds_RC # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds_RC # Specify filename containing input files. file_list_spec=$lt_file_list_spec_RC # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_RC # ### END LIBTOOL TAG CONFIG: RC _LT_EOF ;; "po/Makefile.in":C) echo "Skipping update of po/Makefile.in" echo "Real update of po/Makefile.in for 'make dist' is performed by po-config.status" ;; "po-directories":C) echo "Skipping po-directories command." echo "Real po-directories command for 'make dist' is implemented in po-config.status" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi # Finally: summary # Format flags without extra spaces for visual beauty fin_CPPFLAGS="$user_CPPFLAGS" fin_CFLAGS="$user_CFLAGS" fin_LDFLAGS="$user_LDFLAGS" if test -z "$CPPFLAGS_ac" then : fin_CPPFLAGS="${fin_CPPFLAGS}" elif test -z "${fin_CPPFLAGS}" then : fin_CPPFLAGS="$CPPFLAGS_ac" else $as_nop fin_CPPFLAGS="$CPPFLAGS_ac ${fin_CPPFLAGS}" fi if test -z "$CFLAGS_ac" then : fin_CFLAGS="${fin_CFLAGS}" elif test -z "${fin_CFLAGS}" then : fin_CFLAGS="$CFLAGS_ac" else $as_nop fin_CFLAGS="$CFLAGS_ac ${fin_CFLAGS}" fi if test -z "$LDFLAGS_ac" then : fin_LDFLAGS="${fin_LDFLAGS}" elif test -z "${fin_LDFLAGS}" then : fin_LDFLAGS="$LDFLAGS_ac" else $as_nop fin_LDFLAGS="$LDFLAGS_ac ${fin_LDFLAGS}" fi fin_lib_CPPFLAGS="$user_CPPFLAGS" fin_lib_CFLAGS="$user_CFLAGS" fin_lib_LDFLAGS="$user_LDFLAGS" if test -z "$MHD_LIB_CPPFLAGS" then : fin_lib_CPPFLAGS="${fin_lib_CPPFLAGS}" elif test -z "${fin_lib_CPPFLAGS}" then : fin_lib_CPPFLAGS="$MHD_LIB_CPPFLAGS" else $as_nop fin_lib_CPPFLAGS="$MHD_LIB_CPPFLAGS ${fin_lib_CPPFLAGS}" fi if test -z "$MHD_LIB_CFLAGS" then : fin_lib_CFLAGS="${fin_lib_CFLAGS}" elif test -z "${fin_lib_CFLAGS}" then : fin_lib_CFLAGS="$MHD_LIB_CFLAGS" else $as_nop fin_lib_CFLAGS="$MHD_LIB_CFLAGS ${fin_lib_CFLAGS}" fi if test -z "$MHD_LIB_LDFLAGS" then : fin_lib_LDFLAGS="${fin_lib_LDFLAGS}" elif test -z "${fin_lib_LDFLAGS}" then : fin_lib_LDFLAGS="$MHD_LIB_LDFLAGS" else $as_nop fin_lib_LDFLAGS="$MHD_LIB_LDFLAGS ${fin_lib_LDFLAGS}" fi if test -z "$CPPFLAGS_ac" then : fin_lib_CPPFLAGS="${fin_lib_CPPFLAGS}" elif test -z "${fin_lib_CPPFLAGS}" then : fin_lib_CPPFLAGS="$CPPFLAGS_ac" else $as_nop fin_lib_CPPFLAGS="$CPPFLAGS_ac ${fin_lib_CPPFLAGS}" fi if test -z "$CFLAGS_ac" then : fin_lib_CFLAGS="${fin_lib_CFLAGS}" elif test -z "${fin_lib_CFLAGS}" then : fin_lib_CFLAGS="$CFLAGS_ac" else $as_nop fin_lib_CFLAGS="$CFLAGS_ac ${fin_lib_CFLAGS}" fi if test -z "$LDFLAGS_ac" then : fin_lib_LDFLAGS="${fin_lib_LDFLAGS}" elif test -z "${fin_lib_LDFLAGS}" then : fin_lib_LDFLAGS="$LDFLAGS_ac" else $as_nop fin_lib_LDFLAGS="$LDFLAGS_ac ${fin_lib_LDFLAGS}" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Toolchain settings: CC=$CC User/system/default flags: CPPFLAGS=\"$user_CPPFLAGS\" CFLAGS= \"$user_CFLAGS\" LDFLAGS= \"$user_LDFLAGS\" Final set of the flags for tests and examples: CPPFLAGS=\"$fin_CPPFLAGS\" CFLAGS= \"$fin_CFLAGS\" LDFLAGS= \"$fin_LDFLAGS\" Final set of the flags for ${PACKAGE_NAME} library: CPPFLAGS=\"$fin_lib_CPPFLAGS\" CFLAGS= \"$fin_lib_CFLAGS\" LDFLAGS= \"$fin_lib_LDFLAGS\" " >&5 printf "%s\n" "$as_me: Toolchain settings: CC=$CC User/system/default flags: CPPFLAGS=\"$user_CPPFLAGS\" CFLAGS= \"$user_CFLAGS\" LDFLAGS= \"$user_LDFLAGS\" Final set of the flags for tests and examples: CPPFLAGS=\"$fin_CPPFLAGS\" CFLAGS= \"$fin_CFLAGS\" LDFLAGS= \"$fin_LDFLAGS\" Final set of the flags for ${PACKAGE_NAME} library: CPPFLAGS=\"$fin_lib_CPPFLAGS\" CFLAGS= \"$fin_lib_CFLAGS\" LDFLAGS= \"$fin_lib_LDFLAGS\" " >&6;} { fin_CPPFLAGS=; unset fin_CPPFLAGS;} { fin_CFLAGS=; unset fin_CFLAGS;} { fin_LDFLAGS=; unset fin_LDFLAGS;} { fin_lib_CPPFLAGS=; unset fin_lib_CPPFLAGS;} { fin_lib_CFLAGS=; unset fin_lib_CFLAGS;} { fin_lib_LDFLAGS=; unset fin_lib_LDFLAGS;} if test "x$os_is_windows" = x"yes" then : os_ver_msg=" Target W32 ver: ${mhd_w32_ver_msg}" else $as_nop { os_ver_msg=; unset os_ver_msg;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: GNU libmicrohttpd ${PACKAGE_VERSION} Configuration Summary: Target directory: ${prefix} Cross-compiling: ${cross_compiling} Operating System: ${mhd_host_os}${os_ver_msg} Threading lib: ${USE_THREADS} Inter-thread comm: ${use_itc} Shutdown of listening socket triggers select: ${mhd_cv_host_shtdwn_trgr_select} poll support: ${enable_poll=no} epoll support: ${enable_epoll=no} sendfile used: ${found_sendfile} HTTPS support: ${MSG_HTTPS} Messages: ${enable_messages} Cookie parsing: ${enable_cookie} Postproc: ${enable_postprocessor} Basic auth.: ${enable_bauth} Digest auth.: ${enable_dauth} Digest auth. defaults: ${dauth_defs_MSG} MD5: ${enable_md5_MSG} SHA-256: ${enable_sha256_MSG} SHA-512/256: ${enable_sha512_256_MSG} HTTP \"Upgrade\": ${enable_httpupgrade} Compact code: ${enable_compact_code} (${compact_code_MSG}) Use thread names: ${enable_thread_names} Use debug asserts: ${use_asserts_MSG=no} Use sanitizers: ${enabled_sanitizers:=no} Build static lib: ${enable_static} Build shared lib: ${enable_shared} Build docs: ${enable_doc} Build examples: ${enable_examples} Build tools: ${enable_examples} Test with libcurl: ${MSG_CURL} Heavy tests: ${use_heavy_tests_MSG} Fuzzing tests: ${run_zzuf_tests_MSG=no} " >&5 printf "%s\n" "$as_me: GNU libmicrohttpd ${PACKAGE_VERSION} Configuration Summary: Target directory: ${prefix} Cross-compiling: ${cross_compiling} Operating System: ${mhd_host_os}${os_ver_msg} Threading lib: ${USE_THREADS} Inter-thread comm: ${use_itc} Shutdown of listening socket triggers select: ${mhd_cv_host_shtdwn_trgr_select} poll support: ${enable_poll=no} epoll support: ${enable_epoll=no} sendfile used: ${found_sendfile} HTTPS support: ${MSG_HTTPS} Messages: ${enable_messages} Cookie parsing: ${enable_cookie} Postproc: ${enable_postprocessor} Basic auth.: ${enable_bauth} Digest auth.: ${enable_dauth} Digest auth. defaults: ${dauth_defs_MSG} MD5: ${enable_md5_MSG} SHA-256: ${enable_sha256_MSG} SHA-512/256: ${enable_sha512_256_MSG} HTTP \"Upgrade\": ${enable_httpupgrade} Compact code: ${enable_compact_code} (${compact_code_MSG}) Use thread names: ${enable_thread_names} Use debug asserts: ${use_asserts_MSG=no} Use sanitizers: ${enabled_sanitizers:=no} Build static lib: ${enable_static} Build shared lib: ${enable_shared} Build docs: ${enable_doc} Build examples: ${enable_examples} Build tools: ${enable_examples} Test with libcurl: ${MSG_CURL} Heavy tests: ${use_heavy_tests_MSG} Fuzzing tests: ${run_zzuf_tests_MSG=no} " >&6;} if test "x$enable_https" = "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: HTTPS subsystem configuration: License : LGPL version 2.1 or any later version " >&5 printf "%s\n" "$as_me: HTTPS subsystem configuration: License : LGPL version 2.1 or any later version " >&6;} else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: License : LGPLv2.1+ or eCos " >&5 printf "%s\n" "$as_me: License : LGPLv2.1+ or eCos " >&6;} fi if test "x$enable_bauth" != "xyes" || \ test "x$enable_dauth" != "xyes" || \ test "x${enable_md5}" = "xno" || \ test "x${enable_sha256}" = "xno" || \ test "x${enable_sha512_256}" != "xyes" || \ test "x${USE_THREADS}" = "xnone" || \ test "x$enable_httpupgrade" != "xyes" || \ test "x$enable_cookie" != "xyes" || \ test "x$enable_httpupgrade" != "xyes" || \ test "x$enable_postprocessor" != "xyes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: This will be a custom build with missing symbols. Do NOT use this build in a distribution. Building with these kinds of configure options is only for custom builds for embedded systems." >&5 printf "%s\n" "$as_me: WARNING: This will be a custom build with missing symbols. Do NOT use this build in a distribution. Building with these kinds of configure options is only for custom builds for embedded systems." >&2;} fi libmicrohttpd-1.0.1/INSTALL0000644000175000017500000003662614566140066011114 Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell command './configure && make && make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the 'README' file for instructions specific to this package. Some packages provide this 'INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The 'configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a 'Makefile' in each directory of the package. It may also create one or more '.h' files containing system-dependent definitions. Finally, it creates a shell script 'config.status' that you can run in the future to recreate the current configuration, and a file 'config.log' containing compiler output (useful mainly for debugging 'configure'). It can also use an optional file (typically called 'config.cache' and enabled with '--cache-file=config.cache' or simply '-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how 'configure' could check whether to do them, and mail diffs or instructions to the address given in the 'README' so they can be considered for the next release. If you are using the cache, and at some point 'config.cache' contains results you don't want to keep, you may remove or edit it. The file 'configure.ac' (or 'configure.in') is used to create 'configure' by a program called 'autoconf'. You need 'configure.ac' if you want to change it or regenerate 'configure' using a newer version of 'autoconf'. The simplest way to compile this package is: 1. 'cd' to the directory containing the package's source code and type './configure' to configure the package for your system. Running 'configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type 'make' to compile the package. 3. Optionally, type 'make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type 'make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the 'make install' phase executed with root privileges. 5. Optionally, type 'make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior 'make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing 'make clean'. To also remove the files that 'configure' created (so you can compile the package for a different kind of computer), type 'make distclean'. There is also a 'make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type 'make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide 'make distcheck', which can by used by developers to test that all other targets like 'make install' and 'make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the 'configure' script does not know about. Run './configure --help' for details on some of the pertinent environment variables. You can give 'configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU 'make'. 'cd' to the directory where you want the object files and executables to go and run the 'configure' script. 'configure' automatically checks for the source code in the directory that 'configure' is in and in '..'. This is known as a "VPATH" build. With a non-GNU 'make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use 'make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple '-arch' options to the compiler but only a single '-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the 'lipo' tool if you have problems. Installation Names ================== By default, 'make install' installs the package's commands under '/usr/local/bin', include files under '/usr/local/include', etc. You can specify an installation prefix other than '/usr/local' by giving 'configure' the option '--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option '--exec-prefix=PREFIX' to 'configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like '--bindir=DIR' to specify different values for particular kinds of files. Run 'configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of '${prefix}', so that specifying just '--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to 'configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the 'make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, 'make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of '${prefix}'. Any directories that were specified during 'configure', but not in terms of '${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the 'DESTDIR' variable. For example, 'make install DESTDIR=/alternate/directory' will prepend '/alternate/directory' before all installation names. The approach of 'DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of '${prefix}' at 'configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving 'configure' the option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. Some packages pay attention to '--enable-FEATURE' options to 'configure', where FEATURE indicates an optional part of the package. They may also pay attention to '--with-PACKAGE' options, where PACKAGE is something like 'gnu-as' or 'x' (for the X Window System). The 'README' should mention any '--enable-' and '--with-' options that the package recognizes. For packages that use the X Window System, 'configure' can usually find the X include and library files automatically, but if it doesn't, you can use the 'configure' options '--x-includes=DIR' and '--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of 'make' will be. For these packages, running './configure --enable-silent-rules' sets the default to minimal output, which can be overridden with 'make V=1'; while running './configure --disable-silent-rules' sets the default to verbose, which can be overridden with 'make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX 'make' updates targets which have the same timestamps as their prerequisites, which makes it generally unusable when shipped generated files such as 'configure' are involved. Use GNU 'make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its '' header file. The option '-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put '/usr/ucb' early in your 'PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in '/usr/bin'. So, if you need '/usr/ucb' in your 'PATH', put it _after_ '/usr/bin'. On Haiku, software installed for all users goes in '/boot/common', not '/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features 'configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, 'configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the '--build=TYPE' option. TYPE can either be a short name for the system type, such as 'sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file 'config.sub' for the possible values of each field. If 'config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option '--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with '--host=TYPE'. Sharing Defaults ================ If you want to set default values for 'configure' scripts to share, you can create a site shell script called 'config.site' that gives default values for variables like 'CC', 'cache_file', and 'prefix'. 'configure' looks for 'PREFIX/share/config.site' if it exists, then 'PREFIX/etc/config.site' if it exists. Or, you can set the 'CONFIG_SITE' environment variable to the location of the site script. A warning: not all 'configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to 'configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the 'configure' command line, using 'VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified 'gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an Autoconf limitation. Until the limitation is lifted, you can use this workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash 'configure' Invocation ====================== 'configure' recognizes the following options to control how it operates. '--help' '-h' Print a summary of all of the options to 'configure', and exit. '--help=short' '--help=recursive' Print a summary of the options unique to this package's 'configure', and exit. The 'short' variant lists options used only in the top level, while the 'recursive' variant lists options also present in any nested packages. '--version' '-V' Print the version of Autoconf used to generate the 'configure' script, and exit. '--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally 'config.cache'. FILE defaults to '/dev/null' to disable caching. '--config-cache' '-C' Alias for '--cache-file=config.cache'. '--quiet' '--silent' '-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to '/dev/null' (any error messages will still be shown). '--srcdir=DIR' Look for the package's source code in directory DIR. Usually 'configure' can determine that directory automatically. '--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. '--no-create' '-n' Run the configure checks, but stop before creating any output files. 'configure' also accepts some other, not widely useful, options. Run 'configure --help' for more details. libmicrohttpd-1.0.1/Makefile.am0000644000175000017500000004065614445225034012110 # This Makefile.am is in the public domain ACLOCAL_AMFLAGS = -I m4 SUBDIRS = contrib m4 src . if BUILD_DOC SUBDIRS += doc endif W32COMMON = w32/common/gen_dll_res.ps1 w32/common/microhttpd_dll_res_vc.rc.in w32/common/microhttpd_dll_res_vc.rc \ w32/common/MHD_config.h w32/common/vs_dirs.props \ w32/common/common-build-settings.props w32/common/libmicrohttpd-build-settings.props \ w32/common/apps-build-settings.props \ w32/common/project-configs.props w32/common/project-configs-xp.props \ w32/common/libmicrohttpd-files.vcxproj w32/common/libmicrohttpd-filters.vcxproj \ w32/common/hellobrowser-files.vcxproj w32/common/hellobrowser-filters.vcxproj W32VS2013 = w32/VS2013/libmicrohttpd.vcxproj w32/VS2013/libmicrohttpd.vcxproj.filters \ w32/VS2013/hellobrowser.vcxproj w32/VS2013/hellobrowser.vcxproj.filters \ w32/VS2013/simplepost.vcxproj w32/VS2013/largepost.vcxproj \ w32/VS2013/libmicrohttpd.sln W32VS2015 = w32/VS2015/libmicrohttpd.vcxproj w32/VS2015/libmicrohttpd.vcxproj.filters \ w32/VS2015/hellobrowser.vcxproj w32/VS2015/hellobrowser.vcxproj.filters \ w32/VS2015/simplepost.vcxproj w32/VS2015/largepost.vcxproj \ w32/VS2015/libmicrohttpd.sln W32VS2017 = w32/VS2017/libmicrohttpd.vcxproj w32/VS2017/libmicrohttpd.vcxproj.filters \ w32/VS2017/hellobrowser.vcxproj w32/VS2017/hellobrowser.vcxproj.filters \ w32/VS2017/simplepost.vcxproj w32/VS2017/largepost.vcxproj \ w32/VS2017/libmicrohttpd.sln W32VS2019 = w32/VS2019/libmicrohttpd.vcxproj w32/VS2019/libmicrohttpd.vcxproj.filters \ w32/VS2019/hellobrowser.vcxproj w32/VS2019/hellobrowser.vcxproj.filters \ w32/VS2019/simplepost.vcxproj w32/VS2019/largepost.vcxproj \ w32/VS2019/libmicrohttpd.sln W32VS2022 = w32/VS2022/libmicrohttpd.vcxproj w32/VS2022/libmicrohttpd.vcxproj.filters \ w32/VS2022/hellobrowser.vcxproj w32/VS2022/hellobrowser.vcxproj.filters \ w32/VS2022/simplepost.vcxproj w32/VS2022/largepost.vcxproj \ w32/VS2022/libmicrohttpd.sln W32VSAV = w32/VS-Any-Version/libmicrohttpd.vcxproj w32/VS-Any-Version/libmicrohttpd.vcxproj.filters \ w32/VS-Any-Version/hellobrowser.vcxproj w32/VS-Any-Version/hellobrowser.vcxproj.filters \ w32/VS-Any-Version/simplepost.vcxproj w32/VS-Any-Version/largepost.vcxproj \ w32/VS-Any-Version/libmicrohttpd.sln EXTRA_DIST = \ libmicrohttpd.pc.in \ $(W32COMMON) $(W32VS2013) $(W32VS2015) $(W32VS2017) \ $(W32VS2019) $(W32VS2022) $(W32VSAV) pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libmicrohttpd.pc EXTRA_DIST += pre-dist-hook-dummy MOSTLYCLEANFILES = pre-dist-hook-dummy DISTCLEANFILES = MAINTAINERCLEANFILES = m4/c_backported.m4 pre-dist-hook-dummy: pre-dist-hook Makefile @echo "dummy" > $@ dist-hook: dist-po @chmod u+w '$(distdir)/pre-dist-hook-dummy' && \ rm -f '$(distdir)/pre-dist-hook-dummy' @rm -f pre-dist-hook-dummy @if test -w '$(distdir)/m4/c_backported.m4'; then \ echo "Use empty m4/c_backported.m4 for dist target"; \ touch -r '$(distdir)/m4/c_backported.m4' '$(distdir)/m4/c_backported.m4-tmst' && \ echo 'dnl Not used for distribution' > '$(distdir)/m4/c_backported.m4' && \ touch -r '$(distdir)/m4/c_backported.m4-tmst' '$(distdir)/m4/c_backported.m4' && \ rm -f '$(distdir)/m4/c_backported.m4-tmst'; \ else \ true; \ fi dist-custm: distdir @test -n "$(ARC_CMD)" || \ { echo 'The valid archive command must be defined by "ARC_CMD".' >&2; false; } @test -n "$(ARC_EXT)" || \ { echo 'The archive file extension must be set by "ARC_EXT".' >&2; false; } -rm -f '$(distdir).$(ARC_EXT)' tardir=$(distdir) && $(am__tar) | $(ARC_CMD) >$(distdir).$(ARC_EXT) $(am__post_remove_distdir) dist-custm2: distdir @test -n "$(ARC_CMD)" || \ { echo 'The valid archive command must be defined by "ARC_CMD".' >&2; false; } @test -n "$(ARC_EXT)" || \ { echo 'The archive file extension must be set by "ARC_EXT".' >&2; false; } -rm -f '$(distdir).$(ARC_EXT)' tardir=$(distdir) && $(am__tar) >$(distdir).tar && $(ARC_CMD) $(distdir).tar rm -f $(distdir).tar $(am__post_remove_distdir) pre-dist-hook: pre-dist-hook-doc @echo "Preparing to make dist" pre-dist-hook-doc: @echo "Preparing to make dist in doc" @if test -w '$(top_srcdir)/doc' ; then \ $(am__cd) doc && $(MAKE) $(AM_MAKEFLAGS) update-stamp; \ else \ echo "Source tree is read-only, skipping force doc update"; \ fi; .PHONY: pre-dist-hook pre-dist-hook-doc # Works with old automake versions (<1.12.2) as "false" MHD_V = $(AM_V_P) false distclean-local: distclean-po maintainer-clean-local: maintainer-clean-po srcdir_po = $(top_srcdir)/po PO_ACLOCAL_M4 = $(srcdir_po)/aclocal.m4 PO_MAIN_FILES = $(srcdir_po)/Makefile.in.in $(srcdir_po)/remove-potcdate.sin \ $(srcdir_po)/quot.sed $(srcdir_po)/boldquot.sed \ $(srcdir_po)/en@quot.header $(srcdir_po)/en@boldquot.header \ $(srcdir_po)/insert-header.sin $(srcdir_po)/Rules-quot PO_EXTRA_FILES = $(srcdir_po)/Makevars.template PO_ROOT_FILES = $(srcdir_po)/ABOUT-NLS PO_M4_FILES = $(srcdir_po)/m4/gettext.m4 $(srcdir_po)/m4/host-cpu-c-abi.m4 \ $(srcdir_po)/m4/iconv.m4 $(srcdir_po)/m4/intlmacosx.m4 \ $(srcdir_po)/m4/lib-ld.m4 $(srcdir_po)/m4/lib-link.m4 \ $(srcdir_po)/m4/lib-prefix.m4 $(srcdir_po)/m4/nls.m4 \ $(srcdir_po)/m4/po.m4 $(srcdir_po)/m4/progtest.m4 PO_AUX_FILES = $(srcdir_po)/$(MHD_AUX_DIR)/config.rpath # All autopoint-created files PO_ALL_FILES = $(PO_MAIN_FILES) $(PO_EXTRA_FILES) $(PO_ROOT_FILES) \ $(PO_M4_FILES) $(PO_AUX_FILES) am__po_aclocal_m4_deps = $(PO_M4_FILES) $(srcdir_po)/configure.ac am__po_configure_deps = $(am__po_aclocal_m4_deps) $(PO_ACLOCAL_M4) $(PO_ACLOCAL_M4): $(am__po_aclocal_m4_deps) @{ $(MHD_V) && echo "Building $@" ; } || true @echo "cd $(srcdir_po) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)" && \ $(am__cd) '$(srcdir_po)' && $(ACLOCAL) $(ACLOCAL_AMFLAGS) # Do update po/configure.ac only if template files updated $(srcdir_po)/configure.ac: $(srcdir_po)/po-configure.ac.in $(top_srcdir)/configure.ac @{ $(MHD_V) && echo "Building $@" ; } || true @$(MAKE) $(AM_MAKEFLAGS) po/po-configure.ac @cp -f po/po-configure.ac '$@' $(top_srcdir)/po-configure: $(srcdir_po)/configure.ac $(PO_ACLOCAL_M4) $(PO_AUX_FILES) $(srcdir_po)/$(MHD_AUX_DIR)/install-sh @{ $(MHD_V) && echo "Building $@" ; } || true @echo "cd $(srcdir_po) && $(AUTOCONF)" && \ ( $(am__cd) '$(srcdir_po)' && $(AUTOCONF) ) mv -f '$(srcdir_po)/configure' '$@' -chmod a-x '$@' EXTRA_DIST += $(top_srcdir)/$(MHD_AUX_DIR)/config.rpath $(srcdir_po)/$(MHD_AUX_DIR)/install-sh \ $(PO_ALL_FILES) \ $(PO_ACLOCAL_M4) \ $(srcdir_po)/po-configure.ac.in $(srcdir_po)/configure.ac \ $(top_srcdir)/po-configure \ $(srcdir_po)/stamp-m.in DISTCLEANFILES += config.main.log po-config.log po/stamp-m MAINTAINERCLEANFILES += $(srcdir_po)/configure.ac $(srcdir_po)/stamp-m.in: @: > '$@' po-config.status: $(top_srcdir)/po-configure $(top_srcdir)/$(MHD_AUX_DIR)/install-sh $(top_srcdir)/$(MHD_AUX_DIR)/config.rpath @if test -f config.log; then \ mv -f config.log config.main.log; \ else \ true; \ fi @SHELL@ '$(top_srcdir)/po-configure' $(ac_configure_args) --silent --no-create --no-recursion --disable-option-checking @mv -f config.log po-config.log @if test -f config.main.log; then \ mv -f config.main.log config.log; \ else \ true; \ fi po/Makefile: $(srcdir_po)/Makefile.in.in $(srcdir_po)/Makevars po-config.status $(srcdir_po)/POTFILES.in $(srcdir_po)/stamp-m.in @: && @SHELL@ ./po-config.status po/stamp-m po/Makefile.in po-directories dist-po: po/Makefile $(PO_MAIN_FILES) @dir1="po"; dir2="$(distdir)/po"; \ $(am__relativize); \ rel_distsubdir=$$reldir; \ echo "cd po && $(MAKE) $(AM_MAKEFLAGS) distdir='$$rel_distsubdir' distdir" && \ $(am__cd) po && $(MAKE) $(AM_MAKEFLAGS) distdir="$$rel_distsubdir" distdir $(srcdir_po)/POTFILES.in: $(top_srcdir)/src/microhttpd/Makefile.am @echo "cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) update-po-POTFILES.in" && \ $(am__cd) '$(top_builddir)/src/microhttpd' && $(MAKE) $(AM_MAKEFLAGS) update-po-POTFILES.in AUTOPOINT = autopoint AUTOPOINT_FLAGS = APIM_LOCK_BASE = autopoint-updating-lock APIM_TMSTMP_BASE = autopoint-timestamp APIM_TMSTMP_TMP_BASE = $(APIM_TMSTMP_BASE)-tmp APIM_TRIGGER_BASE = autopoint-trigger APIM_LOCK = $(srcdir_po)/$(APIM_LOCK_BASE) APIM_TMSTMP = $(srcdir_po)/$(APIM_TMSTMP_BASE) APIM_TMSTMP_TMP = $(srcdir_po)/$(APIM_TMSTMP_TMP_BASE) APIM_TRIGGER = $(srcdir_po)/$(APIM_TRIGGER_BASE) # Run 'autopoint' even if no file missing FORCE_AUTOPOINT_CHECK = no LOCK_TIMEOUT_VALUE = 120 EXTRA_DIST += $(APIM_TMSTMP) $(APIM_TRIGGER) sleep_with_timeout = \ sleep 1; \ sec_waiting=`expr ${sec_waiting} + 1`; \ if test $${sec_waiting} -gt '$(LOCK_TIMEOUT_VALUE)'; then \ echo "Waiting timeout" 1>&2; \ rmdir "$${lock_name}" ; \ exit 1; \ fi wait_for_unlock = \ test -n "$${lock_name}" || lock_name='$(APIM_LOCK)'; \ if test -d "$${lock_name}"; then \ { $(MHD_V) && \ echo "Autopoint files are being updated in parallel thread, wait"; } || : ; \ sec_waiting=0; \ while test -d "$${lock_name}"; do \ $(sleep_with_timeout) ; \ done; \ fi apim_prepare = \ $(am__cd) '$(srcdir_po)' || exit 1; \ lock_name='$(APIM_LOCK_BASE)'; \ { trap "rm -rf $(APIM_TMSTMP_BASE) $(APIM_TMSTMP_TMP_BASE) $${lock_name} po" HUP ABRT INT TERM 2>/dev/null && \ trap "rm -rf $(APIM_TMSTMP_BASE) $(APIM_TMSTMP_TMP_BASE) $${lock_name} po" PIPE 2>/dev/null ; } || \ trap "rm -rf $(APIM_TMSTMP_BASE) $(APIM_TMSTMP_TMP_BASE) $${lock_name} po" 1 2 13 15; \ lock_held='false'; \ sec_waiting=0; \ while : ; do \ if mkdir "$${lock_name}" 2>/dev/null; then lock_held=':' ; else : ; fi; \ $${lock_held} && break || : ; \ test 'xyes' = 'x$(FORCE_AUTOPOINT_CHECK)' || break ; \ $(sleep_with_timeout) ; \ done; \ if $${lock_held} ; then \ rm -f '$(APIM_TMSTMP_BASE)' '$(APIM_TMSTMP_TMP_BASE)' || exit 1; \ echo 'timestamp' > '$(APIM_TMSTMP_TMP_BASE)' || exit 1; \ if test 'xyes' = 'x$(FORCE_AUTOPOINT_CHECK)'; then \ call_autopoint=':'; check_all='false'; \ else \ call_autopoint='false'; check_all=':'; \ fi; \ if $(MHD_V) ; then apim_echo='echo' ; else apim_echo=':'; fi ;\ $$apim_echo "Sync autopoint files"; \ files_missing='false'; \ $(MKDIR_P) 'po'; \ $(MKDIR_P) '$(MHD_AUX_DIR)'; \ main_f_names=`for f in $(PO_MAIN_FILES) $(PO_EXTRA_FILES); do echo "$$f"; done | $(SED) -e 's|^.*/||'`; \ root_f_names=`for f in $(PO_ROOT_FILES); do echo "$$f"; done | $(SED) -e 's|^.*/||'`; \ m4_f_names=`for f in $(PO_M4_FILES); do echo "$$f"; done | $(SED) -e 's|^.*/||'`; \ aux_f_names=`for f in $(PO_AUX_FILES); do echo "$$f"; done | $(SED) -e 's|^.*/||'`; \ for f in $${main_f_names}; do \ if test -f "$$f"; then \ cp -f "$$f" "po/$$f" ; \ else \ $$apim_echo "Missing $(srcdir_po)/$$f" ; \ files_missing=':' ; \ fi; \ done; \ if $${check_all} ; then \ for f in $${root_f_names}; do \ if test -f "./$$f"; then : ; \ else \ $$apim_echo "Missing $(srcdir_po)/$$f" ; \ files_missing=':' ; \ fi; \ done; \ for f in $${m4_f_names}; do \ if test -f "m4/$$f"; then : ; \ else \ $$apim_echo "Missing $(srcdir_po)/m4/$$f" ; \ files_missing=':' ; \ fi; \ done; \ for f in $${aux_f_names}; do \ if test -f "$(MHD_AUX_DIR)/$$f"; then : ;\ else \ $$apim_echo "Missing $(srcdir_po)/$(MHD_AUX_DIR)/$$f" ; \ files_missing=':' ; \ fi; \ done; \ fi; \ if $${files_missing} ; then \ call_autopoint=':' ; \ $$apim_echo "Some files are missing, call autopoint to restore them" ; \ elif $${call_autopoint}; then $$apim_echo "Check and update autopoint files" ; \ fi; \ rc_code=0; \ if $${call_autopoint} ; then \ echo ' cd $(srcdir_po) && $(AUTOPOINT) $(AUTOPOINT_FLAGS)'; \ '$(AUTOPOINT)' $(AUTOPOINT_FLAGS) || rc_code=1; \ fi; \ if test "$${rc_code}" = "0"; then \ $$apim_echo "Re-sync autopoint files back"; \ for f in $${aux_f_names}; do \ if test -f "$(MHD_AUX_DIR)/$$f"; then \ touch -f "$(MHD_AUX_DIR)/$$f" && \ cp -f "$(MHD_AUX_DIR)/$$f" "../$(MHD_AUX_DIR)/$$f"; \ else \ $$apim_echo "Still missing $(srcdir_po)/$(MHD_AUX_DIR)/$$f" 1>&2 ; \ rc_code=1; \ fi; \ done; \ for f in $${m4_f_names}; do \ if test -f "m4/$$f"; then \ touch "m4/$$f"; \ else \ $$apim_echo "Still missing $(srcdir_po)/m4/$$f" 1>&2 ; \ rc_code=1; \ fi; \ done; \ for f in $${root_f_names}; do \ if test -f "./$$f"; then \ touch "./$$f"; \ else \ $$apim_echo "Still missing $(srcdir_po)/$$f" 1>&2 ; \ rc_code=1; \ fi; \ done; \ for f in $${main_f_names}; do \ if test -f "po/$$f"; then \ cp -f "po/$$f" "$$f"; \ else \ $$apim_echo "Still missing $(srcdir_po)/$$f" 1>&2 ; \ rc_code=1; \ fi; \ done; \ fi; \ if test $${rc_code} = 0; then \ cp -fp '$(APIM_TMSTMP_TMP_BASE)' '$(APIM_TMSTMP_BASE)' ; \ touch -r '$(APIM_TMSTMP_TMP_BASE)' '$(APIM_TMSTMP_BASE)' ; \ $$apim_echo "All autopoint files have been synced"; \ rm -f '$(APIM_TMSTMP_TMP_BASE)'; \ else \ rm -f '$(APIM_TMSTMP_BASE)' '$(APIM_TMSTMP_TMP_BASE)'; \ fi; \ rm -fr 'po'; \ rmdir "$${lock_name}"; \ exit $${rc_code} ; \ else \ $(wait_for_unlock) ; \ test -f '$(APIM_TMSTMP_BASE)' || exit 1; \ fi; \ : mostlyclean-local: mostlyclean-autopoint-update mostlyclean-autopoint-update: -test -d '$(APIM_LOCK)' && rm -rf '$(APIM_LOCK)' -test -d '$(srcdir_po)/po' && rm -rf '$(srcdir_po)/po' rm -f '$(APIM_TMSTMP_TMP)' $(APIM_TRIGGER): @echo "autopoint files rebuild trigger" > "$@" $(APIM_TMSTMP): $(srcdir_po)/configure.ac $(APIM_TRIGGER) @ $(apim_prepare) .DELETE_ON_ERROR: $(APIM_TMSTMP) $(PO_ALL_FILES): $(APIM_TMSTMP) $(srcdir_po)/configure.ac @ ( $(apim_prepare) ) @test -f '$@' prepare-autopoint: $(srcdir_po)/configure.ac @ ( $(apim_prepare) ) @test -f '$(APIM_TMSTMP)' check-prepare-autopoint: $(srcdir_po)/$(MHD_AUX_DIR)/install-sh $(APIM_TMSTMP) @echo "Check all autopoint files"; \ files_missing='false'; \ for f in $(PO_ALL_FILES); do \ if test -f "$$f"; then : ; \ else \ echo "Missing $$f" ; \ files_missing=':' ; \ fi; \ done; \ if $${files_missing}; then \ $(MAKE) $(AM_MAKEFLAGS) prepare-autopoint || exit 1; \ else \ exit 0; \ fi # This could be used to update autopoint files for git or for 'dist' target update-autopoint-force: $(MAKE) $(AM_MAKEFLAGS) 'FORCE_AUTOPOINT_CHECK=yes' 'AUTOPOINT_FLAGS=$(AUTOPOINT_FLAGS) -f' prepare-autopoint autopoint-files-all: $(APIM_TRIGGER) $(APIM_TMSTMP) $(PO_MAIN_FILES) $(PO_EXTRA_FILES) $(PO_M4_FILES) $(PO_AUX_FILES) $(srcdir_po)/$(MHD_AUX_DIR)/install-sh $(top_srcdir)/$(MHD_AUX_DIR)/config.rpath: $(srcdir_po)/$(MHD_AUX_DIR)/config.rpath cp -f '$(srcdir_po)/$(MHD_AUX_DIR)/config.rpath' '$@' $(srcdir_po)/$(MHD_AUX_DIR)/install-sh: $(top_srcdir)/$(MHD_AUX_DIR)/install-sh $(MKDIR_P) '$(srcdir_po)/$(MHD_AUX_DIR)' cp -f '$(top_srcdir)/$(MHD_AUX_DIR)/install-sh' '$@' .PHONY: mostlyclean-autopoint-update prepare-autopoint update-autopoint-force check-prepare-autopoint autopoint-files-all distclean-po: @( if test -f po/Makefile; then \ $(am__cd) po && $(MAKE) $(AM_MAKEFLAGS) distclean; \ else \ true; \ fi ) -rm -f po-config.status po/Makefile po/stamp-m -rm -f po/POTFILES po/remove-potcdate.sed po/Makefile.in maintainer-clean-po: @( if test -f po/Makefile; then \ $(am__cd) po && $(MAKE) $(AM_MAKEFLAGS) maintainer-clean; \ else \ true; \ fi ) -rm -f po/$(PACKAGE_TARNAME).pot -rm -rf $(srcdir_po)/autom4te.cache .PHONY: distclean-po maintainer-clean-po libmicrohttpd-1.0.1/contrib/0000755000175000017500000000000014566140216011563 5libmicrohttpd-1.0.1/contrib/ascebc0000644000175000017500000000022214417460232012640 #!/bin/sh iconv -f UTF-8 -t IBM-1047 $1 > temp.file if test -x $1 then rm $1 mv temp.file $1 chmod +x $1 else rm $1 mv temp.file $1 fi libmicrohttpd-1.0.1/contrib/Makefile.am0000644000175000017500000000014014417460232013530 # This Makefile.am is in the public domain EXTRA_DIST = xcc ascebc mhd.png mhd.svg mhd_logo.png libmicrohttpd-1.0.1/contrib/Makefile.in0000644000175000017500000003600414566140140013547 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = contrib ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # This Makefile.am is in the public domain EXTRA_DIST = xcc ascebc mhd.png mhd.svg mhd_logo.png all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu contrib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu contrib/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/contrib/xcc0000644000175000017500000000015314417460232012200 #!/bin/sh c89 -Wc,'LANGLVL(EXTENDED),XPLINK' -Wl,'XPLINK' -D__STRING_CODE_SET__="ISO8859-1" -Wc,"ASCII" $@ libmicrohttpd-1.0.1/contrib/mhd_logo.png0000644000175000017500000000547114417460232014006 ‰PNG  IHDR“d§]hbKGDÿ‡Ì¿ oFFsXILÈ pHYs``ðkBÏ vpAg=ÀÁy· QIDAThÞÍ›yXGÀ{Q.£€º¢«ˆGÜhôS”€Š Ê’xÐÕ˜„àÝ1¸_PðXÅ ˆx¬dݘ¸ÆU£x­»Æ˜x®’hDTŽ®œá˜žÚ©×=Ð3]=À|ÝÈûƒî~¯Žßtw½zõª¡ÒÒ3;–dl£Ò‹«ÕIªUÔ> êXR·ß2“ž¦õ‡I›w*cýŠùoOŸ¿Ëà7/ð[Èh°øý•£IšÁ'‰L™Ø6p¯&͹We.Nþë˜Þ¬«v¬iF-¯—5`ØÌÑÄ€&‹È´l™ôÿ‰p¦ˆ"ëûécî½jbräÿzQ™ê³<)A‘ûœ%1QSÕR2©“Œ7Iæ<,ò‰;÷¤¬ú0´Sï©D&‡c2Õ,µaz± Ø~­˜OtÝ““ñ£í-0QÊ%c¢·1=+Æd©Ìª©ŽNî,ÌdoÞ—xLgÝÁhûQ¡¢úD ‚Àä{l©DL‡3oG‚šX½ˆwÚÊc7ÿµÉ”ˆi-ó  Î6 _Ÿæ1M¾ì†oJÂôÄL£ž"AÑs§†)X³^Áí’0¥Ê±¥Ë ÔJa˜&Ò?öÂÇ¡Ï$`* –‰UmdjÔ-š,Ó•.ð 2QkÅÈ„îõÁ'¾¿ŠÏ” ¯Ü¶3éã¡êÎd(SãlfêªC­•&&ôóø9ÄfúßP0Ä·‰Ã¤O‚Ø&®9–‡éökð:}a Ê7ÒûŽÈL±ÞõªUL(üÈÒFq™NtÂz;¨ÕÂeÊÿ>ïq]\¦,%Ö{>²Ž í‚êÑÆ5€8L»WPhV¼tEôGù MOf*…/ºÿKT¦Í ÷5‹9P®;e"a4™ íƒhpŽVL¦4æ>Xˤ ÀW.çÄd:¿³÷Ck™ÐaˆQgÖŠÈôwî·­fªÆ—ŽßŠÈtü“˳â©Ië@6Ì“[fB_ယ¦én7¬—Ž„äœ²¦ê0|íðw2D~Ô~bÓk˜JÞC¬õLè”(ʉLdQ;‰M¯[*I÷& ã-3ÕΠûCD&FóRËôbxD„FÌí}~¶ž e»b͸RÓVЬ"µÜa’íßøL×`¡&KEÒ &í\¬±ÙCbÚCdz#¡eõlê|šÏTNò/³ž ]…uÕÈ"Óyð5#H­çöÅ&·{|&” Ú ¼Ö0ÕÈWîd—Š\¦ÜþÐñMBËÿtÀ¦Q*S!3ò=@Di ºÑë^/Jä1iÀ¥R)ü†õËÀò>M`B[à‘S‘•Ö3é }y*ÿ>¡?ƒ*@ÅkøÉ@¨ó"1B5›ÅV3¡»°®2›ÏtÞ5ž‡jüÊ0.˜Ìò*×~ fyx!Ý:&z°éÊgª‹]ßlÓfé/a¡âŒ]šçÄ‚'¦d¾ÉyfTõ7þ k Êñjž°M˜Ðð^T¿cÜÕ»™IÞóV»S]bg¦5…_Ü7j€Ö¨neF¸µ°¢ObjX­­Ó¬“ùZ~òe¸ªÓ.½ÒîîalÐ®Ïø¨E«×'¬\:ÔMÎ*]8“™ å`B¥ÓX½ƒwøâÕë>YÚMÂË¢›ÓÙü¼/}z0%(6ÎÔ·È„6ɘÐ/¡rr»s9‰ARÎ>gY/±¦ÝëÛM²ÓóaBLèÅbBîk¹¹â>Bã­ež óz2·éG Mß{!&´S!Ä„jMébÖ²ËÌ3&»0û- ÷ÄŒpU²7Z¦ì>bæ¥îM ˆåïÍ Â@ZèW3²»’}J÷Ñg¿4-À2é+JUXJUMÄtÙÇ÷nŽ_°0~Óîã7—W`{9@§****,&í45j‹ Æ ] Ó…ª¬¢äáÙ]kccæ/_ŸöÕ½*ž'd™ªÃú{ƒøF$¹2Œ1ÇY’>=ÀÛÛ+”˜Ö«˜ìe(íŸÏQ%ôó6Šßã¦Ì˜·4åÔÃrþ]f™ª†n8)Ìd'Iƒôä$-ƒÇò+'T@*lóxÂQÅðßm™½ûȨÌ\] Ln?zx>P&…×¢ïÔ™¨u„ÛHÈdÇðhKL£ù v%“m'Fìm\'è¹£ŠÌ¤Àž£ó^wzb½(L ?]Çòý…Ÿ§ÇMóq2‚ÙF™ºNÅ%óv£7cõOQ˜LÖÁ/ .­ôaý«l^%‰Éí3õøæ™µ_ùžWvøˆÏd]Þ6¶Q®Ò˜º]ŸhøksЬZ6Ž©†Üò–„É 7C!X¤v˜^{´f˜N"zXTÇ–xIÅ„JÞcÞªaÏIL9¿Á-™¦{òqšÙùR™tL(<ã©¶˜~ÑEâ£Éf:‚\ ºTB&t½/s£ L設á8®‚S\û.[„ÏÎ0áÇ1¯ù~S>2ÏsŠßÅ›s½îJË„n27,;Í™ôÂ'Ë8.*¿u35@òƒQJ`bþ çM…+±{0D0Ò2¡=0ôºÞ 1ƒ´=ÒTöNù=—œéß°ö“g’˜P >{׸‰Ç>K½äL/9žÈtO¸½ØT*ÀEð;/Ää5Ÿ ‘Îmdzæ…4‰©“-lÑ£Ø9TX`²$m`ªÏHE5˜Ð!좙p¦JnBÒ3ÑŒ9TCdzÆÌ%PòvN=n·Š³ ‘‰†A,,q¶â:SÛLLÆl¸šÈ„ÎáMŽ¡xÑTd8S2Í1¹­IæË¦O»·•‰Ié¿UKf*k8·ÃÉêKxôø>³È$’/Ð}æßkÉL(_Ì1Œ€ød©¾=˜˜áNÍm`ºía¸èƒ `BþµSÍ0¬`ÒÎ0\Èv /°W[Þ.LO!{N­AL( {ÊàRȉ²XR3ƒ íQA¦§¾†«n8«ìaÌûKÌÄ|Àãq_I·Äp¥è—ïsÒ2ÕLe\A¥ :kÌ¥)UÒ2e»€u9f*Ã2y7-@%eªŒßX`BX¦EMQ°¤L_3Û+-1Ýd’û]š?}”’éóÁc'&ý)Ĥ™.S*•²±Í¹g ™0KNãGÃBLèñùìììó÷› ’15gÂ^ÊÝtï•Ïĉ˜j¯,dÞ%Ê1ÓtOñ•0éë ¿ßæÊŽ&ÛDcR»Ý™¢Är =yõ’0?ç¦í—n‰ÕÆ‚íÎD¹ÿÙæ’Á¤èÏýêª0¹§ÿj’µµLv=‡ÏÞxÙüz–©vѤ)ùHX*?œ2yNI³¦(Ò ™SM*­ŽÆ¥g¿à¨v‡eJÈôyKâ7¤üoE¿®q¯L‚, ¿ˆ¥J|­ãˆ¥ÿ kéÿÊ^…˜öÔÐK4û¨¤½;–ìKø?™®¤š’®¶´%tEXtdate:create2011-07-22T18:12:45+02:00 ÿÑÐ%tEXtdate:modify2011-07-22T18:12:45+02:00{¢ilIEND®B`‚libmicrohttpd-1.0.1/contrib/mhd.svg0000644000175000017500000001007614417460232012776 image/svg+xml MHD GNU libmicrohttpd-1.0.1/contrib/mhd.png0000644000175000017500000001201114417460232012752 ‰PNG  IHDRYëæìºÍbKGDÿ‡Ì¿ oFFsΫ¼;¬( pHYs``ðkBÏ vpAgéKc"ª!IDATxÚíy MÕÇÏ=óIDæJÉe|$„L‰ú¡D$™"?^Q™)e|”Y”¡¢2‡T"Sæò )S?ž7Ü»ï‰ìµÏ>çìµï=ïž³ßY9gïµöÞ÷Ý{†µ¿K»tØ3;ì¼6'W)Ï‚oùã´9OÏ‚oqY›Ì#k—ydí2¬]摵Ë<²v™GÖ. ìåý›–Í= s‹‡ÊˆÌ_²Jƒ6]ûxáA¨×z €lÊÆ¸ÚQßòÆö_p(kã•$ëß>¶INÍÂò5°Ö‡‰Ê‰15-蜞²dÈ&Ç?~‹ÕV´ïÏ‘Í}&ëMþðQ¬ÿXù7É“Õúe²É!¹^³ê.É’9™%ȦL..Á5à M¸*GVëžȦL)!É5ÊǧI‘úMy²‡+À5Ãî^"CVë¨:Ù5›nÕWK ß«6ÙI‘ƒµZƒO[•ɦö W9²a—Äî#{6Ö˜U¾fÏ¿lÓ¾Ó)gö®_ôÁ°îmj*Y­‰²d÷–6Xr®¦c¶qï_wk’#xdµï%ûCnîr«¼¹%ÕÄ+yíàjáA"[WM²g¹w]UWŒ~nZù ÕV©HÖט÷y]&8¾ïÓªÁ [ME²qúuVZŠ™Â7±¢k0&«YÝd¸ì*ýw嫨GÚ[[†J¶‚Ѓ^7‘=¦{9Mb{ëàÉÞŽf+F6¹ 6Ï72Ó ¾QÑX²ËÁQéµÈöbÁß-6ÝvT@’%5Áád¥È~­xJ,!I}Âpd׀âI*‘­Ï€Í)úÞ…o«‹¡È’àxœBd·²Y™/Úþì÷à¸õ×mÍ€m Xôd[€#”!»Ÿ¹”-‚zCŒÉþFŸÈ{^²]¡s˜àÍ{É’öàÌ EÈžŒ†Î/Ú –3Ùô™ªAvô8²¤ 8õ’dó@ß–¶ƒåM6üáD'¨@v,tÕ¾ Yò8×U²Ì«¯²™³É›ì)ðÖ'ò ûɦd‡®w@¶%¯‚“¸[ G’Ý =³[^KÚEö|^údØNד =;gXƒÉg[¸žlSè‰z?\² ‚Ó[]NÖÇ\sý:²d8ÝÐåd†ŽÅ2¬Ñd“Š‚ókÝMö]èØ&”dÉGà|Mw“mG…”lJ)аÀAdýðWÃì/0È’O@Ãý~tçý ú…_ -Yß= e‹É2ïiîɰ&“]Zʧ¡8†ìWбUÀ²f‡Íp/ÙÙЯÈÉ®M%’]Kö=ègýnÏn²¤h{ßµd™Ä÷­²›ìFÐvÛe·’…Ï›µOBO–À4ÞQøÎ ûô[î²?Æ\J¶ ôÛತ hŠà²@¿ÖÙOvH,á ¸€lèwTj4“žì3 ¹>€Èæ‡~‰Ž {¨Öð„\@–Ùdk¹>SÈ’@{w|Íý.X”dOÄÐíáe¶ƒ&X”dI_С#>@èÉV‡~¢×v“=‹î >pYæzv£CÈ’ÿ‚mñBNVòÌv²‰à¢E'|à²Ìn%Ñç¶“eLšà„š¬ä³.ûÉ^†¢ß¡„š¬äóYûÉ’‰ O]|€“eÞ)ˆJèeÙd¨Å¶  Ädƒû,˜dÉtЩšÔ@Îyw[ÁAdÓÊ^Ÿƒ¬DÖµ_’ìè`¾APÉ’ùð?Ý'1ÛSHÚEI²~FÖ °™à’õWÝfK D{–È´< D “eóºF:ˆ,a„Rñ³«Ìw?pm?PHœ,“‹ØÚId ”³˜Œ@HYСë|öåÄÉ2ù³EEv5œ[:ûÈi=~Më@€âdÙœïN"˼+AöÐó üšàWG_PtŸÂgV#e*Y#áq²p«ô|üšæ‚œÍT†dGÁY>ë(²¤9è9¾ø™ˆ_¼ÿï »Î2欣Ȉzvïéyà5ÙF‹sŒ£Èˆ€’á×…™8tŒ÷Ý6„Ó,…ªæa;Y¾ðx€) güš ¾)G`ǘì;pšÚ—Ž"ËôÆØ»Š¾Bý׎BŽ@®¸¾A3g‘= „²% \··èË®À=š£%f¢É7ikሺ™@–y¡ÔÞ* weÁ·Fœ3²§²Á‰>ç,²<áD€Þ k=ì’ê÷>8²¤œ¨|­-dyˆ à$òó8¸êÓ!Ébôº YIe.ÙszáD€Øw,nEc ÷q$YÒŽùÐ6uYFøà1d¸Mº2nE•€ó¼.¦d™^šöž£Èê…0‡÷aô+ô}M–4bÈÆÈ©ÏÚD–¹änˆ 0vîY³A†+ÄiN>„L·»¤äÐì"«>À¸ ³¯#¶‹¯çgp¨ÝrO–I«L·"ÛD–>x€¹^¯&|ûž·ªjƒ¹½,ȦÖfÑæP”±,+|€ pœIlþý¢øõ ­´éÿÐ÷ Ç+wÙF–>Àè»ç|Ïx0ô{šßͲžÂ:ø’aÝÍÊÕd.YFø€•„.¼CdÈíìgÍàûѺÈ(ý”z¤xÖ>²dqdɃŒCžuÖ®eTiu :Z“õ·äLÁ6á圢 – Ëà,g=²-²rY”õ1zº*Pk)‘[LížN‘â –!»R34kçn:ŸFß›õßÚHç`¨w,Rì—ü܉ß5ly [ÿ¶7j„éý‚K–ÔÖŒÌÚ7©¢Þ«™á…íöæúÞ• Õ´;t—ÁÜcŒØÄ¯z’²açÛ° –"»Q32ç¹ônaµ†­Ó=ɾº>®çS’ǸÀ„XÆÄ¦†Ó×r>ÜuàèéŸoÜs*ùêÙ„_\·bj¿æe+F™,il4’ˆó\¾kLì°©‹×í<~%éä®õK¦Æ5ˆá÷[hY°v¨¯Ÿ$«µ+Ød2JÈû¹@ÓÃ$°p½ÛYٙ +o–,G–>@¸R_~5 Í~gÄk4o),?…ëþ‚¹>°$Ù=áüáļSºË.§—颮ø±ª²S¸nÕ~´A’,#|€09Êzîz‹¶(⃠KÒf•‘™ÂuË7ÉòX–ì>aÿ…ðË)¼É"(†l lËŽH “%Ëä¿á$T®§ŠåƒjYI¶ÑO¬Ú½"Mö÷¢ 郘•˜tÕ2$–¬Û²cN †–£B @Rg–YL†•Ÿ)ò°O6í¼'…¯²µû¸Hö4ç^ »η°’ÈŠ*-{%C6ÃvOh‘ÇjEÚ¼³Ùú¯&(dá)²é¶ê¥Šaf+ »¯—p)/Y²é–¶õ-£›>-ªzïù¢RTβsKûVà-)¼JŸÏÏ!@6Ã’l^?f`—–µÊŒÌ[²j£ö=†Œ›¹tëù° +§ŒÐ¥UÝ{o‰)R¡N«.ýßžü•¨²Ö ¬g†Æåþi[éãÙXn(3@¿$QL bn-S%¶eÇ^¯úhåªL‰-&“H¯‹É2–·Þ+³÷ŠŠÁ¡Èj¥Ä í¹’ì5ËQóÅéÛEj›£È>xÝzñ#¹—ì5‹®5MxþÙhyƒä[ø‘\N6Ýruý^l2BdµéØ5¥¸ŸlºU/²íPŒlHÀZR‚lÆ=û·– bdÃŽà–ø—Ñ FEȦ[ù-A!«Åá–8Î(Ž:dµðW“MG$[wµ\Ñ(ŽBd5í^ÓdfA²8ÕŠí†a”"«E 7yP+JU;´·aµÈjZuã#¦d©g•¹/aK)È á`²ºæäÓZ½xƸa/·»ÓmŒ¡§)ÙzÔ¿gaûœr«ïN²´þbXS¦Äm“ ÜLÉÆSÿ~X|tÂíL÷“½fG´5¸’Œ\)Aö•S~Üzøì õö?ç%EȦÛñ!·rÑææ« ›’%©ƒ·D×7rêä(yÍ@Kž 5Ø®[1îæs²k¨ƒr‚Ã=©˜ÍoÎ'›nÛôYßšV™÷Ìœ¬Ÿ–Ñ|Ƴ“r)áW,ñä|ß6ã<7' ^6wúÊe¨³Ävƒ3بÚ|Í8»,ȤŽò å¤Ò_ó‡T$KηңÕWœ° K¢Š »Œr¨…Z‚kÈ2Q—±ÛM–Þ«þ¨È tö4UÉ’·uÚÍX²‰ÙoFœ²ò,%ö”ý‚²dýº þG°dÉ“Ôñ;ÖCÒåžÂ-ÁMdÉÅ»Y´[±dWQÇ÷YHgÜ­0Y²ŸMdEv,ÉúhÝ KÝŠÝTç¢>•É’¥lÖ"³ Ã’,®°[¡· B.Áedu)üͱdiŸ‚I"iô†Ð}Š“eåÌvk² ö­…ÔÉTר%¸,iÍ…~d'Qg,Ôÿi ¬•'»™! ÕÔÈž§ö…F›f‡Ð=³Wž,«é’—È‚O¢©Ö8ýén‡^‚ûÈ.a>´@’S„,ýíYÕl$ZÓõK³ˆŠõ1û·@5²©ô/þãöRÝnK3‹¨Yöñ(V&B\¥0g Õ­?~ .$˨…Gе¬…Èî¢Î1L+O»ê¶Û<¢"dµp ƒ$D–T¦N®4†®0XEb .$KªÁ8ÑdéR"íF¡‹GL´Š¨Y&Ïê4Y:… Æ`ËÙßÔ~ƨ3Y„,T ×"ÿ‡% JÜMáB+–¶¶Ž¨Ùc0޶M–NÕ2(òBrYjQ ²ŒZ8ýÎF,^ȯZH×%,”bQ²ma h²à«zoº,ÔËRKЂl™B¶' ô1ž,Æ]œ“Zï+FuØ‘uÈ2º ãñdÉ}Ôù5ú¾¦š+Ê-Á•d™ŠTC%ÈÒ!:éG _ñ¹jÅÉ΀zJý“J˩˽»@¥%Dþ•…È~Q•.…É’fTÃ,v:•¾iSœìZˆÊç'û)ÕPŸ€NÿZœ•Èçˆâd¯¸ÙƨïÐ)‹àÖ>ÅÉþ•’!K^¤Z†Ã¦!TSOؤ8ÙD(ŸÙ¨–2 ÅGçê2©"Š“M…¢¤È:I (Y~K5Ü#½W’ejE”#K׬Eiý×ÑY‹ìaˆÚ&ƒ!{‚J·ÉCi]¤jMF°;xdÉÊ,3d·Á@5åÈøy7OO§N7‘_‚+É~ Qiñ(²ó¨¶Æ7OסNÏÏbd?…ž‘$›”÷fÛÍ?û#T"i^]‰ÅÉ×D‘%ÏSÿþT ¥Nv ` ®$Ë”g}C–,}wãòÊ'uR/[£8ÙÁ0¥v€#KÊR­×o ègœ½¹Š“íÍ•&;‚j½~Û‰:õf–#Ë”_¢Ò\d¨_«½ ޾âd™J ?H“% ¨æ%'hцµÉ„q4ª¨–,]¬³EÆ +­µÉ~ ãÄP›¾±dÿGÉëg¼–ùÝJIm²ÌÎ%ú–,éLµ'äuê°K`Kp#YFLïõ@È®§Ú+?]$yC–#{‘Ù¶.²þ’T‡4çR\íD¥É2Ïc²Ñ÷öh²$ŽêЗþnxÛ]i²Ã` Ó‹'K?€¹5÷͇ý–åȦƒa†Òx²¤®Æµz.Á}dç0VH–I¸¹añYle%\uJ¥_ÎÜ´œrø “]à ¨Z%Èò Jv x ®#û(ƒàµ€É®æ‘]cÐY]²¿2¢&ë»C¶¸‘¸ºdŸe0•RdÈ’×ôd‡õU–ì<†@8#L-Eö€žìA£¾ª’ÝÅþŽw`:H‘e% w2©KöïÒ 0v½Ù),Ù©YŒ¬¿K ÛEŽl"SÙ2{¢aW5ÉÆiŒ…í YÒv|2KpYÿX]íÖ6zørdWÂŽ&E`${†½EHÿÈþ,²v¬Ö-d70{m3l¨¾›G9˜o8§Î0¯œ¢G7ØÖšÞêòêYydƒ]ý¸ºÆ±rÜ¢ØYáÁŽ fb®[ÁÃÜîY±ÁÏkíã®i1›ùYË®g¾ÖÄ Èlº…)ö{d¹]SÎÚ¶fIü»q}ž(©™YîOŒFðÈd±G GðÈ`9Þ3)üé‘•·šÌFðÈÊZôÛi¦#xd%­ê.‹Éxde,ç6YNÆ#‹·j“/ LÆ#‹´ü½vŠMÆ#‹±ì ç$ ÎÅ#+j¹jõžµ+Mp"Y1ËÛoî>v2YŽE*]¹þcÏô<òÃ9Ë7‘[8CÖ³ ™GÖ.óÈÚeY»Ì#k—ydí2¬]摵Ë2ÈÆ®ô,øötœ¶¶±gvØìÿT¯‰Ä eD8%tEXtdate:create2011-07-22T18:11:03+02:00RQ%tEXtdate:modify2011-07-22T18:11:03+02:00wé¯IEND®B`‚libmicrohttpd-1.0.1/NEWS0000644000175000017500000004174214566137250010556 Fri 23 Feb 2024 21:00:00 UZT Released GNU libmicrohttpd 1.0.1. This is a correction release. This release mainly fixes and improves builds with non-default configure parameters. -- Evgeny Grin (Karlson2k) Thu 01 Feb 2024 15:00:00 CET Released GNU libmicrohttpd 1.0.0. This is the first non-bugfix release since version 0.9.75 and the first ever stable release of GNU libmicrohttpd. It is a huge one with new features and fixes. The major changes: * Rewritten parsing of clients' requests, fully aligned with current RFCs (9110 and 9112) requirements. Added detailed control of strict or lenient specification enforcement. Application may choose between more compatible mode or more strict and secure mode. * Reworked Digest Auth, greater enhanced support for current RFC 7617 features. MHD currently is the only known server-side implementation with support for SHA-512/256, userhash and username in extended notation. At the same time the very old RFC2069 is supported, as well as MD5 and SHA-256. * Improved functionality in multi-threading environment, especially with external sockets polling modes. * Reworked Basic Auth, adding new convenient API functions. * Re-implemented GnuTLS initialisation. Now supported libmicrohttpd-specific system-wide configuration, as well as generic GnuTLS system-wide configuration. Application may adjust settings based on system configuration instead of specifying its own full configuration. * Tons of other new functionality and various fixes. For detailed changes see the ChangeLog or Git commit logs. Since last non-bugfix release there are 1062 commits added with 67007 lines insertions and 26616 deletions. -- Evgeny Grin (Karlson2k) Sun 28 May 2023 18:00:00 MSK Released GNU libmicrohttpd 0.9.77. This is mostly a bugfix release. This version created by taking patches from the current development branch and back-porting them on top of version 0.9.76. The most notable changes are: some improvements for Digest and Basic authorizations, fixed efficiency for TLS upgraded connections, fixed processing of folded headers in requests, fixed functionality with blocking sockets, improved and fixed internal test-suite. The more detailed list of the important changes: API changes: + Added new function MHD_get_version_bin(). Improvements and enhancements: * Digest Auth: changed algorithm identifiers in server generated headers from "md5" / "sha-256" to "MD5" / "SHA-256" to better match RFC (while clients should use caseless matching). * Improved Base64 decoding by new implementation with robust input data validation checks. * Improved configure for cross-compiling, for better compatibility with POSIX and for better compatibility with the latest compiler versions. * New internal tests: for Base64 decoding, Basic Auth and folded headers. * Supported new libcurl API in tests to mute deprecation warnings. * Supported ARM and ARM64 for VC compilers. Functionality changes: * any negative number returned by response data generation callback function is treated as an error. Previously negative values except predefined error codes could produce undefined behaviour. * Added handling of "DEBUG" preprocessor macro as an alias of "_DEBUG". Fixes: # Fixed functionality with blocking sockets. # Fixed very inefficient data pumping for upgraded TLS connections. # Fixed processing of folded headers in the requests. # Fixed data races when closing upgraded connection. # Removed duplication of "Connection: upgrade" header. # Digest auth: fixed thread sync to avoid "stale hash" results. # Fixed harmless unwanted extra data processing resulting in triggering of the assert. # Fixed tests for LTO. # Removed removed non-portable functions in examples. # Fixed delayed call of connection notification callback in thread-per-connection mode. # Fixed Address Sanitizer unpoison of memory when memory pool is destroyed. This fixed periodic ASAN error when used for a long time with the sanitizer. # Fixed compiler warnings in library code, examples, tests and configure checks. # New TLS certificates for test-suite: all with SAN fields and SHA-256 hash. # Tests: fixed tests on Darwin 22.x (Ventura). # Tests: redesigned one tests group to avoid stress-testing of the OS. -- Evgeny Grin (Karlson2k) Sun 26 Feb 2023 17:49:30 CET Released GNU libmicrohttpd 0.9.76 hotfix. -CG This is a hotfix release. This only change since previous release is fixed potential DoS vector in MHD_PostProcessor discovered by Gynvael Coldwind and Dejan Alvadzijevic (CVE-2023-27371). While the researchers have not been able to exploit this attack vector when libmicrohttpd is compiled with the standard GNU C library, it is recommended that you update MHD as soon as possible if your applications are using (optional) MHD_PostProcessor functionality. -- Evgeny Grin (Karlson2k) Sun 26 Dec 2021 20:30:00 MSK Released GNU libmicrohttpd 0.9.75 -EG This is a correction release. The main improvement is the implementation of workaround for some OSes (like OpenBSD 7) where "monotonic" clock may jump back. Now MHD is able to automatically detect such situation and recover if the jump is small. This workaround is needed with increased accuracy of connection timeout introduced in previous version, as with lower accuracy (v0.9.73 and before) these jumpbacks were unnoticeable. Other changes: fixed some compiler, Makefile, and configure warnings on specific platforms; one test further improved. -- Evgeny Grin (Karlson2k) Sun 19 Dec 2021 18:30:00 MSK Released GNU libmicrohttpd 0.9.74 This release brings a lot of fixes and improvements, and important new features. The most significant addition is the new experimental implementation of WebSockets contributed by David Gausmann. This implementation is not fully tested yet so currently it is disabled by default. Other changes include a lot of improvements and clarifications in doxy comments in microhttpd.h header file, improved compliance with the RFC HTTP specifications, the new implementation of reply header forming, the new implementation of request chunked encoding parsing, new automatic error replies, internal optimisations, and many important fixes, including fixes for long-standing bugs. More detailed list of notable changes: API changes: + Added new function MHD_get_reason_phrase_len_for(). + Added MHD_CONNECTION_INFO_HTTP_STATUS type of information queried by MHD_get_connection_info(). + Added new response flag MHD_RF_SEND_KEEP_ALIVE_HEADER to force sending of "keep-alive" header even if not required by RFC. + Added new response creation function MHD_create_response_from_buffer_with_free_callback_cls() with custom cleanup callback. + Added new response flag MHD_RF_HTTP_1_0_COMPATIBLE_STRICT with the same functionality as existing MHD_RF_HTTP_VERSION_1_0_ONLY flag. The old flag will be deprecated. + Added new response flag MHD_RF_HTTP_1_0_SERVER with the same functionality as existing MHD_RF_HTTP_VERSION_1_0_RESPONSE flag. The old flag will be deprecated. New features: + Added experimental WebSockets extension with separate header. Disabled by default as it is not fully tested yet. + Added '--enable-sanitizers[=address,undefined,leak,user-poison]' configure parameter (instead of '--enable-sanitizer'), implemented custom memory poisoning for memory pools. Improvements and enhancements: * Doxy function descriptions was corrected, clarified, extended, and improved. Now it should be much easier to learn MHD just by reading the headers. * Completely rewritten reply header forming. New implementation is more robust, simpler maintainable and expandable, and better follows RFC HTTP specifications. * Performance improvements: now HTTP version and request method are decoded one time only (previously MHD used string comparison many times during processing the data). * Rewritten request chunked payload decoding. The new implementation better conforms to the HTTP RFC, detects format problems earlier, replies to the clients with description of detected problems, handles untypical (but syntactically correct) values properly. * Added special replies for wrong/unsupported HTTP versions in requests, broken HTTP chunked encoding in requests, * As required by HTTP RFC, added automatic error replies if client used broken chunked encoding, too large chunk size, too large payload size, or broken Content-Length header. * Optimized connection's memory pool handling. * Changed timeout precision from one second to one millisecond. * Added some checks for incorrect user data, reporting problems in MHD log. * Improved performance of hash calculations functions by using compiler built-ins (if available). * Implemented SHA-1 calculations (required for WebSockets). * Added universal MSVC project that works with any (sufficiently new) version of MSVC. * Developed simple HTTP client to test MHD under very special conditions. * Implemented 45 new tests. * Improved existing tests to test more aspects of MHD. * Added check for correct results of system and libcurl functions. * Response headers are checked during forming of responses. * HTTPS tests were improved. * Added rebuild on W32 of all required files if files are missing. * Many internal optimisations and improvements. Functionality changes: * Keep-alive header is omitted by default for HTTP/1.1 connections. Use of header can be enforced by response flag. * Chunked encoding is used for HTTP/1.1 non-keep-alive connections for responses with unknown size. Previously MHD used "indication of the end of the response by closing connection" in such cases, however it is not correct for HTTP/1.1 connections as per HTTP RFC. * As required by HTTP RFC, use HTTP/1.1 version instead of HTTP/1.0 in reply headers when client is HTTP/1.0 . HTTP/1.0 version can be enforced by response flag. * User response headers are used in replies in the same order as was added by application. * Allowed tab characters in response header values. * All custom "Connection:" response headers are automatically combined into single "Connection:" header. * "keep-alive" token silently dropped from custom "Connection:" response header. "Keep-alive" cannot be enforced and used automatically if possible. * Allow tab character in custom response header value. * Disallow space character in custom response header value. * Do not allow responses with 1xx codes for HTTP/1.0 requests. * Detected and reported incorrect "Upgrade" responses. * W32 targets are changed to Vista+ by default. XP is supported still. Fixes: # Fixed short busy-waiting (up to one second) when connection is going to be expired and closed. # Fixed handling of errors during start of new connection, fixed inability to accept new connections in thread-per-connection mode due to the missing decrement of number of daemon's connections if start of new thread is failed. # Fixed incorrect parsing of LFLF, LFCR, CRCR, and bare CR as single linefeed in request header and request chunked payload. Now only CRLF or bare LF are recognized as linefeed. # Fixed response chunked encoding handling. Now it works properly with non-keep-alive connection, with fixed size replies (if chunked was enforced by header), and in other situations. # Other fixes for chunked replies. # Fixed handling of custom connection timeout in thread-per- connection mode. # Fixed wrongly used MHD_REQUEST_TERMINATED_COMPLETED_OK code for application notification when MHD_REQUEST_TERMINATED_WITH_ERROR code must be used. # Fixed code MHD_REQUEST_TERMINATED_READ_ERROR not reported (code MHD_REQUEST_TERMINATED_WITH_ERROR was incorrectly used instead). # Fixed handling of request chunked encoding with untypical formatting. # Fixed processing of last part of hex-encoded values under certain conditions. # Fixed value returned for MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE. # Fixed returned value for MHD_FEATURE_AUTOSUPPRESS_SIGPIPE on W32, now it is MHD_YES as W32 does not need SIGPIPE suppression. # Fixed portability of bitwise NOT for enums values. # Fixed SHA-256 and MD5 calculations with unaligned data. # Fixed incorrect caseless matching for HTTP version. # Fixed incorrect caseless matching for request method. # Fixed compatibility with old GnuTLS versions. # Fixed compiler warnings on 32-bits platforms. # Fixed blocking sockets setting in tests and examples for W32. # Fixed examples to really use libmagic if present. # HTTPS tests were fixed. # Fixed libcurl test with case-insensitive match for HTTP methods, method names must use case-sensitive match. # Fixed tests compatibility with old libcurl versions. # Fixed build on W32 with llvm-dlltool (this tool is too oversimplified) -- Evgeny Grin (Karlson2k) Sun 25 Apr 2021 14:00:00 MSK Released GNU libmicrohttpd 0.9.73 This release brings new features, improvements, and a few fixes. The most important addition is the new function for vector-backed responses, based on the patch contributed by NASA engineers. Other changes include compatibility with autoconf 2.70+, improved testsuite compatibility with CI systems, fixed and improved MSVC builds, and implementation of ALPN support. More detailed list of notable changes: API changes: + Added new function MHD_create_response_from_iovec(), based on the patch provided by Lawrence Sebald and Damon N. Earp from NASA. + Added MHD_OPTION_SIGPIPE_HANDLED_BY_APP daemon option. + Added new function MHD_run_wait(). + Added MHD_OPTION_TLS_NO_ALPN to disable usage of ALPN even if it is supported by TLS library. New features: + Added '--enable-heavy-tests' configure parameter (disabled by default). + Implemented support for ALPN. Improvements and enhancements: * Return timeout of zero also for connections awaiting cleanup. * Compatibility with autoconf >=2.70, used new autoconf features. * Warn user when custom logger option is not the first option. * Added information to the header about minimal MHD version when particular symbols were introduced. * Updated test certificates to be compatible with modern browsers. * Added on-fly detection of UNIX domain sockets and pipes, MHD does not try to use TCP/IP-specific socket options on them. * Report more detailed error description in the MHD log for send and receive errors. * Enabled bind port autodetection for MSVC builds. Fixes: # Fix PostProcessor to always properly stop iteration when application callback tells it to do so. # Fixed MD5 digest authorization broken when compiled without variable length arrays support (notably with MSVC). # Fixed detection of type of send errors on W32. -- Evgeny Grin (Karlson2k) Mon 28 Dec 2020 21:36:00 MSK Released GNU libmicrohttpd 0.9.72 This release is mostly a bugfix release, with greatly improved compatibility with various OSes/kernels, including FreeBSD, Windows, OpenBSD, NetBSD, Darwin (macOS), Solaris. Performance is improved, especially with HTTPS connections and stay-alive HTTP connections. Notable changes since version 0.9.71: API changes: + New function MHD_create_response_from_pipe() Improvements and enhancements: * Fully rewritten code for buffering/pushing from kernel network buffers for compatibility with various OSes. Reduced number of additional sys-calls, network is better utilized, responses are delivered faster. * Restored optimal sendfile() usage on FreeBSD. * MHD now takes care about SIGPIPE handling by blocking it in internal threads and avoiding functions (like sendfile()) that could generate SIGPIPE when blocking of this signal is not possible. Fixes: # Fixed crash in PostProcessor. # Fixed several resources leaks in corner cases. # Improved thread sync, thread safety and fixed one use-after-free under special conditions during stopping of daemon. # Updated HTTP status codes, header names and methods from the registries. # Fixed functioning without listen socket and with internal threads. # Fixed streaming of chunked responses for both HTTP and HTTPS. # Various compatibility fixes. -- Evgeny Grin (Karlson2k) Tue Jan 9 20:52:48 MST 2007 Project posted. libmicrohttpd-1.0.1/src/0000755000175000017500000000000014566140217010713 5libmicrohttpd-1.0.1/src/include/0000755000175000017500000000000014566140216012335 5libmicrohttpd-1.0.1/src/include/Makefile.am0000644000175000017500000000037614417460232014315 # This Makefile.am is in the public domain SUBDIRS = . include_HEADERS = microhttpd.h noinst_HEADERS = microhttpd2.h microhttpd_tls.h if HAVE_EXPERIMENTAL include_HEADERS += microhttpd_ws.h endif EXTRA_DIST = platform.h autoinit_funcs.h mhd_options.h libmicrohttpd-1.0.1/src/include/microhttpd_ws.h0000644000175000017500000013324114441373361015321 /* This file is part of libmicrohttpd Copyright (C) 2021 Christian Grothoff (and other contributing authors) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd_ws.h * @brief interface for experimental web socket extension to libmicrohttpd * @author David Gausmann */ /* * *** WARNING! *** * * The websockets interface is currently in "experimental" stage. * * * It does not work on architectures with endianness different from * * * big endian and little endian and may have some portability issues.* * * API and ABI are not yet stable. * */ #ifndef MHD_MICROHTTPD_WS_H #define MHD_MICROHTTPD_WS_H #ifdef __cplusplus extern "C" { #if 0 /* keep Emacsens' auto-indent happy */ } #endif #endif /** * @brief Handle for the encoding/decoding of websocket data * (one stream is used per websocket) * @ingroup websocket */ struct MHD_WebSocketStream; /** * @brief Flags for the initialization of a websocket stream * `struct MHD_WebSocketStream` used by * #MHD_websocket_stream_init() or * #MHD_websocket_stream_init2(). * @ingroup websocket */ enum MHD_WEBSOCKET_FLAG { /** * The websocket stream is initialized in server mode (default). * Thus all outgoing payload will not be "masked". * All incoming payload must be masked. * This flag cannot be used together with #MHD_WEBSOCKET_FLAG_CLIENT */ MHD_WEBSOCKET_FLAG_SERVER = 0, /** * The websocket stream is initialized in client mode. * You will usually never use that mode in combination with libmicrohttpd, * because libmicrohttpd provides a server and not a client. * In client mode all outgoing payload will be "masked" * (XOR-ed with random values). * All incoming payload must be unmasked. * If you use this mode, you must always call #MHD_websocket_stream_init2() * instead of #MHD_websocket_stream_init(), because you need * to pass a random number generator callback function for masking. * This flag cannot be used together with #MHD_WEBSOCKET_FLAG_SERVER */ MHD_WEBSOCKET_FLAG_CLIENT = 1, /** * You don't want to get fragmented data while decoding (default). * Fragmented frames will be internally put together until * they are complete. * Whether or not data is fragmented is decided * by the sender of the data during encoding. * This cannot be used together with #MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS */ MHD_WEBSOCKET_FLAG_NO_FRAGMENTS = 0, /** * You want fragmented data, if it appears while decoding. * You will receive the content of the fragmented frame, * but if you are decoding text, you will never get an unfinished * UTF-8 sequence (if the sequence appears between two fragments). * Instead the text will end before the unfinished UTF-8 sequence. * With the next fragment, which finishes the UTF-8 sequence, * you will get the complete UTF-8 sequence. * This cannot be used together with #MHD_WEBSOCKET_FLAG_NO_FRAGMENTS */ MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS = 2, /** * If the websocket stream becomes invalid during decoding due to * protocol errors, a matching close frame will automatically * be generated. * The close frame will be returned via the parameters * `payload` and `payload_len` of #MHD_websocket_decode() and * the return value is negative * (a value of `enum MHD_WEBSOCKET_STATUS`). * The generated close frame must be freed by the caller * with #MHD_websocket_free(). */ MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR = 4 }; /** * @brief Enum to specify the fragmenting behavior * while encoding with #MHD_websocket_encode_text() or * #MHD_websocket_encode_binary(). * @ingroup websocket */ enum MHD_WEBSOCKET_FRAGMENTATION { /** * You don't want to use fragmentation. * The encoded frame consists of only one frame. */ MHD_WEBSOCKET_FRAGMENTATION_NONE = 0, /** * You want to use fragmentation. * The encoded frame is the first frame of * a series of data frames of the same type * (text or binary). * You may send control frames (ping, pong or close) * between these data frames. */ MHD_WEBSOCKET_FRAGMENTATION_FIRST = 1, /** * You want to use fragmentation. * The encoded frame is not the first frame of * the series of data frames, but also not the last one. * You may send control frames (ping, pong or close) * between these data frames. */ MHD_WEBSOCKET_FRAGMENTATION_FOLLOWING = 2, /** * You want to use fragmentation. * The encoded frame is the last frame of * the series of data frames, but also not the first one. * After this frame, you may send all types of frames again. */ MHD_WEBSOCKET_FRAGMENTATION_LAST = 3 }; /** * @brief Enum of the return value for almost every MHD_websocket function. * Errors are negative and values equal to or above zero mean a success. * Positive values are only used by #MHD_websocket_decode(). * @ingroup websocket */ enum MHD_WEBSOCKET_STATUS { /** * The call succeeded. * For #MHD_websocket_decode() this means that no error occurred, * but also no frame has been completed yet. * For other functions this means simply a success. */ MHD_WEBSOCKET_STATUS_OK = 0, /** * #MHD_websocket_decode() has decoded a text frame. * The parameters `payload` and `payload_len` are filled with * the decoded text (if any). */ MHD_WEBSOCKET_STATUS_TEXT_FRAME = 0x1, /** * #MHD_websocket_decode() has decoded a binary frame. * The parameters `payload` and `payload_len` are filled with * the decoded binary data (if any). */ MHD_WEBSOCKET_STATUS_BINARY_FRAME = 0x2, /** * #MHD_websocket_decode() has decoded a close frame. * This means you must close the socket using #MHD_upgrade_action() * with #MHD_UPGRADE_ACTION_CLOSE. * You may respond with a close frame before closing. * The parameters `payload` and `payload_len` are filled with * the close reason (if any). * The close reason starts with a two byte sequence of close code * in network byte order (see `enum MHD_WEBSOCKET_CLOSEREASON`). * After these two bytes a UTF-8 encoded close reason may follow. * You can call #MHD_websocket_split_close_reason() to split that * close reason. */ MHD_WEBSOCKET_STATUS_CLOSE_FRAME = 0x8, /** * #MHD_websocket_decode() has decoded a ping frame. * You should respond to this with a pong frame. * The pong frame must contain the same binary data as * the corresponding ping frame (if it had any). * The parameters `payload` and `payload_len` are filled with * the binary ping data (if any). */ MHD_WEBSOCKET_STATUS_PING_FRAME = 0x9, /** * #MHD_websocket_decode() has decoded a pong frame. * You should usually only receive pong frames if you sent * a ping frame before. * The binary data should be equal to your ping frame and can be * used to distinguish the response if you sent multiple ping frames. * The parameters `payload` and `payload_len` are filled with * the binary pong data (if any). */ MHD_WEBSOCKET_STATUS_PONG_FRAME = 0xA, /** * #MHD_websocket_decode() has decoded a text frame fragment. * The parameters `payload` and `payload_len` are filled with * the decoded text (if any). * This is like #MHD_WEBSOCKET_STATUS_TEXT_FRAME, but it can only * appear if you specified #MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS during * the call of #MHD_websocket_stream_init() or * #MHD_websocket_stream_init2(). */ MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT = 0x11, /** * #MHD_websocket_decode() has decoded a binary frame fragment. * The parameters `payload` and `payload_len` are filled with * the decoded binary data (if any). * This is like #MHD_WEBSOCKET_STATUS_BINARY_FRAME, but it can only * appear if you specified #MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS during * the call of #MHD_websocket_stream_init() or * #MHD_websocket_stream_init2(). */ MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT = 0x12, /** * #MHD_websocket_decode() has decoded the next text frame fragment. * The parameters `payload` and `payload_len` are filled with * the decoded text (if any). * This is like #MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT, but it appears * only after the first and before the last fragment of a series of fragments. * It can only appear if you specified #MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS * during the call of #MHD_websocket_stream_init() or * #MHD_websocket_stream_init2(). */ MHD_WEBSOCKET_STATUS_TEXT_NEXT_FRAGMENT = 0x21, /** * #MHD_websocket_decode() has decoded the next binary frame fragment. * The parameters `payload` and `payload_len` are filled with * the decoded binary data (if any). * This is like #MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT, but it appears * only after the first and before the last fragment of a series of fragments. * It can only appear if you specified #MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS * during the call of #MHD_websocket_stream_init() or * #MHD_websocket_stream_init2(). */ MHD_WEBSOCKET_STATUS_BINARY_NEXT_FRAGMENT = 0x22, /** * #MHD_websocket_decode() has decoded the last text frame fragment. * The parameters `payload` and `payload_len` are filled with * the decoded text (if any). * This is like #MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT, but it appears * only for the last fragment of a series of fragments. * It can only appear if you specified #MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS * during the call of #MHD_websocket_stream_init() or * #MHD_websocket_stream_init2(). */ MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT = 0x41, /** * #MHD_websocket_decode() has decoded the last binary frame fragment. * The parameters `payload` and `payload_len` are filled with * the decoded binary data (if any). * This is like #MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT, but it appears * only for the last fragment of a series of fragments. * It can only appear if you specified #MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS * during the call of #MHD_websocket_stream_init() or * #MHD_websocket_stream_init2(). */ MHD_WEBSOCKET_STATUS_BINARY_LAST_FRAGMENT = 0x42, /** * The call failed and the stream is invalid now for decoding. * You must close the websocket now using #MHD_upgrade_action() * with #MHD_UPGRADE_ACTION_CLOSE. * You may send a close frame before closing. * This is only used by #MHD_websocket_decode() and happens * if the stream contains errors (i. e. invalid byte data). */ MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR = -1, /** * You tried to decode something, but the stream has already * been marked invalid. * You must close the websocket now using #MHD_upgrade_action() * with #MHD_UPGRADE_ACTION_CLOSE. * You may send a close frame before closing. * This is only used by #MHD_websocket_decode() and happens * if you call #MDM_websocket_decode() again after * has been invalidated. * You can call #MHD_websocket_stream_is_valid() at any time * to check whether a stream is invalid or not. */ MHD_WEBSOCKET_STATUS_STREAM_BROKEN = -2, /** * A memory allocation failed. The stream remains valid. * If this occurred while decoding, the decoding could be * possible later if enough memory is available. * This could happen while decoding if you received a too big data frame. * You could try to specify max_payload_size during the call of * #MHD_websocket_stream_init() or #MHD_websocket_stream_init2() to * avoid this and close the websocket instead. */ MHD_WEBSOCKET_STATUS_MEMORY_ERROR = -3, /** * You passed invalid parameters during the function call * (i. e. a NULL pointer for a required parameter). * The stream remains valid. */ MHD_WEBSOCKET_STATUS_PARAMETER_ERROR = -4, /** * The maximum payload size has been exceeded. * If you got this return code from #MHD_websocket_decode() then * the stream becomes invalid and the websocket must be closed * using #MHD_upgrade_action() with #MHD_UPGRADE_ACTION_CLOSE. * You may send a close frame before closing. * The maximum payload size is specified during the call of * #MHD_websocket_stream_init() or #MHD_websocket_stream_init2(). * This can also appear if you specified 0 as maximum payload size * when the message is greater than the maximum allocatable memory size * (i. e. more than 4 GiB on 32 bit systems). * If you got this return code from #MHD_websocket_encode_close(), * #MHD_websocket_encode_ping() or #MHD_websocket_encode_pong() then * you passed to much payload data. The stream remains valid then. */ MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED = -5, /** * An UTF-8 sequence is invalid. * If you got this return code from #MHD_websocket_decode() then * the stream becomes invalid and you must close the websocket * using #MHD_upgrade_action() with #MHD_UPGRADE_ACTION_CLOSE. * You may send a close frame before closing. * If you got this from #MHD_websocket_encode_text() or * #MHD_websocket_encode_close() then you passed invalid UTF-8 text. * The stream remains valid then. */ MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR = -6, /** * A check routine for the HTTP headers came to the conclusion that * the header value isn't valid for a websocket handshake request. * This value can only be returned from the following functions: * * #MHD_websocket_check_http_version() * * #MHD_websocket_check_connection_header() * * #MHD_websocket_check_upgrade_header() * * #MHD_websocket_check_version_header() * * #MHD_websocket_create_accept_header() */ MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER = -7 }; /** * @brief Enumeration of possible close reasons for close frames. * * The possible values are specified in RFC 6455 7.4.1 * These close reasons here are the default set specified by RFC 6455, * but also other close reasons could be used. * * The definition is for short: * 0-999 are never used (if you pass 0 in * #MHD_websocket_encode_close() then no close reason is used). * 1000-2999 are specified by RFC 6455. * 3000-3999 are specified by libraries, etc. but must be registered by IANA. * 4000-4999 are reserved for private use. * * @ingroup websocket */ enum MHD_WEBSOCKET_CLOSEREASON { /** * This value is used as placeholder for #MHD_websocket_encode_close() * to tell that you don't want to specify any reason. * If you use this value then no reason text may be used. * This value cannot be a result of decoding, because this value * is not a valid close reason for the websocket protocol. */ MHD_WEBSOCKET_CLOSEREASON_NO_REASON = 0, /** * You close the websocket because it fulfilled its purpose and shall * now be closed in a normal, planned way. */ MHD_WEBSOCKET_CLOSEREASON_REGULAR = 1000, /** * You close the websocket because you are shutting down the server or * something similar. */ MHD_WEBSOCKET_CLOSEREASON_GOING_AWAY = 1001, /** * You close the websocket because a protocol error occurred * during decoding (i. e. invalid byte data). */ MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR = 1002, /** * You close the websocket because you received data which you don't accept. * For example if you received a binary frame, * but your application only expects text frames. */ MHD_WEBSOCKET_CLOSEREASON_UNSUPPORTED_DATATYPE = 1003, /** * You close the websocket because it contains malformed UTF-8. * The UTF-8 validity is automatically checked by #MHD_websocket_decode(), * so you don't need to check it on your own. * UTF-8 is specified in RFC 3629. */ MHD_WEBSOCKET_CLOSEREASON_MALFORMED_UTF8 = 1007, /** * You close the websocket because of any reason. * Usually this close reason is used if no other close reason * is more specific or if you don't want to use any other close reason. */ MHD_WEBSOCKET_CLOSEREASON_POLICY_VIOLATED = 1008, /** * You close the websocket because you received a frame which is too big * to process. * You can specify the maximum allowed payload size during the call of * #MHD_websocket_stream_init() or #MHD_websocket_stream_init2(). */ MHD_WEBSOCKET_CLOSEREASON_MAXIMUM_ALLOWED_PAYLOAD_SIZE_EXCEEDED = 1009, /** * This status code can be sent by the client if it * expected a specific extension, but this extension hasn't been negotiated. */ MHD_WEBSOCKET_CLOSEREASON_MISSING_EXTENSION = 1010, /** * The server closes the websocket because it encountered * an unexpected condition that prevented it from fulfilling the request. */ MHD_WEBSOCKET_CLOSEREASON_UNEXPECTED_CONDITION = 1011 }; /** * @brief Enumeration of possible UTF-8 check steps * * These values are used during the encoding of fragmented text frames * or for error analysis while encoding text frames. * Its values specify the next step of the UTF-8 check. * UTF-8 sequences consist of one to four bytes. * This enumeration just says how long the current UTF-8 sequence is * and what is the next expected byte. * * @ingroup websocket */ enum MHD_WEBSOCKET_UTF8STEP { /** * There is no open UTF-8 sequence. * The next byte must be 0x00-0x7F or 0xC2-0xF4. */ MHD_WEBSOCKET_UTF8STEP_NORMAL = 0, /** * The second byte of a two byte UTF-8 sequence. * The first byte was 0xC2-0xDF. * The next byte must be 0x80-0xBF. */ MHD_WEBSOCKET_UTF8STEP_UTF2TAIL_1OF1 = 1, /** * The second byte of a three byte UTF-8 sequence. * The first byte was 0xE0. * The next byte must be 0xA0-0xBF. */ MHD_WEBSOCKET_UTF8STEP_UTF3TAIL1_1OF2 = 2, /** * The second byte of a three byte UTF-8 sequence. * The first byte was 0xED. * The next byte must by 0x80-0x9F. */ MHD_WEBSOCKET_UTF8STEP_UTF3TAIL2_1OF2 = 3, /** * The second byte of a three byte UTF-8 sequence. * The first byte was 0xE1-0xEC or 0xEE-0xEF. * The next byte must be 0x80-0xBF. */ MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_1OF2 = 4, /** * The third byte of a three byte UTF-8 sequence. * The next byte must be 0x80-0xBF. */ MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_2OF2 = 5, /** * The second byte of a four byte UTF-8 sequence. * The first byte was 0xF0. * The next byte must be 0x90-0xBF. */ MHD_WEBSOCKET_UTF8STEP_UTF4TAIL1_1OF3 = 6, /** * The second byte of a four byte UTF-8 sequence. * The first byte was 0xF4. * The next byte must be 0x80-0x8F. */ MHD_WEBSOCKET_UTF8STEP_UTF4TAIL2_1OF3 = 7, /** * The second byte of a four byte UTF-8 sequence. * The first byte was 0xF1-0xF3. * The next byte must be 0x80-0xBF. */ MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_1OF3 = 8, /** * The third byte of a four byte UTF-8 sequence. * The next byte must be 0x80-0xBF. */ MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_2OF3 = 9, /** * The fourth byte of a four byte UTF-8 sequence. * The next byte must be 0x80-0xBF. */ MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_3OF3 = 10 }; /** * @brief Enumeration of validity values * * These values are used for #MHD_websocket_stream_is_valid() * and specify the validity status. * * @ingroup websocket */ enum MHD_WEBSOCKET_VALIDITY { /** * The stream is invalid. * It cannot be used for decoding anymore. */ MHD_WEBSOCKET_VALIDITY_INVALID = 0, /** * The stream is valid. * Decoding works as expected. */ MHD_WEBSOCKET_VALIDITY_VALID = 1, /** * The stream has received a close frame and * is partly invalid. * You can still use the stream for decoding, * but if a data frame is received an error will be reported. * After a close frame has been sent, no data frames * may follow from the sender of the close frame. */ MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES = 2 }; /** * This callback function is used internally by many websocket functions * for allocating data. * By default `malloc()` is used. * You can use your own allocation function with * #MHD_websocket_stream_init2() if you wish to. * This can be useful for operating systems like Windows * where `malloc()`, `realloc()` and `free()` are compiler-dependent. * You can call the associated `malloc()` callback of * a websocket stream with #MHD_websocket_malloc(). * * @param buf_len buffer size in bytes * @return allocated memory * @ingroup websocket */ typedef void * (*MHD_WebSocketMallocCallback) (size_t buf_len); /** * This callback function is used internally by many websocket * functions for reallocating data. * By default `realloc()` is used. * You can use your own reallocation function with * #MHD_websocket_stream_init2() if you wish to. * This can be useful for operating systems like Windows * where `malloc()`, `realloc()` and `free()` are compiler-dependent. * You can call the associated `realloc()` callback of * a websocket stream with #MHD_websocket_realloc(). * * @param buf buffer * @param new_buf_len new buffer size in bytes * @return reallocated memory * @ingroup websocket */ typedef void * (*MHD_WebSocketReallocCallback) (void *buf, size_t new_buf_len); /** * This callback function is used internally by many websocket * functions for freeing data. * By default `free()` is used. * You can use your own free function with * #MHD_websocket_stream_init2() if you wish to. * This can be useful for operating systems like Windows * where `malloc()`, `realloc()` and `free()` are compiler-dependent. * You can call the associated `free()` callback of * a websocket stream with #MHD_websocket_free(). * * @param buf buffer * @ingroup websocket */ typedef void (*MHD_WebSocketFreeCallback) (void *buf); /** * This callback function is used for generating random numbers * for masking payload data in client mode. * If you use websockets in server mode with libmicrohttpd then * you don't need a random number generator, because * the server doesn't mask its outgoing messageses. * However if you wish to use a websocket stream in client mode, * you must pass this callback function to #MHD_websocket_stream_init2(). * * @param cls closure specified in #MHD_websocket_stream_init2() * @param buf buffer to fill with random values * @param buf_len size of buffer in bytes * @return The number of generated random bytes. * Should usually equal to buf_len. * @ingroup websocket */ typedef size_t (*MHD_WebSocketRandomNumberGenerator) (void *cls, void *buf, size_t buf_len); /** * Checks the HTTP version of the incoming request. * Websocket requests are only allowed for HTTP/1.1 or above. * * @param http_version The value of the 'version' parameter of your * access_handler callback * @return A value of `enum MHD_WEBSOCKET_STATUS`. * 0 means the HTTP version is correct for a websocket request, * a value less than zero means that the HTTP version isn't * valid for a websocket request. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_http_version (const char *http_version); /** * Checks the value of the 'Connection' HTTP request header. * Websocket requests require the token 'Upgrade' in * the 'Connection' HTTP request header. * * @param connection_header The value of the 'Connection' request header. * You can get this request header value by passing * #MHD_HTTP_HEADER_CONNECTION to * #MHD_lookup_connection_value(). * @return A value of `enum MHD_WEBSOCKET_STATUS`. * 0 means the 'Connection' request header is correct * for a websocket request, * a value less than zero means that the 'Connection' header isn't * valid for a websocket request. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_connection_header (const char *connection_header); /** * Checks the value of the 'Upgrade' HTTP request header. * Websocket requests require the value 'websocket' in * the 'Upgrade' HTTP request header. * * @param upgrade_header The value of the 'Upgrade' request header. * You can get this request header value by passing * #MHD_HTTP_HEADER_UPGRADE to * #MHD_lookup_connection_value(). * @return A value of `enum MHD_WEBSOCKET_STATUS`. * 0 means the 'Upgrade' request header is correct * for a websocket request, * a value less than zero means that the 'Upgrade' header isn't * valid for a websocket request. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_upgrade_header (const char *upgrade_header); /** * Checks the value of the 'Sec-WebSocket-Version' HTTP request header. * Websocket requests require the value '13' * in the 'Sec-WebSocket-Version' HTTP request header. * * @param version_header The value of the 'Sec-WebSocket-Version' * request header. * You can get this request header value by passing * #MHD_HTTP_HEADER_SEC_WEBSOCKET_VERSION to * #MHD_lookup_connection_value(). * @return A value of `enum MHD_WEBSOCKET_STATUS`. * 0 means the 'Sec-WebSocket-Version' request header is correct * for a websocket request, * a value less than zero means that the 'Sec-WebSocket-Version' * header isn't valid for a websocket request. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_version_header (const char *version_header); /** * Creates the response value for the 'Sec-WebSocket-Key' HTTP request header. * The generated value must be sent to the client * as 'Sec-WebSocket-Accept' HTTP response header. * * @param sec_websocket_key The value of the 'Sec-WebSocket-Key' * request header. * You can get this request header value by passing * #MHD_HTTP_HEADER_SEC_WEBSOCKET_KEY to * #MHD_lookup_connection_value(). * @param[out] sec_websocket_accept The response buffer, which will receive * the generated 'Sec-WebSocket-Accept' header. * This buffer must be at least 29 bytes long and * will contain the response value plus * a terminating NUL on success. * @return A value of `enum MHD_WEBSOCKET_STATUS`. * Typically 0 on success or less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_create_accept_header (const char *sec_websocket_key, char *sec_websocket_accept); /** * Creates a new websocket stream, used for decoding/encoding. * * @param[out] ws The websocket stream * @param flags Combination of `enum MHD_WEBSOCKET_FLAG` values * to modify the behavior of the websocket stream. * @param max_payload_size The maximum size for incoming payload * data in bytes. Use 0 to allow each size. * @return A value of `enum MHD_WEBSOCKET_STATUS`. * Typically 0 on success or less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_init (struct MHD_WebSocketStream **ws, int flags, size_t max_payload_size); /** * Creates a new websocket stream, used for decoding/encoding, * but with custom memory functions for malloc, realloc and free. * Also a random number generator can be specified for client mode. * * @param[out] ws The websocket stream * @param flags Combination of `enum MHD_WEBSOCKET_FLAG` values * to modify the behavior of the websocket stream. * @param max_payload_size The maximum size for incoming payload * data in bytes. Use 0 to allow each size. * @param callback_malloc The callback function for `malloc()`. * @param callback_realloc The callback function for `realloc()`. * @param callback_free The callback function for `free()`. * @param cls_rng A closure for the random number generator callback. * This is only required when * MHD_WEBSOCKET_FLAG_CLIENT is passed in `flags`. * The given value is passed to * the random number generator. * May be NULL if not needed. * Should be NULL when you are * not using MHD_WEBSOCKET_FLAG_CLIENT. * @param callback_rng A callback function for a * secure random number generator. * This is only required when * MHD_WEBSOCKET_FLAG_CLIENT is passed in `flags`. * Should be NULL otherwise. * @return A value of `enum MHD_WEBSOCKET_STATUS`. * Typically 0 on success or less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_init2 (struct MHD_WebSocketStream **ws, int flags, size_t max_payload_size, MHD_WebSocketMallocCallback callback_malloc, MHD_WebSocketReallocCallback callback_realloc, MHD_WebSocketFreeCallback callback_free, void *cls_rng, MHD_WebSocketRandomNumberGenerator callback_rng); /** * Frees a websocket stream * * @param ws The websocket stream. This value may be NULL. * @return A value of `enum MHD_WEBSOCKET_STATUS`. * Typically 0 on success or less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_free (struct MHD_WebSocketStream *ws); /** * Invalidates a websocket stream. * After invalidation a websocket stream cannot be used for decoding anymore. * Encoding is still possible. * * @param ws The websocket stream. * @return A value of `enum MHD_WEBSOCKET_STATUS`. * Typically 0 on success or less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_invalidate (struct MHD_WebSocketStream *ws); /** * Queries whether a websocket stream is valid. * Invalidated websocket streams cannot be used for decoding anymore. * Encoding is still possible. * * @param ws The websocket stream. * @return A value of `enum MHD_WEBSOCKET_VALIDITY`. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_VALIDITY MHD_websocket_stream_is_valid (struct MHD_WebSocketStream *ws); /** * Decodes a byte sequence for a websocket stream. * Decoding is done until either a frame is complete or * the end of the byte sequence is reached. * * @param ws The websocket stream. * @param streambuf The byte sequence for decoding. * Typically that what you received via `recv()`. * @param streambuf_len The length of the byte sequence @a streambuf * @param[out] streambuf_read_len The number of bytes which has been processed * by this call. This value may be less * than @a streambuf_len when a frame is decoded * before the end of the buffer is reached. * The remaining bytes of @a buf must be passed * to the next call of this function. * @param[out] payload Pointer to a variable, which receives a buffer * with the decoded payload data. * If no decoded data is available this is NULL. * When the returned value is not NULL then * the buffer contains always @a payload_len bytes plus * one terminating NUL character. * The caller must free this buffer * using #MHD_websocket_free(). * If you passed the flag * #MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR * upon creation of this websocket stream and * a decoding error occurred * (function return value less than 0), then this * buffer contains a generated close frame * which must be sent via the socket to the recipient. * If you passed the flag #MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS * upon creation of the websocket stream then * this payload may only be a part of the complete message. * Only complete UTF-8 sequences are returned * for fragmented text frames. * If necessary the UTF-8 sequence will be completed * with the next text fragment. * @param[out] payload_len The length of the result payload buffer in bytes. * * @return A value of `enum MHD_WEBSOCKET_STATUS`. * This is greater than 0 if a frame has is complete, * equal to 0 if more data is needed an less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_decode (struct MHD_WebSocketStream *ws, const char *streambuf, size_t streambuf_len, size_t *streambuf_read_len, char **payload, size_t *payload_len); /** * Splits the payload of a decoded close frame. * * @param payload The payload of the close frame. * This parameter may only be NULL if @a payload_len is 0. * @param payload_len The length of @a payload. * @param[out] reason_code The numeric close reason. * If there was no close reason, this is * #MHD_WEBSOCKET_CLOSEREASON_NO_REASON. * Compare with `enum MHD_WEBSOCKET_CLOSEREASON`. * This parameter is optional and may be NULL. * @param[out] reason_utf8 The literal close reason. * If there was no literal close reason, this is NULL. * This parameter is optional and may be NULL. * Please note that no memory is allocated * in this function. * If not NULL the returned value of this parameter * points to a position in the specified @a payload. * @param[out] reason_utf8_len The length of the literal close reason. * If there was no literal close reason, this is 0. * This parameter is optional and may be NULL. * * @return A value of `enum MHD_WEBSOCKET_STATUS`. * This is #MHD_WEBSOCKET_STATUS_OK (= 0) on success * or a value less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_split_close_reason (const char *payload, size_t payload_len, unsigned short *reason_code, const char **reason_utf8, size_t *reason_utf8_len); /** * Encodes an UTF-8 encoded text into websocket text frame. * * @param ws The websocket stream. * @param payload_utf8 The UTF-8 encoded text to send. * This may be NULL if payload_utf8_len is 0. * @param payload_utf8_len The length of the UTF-8 encoded text in bytes. * @param fragmentation A value of `enum MHD_WEBSOCKET_FRAGMENTATION` * to specify the fragmentation behavior. * Specify MHD_WEBSOCKET_FRAGMENTATION_NONE * if you don't want to use fragmentation. * @param[out] frame This variable receives a buffer with the encoded frame. * This is what you typically send via `send()` to the recipient. * If no encoded data is available this is NULL. * When this variable is not NULL then the buffer contains always * @a frame_len bytes plus one terminating NUL character. * The caller must free this buffer using #MHD_websocket_free(). * @param[out] frame_len The length of the encoded frame in bytes. * @param[out] utf8_step This parameter is required for fragmentation and * should be NULL if no fragmentation is used. * It contains information about the last encoded * UTF-8 sequence and is required to continue a previous * UTF-8 sequence when fragmentation is used. * `enum MHD_WEBSOCKET_UTF8STEP` is for this value. * If you start a new fragment using * MHD_WEBSOCKET_FRAGMENTATION_NONE or * MHD_WEBSOCKET_FRAGMENTATION_FIRST the value * of this variable will be initialized * to MHD_WEBSOCKET_UTF8STEP_NORMAL. * * @return A value of `enum MHD_WEBSOCKET_STATUS`. * This is #MHD_WEBSOCKET_STATUS_OK (= 0) on success * or a value less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_text (struct MHD_WebSocketStream *ws, const char *payload_utf8, size_t payload_utf8_len, int fragmentation, char **frame, size_t *frame_len, int *utf8_step); /** * Encodes binary data into websocket binary frame. * * @param ws The websocket stream. * @param payload The binary data to send. * @param payload_len The length of the binary data in bytes. * @param fragmentation A value of `enum MHD_WEBSOCKET_FRAGMENTATION` * to specify the fragmentation behavior. * Specify MHD_WEBSOCKET_FRAGMENTATION_NONE * if you don't want to use fragmentation. * @param[out] frame This variable receives a buffer with * the encoded binary frame. * This is what you typically send via `send()` * to the recipient. * If no encoded frame is available this is NULL. * When this variable is not NULL then the allocated buffer * contains always @a frame_len bytes plus one terminating * NUL character. * The caller must free this buffer using #MHD_websocket_free(). * @param[out] frame_len The length of the result frame buffer in bytes. * * @return A value of `enum MHD_WEBSOCKET_STATUS`. * This is #MHD_WEBSOCKET_STATUS_OK (= 0) on success * or a value less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_binary (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, int fragmentation, char **frame, size_t *frame_len); /** * Encodes a websocket ping frame * * @param ws The websocket stream. * @param payload The binary ping payload data to send. * This may be NULL if @a payload_len is 0. * @param payload_len The length of the payload data in bytes. * This may not exceed 125 bytes. * @param[out] frame This variable receives a buffer with the encoded ping frame data. * This is what you typically send via `send()` to the recipient. * If no encoded frame is available this is NULL. * When this variable is not NULL then the buffer contains always * @a frame_len bytes plus one terminating NUL character. * The caller must free this buffer using #MHD_websocket_free(). * @param[out] frame_len The length of the result frame buffer in bytes. * * @return A value of `enum MHD_WEBSOCKET_STATUS`. * This is #MHD_WEBSOCKET_STATUS_OK (= 0) on success * or a value less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_ping (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, char **frame, size_t *frame_len); /** * Encodes a websocket pong frame * * @param ws The websocket stream. * @param payload The binary pong payload data, which should be * the decoded payload from the received ping frame. * This may be NULL if @a payload_len is 0. * @param payload_len The length of the payload data in bytes. * This may not exceed 125 bytes. * @param[out] frame This variable receives a buffer with * the encoded pong frame data. * This is what you typically send via `send()` * to the recipient. * If no encoded frame is available this is NULL. * When this variable is not NULL then the buffer * contains always @a frame_len bytes plus one * terminating NUL character. * The caller must free this buffer * using #MHD_websocket_free(). * @param[out] frame_len The length of the result frame buffer in bytes. * * @return A value of `enum MHD_WEBSOCKET_STATUS`. * This is #MHD_WEBSOCKET_STATUS_OK (= 0) on success * or a value less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_pong (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, char **frame, size_t *frame_len); /** * Encodes a websocket close frame * * @param ws The websocket stream. * @param reason_code The reason for close. * You can use `enum MHD_WEBSOCKET_CLOSEREASON` * for typical reasons, * but you are not limited to these values. * The allowed values are specified in RFC 6455 7.4. * If you don't want to enter a reason, you can specify * #MHD_WEBSOCKET_CLOSEREASON_NO_REASON then * no reason is encoded. * @param reason_utf8 An UTF-8 encoded text reason why the connection is closed. * This may be NULL if @a reason_utf8_len is 0. * This must be NULL if @a reason_code is * #MHD_WEBSOCKET_CLOSEREASON_NO_REASON (= 0). * @param reason_utf8_len The length of the UTF-8 encoded text reason in bytes. * This may not exceed 123 bytes. * @param[out] frame This variable receives a buffer with * the encoded close frame. * This is what you typically send via `send()` * to the recipient. * If no encoded frame is available this is NULL. * When this variable is not NULL then the buffer * contains always @a frame_len bytes plus * one terminating NUL character. * The caller must free this buffer * using #MHD_websocket_free(). * @param[out] frame_len The length of the result frame buffer in bytes. * * @return A value of `enum MHD_WEBSOCKET_STATUS`. * This is #MHD_WEBSOCKET_STATUS_OK (= 0) on success * or a value less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_close (struct MHD_WebSocketStream *ws, unsigned short reason_code, const char *reason_utf8, size_t reason_utf8_len, char **frame, size_t *frame_len); /** * Allocates memory with the associated 'malloc' function * of the websocket stream * * @param ws The websocket stream. * @param buf_len The length of the memory to allocate in bytes * * @return The allocated memory on success or NULL on failure. * @ingroup websocket */ _MHD_EXTERN void * MHD_websocket_malloc (struct MHD_WebSocketStream *ws, size_t buf_len); /** * Reallocates memory with the associated 'realloc' function * of the websocket stream * * @param ws The websocket stream. * @param buf The previously allocated memory or NULL * @param new_buf_len The new length of the memory in bytes * * @return The allocated memory on success or NULL on failure. * If NULL is returned the previously allocated buffer * remains valid. * @ingroup websocket */ _MHD_EXTERN void * MHD_websocket_realloc (struct MHD_WebSocketStream *ws, void *buf, size_t new_buf_len); /** * Frees memory with the associated 'free' function * of the websocket stream * * @param ws The websocket stream. * @param buf The previously allocated memory or NULL * * @return A value of `enum MHD_WEBSOCKET_STATUS`. * This is #MHD_WEBSOCKET_STATUS_OK (= 0) on success * or a value less than 0 on errors. * @ingroup websocket */ _MHD_EXTERN int MHD_websocket_free (struct MHD_WebSocketStream *ws, void *buf); #if 0 /* keep Emacsens' auto-indent happy */ { #endif #ifdef __cplusplus } #endif #endif libmicrohttpd-1.0.1/src/include/autoinit_funcs.h0000644000175000017500000003021414445225034015456 /* * AutoinitFuncs: Automatic Initialization and Deinitialization Functions * Copyright(C) 2014-2023 Karlson2k (Evgeny Grin) * * This header is free software; you can redistribute it and / or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This header is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this header; if not, see * . */ /* General usage is simple: include this header, declare or define two functions with zero parameters (void) and any return type: one for initialisation and one for deinitialisation, add _SET_INIT_AND_DEINIT_FUNCS(FuncInitName, FuncDeInitName) to the code and functions will be automatically called during application startup and shutdown. This is useful for libraries as libraries don't have direct access to main() functions. Example: ------------------------------------------------- #include #include "autoinit_funcs.h" int someVar; void* somePtr; void libInit(void) { someVar = 3; somePtr = malloc(100); } void libDeinit(void) { free(somePtr); } _SET_INIT_AND_DEINIT_FUNCS(libInit,libDeinit); ------------------------------------------------- If initialiser or deinitialiser function is not needed, just define it as empty function. This header should work with GCC, clang, MSVC (2010 or later) and SunPro / Sun Studio / Oracle Solaris Studio / Oracle Developer Studio compiler. Supported C and C++ languages; application, static and dynamic (DLL) libraries; non-optimized (Debug) and optimised (Release) compilation and linking. For more information see header code and comments in code. */ #ifndef AUTOINIT_FUNCS_INCLUDED #define AUTOINIT_FUNCS_INCLUDED 1 /** * Current version of the header in packed BCD form. * 0x01093001 = 1.9.30-1. */ #define AUTOINIT_FUNCS_VERSION 0x01001000 #if defined(__GNUC__) || defined(__clang__) /* if possible - check for supported attribute */ #ifdef __has_attribute #if ! __has_attribute (constructor) || ! __has_attribute (destructor) #define _GNUC_ATTR_CONSTR_NOT_SUPPORTED 1 #endif /* !__has_attribute(constructor) || !__has_attribute(destructor) */ #endif /* __has_attribute */ #endif /* __GNUC__ */ /* "__has_attribute__ ((constructor))" is supported by GCC, clang and Sun/Oracle compiler starting from version 12.1. */ #if ((defined(__GNUC__) || defined(__clang__)) && \ ! defined(_GNUC_ATTR_CONSTR_NOT_SUPPORTED)) || \ (defined(__SUNPRO_C) && __SUNPRO_C + 0 >= 0x5100) #define GNUC_SET_INIT_AND_DEINIT(FI,FD) \ void __attribute__ ((constructor)) _GNUC_init_helper_ ## FI (void); \ void __attribute__ ((destructor)) _GNUC_deinit_helper_ ## FD (void); \ void __attribute__ ((constructor)) _GNUC_init_helper_ ## FI (void) \ { (void) (FI) (); } \ void __attribute__ ((destructor)) _GNUC_deinit_helper_ ## FD (void) \ { (void) (FD) (); } \ struct _GNUC_dummy_str_ ## FI {int i;} #define _SET_INIT_AND_DEINIT_FUNCS(FI,FD) GNUC_SET_INIT_AND_DEINIT (FI,FD) #define _AUTOINIT_FUNCS_ARE_SUPPORTED 1 #elif defined(_MSC_FULL_VER) && _MSC_VER + 0 >= 1600 /* Make sure that your project/sources define: _LIB if building a static library (_LIB is ignored if _CONSOLE is defined); _USRDLL if building DLL-library; not defined both _LIB and _USRDLL if building an application */ /* Define AUTOINIT_FUNCS_DECLARE_STATIC_REG if you need macro declaration for registering static initialisation functions even if you building DLL */ /* Define AUTOINIT_FUNCS_FORCE_STATIC_REG if you want to set main macro _SET_INIT_AND_DEINIT_FUNCS to static version even if building a DLL */ /* Stringify macros */ #define _INSTRMACRO(a) #a #define _STRMACRO(a) _INSTRMACRO (a) #if ! defined(_USRDLL) || defined(AUTOINIT_FUNCS_DECLARE_STATIC_REG) \ || defined(AUTOINIT_FUNCS_FORCE_STATIC_REG) /* Use "C" linkage for variable to simplify variable decoration */ #ifdef __cplusplus #define W32_INITVARDECL extern "C" #else #define W32_INITVARDECL extern #endif /* How variable is decorated by compiler */ #if (defined(_WIN32) || defined(_WIN64)) \ && ! defined(_M_IX86) && ! defined(_X86_) #if ! defined(_M_X64) && ! defined(_M_AMD64) && ! defined(_x86_64_) \ && ! defined(_M_ARM) && ! defined(_M_ARM64) #pragma message(__FILE__ "(" _STRMACRO(__LINE__) ") : warning AIFW001 : " \ "Untested architecture, linker may fail with unresolved symbol") #endif /* ! _M_X64 && ! _M_AMD64 && ! _x86_64_ && ! _M_ARM && ! _M_ARM64 */ #define W32_VARDECORPREFIX #define W32_DECORVARNAME(v) v #define W32_VARDECORPREFIXSTR "" #elif defined(_WIN32) && (defined(_M_IX86) || defined(_X86_)) #define W32_VARDECORPREFIX _ #define W32_DECORVARNAME(v) _ ## v #define W32_VARDECORPREFIXSTR "_" #else #error Do not know how to decorate symbols for this architecture #endif /* Internal variable prefix (can be any) */ #define W32_INITHELPERVARNAME(f) _initHelperDummy_ ## f #define W32_INITHELPERVARNAMEDECORSTR(f) \ W32_VARDECORPREFIXSTR _STRMACRO (W32_INITHELPERVARNAME (f)) /* Declare section (segment), put variable pointing to init function to chosen segment, force linker to always include variable to avoid omitting by optimiser */ /* Initialisation function must be declared as void __cdecl FuncName(void) */ /* "extern" with initialisation value means that variable is declared AND defined. */ #define W32_VFPTR_IN_SEG(S,F) \ __pragma (section (S,long,read)) \ __pragma (comment (linker, "/INCLUDE:" W32_INITHELPERVARNAMEDECORSTR (F))) \ W32_INITVARDECL __declspec(allocate (S))void \ (__cdecl * W32_INITHELPERVARNAME (F))(void) = &F /* Sections (segments) for pointers to initialisers/deinitialisers */ /* Semi-officially suggested section for early initialisers (called before C++ objects initialisers), "void" return type */ #define W32_SEG_INIT_EARLY ".CRT$XCT" /* Semi-officially suggested section for late initialisers (called after C++ objects initialisers), "void" return type */ #define W32_SEG_INIT_LATE ".CRT$XCV" /* Unsafe sections (segments) for pointers to initialisers/deinitialisers */ /* C++ lib initialisers, "void" return type (reserved by the system!) */ #define W32_SEG_INIT_CXX_LIB ".CRT$XCL" /* C++ user initialisers, "void" return type (reserved by the system!) */ #define W32_SEG_INIT_CXX_USER ".CRT$XCU" /* Declare section (segment), put variable pointing to init function to chosen segment, force linker to always include variable to avoid omitting by optimiser */ /* Initialisation function must be declared as int __cdecl FuncName(void) */ /* Startup process is aborted if initialiser returns non-zero */ /* "extern" with initialisation value means that variable is declared AND defined. */ #define W32_IFPTR_IN_SEG(S,F) \ __pragma (section (S,long,read)) \ __pragma (comment (linker, "/INCLUDE:" W32_INITHELPERVARNAMEDECORSTR (F))) \ W32_INITVARDECL __declspec(allocate (S))int \ (__cdecl * W32_INITHELPERVARNAME (F))(void) = &F /* Unsafe sections (segments) for pointers to initialisers with "int" return type */ /* C lib initialisers, "int" return type (reserved by the system!). These initialisers are called before others. */ #define W32_SEG_INIT_C_LIB ".CRT$XIL" /* C user initialisers, "int" return type (reserved by the system!). These initialisers are called before others. */ #define W32_SEG_INIT_C_USER ".CRT$XIU" /* Declare macro for different initialisers sections */ /* Macro can be used several times to register several initialisers */ /* Once function is registered as initialiser, it will be called automatically during application startup */ #define W32_REG_INIT_EARLY(F) W32_VFPTR_IN_SEG (W32_SEG_INIT_EARLY,F) #define W32_REG_INIT_LATE(F) W32_VFPTR_IN_SEG (W32_SEG_INIT_LATE,F) /* Not recommended / unsafe */ /* "lib" initialisers are called before "user" initialisers */ /* "C" initialisers are called before "C++" initialisers */ #define W32_REG_INIT_C_USER(F) W32_FPTR_IN_SEG (W32_SEG_INIT_C_USER,F) #define W32_REG_INIT_C_LIB(F) W32_FPTR_IN_SEG (W32_SEG_INIT_C_LIB,F) #define W32_REG_INIT_CXX_USER(F) W32_FPTR_IN_SEG (W32_SEG_INIT_CXX_USER,F) #define W32_REG_INIT_CXX_LIB(F) W32_FPTR_IN_SEG (W32_SEG_INIT_CXX_LIB,F) /* Choose main register macro based on language and program type */ /* Assuming that _LIB or _USRDLL is defined for static or DLL-library */ /* Macro can be used several times to register several initialisers */ /* Once function is registered as initialiser, it will be called automatically during application startup */ /* Define AUTOINIT_FUNCS_FORCE_EARLY_INIT to force register as early initialiser */ /* Define AUTOINIT_FUNCS_FORCE_LATE_INIT to force register as late initialiser */ /* By default C++ static or DLL-library code and any C code and will be registered as early initialiser, while C++ non-library code will be registered as late initialiser */ #if (! defined(__cplusplus) || \ ((defined(_LIB) && ! defined(_CONSOLE)) || defined(_USRDLL)) || \ defined(AUTOINIT_FUNCS_FORCE_EARLY_INIT)) && \ ! defined(AUTOINIT_FUNCS_FORCE_LATE_INIT) #define W32_REGISTER_INIT(F) W32_REG_INIT_EARLY(F) #else #define W32_REGISTER_INIT(F) W32_REG_INIT_LATE(F) #endif #endif /* ! _USRDLL || ! AUTOINIT_FUNCS_DECLARE_STATIC_REG || AUTOINIT_FUNCS_FORCE_STATIC_REG */ #if ! defined(_USRDLL) || defined(AUTOINIT_FUNCS_FORCE_STATIC_REG) #include /* required for atexit() */ #define W32_SET_INIT_AND_DEINIT(FI,FD) \ void __cdecl _W32_init_helper_ ## FI (void); \ void __cdecl _W32_deinit_helper_ ## FD (void); \ void __cdecl _W32_init_helper_ ## FI (void) \ { (void) (FI) (); atexit (_W32_deinit_helper_ ## FD); } \ void __cdecl _W32_deinit_helper_ ## FD (void) \ { (void) (FD) (); } \ W32_REGISTER_INIT (_W32_init_helper_ ## FI) #else /* _USRDLL */ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* WIN32_LEAN_AND_MEAN */ #include /* Required for DllMain */ /* If DllMain is already present in code, define AUTOINIT_FUNCS_CALL_USR_DLLMAIN and rename DllMain to usr_DllMain */ #ifndef AUTOINIT_FUNCS_CALL_USR_DLLMAIN #define W32_SET_INIT_AND_DEINIT(FI,FD) \ BOOL WINAPI DllMain (HINSTANCE hinst,DWORD reason,LPVOID unused); \ BOOL WINAPI DllMain (HINSTANCE hinst,DWORD reason,LPVOID unused) \ { (void) hinst; (void) unused; \ if (DLL_PROCESS_ATTACH==reason) {(void) (FI) ();} \ else if (DLL_PROCESS_DETACH==reason) {(void) (FD) ();} \ return TRUE; \ } struct _W32_dummy_strc_ ## FI {int i;} #else /* AUTOINIT_FUNCS_CALL_USR_DLLMAIN */ #define W32_SET_INIT_AND_DEINIT(FI,FD) \ BOOL WINAPI usr_DllMain (HINSTANCE hinst,DWORD reason,LPVOID unused); \ BOOL WINAPI DllMain (HINSTANCE hinst,DWORD reason,LPVOID unused); \ BOOL WINAPI DllMain (HINSTANCE hinst,DWORD reason,LPVOID unused) \ { if (DLL_PROCESS_ATTACH==reason) {(void) (FI) ();} \ else if (DLL_PROCESS_DETACH==reason) {(void) (FD) ();} \ return usr_DllMain (hinst,reason,unused); \ } struct _W32_dummy_strc_ ## FI {int i;} #endif /* AUTOINIT_FUNCS_CALL_USR_DLLMAIN */ #endif /* _USRDLL */ #define _SET_INIT_AND_DEINIT_FUNCS(FI,FD) W32_SET_INIT_AND_DEINIT (FI,FD) /* Indicate that automatic initialisers/deinitialisers are supported */ #define _AUTOINIT_FUNCS_ARE_SUPPORTED 1 #else /* !__GNUC__ && !_MSC_FULL_VER */ /* Define EMIT_ERROR_IF_AUTOINIT_FUNCS_ARE_NOT_SUPPORTED before inclusion of header to abort compilation if automatic initialisers/deinitialisers are not supported */ #ifdef EMIT_ERROR_IF_AUTOINIT_FUNCS_ARE_NOT_SUPPORTED #error \ Compiler/platform does not support automatic calls of user-defined initializer and deinitializer #endif /* EMIT_ERROR_IF_AUTOINIT_FUNCS_ARE_NOT_SUPPORTED */ /* Do nothing */ #define _SET_INIT_AND_DEINIT_FUNCS(FI,FD) /* Indicate that automatic initialisers/deinitialisers are not supported */ #define _AUTOINIT_FUNCS_ARE_NOT_SUPPORTED 1 #endif /* !__GNUC__ && !_MSC_FULL_VER */ #endif /* !AUTOINIT_FUNCS_INCLUDED */ libmicrohttpd-1.0.1/src/include/platform.h0000644000175000017500000000726014441373361014260 /* This file is part of libmicrohttpd Copyright (C) 2008 Christian Grothoff (and other contributing authors) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file platform.h * @brief platform-specific includes for libmicrohttpd * @author Christian Grothoff * * This file is included by the libmicrohttpd code * before "microhttpd.h"; it provides the required * standard headers (which are platform-specific).

* * Note that this file depends on our configure.ac * build process and the generated config.h file. * Hence you cannot include it directly in applications * that use libmicrohttpd. */ #ifndef MHD_PLATFORM_H #define MHD_PLATFORM_H #include "mhd_options.h" #include #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include #ifdef HAVE_UNISTD_H #include #endif #include #include #include #include #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ /* different OSes have fd_set in a broad range of header files; we just include most of them (if they are available) */ #if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS) #include #include #ifdef HAVE_SOCKLIB_H #include #endif /* HAVE_SOCKLIB_H */ #ifdef HAVE_INETLIB_H #include #endif /* HAVE_INETLIB_H */ #endif /* __VXWORKS__ */ #ifdef HAVE_MEMORY_H #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_STAT_H #include #endif #ifdef HAVE_SYS_MSG_H #include #endif #ifdef HAVE_SYS_MMAN_H #include #endif #ifdef HAVE_TIME_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #ifndef WIN32_LEAN_AND_MEAN /* Do not include unneeded parts of W32 headers. */ #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #include #endif /* _WIN32 && !__CYGWIN__ */ #if defined(__CYGWIN__) && ! defined(_SYS_TYPES_FD_SET) /* Do not define __USE_W32_SOCKETS under Cygwin! */ #error Cygwin with winsock fd_set is not supported #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #define sleep(seconds) ((SleepEx ((seconds) * 1000, 1)==0) ? 0 : (seconds)) #define usleep(useconds) ((SleepEx ((useconds) / 1000, 1)==0) ? 0 : -1) #endif #if defined(_MSC_FULL_VER) && ! defined(_SSIZE_T_DEFINED) #define _SSIZE_T_DEFINED typedef intptr_t ssize_t; #endif /* !_SSIZE_T_DEFINED */ #if ! defined(_WIN32) || defined(__CYGWIN__) typedef time_t _MHD_TIMEVAL_TV_SEC_TYPE; #else /* _WIN32 && ! __CYGWIN__ */ typedef long _MHD_TIMEVAL_TV_SEC_TYPE; #endif /* _WIN32 && ! __CYGWIN__ */ #if ! defined(IPPROTO_IPV6) && defined(_MSC_FULL_VER) && _WIN32_WINNT >= 0x0501 /* VC use IPPROTO_IPV6 as part of enum */ #define IPPROTO_IPV6 IPPROTO_IPV6 #endif #endif libmicrohttpd-1.0.1/src/include/Makefile.in0000644000175000017500000005736514566140141014337 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @HAVE_EXPERIMENTAL_TRUE@am__append_1 = microhttpd_ws.h subdir = src/include ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__include_HEADERS_DIST) \ $(noinst_HEADERS) $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__include_HEADERS_DIST = microhttpd.h microhttpd_ws.h am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(includedir)" HEADERS = $(include_HEADERS) $(noinst_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # This Makefile.am is in the public domain SUBDIRS = . include_HEADERS = microhttpd.h $(am__append_1) noinst_HEADERS = microhttpd2.h microhttpd_tls.h EXTRA_DIST = platform.h autoinit_funcs.h mhd_options.h all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/include/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/include/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(HEADERS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-includeHEADERS install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-includeHEADERS .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-includeHEADERS install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-includeHEADERS .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/src/include/microhttpd.h0000644000175000017500000075552014566137250014625 /* This file is part of libmicrohttpd Copyright (C) 2006-2021 Christian Grothoff (and other contributing authors) Copyright (C) 2014-2023 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd.h * @brief public interface to libmicrohttpd * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) * @author Chris GauthierDickey * * All symbols defined in this header start with MHD. MHD is a small * HTTP daemon library. As such, it does not have any API for logging * errors (you can only enable or disable logging to stderr). Also, * it may not support all of the HTTP features directly, where * applicable, portions of HTTP may have to be handled by clients of * the library. * * The library is supposed to handle everything that it must handle * (because the API would not allow clients to do this), such as basic * connection management; however, detailed interpretations of headers * -- such as range requests -- and HTTP methods are left to clients. * The library does understand HEAD and will only send the headers of * the response and not the body, even if the client supplied a body. * The library also understands headers that control connection * management (specifically, "Connection: close" and "Expect: 100 * continue" are understood and handled automatically). * * MHD understands POST data and is able to decode certain formats * (at the moment only "application/x-www-form-urlencoded" and * "multipart/formdata"). Unsupported encodings and large POST * submissions may require the application to manually process * the stream, which is provided to the main application (and thus can be * processed, just not conveniently by MHD). * * The header file defines various constants used by the HTTP protocol. * This does not mean that MHD actually interprets all of these * values. The provided constants are exported as a convenience * for users of the library. MHD does not verify that transmitted * HTTP headers are part of the standard specification; users of the * library are free to define their own extensions of the HTTP * standard and use those with MHD. * * All functions are guaranteed to be completely reentrant and * thread-safe (with the exception of #MHD_set_connection_value, * which must only be used in a particular context). * * * @defgroup event event-loop control * MHD API to start and stop the HTTP server and manage the event loop. * @defgroup response generation of responses * MHD API used to generate responses. * @defgroup request handling of requests * MHD API used to access information about requests. * @defgroup authentication HTTP authentication * MHD API related to basic and digest HTTP authentication. * @defgroup logging logging * MHD API to mange logging and error handling * @defgroup specialized misc. specialized functions * This group includes functions that do not fit into any particular * category and that are rarely used. */ #ifndef MHD_MICROHTTPD_H #define MHD_MICROHTTPD_H #ifdef __cplusplus extern "C" { #if 0 /* keep Emacsens' auto-indent happy */ } #endif #endif /** * Current version of the library in packed BCD form. * @note Version number components are coded as Simple Binary-Coded Decimal * (also called Natural BCD or BCD 8421). While they are hexadecimal numbers, * they are parsed as decimal numbers. * Example: 0x01093001 = 1.9.30-1. */ #define MHD_VERSION 0x01000100 /* If generic headers don't work on your platform, include headers which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t', 'uint8_t', 'uint16_t', 'int32_t', 'uint32_t', 'int64_t', 'uint64_t', 'struct sockaddr', 'socklen_t', 'fd_set' and "#define MHD_PLATFORM_H" before including "microhttpd.h". Then the following "standard" includes won't be used (which might be a good idea, especially on platforms where they do not exist). */ #ifndef MHD_PLATFORM_H #if defined(_WIN32) && ! defined(__CYGWIN__) && \ ! defined(_CRT_DECLARE_NONSTDC_NAMES) /* Declare POSIX-compatible names */ #define _CRT_DECLARE_NONSTDC_NAMES 1 #endif /* _WIN32 && ! __CYGWIN__ && ! _CRT_DECLARE_NONSTDC_NAMES */ #include #include #include #if ! defined(_WIN32) || defined(__CYGWIN__) #include #include #include #else /* _WIN32 && ! __CYGWIN__ */ #include #if defined(_MSC_FULL_VER) && ! defined(_SSIZE_T_DEFINED) #define _SSIZE_T_DEFINED typedef intptr_t ssize_t; #endif /* !_SSIZE_T_DEFINED */ #endif /* _WIN32 && ! __CYGWIN__ */ #endif #if defined(__CYGWIN__) && ! defined(_SYS_TYPES_FD_SET) /* Do not define __USE_W32_SOCKETS under Cygwin! */ #error Cygwin with winsock fd_set is not supported #endif #ifdef __has_attribute #if __has_attribute (flag_enum) #define _MHD_FLAGS_ENUM __attribute__((flag_enum)) #endif /* flag_enum */ #if __has_attribute (enum_extensibility) #define _MHD_FIXED_ENUM __attribute__((enum_extensibility (closed))) #endif /* enum_extensibility */ #endif /* __has_attribute */ #ifndef _MHD_FLAGS_ENUM #define _MHD_FLAGS_ENUM #endif /* _MHD_FLAGS_ENUM */ #ifndef _MHD_FIXED_ENUM #define _MHD_FIXED_ENUM #endif /* _MHD_FIXED_ENUM */ #define _MHD_FIXED_FLAGS_ENUM _MHD_FIXED_ENUM _MHD_FLAGS_ENUM /** * Operational results from MHD calls. */ enum MHD_Result { /** * MHD result code for "NO". */ MHD_NO = 0, /** * MHD result code for "YES". */ MHD_YES = 1 } _MHD_FIXED_ENUM; /** * Constant used to indicate unknown size (use when * creating a response). */ #ifdef UINT64_MAX #define MHD_SIZE_UNKNOWN UINT64_MAX #else #define MHD_SIZE_UNKNOWN ((uint64_t) -1LL) #endif #define MHD_CONTENT_READER_END_OF_STREAM ((ssize_t) -1) #define MHD_CONTENT_READER_END_WITH_ERROR ((ssize_t) -2) #ifndef _MHD_EXTERN #if defined(_WIN32) && defined(MHD_W32LIB) #define _MHD_EXTERN extern #elif defined(_WIN32) && defined(MHD_W32DLL) /* Define MHD_W32DLL when using MHD as W32 .DLL to speed up linker a little */ #define _MHD_EXTERN __declspec(dllimport) #else #define _MHD_EXTERN extern #endif #endif #ifndef MHD_SOCKET_DEFINED /** * MHD_socket is type for socket FDs */ #if ! defined(_WIN32) || defined(_SYS_TYPES_FD_SET) #define MHD_POSIX_SOCKETS 1 typedef int MHD_socket; #define MHD_INVALID_SOCKET (-1) #else /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */ #define MHD_WINSOCK_SOCKETS 1 #include typedef SOCKET MHD_socket; #define MHD_INVALID_SOCKET (INVALID_SOCKET) #endif /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */ #define MHD_SOCKET_DEFINED 1 #endif /* MHD_SOCKET_DEFINED */ /** * Define MHD_NO_DEPRECATION before including "microhttpd.h" to disable deprecation messages */ #ifdef MHD_NO_DEPRECATION #define _MHD_DEPR_MACRO(msg) #define _MHD_NO_DEPR_IN_MACRO 1 #define _MHD_DEPR_IN_MACRO(msg) #define _MHD_NO_DEPR_FUNC 1 #define _MHD_DEPR_FUNC(msg) #endif /* MHD_NO_DEPRECATION */ #ifndef _MHD_DEPR_MACRO #if defined(_MSC_FULL_VER) && _MSC_VER + 0 >= 1500 /* VS 2008 or later */ /* Stringify macros */ #define _MHD_INSTRMACRO(a) #a #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) /* deprecation message */ #define _MHD_DEPR_MACRO(msg) \ __pragma(message (__FILE__ "(" _MHD_STRMACRO ( __LINE__) "): warning: " msg)) #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO (msg) #elif defined(__clang__) || defined(__GNUC_PATCHLEVEL__) /* clang or GCC since 3.0 */ #define _MHD_GCC_PRAG(x) _Pragma(#x) #if (defined(__clang__) && \ (__clang_major__ + 0 >= 5 || \ (! defined(__apple_build_version__) && \ (__clang_major__ + 0 > 3 || \ (__clang_major__ + 0 == 3 && __clang_minor__ >= 3))))) || \ __GNUC__ + 0 > 4 || (__GNUC__ + 0 == 4 && __GNUC_MINOR__ + 0 >= 8) /* clang >= 3.3 (or XCode's clang >= 5.0) or GCC >= 4.8 */ #define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG (GCC warning msg) #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO (msg) #else /* older clang or GCC */ /* clang < 3.3, XCode's clang < 5.0, 3.0 <= GCC < 4.8 */ #define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG (message msg) #if (defined(__clang__) && \ (__clang_major__ + 0 > 2 || \ (__clang_major__ + 0 == 2 && __clang_minor__ >= 9))) /* clang >= 2.9 */ /* clang handles inline pragmas better than GCC */ #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO (msg) #endif /* clang >= 2.9 */ #endif /* older clang or GCC */ /* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */ #endif /* clang || GCC >= 3.0 */ #endif /* !_MHD_DEPR_MACRO */ #ifndef _MHD_DEPR_MACRO #define _MHD_DEPR_MACRO(msg) #endif /* !_MHD_DEPR_MACRO */ #ifndef _MHD_DEPR_IN_MACRO #define _MHD_NO_DEPR_IN_MACRO 1 #define _MHD_DEPR_IN_MACRO(msg) #endif /* !_MHD_DEPR_IN_MACRO */ #ifndef _MHD_DEPR_FUNC #if defined(_MSC_FULL_VER) && _MSC_VER + 0 >= 1400 /* VS 2005 or later */ #define _MHD_DEPR_FUNC(msg) __declspec(deprecated (msg)) #elif defined(_MSC_FULL_VER) && _MSC_VER + 0 >= 1310 /* VS .NET 2003 deprecation does not support custom messages */ #define _MHD_DEPR_FUNC(msg) __declspec(deprecated) #elif (__GNUC__ + 0 >= 5) || (defined(__clang__) && \ (__clang_major__ + 0 > 2 || \ (__clang_major__ + 0 == 2 && __clang_minor__ >= 9))) /* GCC >= 5.0 or clang >= 2.9 */ #define _MHD_DEPR_FUNC(msg) __attribute__((deprecated (msg))) #elif defined(__clang__) || __GNUC__ + 0 > 3 || \ (__GNUC__ + 0 == 3 && __GNUC_MINOR__ + 0 >= 1) /* 3.1 <= GCC < 5.0 or clang < 2.9 */ /* old GCC-style deprecation does not support custom messages */ #define _MHD_DEPR_FUNC(msg) __attribute__((__deprecated__)) /* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */ #endif /* clang < 2.9 || GCC >= 3.1 */ #endif /* !_MHD_DEPR_FUNC */ #ifndef _MHD_DEPR_FUNC #define _MHD_NO_DEPR_FUNC 1 #define _MHD_DEPR_FUNC(msg) #endif /* !_MHD_DEPR_FUNC */ /** * Not all architectures and `printf()`'s support the `long long` type. * This gives the ability to replace `long long` with just a `long`, * standard `int` or a `short`. */ #ifndef MHD_LONG_LONG /** * @deprecated use #MHD_UNSIGNED_LONG_LONG instead! */ #define MHD_LONG_LONG long long #define MHD_UNSIGNED_LONG_LONG unsigned long long #else /* MHD_LONG_LONG */ _MHD_DEPR_MACRO ( \ "Macro MHD_LONG_LONG is deprecated, use MHD_UNSIGNED_LONG_LONG") #endif /** * Format string for printing a variable of type #MHD_LONG_LONG. * You should only redefine this if you also define #MHD_LONG_LONG. */ #ifndef MHD_LONG_LONG_PRINTF /** * @deprecated use #MHD_UNSIGNED_LONG_LONG_PRINTF instead! */ #define MHD_LONG_LONG_PRINTF "ll" #define MHD_UNSIGNED_LONG_LONG_PRINTF "%llu" #else /* MHD_LONG_LONG_PRINTF */ _MHD_DEPR_MACRO ( \ "Macro MHD_LONG_LONG_PRINTF is deprecated, use MHD_UNSIGNED_LONG_LONG_PRINTF") #endif /** * @defgroup httpcode HTTP response codes. * These are the status codes defined for HTTP responses. * See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml * Registry export date: 2023-09-29 * @{ */ /* 100 "Continue". RFC9110, Section 15.2.1. */ #define MHD_HTTP_CONTINUE 100 /* 101 "Switching Protocols". RFC9110, Section 15.2.2. */ #define MHD_HTTP_SWITCHING_PROTOCOLS 101 /* 102 "Processing". RFC2518. */ #define MHD_HTTP_PROCESSING 102 /* 103 "Early Hints". RFC8297. */ #define MHD_HTTP_EARLY_HINTS 103 /* 200 "OK". RFC9110, Section 15.3.1. */ #define MHD_HTTP_OK 200 /* 201 "Created". RFC9110, Section 15.3.2. */ #define MHD_HTTP_CREATED 201 /* 202 "Accepted". RFC9110, Section 15.3.3. */ #define MHD_HTTP_ACCEPTED 202 /* 203 "Non-Authoritative Information". RFC9110, Section 15.3.4. */ #define MHD_HTTP_NON_AUTHORITATIVE_INFORMATION 203 /* 204 "No Content". RFC9110, Section 15.3.5. */ #define MHD_HTTP_NO_CONTENT 204 /* 205 "Reset Content". RFC9110, Section 15.3.6. */ #define MHD_HTTP_RESET_CONTENT 205 /* 206 "Partial Content". RFC9110, Section 15.3.7. */ #define MHD_HTTP_PARTIAL_CONTENT 206 /* 207 "Multi-Status". RFC4918. */ #define MHD_HTTP_MULTI_STATUS 207 /* 208 "Already Reported". RFC5842. */ #define MHD_HTTP_ALREADY_REPORTED 208 /* 226 "IM Used". RFC3229. */ #define MHD_HTTP_IM_USED 226 /* 300 "Multiple Choices". RFC9110, Section 15.4.1. */ #define MHD_HTTP_MULTIPLE_CHOICES 300 /* 301 "Moved Permanently". RFC9110, Section 15.4.2. */ #define MHD_HTTP_MOVED_PERMANENTLY 301 /* 302 "Found". RFC9110, Section 15.4.3. */ #define MHD_HTTP_FOUND 302 /* 303 "See Other". RFC9110, Section 15.4.4. */ #define MHD_HTTP_SEE_OTHER 303 /* 304 "Not Modified". RFC9110, Section 15.4.5. */ #define MHD_HTTP_NOT_MODIFIED 304 /* 305 "Use Proxy". RFC9110, Section 15.4.6. */ #define MHD_HTTP_USE_PROXY 305 /* 306 "Switch Proxy". Not used! RFC9110, Section 15.4.7. */ #define MHD_HTTP_SWITCH_PROXY 306 /* 307 "Temporary Redirect". RFC9110, Section 15.4.8. */ #define MHD_HTTP_TEMPORARY_REDIRECT 307 /* 308 "Permanent Redirect". RFC9110, Section 15.4.9. */ #define MHD_HTTP_PERMANENT_REDIRECT 308 /* 400 "Bad Request". RFC9110, Section 15.5.1. */ #define MHD_HTTP_BAD_REQUEST 400 /* 401 "Unauthorized". RFC9110, Section 15.5.2. */ #define MHD_HTTP_UNAUTHORIZED 401 /* 402 "Payment Required". RFC9110, Section 15.5.3. */ #define MHD_HTTP_PAYMENT_REQUIRED 402 /* 403 "Forbidden". RFC9110, Section 15.5.4. */ #define MHD_HTTP_FORBIDDEN 403 /* 404 "Not Found". RFC9110, Section 15.5.5. */ #define MHD_HTTP_NOT_FOUND 404 /* 405 "Method Not Allowed". RFC9110, Section 15.5.6. */ #define MHD_HTTP_METHOD_NOT_ALLOWED 405 /* 406 "Not Acceptable". RFC9110, Section 15.5.7. */ #define MHD_HTTP_NOT_ACCEPTABLE 406 /* 407 "Proxy Authentication Required". RFC9110, Section 15.5.8. */ #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407 /* 408 "Request Timeout". RFC9110, Section 15.5.9. */ #define MHD_HTTP_REQUEST_TIMEOUT 408 /* 409 "Conflict". RFC9110, Section 15.5.10. */ #define MHD_HTTP_CONFLICT 409 /* 410 "Gone". RFC9110, Section 15.5.11. */ #define MHD_HTTP_GONE 410 /* 411 "Length Required". RFC9110, Section 15.5.12. */ #define MHD_HTTP_LENGTH_REQUIRED 411 /* 412 "Precondition Failed". RFC9110, Section 15.5.13. */ #define MHD_HTTP_PRECONDITION_FAILED 412 /* 413 "Content Too Large". RFC9110, Section 15.5.14. */ #define MHD_HTTP_CONTENT_TOO_LARGE 413 /* 414 "URI Too Long". RFC9110, Section 15.5.15. */ #define MHD_HTTP_URI_TOO_LONG 414 /* 415 "Unsupported Media Type". RFC9110, Section 15.5.16. */ #define MHD_HTTP_UNSUPPORTED_MEDIA_TYPE 415 /* 416 "Range Not Satisfiable". RFC9110, Section 15.5.17. */ #define MHD_HTTP_RANGE_NOT_SATISFIABLE 416 /* 417 "Expectation Failed". RFC9110, Section 15.5.18. */ #define MHD_HTTP_EXPECTATION_FAILED 417 /* 421 "Misdirected Request". RFC9110, Section 15.5.20. */ #define MHD_HTTP_MISDIRECTED_REQUEST 421 /* 422 "Unprocessable Content". RFC9110, Section 15.5.21. */ #define MHD_HTTP_UNPROCESSABLE_CONTENT 422 /* 423 "Locked". RFC4918. */ #define MHD_HTTP_LOCKED 423 /* 424 "Failed Dependency". RFC4918. */ #define MHD_HTTP_FAILED_DEPENDENCY 424 /* 425 "Too Early". RFC8470. */ #define MHD_HTTP_TOO_EARLY 425 /* 426 "Upgrade Required". RFC9110, Section 15.5.22. */ #define MHD_HTTP_UPGRADE_REQUIRED 426 /* 428 "Precondition Required". RFC6585. */ #define MHD_HTTP_PRECONDITION_REQUIRED 428 /* 429 "Too Many Requests". RFC6585. */ #define MHD_HTTP_TOO_MANY_REQUESTS 429 /* 431 "Request Header Fields Too Large". RFC6585. */ #define MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE 431 /* 451 "Unavailable For Legal Reasons". RFC7725. */ #define MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS 451 /* 500 "Internal Server Error". RFC9110, Section 15.6.1. */ #define MHD_HTTP_INTERNAL_SERVER_ERROR 500 /* 501 "Not Implemented". RFC9110, Section 15.6.2. */ #define MHD_HTTP_NOT_IMPLEMENTED 501 /* 502 "Bad Gateway". RFC9110, Section 15.6.3. */ #define MHD_HTTP_BAD_GATEWAY 502 /* 503 "Service Unavailable". RFC9110, Section 15.6.4. */ #define MHD_HTTP_SERVICE_UNAVAILABLE 503 /* 504 "Gateway Timeout". RFC9110, Section 15.6.5. */ #define MHD_HTTP_GATEWAY_TIMEOUT 504 /* 505 "HTTP Version Not Supported". RFC9110, Section 15.6.6. */ #define MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED 505 /* 506 "Variant Also Negotiates". RFC2295. */ #define MHD_HTTP_VARIANT_ALSO_NEGOTIATES 506 /* 507 "Insufficient Storage". RFC4918. */ #define MHD_HTTP_INSUFFICIENT_STORAGE 507 /* 508 "Loop Detected". RFC5842. */ #define MHD_HTTP_LOOP_DETECTED 508 /* 510 "Not Extended". (OBSOLETED) RFC2774; status-change-http-experiments-to-historic. */ #define MHD_HTTP_NOT_EXTENDED 510 /* 511 "Network Authentication Required". RFC6585. */ #define MHD_HTTP_NETWORK_AUTHENTICATION_REQUIRED 511 /* Not registered non-standard codes */ /* 449 "Reply With". MS IIS extension. */ #define MHD_HTTP_RETRY_WITH 449 /* 450 "Blocked by Windows Parental Controls". MS extension. */ #define MHD_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS 450 /* 509 "Bandwidth Limit Exceeded". Apache extension. */ #define MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED 509 /* Deprecated names and codes */ /** @deprecated */ #define MHD_HTTP_METHOD_NOT_ACCEPTABLE _MHD_DEPR_IN_MACRO (\ "Value MHD_HTTP_METHOD_NOT_ACCEPTABLE is deprecated, use MHD_HTTP_NOT_ACCEPTABLE" \ ) 406 /** @deprecated */ #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE _MHD_DEPR_IN_MACRO (\ "Value MHD_HTTP_REQUEST_ENTITY_TOO_LARGE is deprecated, use MHD_HTTP_CONTENT_TOO_LARGE"\ ) 413 /** @deprecated */ #define MHD_HTTP_PAYLOAD_TOO_LARGE _MHD_DEPR_IN_MACRO (\ "Value MHD_HTTP_PAYLOAD_TOO_LARGE is deprecated use MHD_HTTP_CONTENT_TOO_LARGE" \ ) 413 /** @deprecated */ #define MHD_HTTP_REQUEST_URI_TOO_LONG _MHD_DEPR_IN_MACRO (\ "Value MHD_HTTP_REQUEST_URI_TOO_LONG is deprecated, use MHD_HTTP_URI_TOO_LONG" \ ) 414 /** @deprecated */ #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE _MHD_DEPR_IN_MACRO (\ "Value MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE is deprecated, use MHD_HTTP_RANGE_NOT_SATISFIABLE" \ ) 416 /** @deprecated */ #define MHD_HTTP_UNPROCESSABLE_ENTITY _MHD_DEPR_IN_MACRO (\ "Value MHD_HTTP_UNPROCESSABLE_ENTITY is deprecated, use MHD_HTTP_UNPROCESSABLE_CONTENT" \ ) 422 /** @deprecated */ #define MHD_HTTP_UNORDERED_COLLECTION _MHD_DEPR_IN_MACRO (\ "Value MHD_HTTP_UNORDERED_COLLECTION is deprecated as it was removed from RFC" \ ) 425 /** @deprecated */ #define MHD_HTTP_NO_RESPONSE _MHD_DEPR_IN_MACRO (\ "Value MHD_HTTP_NO_RESPONSE is deprecated as it is nginx internal code for logs only"\ ) 444 /** @} */ /* end of group httpcode */ /** * Returns the string reason phrase for a response code. * * If message string is not available for a status code, * "Unknown" string will be returned. */ _MHD_EXTERN const char * MHD_get_reason_phrase_for (unsigned int code); /** * Returns the length of the string reason phrase for a response code. * * If message string is not available for a status code, * 0 is returned. */ _MHD_EXTERN size_t MHD_get_reason_phrase_len_for (unsigned int code); /** * Flag to be or-ed with MHD_HTTP status code for * SHOUTcast. This will cause the response to begin * with the SHOUTcast "ICY" line instead of "HTTP/1.x". * @ingroup specialized */ #define MHD_ICY_FLAG ((uint32_t) (((uint32_t) 1) << 31)) /** * @defgroup headers HTTP headers * The standard headers found in HTTP requests and responses. * See: https://www.iana.org/assignments/http-fields/http-fields.xhtml * Registry export date: 2023-10-02 * @{ */ /* Main HTTP headers. */ /* Permanent. RFC9110, Section 12.5.1: HTTP Semantics */ #define MHD_HTTP_HEADER_ACCEPT "Accept" /* Deprecated. RFC9110, Section 12.5.2: HTTP Semantics */ #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset" /* Permanent. RFC9110, Section 12.5.3: HTTP Semantics */ #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding" /* Permanent. RFC9110, Section 12.5.4: HTTP Semantics */ #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language" /* Permanent. RFC9110, Section 14.3: HTTP Semantics */ #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges" /* Permanent. RFC9111, Section 5.1: HTTP Caching */ #define MHD_HTTP_HEADER_AGE "Age" /* Permanent. RFC9110, Section 10.2.1: HTTP Semantics */ #define MHD_HTTP_HEADER_ALLOW "Allow" /* Permanent. RFC9110, Section 11.6.3: HTTP Semantics */ #define MHD_HTTP_HEADER_AUTHENTICATION_INFO "Authentication-Info" /* Permanent. RFC9110, Section 11.6.2: HTTP Semantics */ #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization" /* Permanent. RFC9111, Section 5.2 */ #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control" /* Permanent. RFC9112, Section 9.6: HTTP/1.1 */ #define MHD_HTTP_HEADER_CLOSE "Close" /* Permanent. RFC9110, Section 7.6.1: HTTP Semantics */ #define MHD_HTTP_HEADER_CONNECTION "Connection" /* Permanent. RFC9110, Section 8.4: HTTP Semantics */ #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding" /* Permanent. RFC9110, Section 8.5: HTTP Semantics */ #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language" /* Permanent. RFC9110, Section 8.6: HTTP Semantics */ #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length" /* Permanent. RFC9110, Section 8.7: HTTP Semantics */ #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location" /* Permanent. RFC9110, Section 14.4: HTTP Semantics */ #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range" /* Permanent. RFC9110, Section 8.3: HTTP Semantics */ #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type" /* Permanent. RFC9110, Section 6.6.1: HTTP Semantics */ #define MHD_HTTP_HEADER_DATE "Date" /* Permanent. RFC9110, Section 8.8.3: HTTP Semantics */ #define MHD_HTTP_HEADER_ETAG "ETag" /* Permanent. RFC9110, Section 10.1.1: HTTP Semantics */ #define MHD_HTTP_HEADER_EXPECT "Expect" /* Permanent. RFC9111, Section 5.3: HTTP Caching */ #define MHD_HTTP_HEADER_EXPIRES "Expires" /* Permanent. RFC9110, Section 10.1.2: HTTP Semantics */ #define MHD_HTTP_HEADER_FROM "From" /* Permanent. RFC9110, Section 7.2: HTTP Semantics */ #define MHD_HTTP_HEADER_HOST "Host" /* Permanent. RFC9110, Section 13.1.1: HTTP Semantics */ #define MHD_HTTP_HEADER_IF_MATCH "If-Match" /* Permanent. RFC9110, Section 13.1.3: HTTP Semantics */ #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since" /* Permanent. RFC9110, Section 13.1.2: HTTP Semantics */ #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match" /* Permanent. RFC9110, Section 13.1.5: HTTP Semantics */ #define MHD_HTTP_HEADER_IF_RANGE "If-Range" /* Permanent. RFC9110, Section 13.1.4: HTTP Semantics */ #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since" /* Permanent. RFC9110, Section 8.8.2: HTTP Semantics */ #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified" /* Permanent. RFC9110, Section 10.2.2: HTTP Semantics */ #define MHD_HTTP_HEADER_LOCATION "Location" /* Permanent. RFC9110, Section 7.6.2: HTTP Semantics */ #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards" /* Permanent. RFC9112, Appendix B.1: HTTP/1.1 */ #define MHD_HTTP_HEADER_MIME_VERSION "MIME-Version" /* Deprecated. RFC9111, Section 5.4: HTTP Caching */ #define MHD_HTTP_HEADER_PRAGMA "Pragma" /* Permanent. RFC9110, Section 11.7.1: HTTP Semantics */ #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate" /* Permanent. RFC9110, Section 11.7.3: HTTP Semantics */ #define MHD_HTTP_HEADER_PROXY_AUTHENTICATION_INFO "Proxy-Authentication-Info" /* Permanent. RFC9110, Section 11.7.2: HTTP Semantics */ #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization" /* Permanent. RFC9110, Section 14.2: HTTP Semantics */ #define MHD_HTTP_HEADER_RANGE "Range" /* Permanent. RFC9110, Section 10.1.3: HTTP Semantics */ #define MHD_HTTP_HEADER_REFERER "Referer" /* Permanent. RFC9110, Section 10.2.3: HTTP Semantics */ #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After" /* Permanent. RFC9110, Section 10.2.4: HTTP Semantics */ #define MHD_HTTP_HEADER_SERVER "Server" /* Permanent. RFC9110, Section 10.1.4: HTTP Semantics */ #define MHD_HTTP_HEADER_TE "TE" /* Permanent. RFC9110, Section 6.6.2: HTTP Semantics */ #define MHD_HTTP_HEADER_TRAILER "Trailer" /* Permanent. RFC9112, Section 6.1: HTTP Semantics */ #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding" /* Permanent. RFC9110, Section 7.8: HTTP Semantics */ #define MHD_HTTP_HEADER_UPGRADE "Upgrade" /* Permanent. RFC9110, Section 10.1.5: HTTP Semantics */ #define MHD_HTTP_HEADER_USER_AGENT "User-Agent" /* Permanent. RFC9110, Section 12.5.5: HTTP Semantics */ #define MHD_HTTP_HEADER_VARY "Vary" /* Permanent. RFC9110, Section 7.6.3: HTTP Semantics */ #define MHD_HTTP_HEADER_VIA "Via" /* Permanent. RFC9110, Section 11.6.1: HTTP Semantics */ #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate" /* Permanent. RFC9110, Section 12.5.5: HTTP Semantics */ #define MHD_HTTP_HEADER_ASTERISK "*" /* Additional HTTP headers. */ /* Permanent. RFC 3229: Delta encoding in HTTP */ #define MHD_HTTP_HEADER_A_IM "A-IM" /* Permanent. RFC 2324: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0) */ #define MHD_HTTP_HEADER_ACCEPT_ADDITIONS "Accept-Additions" /* Permanent. RFC 8942, Section 3.1: HTTP Client Hints */ #define MHD_HTTP_HEADER_ACCEPT_CH "Accept-CH" /* Permanent. RFC 7089: HTTP Framework for Time-Based Access to Resource States -- Memento */ #define MHD_HTTP_HEADER_ACCEPT_DATETIME "Accept-Datetime" /* Permanent. RFC 2295: Transparent Content Negotiation in HTTP */ #define MHD_HTTP_HEADER_ACCEPT_FEATURES "Accept-Features" /* Permanent. RFC 5789: PATCH Method for HTTP */ #define MHD_HTTP_HEADER_ACCEPT_PATCH "Accept-Patch" /* Permanent. Linked Data Platform 1.0 */ #define MHD_HTTP_HEADER_ACCEPT_POST "Accept-Post" /* Permanent. RFC-ietf-httpbis-message-signatures-19, Section 5.1: HTTP Message Signatures */ #define MHD_HTTP_HEADER_ACCEPT_SIGNATURE "Accept-Signature" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS \ "Access-Control-Allow-Credentials" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_HEADERS \ "Access-Control-Allow-Headers" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_METHODS \ "Access-Control-Allow-Methods" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN \ "Access-Control-Allow-Origin" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS \ "Access-Control-Expose-Headers" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_ACCESS_CONTROL_MAX_AGE "Access-Control-Max-Age" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_ACCESS_CONTROL_REQUEST_HEADERS \ "Access-Control-Request-Headers" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_ACCESS_CONTROL_REQUEST_METHOD \ "Access-Control-Request-Method" /* Permanent. RFC 7639, Section 2: The ALPN HTTP Header Field */ #define MHD_HTTP_HEADER_ALPN "ALPN" /* Permanent. RFC 7838: HTTP Alternative Services */ #define MHD_HTTP_HEADER_ALT_SVC "Alt-Svc" /* Permanent. RFC 7838: HTTP Alternative Services */ #define MHD_HTTP_HEADER_ALT_USED "Alt-Used" /* Permanent. RFC 2295: Transparent Content Negotiation in HTTP */ #define MHD_HTTP_HEADER_ALTERNATES "Alternates" /* Permanent. RFC 4437: Web Distributed Authoring and Versioning (WebDAV) Redirect Reference Resources */ #define MHD_HTTP_HEADER_APPLY_TO_REDIRECT_REF "Apply-To-Redirect-Ref" /* Permanent. RFC 8053, Section 4: HTTP Authentication Extensions for Interactive Clients */ #define MHD_HTTP_HEADER_AUTHENTICATION_CONTROL "Authentication-Control" /* Permanent. RFC9211: The Cache-Status HTTP Response Header Field */ #define MHD_HTTP_HEADER_CACHE_STATUS "Cache-Status" /* Permanent. RFC 8607, Section 5.1: Calendaring Extensions to WebDAV (CalDAV): Managed Attachments */ #define MHD_HTTP_HEADER_CAL_MANAGED_ID "Cal-Managed-ID" /* Permanent. RFC 7809, Section 7.1: Calendaring Extensions to WebDAV (CalDAV): Time Zones by Reference */ #define MHD_HTTP_HEADER_CALDAV_TIMEZONES "CalDAV-Timezones" /* Permanent. RFC9297 */ #define MHD_HTTP_HEADER_CAPSULE_PROTOCOL "Capsule-Protocol" /* Permanent. RFC9213: Targeted HTTP Cache Control */ #define MHD_HTTP_HEADER_CDN_CACHE_CONTROL "CDN-Cache-Control" /* Permanent. RFC 8586: Loop Detection in Content Delivery Networks (CDNs) */ #define MHD_HTTP_HEADER_CDN_LOOP "CDN-Loop" /* Permanent. RFC 8739, Section 3.3: Support for Short-Term, Automatically Renewed (STAR) Certificates in the Automated Certificate Management Environment (ACME) */ #define MHD_HTTP_HEADER_CERT_NOT_AFTER "Cert-Not-After" /* Permanent. RFC 8739, Section 3.3: Support for Short-Term, Automatically Renewed (STAR) Certificates in the Automated Certificate Management Environment (ACME) */ #define MHD_HTTP_HEADER_CERT_NOT_BEFORE "Cert-Not-Before" /* Permanent. Clear Site Data */ #define MHD_HTTP_HEADER_CLEAR_SITE_DATA "Clear-Site-Data" /* Permanent. RFC9440, Section 2: Client-Cert HTTP Header Field */ #define MHD_HTTP_HEADER_CLIENT_CERT "Client-Cert" /* Permanent. RFC9440, Section 2: Client-Cert HTTP Header Field */ #define MHD_HTTP_HEADER_CLIENT_CERT_CHAIN "Client-Cert-Chain" /* Permanent. RFC-ietf-httpbis-digest-headers-13, Section 2: Digest Fields */ #define MHD_HTTP_HEADER_CONTENT_DIGEST "Content-Digest" /* Permanent. RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP) */ #define MHD_HTTP_HEADER_CONTENT_DISPOSITION "Content-Disposition" /* Permanent. The HTTP Distribution and Replication Protocol */ #define MHD_HTTP_HEADER_CONTENT_ID "Content-ID" /* Permanent. Content Security Policy Level 3 */ #define MHD_HTTP_HEADER_CONTENT_SECURITY_POLICY "Content-Security-Policy" /* Permanent. Content Security Policy Level 3 */ #define MHD_HTTP_HEADER_CONTENT_SECURITY_POLICY_REPORT_ONLY \ "Content-Security-Policy-Report-Only" /* Permanent. RFC 6265: HTTP State Management Mechanism */ #define MHD_HTTP_HEADER_COOKIE "Cookie" /* Permanent. HTML */ #define MHD_HTTP_HEADER_CROSS_ORIGIN_EMBEDDER_POLICY \ "Cross-Origin-Embedder-Policy" /* Permanent. HTML */ #define MHD_HTTP_HEADER_CROSS_ORIGIN_EMBEDDER_POLICY_REPORT_ONLY \ "Cross-Origin-Embedder-Policy-Report-Only" /* Permanent. HTML */ #define MHD_HTTP_HEADER_CROSS_ORIGIN_OPENER_POLICY "Cross-Origin-Opener-Policy" /* Permanent. HTML */ #define MHD_HTTP_HEADER_CROSS_ORIGIN_OPENER_POLICY_REPORT_ONLY \ "Cross-Origin-Opener-Policy-Report-Only" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_CROSS_ORIGIN_RESOURCE_POLICY \ "Cross-Origin-Resource-Policy" /* Permanent. RFC 5323: Web Distributed Authoring and Versioning (WebDAV) SEARCH */ #define MHD_HTTP_HEADER_DASL "DASL" /* Permanent. RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */ #define MHD_HTTP_HEADER_DAV "DAV" /* Permanent. RFC 3229: Delta encoding in HTTP */ #define MHD_HTTP_HEADER_DELTA_BASE "Delta-Base" /* Permanent. RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */ #define MHD_HTTP_HEADER_DEPTH "Depth" /* Permanent. RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */ #define MHD_HTTP_HEADER_DESTINATION "Destination" /* Permanent. The HTTP Distribution and Replication Protocol */ #define MHD_HTTP_HEADER_DIFFERENTIAL_ID "Differential-ID" /* Permanent. RFC9449: OAuth 2.0 Demonstrating Proof of Possession (DPoP) */ #define MHD_HTTP_HEADER_DPOP "DPoP" /* Permanent. RFC9449: OAuth 2.0 Demonstrating Proof of Possession (DPoP) */ #define MHD_HTTP_HEADER_DPOP_NONCE "DPoP-Nonce" /* Permanent. RFC 8470: Using Early Data in HTTP */ #define MHD_HTTP_HEADER_EARLY_DATA "Early-Data" /* Permanent. RFC9163: Expect-CT Extension for HTTP */ #define MHD_HTTP_HEADER_EXPECT_CT "Expect-CT" /* Permanent. RFC 7239: Forwarded HTTP Extension */ #define MHD_HTTP_HEADER_FORWARDED "Forwarded" /* Permanent. RFC 7486, Section 6.1.1: HTTP Origin-Bound Authentication (HOBA) */ #define MHD_HTTP_HEADER_HOBAREG "Hobareg" /* Permanent. RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */ #define MHD_HTTP_HEADER_IF "If" /* Permanent. RFC 6338: Scheduling Extensions to CalDAV */ #define MHD_HTTP_HEADER_IF_SCHEDULE_TAG_MATCH "If-Schedule-Tag-Match" /* Permanent. RFC 3229: Delta encoding in HTTP */ #define MHD_HTTP_HEADER_IM "IM" /* Permanent. RFC 8473: Token Binding over HTTP */ #define MHD_HTTP_HEADER_INCLUDE_REFERRED_TOKEN_BINDING_ID \ "Include-Referred-Token-Binding-ID" /* Permanent. RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1 */ #define MHD_HTTP_HEADER_KEEP_ALIVE "Keep-Alive" /* Permanent. RFC 3253: Versioning Extensions to WebDAV: (Web Distributed Authoring and Versioning) */ #define MHD_HTTP_HEADER_LABEL "Label" /* Permanent. HTML */ #define MHD_HTTP_HEADER_LAST_EVENT_ID "Last-Event-ID" /* Permanent. RFC 8288: Web Linking */ #define MHD_HTTP_HEADER_LINK "Link" /* Permanent. RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */ #define MHD_HTTP_HEADER_LOCK_TOKEN "Lock-Token" /* Permanent. RFC 7089: HTTP Framework for Time-Based Access to Resource States -- Memento */ #define MHD_HTTP_HEADER_MEMENTO_DATETIME "Memento-Datetime" /* Permanent. RFC 2227: Simple Hit-Metering and Usage-Limiting for HTTP */ #define MHD_HTTP_HEADER_METER "Meter" /* Permanent. RFC 2295: Transparent Content Negotiation in HTTP */ #define MHD_HTTP_HEADER_NEGOTIATE "Negotiate" /* Permanent. Network Error Logging */ #define MHD_HTTP_HEADER_NEL "NEL" /* Permanent. OData Version 4.01 Part 1: Protocol; OASIS; Chet_Ensign */ #define MHD_HTTP_HEADER_ODATA_ENTITYID "OData-EntityId" /* Permanent. OData Version 4.01 Part 1: Protocol; OASIS; Chet_Ensign */ #define MHD_HTTP_HEADER_ODATA_ISOLATION "OData-Isolation" /* Permanent. OData Version 4.01 Part 1: Protocol; OASIS; Chet_Ensign */ #define MHD_HTTP_HEADER_ODATA_MAXVERSION "OData-MaxVersion" /* Permanent. OData Version 4.01 Part 1: Protocol; OASIS; Chet_Ensign */ #define MHD_HTTP_HEADER_ODATA_VERSION "OData-Version" /* Permanent. RFC 8053, Section 3: HTTP Authentication Extensions for Interactive Clients */ #define MHD_HTTP_HEADER_OPTIONAL_WWW_AUTHENTICATE "Optional-WWW-Authenticate" /* Permanent. RFC 3648: Web Distributed Authoring and Versioning (WebDAV) Ordered Collections Protocol */ #define MHD_HTTP_HEADER_ORDERING_TYPE "Ordering-Type" /* Permanent. RFC 6454: The Web Origin Concept */ #define MHD_HTTP_HEADER_ORIGIN "Origin" /* Permanent. HTML */ #define MHD_HTTP_HEADER_ORIGIN_AGENT_CLUSTER "Origin-Agent-Cluster" /* Permanent. RFC 8613, Section 11.1: Object Security for Constrained RESTful Environments (OSCORE) */ #define MHD_HTTP_HEADER_OSCORE "OSCORE" /* Permanent. OASIS Project Specification 01; OASIS; Chet_Ensign */ #define MHD_HTTP_HEADER_OSLC_CORE_VERSION "OSLC-Core-Version" /* Permanent. RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */ #define MHD_HTTP_HEADER_OVERWRITE "Overwrite" /* Permanent. HTML */ #define MHD_HTTP_HEADER_PING_FROM "Ping-From" /* Permanent. HTML */ #define MHD_HTTP_HEADER_PING_TO "Ping-To" /* Permanent. RFC 3648: Web Distributed Authoring and Versioning (WebDAV) Ordered Collections Protocol */ #define MHD_HTTP_HEADER_POSITION "Position" /* Permanent. RFC 7240: Prefer Header for HTTP */ #define MHD_HTTP_HEADER_PREFER "Prefer" /* Permanent. RFC 7240: Prefer Header for HTTP */ #define MHD_HTTP_HEADER_PREFERENCE_APPLIED "Preference-Applied" /* Permanent. RFC9218: Extensible Prioritization Scheme for HTTP */ #define MHD_HTTP_HEADER_PRIORITY "Priority" /* Permanent. RFC9209: The Proxy-Status HTTP Response Header Field */ #define MHD_HTTP_HEADER_PROXY_STATUS "Proxy-Status" /* Permanent. RFC 7469: Public Key Pinning Extension for HTTP */ #define MHD_HTTP_HEADER_PUBLIC_KEY_PINS "Public-Key-Pins" /* Permanent. RFC 7469: Public Key Pinning Extension for HTTP */ #define MHD_HTTP_HEADER_PUBLIC_KEY_PINS_REPORT_ONLY \ "Public-Key-Pins-Report-Only" /* Permanent. RFC 4437: Web Distributed Authoring and Versioning (WebDAV) Redirect Reference Resources */ #define MHD_HTTP_HEADER_REDIRECT_REF "Redirect-Ref" /* Permanent. HTML */ #define MHD_HTTP_HEADER_REFRESH "Refresh" /* Permanent. RFC 8555, Section 6.5.1: Automatic Certificate Management Environment (ACME) */ #define MHD_HTTP_HEADER_REPLAY_NONCE "Replay-Nonce" /* Permanent. RFC-ietf-httpbis-digest-headers-13, Section 3: Digest Fields */ #define MHD_HTTP_HEADER_REPR_DIGEST "Repr-Digest" /* Permanent. RFC 6638: Scheduling Extensions to CalDAV */ #define MHD_HTTP_HEADER_SCHEDULE_REPLY "Schedule-Reply" /* Permanent. RFC 6338: Scheduling Extensions to CalDAV */ #define MHD_HTTP_HEADER_SCHEDULE_TAG "Schedule-Tag" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_SEC_PURPOSE "Sec-Purpose" /* Permanent. RFC 8473: Token Binding over HTTP */ #define MHD_HTTP_HEADER_SEC_TOKEN_BINDING "Sec-Token-Binding" /* Permanent. RFC 6455: The WebSocket Protocol */ #define MHD_HTTP_HEADER_SEC_WEBSOCKET_ACCEPT "Sec-WebSocket-Accept" /* Permanent. RFC 6455: The WebSocket Protocol */ #define MHD_HTTP_HEADER_SEC_WEBSOCKET_EXTENSIONS "Sec-WebSocket-Extensions" /* Permanent. RFC 6455: The WebSocket Protocol */ #define MHD_HTTP_HEADER_SEC_WEBSOCKET_KEY "Sec-WebSocket-Key" /* Permanent. RFC 6455: The WebSocket Protocol */ #define MHD_HTTP_HEADER_SEC_WEBSOCKET_PROTOCOL "Sec-WebSocket-Protocol" /* Permanent. RFC 6455: The WebSocket Protocol */ #define MHD_HTTP_HEADER_SEC_WEBSOCKET_VERSION "Sec-WebSocket-Version" /* Permanent. Server Timing */ #define MHD_HTTP_HEADER_SERVER_TIMING "Server-Timing" /* Permanent. RFC 6265: HTTP State Management Mechanism */ #define MHD_HTTP_HEADER_SET_COOKIE "Set-Cookie" /* Permanent. RFC-ietf-httpbis-message-signatures-19, Section 4.2: HTTP Message Signatures */ #define MHD_HTTP_HEADER_SIGNATURE "Signature" /* Permanent. RFC-ietf-httpbis-message-signatures-19, Section 4.1: HTTP Message Signatures */ #define MHD_HTTP_HEADER_SIGNATURE_INPUT "Signature-Input" /* Permanent. RFC 5023: The Atom Publishing Protocol */ #define MHD_HTTP_HEADER_SLUG "SLUG" /* Permanent. Simple Object Access Protocol (SOAP) 1.1 */ #define MHD_HTTP_HEADER_SOAPACTION "SoapAction" /* Permanent. RFC 2518: HTTP Extensions for Distributed Authoring -- WEBDAV */ #define MHD_HTTP_HEADER_STATUS_URI "Status-URI" /* Permanent. RFC 6797: HTTP Strict Transport Security (HSTS) */ #define MHD_HTTP_HEADER_STRICT_TRANSPORT_SECURITY "Strict-Transport-Security" /* Permanent. RFC 8594: The Sunset HTTP Header Field */ #define MHD_HTTP_HEADER_SUNSET "Sunset" /* Permanent. Edge Architecture Specification */ #define MHD_HTTP_HEADER_SURROGATE_CAPABILITY "Surrogate-Capability" /* Permanent. Edge Architecture Specification */ #define MHD_HTTP_HEADER_SURROGATE_CONTROL "Surrogate-Control" /* Permanent. RFC 2295: Transparent Content Negotiation in HTTP */ #define MHD_HTTP_HEADER_TCN "TCN" /* Permanent. RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) */ #define MHD_HTTP_HEADER_TIMEOUT "Timeout" /* Permanent. RFC 8030, Section 5.4: Generic Event Delivery Using HTTP Push */ #define MHD_HTTP_HEADER_TOPIC "Topic" /* Permanent. Trace Context */ #define MHD_HTTP_HEADER_TRACEPARENT "Traceparent" /* Permanent. Trace Context */ #define MHD_HTTP_HEADER_TRACESTATE "Tracestate" /* Permanent. RFC 8030, Section 5.2: Generic Event Delivery Using HTTP Push */ #define MHD_HTTP_HEADER_TTL "TTL" /* Permanent. RFC 8030, Section 5.3: Generic Event Delivery Using HTTP Push */ #define MHD_HTTP_HEADER_URGENCY "Urgency" /* Permanent. RFC 2295: Transparent Content Negotiation in HTTP */ #define MHD_HTTP_HEADER_VARIANT_VARY "Variant-Vary" /* Permanent. RFC-ietf-httpbis-digest-headers-13, Section 4: Digest Fields */ #define MHD_HTTP_HEADER_WANT_CONTENT_DIGEST "Want-Content-Digest" /* Permanent. RFC-ietf-httpbis-digest-headers-13, Section 4: Digest Fields */ #define MHD_HTTP_HEADER_WANT_REPR_DIGEST "Want-Repr-Digest" /* Permanent. Fetch */ #define MHD_HTTP_HEADER_X_CONTENT_TYPE_OPTIONS "X-Content-Type-Options" /* Permanent. HTML */ #define MHD_HTTP_HEADER_X_FRAME_OPTIONS "X-Frame-Options" /* Provisional. AMP-Cache-Transform HTTP request header */ #define MHD_HTTP_HEADER_AMP_CACHE_TRANSFORM "AMP-Cache-Transform" /* Provisional. OSLC Configuration Management Version 1.0. Part 3: Configuration Specification */ #define MHD_HTTP_HEADER_CONFIGURATION_CONTEXT "Configuration-Context" /* Provisional. RFC 6017: Electronic Data Interchange - Internet Integration (EDIINT) Features Header Field */ #define MHD_HTTP_HEADER_EDIINT_FEATURES "EDIINT-Features" /* Provisional. OData Version 4.01 Part 1: Protocol; OASIS; Chet_Ensign */ #define MHD_HTTP_HEADER_ISOLATION "Isolation" /* Provisional. Permissions Policy */ #define MHD_HTTP_HEADER_PERMISSIONS_POLICY "Permissions-Policy" /* Provisional. Repeatable Requests Version 1.0; OASIS; Chet_Ensign */ #define MHD_HTTP_HEADER_REPEATABILITY_CLIENT_ID "Repeatability-Client-ID" /* Provisional. Repeatable Requests Version 1.0; OASIS; Chet_Ensign */ #define MHD_HTTP_HEADER_REPEATABILITY_FIRST_SENT "Repeatability-First-Sent" /* Provisional. Repeatable Requests Version 1.0; OASIS; Chet_Ensign */ #define MHD_HTTP_HEADER_REPEATABILITY_REQUEST_ID "Repeatability-Request-ID" /* Provisional. Repeatable Requests Version 1.0; OASIS; Chet_Ensign */ #define MHD_HTTP_HEADER_REPEATABILITY_RESULT "Repeatability-Result" /* Provisional. Reporting API */ #define MHD_HTTP_HEADER_REPORTING_ENDPOINTS "Reporting-Endpoints" /* Provisional. Global Privacy Control (GPC) */ #define MHD_HTTP_HEADER_SEC_GPC "Sec-GPC" /* Provisional. Resource Timing Level 1 */ #define MHD_HTTP_HEADER_TIMING_ALLOW_ORIGIN "Timing-Allow-Origin" /* Deprecated. PEP - an Extension Mechanism for HTTP; status-change-http-experiments-to-historic */ #define MHD_HTTP_HEADER_C_PEP_INFO "C-PEP-Info" /* Deprecated. White Paper: Joint Electronic Payment Initiative */ #define MHD_HTTP_HEADER_PROTOCOL_INFO "Protocol-Info" /* Deprecated. White Paper: Joint Electronic Payment Initiative */ #define MHD_HTTP_HEADER_PROTOCOL_QUERY "Protocol-Query" /* Obsoleted. Access Control for Cross-site Requests */ #define MHD_HTTP_HEADER_ACCESS_CONTROL "Access-Control" /* Obsoleted. RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */ #define MHD_HTTP_HEADER_C_EXT "C-Ext" /* Obsoleted. RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */ #define MHD_HTTP_HEADER_C_MAN "C-Man" /* Obsoleted. RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */ #define MHD_HTTP_HEADER_C_OPT "C-Opt" /* Obsoleted. PEP - an Extension Mechanism for HTTP; status-change-http-experiments-to-historic */ #define MHD_HTTP_HEADER_C_PEP "C-PEP" /* Obsoleted. RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1; RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1 */ #define MHD_HTTP_HEADER_CONTENT_BASE "Content-Base" /* Obsoleted. RFC 2616, Section 14.15: Hypertext Transfer Protocol -- HTTP/1.1; RFC 7231, Appendix B: Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content */ #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5" /* Obsoleted. HTML 4.01 Specification */ #define MHD_HTTP_HEADER_CONTENT_SCRIPT_TYPE "Content-Script-Type" /* Obsoleted. HTML 4.01 Specification */ #define MHD_HTTP_HEADER_CONTENT_STYLE_TYPE "Content-Style-Type" /* Obsoleted. RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1 */ #define MHD_HTTP_HEADER_CONTENT_VERSION "Content-Version" /* Obsoleted. RFC 2965: HTTP State Management Mechanism; RFC 6265: HTTP State Management Mechanism */ #define MHD_HTTP_HEADER_COOKIE2 "Cookie2" /* Obsoleted. HTML 4.01 Specification */ #define MHD_HTTP_HEADER_DEFAULT_STYLE "Default-Style" /* Obsoleted. RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1 */ #define MHD_HTTP_HEADER_DERIVED_FROM "Derived-From" /* Obsoleted. RFC 3230: Instance Digests in HTTP; RFC-ietf-httpbis-digest-headers-13, Section 1.3: Digest Fields */ #define MHD_HTTP_HEADER_DIGEST "Digest" /* Obsoleted. RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */ #define MHD_HTTP_HEADER_EXT "Ext" /* Obsoleted. Implementation of OPS Over HTTP */ #define MHD_HTTP_HEADER_GETPROFILE "GetProfile" /* Obsoleted. RFC 7540, Section 3.2.1: Hypertext Transfer Protocol Version 2 (HTTP/2) */ #define MHD_HTTP_HEADER_HTTP2_SETTINGS "HTTP2-Settings" /* Obsoleted. RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */ #define MHD_HTTP_HEADER_MAN "Man" /* Obsoleted. Access Control for Cross-site Requests */ #define MHD_HTTP_HEADER_METHOD_CHECK "Method-Check" /* Obsoleted. Access Control for Cross-site Requests */ #define MHD_HTTP_HEADER_METHOD_CHECK_EXPIRES "Method-Check-Expires" /* Obsoleted. RFC 2774: An HTTP Extension Framework; status-change-http-experiments-to-historic */ #define MHD_HTTP_HEADER_OPT "Opt" /* Obsoleted. The Platform for Privacy Preferences 1.0 (P3P1.0) Specification */ #define MHD_HTTP_HEADER_P3P "P3P" /* Obsoleted. PEP - an Extension Mechanism for HTTP */ #define MHD_HTTP_HEADER_PEP "PEP" /* Obsoleted. PEP - an Extension Mechanism for HTTP */ #define MHD_HTTP_HEADER_PEP_INFO "Pep-Info" /* Obsoleted. PICS Label Distribution Label Syntax and Communication Protocols */ #define MHD_HTTP_HEADER_PICS_LABEL "PICS-Label" /* Obsoleted. Implementation of OPS Over HTTP */ #define MHD_HTTP_HEADER_PROFILEOBJECT "ProfileObject" /* Obsoleted. PICS Label Distribution Label Syntax and Communication Protocols */ #define MHD_HTTP_HEADER_PROTOCOL "Protocol" /* Obsoleted. PICS Label Distribution Label Syntax and Communication Protocols */ #define MHD_HTTP_HEADER_PROTOCOL_REQUEST "Protocol-Request" /* Obsoleted. Notification for Proxy Caches */ #define MHD_HTTP_HEADER_PROXY_FEATURES "Proxy-Features" /* Obsoleted. Notification for Proxy Caches */ #define MHD_HTTP_HEADER_PROXY_INSTRUCTION "Proxy-Instruction" /* Obsoleted. RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1 */ #define MHD_HTTP_HEADER_PUBLIC "Public" /* Obsoleted. Access Control for Cross-site Requests */ #define MHD_HTTP_HEADER_REFERER_ROOT "Referer-Root" /* Obsoleted. RFC 2310: The Safe Response Header Field; status-change-http-experiments-to-historic */ #define MHD_HTTP_HEADER_SAFE "Safe" /* Obsoleted. RFC 2660: The Secure HyperText Transfer Protocol; status-change-http-experiments-to-historic */ #define MHD_HTTP_HEADER_SECURITY_SCHEME "Security-Scheme" /* Obsoleted. RFC 2965: HTTP State Management Mechanism; RFC 6265: HTTP State Management Mechanism */ #define MHD_HTTP_HEADER_SET_COOKIE2 "Set-Cookie2" /* Obsoleted. Implementation of OPS Over HTTP */ #define MHD_HTTP_HEADER_SETPROFILE "SetProfile" /* Obsoleted. RFC 2068: Hypertext Transfer Protocol -- HTTP/1.1 */ #define MHD_HTTP_HEADER_URI "URI" /* Obsoleted. RFC 3230: Instance Digests in HTTP; RFC-ietf-httpbis-digest-headers-13, Section 1.3: Digest Fields */ #define MHD_HTTP_HEADER_WANT_DIGEST "Want-Digest" /* Obsoleted. RFC9111, Section 5.5: HTTP Caching */ #define MHD_HTTP_HEADER_WARNING "Warning" /* Headers removed from the registry. Do not use! */ /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_COMPLIANCE "Compliance" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_CONTENT_TRANSFER_ENCODING "Content-Transfer-Encoding" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_COST "Cost" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_MESSAGE_ID "Message-ID" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_NON_COMPLIANCE "Non-Compliance" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_OPTIONAL "Optional" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_RESOLUTION_HINT "Resolution-Hint" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_RESOLVER_LOCATION "Resolver-Location" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_SUBOK "SubOK" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_SUBST "Subst" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_TITLE "Title" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_UA_COLOR "UA-Color" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_UA_MEDIA "UA-Media" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_UA_PIXELS "UA-Pixels" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_UA_RESOLUTION "UA-Resolution" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_UA_WINDOWPIXELS "UA-Windowpixels" /* Obsoleted. RFC4229 */ #define MHD_HTTP_HEADER_VERSION "Version" /* Obsoleted. W3C Mobile Web Best Practices Working Group */ #define MHD_HTTP_HEADER_X_DEVICE_ACCEPT "X-Device-Accept" /* Obsoleted. W3C Mobile Web Best Practices Working Group */ #define MHD_HTTP_HEADER_X_DEVICE_ACCEPT_CHARSET "X-Device-Accept-Charset" /* Obsoleted. W3C Mobile Web Best Practices Working Group */ #define MHD_HTTP_HEADER_X_DEVICE_ACCEPT_ENCODING "X-Device-Accept-Encoding" /* Obsoleted. W3C Mobile Web Best Practices Working Group */ #define MHD_HTTP_HEADER_X_DEVICE_ACCEPT_LANGUAGE "X-Device-Accept-Language" /* Obsoleted. W3C Mobile Web Best Practices Working Group */ #define MHD_HTTP_HEADER_X_DEVICE_USER_AGENT "X-Device-User-Agent" /** @} */ /* end of group headers */ /** * @defgroup versions HTTP versions * These strings should be used to match against the first line of the * HTTP header. * @{ */ #define MHD_HTTP_VERSION_1_0 "HTTP/1.0" #define MHD_HTTP_VERSION_1_1 "HTTP/1.1" /** @} */ /* end of group versions */ /** * @defgroup methods HTTP methods * HTTP methods (as strings). * See: https://www.iana.org/assignments/http-methods/http-methods.xml * Registry export date: 2023-10-02 * @{ */ /* Main HTTP methods. */ /* Safe. Idempotent. RFC9110, Section 9.3.1. */ #define MHD_HTTP_METHOD_GET "GET" /* Safe. Idempotent. RFC9110, Section 9.3.2. */ #define MHD_HTTP_METHOD_HEAD "HEAD" /* Not safe. Not idempotent. RFC9110, Section 9.3.3. */ #define MHD_HTTP_METHOD_POST "POST" /* Not safe. Idempotent. RFC9110, Section 9.3.4. */ #define MHD_HTTP_METHOD_PUT "PUT" /* Not safe. Idempotent. RFC9110, Section 9.3.5. */ #define MHD_HTTP_METHOD_DELETE "DELETE" /* Not safe. Not idempotent. RFC9110, Section 9.3.6. */ #define MHD_HTTP_METHOD_CONNECT "CONNECT" /* Safe. Idempotent. RFC9110, Section 9.3.7. */ #define MHD_HTTP_METHOD_OPTIONS "OPTIONS" /* Safe. Idempotent. RFC9110, Section 9.3.8. */ #define MHD_HTTP_METHOD_TRACE "TRACE" /* Additional HTTP methods. */ /* Not safe. Idempotent. RFC3744, Section 8.1. */ #define MHD_HTTP_METHOD_ACL "ACL" /* Not safe. Idempotent. RFC3253, Section 12.6. */ #define MHD_HTTP_METHOD_BASELINE_CONTROL "BASELINE-CONTROL" /* Not safe. Idempotent. RFC5842, Section 4. */ #define MHD_HTTP_METHOD_BIND "BIND" /* Not safe. Idempotent. RFC3253, Section 4.4, Section 9.4. */ #define MHD_HTTP_METHOD_CHECKIN "CHECKIN" /* Not safe. Idempotent. RFC3253, Section 4.3, Section 8.8. */ #define MHD_HTTP_METHOD_CHECKOUT "CHECKOUT" /* Not safe. Idempotent. RFC4918, Section 9.8. */ #define MHD_HTTP_METHOD_COPY "COPY" /* Not safe. Idempotent. RFC3253, Section 8.2. */ #define MHD_HTTP_METHOD_LABEL "LABEL" /* Not safe. Idempotent. RFC2068, Section 19.6.1.2. */ #define MHD_HTTP_METHOD_LINK "LINK" /* Not safe. Not idempotent. RFC4918, Section 9.10. */ #define MHD_HTTP_METHOD_LOCK "LOCK" /* Not safe. Idempotent. RFC3253, Section 11.2. */ #define MHD_HTTP_METHOD_MERGE "MERGE" /* Not safe. Idempotent. RFC3253, Section 13.5. */ #define MHD_HTTP_METHOD_MKACTIVITY "MKACTIVITY" /* Not safe. Idempotent. RFC4791, Section 5.3.1; RFC8144, Section 2.3. */ #define MHD_HTTP_METHOD_MKCALENDAR "MKCALENDAR" /* Not safe. Idempotent. RFC4918, Section 9.3; RFC5689, Section 3; RFC8144, Section 2.3. */ #define MHD_HTTP_METHOD_MKCOL "MKCOL" /* Not safe. Idempotent. RFC4437, Section 6. */ #define MHD_HTTP_METHOD_MKREDIRECTREF "MKREDIRECTREF" /* Not safe. Idempotent. RFC3253, Section 6.3. */ #define MHD_HTTP_METHOD_MKWORKSPACE "MKWORKSPACE" /* Not safe. Idempotent. RFC4918, Section 9.9. */ #define MHD_HTTP_METHOD_MOVE "MOVE" /* Not safe. Idempotent. RFC3648, Section 7. */ #define MHD_HTTP_METHOD_ORDERPATCH "ORDERPATCH" /* Not safe. Not idempotent. RFC5789, Section 2. */ #define MHD_HTTP_METHOD_PATCH "PATCH" /* Safe. Idempotent. RFC9113, Section 3.4. */ #define MHD_HTTP_METHOD_PRI "PRI" /* Safe. Idempotent. RFC4918, Section 9.1; RFC8144, Section 2.1. */ #define MHD_HTTP_METHOD_PROPFIND "PROPFIND" /* Not safe. Idempotent. RFC4918, Section 9.2; RFC8144, Section 2.2. */ #define MHD_HTTP_METHOD_PROPPATCH "PROPPATCH" /* Not safe. Idempotent. RFC5842, Section 6. */ #define MHD_HTTP_METHOD_REBIND "REBIND" /* Safe. Idempotent. RFC3253, Section 3.6; RFC8144, Section 2.1. */ #define MHD_HTTP_METHOD_REPORT "REPORT" /* Safe. Idempotent. RFC5323, Section 2. */ #define MHD_HTTP_METHOD_SEARCH "SEARCH" /* Not safe. Idempotent. RFC5842, Section 5. */ #define MHD_HTTP_METHOD_UNBIND "UNBIND" /* Not safe. Idempotent. RFC3253, Section 4.5. */ #define MHD_HTTP_METHOD_UNCHECKOUT "UNCHECKOUT" /* Not safe. Idempotent. RFC2068, Section 19.6.1.3. */ #define MHD_HTTP_METHOD_UNLINK "UNLINK" /* Not safe. Idempotent. RFC4918, Section 9.11. */ #define MHD_HTTP_METHOD_UNLOCK "UNLOCK" /* Not safe. Idempotent. RFC3253, Section 7.1. */ #define MHD_HTTP_METHOD_UPDATE "UPDATE" /* Not safe. Idempotent. RFC4437, Section 7. */ #define MHD_HTTP_METHOD_UPDATEREDIRECTREF "UPDATEREDIRECTREF" /* Not safe. Idempotent. RFC3253, Section 3.5. */ #define MHD_HTTP_METHOD_VERSION_CONTROL "VERSION-CONTROL" /* Not safe. Not idempotent. RFC9110, Section 18.2. */ #define MHD_HTTP_METHOD_ASTERISK "*" /** @} */ /* end of group methods */ /** * @defgroup postenc HTTP POST encodings * See also: http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4 * @{ */ #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED \ "application/x-www-form-urlencoded" #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data" /** @} */ /* end of group postenc */ /** * @brief Handle for the daemon (listening on a socket for HTTP traffic). * @ingroup event */ struct MHD_Daemon; /** * @brief Handle for a connection / HTTP request. * * With HTTP/1.1, multiple requests can be run over the same * connection. However, MHD will only show one request per TCP * connection to the client at any given time. * @ingroup request */ struct MHD_Connection; /** * @brief Handle for a response. * @ingroup response */ struct MHD_Response; /** * @brief Handle for POST processing. * @ingroup response */ struct MHD_PostProcessor; /** * @brief Flags for the `struct MHD_Daemon`. * * Note that MHD will run automatically in background thread(s) only * if #MHD_USE_INTERNAL_POLLING_THREAD is used. Otherwise caller (application) * must use #MHD_run() or #MHD_run_from_select() to have MHD processed * network connections and data. * * Starting the daemon may also fail if a particular option is not * implemented or not supported on the target platform (i.e. no * support for TLS, epoll or IPv6). */ enum MHD_FLAG { /** * No options selected. */ MHD_NO_FLAG = 0, /** * Print errors messages to custom error logger or to `stderr` if * custom error logger is not set. * @sa ::MHD_OPTION_EXTERNAL_LOGGER */ MHD_USE_ERROR_LOG = 1, /** * Run in debug mode. If this flag is used, the library should * print error messages and warnings to `stderr`. */ MHD_USE_DEBUG = 1, /** * Run in HTTPS mode. The modern protocol is called TLS. */ MHD_USE_TLS = 2, /** @deprecated */ MHD_USE_SSL = 2, #if 0 /* let's do this later once versions that define MHD_USE_TLS a more widely deployed. */ #define MHD_USE_SSL \ _MHD_DEPR_IN_MACRO ("Value MHD_USE_SSL is deprecated, use MHD_USE_TLS") \ MHD_USE_TLS #endif /** * Run using one thread per connection. * Must be used only with #MHD_USE_INTERNAL_POLLING_THREAD. * * If #MHD_USE_ITC is also not used, closed and expired connections may only * be cleaned up internally when a new connection is received. * Consider adding of #MHD_USE_ITC flag to have faster internal cleanups * at very minor increase in system resources usage. */ MHD_USE_THREAD_PER_CONNECTION = 4, /** * Run using an internal thread (or thread pool) for sockets sending * and receiving and data processing. Without this flag MHD will not * run automatically in background thread(s). * If this flag is set, #MHD_run() and #MHD_run_from_select() couldn't * be used. * This flag is set explicitly by #MHD_USE_POLL_INTERNAL_THREAD and * by #MHD_USE_EPOLL_INTERNAL_THREAD. * When this flag is not set, MHD run in "external" polling mode. */ MHD_USE_INTERNAL_POLLING_THREAD = 8, /** @deprecated */ MHD_USE_SELECT_INTERNALLY = 8, #if 0 /* Will be marked for real deprecation later. */ #define MHD_USE_SELECT_INTERNALLY \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_USE_SELECT_INTERNALLY is deprecated, use MHD_USE_INTERNAL_POLLING_THREAD instead") \ MHD_USE_INTERNAL_POLLING_THREAD #endif /* 0 */ /** * Run using the IPv6 protocol (otherwise, MHD will just support * IPv4). If you want MHD to support IPv4 and IPv6 using a single * socket, pass #MHD_USE_DUAL_STACK, otherwise, if you only pass * this option, MHD will try to bind to IPv6-only (resulting in * no IPv4 support). */ MHD_USE_IPv6 = 16, /** * Be pedantic about the protocol (as opposed to as tolerant as * possible). * This flag is equivalent to setting 1 as #MHD_OPTION_CLIENT_DISCIPLINE_LVL * value. * @sa #MHD_OPTION_CLIENT_DISCIPLINE_LVL */ MHD_USE_PEDANTIC_CHECKS = 32, #if 0 /* Will be marked for real deprecation later. */ #define MHD_USE_PEDANTIC_CHECKS \ _MHD_DEPR_IN_MACRO ( \ "Flag MHD_USE_PEDANTIC_CHECKS is deprecated, " \ "use option MHD_OPTION_CLIENT_DISCIPLINE_LVL instead") \ 32 #endif /* 0 */ /** * Use `poll()` instead of `select()` for polling sockets. * This allows sockets with `fd >= FD_SETSIZE`. * This option is not compatible with an "external" polling mode * (as there is no API to get the file descriptors for the external * poll() from MHD) and must also not be used in combination * with #MHD_USE_EPOLL. * @sa ::MHD_FEATURE_POLL, #MHD_USE_POLL_INTERNAL_THREAD */ MHD_USE_POLL = 64, /** * Run using an internal thread (or thread pool) doing `poll()`. * @sa ::MHD_FEATURE_POLL, #MHD_USE_POLL, #MHD_USE_INTERNAL_POLLING_THREAD */ MHD_USE_POLL_INTERNAL_THREAD = MHD_USE_POLL | MHD_USE_INTERNAL_POLLING_THREAD, /** @deprecated */ MHD_USE_POLL_INTERNALLY = MHD_USE_POLL | MHD_USE_INTERNAL_POLLING_THREAD, #if 0 /* Will be marked for real deprecation later. */ #define MHD_USE_POLL_INTERNALLY \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_USE_POLL_INTERNALLY is deprecated, use MHD_USE_POLL_INTERNAL_THREAD instead") \ MHD_USE_POLL_INTERNAL_THREAD #endif /* 0 */ /** * Suppress (automatically) adding the 'Date:' header to HTTP responses. * This option should ONLY be used on systems that do not have a clock * and that DO provide other mechanisms for cache control. See also * RFC 2616, section 14.18 (exception 3). */ MHD_USE_SUPPRESS_DATE_NO_CLOCK = 128, /** @deprecated */ MHD_SUPPRESS_DATE_NO_CLOCK = 128, #if 0 /* Will be marked for real deprecation later. */ #define MHD_SUPPRESS_DATE_NO_CLOCK \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_SUPPRESS_DATE_NO_CLOCK is deprecated, use MHD_USE_SUPPRESS_DATE_NO_CLOCK instead") \ MHD_USE_SUPPRESS_DATE_NO_CLOCK #endif /* 0 */ /** * Run without a listen socket. This option only makes sense if * #MHD_add_connection is to be used exclusively to connect HTTP * clients to the HTTP server. This option is incompatible with * using a thread pool; if it is used, #MHD_OPTION_THREAD_POOL_SIZE * is ignored. */ MHD_USE_NO_LISTEN_SOCKET = 256, /** * Use `epoll()` instead of `select()` or `poll()` for the event loop. * This option is only available on some systems; using the option on * systems without epoll will cause #MHD_start_daemon to fail. Using * this option is not supported with #MHD_USE_THREAD_PER_CONNECTION. * @sa ::MHD_FEATURE_EPOLL */ MHD_USE_EPOLL = 512, /** @deprecated */ MHD_USE_EPOLL_LINUX_ONLY = 512, #if 0 /* Will be marked for real deprecation later. */ #define MHD_USE_EPOLL_LINUX_ONLY \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_USE_EPOLL_LINUX_ONLY is deprecated, use MHD_USE_EPOLL") \ MHD_USE_EPOLL #endif /* 0 */ /** * Run using an internal thread (or thread pool) doing `epoll` polling. * This option is only available on certain platforms; using the option on * platform without `epoll` support will cause #MHD_start_daemon to fail. * @sa ::MHD_FEATURE_EPOLL, #MHD_USE_EPOLL, #MHD_USE_INTERNAL_POLLING_THREAD */ MHD_USE_EPOLL_INTERNAL_THREAD = MHD_USE_EPOLL | MHD_USE_INTERNAL_POLLING_THREAD, /** @deprecated */ MHD_USE_EPOLL_INTERNALLY = MHD_USE_EPOLL | MHD_USE_INTERNAL_POLLING_THREAD, /** @deprecated */ MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY = MHD_USE_EPOLL | MHD_USE_INTERNAL_POLLING_THREAD, #if 0 /* Will be marked for real deprecation later. */ #define MHD_USE_EPOLL_INTERNALLY \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_USE_EPOLL_INTERNALLY is deprecated, use MHD_USE_EPOLL_INTERNAL_THREAD") \ MHD_USE_EPOLL_INTERNAL_THREAD /** @deprecated */ #define MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY is deprecated, use MHD_USE_EPOLL_INTERNAL_THREAD") \ MHD_USE_EPOLL_INTERNAL_THREAD #endif /* 0 */ /** * Use inter-thread communication channel. * #MHD_USE_ITC can be used with #MHD_USE_INTERNAL_POLLING_THREAD * and is ignored with any "external" sockets polling. * It's required for use of #MHD_quiesce_daemon * or #MHD_add_connection. * This option is enforced by #MHD_ALLOW_SUSPEND_RESUME or * #MHD_USE_NO_LISTEN_SOCKET. * #MHD_USE_ITC is always used automatically on platforms * where select()/poll()/other ignore shutdown of listen * socket. */ MHD_USE_ITC = 1024, /** @deprecated */ MHD_USE_PIPE_FOR_SHUTDOWN = 1024, #if 0 /* Will be marked for real deprecation later. */ #define MHD_USE_PIPE_FOR_SHUTDOWN \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_USE_PIPE_FOR_SHUTDOWN is deprecated, use MHD_USE_ITC") \ MHD_USE_ITC #endif /* 0 */ /** * Use a single socket for IPv4 and IPv6. */ MHD_USE_DUAL_STACK = MHD_USE_IPv6 | 2048, /** * Enable `turbo`. Disables certain calls to `shutdown()`, * enables aggressive non-blocking optimistic reads and * other potentially unsafe optimizations. * Most effects only happen with #MHD_USE_EPOLL. */ MHD_USE_TURBO = 4096, /** @deprecated */ MHD_USE_EPOLL_TURBO = 4096, #if 0 /* Will be marked for real deprecation later. */ #define MHD_USE_EPOLL_TURBO \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_USE_EPOLL_TURBO is deprecated, use MHD_USE_TURBO") \ MHD_USE_TURBO #endif /* 0 */ /** * Enable suspend/resume functions, which also implies setting up * ITC to signal resume. */ MHD_ALLOW_SUSPEND_RESUME = 8192 | MHD_USE_ITC, /** @deprecated */ MHD_USE_SUSPEND_RESUME = 8192 | MHD_USE_ITC, #if 0 /* Will be marked for real deprecation later. */ #define MHD_USE_SUSPEND_RESUME \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_USE_SUSPEND_RESUME is deprecated, use MHD_ALLOW_SUSPEND_RESUME instead") \ MHD_ALLOW_SUSPEND_RESUME #endif /* 0 */ /** * Enable TCP_FASTOPEN option. This option is only available on Linux with a * kernel >= 3.6. On other systems, using this option cases #MHD_start_daemon * to fail. */ MHD_USE_TCP_FASTOPEN = 16384, /** * You need to set this option if you want to use HTTP "Upgrade". * "Upgrade" may require usage of additional internal resources, * which we do not want to use unless necessary. */ MHD_ALLOW_UPGRADE = 32768, /** * Automatically use best available polling function. * Choice of polling function is also depend on other daemon options. * If #MHD_USE_INTERNAL_POLLING_THREAD is specified then epoll, poll() or * select() will be used (listed in decreasing preference order, first * function available on system will be used). * If #MHD_USE_THREAD_PER_CONNECTION is specified then poll() or select() * will be used. * If those flags are not specified then epoll or select() will be * used (as the only suitable for MHD_get_fdset()) */ MHD_USE_AUTO = 65536, /** * Run using an internal thread (or thread pool) with best available on * system polling function. * This is combination of #MHD_USE_AUTO and #MHD_USE_INTERNAL_POLLING_THREAD * flags. */ MHD_USE_AUTO_INTERNAL_THREAD = MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, /** * Flag set to enable post-handshake client authentication * (only useful in combination with #MHD_USE_TLS). */ MHD_USE_POST_HANDSHAKE_AUTH_SUPPORT = 1U << 17, /** * Flag set to enable TLS 1.3 early data. This has * security implications, be VERY careful when using this. */ MHD_USE_INSECURE_TLS_EARLY_DATA = 1U << 18, /** * Indicates that MHD daemon will be used by application in single-threaded * mode only. When this flag is set then application must call any MHD * function only within a single thread. * This flag turns off some internal thread-safety and allows MHD making * some of the internal optimisations suitable only for single-threaded * environment. * Not compatible with #MHD_USE_INTERNAL_POLLING_THREAD. * @note Available since #MHD_VERSION 0x00097707 */ MHD_USE_NO_THREAD_SAFETY = 1U << 19 }; /** * Type of a callback function used for logging by MHD. * * @param cls closure * @param fm format string (`printf()`-style) * @param ap arguments to @a fm * @ingroup logging */ typedef void (*MHD_LogCallback)(void *cls, const char *fm, va_list ap); /** * Function called to lookup the pre shared key (@a psk) for a given * HTTP connection based on the @a username. * * @param cls closure * @param connection the HTTPS connection * @param username the user name claimed by the other side * @param[out] psk to be set to the pre-shared-key; should be allocated with malloc(), * will be freed by MHD * @param[out] psk_size to be set to the number of bytes in @a psk * @return 0 on success, -1 on errors */ typedef int (*MHD_PskServerCredentialsCallback)(void *cls, const struct MHD_Connection *connection, const char *username, void **psk, size_t *psk_size); /** * Values for #MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE. * * These values can limit the scope of validity of MHD-generated nonces. * Values can be combined with bitwise OR. * Any value, except #MHD_DAUTH_BIND_NONCE_NONE, enforce function * #MHD_digest_auth_check3() (and similar functions) to check nonce by * re-generating it again with the same parameters, which is CPU-intensive * operation. * @note Available since #MHD_VERSION 0x00097701 */ enum MHD_DAuthBindNonce { /** * Generated nonces are valid for any request from any client until expired. * This is default and recommended value. * #MHD_digest_auth_check3() (and similar functions) would check only whether * the nonce value that is used by client has been generated by MHD and not * expired yet. * It is recommended because RFC 7616 allows clients to use the same nonce * for any request in the same "protection space". * When checking client's authorisation requests CPU is loaded less if this * value is used. * This mode gives MHD maximum flexibility for nonces generation and can * prevent possible nonce collisions (and corresponding log warning messages) * when clients' requests are intensive. * This value cannot be biwise-OR combined with other values. */ MHD_DAUTH_BIND_NONCE_NONE = 0, /** * Generated nonces are valid only for the same realm. */ MHD_DAUTH_BIND_NONCE_REALM = 1 << 0, /** * Generated nonces are valid only for the same URI (excluding parameters * after '?' in URI) and request method (GET, POST etc). * Not recommended unless "protection space" is limited to a single URI as * RFC 7616 allows clients to re-use server-generated nonces for any URI * in the same "protection space" which by default consists of all server * URIs. * Before #MHD_VERSION 0x00097701 this was default (and only supported) * nonce bind type. */ MHD_DAUTH_BIND_NONCE_URI = 1 << 1, /** * Generated nonces are valid only for the same URI including URI parameters * and request method (GET, POST etc). * This value implies #MHD_DAUTH_BIND_NONCE_URI. * Not recommended for that same reasons as #MHD_DAUTH_BIND_NONCE_URI. */ MHD_DAUTH_BIND_NONCE_URI_PARAMS = 1 << 2, /** * Generated nonces are valid only for the single client's IP. * While it looks like security improvement, in practice the same client may * jump from one IP to another (mobile or Wi-Fi handover, DHCP re-assignment, * Multi-NAT, different proxy chain and other reasons), while IP address * spoofing could be used relatively easily. */ MHD_DAUTH_BIND_NONCE_CLIENT_IP = 1 << 3 } _MHD_FLAGS_ENUM; /** * @brief MHD options. * * Passed in the varargs portion of #MHD_start_daemon. */ enum MHD_OPTION { /** * No more options / last option. This is used * to terminate the VARARGs list. */ MHD_OPTION_END = 0, /** * Maximum memory size per connection (followed by a `size_t`). * Default is 32 kb (#MHD_POOL_SIZE_DEFAULT). * Values above 128k are unlikely to result in much benefit, as half * of the memory will be typically used for IO, and TCP buffers are * unlikely to support window sizes above 64k on most systems. * Values below 64 bytes are completely unusable. * Since #MHD_VERSION 0x00097710 silently ignored if followed by zero value. */ MHD_OPTION_CONNECTION_MEMORY_LIMIT = 1, /** * Maximum number of concurrent connections to * accept (followed by an `unsigned int`). */ MHD_OPTION_CONNECTION_LIMIT = 2, /** * After how many seconds of inactivity should a * connection automatically be timed out? (followed * by an `unsigned int`; use zero for no timeout). * Values larger than (UINT64_MAX / 2000 - 1) will * be clipped to this number. */ MHD_OPTION_CONNECTION_TIMEOUT = 3, /** * Register a function that should be called whenever a request has * been completed (this can be used for application-specific clean * up). Requests that have never been presented to the application * (via #MHD_AccessHandlerCallback) will not result in * notifications. * * This option should be followed by TWO pointers. First a pointer * to a function of type #MHD_RequestCompletedCallback and second a * pointer to a closure to pass to the request completed callback. * The second pointer may be NULL. */ MHD_OPTION_NOTIFY_COMPLETED = 4, /** * Limit on the number of (concurrent) connections made to the * server from the same IP address. Can be used to prevent one * IP from taking over all of the allowed connections. If the * same IP tries to establish more than the specified number of * connections, they will be immediately rejected. The option * should be followed by an `unsigned int`. The default is * zero, which means no limit on the number of connections * from the same IP address. */ MHD_OPTION_PER_IP_CONNECTION_LIMIT = 5, /** * Bind daemon to the supplied `struct sockaddr`. This option should * be followed by a `struct sockaddr *`. If #MHD_USE_IPv6 is * specified, the `struct sockaddr*` should point to a `struct * sockaddr_in6`, otherwise to a `struct sockaddr_in`. * Silently ignored if followed by NULL pointer. * @deprecated Use #MHD_OPTION_SOCK_ADDR_LEN */ MHD_OPTION_SOCK_ADDR = 6, /** * Specify a function that should be called before parsing the URI from * the client. The specified callback function can be used for processing * the URI (including the options) before it is parsed. The URI after * parsing will no longer contain the options, which maybe inconvenient for * logging. This option should be followed by two arguments, the first * one must be of the form * * void * my_logger(void *cls, const char *uri, struct MHD_Connection *con) * * where the return value will be passed as * (`* req_cls`) in calls to the #MHD_AccessHandlerCallback * when this request is processed later; returning a * value of NULL has no special significance (however, * note that if you return non-NULL, you can no longer * rely on the first call to the access handler having * `NULL == *req_cls` on entry;) * "cls" will be set to the second argument following * #MHD_OPTION_URI_LOG_CALLBACK. Finally, uri will * be the 0-terminated URI of the request. * * Note that during the time of this call, most of the connection's * state is not initialized (as we have not yet parsed the headers). * However, information about the connecting client (IP, socket) * is available. * * The specified function is called only once per request, therefore some * programmers may use it to instantiate their own request objects, freeing * them in the notifier #MHD_OPTION_NOTIFY_COMPLETED. */ MHD_OPTION_URI_LOG_CALLBACK = 7, /** * Memory pointer for the private key (key.pem) to be used by the * HTTPS daemon. This option should be followed by a * `const char *` argument. * This should be used in conjunction with #MHD_OPTION_HTTPS_MEM_CERT. */ MHD_OPTION_HTTPS_MEM_KEY = 8, /** * Memory pointer for the certificate (cert.pem) to be used by the * HTTPS daemon. This option should be followed by a * `const char *` argument. * This should be used in conjunction with #MHD_OPTION_HTTPS_MEM_KEY. */ MHD_OPTION_HTTPS_MEM_CERT = 9, /** * Daemon credentials type. * Followed by an argument of type * `gnutls_credentials_type_t`. */ MHD_OPTION_HTTPS_CRED_TYPE = 10, /** * Memory pointer to a `const char *` specifying the GnuTLS priorities string. * If this options is not specified, then MHD will try the following strings: * * "@LIBMICROHTTPD" (application-specific system-wide configuration) * * "@SYSTEM" (system-wide configuration) * * default GnuTLS priorities string * * "NORMAL" * The first configuration accepted by GnuTLS will be used. * For more details see GnuTLS documentation for "Application-specific * priority strings". */ MHD_OPTION_HTTPS_PRIORITIES = 11, /** * Pass a listen socket for MHD to use (systemd-style). If this * option is used, MHD will not open its own listen socket(s). The * argument passed must be of type `MHD_socket` and refer to an * existing socket that has been bound to a port and is listening. * If followed by MHD_INVALID_SOCKET value, MHD ignores this option * and creates socket by itself. */ MHD_OPTION_LISTEN_SOCKET = 12, /** * Use the given function for logging error messages. This option * must be followed by two arguments; the first must be a pointer to * a function of type #MHD_LogCallback and the second a pointer * `void *` which will be passed as the first argument to the log * callback. * Should be specified as the first option, otherwise some messages * may be printed by standard MHD logger during daemon startup. * * Note that MHD will not generate any log messages * if it was compiled without the "--enable-messages" * flag being set. */ MHD_OPTION_EXTERNAL_LOGGER = 13, /** * Number (`unsigned int`) of threads in thread pool. Enable * thread pooling by setting this value to to something * greater than 1. * Can be used only for daemons started with #MHD_USE_INTERNAL_POLLING_THREAD. * Ignored if followed by zero value. */ MHD_OPTION_THREAD_POOL_SIZE = 14, /** * Additional options given in an array of `struct MHD_OptionItem`. * The array must be terminated with an entry `{MHD_OPTION_END, 0, NULL}`. * An example for code using #MHD_OPTION_ARRAY is: * * struct MHD_OptionItem ops[] = { * { MHD_OPTION_CONNECTION_LIMIT, 100, NULL }, * { MHD_OPTION_CONNECTION_TIMEOUT, 10, NULL }, * { MHD_OPTION_END, 0, NULL } * }; * d = MHD_start_daemon (0, 8080, NULL, NULL, dh, NULL, * MHD_OPTION_ARRAY, ops, * MHD_OPTION_END); * * For options that expect a single pointer argument, the * 'value' member of the `struct MHD_OptionItem` is ignored. * For options that expect two pointer arguments, the first * argument must be cast to `intptr_t`. */ MHD_OPTION_ARRAY = 15, /** * Specify a function that should be called for unescaping escape * sequences in URIs and URI arguments. Note that this function * will NOT be used by the `struct MHD_PostProcessor`. If this * option is not specified, the default method will be used which * decodes escape sequences of the form "%HH". This option should * be followed by two arguments, the first one must be of the form * * size_t my_unescaper(void *cls, * struct MHD_Connection *c, * char *s) * * where the return value must be the length of the value left in * "s" (without the 0-terminator) and "s" should be updated. Note * that the unescape function must not lengthen "s" (the result must * be shorter than the input and must still be 0-terminated). * However, it may also include binary zeros before the * 0-termination. "cls" will be set to the second argument * following #MHD_OPTION_UNESCAPE_CALLBACK. */ MHD_OPTION_UNESCAPE_CALLBACK = 16, /** * Memory pointer for the random values to be used by the Digest * Auth module. This option should be followed by two arguments. * First an integer of type `size_t` which specifies the size * of the buffer pointed to by the second argument in bytes. * The recommended size is between 8 and 32. If size is four or less * then security could be lowered. Sizes more then 32 (or, probably * more than 16 - debatable) will not increase security. * Note that the application must ensure that the buffer of the * second argument remains allocated and unmodified while the * daemon is running. * @sa #MHD_OPTION_DIGEST_AUTH_RANDOM_COPY */ MHD_OPTION_DIGEST_AUTH_RANDOM = 17, /** * Size of the internal array holding the map of the nonce and * the nonce counter. This option should be followed by an `unsigend int` * argument. * The map size is 4 by default, which is enough to communicate with * a single client at any given moment of time, but not enough to * handle several clients simultaneously. * If Digest Auth is not used, this option can be set to zero to minimise * memory allocation. */ MHD_OPTION_NONCE_NC_SIZE = 18, /** * Desired size of the stack for threads created by MHD. Followed * by an argument of type `size_t`. Use 0 for system default. */ MHD_OPTION_THREAD_STACK_SIZE = 19, /** * Memory pointer for the certificate (ca.pem) to be used by the * HTTPS daemon for client authentication. * This option should be followed by a `const char *` argument. */ MHD_OPTION_HTTPS_MEM_TRUST = 20, /** * Increment to use for growing the read buffer (followed by a * `size_t`). * Must not be higher than 1/4 of #MHD_OPTION_CONNECTION_MEMORY_LIMIT. * Since #MHD_VERSION 0x00097710 silently ignored if followed by zero value. */ MHD_OPTION_CONNECTION_MEMORY_INCREMENT = 21, /** * Use a callback to determine which X.509 certificate should be * used for a given HTTPS connection. This option should be * followed by a argument of type `gnutls_certificate_retrieve_function2 *`. * This option provides an * alternative to #MHD_OPTION_HTTPS_MEM_KEY, * #MHD_OPTION_HTTPS_MEM_CERT. You must use this version if * multiple domains are to be hosted at the same IP address using * TLS's Server Name Indication (SNI) extension. In this case, * the callback is expected to select the correct certificate * based on the SNI information provided. The callback is expected * to access the SNI data using `gnutls_server_name_get()`. * Using this option requires GnuTLS 3.0 or higher. */ MHD_OPTION_HTTPS_CERT_CALLBACK = 22, /** * When using #MHD_USE_TCP_FASTOPEN, this option changes the default TCP * fastopen queue length of 50. Note that having a larger queue size can * cause resource exhaustion attack as the TCP stack has to now allocate * resources for the SYN packet along with its DATA. This option should be * followed by an `unsigned int` argument. */ MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE = 23, /** * Memory pointer for the Diffie-Hellman parameters (dh.pem) to be used by the * HTTPS daemon for key exchange. * This option must be followed by a `const char *` argument. */ MHD_OPTION_HTTPS_MEM_DHPARAMS = 24, /** * If present and set to true, allow reusing address:port socket * (by using SO_REUSEPORT on most platform, or platform-specific ways). * If present and set to false, disallow reusing address:port socket * (does nothing on most platform, but uses SO_EXCLUSIVEADDRUSE on Windows). * This option must be followed by a `unsigned int` argument. */ MHD_OPTION_LISTENING_ADDRESS_REUSE = 25, /** * Memory pointer for a password that decrypts the private key (key.pem) * to be used by the HTTPS daemon. This option should be followed by a * `const char *` argument. * This should be used in conjunction with #MHD_OPTION_HTTPS_MEM_KEY. * @sa ::MHD_FEATURE_HTTPS_KEY_PASSWORD */ MHD_OPTION_HTTPS_KEY_PASSWORD = 26, /** * Register a function that should be called whenever a connection is * started or closed. * * This option should be followed by TWO pointers. First a pointer * to a function of type #MHD_NotifyConnectionCallback and second a * pointer to a closure to pass to the request completed callback. * The second pointer may be NULL. */ MHD_OPTION_NOTIFY_CONNECTION = 27, /** * Allow to change maximum length of the queue of pending connections on * listen socket. If not present than default platform-specific SOMAXCONN * value is used. This option should be followed by an `unsigned int` * argument. */ MHD_OPTION_LISTEN_BACKLOG_SIZE = 28, /** * If set to 1 - be strict about the protocol. Use -1 to be * as tolerant as possible. * * The more flexible option #MHD_OPTION_CLIENT_DISCIPLINE_LVL is recommended * instead of this option. * * The values mapping table: * #MHD_OPTION_STRICT_FOR_CLIENT | #MHD_OPTION_CLIENT_DISCIPLINE_LVL * -----------------------------:|:--------------------------------- * 1 | 1 * 0 | 0 * -1 | -3 * * This option should be followed by an `int` argument. * @sa #MHD_OPTION_CLIENT_DISCIPLINE_LVL */ MHD_OPTION_STRICT_FOR_CLIENT = 29, /** * This should be a pointer to callback of type * gnutls_psk_server_credentials_function that will be given to * gnutls_psk_set_server_credentials_function. It is used to * retrieve the shared key for a given username. */ MHD_OPTION_GNUTLS_PSK_CRED_HANDLER = 30, /** * Use a callback to determine which X.509 certificate should be * used for a given HTTPS connection. This option should be * followed by a argument of type `gnutls_certificate_retrieve_function3 *`. * This option provides an * alternative/extension to #MHD_OPTION_HTTPS_CERT_CALLBACK. * You must use this version if you want to use OCSP stapling. * Using this option requires GnuTLS 3.6.3 or higher. */ MHD_OPTION_HTTPS_CERT_CALLBACK2 = 31, /** * Allows the application to disable certain sanity precautions * in MHD. With these, the client can break the HTTP protocol, * so this should never be used in production. The options are, * however, useful for testing HTTP clients against "broken" * server implementations. * This argument must be followed by an "unsigned int", corresponding * to an `enum MHD_DisableSanityCheck`. */ MHD_OPTION_SERVER_INSANITY = 32, /** * If followed by value '1' informs MHD that SIGPIPE is suppressed or * handled by application. Allows MHD to use network functions that could * generate SIGPIPE, like `sendfile()`. * Valid only for daemons without #MHD_USE_INTERNAL_POLLING_THREAD as * MHD automatically suppresses SIGPIPE for threads started by MHD. * This option should be followed by an `int` argument. * @note Available since #MHD_VERSION 0x00097205 */ MHD_OPTION_SIGPIPE_HANDLED_BY_APP = 33, /** * If followed by 'int' with value '1' disables usage of ALPN for TLS * connections even if supported by TLS library. * Valid only for daemons with #MHD_USE_TLS. * This option should be followed by an `int` argument. * @note Available since #MHD_VERSION 0x00097207 */ MHD_OPTION_TLS_NO_ALPN = 34, /** * Memory pointer for the random values to be used by the Digest * Auth module. This option should be followed by two arguments. * First an integer of type `size_t` which specifies the size * of the buffer pointed to by the second argument in bytes. * The recommended size is between 8 and 32. If size is four or less * then security could be lowered. Sizes more then 32 (or, probably * more than 16 - debatable) will not increase security. * An internal copy of the buffer will be made, the data do not * need to be static. * @sa #MHD_OPTION_DIGEST_AUTH_RANDOM * @note Available since #MHD_VERSION 0x00097701 */ MHD_OPTION_DIGEST_AUTH_RANDOM_COPY = 35, /** * Allow to controls the scope of validity of MHD-generated nonces. * This regulates how "nonces" are generated and how "nonces" are checked by * #MHD_digest_auth_check3() and similar functions. * This option should be followed by an 'unsigned int` argument with value * formed as bitwise OR combination of #MHD_DAuthBindNonce values. * When not specified, default value #MHD_DAUTH_BIND_NONCE_NONE is used. * @note Available since #MHD_VERSION 0x00097701 */ MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE = 36, /** * Memory pointer to a `const char *` specifying the GnuTLS priorities to be * appended to default priorities. * This allow some specific options to be enabled/disabled, while leaving * the rest of the settings to their defaults. * The string does not have to start with a colon ':' character. * See #MHD_OPTION_HTTPS_PRIORITIES description for details of automatic * default priorities. * @note Available since #MHD_VERSION 0x00097701 */ MHD_OPTION_HTTPS_PRIORITIES_APPEND = 37, /** * Sets specified client discipline level (i.e. HTTP protocol parsing * strictness level). * * The following basic values are supported: * 0 - default MHD level, a balance between extra security and broader * compatibility, as allowed by RFCs for HTTP servers; * 1 - more strict protocol interpretation, within the limits set by * RFCs for HTTP servers; * -1 - more lenient protocol interpretation, within the limits set by * RFCs for HTTP servers. * The following extended values could be used as well: * 2 - stricter protocol interpretation, even stricter then allowed * by RFCs for HTTP servers, however it should be absolutely compatible * with clients following at least RFCs' "MUST" type of requirements * for HTTP clients; * 3 - strictest protocol interpretation, even stricter then allowed * by RFCs for HTTP servers, however it should be absolutely compatible * with clients following RFCs' "SHOULD" and "MUST" types of requirements * for HTTP clients; * -2 - more relaxed protocol interpretation, violating RFCs' "SHOULD" type * of requirements for HTTP servers; * -3 - the most flexible protocol interpretation, beyond RFCs' "MUST" type of * requirements for HTTP server. * Values higher than "3" or lower than "-3" are interpreted as "3" or "-3" * respectively. * * Higher values are more secure, lower values are more compatible with * various HTTP clients. * * The default value ("0") could be used in most cases. * Value "1" is suitable for highly loaded public servers. * Values "2" and "3" are generally recommended only for testing of HTTP * clients against MHD. * Value "2" may be used for security-centric application, however it is * slight violation of RFCs' requirements. * Negative values are not recommended for public servers. * Values "-1" and "-2" could be used for servers in isolated environment. * Value "-3" is not recommended unless it is absolutely necessary to * communicate with some client(s) with badly broken HTTP implementation. * * This option should be followed by an `int` argument. * @note Available since #MHD_VERSION 0x00097701 */ MHD_OPTION_CLIENT_DISCIPLINE_LVL = 38, /** * Specifies value of FD_SETSIZE used by application. Only For external * polling modes (without MHD internal threads). * Some platforms (FreeBSD, Solaris, W32 etc.) allow overriding of FD_SETSIZE * value. When polling by select() is used, MHD rejects sockets with numbers * equal or higher than FD_SETSIZE. If this option is used, MHD treats this * value as a limitation for socket number instead of FD_SETSIZE value which * was used for building MHD. * When external polling is used with #MHD_get_fdset2() (or #MHD_get_fdset() * macro) and #MHD_run_from_select() interfaces, it is recommended to always * use this option. * It is safe to use this option on platforms with fixed FD_SETSIZE (like * GNU/Linux) if system value of FD_SETSIZE is used as the argument. * Can be used only for daemons without #MHD_USE_INTERNAL_POLLING_THREAD, i.e. * only when external sockets polling is used. * On W32 it is silently ignored, as W32 does not limit the socket number in * fd_sets. * This option should be followed by a positive 'int' argument. * @note Available since #MHD_VERSION 0x00097705 */ MHD_OPTION_APP_FD_SETSIZE = 39, /** * Bind daemon to the supplied 'struct sockaddr'. This option should * be followed by two parameters: 'socklen_t' the size of memory at the next * pointer and the pointer 'const struct sockaddr *'. * Note: the order of the arguments is not the same as for system bind() and * other network functions. * If #MHD_USE_IPv6 is specified, the 'struct sockaddr*' should * point to a 'struct sockaddr_in6'. * The socket domain (protocol family) is detected from provided * 'struct sockaddr'. IP, IPv6 and UNIX sockets are supported (if supported * by the platform). Other types may work occasionally. * Silently ignored if followed by zero size and NULL pointer. * @note Available since #MHD_VERSION 0x00097706 */ MHD_OPTION_SOCK_ADDR_LEN = 40 , /** * Default nonce timeout value used for Digest Auth. * This option should be followed by an 'unsigned int' argument. * Silently ignored if followed by zero value. * @see #MHD_digest_auth_check3(), MHD_digest_auth_check_digest3() * @note Available since #MHD_VERSION 0x00097709 */ MHD_OPTION_DIGEST_AUTH_DEFAULT_NONCE_TIMEOUT = 41 , /** * Default maximum nc (nonce count) value used for Digest Auth. * This option should be followed by an 'uint32_t' argument. * Silently ignored if followed by zero value. * @see #MHD_digest_auth_check3(), MHD_digest_auth_check_digest3() * @note Available since #MHD_VERSION 0x00097709 */ MHD_OPTION_DIGEST_AUTH_DEFAULT_MAX_NC = 42 } _MHD_FIXED_ENUM; /** * Bitfield for the #MHD_OPTION_SERVER_INSANITY specifying * which santiy checks should be disabled. */ enum MHD_DisableSanityCheck { /** * All sanity checks are enabled. */ MHD_DSC_SANE = 0 } _MHD_FIXED_FLAGS_ENUM; /** * Entry in an #MHD_OPTION_ARRAY. */ struct MHD_OptionItem { /** * Which option is being given. Use #MHD_OPTION_END * to terminate the array. */ enum MHD_OPTION option; /** * Option value (for integer arguments, and for options requiring * two pointer arguments); should be 0 for options that take no * arguments or only a single pointer argument. */ intptr_t value; /** * Pointer option value (use NULL for options taking no arguments * or only an integer option). */ void *ptr_value; }; /** * The `enum MHD_ValueKind` specifies the source of * the key-value pairs in the HTTP protocol. */ enum MHD_ValueKind { /** * Response header * @deprecated */ MHD_RESPONSE_HEADER_KIND = 0, #define MHD_RESPONSE_HEADER_KIND \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_RESPONSE_HEADER_KIND is deprecated and not used") \ MHD_RESPONSE_HEADER_KIND /** * HTTP header (request/response). */ MHD_HEADER_KIND = 1, /** * Cookies. Note that the original HTTP header containing * the cookie(s) will still be available and intact. */ MHD_COOKIE_KIND = 2, /** * POST data. This is available only if a content encoding * supported by MHD is used (currently only URL encoding), * and only if the posted content fits within the available * memory pool. Note that in that case, the upload data * given to the #MHD_AccessHandlerCallback will be * empty (since it has already been processed). */ MHD_POSTDATA_KIND = 4, /** * GET (URI) arguments. */ MHD_GET_ARGUMENT_KIND = 8, /** * HTTP footer (only for HTTP 1.1 chunked encodings). */ MHD_FOOTER_KIND = 16 } _MHD_FIXED_ENUM; /** * The `enum MHD_RequestTerminationCode` specifies reasons * why a request has been terminated (or completed). * @ingroup request */ enum MHD_RequestTerminationCode { /** * We finished sending the response. * @ingroup request */ MHD_REQUEST_TERMINATED_COMPLETED_OK = 0, /** * Error handling the connection (resources * exhausted, application error accepting request, * decrypt error (for HTTPS), connection died when * sending the response etc.) * @ingroup request */ MHD_REQUEST_TERMINATED_WITH_ERROR = 1, /** * No activity on the connection for the number * of seconds specified using * #MHD_OPTION_CONNECTION_TIMEOUT. * @ingroup request */ MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 2, /** * We had to close the session since MHD was being * shut down. * @ingroup request */ MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 3, /** * We tried to read additional data, but the connection became broken or * the other side hard closed the connection. * This error is similar to #MHD_REQUEST_TERMINATED_WITH_ERROR, but * specific to the case where the connection died before request completely * received. * @ingroup request */ MHD_REQUEST_TERMINATED_READ_ERROR = 4, /** * The client terminated the connection by closing the socket * for writing (TCP half-closed) while still sending request. * @ingroup request */ MHD_REQUEST_TERMINATED_CLIENT_ABORT = 5 } _MHD_FIXED_ENUM; /** * The `enum MHD_ConnectionNotificationCode` specifies types * of connection notifications. * @ingroup request */ enum MHD_ConnectionNotificationCode { /** * A new connection has been started. * @ingroup request */ MHD_CONNECTION_NOTIFY_STARTED = 0, /** * A connection is closed. * @ingroup request */ MHD_CONNECTION_NOTIFY_CLOSED = 1 } _MHD_FIXED_ENUM; /** * Information about a connection. */ union MHD_ConnectionInfo { /** * Cipher algorithm used, of type "enum gnutls_cipher_algorithm". */ int /* enum gnutls_cipher_algorithm */ cipher_algorithm; /** * Protocol used, of type "enum gnutls_protocol". */ int /* enum gnutls_protocol */ protocol; /** * The suspended status of a connection. */ int /* MHD_YES or MHD_NO */ suspended; /** * Amount of second that connection could spend in idle state * before automatically disconnected. * Zero for no timeout (unlimited idle time). */ unsigned int connection_timeout; /** * HTTP status queued with the response, for #MHD_CONNECTION_INFO_HTTP_STATUS. */ unsigned int http_status; /** * Connect socket */ MHD_socket connect_fd; /** * Size of the client's HTTP header. * It includes the request line, all request headers, the header section * terminating empty line, with all CRLF (or LF) characters. */ size_t header_size; /** * GNUtls session handle, of type "gnutls_session_t". */ void * /* gnutls_session_t */ tls_session; /** * GNUtls client certificate handle, of type "gnutls_x509_crt_t". */ void * /* gnutls_x509_crt_t */ client_cert; /** * Address information for the client. */ struct sockaddr *client_addr; /** * Which daemon manages this connection (useful in case there are many * daemons running). */ struct MHD_Daemon *daemon; /** * Socket-specific client context. Points to the same address as * the "socket_context" of the #MHD_NotifyConnectionCallback. */ void *socket_context; }; /** * I/O vector type. Provided for use with #MHD_create_response_from_iovec(). * @note Available since #MHD_VERSION 0x00097204 */ struct MHD_IoVec { /** * The pointer to the memory region for I/O. */ const void *iov_base; /** * The size in bytes of the memory region for I/O. */ size_t iov_len; }; /** * Values of this enum are used to specify what * information about a connection is desired. * @ingroup request */ enum MHD_ConnectionInfoType { /** * What cipher algorithm is being used. * Takes no extra arguments. * @ingroup request */ MHD_CONNECTION_INFO_CIPHER_ALGO, /** * * Takes no extra arguments. * @ingroup request */ MHD_CONNECTION_INFO_PROTOCOL, /** * Obtain IP address of the client. Takes no extra arguments. * Returns essentially a `struct sockaddr **` (since the API returns * a `union MHD_ConnectionInfo *` and that union contains a `struct * sockaddr *`). * @ingroup request */ MHD_CONNECTION_INFO_CLIENT_ADDRESS, /** * Get the gnuTLS session handle. * @ingroup request */ MHD_CONNECTION_INFO_GNUTLS_SESSION, /** * Get the gnuTLS client certificate handle. Dysfunctional (never * implemented, deprecated). Use #MHD_CONNECTION_INFO_GNUTLS_SESSION * to get the `gnutls_session_t` and then call * gnutls_certificate_get_peers(). */ MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT, /** * Get the `struct MHD_Daemon *` responsible for managing this connection. * @ingroup request */ MHD_CONNECTION_INFO_DAEMON, /** * Request the file descriptor for the connection socket. * MHD sockets are always in non-blocking mode. * No extra arguments should be passed. * @ingroup request */ MHD_CONNECTION_INFO_CONNECTION_FD, /** * Returns the client-specific pointer to a `void *` that was (possibly) * set during a #MHD_NotifyConnectionCallback when the socket was * first accepted. * Note that this is NOT the same as the "req_cls" argument of * the #MHD_AccessHandlerCallback. The "req_cls" is fresh for each * HTTP request, while the "socket_context" is fresh for each socket. */ MHD_CONNECTION_INFO_SOCKET_CONTEXT, /** * Check whether the connection is suspended. * @ingroup request */ MHD_CONNECTION_INFO_CONNECTION_SUSPENDED, /** * Get connection timeout * @ingroup request */ MHD_CONNECTION_INFO_CONNECTION_TIMEOUT, /** * Return length of the client's HTTP request header. * @ingroup request */ MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE, /** * Return HTTP status queued with the response. NULL * if no HTTP response has been queued yet. */ MHD_CONNECTION_INFO_HTTP_STATUS } _MHD_FIXED_ENUM; /** * Values of this enum are used to specify what * information about a daemon is desired. */ enum MHD_DaemonInfoType { /** * No longer supported (will return NULL). */ MHD_DAEMON_INFO_KEY_SIZE, /** * No longer supported (will return NULL). */ MHD_DAEMON_INFO_MAC_KEY_SIZE, /** * Request the file descriptor for the listening socket. * No extra arguments should be passed. */ MHD_DAEMON_INFO_LISTEN_FD, /** * Request the file descriptor for the "external" sockets polling * when 'epoll' mode is used. * No extra arguments should be passed. * * Waiting on epoll FD must not block longer than value * returned by #MHD_get_timeout() otherwise connections * will "hung" with unprocessed data in network buffers * and timed-out connections will not be closed. * * @sa #MHD_get_timeout(), #MHD_run() */ MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY, MHD_DAEMON_INFO_EPOLL_FD = MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY, /** * Request the number of current connections handled by the daemon. * No extra arguments should be passed. * Note: when using MHD in "external" polling mode, this type of request * could be used only when #MHD_run()/#MHD_run_from_select is not * working in other thread at the same time. */ MHD_DAEMON_INFO_CURRENT_CONNECTIONS, /** * Request the daemon flags. * No extra arguments should be passed. * Note: flags may differ from original 'flags' specified for * daemon, especially if #MHD_USE_AUTO was set. */ MHD_DAEMON_INFO_FLAGS, /** * Request the port number of daemon's listen socket. * No extra arguments should be passed. * Note: if port '0' was specified for #MHD_start_daemon(), returned * value will be real port number. */ MHD_DAEMON_INFO_BIND_PORT } _MHD_FIXED_ENUM; /** * Callback for serious error condition. The default action is to print * an error message and `abort()`. * * @param cls user specified value * @param file where the error occurred, may be NULL if MHD was built without * messages support * @param line where the error occurred * @param reason error detail, may be NULL * @ingroup logging */ typedef void (*MHD_PanicCallback) (void *cls, const char *file, unsigned int line, const char *reason); /** * Allow or deny a client to connect. * * @param cls closure * @param addr address information from the client * @param addrlen length of @a addr * @return #MHD_YES if connection is allowed, #MHD_NO if not */ typedef enum MHD_Result (*MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, socklen_t addrlen); /** * A client has requested the given @a url using the given @a method * (#MHD_HTTP_METHOD_GET, #MHD_HTTP_METHOD_PUT, #MHD_HTTP_METHOD_DELETE, * #MHD_HTTP_METHOD_POST, etc). * * The callback must call MHD function MHD_queue_response() to provide content * to give back to the client and return an HTTP status code (i.e. * #MHD_HTTP_OK, #MHD_HTTP_NOT_FOUND, etc.). The response can be created * in this callback or prepared in advance. * Alternatively, callback may call MHD_suspend_connection() to temporarily * suspend data processing for this connection. * * As soon as response is provided this callback will not be called anymore * for the current request. * * For each HTTP request this callback is called several times: * * after request headers are fully received and decoded, * * for each received part of request body (optional, if request has body), * * when request is fully received. * * If response is provided before request is fully received, the rest * of the request is discarded and connection is automatically closed * after sending response. * * If the request is fully received, but response hasn't been provided and * connection is not suspended, the callback can be called again immediately. * * The response cannot be queued when this callback is called to process * the client upload data (when @a upload_data is not NULL). * * @param cls argument given together with the function * pointer when the handler was registered with MHD * @param connection the connection handle * @param url the requested url * @param method the HTTP method used (#MHD_HTTP_METHOD_GET, * #MHD_HTTP_METHOD_PUT, etc.) * @param version the HTTP version string (i.e. * #MHD_HTTP_VERSION_1_1) * @param upload_data the data being uploaded (excluding HEADERS, * for a POST that fits into memory and that is encoded * with a supported encoding, the POST data will NOT be * given in upload_data and is instead available as * part of #MHD_get_connection_values; very large POST * data *will* be made available incrementally in * @a upload_data) * @param[in,out] upload_data_size set initially to the size of the * @a upload_data provided; the method must update this * value to the number of bytes NOT processed; * @param[in,out] req_cls pointer that the callback can set to some * address and that will be preserved by MHD for future * calls for this request; since the access handler may * be called many times (i.e., for a PUT/POST operation * with plenty of upload data) this allows the application * to easily associate some request-specific state. * If necessary, this state can be cleaned up in the * global #MHD_RequestCompletedCallback (which * can be set with the #MHD_OPTION_NOTIFY_COMPLETED). * Initially, `*req_cls` will be NULL. * @return #MHD_YES if the connection was handled successfully, * #MHD_NO if the socket must be closed due to a serious * error while handling the request * * @sa #MHD_queue_response() */ typedef enum MHD_Result (*MHD_AccessHandlerCallback)(void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls); /** * Signature of the callback used by MHD to notify the * application about completed requests. * * @param cls client-defined closure * @param connection connection handle * @param req_cls value as set by the last call to * the #MHD_AccessHandlerCallback * @param toe reason for request termination * @see #MHD_OPTION_NOTIFY_COMPLETED * @ingroup request */ typedef void (*MHD_RequestCompletedCallback) (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe); /** * Signature of the callback used by MHD to notify the * application about started/stopped connections * * @param cls client-defined closure * @param connection connection handle * @param socket_context socket-specific pointer where the * client can associate some state specific * to the TCP connection; note that this is * different from the "req_cls" which is per * HTTP request. The client can initialize * during #MHD_CONNECTION_NOTIFY_STARTED and * cleanup during #MHD_CONNECTION_NOTIFY_CLOSED * and access in the meantime using * #MHD_CONNECTION_INFO_SOCKET_CONTEXT. * @param toe reason for connection notification * @see #MHD_OPTION_NOTIFY_CONNECTION * @ingroup request */ typedef void (*MHD_NotifyConnectionCallback) (void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe); /** * Iterator over key-value pairs. This iterator * can be used to iterate over all of the cookies, * headers, or POST-data fields of a request, and * also to iterate over the headers that have been * added to a response. * * @param cls closure * @param kind kind of the header we are looking at * @param key key for the value, can be an empty string * @param value corresponding value, can be NULL * @return #MHD_YES to continue iterating, * #MHD_NO to abort the iteration * @ingroup request */ typedef enum MHD_Result (*MHD_KeyValueIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *value); /** * Iterator over key-value pairs with size parameters. * This iterator can be used to iterate over all of * the cookies, headers, or POST-data fields of a * request, and also to iterate over the headers that * have been added to a response. * @note Available since #MHD_VERSION 0x00096303 * * @param cls closure * @param kind kind of the header we are looking at * @param key key for the value, can be an empty string * @param value corresponding value, can be NULL * @param value_size number of bytes in @a value; * for C-strings, the length excludes the 0-terminator * @return #MHD_YES to continue iterating, * #MHD_NO to abort the iteration * @ingroup request */ typedef enum MHD_Result (*MHD_KeyValueIteratorN)(void *cls, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size); /** * Callback used by libmicrohttpd in order to obtain content. * * The callback is to copy at most @a max bytes of content into @a buf. * The total number of bytes that has been placed into @a buf should be * returned. * * Note that returning zero will cause libmicrohttpd to try again. * Thus, returning zero should only be used in conjunction * with MHD_suspend_connection() to avoid busy waiting. * * @param cls extra argument to the callback * @param pos position in the datastream to access; * note that if a `struct MHD_Response` object is re-used, * it is possible for the same content reader to * be queried multiple times for the same data; * however, if a `struct MHD_Response` is not re-used, * libmicrohttpd guarantees that "pos" will be * the sum of all non-negative return values * obtained from the content reader so far. * @param buf where to copy the data * @param max maximum number of bytes to copy to @a buf (size of @a buf) * @return number of bytes written to @a buf; * 0 is legal unless MHD is started in "internal" sockets polling mode * (since this would cause busy-waiting); 0 in "external" sockets * polling mode will cause this function to be called again once * any MHD_run*() function is called; * #MHD_CONTENT_READER_END_OF_STREAM (-1) for the regular * end of transmission (with chunked encoding, MHD will then * terminate the chunk and send any HTTP footers that might be * present; without chunked encoding and given an unknown * response size, MHD will simply close the connection; note * that while returning #MHD_CONTENT_READER_END_OF_STREAM is not technically * legal if a response size was specified, MHD accepts this * and treats it just as #MHD_CONTENT_READER_END_WITH_ERROR; * #MHD_CONTENT_READER_END_WITH_ERROR (-2) to indicate a server * error generating the response; this will cause MHD to simply * close the connection immediately. If a response size was * given or if chunked encoding is in use, this will indicate * an error to the client. Note, however, that if the client * does not know a response size and chunked encoding is not in * use, then clients will not be able to tell the difference between * #MHD_CONTENT_READER_END_WITH_ERROR and #MHD_CONTENT_READER_END_OF_STREAM. * This is not a limitation of MHD but rather of the HTTP protocol. */ typedef ssize_t (*MHD_ContentReaderCallback) (void *cls, uint64_t pos, char *buf, size_t max); /** * This method is called by libmicrohttpd if we * are done with a content reader. It should * be used to free resources associated with the * content reader. * * @param cls closure * @ingroup response */ typedef void (*MHD_ContentReaderFreeCallback) (void *cls); /** * Iterator over key-value pairs where the value * may be made available in increments and/or may * not be zero-terminated. Used for processing * POST data. * * @param cls user-specified closure * @param kind type of the value, always #MHD_POSTDATA_KIND when called from MHD * @param key 0-terminated key for the value, NULL if not known. This value * is never NULL for url-encoded POST data. * @param filename name of the uploaded file, NULL if not known * @param content_type mime-type of the data, NULL if not known * @param transfer_encoding encoding of the data, NULL if not known * @param data pointer to @a size bytes of data at the * specified offset * @param off offset of data in the overall value * @param size number of bytes in @a data available * @return #MHD_YES to continue iterating, * #MHD_NO to abort the iteration */ typedef enum MHD_Result (*MHD_PostDataIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size); /* **************** Daemon handling functions ***************** */ /** * Start a webserver on the given port. * * @param flags combination of `enum MHD_FLAG` values * @param port port to bind to (in host byte order), * use '0' to bind to random free port, * ignored if MHD_OPTION_SOCK_ADDR or * MHD_OPTION_LISTEN_SOCKET is provided * or MHD_USE_NO_LISTEN_SOCKET is specified * @param apc callback to call to check which clients * will be allowed to connect; you can pass NULL * in which case connections from any IP will be * accepted * @param apc_cls extra argument to apc * @param dh handler called for all requests (repeatedly) * @param dh_cls extra argument to @a dh * @param ap list of options (type-value pairs, * terminated with #MHD_OPTION_END). * @return NULL on error, handle to daemon on success * @ingroup event */ _MHD_EXTERN struct MHD_Daemon * MHD_start_daemon_va (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, va_list ap); /** * Start a webserver on the given port. Variadic version of * #MHD_start_daemon_va. * * @param flags combination of `enum MHD_FLAG` values * @param port port to bind to (in host byte order), * use '0' to bind to random free port, * ignored if MHD_OPTION_SOCK_ADDR or * MHD_OPTION_LISTEN_SOCKET is provided * or MHD_USE_NO_LISTEN_SOCKET is specified * @param apc callback to call to check which clients * will be allowed to connect; you can pass NULL * in which case connections from any IP will be * accepted * @param apc_cls extra argument to apc * @param dh handler called for all requests (repeatedly) * @param dh_cls extra argument to @a dh * @return NULL on error, handle to daemon on success * @ingroup event */ _MHD_EXTERN struct MHD_Daemon * MHD_start_daemon (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, ...); /** * Stop accepting connections from the listening socket. Allows * clients to continue processing, but stops accepting new * connections. Note that the caller is responsible for closing the * returned socket; however, if MHD is run using threads (anything but * "external" sockets polling mode), it must not be closed until AFTER * #MHD_stop_daemon has been called (as it is theoretically possible * that an existing thread is still using it). * * Note that some thread modes require the caller to have passed * #MHD_USE_ITC when using this API. If this daemon is * in one of those modes and this option was not given to * #MHD_start_daemon, this function will return #MHD_INVALID_SOCKET. * * @param daemon daemon to stop accepting new connections for * @return old listen socket on success, #MHD_INVALID_SOCKET if * the daemon was already not listening anymore * @ingroup specialized */ _MHD_EXTERN MHD_socket MHD_quiesce_daemon (struct MHD_Daemon *daemon); /** * Shutdown an HTTP daemon. * * @param daemon daemon to stop * @ingroup event */ _MHD_EXTERN void MHD_stop_daemon (struct MHD_Daemon *daemon); /** * Add another client connection to the set of connections managed by * MHD. This API is usually not needed (since MHD will accept inbound * connections on the server socket). Use this API in special cases, * for example if your HTTP server is behind NAT and needs to connect * out to the HTTP client, or if you are building a proxy. * * If you use this API in conjunction with an "internal" socket polling, * you must set the option #MHD_USE_ITC to ensure that the freshly added * connection is immediately processed by MHD. * * The given client socket will be managed (and closed!) by MHD after * this call and must no longer be used directly by the application * afterwards. * * @param daemon daemon that manages the connection * @param client_socket socket to manage (MHD will expect * to receive an HTTP request from this socket next). * @param addr IP address of the client * @param addrlen number of bytes in @a addr * @return #MHD_YES on success, #MHD_NO if this daemon could * not handle the connection (i.e. `malloc()` failed, etc). * The socket will be closed in any case; `errno` is * set to indicate further details about the error. * @ingroup specialized */ _MHD_EXTERN enum MHD_Result MHD_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen); /** * Obtain the `select()` sets for this daemon. * Daemon's FDs will be added to fd_sets. To get only * daemon FDs in fd_sets, call FD_ZERO for each fd_set * before calling this function. FD_SETSIZE is assumed * to be platform's default. * * This function should be called only when MHD is configured to * use "external" sockets polling with 'select()' or with 'epoll'. * In the latter case, it will only add the single 'epoll' file * descriptor used by MHD to the sets. * It's necessary to use #MHD_get_timeout() to get maximum timeout * value for `select()`. Usage of `select()` with indefinite timeout * (or timeout larger than returned by #MHD_get_timeout()) will * violate MHD API and may results in pending unprocessed data. * * This function must be called only for daemon started * without #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @return #MHD_YES on success, #MHD_NO if this * daemon was not started with the right * options for this call or any FD didn't * fit fd_set. * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_get_fdset (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd); /** * Obtain the `select()` sets for this daemon. * Daemon's FDs will be added to fd_sets. To get only * daemon FDs in fd_sets, call FD_ZERO for each fd_set * before calling this function. * * Passing custom FD_SETSIZE as @a fd_setsize allow usage of * larger/smaller than platform's default fd_sets. * * This function should be called only when MHD is configured to * use "external" sockets polling with 'select()' or with 'epoll'. * In the latter case, it will only add the single 'epoll' file * descriptor used by MHD to the sets. * It's necessary to use #MHD_get_timeout() to get maximum timeout * value for `select()`. Usage of `select()` with indefinite timeout * (or timeout larger than returned by #MHD_get_timeout()) will * violate MHD API and may results in pending unprocessed data. * * This function must be called only for daemon started * without #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @param fd_setsize value of FD_SETSIZE * @return #MHD_YES on success, #MHD_NO if this * daemon was not started with the right * options for this call or any FD didn't * fit fd_set. * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_get_fdset2 (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize); /** * Obtain the `select()` sets for this daemon. * Daemon's FDs will be added to fd_sets. To get only * daemon FDs in fd_sets, call FD_ZERO for each fd_set * before calling this function. Size of fd_set is * determined by current value of FD_SETSIZE. * * This function should be called only when MHD is configured to * use "external" sockets polling with 'select()' or with 'epoll'. * In the latter case, it will only add the single 'epoll' file * descriptor used by MHD to the sets. * It's necessary to use #MHD_get_timeout() to get maximum timeout * value for `select()`. Usage of `select()` with indefinite timeout * (or timeout larger than returned by #MHD_get_timeout()) will * violate MHD API and may results in pending unprocessed data. * * This function must be called only for daemon started * without #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @return #MHD_YES on success, #MHD_NO if this * daemon was not started with the right * options for this call or any FD didn't * fit fd_set. * @ingroup event */ #define MHD_get_fdset(daemon,read_fd_set,write_fd_set,except_fd_set,max_fd) \ MHD_get_fdset2 ((daemon),(read_fd_set),(write_fd_set),(except_fd_set), \ (max_fd),FD_SETSIZE) /** * Obtain timeout value for polling function for this daemon. * * This function set value to the amount of milliseconds for which polling * function (`select()`, `poll()` or epoll) should at most block, not the * timeout value set for connections. * * Any "external" sockets polling function must be called with the timeout * value provided by this function. Smaller timeout values can be used for * polling function if it is required for any reason, but using larger * timeout value or no timeout (indefinite timeout) when this function * return #MHD_YES will break MHD processing logic and result in "hung" * connections with data pending in network buffers and other problems. * * It is important to always use this function (or #MHD_get_timeout64(), * #MHD_get_timeout64s(), #MHD_get_timeout_i() functions) when "external" * polling is used. * If this function returns #MHD_YES then #MHD_run() (or #MHD_run_from_select()) * must be called right after return from polling function, regardless of * the states of MHD FDs. * * In practice, if #MHD_YES is returned then #MHD_run() (or * #MHD_run_from_select()) must be called not later than @a timeout * millisecond even if no activity is detected on sockets by sockets * polling function. * * @param daemon daemon to query for timeout * @param[out] timeout set to the timeout (in milliseconds) * @return #MHD_YES on success, #MHD_NO if timeouts are * not used and no data processing is pending. * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_get_timeout (struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout); /** * Free the memory allocated by MHD. * * If any MHD function explicitly mentions that returned pointer must be * freed by this function, then no other method must be used to free * the memory. * * @param ptr the pointer to free. * @sa #MHD_digest_auth_get_username(), #MHD_basic_auth_get_username_password3() * @sa #MHD_basic_auth_get_username_password() * @note Available since #MHD_VERSION 0x00095600 * @ingroup specialized */ _MHD_EXTERN void MHD_free (void *ptr); /** * Obtain timeout value for external polling function for this daemon. * * This function set value to the amount of milliseconds for which polling * function (`select()`, `poll()` or epoll) should at most block, not the * timeout value set for connections. * * Any "external" sockets polling function must be called with the timeout * value provided by this function. Smaller timeout values can be used for * polling function if it is required for any reason, but using larger * timeout value or no timeout (indefinite timeout) when this function * return #MHD_YES will break MHD processing logic and result in "hung" * connections with data pending in network buffers and other problems. * * It is important to always use this function (or #MHD_get_timeout(), * #MHD_get_timeout64s(), #MHD_get_timeout_i() functions) when "external" * polling is used. * If this function returns #MHD_YES then #MHD_run() (or #MHD_run_from_select()) * must be called right after return from polling function, regardless of * the states of MHD FDs. * * In practice, if #MHD_YES is returned then #MHD_run() (or * #MHD_run_from_select()) must be called not later than @a timeout * millisecond even if no activity is detected on sockets by sockets * polling function. * * @param daemon daemon to query for timeout * @param[out] timeout64 the pointer to the variable to be set to the * timeout (in milliseconds) * @return #MHD_YES if timeout value has been set, * #MHD_NO if timeouts are not used and no data processing is pending. * @note Available since #MHD_VERSION 0x00097701 * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_get_timeout64 (struct MHD_Daemon *daemon, uint64_t *timeout); /** * Obtain timeout value for external polling function for this daemon. * * This function set value to the amount of milliseconds for which polling * function (`select()`, `poll()` or epoll) should at most block, not the * timeout value set for connections. * * Any "external" sockets polling function must be called with the timeout * value provided by this function (if returned value is non-negative). * Smaller timeout values can be used for polling function if it is required * for any reason, but using larger timeout value or no timeout (indefinite * timeout) when this function returns non-negative value will break MHD * processing logic and result in "hung" connections with data pending in * network buffers and other problems. * * It is important to always use this function (or #MHD_get_timeout(), * #MHD_get_timeout64(), #MHD_get_timeout_i() functions) when "external" * polling is used. * If this function returns non-negative value then #MHD_run() (or * #MHD_run_from_select()) must be called right after return from polling * function, regardless of the states of MHD FDs. * * In practice, if zero or positive value is returned then #MHD_run() (or * #MHD_run_from_select()) must be called not later than returned amount of * millisecond even if no activity is detected on sockets by sockets * polling function. * * @param daemon the daemon to query for timeout * @return -1 if connections' timeouts are not set and no data processing * is pending, so external polling function may wait for sockets * activity for indefinite amount of time, * otherwise returned value is the the maximum amount of millisecond * that external polling function must wait for the activity of FDs. * @note Available since #MHD_VERSION 0x00097701 * @ingroup event */ _MHD_EXTERN int64_t MHD_get_timeout64s (struct MHD_Daemon *daemon); /** * Obtain timeout value for external polling function for this daemon. * * This function set value to the amount of milliseconds for which polling * function (`select()`, `poll()` or epoll) should at most block, not the * timeout value set for connections. * * Any "external" sockets polling function must be called with the timeout * value provided by this function (if returned value is non-negative). * Smaller timeout values can be used for polling function if it is required * for any reason, but using larger timeout value or no timeout (indefinite * timeout) when this function returns non-negative value will break MHD * processing logic and result in "hung" connections with data pending in * network buffers and other problems. * * It is important to always use this function (or #MHD_get_timeout(), * #MHD_get_timeout64(), #MHD_get_timeout64s() functions) when "external" * polling is used. * If this function returns non-negative value then #MHD_run() (or * #MHD_run_from_select()) must be called right after return from polling * function, regardless of the states of MHD FDs. * * In practice, if zero or positive value is returned then #MHD_run() (or * #MHD_run_from_select()) must be called not later than returned amount of * millisecond even if no activity is detected on sockets by sockets * polling function. * * @param daemon the daemon to query for timeout * @return -1 if connections' timeouts are not set and no data processing * is pending, so external polling function may wait for sockets * activity for indefinite amount of time, * otherwise returned value is the the maximum amount of millisecond * (capped at INT_MAX) that external polling function must wait * for the activity of FDs. * @note Available since #MHD_VERSION 0x00097701 * @ingroup event */ _MHD_EXTERN int MHD_get_timeout_i (struct MHD_Daemon *daemon); /** * Run webserver operations (without blocking unless in client callbacks). * * This method should be called by clients in combination with * #MHD_get_fdset() (or #MHD_get_daemon_info() with MHD_DAEMON_INFO_EPOLL_FD * if epoll is used) and #MHD_get_timeout() if the client-controlled * connection polling method is used (i.e. daemon was started without * #MHD_USE_INTERNAL_POLLING_THREAD flag). * * This function is a convenience method, which is useful if the * fd_sets from #MHD_get_fdset were not directly passed to `select()`; * with this function, MHD will internally do the appropriate `select()` * call itself again. While it is acceptable to call #MHD_run (if * #MHD_USE_INTERNAL_POLLING_THREAD is not set) at any moment, you should * call #MHD_run_from_select() if performance is important (as it saves an * expensive call to `select()`). * * If #MHD_get_timeout() returned #MHD_YES, than this function must be called * right after polling function returns regardless of detected activity on * the daemon's FDs. * * @param daemon daemon to run * @return #MHD_YES on success, #MHD_NO if this * daemon was not started with the right * options for this call. * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_run (struct MHD_Daemon *daemon); /** * Run websever operation with possible blocking. * * This function does the following: waits for any network event not more than * specified number of milliseconds, processes all incoming and outgoing data, * processes new connections, processes any timed-out connection, and does * other things required to run webserver. * Once all connections are processed, function returns. * * This function is useful for quick and simple (lazy) webserver implementation * if application needs to run a single thread only and does not have any other * network activity. * * This function calls MHD_get_timeout() internally and use returned value as * maximum wait time if it less than value of @a millisec parameter. * * It is expected that the "external" socket polling function is not used in * conjunction with this function unless the @a millisec is set to zero. * * @param daemon the daemon to run * @param millisec the maximum time in milliseconds to wait for network and * other events. Note: there is no guarantee that function * blocks for the specified amount of time. The real processing * time can be shorter (if some data or connection timeout * comes earlier) or longer (if data processing requires more * time, especially in user callbacks). * If set to '0' then function does not block and processes * only already available data (if any). * If set to '-1' then function waits for events * indefinitely (blocks until next network activity or * connection timeout). * @return #MHD_YES on success, #MHD_NO if this * daemon was not started with the right * options for this call or some serious * unrecoverable error occurs. * @note Available since #MHD_VERSION 0x00097206 * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_run_wait (struct MHD_Daemon *daemon, int32_t millisec); /** * Run webserver operations. This method should be called by clients * in combination with #MHD_get_fdset and #MHD_get_timeout() if the * client-controlled select method is used. * * You can use this function instead of #MHD_run if you called * `select()` on the result from #MHD_get_fdset. File descriptors in * the sets that are not controlled by MHD will be ignored. Calling * this function instead of #MHD_run is more efficient as MHD will * not have to call `select()` again to determine which operations are * ready. * * If #MHD_get_timeout() returned #MHD_YES, than this function must be * called right after `select()` returns regardless of detected activity * on the daemon's FDs. * * This function cannot be used with daemon started with * #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to run select loop for * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @return #MHD_NO on serious errors, #MHD_YES on success * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set); /** * Run webserver operations. This method should be called by clients * in combination with #MHD_get_fdset and #MHD_get_timeout() if the * client-controlled select method is used. * This function specifies FD_SETSIZE used when provided fd_sets were * created. It is important on platforms where FD_SETSIZE can be * overridden. * * You can use this function instead of #MHD_run if you called * 'select()' on the result from #MHD_get_fdset2(). File descriptors in * the sets that are not controlled by MHD will be ignored. Calling * this function instead of #MHD_run() is more efficient as MHD will * not have to call 'select()' again to determine which operations are * ready. * * If #MHD_get_timeout() returned #MHD_YES, than this function must be * called right after 'select()' returns regardless of detected activity * on the daemon's FDs. * * This function cannot be used with daemon started with * #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon the daemon to run select loop for * @param read_fd_set the read set * @param write_fd_set the write set * @param except_fd_set the except set * @param fd_setsize the value of FD_SETSIZE * @return #MHD_NO on serious errors, #MHD_YES on success * @sa #MHD_get_fdset2(), #MHD_OPTION_APP_FD_SETSIZE * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_run_from_select2 (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set, unsigned int fd_setsize); /** * Run webserver operations. This method should be called by clients * in combination with #MHD_get_fdset and #MHD_get_timeout() if the * client-controlled select method is used. * This macro automatically substitutes current FD_SETSIZE value. * It is important on platforms where FD_SETSIZE can be overridden. * * You can use this function instead of #MHD_run if you called * 'select()' on the result from #MHD_get_fdset2(). File descriptors in * the sets that are not controlled by MHD will be ignored. Calling * this function instead of #MHD_run() is more efficient as MHD will * not have to call 'select()' again to determine which operations are * ready. * * If #MHD_get_timeout() returned #MHD_YES, than this function must be * called right after 'select()' returns regardless of detected activity * on the daemon's FDs. * * This function cannot be used with daemon started with * #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon the daemon to run select loop for * @param read_fd_set the read set * @param write_fd_set the write set * @param except_fd_set the except set * @param fd_setsize the value of FD_SETSIZE * @return #MHD_NO on serious errors, #MHD_YES on success * @sa #MHD_get_fdset2(), #MHD_OPTION_APP_FD_SETSIZE * @ingroup event */ #define MHD_run_from_select(d,r,w,e) \ MHD_run_from_select2((d),(r),(w),(e),(unsigned int)(FD_SETSIZE)) /* **************** Connection handling functions ***************** */ /** * Get all of the headers from the request. * * @param connection connection to get values from * @param kind types of values to iterate over, can be a bitmask * @param iterator callback to call on each header; * may be NULL (then just count headers) * @param iterator_cls extra argument to @a iterator * @return number of entries iterated over, * -1 if connection is NULL. * @ingroup request */ _MHD_EXTERN int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls); /** * Get all of the headers from the request. * * @param connection connection to get values from * @param kind types of values to iterate over, can be a bitmask * @param iterator callback to call on each header; * may be NULL (then just count headers) * @param iterator_cls extra argument to @a iterator * @return number of entries iterated over, * -1 if connection is NULL. * @note Available since #MHD_VERSION 0x00096400 * @ingroup request */ _MHD_EXTERN int MHD_get_connection_values_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIteratorN iterator, void *iterator_cls); /** * This function can be used to add an entry to the HTTP headers of a * connection (so that the #MHD_get_connection_values function will * return them -- and the `struct MHD_PostProcessor` will also see * them). This maybe required in certain situations (see Mantis * #1399) where (broken) HTTP implementations fail to supply values * needed by the post processor (or other parts of the application). * * This function MUST only be called from within the * #MHD_AccessHandlerCallback (otherwise, access maybe improperly * synchronized). Furthermore, the client must guarantee that the key * and value arguments are 0-terminated strings that are NOT freed * until the connection is closed. (The easiest way to do this is by * passing only arguments to permanently allocated strings.). * * @param connection the connection for which a * value should be set * @param kind kind of the value * @param key key for the value * @param value the value itself * @return #MHD_NO if the operation could not be * performed due to insufficient memory; * #MHD_YES on success * @ingroup request */ _MHD_EXTERN enum MHD_Result MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value); /** * This function can be used to add an arbitrary entry to connection. * This function could add entry with binary zero, which is allowed * for #MHD_GET_ARGUMENT_KIND. For other kind on entries it is * recommended to use #MHD_set_connection_value. * * This function MUST only be called from within the * #MHD_AccessHandlerCallback (otherwise, access maybe improperly * synchronized). Furthermore, the client must guarantee that the key * and value arguments are 0-terminated strings that are NOT freed * until the connection is closed. (The easiest way to do this is by * passing only arguments to permanently allocated strings.). * * @param connection the connection for which a * value should be set * @param kind kind of the value * @param key key for the value, must be zero-terminated * @param key_size number of bytes in @a key (excluding 0-terminator) * @param value the value itself, must be zero-terminated * @param value_size number of bytes in @a value (excluding 0-terminator) * @return #MHD_NO if the operation could not be * performed due to insufficient memory; * #MHD_YES on success * @note Available since #MHD_VERSION 0x00096400 * @ingroup request */ _MHD_EXTERN enum MHD_Result MHD_set_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size); /** * Sets the global error handler to a different implementation. * * @a cb will only be called in the case of typically fatal, serious internal * consistency issues or serious system failures like failed lock of mutex. * * These issues should only arise in the case of serious memory corruption or * similar problems with the architecture, there is no safe way to continue * even for closing of the application. * * The default implementation that is used if no panic function is set simply * prints an error message and calls `abort()`. * Alternative implementations might call `exit()` or other similar functions. * * @param cb new error handler or NULL to use default handler * @param cls passed to @a cb * @ingroup logging */ _MHD_EXTERN void MHD_set_panic_func (MHD_PanicCallback cb, void *cls); /** * Process escape sequences ('%HH') Updates val in place; the * result cannot be larger than the input. * The result is still be 0-terminated. * * @param val value to unescape (modified in the process) * @return length of the resulting val (`strlen(val)` may be * shorter afterwards due to elimination of escape sequences) */ _MHD_EXTERN size_t MHD_http_unescape (char *val); /** * Get a particular header value. If multiple * values match the kind, return any one of them. * * @param connection connection to get values from * @param kind what kind of value are we looking for * @param key the header to look for, NULL to lookup 'trailing' value without a key * @return NULL if no such item was found * @ingroup request */ _MHD_EXTERN const char * MHD_lookup_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key); /** * Get a particular header value. If multiple * values match the kind, return any one of them. * @note Since MHD_VERSION 0x00096304 * * @param connection connection to get values from * @param kind what kind of value are we looking for * @param key the header to look for, NULL to lookup 'trailing' value without a key * @param key_size the length of @a key in bytes * @param[out] value_ptr the pointer to variable, which will be set to found value, * will not be updated if key not found, * could be NULL to just check for presence of @a key * @param[out] value_size_ptr the pointer variable, which will set to found value, * will not be updated if key not found, * could be NULL * @return #MHD_YES if key is found, * #MHD_NO otherwise. * @ingroup request */ _MHD_EXTERN enum MHD_Result MHD_lookup_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr); /** * Queue a response to be transmitted to the client (as soon as * possible but after #MHD_AccessHandlerCallback returns). * * For any active connection this function must be called * only by #MHD_AccessHandlerCallback callback. * * For suspended connection this function can be called at any moment (this * behaviour is deprecated and will be removed!). Response will be sent * as soon as connection is resumed. * * For single thread environment, when MHD is used in "external polling" mode * (without MHD_USE_SELECT_INTERNALLY) this function can be called any * time (this behaviour is deprecated and will be removed!). * * If HTTP specifications require use no body in reply, like @a status_code with * value 1xx, the response body is automatically not sent even if it is present * in the response. No "Content-Length" or "Transfer-Encoding" headers are * generated and added. * * When the response is used to respond HEAD request or used with @a status_code * #MHD_HTTP_NOT_MODIFIED, then response body is not sent, but "Content-Length" * header is added automatically based the size of the body in the response. * If body size it set to #MHD_SIZE_UNKNOWN or chunked encoding is enforced * then "Transfer-Encoding: chunked" header (for HTTP/1.1 only) is added instead * of "Content-Length" header. For example, if response with zero-size body is * used for HEAD request, then "Content-Length: 0" is added automatically to * reply headers. * @sa #MHD_RF_HEAD_ONLY_RESPONSE * * In situations, where reply body is required, like answer for the GET request * with @a status_code #MHD_HTTP_OK, headers "Content-Length" (for known body * size) or "Transfer-Encoding: chunked" (for #MHD_SIZE_UNKNOWN with HTTP/1.1) * are added automatically. * In practice, the same response object can be used to respond to both HEAD and * GET requests. * * @param connection the connection identifying the client * @param status_code HTTP status code (i.e. #MHD_HTTP_OK) * @param response response to transmit, the NULL is tolerated * @return #MHD_NO on error (reply already sent, response is NULL), * #MHD_YES on success or if message has been queued * @ingroup response * @sa #MHD_AccessHandlerCallback */ _MHD_EXTERN enum MHD_Result MHD_queue_response (struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response); /** * Suspend handling of network data for a given connection. * This can be used to dequeue a connection from MHD's event loop * (not applicable to thread-per-connection!) for a while. * * If you use this API in conjunction with an "internal" socket polling, * you must set the option #MHD_USE_ITC to ensure that a resumed * connection is immediately processed by MHD. * * Suspended connections continue to count against the total number of * connections allowed (per daemon, as well as per IP, if such limits * are set). Suspended connections will NOT time out; timeouts will * restart when the connection handling is resumed. While a * connection is suspended, MHD will not detect disconnects by the * client. * * The only safe way to call this function is to call it from the * #MHD_AccessHandlerCallback or #MHD_ContentReaderCallback. * * Finally, it is an API violation to call #MHD_stop_daemon while * having suspended connections (this will at least create memory and * socket leaks or lead to undefined behavior). You must explicitly * resume all connections before stopping the daemon. * * @param connection the connection to suspend * * @sa #MHD_AccessHandlerCallback */ _MHD_EXTERN void MHD_suspend_connection (struct MHD_Connection *connection); /** * Resume handling of network data for suspended connection. It is * safe to resume a suspended connection at any time. Calling this * function on a connection that was not previously suspended will * result in undefined behavior. * * If you are using this function in "external" sockets polling mode, you must * make sure to run #MHD_run() and #MHD_get_timeout() afterwards (before * again calling #MHD_get_fdset()), as otherwise the change may not be * reflected in the set returned by #MHD_get_fdset() and you may end up * with a connection that is stuck until the next network activity. * * @param connection the connection to resume */ _MHD_EXTERN void MHD_resume_connection (struct MHD_Connection *connection); /* **************** Response manipulation functions ***************** */ /** * Flags for special handling of responses. */ enum MHD_ResponseFlags { /** * Default: no special flags. * @note Available since #MHD_VERSION 0x00093701 */ MHD_RF_NONE = 0, /** * Only respond in conservative (dumb) HTTP/1.0-compatible mode. * Response still use HTTP/1.1 version in header, but always close * the connection after sending the response and do not use chunked * encoding for the response. * You can also set the #MHD_RF_HTTP_1_0_SERVER flag to force * HTTP/1.0 version in the response. * Responses are still compatible with HTTP/1.1. * This option can be used to communicate with some broken client, which * does not implement HTTP/1.1 features, but advertises HTTP/1.1 support. * @note Available since #MHD_VERSION 0x00097308 */ MHD_RF_HTTP_1_0_COMPATIBLE_STRICT = 1 << 0, /** * The same as #MHD_RF_HTTP_1_0_COMPATIBLE_STRICT * @note Available since #MHD_VERSION 0x00093701 */ MHD_RF_HTTP_VERSION_1_0_ONLY = 1 << 0, /** * Only respond in HTTP 1.0-mode. * Contrary to the #MHD_RF_HTTP_1_0_COMPATIBLE_STRICT flag, the response's * HTTP version will always be set to 1.0 and keep-alive connections * will be used if explicitly requested by the client. * The "Connection:" header will be added for both "close" and "keep-alive" * connections. * Chunked encoding will not be used for the response. * Due to backward compatibility, responses still can be used with * HTTP/1.1 clients. * This option can be used to emulate HTTP/1.0 server (for response part * only as chunked encoding in requests (if any) is processed by MHD). * @note Available since #MHD_VERSION 0x00097308 */ MHD_RF_HTTP_1_0_SERVER = 1 << 1, /** * The same as #MHD_RF_HTTP_1_0_SERVER * @note Available since #MHD_VERSION 0x00096000 */ MHD_RF_HTTP_VERSION_1_0_RESPONSE = 1 << 1, /** * Disable sanity check preventing clients from manually * setting the HTTP content length option. * Allow to set several "Content-Length" headers. These headers will * be used even with replies without body. * @note Available since #MHD_VERSION 0x00096702 */ MHD_RF_INSANITY_HEADER_CONTENT_LENGTH = 1 << 2, /** * Enable sending of "Connection: keep-alive" header even for * HTTP/1.1 clients when "Keep-Alive" connection is used. * Disabled by default for HTTP/1.1 clients as per RFC. * @note Available since #MHD_VERSION 0x00097310 */ MHD_RF_SEND_KEEP_ALIVE_HEADER = 1 << 3, /** * Enable special processing of the response as body-less (with undefined * body size). No automatic "Content-Length" or "Transfer-Encoding: chunked" * headers are added when the response is used with #MHD_HTTP_NOT_MODIFIED * code or to respond to HEAD request. * The flag also allow to set arbitrary "Content-Length" by * MHD_add_response_header() function. * This flag value can be used only with responses created without body * (zero-size body). * Responses with this flag enabled cannot be used in situations where * reply body must be sent to the client. * This flag is primarily intended to be used when automatic "Content-Length" * header is undesirable in response to HEAD requests. * @note Available since #MHD_VERSION 0x00097701 */ MHD_RF_HEAD_ONLY_RESPONSE = 1 << 4 } _MHD_FIXED_FLAGS_ENUM; /** * MHD options (for future extensions). */ enum MHD_ResponseOptions { /** * End of the list of options. */ MHD_RO_END = 0 } _MHD_FIXED_ENUM; /** * Set special flags and options for a response. * * @param response the response to modify * @param flags to set for the response * @param ... #MHD_RO_END terminated list of options * @return #MHD_YES on success, #MHD_NO on error */ _MHD_EXTERN enum MHD_Result MHD_set_response_options (struct MHD_Response *response, enum MHD_ResponseFlags flags, ...); /** * Create a response object. * The response object can be extended with header information and then be used * any number of times. * * If response object is used to answer HEAD request then the body of the * response is not used, while all headers (including automatic headers) are * used. * * @param size size of the data portion of the response, #MHD_SIZE_UNKNOWN for unknown * @param block_size preferred block size for querying crc (advisory only, * MHD may still call @a crc using smaller chunks); this * is essentially the buffer size used for IO, clients * should pick a value that is appropriate for IO and * memory performance requirements * @param crc callback to use to obtain response data * @param crc_cls extra argument to @a crc * @param crfc callback to call to free @a crc_cls resources * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_callback (uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc); /** * Create a response object. * The response object can be extended with header information and then be used * any number of times. * * If response object is used to answer HEAD request then the body of the * response is not used, while all headers (including automatic headers) are * used. * * @param size size of the @a data portion of the response * @param data the data itself * @param must_free libmicrohttpd should free data when done * @param must_copy libmicrohttpd must make a copy of @a data * right away, the data may be released anytime after * this call returns * @return NULL on error (i.e. invalid arguments, out of memory) * @deprecated use #MHD_create_response_from_buffer instead * @ingroup response */ _MHD_DEPR_FUNC ("MHD_create_response_from_data() is deprecated, " \ "use MHD_create_response_from_buffer()") \ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy); /** * Specification for how MHD should treat the memory buffer * given for the response. * @ingroup response */ enum MHD_ResponseMemoryMode { /** * Buffer is a persistent (static/global) buffer that won't change * for at least the lifetime of the response, MHD should just use * it, not free it, not copy it, just keep an alias to it. * @ingroup response */ MHD_RESPMEM_PERSISTENT, /** * Buffer is heap-allocated with `malloc()` (or equivalent) and * should be freed by MHD after processing the response has * concluded (response reference counter reaches zero). * The more portable way to automatically free the buffer is function * MHD_create_response_from_buffer_with_free_callback() with '&free' as * crfc parameter as it does not require to use the same runtime library. * @warning It is critical to make sure that the same C-runtime library * is used by both application and MHD (especially * important for W32). * @ingroup response */ MHD_RESPMEM_MUST_FREE, /** * Buffer is in transient memory, but not on the heap (for example, * on the stack or non-`malloc()` allocated) and only valid during the * call to #MHD_create_response_from_buffer. MHD must make its * own private copy of the data for processing. * @ingroup response */ MHD_RESPMEM_MUST_COPY } _MHD_FIXED_ENUM; /** * Create a response object with the content of provided buffer used as * the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response * @param buffer size bytes containing the response's data portion * @param mode flags for buffer management * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer (size_t size, void *buffer, enum MHD_ResponseMemoryMode mode); /** * Create a response object with the content of provided statically allocated * buffer used as the response body. * * The buffer must be valid for the lifetime of the response. The easiest way * to achieve this is to use a statically allocated buffer. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size the size of the data in @a buffer, can be zero * @param buffer the buffer with the data for the response body, can be NULL * if @a size is zero * @return NULL on error (i.e. invalid arguments, out of memory) * @note Available since #MHD_VERSION 0x00097701 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer_static (size_t size, const void *buffer); /** * Create a response object with the content of provided temporal buffer * used as the response body. * * An internal copy of the buffer will be made automatically, so buffer have * to be valid only during the call of this function (as a typical example: * buffer is a local (non-static) array). * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size the size of the data in @a buffer, can be zero * @param buffer the buffer with the data for the response body, can be NULL * if @a size is zero * @return NULL on error (i.e. invalid arguments, out of memory) * @note Available since #MHD_VERSION 0x00097701 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer_copy (size_t size, const void *buffer); /** * Create a response object with the content of provided buffer used as * the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response * @param buffer size bytes containing the response's data portion * @param crfc function to call to free the @a buffer * @return NULL on error (i.e. invalid arguments, out of memory) * @note Available since #MHD_VERSION 0x00096000 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer_with_free_callback (size_t size, void *buffer, MHD_ContentReaderFreeCallback crfc); /** * Create a response object with the content of provided buffer used as * the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response * @param buffer size bytes containing the response's data portion * @param crfc function to call to cleanup, if set to NULL then callback * is not called * @param crfc_cls an argument for @a crfc * @return NULL on error (i.e. invalid arguments, out of memory) * @note Available since #MHD_VERSION 0x00097302 * @note 'const' qualifier is used for @a buffer since #MHD_VERSION 0x00097701 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer_with_free_callback_cls (size_t size, const void *buffer, MHD_ContentReaderFreeCallback crfc, void *crfc_cls); /** * Create a response object with the content of provided file used as * the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response * @param fd file descriptor referring to a file on disk with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd (size_t size, int fd); /** * Create a response object with the response body created by reading * the provided pipe. * * The response object can be extended with header information and * then be used ONLY ONCE. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param fd file descriptor referring to a read-end of a pipe with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @return NULL on error (i.e. invalid arguments, out of memory) * @note Available since #MHD_VERSION 0x00097102 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_pipe (int fd); /** * Create a response object with the content of provided file used as * the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response; * sizes larger than 2 GiB may be not supported by OS or * MHD build; see ::MHD_FEATURE_LARGE_FILE * @param fd file descriptor referring to a file on disk with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd64 (uint64_t size, int fd); /** * Create a response object with the content of provided file with * specified offset used as the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response * @param fd file descriptor referring to a file on disk with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @param offset offset to start reading from in the file; * Be careful! `off_t` may have been compiled to be a * 64-bit variable for MHD, in which case your application * also has to be compiled using the same options! Read * the MHD manual for more details. * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_DEPR_FUNC ("Function MHD_create_response_from_fd_at_offset() is " \ "deprecated, use MHD_create_response_from_fd_at_offset64()") \ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd_at_offset (size_t size, int fd, off_t offset); #if ! defined(_MHD_NO_DEPR_IN_MACRO) || defined(_MHD_NO_DEPR_FUNC) /* Substitute MHD_create_response_from_fd_at_offset64() instead of MHD_create_response_from_fd_at_offset() to minimize potential problems with different off_t sizes */ #define MHD_create_response_from_fd_at_offset(size,fd,offset) \ _MHD_DEPR_IN_MACRO ( \ "Usage of MHD_create_response_from_fd_at_offset() is deprecated, use MHD_create_response_from_fd_at_offset64()") \ MHD_create_response_from_fd_at_offset64 ((size),(fd),(offset)) #endif /* !_MHD_NO_DEPR_IN_MACRO || _MHD_NO_DEPR_FUNC */ /** * Create a response object with the content of provided file with * specified offset used as the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response; * sizes larger than 2 GiB may be not supported by OS or * MHD build; see ::MHD_FEATURE_LARGE_FILE * @param fd file descriptor referring to a file on disk with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @param offset offset to start reading from in the file; * reading file beyond 2 GiB may be not supported by OS or * MHD build; see ::MHD_FEATURE_LARGE_FILE * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd_at_offset64 (uint64_t size, int fd, uint64_t offset); /** * Create a response object with an array of memory buffers * used as the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param iov the array for response data buffers, an internal copy of this * will be made * @param iovcnt the number of elements in @a iov * @param free_cb the callback to clean up any data associated with @a iov when * the response is destroyed. * @param cls the argument passed to @a free_cb * @return NULL on error (i.e. invalid arguments, out of memory) * @note Available since #MHD_VERSION 0x00097204 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_iovec (const struct MHD_IoVec *iov, unsigned int iovcnt, MHD_ContentReaderFreeCallback free_cb, void *cls); /** * Create a response object with empty (zero size) body. * * The response object can be extended with header information and then be used * any number of times. * * This function is a faster equivalent of #MHD_create_response_from_buffer call * with zero size combined with call of #MHD_set_response_options. * * @param flags the flags for the new response object * @return NULL on error (i.e. invalid arguments, out of memory), * the pointer to the created response object otherwise * @note Available since #MHD_VERSION 0x00097701 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_empty (enum MHD_ResponseFlags flags); /** * Enumeration for actions MHD should perform on the underlying socket * of the upgrade. This API is not finalized, and in particular * the final set of actions is yet to be decided. This is just an * idea for what we might want. */ enum MHD_UpgradeAction { /** * Close the socket, the application is done with it. * * Takes no extra arguments. */ MHD_UPGRADE_ACTION_CLOSE = 0, /** * Enable CORKing on the underlying socket. */ MHD_UPGRADE_ACTION_CORK_ON = 1, /** * Disable CORKing on the underlying socket. */ MHD_UPGRADE_ACTION_CORK_OFF = 2 } _MHD_FIXED_ENUM; /** * Handle given to the application to manage special * actions relating to MHD responses that "upgrade" * the HTTP protocol (i.e. to WebSockets). */ struct MHD_UpgradeResponseHandle; /** * This connection-specific callback is provided by MHD to * applications (unusual) during the #MHD_UpgradeHandler. * It allows applications to perform 'special' actions on * the underlying socket from the upgrade. * * @param urh the handle identifying the connection to perform * the upgrade @a action on. * @param action which action should be performed * @param ... arguments to the action (depends on the action) * @return #MHD_NO on error, #MHD_YES on success */ _MHD_EXTERN enum MHD_Result MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, enum MHD_UpgradeAction action, ...); /** * Function called after a protocol "upgrade" response was sent * successfully and the socket should now be controlled by some * protocol other than HTTP. * * Any data already received on the socket will be made available in * @e extra_in. This can happen if the application sent extra data * before MHD send the upgrade response. The application should * treat data from @a extra_in as if it had read it from the socket. * * Note that the application must not close() @a sock directly, * but instead use #MHD_upgrade_action() for special operations * on @a sock. * * Data forwarding to "upgraded" @a sock will be started as soon * as this function return. * * Except when in 'thread-per-connection' mode, implementations * of this function should never block (as it will still be called * from within the main event loop). * * @param cls closure, whatever was given to #MHD_create_response_for_upgrade(). * @param connection original HTTP connection handle, * giving the function a last chance * to inspect the original HTTP request * @param req_cls last value left in `req_cls` of the `MHD_AccessHandlerCallback` * @param extra_in if we happened to have read bytes after the * HTTP header already (because the client sent * more than the HTTP header of the request before * we sent the upgrade response), * these are the extra bytes already read from @a sock * by MHD. The application should treat these as if * it had read them from @a sock. * @param extra_in_size number of bytes in @a extra_in * @param sock socket to use for bi-directional communication * with the client. For HTTPS, this may not be a socket * that is directly connected to the client and thus certain * operations (TCP-specific setsockopt(), getsockopt(), etc.) * may not work as expected (as the socket could be from a * socketpair() or a TCP-loopback). The application is expected * to perform read()/recv() and write()/send() calls on the socket. * The application may also call shutdown(), but must not call * close() directly. * @param urh argument for #MHD_upgrade_action()s on this @a connection. * Applications must eventually use this callback to (indirectly) * perform the close() action on the @a sock. */ typedef void (*MHD_UpgradeHandler)(void *cls, struct MHD_Connection *connection, void *req_cls, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh); /** * Create a response object that can be used for 101 UPGRADE * responses, for example to implement WebSockets. After sending the * response, control over the data stream is given to the callback (which * can then, for example, start some bi-directional communication). * If the response is queued for multiple connections, the callback * will be called for each connection. The callback * will ONLY be called after the response header was successfully passed * to the OS; if there are communication errors before, the usual MHD * connection error handling code will be performed. * * Setting the correct HTTP code (i.e. MHD_HTTP_SWITCHING_PROTOCOLS) * and setting correct HTTP headers for the upgrade must be done * manually (this way, it is possible to implement most existing * WebSocket versions using this API; in fact, this API might be useful * for any protocol switch, not just WebSockets). Note that * draft-ietf-hybi-thewebsocketprotocol-00 cannot be implemented this * way as the header "HTTP/1.1 101 WebSocket Protocol Handshake" * cannot be generated; instead, MHD will always produce "HTTP/1.1 101 * Switching Protocols" (if the response code 101 is used). * * As usual, the response object can be extended with header * information and then be used any number of times (as long as the * header information is not connection-specific). * * @param upgrade_handler function to call with the "upgraded" socket * @param upgrade_handler_cls closure for @a upgrade_handler * @return NULL on error (i.e. invalid arguments, out of memory) */ _MHD_EXTERN struct MHD_Response * MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, void *upgrade_handler_cls); /** * Destroy a response object and associated resources. Note that * libmicrohttpd may keep some of the resources around if the response * is still in the queue for some clients, so the memory may not * necessarily be freed immediately. * * @param response response to destroy * @ingroup response */ _MHD_EXTERN void MHD_destroy_response (struct MHD_Response *response); /** * Add a header line to the response. * * When reply is generated with queued response, some headers are generated * automatically. Automatically generated headers are only sent to the client, * but not added back to the response object. * * The list of automatic headers: * + "Date" header is added automatically unless already set by * this function * @see #MHD_USE_SUPPRESS_DATE_NO_CLOCK * + "Content-Length" is added automatically when required, attempt to set * it manually by this function is ignored. * @see #MHD_RF_INSANITY_HEADER_CONTENT_LENGTH * + "Transfer-Encoding" with value "chunked" is added automatically, * when chunked transfer encoding is used automatically. Same header with * the same value can be set manually by this function to enforce chunked * encoding, however for HTTP/1.0 clients chunked encoding will not be used * and manually set "Transfer-Encoding" header is automatically removed * for HTTP/1.0 clients * + "Connection" may be added automatically with value "Keep-Alive" (only * for HTTP/1.0 clients) or "Close". The header "Connection" with value * "Close" could be set by this function to enforce closure of * the connection after sending this response. "Keep-Alive" cannot be * enforced and will be removed automatically. * @see #MHD_RF_SEND_KEEP_ALIVE_HEADER * * Some headers are pre-processed by this function: * * "Connection" headers are combined into single header entry, value is * normilised, "Keep-Alive" tokens are removed. * * "Transfer-Encoding" header: the only one header is allowed, the only * allowed value is "chunked". * * "Date" header: the only one header is allowed, the second added header * replaces the first one. * * "Content-Length" application-defined header is not allowed. * @see #MHD_RF_INSANITY_HEADER_CONTENT_LENGTH * * Headers are used in order as they were added. * * @param response the response to add a header to * @param header the header name to add, no need to be static, an internal copy * will be created automatically * @param content the header value to add, no need to be static, an internal * copy will be created automatically * @return #MHD_YES on success, * #MHD_NO on error (i.e. invalid header or content format), * or out of memory * @ingroup response */ _MHD_EXTERN enum MHD_Result MHD_add_response_header (struct MHD_Response *response, const char *header, const char *content); /** * Add a footer line to the response. * * @param response response to remove a header from * @param footer the footer to delete * @param content value to delete * @return #MHD_NO on error (i.e. invalid footer or content format). * @ingroup response */ _MHD_EXTERN enum MHD_Result MHD_add_response_footer (struct MHD_Response *response, const char *footer, const char *content); /** * Delete a header (or footer) line from the response. * * For "Connection" headers this function remove all tokens from existing * value. Successful result means that at least one token has been removed. * If all tokens are removed from "Connection" header, the empty "Connection" * header removed. * * @param response response to remove a header from * @param header the header to delete * @param content value to delete * @return #MHD_NO on error (no such header known) * @ingroup response */ _MHD_EXTERN enum MHD_Result MHD_del_response_header (struct MHD_Response *response, const char *header, const char *content); /** * Get all of the headers (and footers) added to a response. * * @param response response to query * @param iterator callback to call on each header; * may be NULL (then just count headers) * @param iterator_cls extra argument to @a iterator * @return number of entries iterated over * @ingroup response */ _MHD_EXTERN int MHD_get_response_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls); /** * Get a particular header (or footer) from the response. * * @param response response to query * @param key which header to get * @return NULL if header does not exist * @ingroup response */ _MHD_EXTERN const char * MHD_get_response_header (struct MHD_Response *response, const char *key); /* ********************** PostProcessor functions ********************** */ /** * Create a `struct MHD_PostProcessor`. * * A `struct MHD_PostProcessor` can be used to (incrementally) parse * the data portion of a POST request. Note that some buggy browsers * fail to set the encoding type. If you want to support those, you * may have to call #MHD_set_connection_value with the proper encoding * type before creating a post processor (if no supported encoding * type is set, this function will fail). * * @param connection the connection on which the POST is * happening (used to determine the POST format) * @param buffer_size maximum number of bytes to use for * internal buffering (used only for the parsing, * specifically the parsing of the keys). A * tiny value (256-1024) should be sufficient. * Do NOT use a value smaller than 256. For good * performance, use 32 or 64k (i.e. 65536). * @param iter iterator to be called with the parsed data, * Must NOT be NULL. * @param iter_cls first argument to @a iter * @return NULL on error (out of memory, unsupported encoding), * otherwise a PP handle * @ingroup request */ _MHD_EXTERN struct MHD_PostProcessor * MHD_create_post_processor (struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iter, void *iter_cls); /** * Parse and process POST data. Call this function when POST data is * available (usually during an #MHD_AccessHandlerCallback) with the * "upload_data" and "upload_data_size". Whenever possible, this will * then cause calls to the #MHD_PostDataIterator. * * @param pp the post processor * @param post_data @a post_data_len bytes of POST data * @param post_data_len length of @a post_data * @return #MHD_YES on success, #MHD_NO on error * (out-of-memory, iterator aborted, parse error) * @ingroup request */ _MHD_EXTERN enum MHD_Result MHD_post_process (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len); /** * Release PostProcessor resources. * * @param pp the PostProcessor to destroy * @return #MHD_YES if processing completed nicely, * #MHD_NO if there were spurious characters / formatting * problems; it is common to ignore the return * value of this function * @ingroup request */ _MHD_EXTERN enum MHD_Result MHD_destroy_post_processor (struct MHD_PostProcessor *pp); /* ********************* Digest Authentication functions *************** */ /** * Length of the binary output of the MD5 hash function. * @sa #MHD_digest_get_hash_size() * @ingroup authentication */ #define MHD_MD5_DIGEST_SIZE 16 /** * Length of the binary output of the SHA-256 hash function. * @sa #MHD_digest_get_hash_size() * @ingroup authentication */ #define MHD_SHA256_DIGEST_SIZE 32 /** * Length of the binary output of the SHA-512/256 hash function. * @warning While this value is the same as the #MHD_SHA256_DIGEST_SIZE, * the calculated digests for SHA-256 and SHA-512/256 are different. * @sa #MHD_digest_get_hash_size() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ #define MHD_SHA512_256_DIGEST_SIZE 32 /** * Base type of hash calculation. * Used as part of #MHD_DigestAuthAlgo3 values. * * @warning Not used directly by MHD API. * @note Available since #MHD_VERSION 0x00097701 */ enum MHD_DigestBaseAlgo { /** * Invalid hash algorithm value */ MHD_DIGEST_BASE_ALGO_INVALID = 0, /** * MD5 hash algorithm. * As specified by RFC1321 */ MHD_DIGEST_BASE_ALGO_MD5 = (1 << 0), /** * SHA-256 hash algorithm. * As specified by FIPS PUB 180-4 */ MHD_DIGEST_BASE_ALGO_SHA256 = (1 << 1), /** * SHA-512/256 hash algorithm. * As specified by FIPS PUB 180-4 */ MHD_DIGEST_BASE_ALGO_SHA512_256 = (1 << 2) } _MHD_FIXED_FLAGS_ENUM; /** * The flag indicating non-session algorithm types, * like 'MD5', 'SHA-256' or 'SHA-512-256'. * @note Available since #MHD_VERSION 0x00097701 */ #define MHD_DIGEST_AUTH_ALGO3_NON_SESSION (1 << 6) /** * The flag indicating session algorithm types, * like 'MD5-sess', 'SHA-256-sess' or 'SHA-512-256-sess'. * @note Available since #MHD_VERSION 0x00097701 */ #define MHD_DIGEST_AUTH_ALGO3_SESSION (1 << 7) /** * Digest algorithm identification * @warning Do not be confused with #MHD_DigestAuthAlgorithm, * which uses other values! * @note Available since #MHD_VERSION 0x00097701 */ enum MHD_DigestAuthAlgo3 { /** * Unknown or wrong algorithm type. * Used in struct MHD_DigestAuthInfo to indicate client value that * cannot by identified. */ MHD_DIGEST_AUTH_ALGO3_INVALID = 0, /** * The 'MD5' algorithm, non-session version. */ MHD_DIGEST_AUTH_ALGO3_MD5 = MHD_DIGEST_BASE_ALGO_MD5 | MHD_DIGEST_AUTH_ALGO3_NON_SESSION, /** * The 'MD5-sess' algorithm. * Not supported by MHD for authentication. */ MHD_DIGEST_AUTH_ALGO3_MD5_SESSION = MHD_DIGEST_BASE_ALGO_MD5 | MHD_DIGEST_AUTH_ALGO3_SESSION, /** * The 'SHA-256' algorithm, non-session version. */ MHD_DIGEST_AUTH_ALGO3_SHA256 = MHD_DIGEST_BASE_ALGO_SHA256 | MHD_DIGEST_AUTH_ALGO3_NON_SESSION, /** * The 'SHA-256-sess' algorithm. * Not supported by MHD for authentication. */ MHD_DIGEST_AUTH_ALGO3_SHA256_SESSION = MHD_DIGEST_BASE_ALGO_SHA256 | MHD_DIGEST_AUTH_ALGO3_SESSION, /** * The 'SHA-512-256' (SHA-512/256) algorithm. */ MHD_DIGEST_AUTH_ALGO3_SHA512_256 = MHD_DIGEST_BASE_ALGO_SHA512_256 | MHD_DIGEST_AUTH_ALGO3_NON_SESSION, /** * The 'SHA-512-256-sess' (SHA-512/256 session) algorithm. * Not supported by MHD for authentication. */ MHD_DIGEST_AUTH_ALGO3_SHA512_256_SESSION = MHD_DIGEST_BASE_ALGO_SHA512_256 | MHD_DIGEST_AUTH_ALGO3_SESSION }; /** * Get digest size for specified algorithm. * * The size of the digest specifies the size of the userhash, userdigest * and other parameters which size depends on used hash algorithm. * @param algo3 the algorithm to check * @return the size of the digest (either #MHD_MD5_DIGEST_SIZE or * #MHD_SHA256_DIGEST_SIZE/MHD_SHA512_256_DIGEST_SIZE) * or zero if the input value is not supported or not valid * @sa #MHD_digest_auth_calc_userdigest() * @sa #MHD_digest_auth_calc_userhash(), #MHD_digest_auth_calc_userhash_hex() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN size_t MHD_digest_get_hash_size (enum MHD_DigestAuthAlgo3 algo3); /** * Digest algorithm identification, allow multiple selection. * * #MHD_DigestAuthAlgo3 always can be casted to #MHD_DigestAuthMultiAlgo3, but * not vice versa. * * @note Available since #MHD_VERSION 0x00097701 */ enum MHD_DigestAuthMultiAlgo3 { /** * Unknown or wrong algorithm type. */ MHD_DIGEST_AUTH_MULT_ALGO3_INVALID = MHD_DIGEST_AUTH_ALGO3_INVALID, /** * The 'MD5' algorithm, non-session version. */ MHD_DIGEST_AUTH_MULT_ALGO3_MD5 = MHD_DIGEST_AUTH_ALGO3_MD5, /** * The 'MD5-sess' algorithm. * Not supported by MHD for authentication. * Reserved value. */ MHD_DIGEST_AUTH_MULT_ALGO3_MD5_SESSION = MHD_DIGEST_AUTH_ALGO3_MD5_SESSION, /** * The 'SHA-256' algorithm, non-session version. */ MHD_DIGEST_AUTH_MULT_ALGO3_SHA256 = MHD_DIGEST_AUTH_ALGO3_SHA256, /** * The 'SHA-256-sess' algorithm. * Not supported by MHD for authentication. * Reserved value. */ MHD_DIGEST_AUTH_MULT_ALGO3_SHA256_SESSION = MHD_DIGEST_AUTH_ALGO3_SHA256_SESSION, /** * The 'SHA-512-256' (SHA-512/256) algorithm, non-session version. */ MHD_DIGEST_AUTH_MULT_ALGO3_SHA512_256 = MHD_DIGEST_AUTH_ALGO3_SHA512_256, /** * The 'SHA-512-256-sess' (SHA-512/256 session) algorithm. * Not supported by MHD for authentication. * Reserved value. */ MHD_DIGEST_AUTH_MULT_ALGO3_SHA512_256_SESSION = MHD_DIGEST_AUTH_ALGO3_SHA512_256_SESSION, /** * SHA-256 or SHA-512/256 non-session algorithm, MHD will choose * the preferred or the matching one. */ MHD_DIGEST_AUTH_MULT_ALGO3_SHA_ANY_NON_SESSION = MHD_DIGEST_AUTH_ALGO3_SHA256 | MHD_DIGEST_AUTH_ALGO3_SHA512_256, /** * Any non-session algorithm, MHD will choose the preferred or * the matching one. */ MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION = (0x3F) | MHD_DIGEST_AUTH_ALGO3_NON_SESSION, /** * The SHA-256 or SHA-512/256 session algorithm. * Not supported by MHD. * Reserved value. */ MHD_DIGEST_AUTH_MULT_ALGO3_SHA_ANY_SESSION = MHD_DIGEST_AUTH_ALGO3_SHA256_SESSION | MHD_DIGEST_AUTH_ALGO3_SHA512_256_SESSION, /** * Any session algorithm. * Not supported by MHD. * Reserved value. */ MHD_DIGEST_AUTH_MULT_ALGO3_ANY_SESSION = (0x3F) | MHD_DIGEST_AUTH_ALGO3_SESSION, /** * The MD5 algorithm, session or non-session. * Currently supported as non-session only. */ MHD_DIGEST_AUTH_MULT_ALGO3_MD5_ANY = MHD_DIGEST_AUTH_MULT_ALGO3_MD5 | MHD_DIGEST_AUTH_MULT_ALGO3_MD5_SESSION, /** * The SHA-256 algorithm, session or non-session. * Currently supported as non-session only. */ MHD_DIGEST_AUTH_MULT_ALGO3_SHA256_ANY = MHD_DIGEST_AUTH_MULT_ALGO3_SHA256 | MHD_DIGEST_AUTH_MULT_ALGO3_SHA256_SESSION, /** * The SHA-512/256 algorithm, session or non-session. * Currently supported as non-session only. */ MHD_DIGEST_AUTH_MULT_ALGO3_SHA512_256_ANY = MHD_DIGEST_AUTH_MULT_ALGO3_SHA512_256 | MHD_DIGEST_AUTH_MULT_ALGO3_SHA512_256_SESSION, /** * The SHA-256 or SHA-512/256 algorithm, session or non-session. * Currently supported as non-session only. */ MHD_DIGEST_AUTH_MULT_ALGO3_SHA_ANY_ANY = MHD_DIGEST_AUTH_MULT_ALGO3_SHA_ANY_NON_SESSION | MHD_DIGEST_AUTH_MULT_ALGO3_SHA_ANY_SESSION, /** * Any algorithm, MHD will choose the preferred or the matching one. */ MHD_DIGEST_AUTH_MULT_ALGO3_ANY = (0x3F) | MHD_DIGEST_AUTH_ALGO3_NON_SESSION | MHD_DIGEST_AUTH_ALGO3_SESSION }; /** * Calculate "userhash", return it as binary data. * * The "userhash" is the hash of the string "username:realm". * * The "userhash" could be used to avoid sending username in cleartext in Digest * Authorization client's header. * * Userhash is not designed to hide the username in local database or files, * as username in cleartext is required for #MHD_digest_auth_check3() function * to check the response, but it can be used to hide username in HTTP headers. * * This function could be used when the new username is added to the username * database to save the "userhash" alongside with the username (preferably) or * when loading list of the usernames to generate the userhash for every loaded * username (this will cause delays at the start with the long lists). * * Once "userhash" is generated it could be used to identify users by clients * with "userhash" support. * Avoid repetitive usage of this function for the same username/realm * combination as it will cause excessive CPU load; save and re-use the result * instead. * * @param algo3 the algorithm for userhash calculations * @param username the username * @param realm the realm * @param[out] userhash_bin the output buffer for userhash as binary data; * if this function succeeds, then this buffer has * #MHD_digest_get_hash_size(algo3) bytes of userhash * upon return * @param bin_buf_size the size of the @a userhash_bin buffer, must be * at least #MHD_digest_get_hash_size(algo3) bytes long * @return MHD_YES on success, * MHD_NO if @a bin_buf_size is too small or if @a algo3 algorithm is * not supported (or external error has occurred, * see #MHD_FEATURE_EXTERN_HASH) * @sa #MHD_digest_auth_calc_userhash_hex() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userhash (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, void *userhash_bin, size_t bin_buf_size); /** * Calculate "userhash", return it as hexadecimal string. * * The "userhash" is the hash of the string "username:realm". * * The "userhash" could be used to avoid sending username in cleartext in Digest * Authorization client's header. * * Userhash is not designed to hide the username in local database or files, * as username in cleartext is required for #MHD_digest_auth_check3() function * to check the response, but it can be used to hide username in HTTP headers. * * This function could be used when the new username is added to the username * database to save the "userhash" alongside with the username (preferably) or * when loading list of the usernames to generate the userhash for every loaded * username (this will cause delays at the start with the long lists). * * Once "userhash" is generated it could be used to identify users by clients * with "userhash" support. * Avoid repetitive usage of this function for the same username/realm * combination as it will cause excessive CPU load; save and re-use the result * instead. * * @param algo3 the algorithm for userhash calculations * @param username the username * @param realm the realm * @param[out] userhash_hex the output buffer for userhash as hex string; * if this function succeeds, then this buffer has * #MHD_digest_get_hash_size(algo3)*2 chars long * userhash zero-terminated string * @param bin_buf_size the size of the @a userhash_bin buffer, must be * at least #MHD_digest_get_hash_size(algo3)*2+1 chars long * @return MHD_YES on success, * MHD_NO if @a bin_buf_size is too small or if @a algo3 algorithm is * not supported (or external error has occurred, * see #MHD_FEATURE_EXTERN_HASH). * @sa #MHD_digest_auth_calc_userhash() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userhash_hex (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, char *userhash_hex, size_t hex_buf_size); /** * The type of username used by client in Digest Authorization header * * Values are sorted so simplified checks could be used. * For example: * * (value <= MHD_DIGEST_AUTH_UNAME_TYPE_INVALID) is true if no valid username * is provided by the client * * (value >= MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH) is true if username is * provided in any form * * (value >= MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD) is true if username is * provided in clear text (no userhash matching is needed) * * @note Available since #MHD_VERSION 0x00097701 */ enum MHD_DigestAuthUsernameType { /** * No username parameter in in Digest Authorization header. * This should be treated as an error. */ MHD_DIGEST_AUTH_UNAME_TYPE_MISSING = 0, /** * The 'username' parameter is used to specify the username. */ MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD = (1 << 2), /** * The username is specified by 'username*' parameter with * the extended notation (see RFC 5987 #section-3.2.1). * The only difference between standard and extended types is * the way how username value is encoded in the header. */ MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED = (1 << 3), /** * The username provided in form of 'userhash' as * specified by RFC 7616 #section-3.4.4. * @sa #MHD_digest_auth_calc_userhash_hex(), #MHD_digest_auth_calc_userhash() */ MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH = (1 << 1), /** * The invalid combination of username parameters are used by client. * Either: * * both 'username' and 'username*' are used * * 'username*' is used with 'userhash=true' * * 'username*' used with invalid extended notation * * 'username' is not hexadecimal string, while 'userhash' set to 'true' */ MHD_DIGEST_AUTH_UNAME_TYPE_INVALID = (1 << 0) } _MHD_FIXED_ENUM; /** * The QOP ('quality of protection') types. * @note Available since #MHD_VERSION 0x00097701 */ enum MHD_DigestAuthQOP { /** * Invalid/unknown QOP. * Used in struct MHD_DigestAuthInfo to indicate client value that * cannot by identified. */ MHD_DIGEST_AUTH_QOP_INVALID = 0, /** * No QOP parameter. * As described in old RFC 2069 original specification. * This mode is not allowed by latest RFCs and should be used only to * communicate with clients that do not support more modern modes (with QOP * parameter). * This mode is less secure than other modes and inefficient. */ MHD_DIGEST_AUTH_QOP_NONE = 1 << 0, /** * The 'auth' QOP type. */ MHD_DIGEST_AUTH_QOP_AUTH = 1 << 1, /** * The 'auth-int' QOP type. * Not supported by MHD for authentication. */ MHD_DIGEST_AUTH_QOP_AUTH_INT = 1 << 2 } _MHD_FIXED_FLAGS_ENUM; /** * The QOP ('quality of protection') types, multiple selection. * * #MHD_DigestAuthQOP always can be casted to #MHD_DigestAuthMultiQOP, but * not vice versa. * * @note Available since #MHD_VERSION 0x00097701 */ enum MHD_DigestAuthMultiQOP { /** * Invalid/unknown QOP. */ MHD_DIGEST_AUTH_MULT_QOP_INVALID = MHD_DIGEST_AUTH_QOP_INVALID, /** * No QOP parameter. * As described in old RFC 2069 original specification. * This mode is not allowed by latest RFCs and should be used only to * communicate with clients that do not support more modern modes (with QOP * parameter). * This mode is less secure than other modes and inefficient. */ MHD_DIGEST_AUTH_MULT_QOP_NONE = MHD_DIGEST_AUTH_QOP_NONE, /** * The 'auth' QOP type. */ MHD_DIGEST_AUTH_MULT_QOP_AUTH = MHD_DIGEST_AUTH_QOP_AUTH, /** * The 'auth-int' QOP type. * Not supported by MHD. * Reserved value. */ MHD_DIGEST_AUTH_MULT_QOP_AUTH_INT = MHD_DIGEST_AUTH_QOP_AUTH_INT, /** * The 'auth' QOP type OR the old RFC2069 (no QOP) type. * In other words: any types except 'auth-int'. * RFC2069-compatible mode is allowed, thus this value should be used only * when it is really necessary. */ MHD_DIGEST_AUTH_MULT_QOP_ANY_NON_INT = MHD_DIGEST_AUTH_QOP_NONE | MHD_DIGEST_AUTH_QOP_AUTH, /** * Any 'auth' QOP type ('auth' or 'auth-int'). * Currently supported as 'auth' QOP type only. */ MHD_DIGEST_AUTH_MULT_QOP_AUTH_ANY = MHD_DIGEST_AUTH_QOP_AUTH | MHD_DIGEST_AUTH_QOP_AUTH_INT } _MHD_FIXED_ENUM; /** * The invalid value of 'nc' parameter in client Digest Authorization header. * @note Available since #MHD_VERSION 0x00097701 */ #define MHD_DIGEST_AUTH_INVALID_NC_VALUE (0) /** * Information from Digest Authorization client's header. * * All buffers pointed by any struct members are freed when #MHD_free() is * called for pointer to this structure. * * Application may modify buffers as needed until #MHD_free() is called for * pointer to this structure * @note Available since #MHD_VERSION 0x00097701 */ struct MHD_DigestAuthInfo { /** * The algorithm as defined by client. * Set automatically to MD5 if not specified by client. * @warning Do not be confused with #MHD_DigestAuthAlgorithm, * which uses other values! */ enum MHD_DigestAuthAlgo3 algo3; /** * The type of username used by client. */ enum MHD_DigestAuthUsernameType uname_type; /** * The username string. * Used only if username type is standard or extended, always NULL otherwise. * If extended notation is used, this string is pct-decoded string * with charset and language tag removed (i.e. it is original username * extracted from the extended notation). * When userhash is used by the client, this member is NULL and * @a userhash_hex and @a userhash_bin are set. * The buffer pointed by the @a username becomes invalid when the pointer * to the structure is freed by #MHD_free(). */ char *username; /** * The length of the @a username. * When the @a username is NULL, this member is always zero. */ size_t username_len; /** * The userhash string. * Valid only if username type is userhash. * This is unqoted string without decoding of the hexadecimal * digits (as provided by the client). * The buffer pointed by the @a userhash_hex becomes invalid when the pointer * to the structure is freed by #MHD_free(). * @sa #MHD_digest_auth_calc_userhash_hex() */ char *userhash_hex; /** * The length of the @a userhash_hex in characters. * The valid size should be #MHD_digest_get_hash_size(algo3) * 2 characters. * When the @a userhash_hex is NULL, this member is always zero. */ size_t userhash_hex_len; /** * The userhash decoded to binary form. * Used only if username type is userhash, always NULL otherwise. * When not NULL, this points to binary sequence @a userhash_hex_len /2 bytes * long. * The valid size should be #MHD_digest_get_hash_size(algo3) bytes. * The buffer pointed by the @a userhash_bin becomes invalid when the pointer * to the structure is freed by #MHD_free(). * @warning This is a binary data, no zero termination. * @warning To avoid buffer overruns, always check the size of the data before * use, because @a userhash_bin can point even to zero-sized * data. * @sa #MHD_digest_auth_calc_userhash() */ uint8_t *userhash_bin; /** * The 'opaque' parameter value, as specified by client. * NULL if not specified by client. * The buffer pointed by the @a opaque becomes invalid when the pointer * to the structure is freed by #MHD_free(). */ char *opaque; /** * The length of the @a opaque. * When the @a opaque is NULL, this member is always zero. */ size_t opaque_len; /** * The 'realm' parameter value, as specified by client. * NULL if not specified by client. * The buffer pointed by the @a realm becomes invalid when the pointer * to the structure is freed by #MHD_free(). */ char *realm; /** * The length of the @a realm. * When the @a realm is NULL, this member is always zero. */ size_t realm_len; /** * The 'qop' parameter value. */ enum MHD_DigestAuthQOP qop; /** * The length of the 'cnonce' parameter value, including possible * backslash-escape characters. * 'cnonce' is used in hash calculation, which is CPU-intensive procedure. * An application may want to reject too large cnonces to limit the CPU load. * A few kilobytes is a reasonable limit, typically cnonce is just 32-160 * characters long. */ size_t cnonce_len; /** * The nc parameter value. * Can be used by application to limit the number of nonce re-uses. If @a nc * is higher than application wants to allow, then "auth required" response * with 'stale=true' could be used to force client to retry with the fresh * 'nonce'. * If not specified by client or does not have hexadecimal digits only, the * value is #MHD_DIGEST_AUTH_INVALID_NC_VALUE. */ uint32_t nc; }; /** * Get information about Digest Authorization client's header. * * @param connection The MHD connection structure * @return NULL if no valid Digest Authorization header is used in the request; * a pointer to the structure with information if the valid request * header found, free using #MHD_free(). * @sa #MHD_digest_auth_get_username3() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN struct MHD_DigestAuthInfo * MHD_digest_auth_get_request_info3 (struct MHD_Connection *connection); /** * Information from Digest Authorization client's header. * * All buffers pointed by any struct members are freed when #MHD_free() is * called for pointer to this structure. * * Application may modify buffers as needed until #MHD_free() is called for * pointer to this structure * @note Available since #MHD_VERSION 0x00097701 */ struct MHD_DigestAuthUsernameInfo { /** * The algorithm as defined by client. * Set automatically to MD5 if not specified by client. * @warning Do not be confused with #MHD_DigestAuthAlgorithm, * which uses other values! */ enum MHD_DigestAuthAlgo3 algo3; /** * The type of username used by client. * The 'invalid' and 'missing' types are not used in this structure, * instead NULL is returned by #MHD_digest_auth_get_username3(). */ enum MHD_DigestAuthUsernameType uname_type; /** * The username string. * Used only if username type is standard or extended, always NULL otherwise. * If extended notation is used, this string is pct-decoded string * with charset and language tag removed (i.e. it is original username * extracted from the extended notation). * When userhash is used by the client, this member is NULL and * @a userhash_hex and @a userhash_bin are set. * The buffer pointed by the @a username becomes invalid when the pointer * to the structure is freed by #MHD_free(). */ char *username; /** * The length of the @a username. * When the @a username is NULL, this member is always zero. */ size_t username_len; /** * The userhash string. * Valid only if username type is userhash. * This is unqoted string without decoding of the hexadecimal * digits (as provided by the client). * The buffer pointed by the @a userhash_hex becomes invalid when the pointer * to the structure is freed by #MHD_free(). * @sa #MHD_digest_auth_calc_userhash_hex() */ char *userhash_hex; /** * The length of the @a userhash_hex in characters. * The valid size should be #MHD_digest_get_hash_size(algo3) * 2 characters. * When the @a userhash_hex is NULL, this member is always zero. */ size_t userhash_hex_len; /** * The userhash decoded to binary form. * Used only if username type is userhash, always NULL otherwise. * When not NULL, this points to binary sequence @a userhash_hex_len /2 bytes * long. * The valid size should be #MHD_digest_get_hash_size(algo3) bytes. * The buffer pointed by the @a userhash_bin becomes invalid when the pointer * to the structure is freed by #MHD_free(). * @warning This is a binary data, no zero termination. * @warning To avoid buffer overruns, always check the size of the data before * use, because @a userhash_bin can point even to zero-sized * data. * @sa #MHD_digest_auth_calc_userhash() */ uint8_t *userhash_bin; }; /** * Get the username from Digest Authorization client's header. * * @param connection The MHD connection structure * @return NULL if no valid Digest Authorization header is used in the request, * or no username parameter is present in the header, or username is * provided incorrectly by client (see description for * #MHD_DIGEST_AUTH_UNAME_TYPE_INVALID); * a pointer structure with information if the valid request header * found, free using #MHD_free(). * @sa #MHD_digest_auth_get_request_info3() provides more complete information * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN struct MHD_DigestAuthUsernameInfo * MHD_digest_auth_get_username3 (struct MHD_Connection *connection); /** * The result of digest authentication of the client. * * All error values are zero or negative. * * @note Available since #MHD_VERSION 0x00097701 */ enum MHD_DigestAuthResult { /** * Authentication OK. */ MHD_DAUTH_OK = 1, /** * General error, like "out of memory". */ MHD_DAUTH_ERROR = 0, /** * No "Authorization" header or wrong format of the header. * Also may be returned if required parameters in client Authorisation header * are missing or broken (in invalid format). */ MHD_DAUTH_WRONG_HEADER = -1, /** * Wrong 'username'. */ MHD_DAUTH_WRONG_USERNAME = -2, /** * Wrong 'realm'. */ MHD_DAUTH_WRONG_REALM = -3, /** * Wrong 'URI' (or URI parameters). */ MHD_DAUTH_WRONG_URI = -4, /** * Wrong 'qop'. */ MHD_DAUTH_WRONG_QOP = -5, /** * Wrong 'algorithm'. */ MHD_DAUTH_WRONG_ALGO = -6, /** * Too large (>64 KiB) Authorization parameter value. */ MHD_DAUTH_TOO_LARGE = -15, /* The different form of naming is intentionally used for the results below, * as they are more important */ /** * The 'nonce' is too old. Suggest the client to retry with the same * username and password to get the fresh 'nonce'. * The validity of the 'nonce' may be not checked. */ MHD_DAUTH_NONCE_STALE = -17, /** * The 'nonce' was generated by MHD for other conditions. * This value is only returned if #MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE * is set to anything other than #MHD_DAUTH_BIND_NONCE_NONE. * The interpretation of this code could be different. For example, if * #MHD_DAUTH_BIND_NONCE_URI is set and client just used the same 'nonce' for * another URI, the code could be handled as #MHD_DAUTH_NONCE_STALE as * RFCs allow nonces re-using for other URIs in the same "protection * space". However, if only #MHD_DAUTH_BIND_NONCE_CLIENT_IP bit is set and * it is know that clients have fixed IP addresses, this return code could * be handled like #MHD_DAUTH_NONCE_WRONG. */ MHD_DAUTH_NONCE_OTHER_COND = -18, /** * The 'nonce' is wrong. May indicate an attack attempt. */ MHD_DAUTH_NONCE_WRONG = -33, /** * The 'response' is wrong. Typically it means that wrong password used. * May indicate an attack attempt. */ MHD_DAUTH_RESPONSE_WRONG = -34 }; /** * Authenticates the authorization header sent by the client. * * If RFC2069 mode is allowed by setting bit #MHD_DIGEST_AUTH_QOP_NONE in * @a mqop and the client uses this mode, then server generated nonces are * used as one-time nonces because nonce-count is not supported in this old RFC. * Communication in this mode is very inefficient, especially if the client * requests several resources one-by-one as for every request a new nonce must * be generated and client repeats all requests twice (first time to get a new * nonce and second time to perform an authorised request). * * @param connection the MHD connection structure * @param realm the realm for authorization of the client * @param username the username to be authenticated, must be in clear text * even if userhash is used by the client * @param password the password matching the @a username (and the @a realm) * @param nonce_timeout the period of seconds since nonce generation, when * the nonce is recognised as valid and not stale; * if zero is specified then daemon default value is used. * @param max_nc the maximum allowed nc (Nonce Count) value, if client's nc * exceeds the specified value then MHD_DAUTH_NONCE_STALE is * returned; * if zero is specified then daemon default value is used. * @param mqop the QOP to use * @param malgo3 digest algorithms allowed to use, fail if algorithm used * by the client is not allowed by this parameter * @return #MHD_DAUTH_OK if authenticated, * the error code otherwise * @note Available since #MHD_VERSION 0x00097708 * @ingroup authentication */ _MHD_EXTERN enum MHD_DigestAuthResult MHD_digest_auth_check3 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3); /** * Calculate userdigest, return it as a binary data. * * The "userdigest" is the hash of the "username:realm:password" string. * * The "userdigest" can be used to avoid storing the password in clear text * in database/files * * This function is designed to improve security of stored credentials, * the "userdigest" does not improve security of the authentication process. * * The results can be used to store username & userdigest pairs instead of * username & password pairs. To further improve security, application may * store username & userhash & userdigest triplets. * * @param algo3 the digest algorithm * @param username the username * @param realm the realm * @param password the password * @param[out] userdigest_bin the output buffer for userdigest; * if this function succeeds, then this buffer has * #MHD_digest_get_hash_size(algo3) bytes of * userdigest upon return * @param bin_buf_size the size of the @a userdigest_bin buffer, must be * at least #MHD_digest_get_hash_size(algo3) bytes long * @return MHD_YES on success, * MHD_NO if @a userdigest_bin is too small or if @a algo3 algorithm is * not supported (or external error has occurred, * see #MHD_FEATURE_EXTERN_HASH). * @sa #MHD_digest_auth_check_digest3() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userdigest (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, const char *password, void *userdigest_bin, size_t bin_buf_size); /** * Authenticates the authorization header sent by the client by using * hash of "username:realm:password". * * If RFC2069 mode is allowed by setting bit #MHD_DIGEST_AUTH_QOP_NONE in * @a mqop and the client uses this mode, then server generated nonces are * used as one-time nonces because nonce-count is not supported in this old RFC. * Communication in this mode is very inefficient, especially if the client * requests several resources one-by-one as for every request a new nonce must * be generated and client repeats all requests twice (first time to get a new * nonce and second time to perform an authorised request). * * @param connection the MHD connection structure * @param realm the realm for authorization of the client * @param username the username to be authenticated, must be in clear text * even if userhash is used by the client * @param userdigest the precalculated binary hash of the string * "username:realm:password", * see #MHD_digest_auth_calc_userdigest() * @param userdigest_size the size of the @a userdigest in bytes, must match the * hashing algorithm (see #MHD_MD5_DIGEST_SIZE, * #MHD_SHA256_DIGEST_SIZE, #MHD_SHA512_256_DIGEST_SIZE, * #MHD_digest_get_hash_size()) * @param nonce_timeout the period of seconds since nonce generation, when * the nonce is recognised as valid and not stale; * if zero is specified then daemon default value is used. * @param max_nc the maximum allowed nc (Nonce Count) value, if client's nc * exceeds the specified value then MHD_DAUTH_NONCE_STALE is * returned; * if zero is specified then daemon default value is used. * @param mqop the QOP to use * @param malgo3 digest algorithms allowed to use, fail if algorithm used * by the client is not allowed by this parameter; * more than one base algorithms (MD5, SHA-256, SHA-512/256) * cannot be used at the same time for this function * as @a userdigest must match specified algorithm * @return #MHD_DAUTH_OK if authenticated, * the error code otherwise * @sa #MHD_digest_auth_calc_userdigest() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN enum MHD_DigestAuthResult MHD_digest_auth_check_digest3 (struct MHD_Connection *connection, const char *realm, const char *username, const void *userdigest, size_t userdigest_size, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3); /** * Queues a response to request authentication from the client * * This function modifies provided @a response. The @a response must not be * reused and should be destroyed (by #MHD_destroy_response()) after call of * this function. * * If @a mqop allows both RFC 2069 (MHD_DIGEST_AUTH_QOP_NONE) and QOP with * value, then response is formed like if MHD_DIGEST_AUTH_QOP_NONE bit was * not set, because such response should be backward-compatible with RFC 2069. * * If @a mqop allows only MHD_DIGEST_AUTH_MULT_QOP_NONE, then the response is * formed in strict accordance with RFC 2069 (no 'qop', no 'userhash', no * 'charset'). For better compatibility with clients, it is recommended (but * not required) to set @a domain to NULL in this mode. * * @param connection the MHD connection structure * @param realm the realm presented to the client * @param opaque the string for opaque value, can be NULL, but NULL is * not recommended for better compatibility with clients; * the recommended format is hex or Base64 encoded string * @param domain the optional space-separated list of URIs for which the * same authorisation could be used, URIs can be in form * "path-absolute" (the path for the same host with initial slash) * or in form "absolute-URI" (the full path with protocol), in * any case client may assume that URI is in the same "protection * space" if it starts with any of values specified here; * could be NULL (clients typically assume that the same * credentials could be used for any URI on the same host); * this list provides information for the client only and does * not actually restrict anything on the server side * @param response the reply to send; should contain the "access denied" * body; * note: this function sets the "WWW Authenticate" header and * the caller should not set this header; * the NULL is tolerated * @param signal_stale if set to #MHD_YES then indication of stale nonce used in * the client's request is signalled by adding 'stale=true' * to the authentication header, this instructs the client * to retry immediately with the new nonce and the same * credentials, without asking user for the new password * @param mqop the QOP to use * @param malgo3 digest algorithm to use; if several algorithms are allowed * then MD5 is preferred (currently, may be changed in next * versions) * @param userhash_support if set to non-zero value (#MHD_YES) then support of * userhash is indicated, allowing client to provide * hash("username:realm") instead of the username in * clear text; * note that clients are allowed to provide the username * in cleartext even if this parameter set to non-zero; * when userhash is used, application must be ready to * identify users by provided userhash value instead of * username; see #MHD_digest_auth_calc_userhash() and * #MHD_digest_auth_calc_userhash_hex() * @param prefer_utf8 if not set to #MHD_NO, parameter 'charset=UTF-8' is * added, indicating for the client that UTF-8 encoding for * the username is preferred * @return #MHD_YES on success, #MHD_NO otherwise * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_queue_auth_required_response3 (struct MHD_Connection *connection, const char *realm, const char *opaque, const char *domain, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 algo, int userhash_support, int prefer_utf8); /** * Constant to indicate that the nonce of the provided * authentication code was wrong. * Used as return code by #MHD_digest_auth_check(), #MHD_digest_auth_check2(), * #MHD_digest_auth_check_digest(), #MHD_digest_auth_check_digest2(). * @ingroup authentication */ #define MHD_INVALID_NONCE -1 /** * Get the username from the authorization header sent by the client * * This function supports username in standard and extended notations. * "userhash" is not supported by this function. * * @param connection The MHD connection structure * @return NULL if no username could be found, username provided as * "userhash", extended notation broken or memory allocation error * occurs; * a pointer to the username if found, free using #MHD_free(). * @warning Returned value must be freed by #MHD_free(). * @sa #MHD_digest_auth_get_username3() * @ingroup authentication */ _MHD_EXTERN char * MHD_digest_auth_get_username (struct MHD_Connection *connection); /** * Which digest algorithm should MHD use for HTTP digest authentication? * Used as parameter for #MHD_digest_auth_check2(), * #MHD_digest_auth_check_digest2(), #MHD_queue_auth_fail_response2(). */ enum MHD_DigestAuthAlgorithm { /** * MHD should pick (currently defaults to MD5). */ MHD_DIGEST_ALG_AUTO = 0, /** * Force use of MD5. */ MHD_DIGEST_ALG_MD5, /** * Force use of SHA-256. */ MHD_DIGEST_ALG_SHA256 } _MHD_FIXED_ENUM; /** * Authenticates the authorization header sent by the client. * * @param connection The MHD connection structure * @param realm The realm presented to the client * @param username The username needs to be authenticated * @param password The password used in the authentication * @param nonce_timeout The amount of time for a nonce to be * invalid in seconds * @param algo digest algorithms allowed for verification * @return #MHD_YES if authenticated, #MHD_NO if not, * #MHD_INVALID_NONCE if nonce is invalid or stale * @note Available since #MHD_VERSION 0x00096200 * @deprecated use MHD_digest_auth_check3() * @ingroup authentication */ _MHD_EXTERN int MHD_digest_auth_check2 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo); /** * Authenticates the authorization header sent by the client. * Uses #MHD_DIGEST_ALG_MD5 (for now, for backwards-compatibility). * Note that this MAY change to #MHD_DIGEST_ALG_AUTO in the future. * If you want to be sure you get MD5, use #MHD_digest_auth_check2() * and specify MD5 explicitly. * * @param connection The MHD connection structure * @param realm The realm presented to the client * @param username The username needs to be authenticated * @param password The password used in the authentication * @param nonce_timeout The amount of time for a nonce to be * invalid in seconds * @return #MHD_YES if authenticated, #MHD_NO if not, * #MHD_INVALID_NONCE if nonce is invalid or stale * @deprecated use MHD_digest_auth_check3() * @ingroup authentication */ _MHD_EXTERN int MHD_digest_auth_check (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout); /** * Authenticates the authorization header sent by the client. * * @param connection The MHD connection structure * @param realm The realm presented to the client * @param username The username needs to be authenticated * @param digest An `unsigned char *' pointer to the binary MD5 sum * for the precalculated hash value "username:realm:password" * of @a digest_size bytes * @param digest_size number of bytes in @a digest (size must match @a algo!) * @param nonce_timeout The amount of time for a nonce to be * invalid in seconds * @param algo digest algorithms allowed for verification * @return #MHD_YES if authenticated, #MHD_NO if not, * #MHD_INVALID_NONCE if nonce is invalid or stale * @note Available since #MHD_VERSION 0x00096200 * @deprecated use MHD_digest_auth_check_digest3() * @ingroup authentication */ _MHD_EXTERN int MHD_digest_auth_check_digest2 (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t *digest, size_t digest_size, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo); /** * Authenticates the authorization header sent by the client * Uses #MHD_DIGEST_ALG_MD5 (required, as @a digest is of fixed * size). * * @param connection The MHD connection structure * @param realm The realm presented to the client * @param username The username needs to be authenticated * @param digest An `unsigned char *' pointer to the binary hash * for the precalculated hash value "username:realm:password"; * length must be #MHD_MD5_DIGEST_SIZE bytes * @param nonce_timeout The amount of time for a nonce to be * invalid in seconds * @return #MHD_YES if authenticated, #MHD_NO if not, * #MHD_INVALID_NONCE if nonce is invalid or stale * @note Available since #MHD_VERSION 0x00096000 * @deprecated use #MHD_digest_auth_check_digest3() * @ingroup authentication */ _MHD_EXTERN int MHD_digest_auth_check_digest (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t digest[MHD_MD5_DIGEST_SIZE], unsigned int nonce_timeout); /** * Queues a response to request authentication from the client * * This function modifies provided @a response. The @a response must not be * reused and should be destroyed after call of this function. * * @param connection The MHD connection structure * @param realm the realm presented to the client * @param opaque string to user for opaque value * @param response reply to send; should contain the "access denied" * body; note that this function will set the "WWW Authenticate" * header and that the caller should not do this; the NULL is tolerated * @param signal_stale #MHD_YES if the nonce is stale to add * 'stale=true' to the authentication header * @param algo digest algorithm to use * @return #MHD_YES on success, #MHD_NO otherwise * @note Available since #MHD_VERSION 0x00096200 * @deprecated use MHD_queue_auth_required_response3() * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response2 (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthAlgorithm algo); /** * Queues a response to request authentication from the client. * For now uses MD5 (for backwards-compatibility). Still, if you * need to be sure, use #MHD_queue_auth_fail_response2(). * * This function modifies provided @a response. The @a response must not be * reused and should be destroyed after call of this function. * * @param connection The MHD connection structure * @param realm the realm presented to the client * @param opaque string to user for opaque value * @param response reply to send; should contain the "access denied" * body; note that this function will set the "WWW Authenticate" * header and that the caller should not do this; the NULL is tolerated * @param signal_stale #MHD_YES if the nonce is stale to add * 'stale=true' to the authentication header * @return #MHD_YES on success, #MHD_NO otherwise * @deprecated use MHD_queue_auth_required_response3() * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale); /* ********************* Basic Authentication functions *************** */ /** * Information decoded from Basic Authentication client's header. * * The username and the password are technically allowed to have binary zeros, * username_len and password_len could be used to detect such situations. * * The buffers pointed by username and password members are freed * when #MHD_free() is called for pointer to this structure. * * Application may modify buffers as needed until #MHD_free() is called for * pointer to this structure */ struct MHD_BasicAuthInfo { /** * The username, cannot be NULL. * The buffer pointed by the @a username becomes invalid when the pointer * to the structure is freed by #MHD_free(). */ char *username; /** * The length of the @a username, not including zero-termination */ size_t username_len; /** * The password, may be NULL if password is not encoded by the client. * The buffer pointed by the @a password becomes invalid when the pointer * to the structure is freed by #MHD_free(). */ char *password; /** * The length of the @a password, not including zero-termination; * when the @a password is NULL, the length is always zero. */ size_t password_len; }; /** * Get the username and password from the Basic Authorisation header * sent by the client * * @param connection the MHD connection structure * @return NULL if no valid Basic Authentication header is present in * current request, or * pointer to structure with username and password, which must be * freed by #MHD_free(). * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN struct MHD_BasicAuthInfo * MHD_basic_auth_get_username_password3 (struct MHD_Connection *connection); /** * Queues a response to request basic authentication from the client. * * The given response object is expected to include the payload for * the response; the "WWW-Authenticate" header will be added and the * response queued with the 'UNAUTHORIZED' status code. * * See RFC 7617#section-2 for details. * * The @a response is modified by this function. The modified response object * can be used to respond subsequent requests by #MHD_queue_response() * function with status code #MHD_HTTP_UNAUTHORIZED and must not be used again * with MHD_queue_basic_auth_required_response3() function. The response could * be destroyed right after call of this function. * * @param connection the MHD connection structure * @param realm the realm presented to the client * @param prefer_utf8 if not set to #MHD_NO, parameter'charset="UTF-8"' will * be added, indicating for client that UTF-8 encoding * is preferred * @param response the response object to modify and queue; the NULL * is tolerated * @return #MHD_YES on success, #MHD_NO otherwise * @note Available since #MHD_VERSION 0x00097704 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_queue_basic_auth_required_response3 (struct MHD_Connection *connection, const char *realm, int prefer_utf8, struct MHD_Response *response); /** * Get the username and password from the basic authorization header sent by the client * * @param connection The MHD connection structure * @param[out] password a pointer for the password, free using #MHD_free(). * @return NULL if no username could be found, a pointer * to the username if found, free using #MHD_free(). * @deprecated use #MHD_basic_auth_get_username_password3() * @ingroup authentication */ _MHD_EXTERN char * MHD_basic_auth_get_username_password (struct MHD_Connection *connection, char **password); /** * Queues a response to request basic authentication from the client * The given response object is expected to include the payload for * the response; the "WWW-Authenticate" header will be added and the * response queued with the 'UNAUTHORIZED' status code. * * @param connection The MHD connection structure * @param realm the realm presented to the client * @param response response object to modify and queue; the NULL is tolerated * @return #MHD_YES on success, #MHD_NO otherwise * @deprecated use MHD_queue_basic_auth_required_response3() * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, const char *realm, struct MHD_Response *response); /* ********************** generic query functions ********************** */ /** * Obtain information about the given connection. * The returned pointer is invalidated with the next call of this function or * when the connection is closed. * * @param connection what connection to get information about * @param info_type what information is desired? * @param ... depends on @a info_type * @return NULL if this information is not available * (or if the @a info_type is unknown) * @ingroup specialized */ _MHD_EXTERN const union MHD_ConnectionInfo * MHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type, ...); /** * MHD connection options. Given to #MHD_set_connection_option to * set custom options for a particular connection. */ enum MHD_CONNECTION_OPTION { /** * Set a custom timeout for the given connection. Specified * as the number of seconds, given as an `unsigned int`. Use * zero for no timeout. * If timeout was set to zero (or unset) before, setup of new value by * MHD_set_connection_option() will reset timeout timer. * Values larger than (UINT64_MAX / 2000 - 1) will * be clipped to this number. */ MHD_CONNECTION_OPTION_TIMEOUT } _MHD_FIXED_ENUM; /** * Set a custom option for the given connection, overriding defaults. * * @param connection connection to modify * @param option option to set * @param ... arguments to the option, depending on the option type * @return #MHD_YES on success, #MHD_NO if setting the option failed * @ingroup specialized */ _MHD_EXTERN enum MHD_Result MHD_set_connection_option (struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option, ...); /** * Information about an MHD daemon. */ union MHD_DaemonInfo { /** * Size of the key, no longer supported. * @deprecated */ size_t key_size; /** * Size of the mac key, no longer supported. * @deprecated */ size_t mac_key_size; /** * Socket, returned for #MHD_DAEMON_INFO_LISTEN_FD. */ MHD_socket listen_fd; /** * Bind port number, returned for #MHD_DAEMON_INFO_BIND_PORT. */ uint16_t port; /** * epoll FD, returned for #MHD_DAEMON_INFO_EPOLL_FD. */ int epoll_fd; /** * Number of active connections, for #MHD_DAEMON_INFO_CURRENT_CONNECTIONS. */ unsigned int num_connections; /** * Combination of #MHD_FLAG values, for #MHD_DAEMON_INFO_FLAGS. * This value is actually a bitfield. * Note: flags may differ from original 'flags' specified for * daemon, especially if #MHD_USE_AUTO was set. */ enum MHD_FLAG flags; }; /** * Obtain information about the given daemon. * The returned pointer is invalidated with the next call of this function or * when the daemon is stopped. * * @param daemon what daemon to get information about * @param info_type what information is desired? * @param ... depends on @a info_type * @return NULL if this information is not available * (or if the @a info_type is unknown) * @ingroup specialized */ _MHD_EXTERN const union MHD_DaemonInfo * MHD_get_daemon_info (struct MHD_Daemon *daemon, enum MHD_DaemonInfoType info_type, ...); /** * Obtain the version of this library * * @return static version string, e.g. "0.9.9" * @ingroup specialized */ _MHD_EXTERN const char * MHD_get_version (void); /** * Obtain the version of this library as a binary value. * * @return version binary value, e.g. "0x00090900" (#MHD_VERSION of * compiled MHD binary) * @note Available since #MHD_VERSION 0x00097601 * @ingroup specialized */ _MHD_EXTERN uint32_t MHD_get_version_bin (void); /** * Types of information about MHD features, * used by #MHD_is_feature_supported(). */ enum MHD_FEATURE { /** * Get whether messages are supported. If supported then in debug * mode messages can be printed to stderr or to external logger. */ MHD_FEATURE_MESSAGES = 1, /** * Get whether HTTPS is supported. If supported then flag * #MHD_USE_TLS and options #MHD_OPTION_HTTPS_MEM_KEY, * #MHD_OPTION_HTTPS_MEM_CERT, #MHD_OPTION_HTTPS_MEM_TRUST, * #MHD_OPTION_HTTPS_MEM_DHPARAMS, #MHD_OPTION_HTTPS_CRED_TYPE, * #MHD_OPTION_HTTPS_PRIORITIES can be used. */ MHD_FEATURE_TLS = 2, MHD_FEATURE_SSL = 2, /** * Get whether option #MHD_OPTION_HTTPS_CERT_CALLBACK is * supported. */ MHD_FEATURE_HTTPS_CERT_CALLBACK = 3, /** * Get whether IPv6 is supported. If supported then flag * #MHD_USE_IPv6 can be used. */ MHD_FEATURE_IPv6 = 4, /** * Get whether IPv6 without IPv4 is supported. If not supported * then IPv4 is always enabled in IPv6 sockets and * flag #MHD_USE_DUAL_STACK is always used when #MHD_USE_IPv6 is * specified. */ MHD_FEATURE_IPv6_ONLY = 5, /** * Get whether `poll()` is supported. If supported then flag * #MHD_USE_POLL can be used. */ MHD_FEATURE_POLL = 6, /** * Get whether `epoll()` is supported. If supported then Flags * #MHD_USE_EPOLL and * #MHD_USE_EPOLL_INTERNAL_THREAD can be used. */ MHD_FEATURE_EPOLL = 7, /** * Get whether shutdown on listen socket to signal other * threads is supported. If not supported flag * #MHD_USE_ITC is automatically forced. */ MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET = 8, /** * Get whether socketpair is used internally instead of pipe to * signal other threads. */ MHD_FEATURE_SOCKETPAIR = 9, /** * Get whether TCP Fast Open is supported. If supported then * flag #MHD_USE_TCP_FASTOPEN and option * #MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE can be used. */ MHD_FEATURE_TCP_FASTOPEN = 10, /** * Get whether HTTP Basic authorization is supported. If supported * then functions #MHD_basic_auth_get_username_password and * #MHD_queue_basic_auth_fail_response can be used. */ MHD_FEATURE_BASIC_AUTH = 11, /** * Get whether HTTP Digest authorization is supported. If * supported then options #MHD_OPTION_DIGEST_AUTH_RANDOM, * #MHD_OPTION_NONCE_NC_SIZE and * #MHD_digest_auth_check() can be used. */ MHD_FEATURE_DIGEST_AUTH = 12, /** * Get whether postprocessor is supported. If supported then * functions #MHD_create_post_processor(), #MHD_post_process() and * #MHD_destroy_post_processor() can * be used. */ MHD_FEATURE_POSTPROCESSOR = 13, /** * Get whether password encrypted private key for HTTPS daemon is * supported. If supported then option * ::MHD_OPTION_HTTPS_KEY_PASSWORD can be used. */ MHD_FEATURE_HTTPS_KEY_PASSWORD = 14, /** * Get whether reading files beyond 2 GiB boundary is supported. * If supported then #MHD_create_response_from_fd(), * #MHD_create_response_from_fd64 #MHD_create_response_from_fd_at_offset() * and #MHD_create_response_from_fd_at_offset64() can be used with sizes and * offsets larger than 2 GiB. If not supported value of size+offset is * limited to 2 GiB. */ MHD_FEATURE_LARGE_FILE = 15, /** * Get whether MHD set names on generated threads. */ MHD_FEATURE_THREAD_NAMES = 16, MHD_THREAD_NAMES = 16, /** * Get whether HTTP "Upgrade" is supported. * If supported then #MHD_ALLOW_UPGRADE, #MHD_upgrade_action() and * #MHD_create_response_for_upgrade() can be used. */ MHD_FEATURE_UPGRADE = 17, /** * Get whether it's safe to use same FD for multiple calls of * #MHD_create_response_from_fd() and whether it's safe to use single * response generated by #MHD_create_response_from_fd() with multiple * connections at same time. * If #MHD_is_feature_supported() return #MHD_NO for this feature then * usage of responses with same file FD in multiple parallel threads may * results in incorrect data sent to remote client. * It's always safe to use same file FD in multiple responses if MHD * is run in any single thread mode. */ MHD_FEATURE_RESPONSES_SHARED_FD = 18, /** * Get whether MHD support automatic detection of bind port number. * @sa #MHD_DAEMON_INFO_BIND_PORT */ MHD_FEATURE_AUTODETECT_BIND_PORT = 19, /** * Get whether MHD supports automatic SIGPIPE suppression. * If SIGPIPE suppression is not supported, application must handle * SIGPIPE signal by itself. */ MHD_FEATURE_AUTOSUPPRESS_SIGPIPE = 20, /** * Get whether MHD use system's sendfile() function to send * file-FD based responses over non-TLS connections. * @note Since v0.9.56 */ MHD_FEATURE_SENDFILE = 21, /** * Get whether MHD supports threads. */ MHD_FEATURE_THREADS = 22, /** * Get whether option #MHD_OPTION_HTTPS_CERT_CALLBACK2 is * supported. */ MHD_FEATURE_HTTPS_CERT_CALLBACK2 = 23, /** * Get whether automatic parsing of HTTP Cookie header is supported. * If disabled, no MHD_COOKIE_KIND will be generated by MHD. * MHD versions before 0x00097701 always support cookie parsing. * @note Available since #MHD_VERSION 0x00097701 */ MHD_FEATURE_HTTPS_COOKIE_PARSING = 24, /** * Get whether the early version the Digest Authorization (RFC 2069) is * supported (digest authorisation without QOP parameter). * Since #MHD_VERSION 0x00097701 it is always supported if Digest Auth * module is built. * @note Available since #MHD_VERSION 0x00097701 */ MHD_FEATURE_DIGEST_AUTH_RFC2069 = 25, /** * Get whether the MD5-based hashing algorithms are supported for Digest * Authorization. * Currently it is always supported if Digest Auth module is built * unless manually disabled in a custom build. * @note Available since #MHD_VERSION 0x00097701 */ MHD_FEATURE_DIGEST_AUTH_MD5 = 26, /** * Get whether the SHA-256-based hashing algorithms are supported for Digest * Authorization. * It is always supported since #MHD_VERSION 0x00096200 if Digest Auth * module is built unless manually disabled in a custom build. * @note Available since #MHD_VERSION 0x00097701 */ MHD_FEATURE_DIGEST_AUTH_SHA256 = 27, /** * Get whether the SHA-512/256-based hashing algorithms are supported * for Digest Authorization. * It it always supported since #MHD_VERSION 0x00097701 if Digest Auth * module is built unless manually disabled in a custom build. * @note Available since #MHD_VERSION 0x00097701 */ MHD_FEATURE_DIGEST_AUTH_SHA512_256 = 28, /** * Get whether QOP with value 'auth-int' (authentication with integrity * protection) is supported for Digest Authorization. * Currently it is always not supported. * @note Available since #MHD_VERSION 0x00097701 */ MHD_FEATURE_DIGEST_AUTH_AUTH_INT = 29, /** * Get whether 'session' algorithms (like 'MD5-sess') are supported for Digest * Authorization. * Currently it is always not supported. * @note Available since #MHD_VERSION 0x00097701 */ MHD_FEATURE_DIGEST_AUTH_ALGO_SESSION = 30, /** * Get whether 'userhash' is supported for Digest Authorization. * It is always supported since #MHD_VERSION 0x00097701 if Digest Auth * module is built. * @note Available since #MHD_VERSION 0x00097701 */ MHD_FEATURE_DIGEST_AUTH_USERHASH = 31, /** * Get whether any of hashing algorithms is implemented by external * function (like TLS library) and may fail due to external conditions, * like "out-of-memory". * * If result is #MHD_YES then functions which use hash calculations * like #MHD_digest_auth_calc_userhash(), #MHD_digest_auth_check3() and others * potentially may fail even with valid input because of out-of-memory error * or crypto accelerator device failure, however in practice such fails are * unlikely. * @note Available since #MHD_VERSION 0x00097701 */ MHD_FEATURE_EXTERN_HASH = 32, /** * Get whether MHD was built with asserts enabled. * For debug builds the error log is always enabled even if #MHD_USE_ERROR_LOG * is not specified for daemon. * @note Available since #MHD_VERSION 0x00097701 */ MHD_FEATURE_DEBUG_BUILD = 33, /** * Get whether MHD was build with support for overridable FD_SETSIZE. * This feature should be always available when the relevant platform ability * is detected. * @sa #MHD_OPTION_APP_FD_SETSIZE * @note Available since #MHD_VERSION 0x00097705 */ MHD_FEATURE_FLEXIBLE_FD_SETSIZE = 34 }; /** * Get information about supported MHD features. * Indicate that MHD was compiled with or without support for * particular feature. Some features require additional support * by kernel. Kernel support is not checked by this function. * * @param feature type of requested information * @return #MHD_YES if feature is supported by MHD, #MHD_NO if * feature is not supported or feature is unknown. * @ingroup specialized */ _MHD_EXTERN enum MHD_Result MHD_is_feature_supported (enum MHD_FEATURE feature); #ifdef __cplusplus #if 0 /* keep Emacsens' auto-indent happy */ { #endif } #endif #endif libmicrohttpd-1.0.1/src/include/microhttpd2.h0000644000175000017500000041454714555767064014722 /* This file is part of libmicrohttpd Copyright (C) 2006-2018 Christian Grothoff, Karlson2k (Evgeny Grin) (and other contributing authors) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * Just includes the NEW definitions for the NG-API. * Note that we do not indicate which of the OLD APIs * simply need to be kept vs. deprecated. * * * The goal is to provide a basis for discussion! * Little of this is implemented yet. * * Main goals: * - simplify application callbacks by splitting header/upload/post * functionality currently provided by calling the same * MHD_AccessHandlerCallback 3+ times into separate callbacks. * - keep the API very simple for simple requests, but allow * more complex logic to be incrementally introduced * (via new struct MHD_Action construction) * - avoid repeated scans for URL matches via the new * struct MHD_Action construction * - provide default logarithmic implementation of URL scan * => reduce strcmp(url) from >= 3n operations to "log n" * per request. * - better types, in particular avoid varargs for options * - make it harder to pass inconsistent options * - combine options and flags into more uniform API (at least * exterally!) * - simplify API use by using sane defaults (benefiting from * breaking backwards compatibility) and making all options * really optional, and where applicable avoid having options * where the default works if nothing is specified * - simplify API by moving rarely used http_version into * MHD_request_get_information() * - avoid 'int' for MHD_YES/MHD_NO by introducing `enum MHD_Bool` * - improve terminology by eliminating confusion between * 'request' and 'connection' * - prepare API for having multiple TLS backends * - use more consistent prefixes for related functions * by using MHD_subject_verb_object naming convention, also * at the same time avoid symbol conflict with legacy names * (so we can have one binary implementing old and new * library API at the same time via compatibility layer). * - make it impossible to queue a response at the wrong time * - make it impossible to suspend a connection/request at the * wrong time (improves thread-safety) * - make it clear which response status codes are "properly" * supported (include the descriptive string) by using an enum; * - simplify API for common-case of one-shot responses by * eliminating need for destroy response in most cases; * * NEW-EG: * - avoid fixed types, like uint32_t. They may not exist on some * platforms. Instead use uint_fast32_t. * It is also better for future-proof. * - check portability for embedded platforms. Some of them support * 64 bits, but 'int' could be just 16 bits resulting of silently * dropping enum values higher than 65535. * => in general, more functions, fewer enums for setup * * - Avoid returning pointers to internal members. It is not thread-safe and * even in single thread the value could change over the time. Prefer pointers to * app-allocated memory with the size, like MHD_daemon_get_static_info(enum * MHD_enum_name info_type, void *buf, size_t buf_size). * => Except in cases where zero-copy matters. * * - Use separate app calls/functions for data the will not change for the * lifetime of the object and dynamic data. The only difference should be the * name. Like MHD_daemon_get_static_info(enum MHD_enum_name info_type, void *buf, * size_t buf_size) MHD_daemon_get_dynamic_info(enum MHD_enum_name info_type, * void *buf, size_t buf_size) Examples of static data: listen socket, number of * workers, daemon flags. Examples of dynamic data: number of connections, * quiesce status. It should give a clear idea whether the data could be changed * over the time (could be not obvious for some data) and thus may change the * approach how to use the data in app. The same for: library, daemon, * connection, request. Not sure that dynamic data makes sense for the library. * * - Use clear separation between connection and request. Do not mix the kind * data in the callbacks. Currently we are mixing things in * MHD_AccessHandlerCallback and MHD_RequestCompletedCallback. Instead of * pointers to struct MHD_Connection we should use pointers to (new) struct * MHD_Request. Probably some other functions are mixing the things as well, to * be re-checked. * * - Define default response code in response object. There are a very little * chance that response body designed for 404 or 403 codes will be used with * 200 code. However, the responses body for 307 and 308 could be the same. So: * * add default response code in response object. Use zero for default 200. * * When app sending the response use zero for response's default code or * use specific code to override response's default value. * * - Make responses unmodifiable after first use. It is not thread-safe. * MHD-generated headers (Date, Connection/Keep-Alive) are again * part of the *request* and do not count as part of the "response" here. * * - Remove "footers" from responses. With unmodifiable responses everything should be "headers". * Add footers to *requests* instead. * * - Add API for adding request-specific response headers and footers. To * simplify the things it should just copy the strings (to avoid dealing with * complicated deinit of possible dynamic strings). After this change it should * be possible to simplify DAuth handling as response could be reused (currently * 403 responses are modified for each reply). * * - Control response behaviour mainly by response flags, not by additional * headers (like MHD_RF_FORCE_CLOSE instead of "Connection: close"). * It is easier for both: app and MHD. * * - Move response codes from MHD_HTTP_xxx namespace to MHD_HTTP_CODE_xxx * namespace. It already may clash with other HTTP values. * * - plus other things that was discussed already, like avoiding extra calls * for body-less requests. I assume it should be resolved with fundamental * re-design of request/response cycle handling. * * - Internals: carefully check where locking is really required. Probably * separate locks. Check out-of-thread value reading. Currently code assumes * atomic reading of values used in other threads, which mostly true on x86, * but not OK on other arches. Probably use read/write locking to minimize * the threads interference. * * - figure out how to do portable variant of cork/uncork * * NEW-CG: * - Postprocessor is unusable night-mare when doing "stream processing" * for tiny values where the application basically has to copy together * the stream back into a single compact heap value, just making the * parsing highly more complicated (see examples in Challenger) * * - non-stream processing variant for request bodies, give apps a * way to request the full body in one buffer; give apps a way * to request a 'large new allocation' for such buffers; give apps * a way to specify a global quota for large allocations to ensure * memory usage has a hard bound * * - remove request data from memory pool when response is queued * (IF no callbacks and thus data cannot be used anymore, or IF * application permits explictly per daemon) to get more space * for building response; * * * TODO: * - varargs in upgrade is still there and ugly (and not even used!) * - migrate event loop apis (get fdset, timeout, MHD_run(), etc.) */ #ifndef MICROHTTPD2_H #define MICROHTTPD2_H #ifdef __cplusplus extern "C" { #if 0 /* keep Emacsens' auto-indent happy */ } #endif #endif /* While we generally would like users to use a configure-driven build process which detects which headers are present and hence works on any platform, we use "standard" includes here to build out-of-the-box for beginning users on common systems. If generic headers don't work on your platform, include headers which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'uint16_t', 'uint32_t', 'uint64_t', 'off_t', 'struct sockaddr', 'socklen_t', 'fd_set' and "#define MHD_PLATFORM_H" before including "microhttpd.h". Then the following "standard" includes won't be used (which might be a good idea, especially on platforms where they do not exist). */ #ifndef MHD_PLATFORM_H #include #include #include #if defined(_WIN32) && ! defined(__CYGWIN__) #include #if defined(_MSC_FULL_VER) && ! defined(_SSIZE_T_DEFINED) #define _SSIZE_T_DEFINED typedef intptr_t ssize_t; #endif /* !_SSIZE_T_DEFINED */ #else #include #include #include #endif #endif #if defined(__CYGWIN__) && ! defined(_SYS_TYPES_FD_SET) /* Do not define __USE_W32_SOCKETS under Cygwin! */ #error Cygwin with winsock fd_set is not supported #endif /** * Current version of the library. * 0x01093001 = 1.9.30-1. */ #define MHD_VERSION 0x01000000 /** * Representation of 'bool' in the public API as stdbool.h may not * always be available. */ enum MHD_Bool { /** * MHD-internal return code for "NO". */ MHD_NO = 0, /** * MHD-internal return code for "YES". All non-zero values * will be interpreted as "YES", but MHD will only ever * return #MHD_YES or #MHD_NO. */ MHD_YES = 1 }; /** * Constant used to indicate unknown size (use when * creating a response). */ #ifdef UINT64_MAX #define MHD_SIZE_UNKNOWN UINT64_MAX #else #define MHD_SIZE_UNKNOWN ((uint64_t) -1LL) #endif #ifdef SIZE_MAX #define MHD_CONTENT_READER_END_OF_STREAM SIZE_MAX #define MHD_CONTENT_READER_END_WITH_ERROR (SIZE_MAX - 1) #else #define MHD_CONTENT_READER_END_OF_STREAM ((size_t) -1LL) #define MHD_CONTENT_READER_END_WITH_ERROR (((size_t) -1LL) - 1) #endif #ifndef _MHD_EXTERN #if defined(_WIN32) && defined(MHD_W32LIB) #define _MHD_EXTERN extern #elif defined(_WIN32) && defined(MHD_W32DLL) /* Define MHD_W32DLL when using MHD as W32 .DLL to speed up linker a little */ #define _MHD_EXTERN __declspec(dllimport) #else #define _MHD_EXTERN extern #endif #endif #ifndef MHD_SOCKET_DEFINED /** * MHD_socket is type for socket FDs */ #if ! defined(_WIN32) || defined(_SYS_TYPES_FD_SET) #define MHD_POSIX_SOCKETS 1 typedef int MHD_socket; #define MHD_INVALID_SOCKET (-1) #else /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */ #define MHD_WINSOCK_SOCKETS 1 #include typedef SOCKET MHD_socket; #define MHD_INVALID_SOCKET (INVALID_SOCKET) #endif /* !defined(_WIN32) || defined(_SYS_TYPES_FD_SET) */ #define MHD_SOCKET_DEFINED 1 #endif /* MHD_SOCKET_DEFINED */ /** * Define MHD_NO_DEPRECATION before including "microhttpd.h" to disable deprecation messages */ #ifdef MHD_NO_DEPRECATION #define _MHD_DEPR_MACRO(msg) #define _MHD_NO_DEPR_IN_MACRO 1 #define _MHD_DEPR_IN_MACRO(msg) #define _MHD_NO_DEPR_FUNC 1 #define _MHD_DEPR_FUNC(msg) #endif /* MHD_NO_DEPRECATION */ #ifndef _MHD_DEPR_MACRO #if defined(_MSC_FULL_VER) && _MSC_VER + 0 >= 1500 /* VS 2008 or later */ /* Stringify macros */ #define _MHD_INSTRMACRO(a) #a #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) /* deprecation message */ #define _MHD_DEPR_MACRO(msg) __pragma(message (__FILE__ "(" _MHD_STRMACRO ( \ __LINE__) "): warning: " msg)) #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO (msg) #elif defined(__clang__) || defined(__GNUC_PATCHLEVEL__) /* clang or GCC since 3.0 */ #define _MHD_GCC_PRAG(x) _Pragma(#x) #if (defined(__clang__) && (__clang_major__ + 0 >= 5 || \ (! defined(__apple_build_version__) && \ (__clang_major__ + 0 > 3 || (__clang_major__ + 0 == 3 && __clang_minor__ >= \ 3))))) || \ __GNUC__ + 0 > 4 || (__GNUC__ + 0 == 4 && __GNUC_MINOR__ + 0 >= 8) /* clang >= 3.3 (or XCode's clang >= 5.0) or GCC >= 4.8 */ #define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG (GCC warning msg) #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO (msg) #else /* older clang or GCC */ /* clang < 3.3, XCode's clang < 5.0, 3.0 <= GCC < 4.8 */ #define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG (message msg) #if (defined(__clang__) && (__clang_major__ + 0 > 2 || (__clang_major__ + 0 == \ 2 && __clang_minor__ >= \ 9))) /* FIXME: clang >= 2.9, earlier versions not tested */ /* clang handles inline pragmas better than GCC */ #define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO (msg) #endif /* clang >= 2.9 */ #endif /* older clang or GCC */ /* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */ #endif /* clang || GCC >= 3.0 */ #endif /* !_MHD_DEPR_MACRO */ #ifndef _MHD_DEPR_MACRO #define _MHD_DEPR_MACRO(msg) #endif /* !_MHD_DEPR_MACRO */ #ifndef _MHD_DEPR_IN_MACRO #define _MHD_NO_DEPR_IN_MACRO 1 #define _MHD_DEPR_IN_MACRO(msg) #endif /* !_MHD_DEPR_IN_MACRO */ #ifndef _MHD_DEPR_FUNC #if defined(_MSC_FULL_VER) && _MSC_VER + 0 >= 1400 /* VS 2005 or later */ #define _MHD_DEPR_FUNC(msg) __declspec(deprecated (msg)) #elif defined(_MSC_FULL_VER) && _MSC_VER + 0 >= 1310 /* VS .NET 2003 deprecation do not support custom messages */ #define _MHD_DEPR_FUNC(msg) __declspec(deprecated) #elif (__GNUC__ + 0 >= 5) || (defined(__clang__) && \ (__clang_major__ + 0 > 2 || (__clang_major__ + 0 == 2 && __clang_minor__ >= \ 9))) /* FIXME: earlier versions not tested */ /* GCC >= 5.0 or clang >= 2.9 */ #define _MHD_DEPR_FUNC(msg) __attribute__((deprecated (msg))) #elif defined(__clang__) || __GNUC__ + 0 > 3 || (__GNUC__ + 0 == 3 && \ __GNUC_MINOR__ + 0 >= 1) /* 3.1 <= GCC < 5.0 or clang < 2.9 */ /* old GCC-style deprecation do not support custom messages */ #define _MHD_DEPR_FUNC(msg) __attribute__((__deprecated__)) /* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */ #endif /* clang < 2.9 || GCC >= 3.1 */ #endif /* !_MHD_DEPR_FUNC */ #ifndef _MHD_DEPR_FUNC #define _MHD_NO_DEPR_FUNC 1 #define _MHD_DEPR_FUNC(msg) #endif /* !_MHD_DEPR_FUNC */ /* Define MHD_NONNULL attribute */ /** * Macro to indicate that certain parameters must be * non-null. Todo: port to non-gcc platforms. */ #if defined(__CYGWIN__) || defined(_WIN32) || defined(MHD_W32LIB) || \ defined(__clang__) || ! defined(__GNUC__) #define MHD_NONNULL(...) /* empty */ #else #define MHD_NONNULL(...) __THROW __nonnull ((__VA_ARGS__)) #endif /** * Not all architectures and `printf()`'s support the `long long` type. * This gives the ability to replace `long long` with just a `long`, * standard `int` or a `short`. */ #ifndef MHD_UNSIGNED_LONG_LONG #define MHD_UNSIGNED_LONG_LONG unsigned long long #endif /** * Format string for printing a variable of type #MHD_LONG_LONG. * You should only redefine this if you also define #MHD_LONG_LONG. */ #ifndef MHD_UNSIGNED_LONG_LONG_PRINTF #define MHD_UNSIGNED_LONG_LONG_PRINTF "%llu" #endif /** * @brief Handle for a connection / HTTP request. * * With HTTP/1.1, multiple requests can be run over the same * connection. However, MHD will only show one request per TCP * connection to the client at any given time. * * Replaces `struct MHD_Connection`, renamed to better reflect * what this object truly represents to the application using * MHD. * * @ingroup request */ struct MHD_Request; /** * A connection corresponds to the network/stream abstraction. * A single network (i.e. TCP) stream may be used for multiple * requests, which in HTTP/1.1 must be processed sequentially. */ struct MHD_Connection; /** * Return values for reporting errors, also used * for logging. * * A value of 0 indicates success (as a return value). * Values between 0 and 10000 must be handled explicitly by the app. * Values from 10000-19999 are informational. * Values from 20000-29999 indicate successful operations. * Values from 30000-39999 indicate unsuccessful (normal) operations. * Values from 40000-49999 indicate client errors. * Values from 50000-59999 indicate MHD server errors. * Values from 60000-69999 indicate application errors. */ enum MHD_StatusCode { /* 00000-level status codes indicate return values the application must act on. */ /** * Successful operation (not used for logging). */ MHD_SC_OK = 0, /** * We were asked to return a timeout, but, there is no timeout. */ MHD_SC_NO_TIMEOUT = 1, /* 10000-level status codes indicate intermediate results of some kind. */ /** * Informational event, MHD started. */ MHD_SC_DAEMON_STARTED = 10000, /** * Informational event, we accepted a connection. */ MHD_SC_CONNECTION_ACCEPTED = 10001, /** * Informational event, thread processing connection termiantes. */ MHD_SC_THREAD_TERMINATING = 10002, /** * Informational event, state machine status for a connection. */ MHD_SC_STATE_MACHINE_STATUS_REPORT = 10003, /** * accept() returned transient error. */ MHD_SC_ACCEPT_FAILED_EAGAIN = 10004, /* 20000-level status codes indicate success of some kind. */ /** * MHD is closing a connection after the client closed it * (perfectly normal end). */ MHD_SC_CONNECTION_CLOSED = 20000, /** * MHD is closing a connection because the application * logic to generate the response data completed. */ MHD_SC_APPLICATION_DATA_GENERATION_FINISHED = 20001, /* 30000-level status codes indicate transient failures that might go away if the client tries again. */ /** * Resource limit in terms of number of parallel connections * hit. */ MHD_SC_LIMIT_CONNECTIONS_REACHED = 30000, /** * We failed to allocate memory for poll() syscall. * (May be transient.) */ MHD_SC_POLL_MALLOC_FAILURE = 30001, /** * The operation failed because the respective * daemon is already too deep inside of the shutdown * activity. */ MHD_SC_DAEMON_ALREADY_SHUTDOWN = 30002, /** * We failed to start a thread. */ MHD_SC_THREAD_LAUNCH_FAILURE = 30003, /** * The operation failed because we either have no * listen socket or were already quiesced. */ MHD_SC_DAEMON_ALREADY_QUIESCED = 30004, /** * The operation failed because client disconnected * faster than we could accept(). */ MHD_SC_ACCEPT_FAST_DISCONNECT = 30005, /** * Operating resource limits hit on accept(). */ MHD_SC_ACCEPT_SYSTEM_LIMIT_REACHED = 30006, /** * Connection was refused by accept policy callback. */ MHD_SC_ACCEPT_POLICY_REJECTED = 30007, /** * We failed to allocate memory for the connection. * (May be transient.) */ MHD_SC_CONNECTION_MALLOC_FAILURE = 30008, /** * We failed to allocate memory for the connection's memory pool. * (May be transient.) */ MHD_SC_POOL_MALLOC_FAILURE = 30009, /** * We failed to forward data from a Web socket to the * application to the remote side due to the socket * being closed prematurely. (May be transient.) */ MHD_SC_UPGRADE_FORWARD_INCOMPLETE = 30010, /** * We failed to allocate memory for generating the response from our * memory pool. Likely the request header was too large to leave * enough room. */ MHD_SC_CONNECTION_POOL_MALLOC_FAILURE = 30011, /* 40000-level errors are caused by the HTTP client (or the network) */ /** * MHD is closing a connection because parsing the * request failed. */ MHD_SC_CONNECTION_PARSE_FAIL_CLOSED = 40000, /** * MHD is closing a connection because it was reset. */ MHD_SC_CONNECTION_RESET_CLOSED = 40001, /** * MHD is closing a connection because reading the * request failed. */ MHD_SC_CONNECTION_READ_FAIL_CLOSED = 40002, /** * MHD is closing a connection because writing the response failed. */ MHD_SC_CONNECTION_WRITE_FAIL_CLOSED = 40003, /** * MHD is returning an error because the header provided * by the client is too big. */ MHD_SC_CLIENT_HEADER_TOO_BIG = 40004, /** * An HTTP/1.1 request was sent without the "Host:" header. */ MHD_SC_HOST_HEADER_MISSING = 40005, /** * The given content length was not a number. */ MHD_SC_CONTENT_LENGTH_MALFORMED = 40006, /** * The given uploaded, chunked-encoded body was malformed. */ MHD_SC_CHUNKED_ENCODING_MALFORMED = 40007, /* 50000-level errors are because of an error internal to the MHD logic, possibly including our interaction with the operating system (but not the application) */ /** * This build of MHD does not support TLS, but the application * requested TLS. */ MHD_SC_TLS_DISABLED = 50000, /** * The application attempted to setup TLS parameters before * enabling TLS. */ MHD_SC_TLS_BACKEND_UNINITIALIZED = 50003, /** * The selected TLS backend does not yet support this operation. */ MHD_SC_TLS_BACKEND_OPERATION_UNSUPPORTED = 50004, /** * Failed to setup ITC channel. */ MHD_SC_ITC_INITIALIZATION_FAILED = 50005, /** * File descriptor for ITC channel too large. */ MHD_SC_ITC_DESCRIPTOR_TOO_LARGE = 50006, /** * The specified value for the NC length is way too large * for this platform (integer overflow on `size_t`). */ MHD_SC_DIGEST_AUTH_NC_LENGTH_TOO_BIG = 50007, /** * We failed to allocate memory for the specified nonce * counter array. The option was not set. */ MHD_SC_DIGEST_AUTH_NC_ALLOCATION_FAILURE = 50008, /** * This build of the library does not support * digest authentication. */ MHD_SC_DIGEST_AUTH_NOT_SUPPORTED_BY_BUILD = 50009, /** * IPv6 requested but not supported by this build. */ MHD_SC_IPV6_NOT_SUPPORTED_BY_BUILD = 50010, /** * We failed to open the listen socket. Maybe the build * supports IPv6, but your kernel does not? */ MHD_SC_FAILED_TO_OPEN_LISTEN_SOCKET = 50011, /** * Specified address family is not supported by this build. */ MHD_SC_AF_NOT_SUPPORTED_BY_BUILD = 50012, /** * Failed to enable listen address reuse. */ MHD_SC_LISTEN_ADDRESS_REUSE_ENABLE_FAILED = 50013, /** * Enabling listen address reuse is not supported by this platform. */ MHD_SC_LISTEN_ADDRESS_REUSE_ENABLE_NOT_SUPPORTED = 50014, /** * Failed to disable listen address reuse. */ MHD_SC_LISTEN_ADDRESS_REUSE_DISABLE_FAILED = 50015, /** * Disabling listen address reuse is not supported by this platform. */ MHD_SC_LISTEN_ADDRESS_REUSE_DISABLE_NOT_SUPPORTED = 50016, /** * We failed to explicitly enable or disable dual stack for * the IPv6 listen socket. The socket will be used in whatever * the default is the OS gives us. */ MHD_SC_LISTEN_DUAL_STACK_CONFIGURATION_FAILED = 50017, /** * On this platform, MHD does not support explicitly configuring * dual stack behavior. */ MHD_SC_LISTEN_DUAL_STACK_CONFIGURATION_NOT_SUPPORTED = 50018, /** * Failed to enable TCP FAST OPEN option. */ MHD_SC_FAST_OPEN_FAILURE = 50020, /** * Failed to start listening on listen socket. */ MHD_SC_LISTEN_FAILURE = 50021, /** * Failed to obtain our listen port via introspection. */ MHD_SC_LISTEN_PORT_INTROSPECTION_FAILURE = 50022, /** * Failed to obtain our listen port via introspection * due to unsupported address family being used. */ MHD_SC_LISTEN_PORT_INTROSPECTION_UNKNOWN_AF = 50023, /** * We failed to set the listen socket to non-blocking. */ MHD_SC_LISTEN_SOCKET_NONBLOCKING_FAILURE = 50024, /** * Listen socket value is too large (for use with select()). */ MHD_SC_LISTEN_SOCKET_TOO_LARGE = 50025, /** * We failed to allocate memory for the thread pool. */ MHD_SC_THREAD_POOL_MALLOC_FAILURE = 50026, /** * We failed to allocate mutex for thread pool worker. */ MHD_SC_THREAD_POOL_CREATE_MUTEX_FAILURE = 50027, /** * There was an attempt to upgrade a connection on * a daemon where upgrades are disallowed. */ MHD_SC_UPGRADE_ON_DAEMON_WITH_UPGRADE_DISALLOWED = 50028, /** * Failed to signal via ITC channel. */ MHD_SC_ITC_USE_FAILED = 50029, /** * We failed to initialize the main thread for listening. */ MHD_SC_THREAD_MAIN_LAUNCH_FAILURE = 50030, /** * We failed to initialize the threads for the worker pool. */ MHD_SC_THREAD_POOL_LAUNCH_FAILURE = 50031, /** * We failed to add a socket to the epoll() set. */ MHD_SC_EPOLL_CTL_ADD_FAILED = 50032, /** * We failed to create control socket for the epoll(). */ MHD_SC_EPOLL_CTL_CREATE_FAILED = 50034, /** * We failed to configure control socket for the epoll() * to be non-inheritable. */ MHD_SC_EPOLL_CTL_CONFIGURE_NOINHERIT_FAILED = 50035, /** * We failed to build the FD set because a socket was * outside of the permitted range. */ MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE = 50036, /** * This daemon was not configured with options that * would allow us to build an FD set for select(). */ MHD_SC_CONFIGURATION_MISMATCH_FOR_GET_FDSET = 50037, /** * This daemon was not configured with options that * would allow us to obtain a meaningful timeout. */ MHD_SC_CONFIGURATION_MISMATCH_FOR_GET_TIMEOUT = 50038, /** * This daemon was not configured with options that * would allow us to run with select() data. */ MHD_SC_CONFIGURATION_MISMATCH_FOR_RUN_SELECT = 50039, /** * This daemon was not configured to run with an * external event loop. */ MHD_SC_CONFIGURATION_MISMATCH_FOR_RUN_EXTERNAL = 50040, /** * Encountered an unexpected event loop style * (should never happen). */ MHD_SC_CONFIGURATION_UNEXPECTED_ELS = 50041, /** * Encountered an unexpected error from select() * (should never happen). */ MHD_SC_UNEXPECTED_SELECT_ERROR = 50042, /** * poll() is not supported. */ MHD_SC_POLL_NOT_SUPPORTED = 50043, /** * Encountered an unexpected error from poll() * (should never happen). */ MHD_SC_UNEXPECTED_POLL_ERROR = 50044, /** * We failed to configure accepted socket * to not use a signal pipe. */ MHD_SC_ACCEPT_CONFIGURE_NOSIGPIPE_FAILED = 50045, /** * Encountered an unexpected error from epoll_wait() * (should never happen). */ MHD_SC_UNEXPECTED_EPOLL_WAIT_ERROR = 50046, /** * epoll file descriptor is invalid (strange) */ MHD_SC_EPOLL_FD_INVALID = 50047, /** * We failed to configure accepted socket * to be non-inheritable. */ MHD_SC_ACCEPT_CONFIGURE_NOINHERIT_FAILED = 50048, /** * We failed to configure accepted socket * to be non-blocking. */ MHD_SC_ACCEPT_CONFIGURE_NONBLOCKING_FAILED = 50049, /** * accept() returned non-transient error. */ MHD_SC_ACCEPT_FAILED_UNEXPECTEDLY = 50050, /** * Operating resource limits hit on accept() while * zero connections are active. Oopsie. */ MHD_SC_ACCEPT_SYSTEM_LIMIT_REACHED_INSTANTLY = 50051, /** * Failed to add IP address to per-IP counter for * some reason. */ MHD_SC_IP_COUNTER_FAILURE = 50052, /** * Application violated our API by calling shutdown * while having an upgrade connection still open. */ MHD_SC_SHUTDOWN_WITH_OPEN_UPGRADED_CONNECTION = 50053, /** * Due to an unexpected internal error with the * state machine, we closed the connection. */ MHD_SC_STATEMACHINE_FAILURE_CONNECTION_CLOSED = 50054, /** * Failed to allocate memory in connection's pool * to parse the cookie header. */ MHD_SC_COOKIE_POOL_ALLOCATION_FAILURE = 50055, /** * MHD failed to build the response header. */ MHD_SC_FAILED_RESPONSE_HEADER_GENERATION = 50056, /* 60000-level errors are because the application logic did something wrong or generated an error. */ /** * MHD does not support the requested combination of * EPOLL with thread-per-connection mode. */ MHD_SC_SYSCALL_THREAD_COMBINATION_INVALID = 60000, /** * MHD does not support quiescing if ITC was disabled * and threads are used. */ MHD_SC_SYSCALL_QUIESCE_REQUIRES_ITC = 60001, /** * We failed to bind the listen socket. */ MHD_SC_LISTEN_SOCKET_BIND_FAILED = 60002, /** * The application requested an unsupported TLS backend to be used. */ MHD_SC_TLS_BACKEND_UNSUPPORTED = 60003, /** * The application requested a TLS cipher suite which is not * supported by the selected backend. */ MHD_SC_TLS_CIPHERS_INVALID = 60004, /** * MHD is closing a connection because the application * logic to generate the response data failed. */ MHD_SC_APPLICATION_DATA_GENERATION_FAILURE_CLOSED = 60005, /** * MHD is closing a connection because the application * callback told it to do so. */ MHD_SC_APPLICATION_CALLBACK_FAILURE_CLOSED = 60006, /** * Application only partially processed upload and did * not suspend connection. This may result in a hung * connection. */ MHD_SC_APPLICATION_HUNG_CONNECTION = 60007, /** * Application only partially processed upload and did * not suspend connection and the read buffer was maxxed * out, so MHD closed the connection. */ MHD_SC_APPLICATION_HUNG_CONNECTION_CLOSED = 60008, }; /** * Actions are returned by the application to drive the request * handling of MHD. */ struct MHD_Action; /** * HTTP methods explicitly supported by MHD. Note that for * non-canonical methods, MHD will return #MHD_METHOD_UNKNOWN * and you can use #MHD_REQUEST_INFORMATION_HTTP_METHOD to get * the original string. * * However, applications must check for "#MHD_METHOD_UNKNOWN" *or* any * enum-value above those in this list, as future versions of MHD may * add additional methods (as per IANA registry), thus even if the API * returns "unknown" today, it may return a method-specific header in * the future! * * @defgroup methods HTTP methods * HTTP methods (as strings). * See: http://www.iana.org/assignments/http-methods/http-methods.xml * Registry Version 2015-05-19 * @{ */ enum MHD_Method { /** * Method did not match any of the methods given below. */ MHD_METHOD_UNKNOWN = 0, /** * "OPTIONS" method. * Safe. Idempotent. RFC7231, Section 4.3.7. */ MHD_METHOD_OPTIONS = 1, /** * "GET" method. * Safe. Idempotent. RFC7231, Section 4.3.1. */ MHD_METHOD_GET = 2, /** * "HEAD" method. * Safe. Idempotent. RFC7231, Section 4.3.2. */ MHD_METHOD_HEAD = 3, /** * "POST" method. * Not safe. Not idempotent. RFC7231, Section 4.3.3. */ MHD_METHOD_POST = 4, /** * "PUT" method. * Not safe. Idempotent. RFC7231, Section 4.3.4. */ MHD_METHOD_PUT = 5, /** * "DELETE" method. * Not safe. Idempotent. RFC7231, Section 4.3.5. */ MHD_METHOD_DELETE = 6, /** * "TRACE" method. */ MHD_METHOD_TRACE = 7, /** * "CONNECT" method. */ MHD_METHOD_CONNECT = 8, /** * "ACL" method. */ MHD_METHOD_ACL = 9, /** * "BASELINE-CONTROL" method. */ MHD_METHOD_BASELINE_CONTROL = 10, /** * "BIND" method. */ MHD_METHOD_BIND = 11, /** * "CHECKIN" method. */ MHD_METHOD_CHECKIN = 12, /** * "CHECKOUT" method. */ MHD_METHOD_CHECKOUT = 13, /** * "COPY" method. */ MHD_METHOD_COPY = 14, /** * "LABEL" method. */ MHD_METHOD_LABEL = 15, /** * "LINK" method. */ MHD_METHOD_LINK = 16, /** * "LOCK" method. */ MHD_METHOD_LOCK = 17, /** * "MERGE" method. */ MHD_METHOD_MERGE = 18, /** * "MKACTIVITY" method. */ MHD_METHOD_MKACTIVITY = 19, /** * "MKCOL" method. */ MHD_METHOD_MKCOL = 20, /** * "MKREDIRECTREF" method. */ MHD_METHOD_MKREDIRECTREF = 21, /** * "MKWORKSPACE" method. */ MHD_METHOD_MKWORKSPACE = 22, /** * "MOVE" method. */ MHD_METHOD_MOVE = 23, /** * "ORDERPATCH" method. */ MHD_METHOD_ORDERPATCH = 24, /** * "PATCH" method. */ MHD_METHOD_PATH = 25, /** * "PRI" method. */ MHD_METHOD_PRI = 26, /** * "PROPFIND" method. */ MHD_METHOD_PROPFIND = 27, /** * "PROPPATCH" method. */ MHD_METHOD_PROPPATCH = 28, /** * "REBIND" method. */ MHD_METHOD_REBIND = 29, /** * "REPORT" method. */ MHD_METHOD_REPORT = 30, /** * "SEARCH" method. */ MHD_METHOD_SEARCH = 31, /** * "UNBIND" method. */ MHD_METHOD_UNBIND = 32, /** * "UNCHECKOUT" method. */ MHD_METHOD_UNCHECKOUT = 33, /** * "UNLINK" method. */ MHD_METHOD_UNLINK = 34, /** * "UNLOCK" method. */ MHD_METHOD_UNLOCK = 35, /** * "UPDATE" method. */ MHD_METHOD_UPDATE = 36, /** * "UPDATEDIRECTREF" method. */ MHD_METHOD_UPDATEDIRECTREF = 37, /** * "VERSION-CONTROL" method. */ MHD_METHOD_VERSION_CONTROL = 38 /* For more, check: https://www.iana.org/assignments/http-methods/http-methods.xhtml */ }; /** @} */ /* end of group methods */ /** * @defgroup postenc HTTP POST encodings * See also: http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4 * @{ */ #define MHD_HTTP_POST_ENCODING_FORM_URLENCODED \ "application/x-www-form-urlencoded" #define MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA "multipart/form-data" /** @} */ /* end of group postenc */ /** * @defgroup headers HTTP headers * These are the standard headers found in HTTP requests and responses. * See: http://www.iana.org/assignments/message-headers/message-headers.xml * Registry Version 2017-01-27 * @{ */ /* Main HTTP headers. */ /* Standard. RFC7231, Section 5.3.2 */ #define MHD_HTTP_HEADER_ACCEPT "Accept" /* Standard. RFC7231, Section 5.3.3 */ #define MHD_HTTP_HEADER_ACCEPT_CHARSET "Accept-Charset" /* Standard. RFC7231, Section 5.3.4; RFC7694, Section 3 */ #define MHD_HTTP_HEADER_ACCEPT_ENCODING "Accept-Encoding" /* Standard. RFC7231, Section 5.3.5 */ #define MHD_HTTP_HEADER_ACCEPT_LANGUAGE "Accept-Language" /* Standard. RFC7233, Section 2.3 */ #define MHD_HTTP_HEADER_ACCEPT_RANGES "Accept-Ranges" /* Standard. RFC7234, Section 5.1 */ #define MHD_HTTP_HEADER_AGE "Age" /* Standard. RFC7231, Section 7.4.1 */ #define MHD_HTTP_HEADER_ALLOW "Allow" /* Standard. RFC7235, Section 4.2 */ #define MHD_HTTP_HEADER_AUTHORIZATION "Authorization" /* Standard. RFC7234, Section 5.2 */ #define MHD_HTTP_HEADER_CACHE_CONTROL "Cache-Control" /* Reserved. RFC7230, Section 8.1 */ #define MHD_HTTP_HEADER_CLOSE "Close" /* Standard. RFC7230, Section 6.1 */ #define MHD_HTTP_HEADER_CONNECTION "Connection" /* Standard. RFC7231, Section 3.1.2.2 */ #define MHD_HTTP_HEADER_CONTENT_ENCODING "Content-Encoding" /* Standard. RFC7231, Section 3.1.3.2 */ #define MHD_HTTP_HEADER_CONTENT_LANGUAGE "Content-Language" /* Standard. RFC7230, Section 3.3.2 */ #define MHD_HTTP_HEADER_CONTENT_LENGTH "Content-Length" /* Standard. RFC7231, Section 3.1.4.2 */ #define MHD_HTTP_HEADER_CONTENT_LOCATION "Content-Location" /* Standard. RFC7233, Section 4.2 */ #define MHD_HTTP_HEADER_CONTENT_RANGE "Content-Range" /* Standard. RFC7231, Section 3.1.1.5 */ #define MHD_HTTP_HEADER_CONTENT_TYPE "Content-Type" /* Standard. RFC7231, Section 7.1.1.2 */ #define MHD_HTTP_HEADER_DATE "Date" /* Standard. RFC7232, Section 2.3 */ #define MHD_HTTP_HEADER_ETAG "ETag" /* Standard. RFC7231, Section 5.1.1 */ #define MHD_HTTP_HEADER_EXPECT "Expect" /* Standard. RFC7234, Section 5.3 */ #define MHD_HTTP_HEADER_EXPIRES "Expires" /* Standard. RFC7231, Section 5.5.1 */ #define MHD_HTTP_HEADER_FROM "From" /* Standard. RFC7230, Section 5.4 */ #define MHD_HTTP_HEADER_HOST "Host" /* Standard. RFC7232, Section 3.1 */ #define MHD_HTTP_HEADER_IF_MATCH "If-Match" /* Standard. RFC7232, Section 3.3 */ #define MHD_HTTP_HEADER_IF_MODIFIED_SINCE "If-Modified-Since" /* Standard. RFC7232, Section 3.2 */ #define MHD_HTTP_HEADER_IF_NONE_MATCH "If-None-Match" /* Standard. RFC7233, Section 3.2 */ #define MHD_HTTP_HEADER_IF_RANGE "If-Range" /* Standard. RFC7232, Section 3.4 */ #define MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE "If-Unmodified-Since" /* Standard. RFC7232, Section 2.2 */ #define MHD_HTTP_HEADER_LAST_MODIFIED "Last-Modified" /* Standard. RFC7231, Section 7.1.2 */ #define MHD_HTTP_HEADER_LOCATION "Location" /* Standard. RFC7231, Section 5.1.2 */ #define MHD_HTTP_HEADER_MAX_FORWARDS "Max-Forwards" /* Standard. RFC7231, Appendix A.1 */ #define MHD_HTTP_HEADER_MIME_VERSION "MIME-Version" /* Standard. RFC7234, Section 5.4 */ #define MHD_HTTP_HEADER_PRAGMA "Pragma" /* Standard. RFC7235, Section 4.3 */ #define MHD_HTTP_HEADER_PROXY_AUTHENTICATE "Proxy-Authenticate" /* Standard. RFC7235, Section 4.4 */ #define MHD_HTTP_HEADER_PROXY_AUTHORIZATION "Proxy-Authorization" /* Standard. RFC7233, Section 3.1 */ #define MHD_HTTP_HEADER_RANGE "Range" /* Standard. RFC7231, Section 5.5.2 */ #define MHD_HTTP_HEADER_REFERER "Referer" /* Standard. RFC7231, Section 7.1.3 */ #define MHD_HTTP_HEADER_RETRY_AFTER "Retry-After" /* Standard. RFC7231, Section 7.4.2 */ #define MHD_HTTP_HEADER_SERVER "Server" /* Standard. RFC7230, Section 4.3 */ #define MHD_HTTP_HEADER_TE "TE" /* Standard. RFC7230, Section 4.4 */ #define MHD_HTTP_HEADER_TRAILER "Trailer" /* Standard. RFC7230, Section 3.3.1 */ #define MHD_HTTP_HEADER_TRANSFER_ENCODING "Transfer-Encoding" /* Standard. RFC7230, Section 6.7 */ #define MHD_HTTP_HEADER_UPGRADE "Upgrade" /* Standard. RFC7231, Section 5.5.3 */ #define MHD_HTTP_HEADER_USER_AGENT "User-Agent" /* Standard. RFC7231, Section 7.1.4 */ #define MHD_HTTP_HEADER_VARY "Vary" /* Standard. RFC7230, Section 5.7.1 */ #define MHD_HTTP_HEADER_VIA "Via" /* Standard. RFC7235, Section 4.1 */ #define MHD_HTTP_HEADER_WWW_AUTHENTICATE "WWW-Authenticate" /* Standard. RFC7234, Section 5.5 */ #define MHD_HTTP_HEADER_WARNING "Warning" /* Additional HTTP headers. */ /* No category. RFC4229 */ #define MHD_HTTP_HEADER_A_IM "A-IM" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_ACCEPT_ADDITIONS "Accept-Additions" /* Informational. RFC7089 */ #define MHD_HTTP_HEADER_ACCEPT_DATETIME "Accept-Datetime" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_ACCEPT_FEATURES "Accept-Features" /* No category. RFC5789 */ #define MHD_HTTP_HEADER_ACCEPT_PATCH "Accept-Patch" /* Standard. RFC7639, Section 2 */ #define MHD_HTTP_HEADER_ALPN "ALPN" /* Standard. RFC7838 */ #define MHD_HTTP_HEADER_ALT_SVC "Alt-Svc" /* Standard. RFC7838 */ #define MHD_HTTP_HEADER_ALT_USED "Alt-Used" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_ALTERNATES "Alternates" /* No category. RFC4437 */ #define MHD_HTTP_HEADER_APPLY_TO_REDIRECT_REF "Apply-To-Redirect-Ref" /* Experimental. RFC8053, Section 4 */ #define MHD_HTTP_HEADER_AUTHENTICATION_CONTROL "Authentication-Control" /* Standard. RFC7615, Section 3 */ #define MHD_HTTP_HEADER_AUTHENTICATION_INFO "Authentication-Info" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_C_EXT "C-Ext" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_C_MAN "C-Man" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_C_OPT "C-Opt" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_C_PEP "C-PEP" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_C_PEP_INFO "C-PEP-Info" /* Standard. RFC7809, Section 7.1 */ #define MHD_HTTP_HEADER_CALDAV_TIMEZONES "CalDAV-Timezones" /* Obsoleted. RFC2068; RFC2616 */ #define MHD_HTTP_HEADER_CONTENT_BASE "Content-Base" /* Standard. RFC6266 */ #define MHD_HTTP_HEADER_CONTENT_DISPOSITION "Content-Disposition" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_CONTENT_ID "Content-ID" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_CONTENT_MD5 "Content-MD5" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_CONTENT_SCRIPT_TYPE "Content-Script-Type" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_CONTENT_STYLE_TYPE "Content-Style-Type" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_CONTENT_VERSION "Content-Version" /* Standard. RFC6265 */ #define MHD_HTTP_HEADER_COOKIE "Cookie" /* Obsoleted. RFC2965; RFC6265 */ #define MHD_HTTP_HEADER_COOKIE2 "Cookie2" /* Standard. RFC5323 */ #define MHD_HTTP_HEADER_DASL "DASL" /* Standard. RFC4918 */ #define MHD_HTTP_HEADER_DAV "DAV" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_DEFAULT_STYLE "Default-Style" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_DELTA_BASE "Delta-Base" /* Standard. RFC4918 */ #define MHD_HTTP_HEADER_DEPTH "Depth" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_DERIVED_FROM "Derived-From" /* Standard. RFC4918 */ #define MHD_HTTP_HEADER_DESTINATION "Destination" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_DIFFERENTIAL_ID "Differential-ID" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_DIGEST "Digest" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_EXT "Ext" /* Standard. RFC7239 */ #define MHD_HTTP_HEADER_FORWARDED "Forwarded" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_GETPROFILE "GetProfile" /* Experimental. RFC7486, Section 6.1.1 */ #define MHD_HTTP_HEADER_HOBAREG "Hobareg" /* Standard. RFC7540, Section 3.2.1 */ #define MHD_HTTP_HEADER_HTTP2_SETTINGS "HTTP2-Settings" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_IM "IM" /* Standard. RFC4918 */ #define MHD_HTTP_HEADER_IF "If" /* Standard. RFC6638 */ #define MHD_HTTP_HEADER_IF_SCHEDULE_TAG_MATCH "If-Schedule-Tag-Match" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_KEEP_ALIVE "Keep-Alive" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_LABEL "Label" /* No category. RFC5988 */ #define MHD_HTTP_HEADER_LINK "Link" /* Standard. RFC4918 */ #define MHD_HTTP_HEADER_LOCK_TOKEN "Lock-Token" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_MAN "Man" /* Informational. RFC7089 */ #define MHD_HTTP_HEADER_MEMENTO_DATETIME "Memento-Datetime" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_METER "Meter" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_NEGOTIATE "Negotiate" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_OPT "Opt" /* Experimental. RFC8053, Section 3 */ #define MHD_HTTP_HEADER_OPTIONAL_WWW_AUTHENTICATE "Optional-WWW-Authenticate" /* Standard. RFC4229 */ #define MHD_HTTP_HEADER_ORDERING_TYPE "Ordering-Type" /* Standard. RFC6454 */ #define MHD_HTTP_HEADER_ORIGIN "Origin" /* Standard. RFC4918 */ #define MHD_HTTP_HEADER_OVERWRITE "Overwrite" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_P3P "P3P" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PEP "PEP" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PICS_LABEL "PICS-Label" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PEP_INFO "Pep-Info" /* Standard. RFC4229 */ #define MHD_HTTP_HEADER_POSITION "Position" /* Standard. RFC7240 */ #define MHD_HTTP_HEADER_PREFER "Prefer" /* Standard. RFC7240 */ #define MHD_HTTP_HEADER_PREFERENCE_APPLIED "Preference-Applied" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PROFILEOBJECT "ProfileObject" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PROTOCOL "Protocol" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PROTOCOL_INFO "Protocol-Info" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PROTOCOL_QUERY "Protocol-Query" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PROTOCOL_REQUEST "Protocol-Request" /* Standard. RFC7615, Section 4 */ #define MHD_HTTP_HEADER_PROXY_AUTHENTICATION_INFO "Proxy-Authentication-Info" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PROXY_FEATURES "Proxy-Features" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PROXY_INSTRUCTION "Proxy-Instruction" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_PUBLIC "Public" /* Standard. RFC7469 */ #define MHD_HTTP_HEADER_PUBLIC_KEY_PINS "Public-Key-Pins" /* Standard. RFC7469 */ #define MHD_HTTP_HEADER_PUBLIC_KEY_PINS_REPORT_ONLY \ "Public-Key-Pins-Report-Only" /* No category. RFC4437 */ #define MHD_HTTP_HEADER_REDIRECT_REF "Redirect-Ref" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_SAFE "Safe" /* Standard. RFC6638 */ #define MHD_HTTP_HEADER_SCHEDULE_REPLY "Schedule-Reply" /* Standard. RFC6638 */ #define MHD_HTTP_HEADER_SCHEDULE_TAG "Schedule-Tag" /* Standard. RFC6455 */ #define MHD_HTTP_HEADER_SEC_WEBSOCKET_ACCEPT "Sec-WebSocket-Accept" /* Standard. RFC6455 */ #define MHD_HTTP_HEADER_SEC_WEBSOCKET_EXTENSIONS "Sec-WebSocket-Extensions" /* Standard. RFC6455 */ #define MHD_HTTP_HEADER_SEC_WEBSOCKET_KEY "Sec-WebSocket-Key" /* Standard. RFC6455 */ #define MHD_HTTP_HEADER_SEC_WEBSOCKET_PROTOCOL "Sec-WebSocket-Protocol" /* Standard. RFC6455 */ #define MHD_HTTP_HEADER_SEC_WEBSOCKET_VERSION "Sec-WebSocket-Version" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_SECURITY_SCHEME "Security-Scheme" /* Standard. RFC6265 */ #define MHD_HTTP_HEADER_SET_COOKIE "Set-Cookie" /* Obsoleted. RFC2965; RFC6265 */ #define MHD_HTTP_HEADER_SET_COOKIE2 "Set-Cookie2" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_SETPROFILE "SetProfile" /* Standard. RFC5023 */ #define MHD_HTTP_HEADER_SLUG "SLUG" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_SOAPACTION "SoapAction" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_STATUS_URI "Status-URI" /* Standard. RFC6797 */ #define MHD_HTTP_HEADER_STRICT_TRANSPORT_SECURITY "Strict-Transport-Security" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_SURROGATE_CAPABILITY "Surrogate-Capability" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_SURROGATE_CONTROL "Surrogate-Control" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_TCN "TCN" /* Standard. RFC4918 */ #define MHD_HTTP_HEADER_TIMEOUT "Timeout" /* Standard. RFC8030, Section 5.4 */ #define MHD_HTTP_HEADER_TOPIC "Topic" /* Standard. RFC8030, Section 5.2 */ #define MHD_HTTP_HEADER_TTL "TTL" /* Standard. RFC8030, Section 5.3 */ #define MHD_HTTP_HEADER_URGENCY "Urgency" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_URI "URI" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_VARIANT_VARY "Variant-Vary" /* No category. RFC4229 */ #define MHD_HTTP_HEADER_WANT_DIGEST "Want-Digest" /* Informational. RFC7034 */ #define MHD_HTTP_HEADER_X_FRAME_OPTIONS "X-Frame-Options" /* Some provisional headers. */ #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN \ "Access-Control-Allow-Origin" /** @} */ /* end of group headers */ /** * A client has requested the given url using the given method * (#MHD_HTTP_METHOD_GET, #MHD_HTTP_METHOD_PUT, * #MHD_HTTP_METHOD_DELETE, #MHD_HTTP_METHOD_POST, etc). The callback * must initialize @a rhp to provide further callbacks which will * process the request further and ultimately to provide the response * to give back to the client, or return #MHD_NO. * * @param cls argument given together with the function * pointer when the handler was registered with MHD * @param url the requested url (without arguments after "?") * @param method the HTTP method used (#MHD_HTTP_METHOD_GET, * #MHD_HTTP_METHOD_PUT, etc.) * @return action how to proceed, NULL * if the socket must be closed due to a serious * error while handling the request */ typedef const struct MHD_Action * (*MHD_RequestCallback) (void *cls, struct MHD_Request *request, const char *url, enum MHD_Method method); /** * Create (but do not yet start) an MHD daemon. * Usually, you will want to set various options before * starting the daemon with #MHD_daemon_start(). * * @param cb function to be called for incoming requests * @param cb_cls closure for @a cb * @return NULL on error */ _MHD_EXTERN struct MHD_Daemon * MHD_daemon_create (MHD_RequestCallback cb, void *cb_cls) MHD_NONNULL (1); /** * Start a webserver. * * @param daemon daemon to start; you can no longer set * options on this daemon after this call! * @return #MHD_SC_OK on success * @ingroup event */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_start (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * Stop accepting connections from the listening socket. Allows * clients to continue processing, but stops accepting new * connections. Note that the caller is responsible for closing the * returned socket; however, if MHD is run using threads (anything but * external select mode), it must not be closed until AFTER * #MHD_stop_daemon has been called (as it is theoretically possible * that an existing thread is still using it). * * Note that some thread modes require the caller to have passed * #MHD_USE_ITC when using this API. If this daemon is * in one of those modes and this option was not given to * #MHD_start_daemon, this function will return #MHD_INVALID_SOCKET. * * @param daemon daemon to stop accepting new connections for * @return old listen socket on success, #MHD_INVALID_SOCKET if * the daemon was already not listening anymore, or * was never started * @ingroup specialized */ _MHD_EXTERN MHD_socket MHD_daemon_quiesce (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * Shutdown and destroy an HTTP daemon. * * @param daemon daemon to stop * @ingroup event */ _MHD_EXTERN void MHD_daemon_destroy (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * Add another client connection to the set of connections managed by * MHD. This API is usually not needed (since MHD will accept inbound * connections on the server socket). Use this API in special cases, * for example if your HTTP server is behind NAT and needs to connect * out to the HTTP client, or if you are building a proxy. * * If you use this API in conjunction with a internal select or a * thread pool, you must set the option #MHD_USE_ITC to ensure that * the freshly added connection is immediately processed by MHD. * * The given client socket will be managed (and closed!) by MHD after * this call and must no longer be used directly by the application * afterwards. * * @param daemon daemon that manages the connection * @param client_socket socket to manage (MHD will expect * to receive an HTTP request from this socket next). * @param addr IP address of the client * @param addrlen number of bytes in @a addr * @return #MHD_SC_OK on success * The socket will be closed in any case; `errno` is * set to indicate further details about the error. * @ingroup specialized */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen) MHD_NONNULL (1); /** * Obtain the `select()` sets for this daemon. Daemon's FDs will be * added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO * for each fd_set before calling this function. FD_SETSIZE is assumed * to be platform's default. * * This function should only be called in when MHD is configured to * use external select with 'select()' or with 'epoll'. In the latter * case, it will only add the single 'epoll()' file descriptor used by * MHD to the sets. It's necessary to use #MHD_get_timeout() in * combination with this function. * * This function must be called only for daemon started without * #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @return #MHD_SC_OK on success, otherwise error code * @ingroup event */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_get_fdset (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd) MHD_NONNULL (1,2,3,4); /** * Obtain the `select()` sets for this daemon. Daemon's FDs will be * added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO * for each fd_set before calling this function. * * Passing custom FD_SETSIZE as @a fd_setsize allow usage of * larger/smaller than platform's default fd_sets. * * This function should only be called in when MHD is configured to * use external select with 'select()' or with 'epoll'. In the latter * case, it will only add the single 'epoll' file descriptor used by * MHD to the sets. It's necessary to use #MHD_get_timeout() in * combination with this function. * * This function must be called only for daemon started * without #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @param fd_setsize value of FD_SETSIZE * @return #MHD_SC_OK on success, otherwise error code * @ingroup event */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_get_fdset2 (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize) MHD_NONNULL (1,2,3,4); /** * Obtain the `select()` sets for this daemon. Daemon's FDs will be * added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO * for each fd_set before calling this function. Size of fd_set is * determined by current value of FD_SETSIZE. It's necessary to use * #MHD_get_timeout() in combination with this function. * * This function could be called only for daemon started * without #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @return #MHD_YES on success, #MHD_NO if this * daemon was not started with the right * options for this call or any FD didn't * fit fd_set. * @ingroup event */ #define MHD_daemon_get_fdset(daemon,read_fd_set,write_fd_set,except_fd_set, \ max_fd) \ MHD_get_fdset2 ((daemon),(read_fd_set),(write_fd_set),(except_fd_set), \ (max_fd),FD_SETSIZE) /** * Obtain timeout value for polling function for this daemon. * This function set value to amount of milliseconds for which polling * function (`select()` or `poll()`) should at most block, not the * timeout value set for connections. * It is important to always use this function, even if connection * timeout is not set, as in some cases MHD may already have more * data to process on next turn (data pending in TLS buffers, * connections are already ready with epoll etc.) and returned timeout * will be zero. * * @param daemon daemon to query for timeout * @param timeout set to the timeout (in milliseconds) * @return #MHD_SC_OK on success, #MHD_SC_NO_TIMEOUT if timeouts are * not used (or no connections exist that would * necessitate the use of a timeout right now), otherwise * an error code * @ingroup event */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_get_timeout (struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout) MHD_NONNULL (1,2); /** * Run webserver operations (without blocking unless in client * callbacks). This method should be called by clients in combination * with #MHD_get_fdset if the client-controlled select method is used * and #MHD_get_timeout(). * * This function is a convenience method, which is useful if the * fd_sets from #MHD_get_fdset were not directly passed to `select()`; * with this function, MHD will internally do the appropriate `select()` * call itself again. While it is always safe to call #MHD_run (if * #MHD_USE_INTERNAL_POLLING_THREAD is not set), you should call * #MHD_run_from_select if performance is important (as it saves an * expensive call to `select()`). * * @param daemon daemon to run * @return #MHD_SC_OK on success * @ingroup event */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_run (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * Run webserver operations. This method should be called by clients * in combination with #MHD_get_fdset and #MHD_get_timeout() if the * client-controlled select method is used. * * You can use this function instead of #MHD_run if you called * `select()` on the result from #MHD_get_fdset. File descriptors in * the sets that are not controlled by MHD will be ignored. Calling * this function instead of #MHD_run is more efficient as MHD will not * have to call `select()` again to determine which operations are * ready. * * This function cannot be used with daemon started with * #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to run select loop for * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @return #MHD_SC_OK on success * @ingroup event */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set) MHD_NONNULL (1,2,3,4); /* ********************* daemon options ************** */ /** * Type of a callback function used for logging by MHD. * * @param cls closure * @param sc status code of the event * @param fm format string (`printf()`-style) * @param ap arguments to @a fm * @ingroup logging */ typedef void (*MHD_LoggingCallback)(void *cls, enum MHD_StatusCode sc, const char *fm, va_list ap); /** * Set logging method. Specify NULL to disable logging entirely. By * default (if this option is not given), we log error messages to * stderr. * * @param daemon which instance to setup logging for * @param logger function to invoke * @param logger_cls closure for @a logger */ _MHD_EXTERN void MHD_daemon_set_logger (struct MHD_Daemon *daemon, MHD_LoggingCallback logger, void *logger_cls) MHD_NONNULL (1); /** * Convenience macro used to disable logging. * * @param daemon which instance to disable logging for */ #define MHD_daemon_disable_logging(daemon) MHD_daemon_set_logger (daemon, NULL, \ NULL) /** * Suppress use of "Date" header as this system has no RTC. * * @param daemon which instance to disable clock for. */ _MHD_EXTERN void MHD_daemon_suppress_date_no_clock (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * Disable use of inter-thread communication channel. * #MHD_daemon_disable_itc() can be used with * #MHD_daemon_thread_internal() to perform some additional * optimizations (in particular, not creating a pipe for IPC * signalling). If it is used, certain functions like * #MHD_daemon_quiesce() or #MHD_connection_add() or * #MHD_action_suspend() cannot be used anymore. * #MHD_daemon_disable_itc() is not beneficial on platforms where * select()/poll()/other signal shutdown() of a listen socket. * * You should only use this function if you are sure you do * satisfy all of its requirements and need a generally minor * boost in performance. * * @param daemon which instance to disable itc for */ _MHD_EXTERN void MHD_daemon_disable_itc (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * Enable `turbo`. Disables certain calls to `shutdown()`, * enables aggressive non-blocking optimistic reads and * other potentially unsafe optimizations. * Most effects only happen with #MHD_ELS_EPOLL. * * @param daemon which instance to enable turbo for */ _MHD_EXTERN void MHD_daemon_enable_turbo (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * Disable #MHD_action_suspend() functionality. * * You should only use this function if you are sure you do * satisfy all of its requirements and need a generally minor * boost in performance. * * @param daemon which instance to disable suspend for */ _MHD_EXTERN void MHD_daemon_disallow_suspend_resume (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * You need to set this option if you want to disable use of HTTP "Upgrade". * "Upgrade" may require usage of additional internal resources, * which we can avoid providing if they will not be used. * * You should only use this function if you are sure you do * satisfy all of its requirements and need a generally minor * boost in performance. * * @param daemon which instance to enable suspend/resume for */ _MHD_EXTERN void MHD_daemon_disallow_upgrade (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * Possible levels of enforcement for TCP_FASTOPEN. */ enum MHD_FastOpenMethod { /** * Disable use of TCP_FASTOPEN. */ MHD_FOM_DISABLE = -1, /** * Enable TCP_FASTOPEN where supported (Linux with a kernel >= 3.6). * This is the default. */ MHD_FOM_AUTO = 0, /** * If TCP_FASTOPEN is not available, return #MHD_NO. * Also causes #MHD_daemon_start() to fail if setting * the option fails later. */ MHD_FOM_REQUIRE = 1 }; /** * Configure TCP_FASTOPEN option, including setting a * custom @a queue_length. * * Note that having a larger queue size can cause resource exhaustion * attack as the TCP stack has to now allocate resources for the SYN * packet along with its DATA. * * @param daemon which instance to configure TCP_FASTOPEN for * @param fom under which conditions should we use TCP_FASTOPEN? * @param queue_length queue length to use, default is 50 if this * option is never given. * @return #MHD_YES upon success, #MHD_NO if #MHD_FOM_REQUIRE was * given, but TCP_FASTOPEN is not available on the platform */ _MHD_EXTERN enum MHD_Bool MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon, enum MHD_FastOpenMethod fom, unsigned int queue_length) MHD_NONNULL (1); /** * Address family to be used by MHD. */ enum MHD_AddressFamily { /** * Option not given, do not listen at all * (unless listen socket or address specified by * other means). */ MHD_AF_NONE = 0, /** * Pick "best" available method automatically. */ MHD_AF_AUTO, /** * Use IPv4. */ MHD_AF_INET4, /** * Use IPv6. */ MHD_AF_INET6, /** * Use dual stack. */ MHD_AF_DUAL }; /** * Bind to the given TCP port and address family. * * Ineffective in conjunction with #MHD_daemon_listen_socket(). * Ineffective in conjunction with #MHD_daemon_bind_sa(). * * If neither this option nor the other two mentioned above * is specified, MHD will simply not listen on any socket! * * @param daemon which instance to configure the TCP port for * @param af address family to use * @param port port to use, 0 to bind to a random (free) port */ _MHD_EXTERN void MHD_daemon_bind_port (struct MHD_Daemon *daemon, enum MHD_AddressFamily af, uint16_t port) MHD_NONNULL (1); /** * Bind to the given socket address. * Ineffective in conjunction with #MHD_daemon_listen_socket(). * * @param daemon which instance to configure the binding address for * @param sa address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) * or even a UNIX domain socket (AF_UNIX) * @param sa_len number of bytes in @a sa */ _MHD_EXTERN void MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon, const struct sockaddr *sa, size_t sa_len) MHD_NONNULL (1); /** * Use the given backlog for the listen() call. * Ineffective in conjunction with #MHD_daemon_listen_socket(). * * @param daemon which instance to configure the backlog for * @param listen_backlog backlog to use */ _MHD_EXTERN void MHD_daemon_listen_backlog (struct MHD_Daemon *daemon, int listen_backlog) MHD_NONNULL (1); /** * If present true, allow reusing address:port socket (by using * SO_REUSEPORT on most platform, or platform-specific ways). If * present and set to false, disallow reusing address:port socket * (does nothing on most platform, but uses SO_EXCLUSIVEADDRUSE on * Windows). * Ineffective in conjunction with #MHD_daemon_listen_socket(). * * @param daemon daemon to configure address reuse for */ _MHD_EXTERN void MHD_daemon_listen_allow_address_reuse (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * Accept connections from the given socket. Socket * must be a TCP or UNIX domain (stream) socket. * * Unless -1 is given, this disables other listen options, including * #MHD_daemon_bind_sa(), #MHD_daemon_bind_port(), * #MHD_daemon_listen_queue() and * #MHD_daemon_listen_allow_address_reuse(). * * @param daemon daemon to set listen socket for * @param listen_socket listen socket to use, * MHD_INVALID_SOCKET value will cause this call to be * ignored (other binding options may still be effective) */ _MHD_EXTERN void MHD_daemon_listen_socket (struct MHD_Daemon *daemon, MHD_socket listen_socket) MHD_NONNULL (1); /** * Event loop syscalls supported by MHD. */ enum MHD_EventLoopSyscall { /** * Automatic selection of best-available method. This is also the * default. */ MHD_ELS_AUTO = 0, /** * Use select(). */ MHD_ELS_SELECT = 1, /** * Use poll(). */ MHD_ELS_POLL = 2, /** * Use epoll(). */ MHD_ELS_EPOLL = 3 }; /** * Force use of a particular event loop system call. * * @param daemon daemon to set event loop style for * @param els event loop syscall to use * @return #MHD_NO on failure, #MHD_YES on success */ _MHD_EXTERN enum MHD_Bool MHD_daemon_event_loop (struct MHD_Daemon *daemon, enum MHD_EventLoopSyscall els) MHD_NONNULL (1); /** * Protocol strictness enforced by MHD on clients. */ enum MHD_ProtocolStrictLevel { /** * Be particularly permissive about the protocol, allowing slight * deviations that are technically not allowed by the * RFC. Specifically, at the moment, this flag causes MHD to allow * spaces in header field names. This is disallowed by the standard. * It is not recommended to set this value on publicly available * servers as it may potentially lower level of protection. */ MHD_PSL_PERMISSIVE = -1, /** * Sane level of protocol enforcement for production use. */ MHD_PSL_DEFAULT = 0, /** * Be strict about the protocol (as opposed to as tolerant as * possible). Specifically, at the moment, this flag causes MHD to * reject HTTP 1.1 connections without a "Host" header. This is * required by the standard, but of course in violation of the "be * as liberal as possible in what you accept" norm. It is * recommended to set this if you are testing clients against * MHD, and to use default in production. */ MHD_PSL_STRICT = 1 }; /** * Set how strictly MHD will enforce the HTTP protocol. * * @param daemon daemon to configure strictness for * @param sl how strict should we be */ _MHD_EXTERN void MHD_daemon_protocol_strict_level (struct MHD_Daemon *daemon, enum MHD_ProtocolStrictLevel sl) MHD_NONNULL (1); /** * Use SHOUTcast. This will cause the response to begin * with the SHOUTcast "ICY" line instead of "HTTP". * * @param daemon daemon to set SHOUTcast option for */ _MHD_EXTERN void MHD_daemon_enable_shoutcast (struct MHD_Daemon *daemon) MHD_NONNULL (1); /** * Enable and configure TLS. * * @param daemon which instance should be configured * @param tls_backend which TLS backend should be used, * currently only "gnutls" is supported. You can * also specify NULL for best-available (which is the default). * @param ciphers which ciphers should be used by TLS, default is * "NORMAL" * @return status code, #MHD_SC_OK upon success * #MHD_TLS_BACKEND_UNSUPPORTED if the @a backend is unknown * #MHD_TLS_DISABLED if this build of MHD does not support TLS * #MHD_TLS_CIPHERS_INVALID if the given @a ciphers are not supported * by this backend */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon, const char *tls_backend, const char *ciphers) MHD_NONNULL (1); /** * Provide TLS key and certificate data in-memory. * * @param daemon which instance should be configured * @param mem_key private key (key.pem) to be used by the * HTTPS daemon. Must be the actual data in-memory, not a filename. * @param mem_cert certificate (cert.pem) to be used by the * HTTPS daemon. Must be the actual data in-memory, not a filename. * @param pass passphrase phrase to decrypt 'key.pem', NULL * if @param mem_key is in cleartext already * @return #MHD_SC_OK upon success; TODO: define failure modes */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon, const char *mem_key, const char *mem_cert, const char *pass) MHD_NONNULL (1,2,3); /** * Configure DH parameters (dh.pem) to use for the TLS key * exchange. * * @param daemon daemon to configure tls for * @param dh parameters to use * @return #MHD_SC_OK upon success; TODO: define failure modes */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon, const char *dh) MHD_NONNULL (1); /** * Function called to lookup the pre shared key (@a psk) for a given * HTTP connection based on the @a username. * * @param cls closure * @param connection the HTTPS connection * @param username the user name claimed by the other side * @param[out] psk to be set to the pre-shared-key; should be allocated with malloc(), * will be freed by MHD * @param[out] psk_size to be set to the number of bytes in @a psk * @return 0 on success, -1 on errors */ typedef int (*MHD_PskServerCredentialsCallback)(void *cls, const struct MHD_Connection *connection, const char *username, void **psk, size_t *psk_size); /** * Configure PSK to use for the TLS key exchange. * * @param daemon daemon to configure tls for * @param psk_cb function to call to obtain pre-shared key * @param psk_cb_cls closure for @a psk_cb * @return #MHD_SC_OK upon success; TODO: define failure modes */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_set_tls_psk_callback (struct MHD_Daemon *daemon, MHD_PskServerCredentialsCallback psk_cb, void *psk_cb_cls) MHD_NONNULL (1); /** * Memory pointer for the certificate (ca.pem) to be used by the * HTTPS daemon for client authentication. * * @param daemon daemon to configure tls for * @param mem_trust memory pointer to the certificate * @return #MHD_SC_OK upon success; TODO: define failure modes */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon, const char *mem_trust) MHD_NONNULL (1); /** * Configure daemon credentials type for GnuTLS. * * @param gnutls_credentials must be a value of * type `gnutls_credentials_type_t` * @return #MHD_SC_OK upon success; TODO: define failure modes */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon, int gnutls_credentials) MHD_NONNULL (1); /** * Provide TLS key and certificate data via callback. * * Use a callback to determine which X.509 certificate should be used * for a given HTTPS connection. This option provides an alternative * to #MHD_daemon_tls_key_and_cert_from_memory(). You must use this * version if multiple domains are to be hosted at the same IP address * using TLS's Server Name Indication (SNI) extension. In this case, * the callback is expected to select the correct certificate based on * the SNI information provided. The callback is expected to access * the SNI data using `gnutls_server_name_get()`. Using this option * requires GnuTLS 3.0 or higher. * * @param daemon daemon to configure callback for * @param cb must be of type `gnutls_certificate_retrieve_function2 *`. * @return #MHD_SC_OK on success */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_gnutls_key_and_cert_from_callback (struct MHD_Daemon *daemon, void *cb) MHD_NONNULL (1); /** * Which threading mode should be used by MHD? */ enum MHD_ThreadingMode { /** * MHD should create its own thread for listening and furthermore * create another thread per connection to handle requests. Use * this if handling requests is CPU-intensive or blocking, your * application is thread-safe and you have plenty of memory (per * request). */ MHD_TM_THREAD_PER_CONNECTION = -1, /** * Use an external event loop. This is the default. */ MHD_TM_EXTERNAL_EVENT_LOOP = 0, /** * Run with one or more worker threads. Any positive value * means that MHD should start that number of worker threads * (so > 1 is a thread pool) and distributed processing of * requests among the workers. * * A good way to express the use of a thread pool * in your code would be to write "MHD_TM_THREAD_POOL(4)" * to indicate four threads. * * If a positive value is set, * #MHD_daemon_run() and * #MHD_daemon_run_from_select() cannot be used. */ MHD_TM_WORKER_THREADS = 1 }; /** * Use a thread pool of size @a n. * * @return an `enum MHD_ThreadingMode` for a thread pool of size @a n */ #define MHD_TM_THREAD_POOL(n) ((enum MHD_ThreadingMode) (n)) /** * Specify threading mode to use. * * @param daemon daemon to configure * @param tm mode to use (positive values indicate the * number of worker threads to be used) */ _MHD_EXTERN void MHD_daemon_threading_mode (struct MHD_Daemon *daemon, enum MHD_ThreadingMode tm) MHD_NONNULL (1); /** * Allow or deny a client to connect. * * @param cls closure * @param addr address information from the client * @param addrlen length of @a addr * @see #MHD_daemon_accept_policy() * @return #MHD_YES if connection is allowed, #MHD_NO if not */ typedef enum MHD_Bool (*MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, size_t addrlen); /** * Set a policy callback that accepts/rejects connections * based on the client's IP address. This function will be called * before a connection object is created. * * @param daemon daemon to set policy for * @param apc function to call to check the policy * @param apc_cls closure for @a apc */ _MHD_EXTERN void MHD_daemon_accept_policy (struct MHD_Daemon *daemon, MHD_AcceptPolicyCallback apc, void *apc_cls) MHD_NONNULL (1); /** * Function called by MHD to allow the application to log * the full @a uri of a @a request. * * @param cls client-defined closure * @param uri the full URI from the HTTP request * @param request the HTTP request handle (headers are * not yet available) * @return value to set for the "request_context" of @a request */ typedef void * (*MHD_EarlyUriLogCallback)(void *cls, const char *uri, struct MHD_Request *request); /** * Register a callback to be called first for every request * (before any parsing of the header). Makes it easy to * log the full URL. * * @param daemon daemon for which to set the logger * @param cb function to call * @param cb_cls closure for @a cb */ _MHD_EXTERN void MHD_daemon_set_early_uri_logger (struct MHD_Daemon *daemon, MHD_EarlyUriLogCallback cb, void *cb_cls) MHD_NONNULL (1); /** * The `enum MHD_ConnectionNotificationCode` specifies types * of connection notifications. * @ingroup request */ enum MHD_ConnectionNotificationCode { /** * A new connection has been started. * @ingroup request */ MHD_CONNECTION_NOTIFY_STARTED = 0, /** * A connection is closed. * @ingroup request */ MHD_CONNECTION_NOTIFY_CLOSED = 1 }; /** * Signature of the callback used by MHD to notify the * application about started/stopped connections * * @param cls client-defined closure * @param connection connection handle * @param socket_context socket-specific pointer where the * client can associate some state specific * to the TCP connection; note that this is * different from the "req_cls" which is per * HTTP request. The client can initialize * during #MHD_CONNECTION_NOTIFY_STARTED and * cleanup during #MHD_CONNECTION_NOTIFY_CLOSED * and access in the meantime using * #MHD_CONNECTION_INFO_SOCKET_CONTEXT. * @param toe reason for connection notification * @see #MHD_OPTION_NOTIFY_CONNECTION * @ingroup request */ typedef void (*MHD_NotifyConnectionCallback) (void *cls, struct MHD_Connection *connection, enum MHD_ConnectionNotificationCode toe); /** * Register a function that should be called whenever a connection is * started or closed. * * @param daemon daemon to set callback for * @param ncc function to call to check the policy * @param ncc_cls closure for @a apc */ _MHD_EXTERN void MHD_daemon_set_notify_connection (struct MHD_Daemon *daemon, MHD_NotifyConnectionCallback ncc, void *ncc_cls) MHD_NONNULL (1); /** * Maximum memory size per connection. * Default is 32 kb (#MHD_POOL_SIZE_DEFAULT). * Values above 128k are unlikely to result in much benefit, as half * of the memory will be typically used for IO, and TCP buffers are * unlikely to support window sizes above 64k on most systems. * * @param daemon daemon to configure * @param memory_limit_b connection memory limit to use in bytes * @param memory_increment_b increment to use when growing the read buffer, must be smaller than @a memory_limit_b */ _MHD_EXTERN void MHD_daemon_connection_memory_limit (struct MHD_Daemon *daemon, size_t memory_limit_b, size_t memory_increment_b) MHD_NONNULL (1); /** * Desired size of the stack for threads created by MHD. Use 0 for * system default. Only useful if the selected threading mode * is not #MHD_TM_EXTERNAL_EVENT_LOOP. * * @param daemon daemon to configure * @param stack_limit_b stack size to use in bytes */ _MHD_EXTERN void MHD_daemon_thread_stack_size (struct MHD_Daemon *daemon, size_t stack_limit_b) MHD_NONNULL (1); /** * Set maximum number of concurrent connections to accept. If not * given, MHD will not enforce any limits (modulo running into * OS limits). Values of 0 mean no limit. * * @param daemon daemon to configure * @param global_connection_limit maximum number of (concurrent) connections * @param ip_connection_limit limit on the number of (concurrent) * connections made to the server from the same IP address. * Can be used to prevent one IP from taking over all of * the allowed connections. If the same IP tries to * establish more than the specified number of * connections, they will be immediately rejected. */ _MHD_EXTERN void MHD_daemon_connection_limits (struct MHD_Daemon *daemon, unsigned int global_connection_limit, unsigned int ip_connection_limit) MHD_NONNULL (1); /** * After how many seconds of inactivity should a * connection automatically be timed out? * Use zero for no timeout, which is also the (unsafe!) default. * * @param daemon daemon to configure * @param timeout_s number of seconds of timeout to use */ _MHD_EXTERN void MHD_daemon_connection_default_timeout (struct MHD_Daemon *daemon, unsigned int timeout_s) MHD_NONNULL (1); /** * Signature of functions performing unescaping of strings. * The return value must be "strlen(s)" and @a s should be * updated. Note that the unescape function must not lengthen @a s * (the result must be shorter than the input and still be * 0-terminated). * * @param cls closure * @param req the request for which unescaping is performed * @param[in,out] s string to unescape * @return number of characters in @a s (excluding 0-terminator) */ typedef size_t (*MHD_UnescapeCallback) (void *cls, struct MHD_Request *req, char *s); /** * Specify a function that should be called for unescaping escape * sequences in URIs and URI arguments. Note that this function * will NOT be used by the `struct MHD_PostProcessor`. If this * option is not specified, the default method will be used which * decodes escape sequences of the form "%HH". * * @param daemon daemon to configure * @param unescape_cb function to use, NULL for default * @param unescape_cb_cls closure for @a unescape_cb */ _MHD_EXTERN void MHD_daemon_unescape_cb (struct MHD_Daemon *daemon, MHD_UnescapeCallback unescape_cb, void *unescape_cb_cls) MHD_NONNULL (1); /** * Set random values to be used by the Digest Auth module. Note that * the application must ensure that @a buf remains allocated and * unmodified while the daemon is running. * * @param daemon daemon to configure * @param buf_size number of bytes in @a buf * @param buf entropy buffer */ _MHD_EXTERN void MHD_daemon_digest_auth_random (struct MHD_Daemon *daemon, size_t buf_size, const void *buf) MHD_NONNULL (1,3); /** * Length of the internal array holding the map of the nonce and * the nonce counter. * * @param daemon daemon to configure * @param nc_length desired array length */ _MHD_EXTERN enum MHD_StatusCode MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon, size_t nc_length) MHD_NONNULL (1); /* ********************* connection options ************** */ /** * Set custom timeout for the given connection. * Specified as the number of seconds. Use zero for no timeout. * Calling this function will reset timeout timer. * * @param connection connection to configure timeout for * @param timeout_s new timeout in seconds */ _MHD_EXTERN void MHD_connection_set_timeout (struct MHD_Connection *connection, unsigned int timeout_s) MHD_NONNULL (1); /* **************** Request handling functions ***************** */ /** * The `enum MHD_ValueKind` specifies the source of * the key-value pairs in the HTTP protocol. */ enum MHD_ValueKind { /** * HTTP header (request/response). */ MHD_HEADER_KIND = 1, /** * Cookies. Note that the original HTTP header containing * the cookie(s) will still be available and intact. */ MHD_COOKIE_KIND = 2, /** * POST data. This is available only if a content encoding * supported by MHD is used (currently only URL encoding), * and only if the posted content fits within the available * memory pool. Note that in that case, the upload data * given to the #MHD_AccessHandlerCallback will be * empty (since it has already been processed). */ MHD_POSTDATA_KIND = 4, /** * GET (URI) arguments. */ MHD_GET_ARGUMENT_KIND = 8, /** * HTTP footer (only for HTTP 1.1 chunked encodings). */ MHD_FOOTER_KIND = 16 }; /** * Iterator over key-value pairs. This iterator can be used to * iterate over all of the cookies, headers, or POST-data fields of a * request, and also to iterate over the headers that have been added * to a response. * * @param cls closure * @param kind kind of the header we are looking at * @param key key for the value, can be an empty string * @param value corresponding value, can be NULL * @return #MHD_YES to continue iterating, * #MHD_NO to abort the iteration * @ingroup request */ typedef int (*MHD_KeyValueIterator) (void *cls, enum MHD_ValueKind kind, const char *key, const char *value); /** * Get all of the headers from the request. * * @param request request to get values from * @param kind types of values to iterate over, can be a bitmask * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator * @return number of entries iterated over * @ingroup request */ _MHD_EXTERN unsigned int MHD_request_get_values (struct MHD_Request *request, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) MHD_NONNULL (1); /** * This function can be used to add an entry to the HTTP headers of a * request (so that the #MHD_request_get_values function will * return them -- and the `struct MHD_PostProcessor` will also see * them). This maybe required in certain situations (see Mantis * #1399) where (broken) HTTP implementations fail to supply values * needed by the post processor (or other parts of the application). * * This function MUST only be called from within the * request callbacks (otherwise, access maybe improperly * synchronized). Furthermore, the client must guarantee that the key * and value arguments are 0-terminated strings that are NOT freed * until the connection is closed. (The easiest way to do this is by * passing only arguments to permanently allocated strings.). * * @param request the request for which a * value should be set * @param kind kind of the value * @param key key for the value * @param value the value itself * @return #MHD_NO if the operation could not be * performed due to insufficient memory; * #MHD_YES on success * @ingroup request */ _MHD_EXTERN enum MHD_Bool MHD_request_set_value (struct MHD_Request *request, enum MHD_ValueKind kind, const char *key, const char *value) MHD_NONNULL (1,3,4); /** * Get a particular header value. If multiple * values match the kind, return any one of them. * * @param request request to get values from * @param kind what kind of value are we looking for * @param key the header to look for, NULL to lookup 'trailing' value without a key * @return NULL if no such item was found * @ingroup request */ _MHD_EXTERN const char * MHD_request_lookup_value (struct MHD_Request *request, enum MHD_ValueKind kind, const char *key) MHD_NONNULL (1); /** * @defgroup httpcode HTTP response codes. * These are the status codes defined for HTTP responses. * @{ */ /* See http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml */ enum MHD_HTTP_StatusCode { MHD_HTTP_CONTINUE = 100, MHD_HTTP_SWITCHING_PROTOCOLS = 101, MHD_HTTP_PROCESSING = 102, MHD_HTTP_OK = 200, MHD_HTTP_CREATED = 201, MHD_HTTP_ACCEPTED = 202, MHD_HTTP_NON_AUTHORITATIVE_INFORMATION = 203, MHD_HTTP_NO_CONTENT = 204, MHD_HTTP_RESET_CONTENT = 205, MHD_HTTP_PARTIAL_CONTENT = 206, MHD_HTTP_MULTI_STATUS = 207, MHD_HTTP_ALREADY_REPORTED = 208, MHD_HTTP_IM_USED = 226, MHD_HTTP_MULTIPLE_CHOICES = 300, MHD_HTTP_MOVED_PERMANENTLY = 301, MHD_HTTP_FOUND = 302, MHD_HTTP_SEE_OTHER = 303, MHD_HTTP_NOT_MODIFIED = 304, MHD_HTTP_USE_PROXY = 305, MHD_HTTP_SWITCH_PROXY = 306, /* IANA: unused */ MHD_HTTP_TEMPORARY_REDIRECT = 307, MHD_HTTP_PERMANENT_REDIRECT = 308, MHD_HTTP_BAD_REQUEST = 400, MHD_HTTP_UNAUTHORIZED = 401, MHD_HTTP_PAYMENT_REQUIRED = 402, MHD_HTTP_FORBIDDEN = 403, MHD_HTTP_NOT_FOUND = 404, MHD_HTTP_METHOD_NOT_ALLOWED = 405, MHD_HTTP_NOT_ACCEPTABLE = 406, /** @deprecated */ #define MHD_HTTP_METHOD_NOT_ACCEPTABLE \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_HTTP_METHOD_NOT_ACCEPTABLE is deprecated, use MHD_HTTP_NOT_ACCEPTABLE") \ MHD_HTTP_NOT_ACCEPTABLE MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED = 407, MHD_HTTP_REQUEST_TIMEOUT = 408, MHD_HTTP_CONFLICT = 409, MHD_HTTP_GONE = 410, MHD_HTTP_LENGTH_REQUIRED = 411, MHD_HTTP_PRECONDITION_FAILED = 412, MHD_HTTP_PAYLOAD_TOO_LARGE = 413, /** @deprecated */ #define MHD_HTTP_REQUEST_ENTITY_TOO_LARGE \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_HTTP_REQUEST_ENTITY_TOO_LARGE is deprecated, use MHD_HTTP_PAYLOAD_TOO_LARGE") \ MHD_HTTP_PAYLOAD_TOO_LARGE MHD_HTTP_URI_TOO_LONG = 414, /** @deprecated */ #define MHD_HTTP_REQUEST_URI_TOO_LONG \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_HTTP_REQUEST_URI_TOO_LONG is deprecated, use MHD_HTTP_URI_TOO_LONG") \ MHD_HTTP_URI_TOO_LONG MHD_HTTP_UNSUPPORTED_MEDIA_TYPE = 415, MHD_HTTP_RANGE_NOT_SATISFIABLE = 416, /** @deprecated */ #define MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE \ _MHD_DEPR_IN_MACRO ( \ "Value MHD_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE is deprecated, use MHD_HTTP_RANGE_NOT_SATISFIABLE") \ MHD_HTTP_RANGE_NOT_SATISFIABLE MHD_HTTP_EXPECTATION_FAILED = 417, MHD_HTTP_MISDIRECTED_REQUEST = 421, MHD_HTTP_UNPROCESSABLE_ENTITY = 422, MHD_HTTP_LOCKED = 423, MHD_HTTP_FAILED_DEPENDENCY = 424, MHD_HTTP_UNORDERED_COLLECTION = 425, /* IANA: unused */ MHD_HTTP_UPGRADE_REQUIRED = 426, MHD_HTTP_PRECONDITION_REQUIRED = 428, MHD_HTTP_TOO_MANY_REQUESTS = 429, MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431, MHD_HTTP_NO_RESPONSE = 444, /* IANA: unused */ MHD_HTTP_RETRY_WITH = 449, /* IANA: unused */ MHD_HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS = 450, /* IANA: unused */ MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451, MHD_HTTP_INTERNAL_SERVER_ERROR = 500, MHD_HTTP_NOT_IMPLEMENTED = 501, MHD_HTTP_BAD_GATEWAY = 502, MHD_HTTP_SERVICE_UNAVAILABLE = 503, MHD_HTTP_GATEWAY_TIMEOUT = 504, MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED = 505, MHD_HTTP_VARIANT_ALSO_NEGOTIATES = 506, MHD_HTTP_INSUFFICIENT_STORAGE = 507, MHD_HTTP_LOOP_DETECTED = 508, MHD_HTTP_BANDWIDTH_LIMIT_EXCEEDED = 509, /* IANA: unused */ MHD_HTTP_NOT_EXTENDED = 510, MHD_HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511 }; /** * Returns the string reason phrase for a response code. * * If we don't have a string for a status code, we give the first * message in that status code class. */ _MHD_EXTERN const char * MHD_get_reason_phrase_for (enum MHD_HTTP_StatusCode code); /** @} */ /* end of group httpcode */ /** * @defgroup versions HTTP versions * These strings should be used to match against the first line of the * HTTP header. * @{ */ #define MHD_HTTP_VERSION_1_0 "HTTP/1.0" #define MHD_HTTP_VERSION_1_1 "HTTP/1.1" /** @} */ /* end of group versions */ /** * Suspend handling of network data for a given request. This can * be used to dequeue a request from MHD's event loop for a while. * * If you use this API in conjunction with a internal select or a * thread pool, you must set the option #MHD_USE_ITC to * ensure that a resumed request is immediately processed by MHD. * * Suspended requests continue to count against the total number of * requests allowed (per daemon, as well as per IP, if such limits * are set). Suspended requests will NOT time out; timeouts will * restart when the request handling is resumed. While a * request is suspended, MHD will not detect disconnects by the * client. * * The only safe time to suspend a request is from either a * #MHD_RequestHeaderCallback, #MHD_UploadCallback, or a * #MHD_RequestfetchResponseCallback. Suspending a request * at any other time will cause an assertion failure. * * Finally, it is an API violation to call #MHD_daemon_stop() while * having suspended requests (this will at least create memory and * socket leaks or lead to undefined behavior). You must explicitly * resume all requests before stopping the daemon. * * @return action to cause a request to be suspended. */ _MHD_EXTERN const struct MHD_Action * MHD_action_suspend (void); /** * Resume handling of network data for suspended request. It is * safe to resume a suspended request at any time. Calling this * function on a request that was not previously suspended will * result in undefined behavior. * * If you are using this function in ``external'' select mode, you must * make sure to run #MHD_run() afterwards (before again calling * #MHD_get_fdset(), as otherwise the change may not be reflected in * the set returned by #MHD_get_fdset() and you may end up with a * request that is stuck until the next network activity. * * @param request the request to resume */ _MHD_EXTERN void MHD_request_resume (struct MHD_Request *request) MHD_NONNULL (1); /* **************** Response manipulation functions ***************** */ /** * Data transmitted in response to an HTTP request. * Usually the final action taken in response to * receiving a request. */ struct MHD_Response; /** * Converts a @a response to an action. If @a destroy_after_use * is set, the reference to the @a response is consumed * by the conversion. If @a consume is #MHD_NO, then * the @a response can be converted to actions in the future. * However, the @a response is frozen by this step and * must no longer be modified (i.e. by setting headers). * * @param response response to convert, not NULL * @param destroy_after_use should the response object be consumed? * @return corresponding action, never returns NULL * * Implementation note: internally, this is largely just * a cast (and possibly an RC increment operation), * as a response *is* an action. As no memory is * allocated, this operation cannot fail. */ _MHD_EXTERN const struct MHD_Action * MHD_action_from_response (struct MHD_Response *response, enum MHD_Bool destroy_after_use) MHD_NONNULL (1); /** * Only respond in conservative HTTP 1.0-mode. In * particular, do not (automatically) sent "Connection" headers and * always close the connection after generating the response. * * @param request the request for which we force HTTP 1.0 to be used */ _MHD_EXTERN void MHD_response_option_v10_only (struct MHD_Response *response) MHD_NONNULL (1); /** * The `enum MHD_RequestTerminationCode` specifies reasons * why a request has been terminated (or completed). * @ingroup request */ enum MHD_RequestTerminationCode { /** * We finished sending the response. * @ingroup request */ MHD_REQUEST_TERMINATED_COMPLETED_OK = 0, /** * Error handling the connection (resources * exhausted, other side closed connection, * application error accepting request, etc.) * @ingroup request */ MHD_REQUEST_TERMINATED_WITH_ERROR = 1, /** * No activity on the connection for the number * of seconds specified using * #MHD_OPTION_CONNECTION_TIMEOUT. * @ingroup request */ MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 2, /** * We had to close the session since MHD was being * shut down. * @ingroup request */ MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 3, /** * We tried to read additional data, but the other side closed the * connection. This error is similar to * #MHD_REQUEST_TERMINATED_WITH_ERROR, but specific to the case where * the connection died because the other side did not send expected * data. * @ingroup request */ MHD_REQUEST_TERMINATED_READ_ERROR = 4, /** * The client terminated the connection by closing the socket * for writing (TCP half-closed); MHD aborted sending the * response according to RFC 2616, section 8.1.4. * @ingroup request */ MHD_REQUEST_TERMINATED_CLIENT_ABORT = 5 }; /** * Signature of the callback used by MHD to notify the application * about completed requests. * * @param cls client-defined closure * @param toe reason for request termination * @param request_context request context value, as originally * returned by the #MHD_EarlyUriLogCallback * @see #MHD_option_request_completion() * @ingroup request */ typedef void (*MHD_RequestTerminationCallback) (void *cls, enum MHD_RequestTerminationCode toe, void *request_context); /** * Set a function to be called once MHD is finished with the * request. * * @param response which response to set the callback for * @param termination_cb function to call * @param termination_cb_cls closure for @e termination_cb */ _MHD_EXTERN void MHD_response_option_termination_callback (struct MHD_Response *response, MHD_RequestTerminationCallback termination_cb, void *termination_cb_cls) MHD_NONNULL (1); /** * Callback used by libmicrohttpd in order to obtain content. The * callback is to copy at most @a max bytes of content into @a buf. The * total number of bytes that has been placed into @a buf should be * returned. * * Note that returning zero will cause libmicrohttpd to try again. * Thus, returning zero should only be used in conjunction * with MHD_suspend_connection() to avoid busy waiting. * * @param cls extra argument to the callback * @param pos position in the datastream to access; * note that if a `struct MHD_Response` object is re-used, * it is possible for the same content reader to * be queried multiple times for the same data; * however, if a `struct MHD_Response` is not re-used, * libmicrohttpd guarantees that "pos" will be * the sum of all non-negative return values * obtained from the content reader so far. * @param buf where to copy the data * @param max maximum number of bytes to copy to @a buf (size of @a buf) * @return number of bytes written to @a buf; * 0 is legal unless we are running in internal select mode (since * this would cause busy-waiting); 0 in external select mode * will cause this function to be called again once the external * select calls MHD again; * #MHD_CONTENT_READER_END_OF_STREAM (-1) for the regular * end of transmission (with chunked encoding, MHD will then * terminate the chunk and send any HTTP footers that might be * present; without chunked encoding and given an unknown * response size, MHD will simply close the connection; note * that while returning #MHD_CONTENT_READER_END_OF_STREAM is not technically * legal if a response size was specified, MHD accepts this * and treats it just as #MHD_CONTENT_READER_END_WITH_ERROR; * #MHD_CONTENT_READER_END_WITH_ERROR (-2) to indicate a server * error generating the response; this will cause MHD to simply * close the connection immediately. If a response size was * given or if chunked encoding is in use, this will indicate * an error to the client. Note, however, that if the client * does not know a response size and chunked encoding is not in * use, then clients will not be able to tell the difference between * #MHD_CONTENT_READER_END_WITH_ERROR and #MHD_CONTENT_READER_END_OF_STREAM. * This is not a limitation of MHD but rather of the HTTP protocol. */ typedef ssize_t (*MHD_ContentReaderCallback) (void *cls, uint64_t pos, char *buf, size_t max); /** * This method is called by libmicrohttpd if we are done with a * content reader. It should be used to free resources associated * with the content reader. * * @param cls closure * @ingroup response */ typedef void (*MHD_ContentReaderFreeCallback) (void *cls); /** * Create a response action. The response object can be extended with * header information and then be used any number of times. * * @param sc status code to return * @param size size of the data portion of the response, #MHD_SIZE_UNKNOWN for unknown * @param block_size preferred block size for querying crc (advisory only, * MHD may still call @a crc using smaller chunks); this * is essentially the buffer size used for IO, clients * should pick a value that is appropriate for IO and * memory performance requirements * @param crc callback to use to obtain response data * @param crc_cls extra argument to @a crc * @param crfc callback to call to free @a crc_cls resources * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_response_from_callback (enum MHD_HTTP_StatusCode sc, uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc); /** * Specification for how MHD should treat the memory buffer * given for the response. * @ingroup response */ enum MHD_ResponseMemoryMode { /** * Buffer is a persistent (static/global) buffer that won't change * for at least the lifetime of the response, MHD should just use * it, not free it, not copy it, just keep an alias to it. * @ingroup response */ MHD_RESPMEM_PERSISTENT, /** * Buffer is heap-allocated with `malloc()` (or equivalent) and * should be freed by MHD after processing the response has * concluded (response reference counter reaches zero). * @ingroup response */ MHD_RESPMEM_MUST_FREE, /** * Buffer is in transient memory, but not on the heap (for example, * on the stack or non-`malloc()` allocated) and only valid during the * call to #MHD_create_response_from_buffer. MHD must make its * own private copy of the data for processing. * @ingroup response */ MHD_RESPMEM_MUST_COPY }; /** * Create a response object. The response object can be extended with * header information and then be used any number of times. * * @param sc status code to use for the response; * #MHD_HTTP_NO_CONTENT is only valid if @a size is 0; * @param size size of the data portion of the response * @param buffer size bytes containing the response's data portion * @param mode flags for buffer management * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_response_from_buffer (enum MHD_HTTP_StatusCode sc, size_t size, void *buffer, enum MHD_ResponseMemoryMode mode); /** * Create a response object based on an @a fd from which * data is read. The response object can be extended with * header information and then be used any number of times. * * @param sc status code to return * @param fd file descriptor referring to a file on disk with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @param offset offset to start reading from in the file; * reading file beyond 2 GiB may be not supported by OS or * MHD build; see ::MHD_FEATURE_LARGE_FILE * @param size size of the data portion of the response; * sizes larger than 2 GiB may be not supported by OS or * MHD build; see ::MHD_FEATURE_LARGE_FILE * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_response_from_fd (enum MHD_HTTP_StatusCode sc, int fd, uint64_t offset, uint64_t size); /** * Enumeration for operations MHD should perform on the underlying socket * of the upgrade. This API is not finalized, and in particular * the final set of actions is yet to be decided. This is just an * idea for what we might want. */ enum MHD_UpgradeOperation { /** * Close the socket, the application is done with it. * * Takes no extra arguments. */ MHD_UPGRADE_OPERATION_CLOSE = 0 }; /** * Handle given to the application to manage special * actions relating to MHD responses that "upgrade" * the HTTP protocol (i.e. to WebSockets). */ struct MHD_UpgradeResponseHandle; /** * This connection-specific callback is provided by MHD to * applications (unusual) during the #MHD_UpgradeHandler. * It allows applications to perform 'special' actions on * the underlying socket from the upgrade. * * FIXME: this API still uses the untyped, ugly varargs. * Should we not modernize this one as well? * * @param urh the handle identifying the connection to perform * the upgrade @a action on. * @param operation which operation should be performed * @param ... arguments to the action (depends on the action) * @return #MHD_NO on error, #MHD_YES on success */ _MHD_EXTERN enum MHD_Bool MHD_upgrade_operation (struct MHD_UpgradeResponseHandle *urh, enum MHD_UpgradeOperation operation, ...) MHD_NONNULL (1); /** * Function called after a protocol "upgrade" response was sent * successfully and the socket should now be controlled by some * protocol other than HTTP. * * Any data already received on the socket will be made available in * @e extra_in. This can happen if the application sent extra data * before MHD send the upgrade response. The application should * treat data from @a extra_in as if it had read it from the socket. * * Note that the application must not close() @a sock directly, * but instead use #MHD_upgrade_action() for special operations * on @a sock. * * Data forwarding to "upgraded" @a sock will be started as soon * as this function return. * * Except when in 'thread-per-connection' mode, implementations * of this function should never block (as it will still be called * from within the main event loop). * * @param cls closure, whatever was given to #MHD_response_create_for_upgrade(). * @param connection original HTTP connection handle, * giving the function a last chance * to inspect the original HTTP request * @param req_cls last value left in `req_cls` of the `MHD_AccessHandlerCallback` * @param extra_in if we happened to have read bytes after the * HTTP header already (because the client sent * more than the HTTP header of the request before * we sent the upgrade response), * these are the extra bytes already read from @a sock * by MHD. The application should treat these as if * it had read them from @a sock. * @param extra_in_size number of bytes in @a extra_in * @param sock socket to use for bi-directional communication * with the client. For HTTPS, this may not be a socket * that is directly connected to the client and thus certain * operations (TCP-specific setsockopt(), getsockopt(), etc.) * may not work as expected (as the socket could be from a * socketpair() or a TCP-loopback). The application is expected * to perform read()/recv() and write()/send() calls on the socket. * The application may also call shutdown(), but must not call * close() directly. * @param urh argument for #MHD_upgrade_action()s on this @a connection. * Applications must eventually use this callback to (indirectly) * perform the close() action on the @a sock. */ typedef void (*MHD_UpgradeHandler)(void *cls, struct MHD_Connection *connection, void *req_cls, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh); /** * Create a response object that can be used for 101 UPGRADE * responses, for example to implement WebSockets. After sending the * response, control over the data stream is given to the callback (which * can then, for example, start some bi-directional communication). * If the response is queued for multiple connections, the callback * will be called for each connection. The callback * will ONLY be called after the response header was successfully passed * to the OS; if there are communication errors before, the usual MHD * connection error handling code will be performed. * * MHD will automatically set the correct HTTP status * code (#MHD_HTTP_SWITCHING_PROTOCOLS). * Setting correct HTTP headers for the upgrade must be done * manually (this way, it is possible to implement most existing * WebSocket versions using this API; in fact, this API might be useful * for any protocol switch, not just WebSockets). Note that * draft-ietf-hybi-thewebsocketprotocol-00 cannot be implemented this * way as the header "HTTP/1.1 101 WebSocket Protocol Handshake" * cannot be generated; instead, MHD will always produce "HTTP/1.1 101 * Switching Protocols" (if the response code 101 is used). * * As usual, the response object can be extended with header * information and then be used any number of times (as long as the * header information is not connection-specific). * * @param upgrade_handler function to call with the "upgraded" socket * @param upgrade_handler_cls closure for @a upgrade_handler * @return NULL on error (i.e. invalid arguments, out of memory) */ _MHD_EXTERN struct MHD_Response * MHD_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, void *upgrade_handler_cls) MHD_NONNULL (1); /** * Explicitly decrease reference counter of a response object. If the * counter hits zero, destroys a response object and associated * resources. Usually, this is implicitly done by converting a * response to an action and returning the action to MHD. * * @param response response to decrement RC of * @ingroup response */ _MHD_EXTERN void MHD_response_queue_for_destroy (struct MHD_Response *response) MHD_NONNULL (1); /** * Add a header line to the response. * * @param response response to add a header to * @param header the header to add * @param content value to add * @return #MHD_NO on error (i.e. invalid header or content format), * or out of memory * @ingroup response */ _MHD_EXTERN enum MHD_Bool MHD_response_add_header (struct MHD_Response *response, const char *header, const char *content) MHD_NONNULL (1,2,3); /** * Add a tailer line to the response. * * @param response response to add a footer to * @param footer the footer to add * @param content value to add * @return #MHD_NO on error (i.e. invalid footer or content format), * or out of memory * @ingroup response */ _MHD_EXTERN enum MHD_Bool MHD_response_add_trailer (struct MHD_Response *response, const char *footer, const char *content) MHD_NONNULL (1,2,3); /** * Delete a header (or footer) line from the response. * * @param response response to remove a header from * @param header the header to delete * @param content value to delete * @return #MHD_NO on error (no such header known) * @ingroup response */ _MHD_EXTERN enum MHD_Bool MHD_response_del_header (struct MHD_Response *response, const char *header, const char *content) MHD_NONNULL (1,2,3); /** * Get all of the headers (and footers) added to a response. * * @param response response to query * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator * @return number of entries iterated over * @ingroup response */ _MHD_EXTERN unsigned int MHD_response_get_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls) MHD_NONNULL (1); /** * Get a particular header (or footer) from the response. * * @param response response to query * @param key which header to get * @return NULL if header does not exist * @ingroup response */ _MHD_EXTERN const char * MHD_response_get_header (struct MHD_Response *response, const char *key) MHD_NONNULL (1,2); /* ************Upload and PostProcessor functions ********************** */ /** * Action telling MHD to continue processing the upload. * * @return action operation, never NULL */ _MHD_EXTERN const struct MHD_Action * MHD_action_continue (void); /** * Function to process data uploaded by a client. * * @param cls argument given together with the function * pointer when the handler was registered with MHD * @param upload_data the data being uploaded (excluding headers) * POST data will typically be made available incrementally via * multiple callbacks * @param[in,out] upload_data_size set initially to the size of the * @a upload_data provided; the method must update this * value to the number of bytes NOT processed; * @return action specifying how to proceed, often * #MHD_action_continue() if all is well, * #MHD_action_suspend() to stop reading the upload until * the request is resumed, * NULL to close the socket, or a response * to discard the rest of the upload and return the data given */ typedef const struct MHD_Action * (*MHD_UploadCallback) (void *cls, const char *upload_data, size_t *upload_data_size); /** * Create an action that handles an upload. * * @param uc function to call with uploaded data * @param uc_cls closure for @a uc * @return NULL on error (out of memory) * @ingroup action */ _MHD_EXTERN const struct MHD_Action * MHD_action_process_upload (MHD_UploadCallback uc, void *uc_cls) MHD_NONNULL (1); /** * Iterator over key-value pairs where the value maybe made available * in increments and/or may not be zero-terminated. Used for * MHD parsing POST data. To access "raw" data from POST or PUT * requests, use #MHD_action_process_upload() instead. * * @param cls user-specified closure * @param kind type of the value, always #MHD_POSTDATA_KIND when called from MHD * @param key 0-terminated key for the value * @param filename name of the uploaded file, NULL if not known * @param content_type mime-type of the data, NULL if not known * @param transfer_encoding encoding of the data, NULL if not known * @param data pointer to @a size bytes of data at the * specified offset * @param off offset of data in the overall value * @param size number of bytes in @a data available * @return action specifying how to proceed, often * #MHD_action_continue() if all is well, * #MHD_action_suspend() to stop reading the upload until * the request is resumed, * NULL to close the socket, or a response * to discard the rest of the upload and return the data given */ typedef const struct MHD_Action * (*MHD_PostDataIterator) (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size); /** * Create an action that parses a POST request. * * This action can be used to (incrementally) parse the data portion * of a POST request. Note that some buggy browsers fail to set the * encoding type. If you want to support those, you may have to call * #MHD_set_connection_value with the proper encoding type before * returning this action (if no supported encoding type is detected, * returning this action will cause a bad request to be returned to * the client). * * @param buffer_size maximum number of bytes to use for * internal buffering (used only for the parsing, * specifically the parsing of the keys). A * tiny value (256-1024) should be sufficient. * Do NOT use a value smaller than 256. For good * performance, use 32 or 64k (i.e. 65536). * @param iter iterator to be called with the parsed data, * Must NOT be NULL. * @param iter_cls first argument to @a iter * @return NULL on error (out of memory, unsupported encoding), * otherwise a PP handle * @ingroup request */ _MHD_EXTERN const struct MHD_Action * MHD_action_parse_post (size_t buffer_size, MHD_PostDataIterator iter, void *iter_cls) MHD_NONNULL (2); /* ********************** generic query functions ********************** */ /** * Select which member of the `struct ConnectionInformation` * union is desired to be returned by #MHD_connection_get_info(). */ enum MHD_ConnectionInformationType { /** * What cipher algorithm is being used. * Takes no extra arguments. * @ingroup request */ MHD_CONNECTION_INFORMATION_CIPHER_ALGO, /** * * Takes no extra arguments. * @ingroup request */ MHD_CONNECTION_INFORMATION_PROTOCOL, /** * Obtain IP address of the client. Takes no extra arguments. * Returns essentially a `struct sockaddr **` (since the API returns * a `union MHD_ConnectionInfo *` and that union contains a `struct * sockaddr *`). * @ingroup request */ MHD_CONNECTION_INFORMATION_CLIENT_ADDRESS, /** * Get the gnuTLS session handle. * @ingroup request */ MHD_CONNECTION_INFORMATION_GNUTLS_SESSION, /** * Get the gnuTLS client certificate handle. Dysfunctional (never * implemented, deprecated). Use #MHD_CONNECTION_INFORMATION_GNUTLS_SESSION * to get the `gnutls_session_t` and then call * gnutls_certificate_get_peers(). */ MHD_CONNECTION_INFORMATION_GNUTLS_CLIENT_CERT, /** * Get the `struct MHD_Daemon *` responsible for managing this connection. * @ingroup request */ MHD_CONNECTION_INFORMATION_DAEMON, /** * Request the file descriptor for the connection socket. * No extra arguments should be passed. * @ingroup request */ MHD_CONNECTION_INFORMATION_CONNECTION_FD, /** * Returns the client-specific pointer to a `void *` that was (possibly) * set during a #MHD_NotifyConnectionCallback when the socket was * first accepted. Note that this is NOT the same as the "req_cls" * argument of the #MHD_AccessHandlerCallback. The "req_cls" is * fresh for each HTTP request, while the "socket_context" is fresh * for each socket. */ MHD_CONNECTION_INFORMATION_SOCKET_CONTEXT, /** * Get connection timeout * @ingroup request */ MHD_CONNECTION_INFORMATION_CONNECTION_TIMEOUT, /** * Check whether the connection is suspended. * @ingroup request */ MHD_CONNECTION_INFORMATION_CONNECTION_SUSPENDED }; /** * Information about a connection. */ union MHD_ConnectionInformation { /** * Cipher algorithm used, of type "enum gnutls_cipher_algorithm". */ int /* enum gnutls_cipher_algorithm */ cipher_algorithm; /** * Protocol used, of type "enum gnutls_protocol". */ int /* enum gnutls_protocol */ protocol; /** * Amount of second that connection could spend in idle state * before automatically disconnected. * Zero for no timeout (unlimited idle time). */ unsigned int connection_timeout; /** * Connect socket */ MHD_socket connect_fd; /** * GNUtls session handle, of type "gnutls_session_t". */ void * /* gnutls_session_t */ tls_session; /** * GNUtls client certificate handle, of type "gnutls_x509_crt_t". */ void * /* gnutls_x509_crt_t */ client_cert; /** * Address information for the client. */ const struct sockaddr *client_addr; /** * Which daemon manages this connection (useful in case there are many * daemons running). */ struct MHD_Daemon *daemon; /** * Pointer to connection-specific client context. Points to the * same address as the "socket_context" of the * #MHD_NotifyConnectionCallback. */ void **socket_context; /** * Is this connection right now suspended? */ enum MHD_Bool suspended; }; /** * Obtain information about the given connection. * Use wrapper macro #MHD_connection_get_information() instead of direct use * of this function. * * @param connection what connection to get information about * @param info_type what information is desired? * @param[out] return_value pointer to union where requested information will * be stored * @param return_value_size size of union MHD_ConnectionInformation at compile * time * @return #MHD_YES on success, #MHD_NO on error * (@a info_type is unknown, NULL pointer etc.) * @ingroup specialized */ _MHD_EXTERN enum MHD_Bool MHD_connection_get_information_sz (struct MHD_Connection *connection, enum MHD_ConnectionInformationType info_type, union MHD_ConnectionInformation *return_value, size_t return_value_size) MHD_NONNULL (1,3); /** * Obtain information about the given connection. * * @param connection what connection to get information about * @param info_type what information is desired? * @param[out] return_value pointer to union where requested information will * be stored * @return #MHD_YES on success, #MHD_NO on error * (@a info_type is unknown, NULL pointer etc.) * @ingroup specialized */ #define MHD_connection_get_information(connection, \ info_type, \ return_value) \ MHD_connection_get_information_sz ((connection),(info_type),(return_value), \ sizeof(union MHD_ConnectionInformation)) /** * Information we return about a request. */ union MHD_RequestInformation { /** * Connection via which we received the request. */ struct MHD_Connection *connection; /** * Pointer to client context. Will also be given to * the application in a #MHD_RequestTerminationCallback. */ void **request_context; /** * HTTP version requested by the client. */ const char *http_version; /** * HTTP method of the request, as a string. Particularly useful if * #MHD_HTTP_METHOD_UNKNOWN was given. */ const char *http_method; /** * Size of the client's HTTP header. */ size_t header_size; }; /** * Select which member of the `struct RequestInformation` * union is desired to be returned by #MHD_request_get_info(). */ enum MHD_RequestInformationType { /** * Return which connection the request is associated with. */ MHD_REQUEST_INFORMATION_CONNECTION, /** * Returns the client-specific pointer to a `void *` that * is specific to this request. */ MHD_REQUEST_INFORMATION_CLIENT_CONTEXT, /** * Return the HTTP version string given by the client. * @ingroup request */ MHD_REQUEST_INFORMATION_HTTP_VERSION, /** * Return the HTTP method used by the request. * @ingroup request */ MHD_REQUEST_INFORMATION_HTTP_METHOD, /** * Return length of the client's HTTP request header. * @ingroup request */ MHD_REQUEST_INFORMATION_HEADER_SIZE }; /** * Obtain information about the given request. * Use wrapper macro #MHD_request_get_information() instead of direct use * of this function. * * @param request what request to get information about * @param info_type what information is desired? * @param[out] return_value pointer to union where requested information will * be stored * @param return_value_size size of union MHD_RequestInformation at compile * time * @return #MHD_YES on success, #MHD_NO on error * (@a info_type is unknown, NULL pointer etc.) * @ingroup specialized */ _MHD_EXTERN enum MHD_Bool MHD_request_get_information_sz (struct MHD_Request *request, enum MHD_RequestInformationType info_type, union MHD_RequestInformation *return_value, size_t return_value_size) MHD_NONNULL (1,3); /** * Obtain information about the given request. * * @param request what request to get information about * @param info_type what information is desired? * @param[out] return_value pointer to union where requested information will * be stored * @return #MHD_YES on success, #MHD_NO on error * (@a info_type is unknown, NULL pointer etc.) * @ingroup specialized */ #define MHD_request_get_information (request, \ info_type, \ return_value) \ MHD_request_get_information_sz ((request), (info_type), (return_value), \ sizeof(union MHD_RequestInformation)) /** * Values of this enum are used to specify what * information about a daemon is desired. */ enum MHD_DaemonInformationType { /** * Request the file descriptor for the listening socket. * No extra arguments should be passed. */ MHD_DAEMON_INFORMATION_LISTEN_SOCKET, /** * Request the file descriptor for the external epoll. * No extra arguments should be passed. */ MHD_DAEMON_INFORMATION_EPOLL_FD, /** * Request the number of current connections handled by the daemon. * No extra arguments should be passed. * Note: when using MHD in external polling mode, this type of request * could be used only when #MHD_run()/#MHD_run_from_select is not * working in other thread at the same time. */ MHD_DAEMON_INFORMATION_CURRENT_CONNECTIONS, /** * Request the port number of daemon's listen socket. * No extra arguments should be passed. * Note: if port '0' was specified for #MHD_option_port(), returned * value will be real port number. */ MHD_DAEMON_INFORMATION_BIND_PORT }; /** * Information about an MHD daemon. */ union MHD_DaemonInformation { /** * Socket, returned for #MHD_DAEMON_INFORMATION_LISTEN_SOCKET. */ MHD_socket listen_socket; /** * Bind port number, returned for #MHD_DAEMON_INFORMATION_BIND_PORT. */ uint16_t port; /** * epoll FD, returned for #MHD_DAEMON_INFORMATION_EPOLL_FD. */ int epoll_fd; /** * Number of active connections, for #MHD_DAEMON_INFORMATION_CURRENT_CONNECTIONS. */ unsigned int num_connections; }; /** * Obtain information about the given daemon. * Use wrapper macro #MHD_daemon_get_information() instead of direct use * of this function. * * @param daemon what daemon to get information about * @param info_type what information is desired? * @param[out] return_value pointer to union where requested information will * be stored * @param return_value_size size of union MHD_DaemonInformation at compile * time * @return #MHD_YES on success, #MHD_NO on error * (@a info_type is unknown, NULL pointer etc.) * @ingroup specialized */ _MHD_EXTERN enum MHD_Bool MHD_daemon_get_information_sz (struct MHD_Daemon *daemon, enum MHD_DaemonInformationType info_type, union MHD_DaemonInformation *return_value, size_t return_value_size) MHD_NONNULL (1,3); /** * Obtain information about the given daemon. * * @param daemon what daemon to get information about * @param info_type what information is desired? * @param[out] return_value pointer to union where requested information will * be stored * @return #MHD_YES on success, #MHD_NO on error * (@a info_type is unknown, NULL pointer etc.) * @ingroup specialized */ #define MHD_daemon_get_information(daemon, \ info_type, \ return_value) \ MHD_daemon_get_information_sz ((daemon), (info_type), (return_value), \ sizeof(union MHD_DaemonInformation)); /** * Callback for serious error condition. The default action is to print * an error message and `abort()`. * * @param cls user specified value * @param file where the error occurred * @param line where the error occurred * @param reason error detail, may be NULL * @ingroup logging */ typedef void (*MHD_PanicCallback) (void *cls, const char *file, unsigned int line, const char *reason); /** * Sets the global error handler to a different implementation. @a cb * will only be called in the case of typically fatal, serious * internal consistency issues. These issues should only arise in the * case of serious memory corruption or similar problems with the * architecture. While @a cb is allowed to return and MHD will then * try to continue, this is never safe. * * The default implementation that is used if no panic function is set * simply prints an error message and calls `abort()`. Alternative * implementations might call `exit()` or other similar functions. * * @param cb new error handler * @param cls passed to @a cb * @ingroup logging */ _MHD_EXTERN void MHD_set_panic_func (MHD_PanicCallback cb, void *cls); /** * Process escape sequences ('%HH') Updates val in place; the * result should be UTF-8 encoded and cannot be larger than the input. * The result must also still be 0-terminated. * * @param val value to unescape (modified in the process) * @return length of the resulting val (`strlen(val)` may be * shorter afterwards due to elimination of escape sequences) */ _MHD_EXTERN size_t MHD_http_unescape (char *val) MHD_NONNULL (1); /** * Types of information about MHD features, * used by #MHD_is_feature_supported(). */ enum MHD_Feature { /** * Get whether messages are supported. If supported then in debug * mode messages can be printed to stderr or to external logger. */ MHD_FEATURE_MESSAGES = 1, /** * Get whether HTTPS is supported. If supported then flag * #MHD_USE_TLS and options #MHD_OPTION_HTTPS_MEM_KEY, * #MHD_OPTION_HTTPS_MEM_CERT, #MHD_OPTION_HTTPS_MEM_TRUST, * #MHD_OPTION_HTTPS_MEM_DHPARAMS, #MHD_OPTION_HTTPS_CRED_TYPE, * #MHD_OPTION_HTTPS_PRIORITIES can be used. */ MHD_FEATURE_TLS = 2, /** * Get whether option #MHD_OPTION_HTTPS_CERT_CALLBACK is * supported. */ MHD_FEATURE_HTTPS_CERT_CALLBACK = 3, /** * Get whether IPv6 is supported. If supported then flag * #MHD_USE_IPv6 can be used. */ MHD_FEATURE_IPv6 = 4, /** * Get whether IPv6 without IPv4 is supported. If not supported * then IPv4 is always enabled in IPv6 sockets and * flag #MHD_USE_DUAL_STACK if always used when #MHD_USE_IPv6 is * specified. */ MHD_FEATURE_IPv6_ONLY = 5, /** * Get whether `poll()` is supported. If supported then flag * #MHD_USE_POLL can be used. */ MHD_FEATURE_POLL = 6, /** * Get whether `epoll()` is supported. If supported then Flags * #MHD_USE_EPOLL and * #MHD_USE_EPOLL_INTERNAL_THREAD can be used. */ MHD_FEATURE_EPOLL = 7, /** * Get whether shutdown on listen socket to signal other * threads is supported. If not supported flag * #MHD_USE_ITC is automatically forced. */ MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET = 8, /** * Get whether socketpair is used internally instead of pipe to * signal other threads. */ MHD_FEATURE_SOCKETPAIR = 9, /** * Get whether TCP Fast Open is supported. If supported then * flag #MHD_USE_TCP_FASTOPEN and option * #MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE can be used. */ MHD_FEATURE_TCP_FASTOPEN = 10, /** * Get whether HTTP Basic authorization is supported. If supported * then functions #MHD_basic_auth_get_username_password and * #MHD_queue_basic_auth_fail_response can be used. */ MHD_FEATURE_BASIC_AUTH = 11, /** * Get whether HTTP Digest authorization is supported. If * supported then options #MHD_OPTION_DIGEST_AUTH_RANDOM, * #MHD_OPTION_NONCE_NC_SIZE and * #MHD_digest_auth_check() can be used. */ MHD_FEATURE_DIGEST_AUTH = 12, /** * Get whether postprocessor is supported. If supported then * functions #MHD_create_post_processor(), #MHD_post_process() and * #MHD_destroy_post_processor() can * be used. */ MHD_FEATURE_POSTPROCESSOR = 13, /** * Get whether password encrypted private key for HTTPS daemon is * supported. If supported then option * ::MHD_OPTION_HTTPS_KEY_PASSWORD can be used. */ MHD_FEATURE_HTTPS_KEY_PASSWORD = 14, /** * Get whether reading files beyond 2 GiB boundary is supported. * If supported then #MHD_create_response_from_fd(), * #MHD_create_response_from_fd64 #MHD_create_response_from_fd_at_offset() * and #MHD_create_response_from_fd_at_offset64() can be used with sizes and * offsets larger than 2 GiB. If not supported value of size+offset is * limited to 2 GiB. */ MHD_FEATURE_LARGE_FILE = 15, /** * Get whether MHD set names on generated threads. */ MHD_FEATURE_THREAD_NAMES = 16, /** * Get whether HTTP "Upgrade" is supported. * If supported then #MHD_ALLOW_UPGRADE, #MHD_upgrade_action() and * #MHD_create_response_for_upgrade() can be used. */ MHD_FEATURE_UPGRADE = 17, /** * Get whether it's safe to use same FD for multiple calls of * #MHD_create_response_from_fd() and whether it's safe to use single * response generated by #MHD_create_response_from_fd() with multiple * connections at same time. * If #MHD_is_feature_supported() return #MHD_NO for this feature then * usage of responses with same file FD in multiple parallel threads may * results in incorrect data sent to remote client. * It's always safe to use same file FD in multiple responses if MHD * is run in any single thread mode. */ MHD_FEATURE_RESPONSES_SHARED_FD = 18, /** * Get whether MHD support automatic detection of bind port number. * @sa #MHD_DAEMON_INFO_BIND_PORT */ MHD_FEATURE_AUTODETECT_BIND_PORT = 19, /** * Get whether MHD support SIGPIPE suppression. * If SIGPIPE suppression is not supported, application must handle * SIGPIPE signal by itself. */ MHD_FEATURE_AUTOSUPPRESS_SIGPIPE = 20, /** * Get whether MHD use system's sendfile() function to send * file-FD based responses over non-TLS connections. * @note Since v0.9.56 */ MHD_FEATURE_SENDFILE = 21 }; /** * Get information about supported MHD features. * Indicate that MHD was compiled with or without support for * particular feature. Some features require additional support * by kernel. Kernel support is not checked by this function. * * @param feature type of requested information * @return #MHD_YES if feature is supported by MHD, #MHD_NO if * feature is not supported or feature is unknown. * @ingroup specialized */ _MHD_EXTERN enum MHD_Bool MHD_is_feature_supported (enum MHD_Feature feature); /** * What is this request waiting for? */ enum MHD_RequestEventLoopInfo { /** * We are waiting to be able to read. */ MHD_EVENT_LOOP_INFO_READ = 0, /** * We are waiting to be able to write. */ MHD_EVENT_LOOP_INFO_WRITE = 1, /** * We are waiting for the application to provide data. */ MHD_EVENT_LOOP_INFO_BLOCK = 2, /** * We are finished and are awaiting cleanup. */ MHD_EVENT_LOOP_INFO_CLEANUP = 3 }; #endif libmicrohttpd-1.0.1/src/include/microhttpd_tls.h0000644000175000017500000001152414417460232015466 /* This file is part of libmicrohttpd Copyright (C) 2018 Christian Grothoff (and other contributing authors) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd_tls.h * @brief interface for TLS plugins of libmicrohttpd * @author Christian Grothoff */ #ifndef MICROHTTPD_TLS_H #define MICROHTTPD_TLS_H #include /** * Version of the TLS ABI. */ #define MHD_TLS_ABI_VERSION 0 /** * Version of the TLS ABI as a string. * Must match #MHD_TLS_ABI_VERSION! */ #define MHD_TLS_ABI_VERSION_STR "0" /** * Data structure kept per TLS client by the plugin. */ struct MHD_TLS_ConnectionState; /** * Callback functions to use for TLS operations. */ struct MHD_TLS_Plugin { /** * Closure with plugin's internal state, opaque to MHD. */ void *cls; /** * Destroy the plugin, we are done with it. */ void (*done)(struct MHD_TLS_Plugin *plugin); /** * Initialize key and certificate data from memory. * * @param cls the @e cls of this struct * @param mem_key private key (key.pem) to be used by the * HTTPS daemon. Must be the actual data in-memory, not a filename. * @param mem_cert certificate (cert.pem) to be used by the * HTTPS daemon. Must be the actual data in-memory, not a filename. * @param pass passphrase phrase to decrypt 'key.pem', NULL * if @param mem_key is in cleartext already * @return #MHD_SC_OK upon success; TODO: define failure modes */ enum MHD_StatusCode (*init_kcp)(void *cls, const char *mem_key, const char *mem_cert, const char *pass); /** * Initialize DH parameters. * * @param cls the @e cls of this struct * @param dh parameters to use * @return #MHD_SC_OK upon success; TODO: define failure modes */ enum MHD_StatusCode (*init_dhparams)(void *cls, const char *dh); /** * Initialize certificate to use for client authentication. * * @param cls the @e cls of this struct * @param mem_trust client certificate * @return #MHD_SC_OK upon success; TODO: define failure modes */ enum MHD_StatusCode (*init_mem_trust)(void *cls, const char *mem_trust); /** * Function called when we receive a connection and need * to initialize our TLS state for it. * * @param cls the @e cls of this struct * @param ... TBD * @return NULL on error */ struct MHD_TLS_ConnectionState * (*setup_connection)(void *cls, ...); enum MHD_Bool (*handshake)(void *cls, struct MHD_TLS_ConnectionState *cs); enum MHD_Bool (*idle_ready)(void *cls, struct MHD_TLS_ConnectionState *cs); enum MHD_Bool (*update_event_loop_info)(void *cls, struct MHD_TLS_ConnectionState *cs, enum MHD_RequestEventLoopInfo *eli); ssize_t (*send)(void *cls, struct MHD_TLS_ConnectionState *cs, const void *buf, size_t buf_size); ssize_t (*recv)(void *cls, struct MHD_TLS_ConnectionState *cs, void *buf, size_t buf_size); const char * (*strerror)(void *cls, int ec); enum MHD_Bool (*check_record_pending)(void *cls, struct MHD_TLS_ConnectionState *cs); enum MHD_Bool (*shutdown_connection)(void *cls, struct MHD_TLS_ConnectionState *cs); void (*teardown_connection)(void *cls, struct MHD_TLS_ConnectionState *cs); /** * TODO: More functions here.... */ }; /** * Signature of the initialization function each TLS plugin must * export. * * @param ciphers desired cipher suite * @return NULL on errors (in particular, invalid cipher suite) */ typedef struct MHD_TLS_Plugin * (*MHD_TLS_PluginInit) (const char *ciphers); /** * Define function to be exported from the TLS plugin. * * @a body function body that receives `ciphers` argument * and must return the plugin API, or NULL on error. */ #define MHD_TLS_INIT(body) \ struct MHD_TLS_Plugin * \ MHD_TLS_init_ ## MHD_TLS_ABI_VERSION (const char *ciphers) \ \ { body } #endif libmicrohttpd-1.0.1/src/include/mhd_options.h0000644000175000017500000002424714555767064015000 /* This file is part of libmicrohttpd Copyright (C) 2016-2021 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file include/mhd_options.h * @brief additional automatic macros for MHD_config.h * @author Karlson2k (Evgeny Grin) * * This file includes MHD_config.h and adds automatic macros based on values * in MHD_config.h, compiler built-in macros and commandline-defined macros * (but not based on values defined in other headers). Works also as a guard * to prevent double inclusion of MHD_config.h */ #ifndef MHD_OPTIONS_H #define MHD_OPTIONS_H 1 #include "MHD_config.h" /** * Macro to make it easy to mark text for translation. Note that * we do not actually call gettext() in MHD, but we do make it * easy to create a ".po" file so that applications that do want * to translate error messages can do so. */ #define _(String) (String) #if defined(_MHD_EXTERN) && ! defined(BUILDING_MHD_LIB) #undef _MHD_EXTERN #endif /* _MHD_EXTERN && ! BUILDING_MHD_LIB */ #ifndef _MHD_EXTERN #if defined(BUILDING_MHD_LIB) && defined(_WIN32) && \ (defined(DLL_EXPORT) || defined(MHD_W32DLL)) #define _MHD_EXTERN __declspec(dllexport) extern #else /* !BUILDING_MHD_LIB || !_WIN32 || (!DLL_EXPORT && !MHD_W32DLL) */ #define _MHD_EXTERN extern #endif /* !BUILDING_MHD_LIB || !_WIN32 || (!DLL_EXPORT && !MHD_W32DLL) */ #endif /* ! _MHD_EXTERN */ /* Some platforms (FreeBSD, Solaris, W32) allow to override default FD_SETSIZE by defining it before including headers. */ #ifdef FD_SETSIZE /* FD_SETSIZE defined in command line or in MHD_config.h */ #elif defined(_WIN32) || defined(__CYGWIN__) /* Platform with WinSock and without overridden FD_SETSIZE */ #define FD_SETSIZE 2048 /* Override default small value (64) */ #else /* !FD_SETSIZE && !W32 */ /* System default value of FD_SETSIZE is used */ #define _MHD_FD_SETSIZE_IS_DEFAULT 1 #endif /* !FD_SETSIZE && !W32 */ #if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_FREEBSD_SENDFILE) || \ defined(HAVE_DARWIN_SENDFILE) || defined(HAVE_SOLARIS_SENDFILE) /* Have any supported sendfile() function. */ #define _MHD_HAVE_SENDFILE #endif /* HAVE_LINUX_SENDFILE || HAVE_FREEBSD_SENDFILE || HAVE_DARWIN_SENDFILE || HAVE_SOLARIS_SENDFILE */ #if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_SOLARIS_SENDFILE) #define MHD_LINUX_SOLARIS_SENDFILE 1 #endif /* HAVE_LINUX_SENDFILE || HAVE_SOLARIS_SENDFILE */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) # ifndef MHD_USE_THREADS # define MHD_USE_THREADS 1 # endif #endif /* MHD_USE_POSIX_THREADS || MHD_USE_W32_THREADS */ #if defined(OS390) #define _OPEN_THREADS #define _OPEN_SYS_SOCK_IPV6 #define _OPEN_MSGQ_EXT #define _LP64 #endif #if defined(_WIN32) && ! defined(__CYGWIN__) /* Declare POSIX-compatible names */ #define _CRT_DECLARE_NONSTDC_NAMES 1 /* Do not warn about POSIX name usage */ #define _CRT_NONSTDC_NO_WARNINGS 1 #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0600 #else /* _WIN32_WINNT */ #if _WIN32_WINNT < 0x0501 #error "Headers for Windows XP or later are required" #endif /* _WIN32_WINNT < 0x0501 */ #endif /* _WIN32_WINNT */ #ifndef WIN32_LEAN_AND_MEAN /* Do not include unneeded parts of W32 headers. */ #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #endif /* _WIN32 && ! __CYGWIN__ */ #if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS) #define RESTRICT __restrict__ #endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */ #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 #endif #ifdef HAVE_C11_GMTIME_S /* Special macro is required to enable C11 definition of gmtime_s() function */ #define __STDC_WANT_LIB_EXT1__ 1 #endif /* HAVE_C11_GMTIME_S */ #if defined(MHD_FAVOR_FAST_CODE) && defined(MHD_FAVOR_SMALL_CODE) #error \ MHD_FAVOR_FAST_CODE and MHD_FAVOR_SMALL_CODE are both defined. Cannot favor speed and size at the same time. #endif /* MHD_FAVOR_FAST_CODE && MHD_FAVOR_SMALL_CODE */ /* Define MHD_FAVOR_FAST_CODE to force fast code path or define MHD_FAVOR_SMALL_CODE to choose compact code path */ #if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE) /* Try to detect user preferences */ /* Defined by GCC and many compatible compilers */ #if defined(__OPTIMIZE_SIZE__) #define MHD_FAVOR_SMALL_CODE 1 #elif defined(__OPTIMIZE__) #define MHD_FAVOR_FAST_CODE 1 #endif /* __OPTIMIZE__ */ #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */ #if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE) /* Use faster code by default */ #define MHD_FAVOR_FAST_CODE 1 #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */ #ifndef MHD_ASAN_ACTIVE #if (defined(__GNUC__) || defined(_MSC_VER)) && defined(__SANITIZE_ADDRESS__) #define MHD_ASAN_ACTIVE 1 #elif defined(__has_feature) #if __has_feature (address_sanitizer) #define MHD_ASAN_ACTIVE 1 #endif /* __has_feature(address_sanitizer) */ #endif /* __has_feature */ #endif /* MHD_ASAN_ACTIVE */ #if defined(MHD_ASAN_ACTIVE) && defined(HAVE_SANITIZER_ASAN_INTERFACE_H) && \ (defined(FUNC_PTRCOMPARE_CAST_WORKAROUND_WORKS) || \ (defined(FUNC_ATTR_PTRCOMPARE_WORKS) && \ defined(FUNC_ATTR_PTRSUBTRACT_WORKS)) || \ defined(FUNC_ATTR_NOSANITIZE_WORKS)) #ifndef MHD_ASAN_POISON_ACTIVE /* User ASAN poisoning could be used */ #warning User memory poisoning is not active #endif /* ! MHD_ASAN_POISON_ACTIVE */ #else /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H && (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS)) */ #ifdef MHD_ASAN_POISON_ACTIVE #error User memory poisoning is active, but conditions are not suitable #endif /* MHD_ASAN_POISON_ACTIVE */ #endif /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H && (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS)) */ #ifndef _MSC_FULL_VER # define MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ /* empty */ # define MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ /* empty */ #else /* _MSC_FULL_VER */ # define MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ \ __pragma(runtime_checks("c", off)) # define MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ \ __pragma(runtime_checks("c", restore)) #endif /* _MSC_FULL_VER */ /** * Automatic string with the name of the current function */ #if defined(HAVE___FUNC__) #define MHD_FUNC_ __func__ #define MHD_HAVE_MHD_FUNC_ 1 #elif defined(HAVE___FUNCTION__) #define MHD_FUNC_ __FUNCTION__ #define MHD_HAVE_MHD_FUNC_ 1 #elif defined(HAVE___PRETTY_FUNCTION__) #define MHD_FUNC_ __PRETTY_FUNCTION__ #define MHD_HAVE_MHD_FUNC_ 1 #else #define MHD_FUNC_ "**name unavailable**" #ifdef MHD_HAVE_MHD_FUNC_ #undef MHD_HAVE_MHD_FUNC_ #endif /* MHD_HAVE_MHD_FUNC_ */ #endif /* Un-define some HAVE_DECL_* macro if they equal zero. This should allow safely use #ifdef in the code. Define HAS_DECL_* macros only if matching HAVE_DECL_* macro has non-zero value. Unlike HAVE_DECL_*, macros HAS_DECL_* cannot have zero value. */ #ifdef HAVE_DECL__SC_NPROCESSORS_ONLN # if 0 == HAVE_DECL__SC_NPROCESSORS_ONLN # undef HAVE_DECL__SC_NPROCESSORS_ONLN # else /* 0 != HAVE_DECL__SC_NPROCESSORS_ONLN */ # define HAS_DECL__SC_NPROCESSORS_ONLN 1 # endif /* 0 != HAVE_DECL__SC_NPROCESSORS_ONLN */ #endif /* HAVE_DECL__SC_NPROCESSORS_ONLN */ #ifdef HAVE_DECL__SC_NPROCESSORS_CONF # if 0 == HAVE_DECL__SC_NPROCESSORS_CONF # undef HAVE_DECL__SC_NPROCESSORS_CONF # else /* 0 != HAVE_DECL__SC_NPROCESSORS_CONF */ # define HAS_DECL__SC_NPROCESSORS_CONF 1 # endif /* 0 != HAVE_DECL__SC_NPROCESSORS_CONF */ #endif /* HAVE_DECL__SC_NPROCESSORS_CONF */ #ifdef HAVE_DECL__SC_NPROC_ONLN # if 0 == HAVE_DECL__SC_NPROC_ONLN # undef HAVE_DECL__SC_NPROC_ONLN # else /* 0 != HAVE_DECL__SC_NPROC_ONLN */ # define HAS_DECL__SC_NPROC_ONLN 1 # endif /* 0 != HAVE_DECL__SC_NPROC_ONLN */ #endif /* HAVE_DECL__SC_NPROC_ONLN */ #ifdef HAVE_DECL__SC_CRAY_NCPU # if 0 == HAVE_DECL__SC_CRAY_NCPU # undef HAVE_DECL__SC_CRAY_NCPU # else /* 0 != HAVE_DECL__SC_CRAY_NCPU */ # define HAS_DECL__SC_CRAY_NCPU 1 # endif /* 0 != HAVE_DECL__SC_CRAY_NCPU */ #endif /* HAVE_DECL__SC_CRAY_NCPU */ #ifdef HAVE_DECL_CTL_HW # if 0 == HAVE_DECL_CTL_HW # undef HAVE_DECL_CTL_HW # else /* 0 != HAVE_DECL_CTL_HW */ # define HAS_DECL_CTL_HW 1 # endif /* 0 != HAVE_DECL_CTL_HW */ #endif /* HAVE_DECL_CTL_HW */ #ifdef HAVE_DECL_HW_NCPUONLINE # if 0 == HAVE_DECL_HW_NCPUONLINE # undef HAVE_DECL_HW_NCPUONLINE # else /* 0 != HAVE_DECL_HW_NCPUONLINE */ # define HAS_DECL_HW_NCPUONLINE 1 # endif /* 0 != HAVE_DECL_HW_NCPUONLINE */ #endif /* HAVE_DECL_HW_NCPUONLINE */ #ifdef HAVE_DECL_HW_AVAILCPU # if 0 == HAVE_DECL_HW_AVAILCPU # undef HAVE_DECL_HW_AVAILCPU # else /* 0 != HAVE_DECL_HW_AVAILCPU */ # define HAS_DECL_HW_AVAILCPU 1 # endif /* 0 != HAVE_DECL_HW_AVAILCPU */ #endif /* HAVE_DECL_HW_AVAILCPU */ #ifdef HAVE_DECL_HW_NCPU # if 0 == HAVE_DECL_HW_NCPU # undef HAVE_DECL_HW_NCPU # else /* 0 != HAVE_DECL_HW_NCPU */ # define HAS_DECL_HW_NCPU 1 # endif /* 0 != HAVE_DECL_HW_NCPU */ #endif /* HAVE_DECL_HW_NCPU */ #ifdef HAVE_DECL_CPU_SETSIZE # if 0 == HAVE_DECL_CPU_SETSIZE # undef HAVE_DECL_CPU_SETSIZE # else /* 0 != HAVE_DECL_CPU_SETSIZE */ # define HAS_DECL_CPU_SETSIZE 1 # endif /* 0 != HAVE_DECL_CPU_SETSIZE */ #endif /* HAVE_DECL_CPU_SETSIZE */ #ifndef MHD_DAUTH_DEF_TIMEOUT_ # define MHD_DAUTH_DEF_TIMEOUT_ 90 #endif /* ! MHD_DAUTH_DEF_TIMEOUT_ */ #ifndef MHD_DAUTH_DEF_MAX_NC_ # define MHD_DAUTH_DEF_MAX_NC_ 1000 #endif /* ! MHD_DAUTH_DEF_MAX_NC_ */ #endif /* MHD_OPTIONS_H */ libmicrohttpd-1.0.1/src/Makefile.am0000644000175000017500000000071014452761203012663 # This Makefile.am is in the public domain SUBDIRS = include microhttpd . if RUN_LIBCURL_TESTS SUBDIRS += testcurl if RUN_ZZUF_TESTS SUBDIRS += testzzuf endif endif # Finally (last!) also build experimental lib... if HAVE_EXPERIMENTAL SUBDIRS += microhttpd_ws lib endif if BUILD_EXAMPLES SUBDIRS += examples endif if BUILD_TOOLS SUBDIRS += tools endif EXTRA_DIST = \ datadir/cert-and-key.pem \ datadir/cert-and-key-for-wireshark.pem .NOTPARALLEL: libmicrohttpd-1.0.1/src/lib/0000755000175000017500000000000014566140217011461 5libmicrohttpd-1.0.1/src/lib/response_options.c0000644000175000017500000000377314417460232015165 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/response_option.c * @brief implementation of response options * @author Christian Grothoff */ #include "internal.h" /** * Only respond in conservative HTTP 1.0-mode. In * particular, do not (automatically) sent "Connection" headers and * always close the connection after generating the response. * * @param request the request for which we force HTTP 1.0 to be used */ void MHD_response_option_v10_only (struct MHD_Response *response) { response->v10_only = true; } /** * Set a function to be called once MHD is finished with the * request. * * @param response which response to set the callback for * @param termination_cb function to call * @param termination_cb_cls closure for @e termination_cb */ void MHD_response_option_termination_callback (struct MHD_Response *response, MHD_RequestTerminationCallback termination_cb, void *termination_cb_cls) { /* Q: should we assert termination_cb non-NULL? */ response->termination_cb = termination_cb; response->termination_cb_cls = termination_cb_cls; } /* end of response_option.c */ libmicrohttpd-1.0.1/src/lib/internal.h0000644000175000017500000013440514417460232013372 /* This file is part of libmicrohttpd Copyright (C) 2007-2017 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/internal.h * @brief internal shared structures * @author Daniel Pittman * @author Christian Grothoff */ #ifndef INTERNAL_H #define INTERNAL_H #include "mhd_options.h" #include "platform.h" #include "microhttpd2.h" #include "microhttpd_tls.h" #include "mhd_assert.h" #include "mhd_compat.h" #include "mhd_itc.h" #include "mhd_mono_clock.h" #include "memorypool.h" #ifdef HTTPS_SUPPORT #include #if GNUTLS_VERSION_MAJOR >= 3 #include #endif #endif /* HTTPS_SUPPORT */ #ifdef HAVE_STDBOOL_H #include #endif #ifdef MHD_PANIC /* Override any defined MHD_PANIC macro with proper one */ #undef MHD_PANIC #endif /* MHD_PANIC */ #ifdef HAVE_MESSAGES /** * Trigger 'panic' action based on fatal errors. * * @param msg error message (const char *) */ #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg); \ BUILTIN_NOT_REACHED; } while (0) #else /** * Trigger 'panic' action based on fatal errors. * * @param msg error message (const char *) */ #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); \ BUILTIN_NOT_REACHED; } while (0) #endif #include "mhd_threads.h" #include "mhd_locks.h" #include "mhd_sockets.h" #include "mhd_str.h" #include "mhd_itc_types.h" #ifdef HAVE_MESSAGES /** * fprintf()-like helper function for logging debug * messages. */ void MHD_DLOG (const struct MHD_Daemon *daemon, enum MHD_StatusCode sc, const char *format, ...); #endif /** * Close FD and abort execution if error is detected. * @param fd the FD to close */ #define MHD_fd_close_chk_(fd) do { \ if ( (0 != close ((fd)) && (EBADF == errno)) ) \ MHD_PANIC (_ ("Failed to close FD.\n")); \ } while (0) /** * Should we perform additional sanity checks at runtime (on our internal * invariants)? This may lead to aborts, but can be useful for debugging. */ #define EXTRA_CHECKS MHD_NO #define MHD_MAX(a,b) (((a)<(b)) ? (b) : (a)) #define MHD_MIN(a,b) (((a)<(b)) ? (a) : (b)) /** * Minimum size by which MHD tries to increment read/write buffers. * We usually begin with half the available pool space for the * IO-buffer, but if absolutely needed we additively grow by the * number of bytes given here (up to -- theoretically -- the full pool * space). */ #define MHD_BUF_INC_SIZE 1024 /** * Handler for fatal errors. */ extern MHD_PanicCallback mhd_panic; /** * Closure argument for "mhd_panic". */ extern void *mhd_panic_cls; /* If we have Clang or gcc >= 4.5, use __buildin_unreachable() */ #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= \ 5) #define BUILTIN_NOT_REACHED __builtin_unreachable () #elif defined(_MSC_FULL_VER) #define BUILTIN_NOT_REACHED __assume (0) #else #define BUILTIN_NOT_REACHED #endif #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ /** * Ability to use same connection for next request */ enum MHD_ConnKeepAlive { /** * Connection must be closed after sending response. */ MHD_CONN_MUST_CLOSE = -1, /** * KeelAlive state is not yet determined */ MHD_CONN_KEEPALIVE_UNKOWN = 0, /** * Connection can be used for serving next request */ MHD_CONN_USE_KEEPALIVE = 1 }; /** * Function to receive plaintext data. * * @param conn the connection struct * @param write_to where to write received data * @param max_bytes maximum number of bytes to receive * @return number of bytes written to @a write_to */ typedef ssize_t (*ReceiveCallback) (struct MHD_Connection *conn, void *write_to, size_t max_bytes); /** * Function to transmit plaintext data. * * @param conn the connection struct * @param read_from where to read data to transmit * @param max_bytes maximum number of bytes to transmit * @return number of bytes transmitted */ typedef ssize_t (*TransmitCallback) (struct MHD_Connection *conn, const void *read_from, size_t max_bytes); /** * States in a state machine for a request. * * The main transitions are any-state to #MHD_REQUEST_CLOSED, any * state to state+1, #MHD_REQUEST_FOOTERS_SENT to * #MHD_REQUEST_INIT. #MHD_REQUEST_CLOSED is the terminal state * and #MHD_REQUEST_INIT the initial state. * * Note that transitions for *reading* happen only after the input has * been processed; transitions for *writing* happen after the * respective data has been put into the write buffer (the write does * not have to be completed yet). A transition to * #MHD_REQUEST_CLOSED or #MHD_REQUEST_INIT requires the write * to be complete. */ enum MHD_REQUEST_STATE // FIXME: fix capitalization! { /** * Request just started (no headers received). * Waiting for the line with the request type, URL and version. */ MHD_REQUEST_INIT = 0, /** * 1: We got the URL (and request type and version). Wait for a header line. */ MHD_REQUEST_URL_RECEIVED = MHD_REQUEST_INIT + 1, /** * 2: We got part of a multi-line request header. Wait for the rest. */ MHD_REQUEST_HEADER_PART_RECEIVED = MHD_REQUEST_URL_RECEIVED + 1, /** * 3: We got the request headers. Process them. */ MHD_REQUEST_HEADERS_RECEIVED = MHD_REQUEST_HEADER_PART_RECEIVED + 1, /** * 4: We have processed the request headers. Send 100 continue. */ MHD_REQUEST_HEADERS_PROCESSED = MHD_REQUEST_HEADERS_RECEIVED + 1, /** * 5: We have processed the headers and need to send 100 CONTINUE. */ MHD_REQUEST_CONTINUE_SENDING = MHD_REQUEST_HEADERS_PROCESSED + 1, /** * 6: We have sent 100 CONTINUE (or do not need to). Read the message body. */ MHD_REQUEST_CONTINUE_SENT = MHD_REQUEST_CONTINUE_SENDING + 1, /** * 7: We got the request body. Wait for a line of the footer. */ MHD_REQUEST_BODY_RECEIVED = MHD_REQUEST_CONTINUE_SENT + 1, /** * 8: We got part of a line of the footer. Wait for the * rest. */ MHD_REQUEST_FOOTER_PART_RECEIVED = MHD_REQUEST_BODY_RECEIVED + 1, /** * 9: We received the entire footer. Wait for a response to be queued * and prepare the response headers. */ MHD_REQUEST_FOOTERS_RECEIVED = MHD_REQUEST_FOOTER_PART_RECEIVED + 1, /** * 10: We have prepared the response headers in the writ buffer. * Send the response headers. */ MHD_REQUEST_HEADERS_SENDING = MHD_REQUEST_FOOTERS_RECEIVED + 1, /** * 11: We have sent the response headers. Get ready to send the body. */ MHD_REQUEST_HEADERS_SENT = MHD_REQUEST_HEADERS_SENDING + 1, /** * 12: We are ready to send a part of a non-chunked body. Send it. */ MHD_REQUEST_NORMAL_BODY_READY = MHD_REQUEST_HEADERS_SENT + 1, /** * 13: We are waiting for the client to provide more * data of a non-chunked body. */ MHD_REQUEST_NORMAL_BODY_UNREADY = MHD_REQUEST_NORMAL_BODY_READY + 1, /** * 14: We are ready to send a chunk. */ MHD_REQUEST_CHUNKED_BODY_READY = MHD_REQUEST_NORMAL_BODY_UNREADY + 1, /** * 15: We are waiting for the client to provide a chunk of the body. */ MHD_REQUEST_CHUNKED_BODY_UNREADY = MHD_REQUEST_CHUNKED_BODY_READY + 1, /** * 16: We have sent the response body. Prepare the footers. */ MHD_REQUEST_BODY_SENT = MHD_REQUEST_CHUNKED_BODY_UNREADY + 1, /** * 17: We have prepared the response footer. Send it. */ MHD_REQUEST_FOOTERS_SENDING = MHD_REQUEST_BODY_SENT + 1, /** * 18: We have sent the response footer. Shutdown or restart. */ MHD_REQUEST_FOOTERS_SENT = MHD_REQUEST_FOOTERS_SENDING + 1, /** * 19: This request is to be closed. */ MHD_REQUEST_CLOSED = MHD_REQUEST_FOOTERS_SENT + 1, #ifdef UPGRADE_SUPPORT /** * Request was "upgraded" and socket is now under the * control of the application. */ MHD_REQUEST_UPGRADE #endif /* UPGRADE_SUPPORT */ }; /** * Header or cookie in HTTP request or response. */ struct MHD_HTTP_Header { /** * Headers are kept in a linked list. */ struct MHD_HTTP_Header *next; /** * The name of the header (key), without the colon. */ char *header; /** * The value of the header. */ char *value; /** * Type of the header (where in the HTTP protocol is this header * from). */ enum MHD_ValueKind kind; }; /** * State kept for each HTTP request. */ struct MHD_Request { /** * Reference to the `struct MHD_Daemon`. */ struct MHD_Daemon *daemon; /** * Connection this request is associated with. */ struct MHD_Connection *connection; /** * Response to return for this request, set once * it is available. */ struct MHD_Response *response; /** * Linked list of parsed headers. */ struct MHD_HTTP_Header *headers_received; /** * Tail of linked list of parsed headers. */ struct MHD_HTTP_Header *headers_received_tail; /** * We allow the main application to associate some pointer with the * HTTP request, which is passed to each #MHD_AccessHandlerCallback * and some other API calls. Here is where we store it. (MHD does * not know or care what it is). */ void *client_context; /** * Request method as string. Should be GET/POST/etc. Allocated in * pool. */ char *method_s; /** * Requested URL (everything after "GET" only). Allocated * in pool. */ const char *url; /** * HTTP version string (i.e. http/1.1). Allocated * in pool. */ char *version_s; /** * Close connection after sending response? * Functions may change value from "Unknown" or "KeepAlive" to "Must close", * but no functions reset value "Must Close" to any other value. */ enum MHD_ConnKeepAlive keepalive; /** * Buffer for reading requests. Allocated in pool. Actually one * byte larger than @e read_buffer_size (if non-NULL) to allow for * 0-termination. */ char *read_buffer; /** * Buffer for writing response (headers only). Allocated * in pool. */ char *write_buffer; /** * Last incomplete header line during parsing of headers. * Allocated in pool. Only valid if state is * either #MHD_REQUEST_HEADER_PART_RECEIVED or * #MHD_REQUEST_FOOTER_PART_RECEIVED. */ char *last; /** * Position after the colon on the last incomplete header * line during parsing of headers. * Allocated in pool. Only valid if state is * either #MHD_REQUEST_HEADER_PART_RECEIVED or * #MHD_REQUEST_FOOTER_PART_RECEIVED. */ char *colon; #ifdef UPGRADE_SUPPORT /** * If this connection was upgraded, this points to * the upgrade response details such that the * #thread_main_connection_upgrade()-logic can perform the * bi-directional forwarding. */ struct MHD_UpgradeResponseHandle *urh; #endif /* UPGRADE_SUPPORT */ /** * Size of @e read_buffer (in bytes). This value indicates * how many bytes we're willing to read into the buffer; * the real buffer is one byte longer to allow for * adding zero-termination (when needed). */ size_t read_buffer_size; /** * Position where we currently append data in * @e read_buffer (last valid position). */ size_t read_buffer_offset; /** * Size of @e write_buffer (in bytes). */ size_t write_buffer_size; /** * Offset where we are with sending from @e write_buffer. */ size_t write_buffer_send_offset; /** * Last valid location in write_buffer (where do we * append and up to where is it safe to send?) */ size_t write_buffer_append_offset; /** * Number of bytes we had in the HTTP header, set once we * pass #MHD_REQUEST_HEADERS_RECEIVED. */ size_t header_size; /** * How many more bytes of the body do we expect * to read? #MHD_SIZE_UNKNOWN for unknown. */ uint64_t remaining_upload_size; /** * If we are receiving with chunked encoding, where are we right * now? Set to 0 if we are waiting to receive the chunk size; * otherwise, this is the size of the current chunk. A value of * zero is also used when we're at the end of the chunks. */ uint64_t current_chunk_size; /** * If we are receiving with chunked encoding, where are we currently * with respect to the current chunk (at what offset / position)? */ uint64_t current_chunk_offset; /** * Current write position in the actual response * (excluding headers, content only; should be 0 * while sending headers). */ uint64_t response_write_position; #if defined(_MHD_HAVE_SENDFILE) // FIXME: document, fix capitalization! enum MHD_resp_sender_ { MHD_resp_sender_std = 0, MHD_resp_sender_sendfile } resp_sender; #endif /* _MHD_HAVE_SENDFILE */ /** * Position in the 100 CONTINUE message that * we need to send when receiving http 1.1 requests. */ size_t continue_message_write_offset; /** * State in the FSM for this request. */ enum MHD_REQUEST_STATE state; /** * HTTP method, as an enum. */ enum MHD_Method method; /** * What is this request waiting for? */ enum MHD_RequestEventLoopInfo event_loop_info; /** * Are we currently inside the "idle" handler (to avoid recursively * invoking it). */ bool in_idle; /** * Are we currently inside the "idle" handler (to avoid recursively * invoking it). */ bool in_cleanup; /** * Are we receiving with chunked encoding? This will be set to * #MHD_YES after we parse the headers and are processing the body * with chunks. After we are done with the body and we are * processing the footers; once the footers are also done, this will * be set to #MHD_NO again (before the final call to the handler). */ bool have_chunked_upload; }; /** * State of the socket with respect to epoll (bitmask). */ enum MHD_EpollState { /** * The socket is not involved with a defined state in epoll() right * now. */ MHD_EPOLL_STATE_UNREADY = 0, /** * epoll() told us that data was ready for reading, and we did * not consume all of it yet. */ MHD_EPOLL_STATE_READ_READY = 1, /** * epoll() told us that space was available for writing, and we did * not consume all of it yet. */ MHD_EPOLL_STATE_WRITE_READY = 2, /** * Is this connection currently in the 'eready' EDLL? */ MHD_EPOLL_STATE_IN_EREADY_EDLL = 4, /** * Is this connection currently in the epoll() set? */ MHD_EPOLL_STATE_IN_EPOLL_SET = 8, /** * Is this connection currently suspended? */ MHD_EPOLL_STATE_SUSPENDED = 16, /** * Is this connection in some error state? */ MHD_EPOLL_STATE_ERROR = 128 }; /** * State kept per HTTP connection. */ struct MHD_Connection { #ifdef EPOLL_SUPPORT /** * Next pointer for the EDLL listing connections that are epoll-ready. */ struct MHD_Connection *nextE; /** * Previous pointer for the EDLL listing connections that are epoll-ready. */ struct MHD_Connection *prevE; #endif /** * Next pointer for the DLL describing our IO state. */ struct MHD_Connection *next; /** * Previous pointer for the DLL describing our IO state. */ struct MHD_Connection *prev; /** * Next pointer for the XDLL organizing connections by timeout. * This DLL can be either the * 'manual_timeout_head/manual_timeout_tail' or the * 'normal_timeout_head/normal_timeout_tail', depending on whether a * custom timeout is set for the connection. */ struct MHD_Connection *nextX; /** * Previous pointer for the XDLL organizing connections by timeout. */ struct MHD_Connection *prevX; /** * Reference to the MHD_Daemon struct. */ struct MHD_Daemon *daemon; /** * The memory pool is created whenever we first read from the TCP * stream and destroyed at the end of each request (and re-created * for the next request). In the meantime, this pointer is NULL. * The pool is used for all request-related data except for the * response (which maybe shared between requests) and the IP * address (which persists across individual requests). */ struct MemoryPool *pool; /** * We allow the main application to associate some pointer with the * TCP connection (which may span multiple HTTP requests). Here is * where we store it. (MHD does not know or care what it is). * The location is given to the #MHD_NotifyConnectionCallback and * also accessible via #MHD_CONNECTION_INFO_SOCKET_CONTEXT. */ void *socket_context; #ifdef HTTPS_SUPPORT /** * State kept per TLS connection. Plugin-specific. */ struct MHD_TLS_ConnectionState *tls_cs; #endif /** * Function used for reading HTTP request stream. */ ReceiveCallback recv_cls; /** * Function used for writing HTTP response stream. */ TransmitCallback send_cls; /** * Information about the current request we are processing * on this connection. */ struct MHD_Request request; /** * Thread handle for this connection (if we are using * one thread per connection). */ MHD_thread_handle_ID_ pid; /** * Foreign address (of length @e addr_len). */ struct sockaddr_storage addr; /** * Length of the foreign address. */ socklen_t addr_len; /** * Last time this connection had any activity * (reading or writing). */ time_t last_activity; /** * After how many seconds of inactivity should * this connection time out? Zero for no timeout. */ time_t connection_timeout; /** * Socket for this connection. Set to #MHD_INVALID_SOCKET if * this connection has died (daemon should clean * up in that case). */ MHD_socket socket_fd; #ifdef EPOLL_SUPPORT /** * What is the state of this socket in relation to epoll? */ enum MHD_EpollState epoll_state; #endif /** * Is the connection suspended? */ bool suspended; /** * Are we ready to read from TLS for this connection? */ bool tls_read_ready; /** * Is the connection wanting to resume? */ bool resuming; /** * Set to `true` if the thread has been joined. */ bool thread_joined; /** * true if #socket_fd is non-blocking, false otherwise. */ bool sk_nonblck; /** * Has this socket been closed for reading (i.e. other side closed * the connection)? If so, we must completely close the connection * once we are done sending our response (and stop trying to read * from this socket). */ bool read_closed; }; #ifdef UPGRADE_SUPPORT /** * Buffer we use for upgrade response handling in the unlikely * case where the memory pool was so small it had no buffer * capacity left. Note that we don't expect to _ever_ use this * buffer, so it's mostly wasted memory (except that it allows * us to handle a tricky error condition nicely). So no need to * make this one big. Applications that want to perform well * should just pick an adequate size for the memory pools. */ #define RESERVE_EBUF_SIZE 8 /** * Context we pass to epoll() for each of the two sockets * of a `struct MHD_UpgradeResponseHandle`. We need to do * this so we can distinguish the two sockets when epoll() * gives us event notifications. */ struct UpgradeEpollHandle { /** * Reference to the overall response handle this struct is * included within. */ struct MHD_UpgradeResponseHandle *urh; /** * The socket this event is kind-of about. Note that this is NOT * necessarily the socket we are polling on, as for when we read * from TLS, we epoll() on the connection's socket * (`urh->connection->socket_fd`), while this then the application's * socket (where the application will read from). Nevertheless, for * the application to read, we need to first read from TLS, hence * the two are related. * * Similarly, for writing to TLS, this epoll() will be on the * connection's `socket_fd`, and this will merely be the FD which * the application would write to. Hence this struct must always be * interpreted based on which field in `struct * MHD_UpgradeResponseHandle` it is (`app` or `mhd`). */ MHD_socket socket; /** * IO-state of the @e socket (or the connection's `socket_fd`). */ enum MHD_EpollState celi; }; /** * Handle given to the application to manage special * actions relating to MHD responses that "upgrade" * the HTTP protocol (i.e. to WebSockets). */ struct MHD_UpgradeResponseHandle { /** * The connection for which this is an upgrade handle. Note that * because a response may be shared over many connections, this may * not be the only upgrade handle for the response of this connection. */ struct MHD_Connection *connection; #ifdef HTTPS_SUPPORT /** * Kept in a DLL per daemon. */ struct MHD_UpgradeResponseHandle *next; /** * Kept in a DLL per daemon. */ struct MHD_UpgradeResponseHandle *prev; #ifdef EPOLL_SUPPORT /** * Next pointer for the EDLL listing urhs that are epoll-ready. */ struct MHD_UpgradeResponseHandle *nextE; /** * Previous pointer for the EDLL listing urhs that are epoll-ready. */ struct MHD_UpgradeResponseHandle *prevE; /** * Specifies whether urh already in EDLL list of ready connections. */ bool in_eready_list; #endif /** * The buffer for receiving data from TLS to * be passed to the application. Contains @e in_buffer_size * bytes (unless @e in_buffer_size is zero). Do not free! */ char *in_buffer; /** * The buffer for receiving data from the application to * be passed to TLS. Contains @e out_buffer_size * bytes (unless @e out_buffer_size is zero). Do not free! */ char *out_buffer; /** * Size of the @e in_buffer. * Set to 0 if the TLS connection went down for reading or socketpair * went down for writing. */ size_t in_buffer_size; /** * Size of the @e out_buffer. * Set to 0 if the TLS connection went down for writing or socketpair * went down for reading. */ size_t out_buffer_size; /** * Number of bytes actually in use in the @e in_buffer. Can be larger * than @e in_buffer_size if and only if @a in_buffer_size is zero and * we still have bytes that can be forwarded. * Reset to zero if all data was forwarded to socketpair or * if socketpair went down for writing. */ size_t in_buffer_used; /** * Number of bytes actually in use in the @e out_buffer. Can be larger * than @e out_buffer_size if and only if @a out_buffer_size is zero and * we still have bytes that can be forwarded. * Reset to zero if all data was forwarded to TLS connection or * if TLS connection went down for writing. */ size_t out_buffer_used; /** * The socket we gave to the application (r/w). */ struct UpgradeEpollHandle app; /** * If @a app_sock was a socketpair, our end of it, otherwise * #MHD_INVALID_SOCKET; (r/w). */ struct UpgradeEpollHandle mhd; /** * Emergency IO buffer we use in case the memory pool has literally * nothing left. */ char e_buf[RESERVE_EBUF_SIZE]; #endif /* HTTPS_SUPPORT */ /** * Set to true after the application finished with the socket * by #MHD_UPGRADE_ACTION_CLOSE. * * When BOTH @e was_closed (changed by command from application) * AND @e clean_ready (changed internally by MHD) are set to * #MHD_YES, function #MHD_resume_connection() will move this * connection to cleanup list. * @remark This flag could be changed from any thread. */ volatile bool was_closed; /** * Set to true if connection is ready for cleanup. * * In TLS mode functions #MHD_connection_finish_forward_() must * be called before setting this flag to true. * * In thread-per-connection mode, true in this flag means * that connection's thread exited or about to exit and will * not use MHD_Connection::urh data anymore. * * In any mode true in this flag also means that * MHD_Connection::urh data will not be used for socketpair * forwarding and forwarding itself is finished. * * When BOTH @e was_closed (changed by command from application) * AND @e clean_ready (changed internally by MHD) are set to * true, function #MHD_resume_connection() will move this * connection to cleanup list. * @remark This flag could be changed from thread that process * connection's recv(), send() and response. */ bool clean_ready; }; #endif /* UPGRADE_SUPPORT */ /** * State kept for each MHD daemon. All connections are kept in two * doubly-linked lists. The first one reflects the state of the * connection in terms of what operations we are waiting for (read, * write, locally blocked, cleanup) whereas the second is about its * timeout state (default or custom). */ struct MHD_Daemon { /** * Function to call to handle incoming requests. */ MHD_RequestCallback rc; /** * Closure for @e rc. */ void *rc_cls; /** * Function to call for logging. */ MHD_LoggingCallback logger; /** * Closure for @e logger. */ void *logger_cls; /** * Function to call to accept/reject connections based on * the client's IP address. */ MHD_AcceptPolicyCallback accept_policy_cb; /** * Closure for @e accept_policy_cb. */ void *accept_policy_cb_cls; /** * Function to call on the full URL early for logging. */ MHD_EarlyUriLogCallback early_uri_logger_cb; /** * Closure for @e early_uri_logger_cb. */ void *early_uri_logger_cb_cls; /** * Function to call whenever a connection is started or * closed. */ MHD_NotifyConnectionCallback notify_connection_cb; /** * Closure for @e notify_connection_cb. */ void *notify_connection_cb_cls; /** * Function to call to unescape sequences in URIs and URI arguments. * See #MHD_daemon_unescape_cb(). */ MHD_UnescapeCallback unescape_cb; /** * Closure for @e unescape_cb. */ void *unescape_cb_cls; /** * Pointer to master daemon (NULL if this is the master) */ struct MHD_Daemon *master; /** * Worker daemons (one per thread) */ struct MHD_Daemon *worker_pool; #if HTTPS_SUPPORT #ifdef UPGRADE_SUPPORT /** * Head of DLL of upgrade response handles we are processing. * Used for upgraded TLS connections when thread-per-connection * is not used. */ struct MHD_UpgradeResponseHandle *urh_head; /** * Tail of DLL of upgrade response handles we are processing. * Used for upgraded TLS connections when thread-per-connection * is not used. */ struct MHD_UpgradeResponseHandle *urh_tail; #endif /* UPGRADE_SUPPORT */ /** * Which TLS backend should be used. NULL for no TLS. * This is merely the handle to the dlsym() object, not * the API. */ void *tls_backend_lib; /** * Callback functions to use for TLS operations. */ struct MHD_TLS_Plugin *tls_api; #endif #if ENABLE_DAUTH /** * Random values to be used by digest authentication module. * Size given in @e digest_auth_random_buf_size. */ const void *digest_auth_random_buf; #endif /** * Head of the XDLL of ALL connections with a default ('normal') * timeout, sorted by timeout (earliest at the tail, most recently * used connection at the head). MHD can just look at the tail of * this list to determine the timeout for all of its elements; * whenever there is an event of a connection, the connection is * moved back to the tail of the list. * * All connections by default start in this list; if a custom * timeout that does not match @e connection_timeout is set, they * are moved to the @e manual_timeout_head-XDLL. * Not used in MHD_USE_THREAD_PER_CONNECTION mode as each thread * needs only one connection-specific timeout. */ struct MHD_Connection *normal_timeout_head; /** * Tail of the XDLL of ALL connections with a default timeout, * sorted by timeout (earliest timeout at the tail). * Not used in MHD_USE_THREAD_PER_CONNECTION mode. */ struct MHD_Connection *normal_timeout_tail; /** * Head of the XDLL of ALL connections with a non-default/custom * timeout, unsorted. MHD will do a O(n) scan over this list to * determine the current timeout. * Not used in MHD_USE_THREAD_PER_CONNECTION mode. */ struct MHD_Connection *manual_timeout_head; /** * Tail of the XDLL of ALL connections with a non-default/custom * timeout, unsorted. * Not used in MHD_USE_THREAD_PER_CONNECTION mode. */ struct MHD_Connection *manual_timeout_tail; /** * Head of doubly-linked list of our current, active connections. */ struct MHD_Connection *connections_head; /** * Tail of doubly-linked list of our current, active connections. */ struct MHD_Connection *connections_tail; /** * Head of doubly-linked list of our current but suspended * connections. */ struct MHD_Connection *suspended_connections_head; /** * Tail of doubly-linked list of our current but suspended * connections. */ struct MHD_Connection *suspended_connections_tail; /** * Head of doubly-linked list of connections to clean up. */ struct MHD_Connection *cleanup_head; /** * Tail of doubly-linked list of connections to clean up. */ struct MHD_Connection *cleanup_tail; /** * Table storing number of connections per IP */ void *per_ip_connection_count; #ifdef EPOLL_SUPPORT /** * Head of EDLL of connections ready for processing (in epoll mode). */ struct MHD_Connection *eready_head; /** * Tail of EDLL of connections ready for processing (in epoll mode) */ struct MHD_Connection *eready_tail; /** * Pointer to marker used to indicate ITC slot in epoll sets. */ const char *epoll_itc_marker; #ifdef UPGRADE_SUPPORT /** * Head of EDLL of upgraded connections ready for processing (in epoll mode). */ struct MHD_UpgradeResponseHandle *eready_urh_head; /** * Tail of EDLL of upgraded connections ready for processing (in epoll mode) */ struct MHD_UpgradeResponseHandle *eready_urh_tail; #endif /* UPGRADE_SUPPORT */ #endif /* EPOLL_SUPPORT */ #ifdef DAUTH_SUPPORT /** * Character array of random values. */ const char *digest_auth_random; /** * An array that contains the map nonce-nc. */ struct MHD_NonceNc *nnc; /** * A rw-lock for synchronizing access to @e nnc. */ MHD_mutex_ nnc_lock; /** * Size of `digest_auth_random. */ size_t digest_auth_rand_size; /** * Size of the nonce-nc array. */ unsigned int nonce_nc_size; #endif /** * The select thread handle (if we have internal select) */ MHD_thread_handle_ID_ pid; /** * Socket address to bind to for the listen socket. */ struct sockaddr_storage listen_sa; /** * Mutex for per-IP connection counts. */ MHD_mutex_ per_ip_connection_mutex; /** * Mutex for (modifying) access to the "cleanup", "normal_timeout" and * "manual_timeout" DLLs. */ MHD_mutex_ cleanup_connection_mutex; /** * Number of (valid) bytes in @e listen_sa. Zero * if @e listen_sa is not initialized. */ size_t listen_sa_len; /** * Default size of the per-connection memory pool. */ #define POOL_SIZE_DEFAULT (32 * 1024) /** * Buffer size to use for each connection. Default * is #POOL_SIZE_DEFAULT. */ size_t connection_memory_limit_b; /** * Default minimum size by which MHD tries to increment read/write * buffers. We usually begin with half the available pool space for * the IO-buffer, but if absolutely needed we additively grow by the * number of bytes given here (up to -- theoretically -- the full pool * space). */ #define BUF_INC_SIZE_DEFAULT 1024 /** * Increment to use when growing the read buffer. Smaller * than @e connection_memory_limit_b. */ size_t connection_memory_increment_b; /** * Desired size of the stack for threads created by MHD, * 0 for system default. */ size_t thread_stack_limit_b; #if ENABLE_DAUTH /** * Size of @e digest_auth_random_buf. */ size_t digest_auth_random_buf_size; /** * Default value for @e digest_nc_length. */ #define DIGEST_NC_LENGTH_DEFAULT 4 /** * Desired length of the internal array with the nonce and * nonce counters for digest authentication. */ size_t digest_nc_length; #endif /** * Default value we use for the listen backlog. */ #ifdef SOMAXCONN #define LISTEN_BACKLOG_DEFAULT SOMAXCONN #else /* !SOMAXCONN */ #define LISTEN_BACKLOG_DEFAULT 511 #endif /** * Backlog argument to use for listen. See * #MHD_daemon_listen_backlog(). */ int listen_backlog; /** * Default queue length to use with fast open. */ #define FO_QUEUE_LENGTH_DEFAULT 50 /** * Queue length to use with fast open. */ unsigned int fo_queue_length; /** * Maximum number of connections MHD accepts. 0 for unlimited. */ unsigned int global_connection_limit; /** * Maximum number of connections we accept per IP, 0 for unlimited. */ unsigned int ip_connection_limit; /** * Number of active parallel connections. */ unsigned int connections; /** * Number of worker daemons */ unsigned int worker_pool_size; /** * Default timeout in seconds for idle connections. */ time_t connection_default_timeout; /** * Listen socket we should use, MHD_INVALID_SOCKET means * we are to initialize the socket from the other options given. */ MHD_socket listen_socket; #ifdef EPOLL_SUPPORT /** * File descriptor associated with our epoll loop. */ int epoll_fd; /** * true if the listen socket is in the 'epoll' set, * false if not. */ bool listen_socket_in_epoll; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * File descriptor associated with the #run_epoll_for_upgrade() loop. * Only available if #MHD_USE_HTTPS_EPOLL_UPGRADE is set. */ int epoll_upgrade_fd; /** * true if @e epoll_upgrade_fd is in the 'epoll' set, * false if not. */ bool upgrade_fd_in_epoll; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ #endif /** * Inter-thread communication channel. */ struct MHD_itc_ itc; /** * Which threading mode do we use? Positive * numbers indicate the number of worker threads to be used. * Values larger than 1 imply a thread pool. */ enum MHD_ThreadingMode threading_mode; /** * When should we use TCP_FASTOPEN? * See #MHD_daemon_tcp_fastopen(). */ enum MHD_FastOpenMethod fast_open_method; /** * Address family to use when listening. * Default is #MHD_AF_NONE (do not listen). */ enum MHD_AddressFamily listen_af; /** * Sets active/desired style of the event loop. * (Auto only possible during initialization, later set to * the actual style we use.) */ enum MHD_EventLoopSyscall event_loop_syscall; /** * How strictly do we enforce the HTTP protocol? * See #MHD_daemon_protocol_strict_level(). */ enum MHD_ProtocolStrictLevel protocol_strict_level; /** * On which port should we listen on? Only effective if we were not * given a listen socket or a full address via * #MHD_daemon_bind_sa(). 0 means to bind to random free port. */ uint16_t listen_port; /** * Suppress generating the "Date:" header, this system * lacks an RTC (or developer is hyper-optimizing). See * #MHD_daemon_suppress_date_no_clock(). */ bool suppress_date; /** * The use of the inter-thread communication channel is disabled. * See #MHD_daemon_disable_itc(). */ bool disable_itc; /** * Disable #MHD_action_suspend() functionality. See * #MHD_daemon_disallow_suspend_resume(). */ bool disallow_suspend_resume; /** * Disable #MHD_action_upgrade() functionality. See * #MHD_daemon_disallow_upgrade(). */ bool disallow_upgrade; /** * Did we hit some system or process-wide resource limit while * trying to accept() the last time? If so, we don't accept new * connections until we close an existing one. This effectively * temporarily lowers the "connection_limit" to the current * number of connections. */ bool at_limit; /** * Disables optional calls to `shutdown()` and enables aggressive * non-blocking optimistic reads and other potentially unsafe * optimizations. See #MHD_daemon_enable_turbo(). */ bool enable_turbo; /** * 'True' if some data is already waiting to be processed. If set * to 'true' - zero timeout for select()/poll*() is used. Should be * reset each time before processing connections and raised by any * connection which require additional immediately processing * (application does not provide data for response, data waiting in * TLS buffers etc.) */ bool data_already_pending; /** * MHD_daemon_quiesce() was run against this daemon. */ bool was_quiesced; /** * Is some connection wanting to resume? */ bool resuming; /** * Allow reusing the address:port combination when binding. * See #MHD_daemon_listen_allow_address_reuse(). */ bool allow_address_reuse; /** * MHD should speak SHOUTcast instead of HTTP. */ bool enable_shoutcast; /** * Are we shutting down? */ volatile bool shutdown; }; /** * Action function implementing some action to be * performed on a request. * * @param cls action-specfic closure * @param request the request on which the action is to be performed * @return #MHD_SC_OK on success, otherwise an error code */ typedef enum MHD_StatusCode (*ActionCallback)(void *cls, struct MHD_Request *request); /** * Actions are returned by the application to drive the request * handling of MHD. */ struct MHD_Action { /** * Function to call for the action. */ ActionCallback action; /** * Closure for @a action */ void *action_cls; }; /** * Representation of an HTTP response. */ struct MHD_Response { /** * A response *is* an action. See also * #MHD_action_from_response(). Hence this field * must be the first field in a response! */ struct MHD_Action action; /** * Headers to send for the response. Initially * the linked list is created in inverse order; * the order should be inverted before sending! */ struct MHD_HTTP_Header *first_header; /** * Buffer pointing to data that we are supposed * to send as a response. */ char *data; /** * Closure to give to the content reader @e crc * and content reader free callback @e crfc. */ void *crc_cls; /** * How do we get more data? NULL if we are * given all of the data up front. */ MHD_ContentReaderCallback crc; /** * NULL if data must not be freed, otherwise * either user-specified callback or "&free". */ MHD_ContentReaderFreeCallback crfc; /** * Function to call once MHD is finished with * the request, may be NULL. */ MHD_RequestTerminationCallback termination_cb; /** * Closure for @e termination_cb. */ void *termination_cb_cls; #ifdef UPGRADE_SUPPORT /** * Application function to call once we are done sending the headers * of the response; NULL unless this is a response created with * #MHD_create_response_for_upgrade(). */ MHD_UpgradeHandler upgrade_handler; /** * Closure for @e uh. */ void *upgrade_handler_cls; #endif /* UPGRADE_SUPPORT */ /** * Mutex to synchronize access to @e data, @e size and * @e reference_count. */ MHD_mutex_ mutex; /** * Set to #MHD_SIZE_UNKNOWN if size is not known. */ uint64_t total_size; /** * At what offset in the stream is the * beginning of @e data located? */ uint64_t data_start; /** * Offset to start reading from when using @e fd. */ uint64_t fd_off; /** * Number of bytes ready in @e data (buffer may be larger * than what is filled with payload). */ size_t data_size; /** * Size of the data buffer @e data. */ size_t data_buffer_size; /** * HTTP status code of the response. */ enum MHD_HTTP_StatusCode status_code; /** * Reference count for this response. Free once the counter hits * zero. */ unsigned int reference_count; /** * File-descriptor if this response is FD-backed. */ int fd; /** * Only respond in HTTP 1.0 mode. */ bool v10_only; /** * Use ShoutCAST format. */ bool icy; }; /** * Callback invoked when iterating over @a key / @a value * argument pairs during parsing. * * @param request context of the iteration * @param key 0-terminated key string, never NULL * @param value 0-terminated value string, may be NULL * @param kind origin of the key-value pair * @return true on success (continue to iterate) * false to signal failure (and abort iteration) */ typedef bool (*MHD_ArgumentIterator_)(struct MHD_Request *request, const char *key, const char *value, enum MHD_ValueKind kind); /** * Parse and unescape the arguments given by the client * as part of the HTTP request URI. * * @param request request to add headers to * @param kind header kind to pass to @a cb * @param[in,out] args argument URI string (after "?" in URI), * clobbered in the process! * @param cb function to call on each key-value pair found * @param[out] num_headers set to the number of headers found * @return false on failure (@a cb returned false), * true for success (parsing succeeded, @a cb always * returned true) */ bool MHD_parse_arguments_ (struct MHD_Request *request, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers); /** * Insert an element at the head of a DLL. Assumes that head, tail and * element are structs with prev and next fields. * * @param head pointer to the head of the DLL * @param tail pointer to the tail of the DLL * @param element element to insert */ #define DLL_insert(head,tail,element) do { \ mhd_assert (NULL == (element)->next); \ mhd_assert (NULL == (element)->prev); \ (element)->next = (head); \ (element)->prev = NULL; \ if ((tail) == NULL) \ (tail) = element; \ else \ (head)->prev = element; \ (head) = (element); } while (0) /** * Remove an element from a DLL. Assumes that head, tail and element * are structs with prev and next fields. * * @param head pointer to the head of the DLL * @param tail pointer to the tail of the DLL * @param element element to remove */ #define DLL_remove(head,tail,element) do { \ mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \ mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \ if ((element)->prev == NULL) \ (head) = (element)->next; \ else \ (element)->prev->next = (element)->next; \ if ((element)->next == NULL) \ (tail) = (element)->prev; \ else \ (element)->next->prev = (element)->prev; \ (element)->next = NULL; \ (element)->prev = NULL; } while (0) /** * Insert an element at the head of a XDLL. Assumes that head, tail and * element are structs with prevX and nextX fields. * * @param head pointer to the head of the XDLL * @param tail pointer to the tail of the XDLL * @param element element to insert */ #define XDLL_insert(head,tail,element) do { \ mhd_assert (NULL == (element)->nextX); \ mhd_assert (NULL == (element)->prevX); \ (element)->nextX = (head); \ (element)->prevX = NULL; \ if (NULL == (tail)) \ (tail) = element; \ else \ (head)->prevX = element; \ (head) = (element); } while (0) /** * Remove an element from a XDLL. Assumes that head, tail and element * are structs with prevX and nextX fields. * * @param head pointer to the head of the XDLL * @param tail pointer to the tail of the XDLL * @param element element to remove */ #define XDLL_remove(head,tail,element) do { \ mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \ mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \ if (NULL == (element)->prevX) \ (head) = (element)->nextX; \ else \ (element)->prevX->nextX = (element)->nextX; \ if (NULL == (element)->nextX) \ (tail) = (element)->prevX; \ else \ (element)->nextX->prevX = (element)->prevX; \ (element)->nextX = NULL; \ (element)->prevX = NULL; } while (0) /** * Insert an element at the head of a EDLL. Assumes that head, tail and * element are structs with prevE and nextE fields. * * @param head pointer to the head of the EDLL * @param tail pointer to the tail of the EDLL * @param element element to insert */ #define EDLL_insert(head,tail,element) do { \ (element)->nextE = (head); \ (element)->prevE = NULL; \ if ((tail) == NULL) \ (tail) = element; \ else \ (head)->prevE = element; \ (head) = (element); } while (0) /** * Remove an element from a EDLL. Assumes that head, tail and element * are structs with prevE and nextE fields. * * @param head pointer to the head of the EDLL * @param tail pointer to the tail of the EDLL * @param element element to remove */ #define EDLL_remove(head,tail,element) do { \ if ((element)->prevE == NULL) \ (head) = (element)->nextE; \ else \ (element)->prevE->nextE = (element)->nextE; \ if ((element)->nextE == NULL) \ (tail) = (element)->prevE; \ else \ (element)->nextE->prevE = (element)->prevE; \ (element)->nextE = NULL; \ (element)->prevE = NULL; } while (0) /** * Error code similar to EGAIN or EINTR */ #define MHD_ERR_AGAIN_ (-3073) /** * Connection was hard-closed by remote peer. */ #define MHD_ERR_CONNRESET_ (-3074) /** * Connection is not connected anymore due to * network error or any other reason. */ #define MHD_ERR_NOTCONN_ (-3075) /** * "Not enough memory" error code */ #define MHD_ERR_NOMEM_ (-3076) /** * "Bad FD" error code */ #define MHD_ERR_BADF_ (-3077) /** * Error code similar to EINVAL */ #define MHD_ERR_INVAL_ (-3078) #endif libmicrohttpd-1.0.1/src/lib/request_resume.c0000644000175000017500000001505414417460232014617 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/request_resume.c * @brief implementation of MHD_request_resume() * @author Christian Grothoff */ #include "internal.h" #include "connection_close.h" /** * Resume handling of network data for suspended request. It is * safe to resume a suspended request at any time. Calling this * function on a request that was not previously suspended will * result in undefined behavior. * * If you are using this function in ``external'' select mode, you must * make sure to run #MHD_run() afterwards (before again calling * #MHD_get_fdset(), as otherwise the change may not be reflected in * the set returned by #MHD_get_fdset() and you may end up with a * request that is stuck until the next network activity. * * @param request the request to resume */ void MHD_request_resume (struct MHD_Request *request) { struct MHD_Daemon *daemon = request->daemon; if (daemon->disallow_suspend_resume) MHD_PANIC (_ ( "Cannot resume connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n")); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); request->connection->resuming = true; daemon->resuming = true; MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "r")) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ITC_USE_FAILED, _ ( "Failed to signal resume via inter-thread communication channel.\n")); #endif } } /** * Run through the suspended connections and move any that are no * longer suspended back to the active state. * * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon daemon context * @return true if a connection was actually resumed */ bool MHD_resume_suspended_connections_ (struct MHD_Daemon *daemon) /* FIXME: rename connections -> requests? */ { struct MHD_Connection *pos; struct MHD_Connection *prev = NULL; bool ret; const bool used_thr_p_c = (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode); mhd_assert (NULL == daemon->worker_pool); ret = false; MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); if (daemon->resuming) { prev = daemon->suspended_connections_tail; /* During shutdown check for resuming is forced. */ mhd_assert ((NULL != prev) || (daemon->shutdown)); } daemon->resuming = false; while (NULL != (pos = prev)) { #ifdef UPGRADE_SUPPORT struct MHD_UpgradeResponseHandle *const urh = pos->request.urh; #else /* ! UPGRADE_SUPPORT */ static const void *const urh = NULL; #endif /* ! UPGRADE_SUPPORT */ prev = pos->prev; if ( (! pos->resuming) #ifdef UPGRADE_SUPPORT || ( (NULL != urh) && ( (! urh->was_closed) || (! urh->clean_ready) ) ) #endif /* UPGRADE_SUPPORT */ ) continue; ret = true; mhd_assert (pos->suspended); DLL_remove (daemon->suspended_connections_head, daemon->suspended_connections_tail, pos); pos->suspended = false; if (NULL == urh) { DLL_insert (daemon->connections_head, daemon->connections_tail, pos); if (! used_thr_p_c) { /* Reset timeout timer on resume. */ if (0 != pos->connection_timeout) pos->last_activity = MHD_monotonic_sec_counter (); if (pos->connection_timeout == daemon->connection_default_timeout) XDLL_insert (daemon->normal_timeout_head, daemon->normal_timeout_tail, pos); else XDLL_insert (daemon->manual_timeout_head, daemon->manual_timeout_tail, pos); } #ifdef EPOLL_SUPPORT if (MHD_ELS_EPOLL == daemon->event_loop_syscall) { if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) MHD_PANIC ("Resumed connection was already in EREADY set.\n"); /* we always mark resumed connections as ready, as we might have missed the edge poll event during suspension */ EDLL_insert (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL \ | MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY; pos->epoll_state &= ~MHD_EPOLL_STATE_SUSPENDED; } #endif } #ifdef UPGRADE_SUPPORT else { struct MHD_Response *response = pos->request.response; /* Data forwarding was finished (for TLS connections) AND * application was closed upgraded connection. * Insert connection into cleanup list. */ if ( (NULL != response) && (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) && (NULL != response->termination_cb) ) response->termination_cb (response->termination_cb_cls, MHD_REQUEST_TERMINATED_COMPLETED_OK, &pos->request.client_context); DLL_insert (daemon->cleanup_head, daemon->cleanup_tail, pos); } #endif /* UPGRADE_SUPPORT */ pos->resuming = false; } MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); if ( (used_thr_p_c) && (ret) ) { /* Wake up suspended connections. */ if (! MHD_itc_activate_ (daemon->itc, "w")) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ITC_USE_FAILED, _ ( "Failed to signal resume of connection via inter-thread communication channel.\n")); #endif } } return ret; } /* end of request_resume.c */ libmicrohttpd-1.0.1/src/lib/response_from_fd.c0000644000175000017500000001502514417460232015077 /* This file is part of libmicrohttpd Copyright (C) 2007-2019 Daniel Pittman, Christian Grothoff and Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/response_from_fd.c * @brief implementation of MHD_response_from_fd() * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "internal.h" /** * Size of single file read operation for * file-backed responses. */ #ifndef MHD_FILE_READ_BLOCK_SIZE #ifdef _WIN32 #define MHD_FILE_READ_BLOCK_SIZE 16384 /* 16k */ #else /* _WIN32 */ #define MHD_FILE_READ_BLOCK_SIZE 4096 /* 4k */ #endif /* _WIN32 */ #endif /* !MHD_FD_BLOCK_SIZE */ /** * Given a file descriptor, read data from the file * to generate the response. * * @param cls pointer to the response * @param pos offset in the file to access * @param buf where to write the data * @param max number of bytes to write at most * @return number of bytes written */ static ssize_t file_reader (void *cls, uint64_t pos, char *buf, size_t max) { struct MHD_Response *response = cls; #if ! defined(_WIN32) || defined(__CYGWIN__) ssize_t n; #else /* _WIN32 && !__CYGWIN__ */ const HANDLE fh = (HANDLE) _get_osfhandle (response->fd); #endif /* _WIN32 && !__CYGWIN__ */ const int64_t offset64 = (int64_t) (pos + response->fd_off); if (offset64 < 0) return MHD_CONTENT_READER_END_WITH_ERROR; /* seek to required position is not possible */ #if ! defined(_WIN32) || defined(__CYGWIN__) if (max > SSIZE_MAX) max = SSIZE_MAX; /* Clamp to maximum return value. */ #if defined(HAVE_PREAD64) n = pread64 (response->fd, buf, max, offset64); #elif defined(HAVE_PREAD) if ( (sizeof(off_t) < sizeof (uint64_t)) && (offset64 > (uint64_t) INT32_MAX) ) return MHD_CONTENT_READER_END_WITH_ERROR; /* Read at required position is not possible. */ n = pread (response->fd, buf, max, (off_t) offset64); #else /* ! HAVE_PREAD */ #if defined(HAVE_LSEEK64) if (lseek64 (response->fd, offset64, SEEK_SET) != offset64) return MHD_CONTENT_READER_END_WITH_ERROR; /* can't seek to required position */ #else /* ! HAVE_LSEEK64 */ if ( (sizeof(off_t) < sizeof (uint64_t)) && (offset64 > (uint64_t) INT32_MAX) ) return MHD_CONTENT_READER_END_WITH_ERROR; /* seek to required position is not possible */ if (lseek (response->fd, (off_t) offset64, SEEK_SET) != (off_t) offset64) return MHD_CONTENT_READER_END_WITH_ERROR; /* can't seek to required position */ #endif /* ! HAVE_LSEEK64 */ n = read (response->fd, buf, max); #endif /* ! HAVE_PREAD */ if (0 == n) return MHD_CONTENT_READER_END_OF_STREAM; if (n < 0) return MHD_CONTENT_READER_END_WITH_ERROR; return n; #else /* _WIN32 && !__CYGWIN__ */ if (INVALID_HANDLE_VALUE == fh) return MHD_CONTENT_READER_END_WITH_ERROR; /* Value of 'response->fd' is not valid. */ else { OVERLAPPED f_ol = {0, 0, {{0, 0}}, 0}; /* Initialize to zero. */ ULARGE_INTEGER pos_uli; DWORD toRead = (max > INT32_MAX) ? INT32_MAX : (DWORD) max; DWORD resRead; pos_uli.QuadPart = (uint64_t) offset64; /* Simple transformation 64bit -> 2x32bit. */ f_ol.Offset = pos_uli.LowPart; f_ol.OffsetHigh = pos_uli.HighPart; if (! ReadFile (fh, (void *) buf, toRead, &resRead, &f_ol)) return MHD_CONTENT_READER_END_WITH_ERROR; /* Read error. */ if (0 == resRead) return MHD_CONTENT_READER_END_OF_STREAM; return (ssize_t) resRead; } #endif /* _WIN32 && !__CYGWIN__ */ } /** * Destroy file reader context. Closes the file * descriptor. * * @param cls pointer to file descriptor */ static void free_callback (void *cls) { struct MHD_Response *response = cls; (void) close (response->fd); response->fd = -1; } /** * Create a response object based on an @a fd from which * data is read. The response object can be extended with * header information and then be used any number of times. * * @param sc status code to return * @param fd file descriptor referring to a file on disk with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @param offset offset to start reading from in the file; * reading file beyond 2 GiB may be not supported by OS or * MHD build; see ::MHD_FEATURE_LARGE_FILE * @param size size of the data portion of the response; * sizes larger than 2 GiB may be not supported by OS or * MHD build; see ::MHD_FEATURE_LARGE_FILE * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ struct MHD_Response * MHD_response_from_fd (enum MHD_HTTP_StatusCode sc, int fd, uint64_t offset, uint64_t size) { struct MHD_Response *response; mhd_assert (-1 != fd); #if ! defined(HAVE___LSEEKI64) && ! defined(HAVE_LSEEK64) if ( (sizeof (uint64_t) > sizeof (off_t)) && ( (size > (uint64_t) INT32_MAX) || (offset > (uint64_t) INT32_MAX) || ((size + offset) >= (uint64_t) INT32_MAX) ) ) return NULL; #endif if ( ((int64_t) size < 0) || ((int64_t) offset < 0) || ((int64_t) (size + offset) < 0) ) return NULL; response = MHD_response_from_callback (sc, size, MHD_FILE_READ_BLOCK_SIZE, &file_reader, NULL, &free_callback); if (NULL == response) return NULL; response->fd = fd; response->fd_off = offset; response->crc_cls = response; return response; } /* end of response_from_fd.c */ libmicrohttpd-1.0.1/src/lib/mhd_byteorder.h0000644000175000017500000001353614441373361014411 /* This file is part of libmicrohttpd Copyright (C) 2015 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/mhd_byteorder.h * @brief macro definitions for host byte order * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_BYTEORDER_H #define MHD_BYTEORDER_H #include "platform.h" #ifdef HAVE_ENDIAN_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_MACHINE_ENDIAN_H #include #endif #ifdef HAVE_SYS_ENDIAN_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_BYTEORDER_H #include #endif #ifdef HAVE_SYS_MACHINE_H #include #endif #ifdef HAVE_MACHINE_PARAM_H #include #endif #ifdef HAVE_SYS_ISA_DEFS_H #include #endif #define _MHD_BIG_ENDIAN 1234 #define _MHD_LITTLE_ENDIAN 4321 #define _MHD_PDP_ENDIAN 2143 #if defined(__BYTE_ORDER__) #if defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == \ __ORDER_LITTLE_ENDIAN__ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(__ORDER_PDP_ENDIAN__) && __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ #define _MHD_BYTE_ORDER _MHD_PDP_ENDIAN #endif /* __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ */ #elif defined(__BYTE_ORDER) #if defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(__PDP_ENDIAN) && __BYTE_ORDER == __PDP_ENDIAN #define _MHD_BYTE_ORDER _MHD_PDP_ENDIAN #endif /* __BYTE_ORDER == __PDP_ENDIAN */ #elif defined (BYTE_ORDER) #if defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(LITTLE_ENDIAN) && BYTE_ORDER == LITTLE_ENDIAN #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(PDP_ENDIAN) && BYTE_ORDER == PDP_ENDIAN #define _MHD_BYTE_ORDER _MHD_PDP_ENDIAN #endif /* __BYTE_ORDER == _PDP_ENDIAN */ #elif defined (_BYTE_ORDER) #if defined(_BIG_ENDIAN) && _BYTE_ORDER == _BIG_ENDIAN #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(_LITTLE_ENDIAN) && _BYTE_ORDER == _LITTLE_ENDIAN #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(_PDP_ENDIAN) && _BYTE_ORDER == _PDP_ENDIAN #define _MHD_BYTE_ORDER _MHD_PDP_ENDIAN #endif /* _BYTE_ORDER == _PDP_ENDIAN */ #endif /* _BYTE_ORDER */ #ifndef _MHD_BYTE_ORDER /* Byte order specification didn't detected in system headers */ /* Try some guessing */ #if (defined(__BIG_ENDIAN__) && ! defined(__LITTLE_ENDIAN__)) || \ (defined(_BIG_ENDIAN) && ! defined(_LITTLE_ENDIAN)) /* Seems that we are on big endian platform */ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif (defined(__LITTLE_ENDIAN__) && ! defined(__BIG_ENDIAN__)) || \ (defined(_LITTLE_ENDIAN) && ! defined(_BIG_ENDIAN)) /* Seems that we are on little endian platform */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || \ defined(__x86_64) || \ defined(_M_X64) || defined(_M_AMD64) || defined(i386) || defined(__i386) || \ defined(__i386__) || defined(__i486__) || defined(__i586__) || \ defined(__i686__) || \ defined(_M_IX86) || defined(_X86_) || defined (__THW_INTEL__) /* x86 family is little endian */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \ defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) /* Looks like we are on ARM/MIPS in big endian mode */ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \ defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) /* Looks like we are on ARM/MIPS in little endian mode */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(__m68k__) || defined(M68000) || defined(__hppa__) || \ defined(__hppa) || \ defined(__HPPA__) || defined(__370__) || defined(__THW_370__) || \ defined(__s390__) || defined(__s390x__) || defined(__SYSC_ZARCH__) /* Looks like we are on big endian platform */ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(__ia64__) || defined(_IA64) || defined(__IA64__) || \ defined(__ia64) || \ defined(_M_IA64) || defined(__itanium__) || defined(__bfin__) || \ defined(__BFIN__) || defined(bfin) || defined(BFIN) /* Looks like we are on little endian platform */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(_WIN32) /* W32 is always little endian on all platforms */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(WORDS_BIGENDIAN) /* Use byte order detected by configure */ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #endif /* _WIN32 */ #endif /* !_MHD_BYTE_ORDER */ #ifdef _MHD_BYTE_ORDER /* Some safety checks */ #if defined(WORDS_BIGENDIAN) && _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN #error \ Configure detected big endian byte order but headers specify different byte order #elif ! defined(WORDS_BIGENDIAN) && _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN #error \ Configure did not detect big endian byte order but headers specify big endian byte order #endif /* !WORDS_BIGENDIAN && _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN */ #endif /* _MHD_BYTE_ORDER */ #endif /* !MHD_BYTEORDER_H */ libmicrohttpd-1.0.1/src/lib/sysfdsetsize.c0000644000175000017500000000425714441373361014314 /* This file is part of libmicrohttpd Copyright (C) 2015 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/sysfdsetsize.c * @brief Helper for obtaining FD_SETSIZE system default value * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #ifdef FD_SETSIZE /* FD_SETSIZE was defined before system headers. */ /* To get system value of FD_SETSIZE, undefine FD_SETSIZE here. */ #undef FD_SETSIZE #endif /* FD_SETSIZE */ #include #if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS) #include #endif /* OS_VXWORKS */ #ifdef HAVE_SYS_SELECT_H #include #endif /* HAVE_SYS_SELECT_H */ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if defined(_WIN32) && ! defined(__CYGWIN__) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif /* _WIN32 && !__CYGWIN__ */ #ifndef FD_SETSIZE #error FD_SETSIZE must be defined in system headers #endif /* !FD_SETSIZE */ #include "sysfdsetsize.h" /** * Get system default value of FD_SETSIZE * @return system default value of FD_SETSIZE */ int get_system_fdsetsize_value (void) { return FD_SETSIZE; } libmicrohttpd-1.0.1/src/lib/mhd_mono_clock.c0000644000175000017500000002504614417460232014524 /* This file is part of libmicrohttpd Copyright (C) 2015 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_mono_clock.h * @brief internal monotonic clock functions implementations * @author Karlson2k (Evgeny Grin) */ #include "mhd_mono_clock.h" #if defined(_WIN32) && ! defined(__CYGWIN__) && defined(HAVE_CLOCK_GETTIME) /* Prefer native clock source over wrappers */ #undef HAVE_CLOCK_GETTIME #endif /* _WIN32 && ! __CYGWIN__ && HAVE_CLOCK_GETTIME */ #ifdef HAVE_CLOCK_GETTIME #include #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_GETHRTIME #ifdef HAVE_SYS_TIME_H /* Solaris defines gethrtime() in sys/time.h */ #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H /* HP-UX defines gethrtime() in time.h */ #include #endif /* HAVE_TIME_H */ #endif /* HAVE_GETHRTIME */ #ifdef HAVE_CLOCK_GET_TIME #include /* for host_get_clock_service(), mach_host_self(), mach_task_self() */ #include /* for clock_get_time() */ #define _MHD_INVALID_CLOCK_SERV ((clock_serv_t) -2) static clock_serv_t mono_clock_service = _MHD_INVALID_CLOCK_SERV; #endif /* HAVE_CLOCK_GET_TIME */ #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN /* Do not include unneeded parts of W32 headers. */ #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #include #endif /* _WIN32 */ #ifdef HAVE_CLOCK_GETTIME #ifdef CLOCK_REALTIME #define _MHD_UNWANTED_CLOCK CLOCK_REALTIME #else /* !CLOCK_REALTIME */ #define _MHD_UNWANTED_CLOCK ((clockid_t) -2) #endif /* !CLOCK_REALTIME */ static clockid_t mono_clock_id = _MHD_UNWANTED_CLOCK; #endif /* HAVE_CLOCK_GETTIME */ /* sync clocks; reduce chance of value wrap */ #if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_CLOCK_GET_TIME) || \ defined(HAVE_GETHRTIME) static time_t mono_clock_start; #endif /* HAVE_CLOCK_GETTIME || HAVE_CLOCK_GET_TIME || HAVE_GETHRTIME */ static time_t sys_clock_start; #ifdef HAVE_GETHRTIME static hrtime_t hrtime_start; #endif /* HAVE_GETHRTIME */ #ifdef _WIN32 #if _WIN32_WINNT >= 0x0600 static uint64_t tick_start; #else /* _WIN32_WINNT < 0x0600 */ static int64_t perf_freq; static int64_t perf_start; #endif /* _WIN32_WINNT < 0x0600 */ #endif /* _WIN32 */ /** * Type of monotonic clock source */ enum _MHD_mono_clock_source { /** * No monotonic clock */ _MHD_CLOCK_NO_SOURCE = 0, /** * clock_gettime() with specific clock */ _MHD_CLOCK_GETTIME, /** * clock_get_time() with specific clock service */ _MHD_CLOCK_GET_TIME, /** * gethrtime() / 1000000000 */ _MHD_CLOCK_GETHRTIME, /** * GetTickCount64() / 1000 */ _MHD_CLOCK_GETTICKCOUNT64, /** * QueryPerformanceCounter() / QueryPerformanceFrequency() */ _MHD_CLOCK_PERFCOUNTER }; /** * Initialise monotonic seconds counter. */ void MHD_monotonic_sec_counter_init (void) { #ifdef HAVE_CLOCK_GET_TIME mach_timespec_t cur_time; #endif /* HAVE_CLOCK_GET_TIME */ enum _MHD_mono_clock_source mono_clock_source = _MHD_CLOCK_NO_SOURCE; #ifdef HAVE_CLOCK_GETTIME struct timespec ts; mono_clock_id = _MHD_UNWANTED_CLOCK; #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_CLOCK_GET_TIME mono_clock_service = _MHD_INVALID_CLOCK_SERV; #endif /* HAVE_CLOCK_GET_TIME */ /* just a little syntactic trick to get the various following ifdef's to work out nicely */ if (0) { } else #ifdef HAVE_CLOCK_GETTIME #ifdef CLOCK_MONOTONIC_COARSE /* Linux-specific fast value-getting clock */ /* Can be affected by frequency adjustment and don't count time in suspend, */ /* but preferred since it's fast */ if (0 == clock_gettime (CLOCK_MONOTONIC_COARSE, &ts)) { mono_clock_id = CLOCK_MONOTONIC_COARSE; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_MONOTONIC_COARSE */ #ifdef CLOCK_MONOTONIC_FAST /* FreeBSD/DragonFly fast value-getting clock */ /* Can be affected by frequency adjustment, but preferred since it's fast */ if (0 == clock_gettime (CLOCK_MONOTONIC_FAST, &ts)) { mono_clock_id = CLOCK_MONOTONIC_FAST; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_MONOTONIC_COARSE */ #ifdef CLOCK_MONOTONIC_RAW /* Linux-specific clock */ /* Not affected by frequency adjustment, but don't count time in suspend */ if (0 == clock_gettime (CLOCK_MONOTONIC_RAW, &ts)) { mono_clock_id = CLOCK_MONOTONIC_RAW; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_MONOTONIC_RAW */ #ifdef CLOCK_BOOTTIME /* Linux-specific clock */ /* Count time in suspend so it's real monotonic on Linux, */ /* but can be slower value-getting than other clocks */ if (0 == clock_gettime (CLOCK_BOOTTIME, &ts)) { mono_clock_id = CLOCK_BOOTTIME; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_BOOTTIME */ #ifdef CLOCK_MONOTONIC /* Monotonic clock */ /* Widely supported, may be affected by frequency adjustment */ /* On Linux it's not truly monotonic as it doesn't count time in suspend */ if (0 == clock_gettime (CLOCK_MONOTONIC, &ts)) { mono_clock_id = CLOCK_MONOTONIC; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_BOOTTIME */ #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_CLOCK_GET_TIME /* Darwin-specific monotonic clock */ /* Should be monotonic as clock_set_time function always unconditionally */ /* failed on latest kernels */ if ( (KERN_SUCCESS == host_get_clock_service (mach_host_self (), SYSTEM_CLOCK, &mono_clock_service)) && (KERN_SUCCESS == clock_get_time (mono_clock_service, &cur_time)) ) { mono_clock_start = cur_time.tv_sec; mono_clock_source = _MHD_CLOCK_GET_TIME; } else #endif /* HAVE_CLOCK_GET_TIME */ #ifdef _WIN32 #if _WIN32_WINNT >= 0x0600 /* W32 Vista or later specific monotonic clock */ /* Available since Vista, ~15ms accuracy */ if (1) { tick_start = GetTickCount64 (); mono_clock_source = _MHD_CLOCK_GETTICKCOUNT64; } else #else /* _WIN32_WINNT < 0x0600 */ /* W32 specific monotonic clock */ /* Available on Windows 2000 and later */ if (1) { LARGE_INTEGER freq; LARGE_INTEGER perf_counter; QueryPerformanceFrequency (&freq); /* never fail on XP and later */ QueryPerformanceCounter (&perf_counter); /* never fail on XP and later */ perf_freq = freq.QuadPart; perf_start = perf_counter.QuadPart; mono_clock_source = _MHD_CLOCK_PERFCOUNTER; } else #endif /* _WIN32_WINNT < 0x0600 */ #endif /* _WIN32 */ #ifdef HAVE_CLOCK_GETTIME #ifdef CLOCK_HIGHRES /* Solaris-specific monotonic high-resolution clock */ /* Not preferred due to be potentially resource-hungry */ if (0 == clock_gettime (CLOCK_HIGHRES, &ts)) { mono_clock_id = CLOCK_HIGHRES; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_HIGHRES */ #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_GETHRTIME /* HP-UX and Solaris monotonic clock */ /* Not preferred due to be potentially resource-hungry */ if (1) { hrtime_start = gethrtime (); mono_clock_source = _MHD_CLOCK_GETHRTIME; } else #endif /* HAVE_GETHRTIME */ { /* no suitable clock source was found */ mono_clock_source = _MHD_CLOCK_NO_SOURCE; } #ifdef HAVE_CLOCK_GET_TIME if ( (_MHD_CLOCK_GET_TIME != mono_clock_source) && (_MHD_INVALID_CLOCK_SERV != mono_clock_service) ) { /* clock service was initialised but clock_get_time failed */ mach_port_deallocate (mach_task_self (), mono_clock_service); mono_clock_service = _MHD_INVALID_CLOCK_SERV; } #else (void) mono_clock_source; /* avoid compiler warning */ #endif /* HAVE_CLOCK_GET_TIME */ sys_clock_start = time (NULL); } /** * Deinitialise monotonic seconds counter by freeing any allocated resources */ void MHD_monotonic_sec_counter_finish (void) { #ifdef HAVE_CLOCK_GET_TIME if (_MHD_INVALID_CLOCK_SERV != mono_clock_service) { mach_port_deallocate (mach_task_self (), mono_clock_service); mono_clock_service = _MHD_INVALID_CLOCK_SERV; } #endif /* HAVE_CLOCK_GET_TIME */ } /** * Monotonic seconds counter, useful for timeout calculation. * Tries to be not affected by manually setting the system real time * clock or adjustments by NTP synchronization. * * @return number of seconds from some fixed moment */ time_t MHD_monotonic_sec_counter (void) { #ifdef HAVE_CLOCK_GETTIME struct timespec ts; if ( (_MHD_UNWANTED_CLOCK != mono_clock_id) && (0 == clock_gettime (mono_clock_id, &ts)) ) return ts.tv_sec - mono_clock_start; #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_CLOCK_GET_TIME if (_MHD_INVALID_CLOCK_SERV != mono_clock_service) { mach_timespec_t cur_time; if (KERN_SUCCESS == clock_get_time (mono_clock_service, &cur_time)) return cur_time.tv_sec - mono_clock_start; } #endif /* HAVE_CLOCK_GET_TIME */ #if defined(_WIN32) #if _WIN32_WINNT >= 0x0600 if (1) return (time_t) (((uint64_t) (GetTickCount64 () - tick_start)) / 1000); #else /* _WIN32_WINNT < 0x0600 */ if (0 != perf_freq) { LARGE_INTEGER perf_counter; QueryPerformanceCounter (&perf_counter); /* never fail on XP and later */ return (time_t) (((uint64_t) (perf_counter.QuadPart - perf_start)) / perf_freq); } #endif /* _WIN32_WINNT < 0x0600 */ #endif /* _WIN32 */ #ifdef HAVE_GETHRTIME if (1) return (time_t) (((uint64_t) (gethrtime () - hrtime_start)) / 1000000000); #endif /* HAVE_GETHRTIME */ return time (NULL) - sys_clock_start; } libmicrohttpd-1.0.1/src/lib/tsearch.h0000644000175000017500000000131514417460232013200 /*- * Written by J.T. Conklin * Public domain. * * $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ * $FreeBSD: release/9.0.0/include/search.h 105250 2002-10-16 14:29:23Z robert $ */ #ifndef _TSEARCH_H_ #define _TSEARCH_H_ #if defined(__cplusplus) extern "C" { #endif /* __cplusplus */ void * tdelete (const void *__restrict, void **__restrict, int (*)(const void *, const void *)); void * tfind (const void *, void *const *, int (*)(const void *, const void *)); void * tsearch (const void *, void **, int (*)(const void *, const void *)); #if defined(__cplusplus) }; #endif /* __cplusplus */ #endif /* !_TSEARCH_H_ */ libmicrohttpd-1.0.1/src/lib/daemon_poll.c0000644000175000017500000003655014417460232014044 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_poll.c * @brief functions to run poll-based event loop * @author Christian Grothoff */ #include "internal.h" #include "connection_add.h" #include "connection_call_handlers.h" #include "connection_finish_forward.h" #include "daemon_poll.h" #include "upgrade_process.h" #include "request_resume.h" #ifdef HAVE_POLL #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Set required 'event' members in 'pollfd' elements, * assuming that @a p[0].fd is MHD side of socketpair * and @a p[1].fd is TLS connected socket. * * @param urh upgrade handle to watch for * @param p pollfd array to update */ static void urh_update_pollfd (struct MHD_UpgradeResponseHandle *urh, struct pollfd p[2]) { p[0].events = 0; p[1].events = 0; if (urh->in_buffer_used < urh->in_buffer_size) p[0].events |= POLLIN; if (0 != urh->out_buffer_used) p[0].events |= POLLOUT; /* Do not monitor again for errors if error was detected before as * error state is remembered. */ if ((0 == (urh->app.celi & MHD_EPOLL_STATE_ERROR)) && ((0 != urh->in_buffer_size) || (0 != urh->out_buffer_size) || (0 != urh->out_buffer_used))) p[0].events |= MHD_POLL_EVENTS_ERR_DISC; if (urh->out_buffer_used < urh->out_buffer_size) p[1].events |= POLLIN; if (0 != urh->in_buffer_used) p[1].events |= POLLOUT; /* Do not monitor again for errors if error was detected before as * error state is remembered. */ if ((0 == (urh->mhd.celi & MHD_EPOLL_STATE_ERROR)) && ((0 != urh->out_buffer_size) || (0 != urh->in_buffer_size) || (0 != urh->in_buffer_used))) p[1].events |= MHD_POLL_EVENTS_ERR_DISC; } /** * Set @a p to watch for @a urh. * * @param urh upgrade handle to watch for * @param p pollfd array to set */ static void urh_to_pollfd (struct MHD_UpgradeResponseHandle *urh, struct pollfd p[2]) { p[0].fd = urh->connection->socket_fd; p[1].fd = urh->mhd.socket; urh_update_pollfd (urh, p); } /** * Update ready state in @a urh based on pollfd. * @param urh upgrade handle to update * @param p 'poll()' processed pollfd. */ static void urh_from_pollfd (struct MHD_UpgradeResponseHandle *urh, struct pollfd p[2]) { /* Reset read/write ready, preserve error state. */ urh->app.celi &= (~MHD_EPOLL_STATE_READ_READY & ~MHD_EPOLL_STATE_WRITE_READY); urh->mhd.celi &= (~MHD_EPOLL_STATE_READ_READY & ~MHD_EPOLL_STATE_WRITE_READY); if (0 != (p[0].revents & POLLIN)) urh->app.celi |= MHD_EPOLL_STATE_READ_READY; if (0 != (p[0].revents & POLLOUT)) urh->app.celi |= MHD_EPOLL_STATE_WRITE_READY; if (0 != (p[0].revents & POLLHUP)) urh->app.celi |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY; if (0 != (p[0].revents & MHD_POLL_REVENTS_ERRROR)) urh->app.celi |= MHD_EPOLL_STATE_ERROR; if (0 != (p[1].revents & POLLIN)) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; if (0 != (p[1].revents & POLLOUT)) urh->mhd.celi |= MHD_EPOLL_STATE_WRITE_READY; if (0 != (p[1].revents & POLLHUP)) urh->mhd.celi |= MHD_EPOLL_STATE_ERROR; if (0 != (p[1].revents & MHD_POLL_REVENTS_ERRROR)) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /** * Process all of our connections and possibly the server * socket using poll(). * * @param daemon daemon to run poll loop for * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_poll_all_ (struct MHD_Daemon *daemon, bool may_block) { unsigned int num_connections; struct MHD_Connection *pos; struct MHD_Connection *prev; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) struct MHD_UpgradeResponseHandle *urh; struct MHD_UpgradeResponseHandle *urhn; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if ( (! daemon->disallow_suspend_resume) && (MHD_resume_suspended_connections_ (daemon)) ) may_block = false; /* count number of connections and thus determine poll set size */ num_connections = 0; for (pos = daemon->connections_head; NULL != pos; pos = pos->next) num_connections++; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) for (urh = daemon->urh_head; NULL != urh; urh = urh->next) num_connections += 2; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ { MHD_UNSIGNED_LONG_LONG ltimeout; unsigned int i; int timeout; unsigned int poll_server; int poll_listen; int poll_itc_idx; struct pollfd *p; MHD_socket ls; p = MHD_calloc_ ((2 + num_connections), sizeof (struct pollfd)); if (NULL == p) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_POLL_MALLOC_FAILURE, _ ("Error allocating memory: %s\n"), MHD_strerror_ (errno)); #endif return MHD_SC_POLL_MALLOC_FAILURE; } poll_server = 0; poll_listen = -1; if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_socket)) && (! daemon->was_quiesced) && (daemon->connections < daemon->global_connection_limit) && (! daemon->at_limit) ) { /* only listen if we are not at the connection limit */ p[poll_server].fd = ls; p[poll_server].events = POLLIN; p[poll_server].revents = 0; poll_listen = (int) poll_server; poll_server++; } poll_itc_idx = -1; if (MHD_ITC_IS_VALID_ (daemon->itc)) { p[poll_server].fd = MHD_itc_r_fd_ (daemon->itc); p[poll_server].events = POLLIN; p[poll_server].revents = 0; poll_itc_idx = (int) poll_server; poll_server++; } if (! may_block) timeout = 0; else if ( (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) || (MHD_SC_OK != /* FIXME: distinguish between NO_TIMEOUT and errors! */ MHD_daemon_get_timeout (daemon, <imeout)) ) timeout = -1; else timeout = (ltimeout > INT_MAX) ? INT_MAX : (int) ltimeout; i = 0; for (pos = daemon->connections_tail; NULL != pos; pos = pos->prev) { p[poll_server + i].fd = pos->socket_fd; switch (pos->request.event_loop_info) { case MHD_EVENT_LOOP_INFO_READ: p[poll_server + i].events |= POLLIN | MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_WRITE: p[poll_server + i].events |= POLLOUT | MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_BLOCK: p[poll_server + i].events |= MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_CLEANUP: timeout = 0; /* clean up "pos" immediately */ break; } i++; } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) for (urh = daemon->urh_tail; NULL != urh; urh = urh->prev) { urh_to_pollfd (urh, &(p[poll_server + i])); i += 2; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if (0 == poll_server + num_connections) { free (p); return MHD_SC_OK; } if (MHD_sys_poll_ (p, poll_server + num_connections, timeout) < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) { free (p); return MHD_SC_OK; } #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_UNEXPECTED_POLL_ERROR, _ ("poll failed: %s\n"), MHD_socket_strerr_ (err)); #endif free (p); return MHD_SC_UNEXPECTED_POLL_ERROR; } /* Reset. New value will be set when connections are processed. */ daemon->data_already_pending = false; /* handle ITC FD */ /* do it before any other processing so new signals will be processed in next loop */ if ( (-1 != poll_itc_idx) && (0 != (p[poll_itc_idx].revents & POLLIN)) ) MHD_itc_clear_ (daemon->itc); /* handle shutdown */ if (daemon->shutdown) { free (p); return MHD_SC_DAEMON_ALREADY_SHUTDOWN; } i = 0; prev = daemon->connections_tail; while (NULL != (pos = prev)) { prev = pos->prev; /* first, sanity checks */ if (i >= num_connections) break; /* connection list changed somehow, retry later ... */ if (p[poll_server + i].fd != pos->socket_fd) continue; /* fd mismatch, something else happened, retry later ... */ MHD_connection_call_handlers_ (pos, 0 != (p[poll_server + i].revents & POLLIN), 0 != (p[poll_server + i].revents & POLLOUT), 0 != (p[poll_server + i].revents & MHD_POLL_REVENTS_ERR_DISC)); i++; } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) for (urh = daemon->urh_tail; NULL != urh; urh = urhn) { if (i >= num_connections) break; /* connection list changed somehow, retry later ... */ /* Get next connection here as connection can be removed * from 'daemon->urh_head' list. */ urhn = urh->prev; /* Check for fd mismatch. FIXME: required for safety? */ if ((p[poll_server + i].fd != urh->connection->socket_fd) || (p[poll_server + i + 1].fd != urh->mhd.socket)) break; urh_from_pollfd (urh, &p[poll_server + i]); i += 2; MHD_upgrade_response_handle_process_ (urh); /* Finished forwarding? */ if ( (0 == urh->in_buffer_size) && (0 == urh->out_buffer_size) && (0 == urh->in_buffer_used) && (0 == urh->out_buffer_used) ) { /* MHD_connection_finish_forward_() will remove connection from * 'daemon->urh_head' list. */ MHD_connection_finish_forward_ (urh->connection); urh->clean_ready = true; /* If 'urh->was_closed' already was set to true, connection will be * moved immediately to cleanup list. Otherwise connection * will stay in suspended list until 'urh' will be marked * with 'was_closed' by application. */ MHD_request_resume (&urh->connection->request); } } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /* handle 'listen' FD */ if ( (-1 != poll_listen) && (0 != (p[poll_listen].revents & POLLIN)) ) (void) MHD_accept_connection_ (daemon); free (p); } return MHD_SC_OK; } /** * Process only the listen socket using poll(). * * @param daemon daemon to run poll loop for * @param may_block true if blocking, false if non-blocking * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_poll_listen_socket_ (struct MHD_Daemon *daemon, bool may_block) { struct pollfd p[2]; int timeout; unsigned int poll_count; int poll_listen; int poll_itc_idx; MHD_socket ls; memset (&p, 0, sizeof (p)); poll_count = 0; poll_listen = -1; poll_itc_idx = -1; if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_socket)) && (! daemon->was_quiesced) ) { p[poll_count].fd = ls; p[poll_count].events = POLLIN; p[poll_count].revents = 0; poll_listen = poll_count; poll_count++; } if (MHD_ITC_IS_VALID_ (daemon->itc)) { p[poll_count].fd = MHD_itc_r_fd_ (daemon->itc); p[poll_count].events = POLLIN; p[poll_count].revents = 0; poll_itc_idx = poll_count; poll_count++; } if (! daemon->disallow_suspend_resume) (void) MHD_resume_suspended_connections_ (daemon); if (! may_block) timeout = 0; else timeout = -1; if (0 == poll_count) return MHD_SC_OK; if (MHD_sys_poll_ (p, poll_count, timeout) < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_SC_OK; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_UNEXPECTED_POLL_ERROR, _ ("poll failed: %s\n"), MHD_socket_strerr_ (err)); #endif return MHD_SC_UNEXPECTED_POLL_ERROR; } if ( (-1 != poll_itc_idx) && (0 != (p[poll_itc_idx].revents & POLLIN)) ) MHD_itc_clear_ (daemon->itc); /* handle shutdown */ if (daemon->shutdown) return MHD_SC_DAEMON_ALREADY_SHUTDOWN; if ( (-1 != poll_listen) && (0 != (p[poll_listen].revents & POLLIN)) ) (void) MHD_accept_connection_ (daemon); return MHD_SC_OK; } #endif /** * Do poll()-based processing. * * @param daemon daemon to run poll()-loop for * @param may_block true if blocking, false if non-blocking * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_poll_ (struct MHD_Daemon *daemon, bool may_block) { #ifdef HAVE_POLL if (daemon->shutdown) return MHD_SC_DAEMON_ALREADY_SHUTDOWN; if (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) return MHD_daemon_poll_all_ (daemon, may_block); return MHD_daemon_poll_listen_socket_ (daemon, may_block); #else /* This code should be dead, as we should have checked this earlier... */ return MHD_SC_POLL_NOT_SUPPORTED; #endif } #ifdef HAVE_POLL #ifdef HTTPS_SUPPORT /** * Process upgraded connection with a poll() loop. * We are in our own thread, only processing @a con * * @param con connection to process */ void MHD_daemon_upgrade_connection_with_poll_ (struct MHD_Connection *con) { struct MHD_UpgradeResponseHandle *urh = con->request.urh; struct pollfd p[2]; memset (p, 0, sizeof (p)); p[0].fd = urh->connection->socket_fd; p[1].fd = urh->mhd.socket; while ( (0 != urh->in_buffer_size) || (0 != urh->out_buffer_size) || (0 != urh->in_buffer_used) || (0 != urh->out_buffer_used) ) { int timeout; urh_update_pollfd (urh, p); if ( (con->tls_read_ready) && (urh->in_buffer_used < urh->in_buffer_size)) timeout = 0; /* No need to wait if incoming data is already pending in TLS buffers. */ else timeout = -1; if (MHD_sys_poll_ (p, 2, timeout) < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, MHD_SC_UNEXPECTED_POLL_ERROR, _ ("Error during poll: `%s'\n"), MHD_socket_strerr_ (err)); #endif break; } urh_from_pollfd (urh, p); MHD_upgrade_response_handle_process_ (urh); } } #endif #endif /* end of daemon_poll.c */ libmicrohttpd-1.0.1/src/lib/daemon_ip_limit.h0000644000175000017500000000402114417460232014675 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_ip_limit.h * @brief counting of connections per IP * @author Christian Grothoff */ #ifndef DAEMON_IP_LIMIT_H #define DAEMON_IP_LIMIT_H /** * Check if IP address is over its limit in terms of the number * of allowed concurrent connections. If the IP is still allowed, * increments the connection counter. * * @param daemon handle to daemon where connection counts are tracked * @param addr address to add (or increment counter) * @param addrlen number of bytes in @a addr * @return Return #MHD_YES if IP below limit, #MHD_NO if IP has surpassed limit. * Also returns #MHD_NO if fails to allocate memory. */ int MHD_ip_limit_add (struct MHD_Daemon *daemon, const struct sockaddr *addr, socklen_t addrlen) MHD_NONNULL (1,2); /** * Decrement connection count for IP address, removing from table * count reaches 0. * * @param daemon handle to daemon where connection counts are tracked * @param addr address to remove (or decrement counter) * @param addrlen number of bytes in @a addr */ void MHD_ip_limit_del (struct MHD_Daemon *daemon, const struct sockaddr *addr, socklen_t addrlen) MHD_NONNULL (1,2); #endif libmicrohttpd-1.0.1/src/lib/connection_close.h0000644000175000017500000000320614417460232015074 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_close.h * @brief functions to close connection * @author Christian Grothoff */ #ifndef CONNECTION_CLOSE_H #define CONNECTION_CLOSE_H #include "microhttpd2.h" /** * Mark connection as "closed". * * @remark To be called from any thread. * * @param connection connection to close */ void MHD_connection_mark_closed_ (struct MHD_Connection *connection) MHD_NONNULL (1); /** * Close the given connection and give the specified termination code * to the user. * * @remark To be called only from thread that process * connection's recv(), send() and response. * * @param connection connection to close * @param rtc termination reason to give */ void MHD_connection_close_ (struct MHD_Connection *connection, enum MHD_RequestTerminationCode rtc) MHD_NONNULL (1); #endif libmicrohttpd-1.0.1/src/lib/action_parse_post.c0000644000175000017500000000435614417460232015266 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/action_parse_post.c * @brief implementation of MHD_action_parse_post() * @author Christian Grothoff */ #include "internal.h" /** * Create an action that parses a POST request. * * This action can be used to (incrementally) parse the data portion * of a POST request. Note that some buggy browsers fail to set the * encoding type. If you want to support those, you may have to call * #MHD_set_connection_value with the proper encoding type before * returning this action (if no supported encoding type is detected, * returning this action will cause a bad request to be returned to * the client). * * @param buffer_size maximum number of bytes to use for * internal buffering (used only for the parsing, * specifically the parsing of the keys). A * tiny value (256-1024) should be sufficient. * Do NOT use a value smaller than 256. For good * performance, use 32 or 64k (i.e. 65536). * @param iter iterator to be called with the parsed data, * Must NOT be NULL. * @param iter_cls first argument to @a iter * @return NULL on error (out of memory, unsupported encoding), * otherwise a PP handle * @ingroup request */ const struct MHD_Action * MHD_action_parse_post (size_t buffer_size, MHD_PostDataIterator iter, void *iter_cls) { return NULL; /* not yet implemented */ } /* end of action_parse_post.c */ libmicrohttpd-1.0.1/src/lib/memorypool.h0000644000175000017500000000741014417460232013753 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file memorypool.h * @brief memory pool; mostly used for efficient (de)allocation * for each connection and bounding memory use for each * request * @author Christian Grothoff */ #ifndef MEMORYPOOL_H #define MEMORYPOOL_H #include "internal.h" /** * Opaque handle for a memory pool. * Pools are not reentrant and must not be used * by multiple threads. */ struct MemoryPool; /** * Create a memory pool. * * @param max maximum size of the pool * @return NULL on error */ struct MemoryPool * MHD_pool_create (size_t max); /** * Destroy a memory pool. * * @param pool memory pool to destroy */ void MHD_pool_destroy (struct MemoryPool *pool); /** * Allocate size bytes from the pool. * * @param pool memory pool to use for the operation * @param size number of bytes to allocate * @param from_end allocate from end of pool (set to #MHD_YES); * use this for small, persistent allocations that * will never be reallocated * @return NULL if the pool cannot support size more * bytes */ void * MHD_pool_allocate (struct MemoryPool *pool, size_t size, int from_end); /** * Reallocate a block of memory obtained from the pool. * This is particularly efficient when growing or * shrinking the block that was last (re)allocated. * If the given block is not the most recently * (re)allocated block, the memory of the previous * allocation may be leaked until the pool is * destroyed (and copying the data maybe required). * * @param pool memory pool to use for the operation * @param old the existing block * @param old_size the size of the existing block * @param new_size the new size of the block * @return new address of the block, or * NULL if the pool cannot support new_size * bytes (old continues to be valid for old_size) */ void * MHD_pool_reallocate (struct MemoryPool *pool, void *old, size_t old_size, size_t new_size); /** * Check how much memory is left in the @a pool * * @param pool pool to check * @return number of bytes still available in @a pool */ size_t MHD_pool_get_free (struct MemoryPool *pool); /** * Clear all entries from the memory pool except * for @a keep of the given @a copy_bytes. The pointer * returned should be a buffer of @a new_size where * the first @a copy_bytes are from @a keep. * * @param pool memory pool to use for the operation * @param keep pointer to the entry to keep (maybe NULL) * @param copy_bytes how many bytes need to be kept at this address * @param new_size how many bytes should the allocation we return have? * (should be larger or equal to @a copy_bytes) * @return addr new address of @a keep (if it had to change) */ void * MHD_pool_reset (struct MemoryPool *pool, void *keep, size_t copy_bytes, size_t new_size); #endif libmicrohttpd-1.0.1/src/lib/sysfdsetsize.h0000644000175000017500000000222514417460232014307 /* This file is part of libmicrohttpd Copyright (C) 2015 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/sysfdsetsize.h * @brief Helper for obtaining FD_SETSIZE system default value * @author Karlson2k (Evgeny Grin) */ #ifndef SYSFDSETSIZE_H #define SYSFDSETSIZE_H 1 /** * Get system default value of FD_SETSIZE * @return system default value of FD_SETSIZE */ int get_system_fdsetsize_value (void); #endif /* !SYSFDSETSIZE_H */ libmicrohttpd-1.0.1/src/lib/connection_close.c0000644000175000017500000000615414417460232015074 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_close.c * @brief functions to close a connection * @author Christian Grothoff */ #include "internal.h" #include "connection_close.h" /** * Mark connection as "closed". * * @remark To be called from any thread. * * @param connection connection to close */ void MHD_connection_mark_closed_ (struct MHD_Connection *connection) { const struct MHD_Daemon *daemon = connection->daemon; connection->request.state = MHD_REQUEST_CLOSED; connection->request.event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; if (! daemon->enable_turbo) { #ifdef HTTPS_SUPPORT struct MHD_TLS_Plugin *tls; /* For TLS connection use shutdown of TLS layer * and do not shutdown TCP socket. This give more * chances to send TLS closure data to remote side. * Closure of TLS layer will be interpreted by * remote side as end of transmission. */if (NULL != (tls = daemon->tls_api)) { if (MHD_YES != tls->shutdown_connection (tls->cls, connection->tls_cs)) { (void) shutdown (connection->socket_fd, SHUT_WR); /* FIXME: log errors */ } } else /* Combined with next 'shutdown()'. */ #endif /* HTTPS_SUPPORT */ { (void) shutdown (connection->socket_fd, SHUT_WR); /* FIXME: log errors */ } } } /** * Close the given connection and give the specified termination code * to the user. * * @remark To be called only from thread that process * connection's recv(), send() and response. * * @param connection connection to close * @param rtc termination reason to give */ void MHD_connection_close_ (struct MHD_Connection *connection, enum MHD_RequestTerminationCode rtc) { struct MHD_Daemon *daemon = connection->daemon; struct MHD_Response *resp = connection->request.response; (void) rtc; // FIXME MHD_connection_mark_closed_ (connection); if (NULL != resp) { connection->request.response = NULL; MHD_response_queue_for_destroy (resp); } if (NULL != daemon->notify_connection_cb) daemon->notify_connection_cb (daemon->notify_connection_cb_cls, connection, MHD_CONNECTION_NOTIFY_CLOSED); } /* end of connection_close.c */ libmicrohttpd-1.0.1/src/lib/Makefile.am0000644000175000017500000001402514417460232013434 # This Makefile.am is in the public domain AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/lib AM_CFLAGS = $(HIDDEN_VISIBILITY_CFLAGS) # Call "libmicrohttpd2" for now, but only while under # development. Once we have 'compat' working, this should be changed! noinst_LTLIBRARIES = \ libmicrohttpd2.la noinst_DATA = MOSTLYCLEANFILES = if W32_SHARED_LIB_EXP W32_MHD_LIB_LDFLAGS = -Wl,--output-def,$(lt_cv_objdir)/libmicrohttpd2.def -XCClinker -static-libgcc noinst_DATA += $(lt_cv_objdir)/libmicrohttpd2.lib $(lt_cv_objdir)/libmicrohttpd2.def $(lt_cv_objdir)/libmicrohttpd2.exp MOSTLYCLEANFILES += $(lt_cv_objdir)/libmicrohttpd2.lib $(lt_cv_objdir)/libmicrohttpd2.def $(lt_cv_objdir)/libmicrohttpd2.exp $(lt_cv_objdir)/libmicrohttpd2.def: libmicrohttpd2.la $(lt_cv_objdir)/libmicrohttpd2.exp: $(lt_cv_objdir)/libmicrohttpd2.lib $(lt_cv_objdir)/libmicrohttpd2.lib: $(lt_cv_objdir)/libmicrohttpd2.def libmicrohttpd2.la $(libmicrohttpd2_la_OBJECTS) if USE_MS_LIB_TOOL @echo Creating $@ and libmicrohttpd2.exp by $(MS_LIB_TOOL)... && \ dll_name=`$(EGREP) -o dlname=\'.+\' libmicrohttpd2.la` && \ dll_name=$${dll_name#*\'} && dll_name=$${dll_name%\'} && test -n "$$dll_name" && \ echo Creating $$dll_name by $(MS_LIB_TOOL).. && cd "$(lt_cv_objdir)" && \ $(MS_LIB_TOOL) -def:libmicrohttpd2.def -name:$$dll_name -out:libmicrohttpd2.lib $(libmicrohttpd2_la_OBJECTS:.lo=.o) && cd .. else @echo Creating $@ and libmicrohttpd2.exp by $(DLLTOOL)... && \ dll_name=`$(EGREP) -o dlname=\'.+\' libmicrohttpd2.la` && \ dll_name=$${dll_name#*\'} && dll_name=$${dll_name%\'} && test -n "$$dll_name" && \ echo Creating $$dll_name by $(DLLTOOL).. && cd "$(lt_cv_objdir)" && \ $(DLLTOOL) -d ./libmicrohttpd2.def -D $$dll_name -l libmicrohttpd2.lib $(libmicrohttpd2_la_OBJECTS:.lo=.o) -e ./libmicrohttpd2.exp && cd .. &&\ echo Created libmicrohttpd2.exp and libmicrohttpd2.lib. endif else W32_MHD_LIB_LDFLAGS = endif if W32_STATIC_LIB noinst_DATA += $(lt_cv_objdir)/libmicrohttpd2-static.lib MOSTLYCLEANFILES += $(lt_cv_objdir)/libmicrohttpd2-static.lib $(lt_cv_objdir)/libmicrohttpd2-static.lib: libmicrohttpd2.la $(libmicrohttpd2_la_OBJECTS) if USE_MS_LIB_TOOL $(MS_LIB_TOOL) -out:$@ $(libmicrohttpd2_la_OBJECTS:.lo=.o) else cp $(lt_cv_objdir)/libmicrohttpd2.a $@ endif endif libmicrohttpd2_la_SOURCES = \ action_continue.c \ action_from_response.c \ action_parse_post.c \ action_process_upload.c \ action_suspend.c \ connection_add.c connection_add.h \ connection_call_handlers.c connection_call_handlers.h \ connection_cleanup.c connection_cleanup.h \ connection_close.c connection_close.h \ connection_finish_forward.c connection_finish_forward.h \ connection_info.c \ connection_options.c \ connection_update_last_activity.c connection_update_last_activity.h \ daemon_close_all_connections.c daemon_close_all_connections.h \ daemon_create.c \ daemon_destroy.c \ daemon_epoll.c daemon_epoll.h \ daemon_get_timeout.c \ daemon_info.c \ daemon_ip_limit.c daemon_ip_limit.h \ daemon_options.c \ daemon_poll.c daemon_poll.h \ daemon_run.c \ daemon_select.c daemon_select.h \ daemon_start.c \ daemon_quiesce.c \ init.c init.h \ internal.c internal.h \ memorypool.c memorypool.h \ mhd_assert.h \ mhd_byteorder.h \ mhd_compat.c mhd_compat.h \ mhd_itc.c mhd_itc.h mhd_itc_types.h \ mhd_limits.h \ mhd_locks.h \ mhd_mono_clock.c mhd_mono_clock.h \ mhd_str.c mhd_str.h \ mhd_sockets.c mhd_sockets.h \ mhd_threads.c mhd_threads.h \ response.c \ response_for_upgrade.c \ response_from_buffer.c \ response_from_callback.c \ response_from_fd.c \ response_options.c \ reason_phrase.c \ request.c \ request_info.c \ request_resume.c \ request_resume.h \ sysfdsetsize.c sysfdsetsize.h \ upgrade_process.c upgrade_process.h \ panic.c \ version.c libmicrohttpd2_la_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) \ -DBUILDING_MHD_LIB=1 libmicrohttpd2_la_CFLAGS = \ $(AM_CFLAGS) $(MHD_LIB_CFLAGS) $(MHD_TLS_LIB_CFLAGS) libmicrohttpd2_la_LDFLAGS = \ $(MHD_LIB_LDFLAGS) \ $(W32_MHD_LIB_LDFLAGS) $(MHD_TLS_LIB_LDFLAGS) \ -version-info 0:0:0 # FIXME: fix once closer to release... if MHD_HAVE_TLS_PLUGIN libmicrohttpd2_la_LDFLAGS += \ -ldl endif libmicrohttpd2_la_LIBADD = \ $(MHD_LIBDEPS) $(MHD_TLS_LIBDEPS) if HAVE_W32 MHD_DLL_RES_SRC = ../microhttpd/microhttpd_dll_res.rc MHD_DLL_RES_LO = libmicrohttpd2_la-$(MHD_DLL_RES_SRC:.rc=.lo) EXTRA_libmicrohttpd2_la_DEPENDENCIES = $(MHD_DLL_RES_LO) libmicrohttpd2_la_LIBADD += $(MHD_DLL_RES_LO) # General rule is not required, but keep it just in case .rc.lo: $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $< -o $@ # To add dll resource only to .dll file and exclude it form static # lib, a little trick was used. Allow libtool to create file.lo, # file.o and .libs/file.lo, .libs/file.o files, then overwrite file.o # by empty object generated from empty c-file. Later libtool will # use .libs/file.o for shared lib and empty file.o for static lib. # This implementation is based on trick found in liblzma. # Note: windres does not understand '-isystem' flag, so all # possible '-isystem' flags are replaced by simple '-I' flags. $(MHD_DLL_RES_LO): $(MHD_DLL_RES_SRC) RC_CPP_FLAGS=" $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) " && \ $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $${RC_CPP_FLAGS// -isystem / -I } $< -o $@ && \ echo > $@-empty.c && $(CC) $(AM_CFLAGS) $(CFLAGS) -c $@-empty.c -o $(@:.lo=.o) && rm -f $@-empty.c endif if USE_COVERAGE AM_CFLAGS += --coverage endif if !MHD_USE_SYS_TSEARCH libmicrohttpd2_la_SOURCES += \ tsearch.c tsearch.h endif # TBD! if HAVE_POSTPROCESSOR #libmicrohttpd2_la_SOURCES += \ # postprocessor.c endif # TBD! if ENABLE_DAUTH #libmicrohttpd2_la_SOURCES += \ # digestauth.c \ # md5.c md5.h endif # TBD! if ENABLE_BAUTH #libmicrohttpd2_la_SOURCES += \ # basicauth.c \ # base64.c base64.h endif libmicrohttpd-1.0.1/src/lib/daemon_info.c0000644000175000017500000000671214417460232014026 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_info.c * @brief implementation of MHD_daemon_get_information_sz() * @author Christian Grothoff */ #include "internal.h" #include "connection_cleanup.h" /** * Obtain information about the given daemon. * Use wrapper macro #MHD_daemon_get_information() instead of direct use * of this function. * * @param daemon what daemon to get information about * @param info_type what information is desired? * @param[out] return_value pointer to union where requested information will * be stored * @param return_value_size size of union MHD_DaemonInformation at compile * time * @return #MHD_YES on success, #MHD_NO on error * (@a info_type is unknown, NULL pointer etc.) * @ingroup specialized */ enum MHD_Bool MHD_daemon_get_information_sz (struct MHD_Daemon *daemon, enum MHD_DaemonInformationType info_type, union MHD_DaemonInformation *return_value, size_t return_value_size) { #define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \ return MHD_NO switch (info_type) { case MHD_DAEMON_INFORMATION_LISTEN_SOCKET: CHECK_SIZE (MHD_socket); return_value->listen_socket = daemon->listen_socket; return MHD_YES; #ifdef EPOLL_SUPPORT case MHD_DAEMON_INFORMATION_EPOLL_FD: CHECK_SIZE (int); // FIXME: maybe return MHD_NO if we are not using EPOLL? return_value->epoll_fd = daemon->epoll_fd; return MHD_YES; #endif case MHD_DAEMON_INFORMATION_CURRENT_CONNECTIONS: CHECK_SIZE (unsigned int); if (MHD_TM_EXTERNAL_EVENT_LOOP == daemon->threading_mode) { /* Assumes that MHD_run() in not called in other thread (of the application) at the same time. */ MHD_connection_cleanup_ (daemon); return_value->num_connections = daemon->connections; } else if (daemon->worker_pool) { unsigned int i; /* Collect the connection information stored in the workers. */ return_value->num_connections = 0; for (i = 0; i < daemon->worker_pool_size; i++) { /* FIXME: next line is thread-safe only if read is atomic. */ return_value->num_connections += daemon->worker_pool[i].connections; } } else return_value->num_connections = daemon->connections; return MHD_YES; case MHD_DAEMON_INFORMATION_BIND_PORT: CHECK_SIZE (uint16_t); // FIXME: return MHD_NO if port is not known/UNIX? return_value->port = daemon->listen_port; return MHD_YES; default: return MHD_NO; } #undef CHECK_SIZE } /* end of daemon_info.c */ libmicrohttpd-1.0.1/src/lib/daemon_options.c0000644000175000017500000005504714441373361014576 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_options.c * @brief boring functions to manipulate daemon options * @author Christian Grothoff */ #include "internal.h" #ifdef HAVE_DLFCN_H #include #endif /** * Set logging method. Specify NULL to disable logging entirely. By * default (if this option is not given), we log error messages to * stderr. * * @param daemon which instance to setup logging for * @param logger function to invoke * @param logger_cls closure for @a logger */ void MHD_daemon_set_logger (struct MHD_Daemon *daemon, MHD_LoggingCallback logger, void *logger_cls) { daemon->logger = logger; daemon->logger_cls = logger_cls; } /** * Suppress use of "Date" header as this system has no RTC. * * @param daemon which instance to disable clock for. */ void MHD_daemon_suppress_date_no_clock (struct MHD_Daemon *daemon) { daemon->suppress_date = true; } /** * Disable use of inter-thread communication channel. * #MHD_daemon_disable_itc() can be used with * #MHD_daemon_thread_internal() to perform some additional * optimizations (in particular, not creating a pipe for IPC * signalling). If it is used, certain functions like * #MHD_daemon_quiesce() or #MHD_connection_add() or * #MHD_action_suspend() cannot be used anymore. * #MHD_daemon_disable_itc() is not beneficial on platforms where * select()/poll()/other signal shutdown() of a listen socket. * * You should only use this function if you are sure you do * satisfy all of its requirements and need a generally minor * boost in performance. * * @param daemon which instance to disable itc for */ void MHD_daemon_disable_itc (struct MHD_Daemon *daemon) { daemon->disable_itc = true; } /** * Enable `turbo`. Disables certain calls to `shutdown()`, * enables aggressive non-blocking optimistic reads and * other potentially unsafe optimizations. * Most effects only happen with #MHD_ELS_EPOLL. * * @param daemon which instance to enable turbo for */ void MHD_daemon_enable_turbo (struct MHD_Daemon *daemon) { daemon->enable_turbo = true; } /** * Disable #MHD_action_suspend() functionality. * * You should only use this function if you are sure you do * satisfy all of its requirements and need a generally minor * boost in performance. * * @param daemon which instance to disable suspend for */ void MHD_daemon_disallow_suspend_resume (struct MHD_Daemon *daemon) { daemon->disallow_suspend_resume = true; } /** * You need to set this option if you want to disable use of HTTP "Upgrade". * "Upgrade" may require usage of additional internal resources, * which we can avoid providing if they will not be used. * * You should only use this function if you are sure you do * satisfy all of its requirements and need a generally minor * boost in performance. * * @param daemon which instance to enable suspend/resume for */ void MHD_daemon_disallow_upgrade (struct MHD_Daemon *daemon) { daemon->disallow_upgrade = true; } /** * Configure TCP_FASTOPEN option, including setting a * custom @a queue_length. * * Note that having a larger queue size can cause resource exhaustion * attack as the TCP stack has to now allocate resources for the SYN * packet along with its DATA. * * @param daemon which instance to configure TCP_FASTOPEN for * @param fom under which conditions should we use TCP_FASTOPEN? * @param queue_length queue length to use, default is 50 if this * option is never given. * @return #MHD_YES upon success, #MHD_NO if #MHD_FOM_REQUIRE was * given, but TCP_FASTOPEN is not available on the platform */ enum MHD_Bool MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon, enum MHD_FastOpenMethod fom, unsigned int queue_length) { daemon->fast_open_method = fom; daemon->fo_queue_length = queue_length; switch (fom) { case MHD_FOM_DISABLE: return MHD_YES; case MHD_FOM_AUTO: return MHD_YES; case MHD_FOM_REQUIRE: #ifdef TCP_FASTOPEN return MHD_YES; #else return MHD_NO; #endif } return MHD_NO; } /** * Bind to the given TCP port and address family. * * Ineffective in conjunction with #MHD_daemon_listen_socket(). * Ineffective in conjunction with #MHD_daemon_bind_sa(). * * If neither this option nor the other two mentioned above * is specified, MHD will simply not listen on any socket! * * @param daemon which instance to configure the TCP port for * @param af address family to use * @param port port to use, 0 to bind to a random (free) port */ void MHD_daemon_bind_port (struct MHD_Daemon *daemon, enum MHD_AddressFamily af, uint16_t port) { daemon->listen_af = af; daemon->listen_port = port; } /** * Bind to the given socket address. * Ineffective in conjunction with #MHD_daemon_listen_socket(). * * @param daemon which instance to configure the binding address for * @param sa address to bind to; can be IPv4 (AF_INET), IPv6 (AF_INET6) * or even a UNIX domain socket (AF_UNIX) * @param sa_len number of bytes in @a sa */ void MHD_daemon_bind_socket_address (struct MHD_Daemon *daemon, const struct sockaddr *sa, size_t sa_len) { memcpy (&daemon->listen_sa, sa, sa_len); daemon->listen_sa_len = sa_len; } /** * Use the given backlog for the listen() call. * Ineffective in conjunction with #MHD_daemon_listen_socket(). * * @param daemon which instance to configure the backlog for * @param listen_backlog backlog to use */ void MHD_daemon_listen_backlog (struct MHD_Daemon *daemon, int listen_backlog) { daemon->listen_backlog = listen_backlog; } /** * If present true, allow reusing address:port socket (by using * SO_REUSEPORT on most platform, or platform-specific ways). If * present and set to false, disallow reusing address:port socket * (does nothing on most platform, but uses SO_EXCLUSIVEADDRUSE on * Windows). * Ineffective in conjunction with #MHD_daemon_listen_socket(). * * @param daemon daemon to configure address reuse for */ void MHD_daemon_listen_allow_address_reuse (struct MHD_Daemon *daemon) { daemon->allow_address_reuse = true; } /** * Use SHOUTcast. This will cause the response to begin * with the SHOUTcast "ICY" line instead of "HTTP". * * @param daemon daemon to set SHOUTcast option for */ _MHD_EXTERN void MHD_daemon_enable_shoutcast (struct MHD_Daemon *daemon) { daemon->enable_shoutcast = true; } /** * Accept connections from the given socket. Socket * must be a TCP or UNIX domain (stream) socket. * * Unless -1 is given, this disables other listen options, including * #MHD_daemon_bind_sa(), #MHD_daemon_bind_port(), * #MHD_daemon_listen_queue() and * #MHD_daemon_listen_allow_address_reuse(). * * @param daemon daemon to set listen socket for * @param listen_socket listen socket to use, * MHD_INVALID_SOCKET value will cause this call to be * ignored (other binding options may still be effective) */ void MHD_daemon_listen_socket (struct MHD_Daemon *daemon, MHD_socket listen_socket) { daemon->listen_socket = listen_socket; } /** * Force use of a particular event loop system call. * * @param daemon daemon to set event loop style for * @param els event loop syscall to use * @return #MHD_NO on failure, #MHD_YES on success */ enum MHD_Bool MHD_daemon_event_loop (struct MHD_Daemon *daemon, enum MHD_EventLoopSyscall els) { switch (els) { case MHD_ELS_AUTO: break; /* should always be OK */ case MHD_ELS_SELECT: break; /* should always be OK */ case MHD_ELS_POLL: #ifdef HAVE_POLL break; #else return MHD_NO; /* not supported */ #endif case MHD_ELS_EPOLL: #ifdef EPOLL_SUPPORT break; #else return MHD_NO; /* not supported */ #endif default: return MHD_NO; /* not supported (presumably future ABI extension) */ } daemon->event_loop_syscall = els; return MHD_YES; } /** * Set how strictly MHD will enforce the HTTP protocol. * * @param daemon daemon to configure strictness for * @param sl how strict should we be */ void MHD_daemon_protocol_strict_level (struct MHD_Daemon *daemon, enum MHD_ProtocolStrictLevel sl) { daemon->protocol_strict_level = sl; } /** * Enable and configure TLS. * * @param daemon which instance should be configured * @param tls_backend which TLS backend should be used, * currently only "gnutls" is supported. You can * also specify NULL for best-available (which is the default). * @param ciphers which ciphers should be used by TLS, default is * "NORMAL" * @return status code, #MHD_SC_OK upon success * #MHD_TLS_BACKEND_UNSUPPORTED if the @a backend is unknown * #MHD_TLS_DISABLED if this build of MHD does not support TLS * #MHD_TLS_CIPHERS_INVALID if the given @a ciphers are not supported * by this backend */ enum MHD_StatusCode MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon, const char *tls_backend, const char *ciphers) { #if ! (defined(HTTPS_SUPPORT) && defined (HAVE_DLFCN_H)) return MHD_SC_TLS_DISABLED; #else char filename[1024]; int res; MHD_TLS_PluginInit init; /* todo: .dll on W32? */ res = MHD_snprintf_ (filename, sizeof (filename), "%s/libmicrohttpd_tls_%s.so", MHD_PLUGIN_INSTALL_PREFIX, tls_backend); if (0 >= res) return MHD_SC_TLS_BACKEND_UNSUPPORTED; /* string too long? */ if (NULL == (daemon->tls_backend_lib = dlopen (filename, RTLD_NOW | RTLD_LOCAL))) return MHD_SC_TLS_BACKEND_UNSUPPORTED; /* plugin not found */ if (NULL == (init = dlsym (daemon->tls_backend_lib, "MHD_TLS_init_" MHD_TLS_ABI_VERSION_STR))) { dlclose (daemon->tls_backend_lib); daemon->tls_backend_lib = NULL; return MHD_SC_TLS_BACKEND_UNSUPPORTED; /* possibly wrong version installed */ } if (NULL == (daemon->tls_api = init (ciphers))) { dlclose (daemon->tls_backend_lib); daemon->tls_backend_lib = NULL; return MHD_SC_TLS_CIPHERS_INVALID; /* possibly wrong version installed */ } return MHD_SC_OK; #endif } /** * Provide TLS key and certificate data in-memory. * * @param daemon which instance should be configured * @param mem_key private key (key.pem) to be used by the * HTTPS daemon. Must be the actual data in-memory, not a filename. * @param mem_cert certificate (cert.pem) to be used by the * HTTPS daemon. Must be the actual data in-memory, not a filename. * @param pass passphrase phrase to decrypt 'key.pem', NULL * if @param mem_key is in cleartext already * @return #MHD_SC_OK upon success; MHD_BACKEND_UNINITIALIZED * if the TLS backend is not yet setup. */ enum MHD_StatusCode MHD_daemon_tls_key_and_cert_from_memory (struct MHD_Daemon *daemon, const char *mem_key, const char *mem_cert, const char *pass) { #ifndef HTTPS_SUPPORT return MHD_SC_TLS_DISABLED; #else struct MHD_TLS_Plugin *plugin; if (NULL == (plugin = daemon->tls_api)) return MHD_SC_TLS_BACKEND_UNINITIALIZED; return plugin->init_kcp (plugin->cls, mem_key, mem_cert, pass); #endif } /** * Configure DH parameters (dh.pem) to use for the TLS key * exchange. * * @param daemon daemon to configure tls for * @param dh parameters to use * @return #MHD_SC_OK upon success; MHD_BACKEND_UNINITIALIZED * if the TLS backend is not yet setup. */ enum MHD_StatusCode MHD_daemon_tls_mem_dhparams (struct MHD_Daemon *daemon, const char *dh) { #ifndef HTTPS_SUPPORT return MHD_SC_TLS_DISABLED; #else struct MHD_TLS_Plugin *plugin; if (NULL == (plugin = daemon->tls_api)) return MHD_SC_TLS_BACKEND_UNINITIALIZED; return plugin->init_dhparams (plugin->cls, dh); #endif } /** * Memory pointer for the certificate (ca.pem) to be used by the * HTTPS daemon for client authentication. * * @param daemon daemon to configure tls for * @param mem_trust memory pointer to the certificate * @return #MHD_SC_OK upon success; MHD_BACKEND_UNINITIALIZED * if the TLS backend is not yet setup. */ enum MHD_StatusCode MHD_daemon_tls_mem_trust (struct MHD_Daemon *daemon, const char *mem_trust) { #ifndef HTTPS_SUPPORT return MHD_SC_TLS_DISABLED; #else struct MHD_TLS_Plugin *plugin; if (NULL == (plugin = daemon->tls_api)) return MHD_SC_TLS_BACKEND_UNINITIALIZED; return plugin->init_mem_trust (plugin->cls, mem_trust); #endif } /** * Configure daemon credentials type for GnuTLS. * * @param gnutls_credentials must be a value of * type `gnutls_credentials_type_t` * @return #MHD_SC_OK upon success; TODO: define failure modes */ enum MHD_StatusCode MHD_daemon_gnutls_credentials (struct MHD_Daemon *daemon, int gnutls_credentials) { #ifndef HTTPS_SUPPORT return MHD_SC_TLS_DISABLED; #else struct MHD_TLS_Plugin *plugin; if (NULL == (plugin = daemon->tls_api)) return MHD_SC_TLS_BACKEND_UNINITIALIZED; return MHD_SC_TLS_BACKEND_OPERATION_UNSUPPORTED; #endif } /** * Provide TLS key and certificate data via callback. * * Use a callback to determine which X.509 certificate should be used * for a given HTTPS connection. This option provides an alternative * to #MHD_daemon_tls_key_and_cert_from_memory(). You must use this * version if multiple domains are to be hosted at the same IP address * using TLS's Server Name Indication (SNI) extension. In this case, * the callback is expected to select the correct certificate based on * the SNI information provided. The callback is expected to access * the SNI data using `gnutls_server_name_get()`. Using this option * requires GnuTLS 3.0 or higher. * * @param daemon daemon to configure callback for * @param cb must be of type `gnutls_certificate_retrieve_function2 *`. * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_gnutls_key_and_cert_from_callback (struct MHD_Daemon *daemon, void *cb) { #ifndef HTTPS_SUPPORT return MHD_SC_TLS_DISABLED; #else struct MHD_TLS_Plugin *plugin; if (NULL == (plugin = daemon->tls_api)) return MHD_SC_TLS_BACKEND_UNINITIALIZED; return MHD_SC_TLS_BACKEND_OPERATION_UNSUPPORTED; #endif } /** * Specify threading mode to use. * * @param daemon daemon to configure * @param tm mode to use (positive values indicate the * number of worker threads to be used) */ void MHD_daemon_threading_mode (struct MHD_Daemon *daemon, enum MHD_ThreadingMode tm) { daemon->threading_mode = tm; } /** * Set a policy callback that accepts/rejects connections * based on the client's IP address. This function will be called * before a connection object is created. * * @param daemon daemon to set policy for * @param apc function to call to check the policy * @param apc_cls closure for @a apc */ void MHD_daemon_accept_policy (struct MHD_Daemon *daemon, MHD_AcceptPolicyCallback apc, void *apc_cls) { daemon->accept_policy_cb = apc; daemon->accept_policy_cb_cls = apc_cls; } /** * Register a callback to be called first for every request * (before any parsing of the header). Makes it easy to * log the full URL. * * @param daemon daemon for which to set the logger * @param cb function to call * @param cb_cls closure for @a cb */ void MHD_daemon_set_early_uri_logger (struct MHD_Daemon *daemon, MHD_EarlyUriLogCallback cb, void *cb_cls) { daemon->early_uri_logger_cb = cb; daemon->early_uri_logger_cb_cls = cb_cls; } /** * Register a function that should be called whenever a connection is * started or closed. * * @param daemon daemon to set callback for * @param ncc function to call to check the policy * @param ncc_cls closure for @a apc */ void MHD_daemon_set_notify_connection (struct MHD_Daemon *daemon, MHD_NotifyConnectionCallback ncc, void *ncc_cls) { daemon->notify_connection_cb = ncc; daemon->notify_connection_cb_cls = ncc_cls; } /** * Maximum memory size per connection. * Default is 32 kb (#MHD_POOL_SIZE_DEFAULT). * Values above 128k are unlikely to result in much benefit, as half * of the memory will be typically used for IO, and TCP buffers are * unlikely to support window sizes above 64k on most systems. * * @param daemon daemon to configure * @param memory_limit_b connection memory limit to use in bytes * @param memory_increment_b increment to use when growing the read buffer, must be smaller than @a memory_limit_b */ void MHD_daemon_connection_memory_limit (struct MHD_Daemon *daemon, size_t memory_limit_b, size_t memory_increment_b) { if (memory_increment_b >= memory_limit_b) MHD_PANIC ("Sane memory increment must be below memory limit.\n"); daemon->connection_memory_limit_b = memory_limit_b; daemon->connection_memory_increment_b = memory_increment_b; } /** * Desired size of the stack for threads created by MHD. Use 0 for * system default. Only useful if the selected threading mode * is not #MHD_TM_EXTERNAL_EVENT_LOOP. * * @param daemon daemon to configure * @param stack_limit_b stack size to use in bytes */ void MHD_daemon_thread_stack_size (struct MHD_Daemon *daemon, size_t stack_limit_b) { daemon->thread_stack_limit_b = stack_limit_b; } /** * Set maximum number of concurrent connections to accept. If not * given, MHD will not enforce any limits (modulo running into * OS limits). Values of 0 mean no limit. * * @param daemon daemon to configure * @param global_connection_limit maximum number of (concurrent) connections * @param ip_connection_limit limit on the number of (concurrent) * connections made to the server from the same IP address. * Can be used to prevent one IP from taking over all of * the allowed connections. If the same IP tries to * establish more than the specified number of * connections, they will be immediately rejected. */ void MHD_daemon_connection_limits (struct MHD_Daemon *daemon, unsigned int global_connection_limit, unsigned int ip_connection_limit) { daemon->global_connection_limit = global_connection_limit; daemon->ip_connection_limit = ip_connection_limit; } /** * After how many seconds of inactivity should a * connection automatically be timed out? * Use zero for no timeout, which is also the (unsafe!) default. * * @param daemon daemon to configure * @param timeout_s number of seconds of timeout to use */ void MHD_daemon_connection_default_timeout (struct MHD_Daemon *daemon, unsigned int timeout_s) { daemon->connection_default_timeout = (time_t) timeout_s; } /** * Specify a function that should be called for unescaping escape * sequences in URIs and URI arguments. Note that this function * will NOT be used by the `struct MHD_PostProcessor`. If this * option is not specified, the default method will be used which * decodes escape sequences of the form "%HH". * * @param daemon daemon to configure * @param unescape_cb function to use, NULL for default * @param unescape_cb_cls closure for @a unescape_cb */ void MHD_daemon_unescape_cb (struct MHD_Daemon *daemon, MHD_UnescapeCallback unescape_cb, void *unescape_cb_cls) { daemon->unescape_cb = unescape_cb; daemon->unescape_cb_cls = unescape_cb_cls; } /** * Set random values to be used by the Digest Auth module. Note that * the application must ensure that @a buf remains allocated and * unmodified while the daemon is running. * * @param daemon daemon to configure * @param buf_size number of bytes in @a buf * @param buf entropy buffer */ void MHD_daemon_digest_auth_random (struct MHD_Daemon *daemon, size_t buf_size, const void *buf) { #if ENABLE_DAUTH daemon->digest_auth_random_buf = buf; daemon->digest_auth_random_buf_size = buf_size; #else (void) daemon; (void) buf_size; (void) buf; MHD_PANIC ("Digest authentication not supported by this build.\n"); #endif } /** * Length of the internal array holding the map of the nonce and * the nonce counter. * * @param daemon daemon to configure * @param nc_length desired array length */ enum MHD_StatusCode MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon, size_t nc_length) { #if ENABLE_DAUTH if ( ( (size_t) (nc_length * sizeof (struct MHD_NonceNc))) / sizeof (struct MHD_NonceNc) != nc_length) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Specified value for NC_SIZE too large.\n")); #endif return MHD_SC_DIGEST_AUTH_NC_LENGTH_TOO_BIG; } if (0 < nc_length) { if (NULL != daemon->nnc) free (daemon->nnc); daemon->nnc = malloc (daemon->nonce_nc_size * sizeof (struct MHD_NonceNc)); if (NULL == daemon->nnc) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to allocate memory for nonce-nc map: %s\n"), MHD_strerror_ (errno)); #endif return MHD_SC_DIGEST_AUTH_NC_ALLOCATION_FAILURE; } } daemon->digest_nc_length = nc_length; return MHD_SC_OK; #else (void) daemon; (void) nc_length; return MHD_SC_DIGEST_AUTH_NOT_SUPPORTED_BY_BUILD; #endif } /* end of daemon_options.c */ libmicrohttpd-1.0.1/src/lib/daemon_close_all_connections.c0000644000175000017500000001755514417460232017441 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_close_all_connections.c * @brief function to close all connections open at a daemon * @author Christian Grothoff */ #include "internal.h" #include "connection_cleanup.h" #include "connection_close.h" #include "connection_finish_forward.h" #include "daemon_close_all_connections.h" #include "request_resume.h" #include "upgrade_process.h" /** * Close the given connection, remove it from all of its * DLLs and move it into the cleanup queue. * @remark To be called only from thread that * process daemon's select()/poll()/etc. * * @param pos connection to move to cleanup */ static void close_connection (struct MHD_Connection *pos) { struct MHD_Daemon *daemon = pos->daemon; if (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) { MHD_connection_mark_closed_ (pos); return; /* must let thread to do the rest */ } MHD_connection_close_ (pos, MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); mhd_assert (! pos->suspended); mhd_assert (! pos->resuming); if (pos->connection_timeout == pos->daemon->connection_default_timeout) XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, pos); else XDLL_remove (daemon->manual_timeout_head, daemon->manual_timeout_tail, pos); DLL_remove (daemon->connections_head, daemon->connections_tail, pos); DLL_insert (daemon->cleanup_head, daemon->cleanup_tail, pos); MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } /** * Close all connections for the daemon. Must only be called when * MHD_Daemon::shutdown was set to true. * * @remark To be called only from thread that process daemon's * select()/poll()/etc. * * @param daemon daemon to close down */ void MHD_daemon_close_all_connections_ (struct MHD_Daemon *daemon) { struct MHD_Connection *pos; const bool used_thr_p_c = (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode); #ifdef UPGRADE_SUPPORT const bool upg_allowed = (! daemon->disallow_upgrade); #endif /* UPGRADE_SUPPORT */ #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) struct MHD_UpgradeResponseHandle *urh; struct MHD_UpgradeResponseHandle *urhn; const bool used_tls = (NULL != daemon->tls_api); mhd_assert (NULL == daemon->worker_pool); mhd_assert (daemon->shutdown); /* give upgraded HTTPS connections a chance to finish */ /* 'daemon->urh_head' is not used in thread-per-connection mode. */ for (urh = daemon->urh_tail; NULL != urh; urh = urhn) { urhn = urh->prev; /* call generic forwarding function for passing data with chance to detect that application is done. */ MHD_upgrade_response_handle_process_ (urh); MHD_connection_finish_forward_ (urh->connection); urh->clean_ready = true; /* Resuming will move connection to cleanup list. */ MHD_request_resume (&urh->connection->request); } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /* Give suspended connections a chance to resume to avoid running into the check for there not being any suspended connections left in case of a tight race with a recently resumed connection. */ if (! daemon->disallow_suspend_resume) { daemon->resuming = true; /* Force check for pending resume. */ MHD_resume_suspended_connections_ (daemon); } /* first, make sure all threads are aware of shutdown; need to traverse DLLs in peace... */ MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #ifdef UPGRADE_SUPPORT if (upg_allowed) { struct MHD_Connection *susp; susp = daemon->suspended_connections_tail; while (NULL != susp) { if (NULL == susp->request.urh) /* "Upgraded" connection? */ MHD_PANIC (_ ( "MHD_stop_daemon() called while we have suspended connections.\n")); #ifdef HTTPS_SUPPORT else if (used_tls && used_thr_p_c && (! susp->request.urh->clean_ready) ) shutdown (susp->request.urh->app.socket, SHUT_RDWR); /* Wake thread by shutdown of app socket. */ #endif /* HTTPS_SUPPORT */ else { #ifdef HAVE_MESSAGES if (! susp->request.urh->was_closed) MHD_DLOG (daemon, MHD_SC_SHUTDOWN_WITH_OPEN_UPGRADED_CONNECTION, _ ( "Initiated daemon shutdown while \"upgraded\" connection was not closed.\n")); #endif susp->request.urh->was_closed = true; /* If thread-per-connection is used, connection's thread * may still processing "upgrade" (exiting). */ if (! used_thr_p_c) MHD_connection_finish_forward_ (susp); /* Do not use MHD_resume_connection() as mutex is * already locked. */ susp->resuming = true; daemon->resuming = true; } susp = susp->prev; } } else /* This 'else' is combined with next 'if' */ #endif /* UPGRADE_SUPPORT */ if (NULL != daemon->suspended_connections_head) MHD_PANIC (_ ( "MHD_stop_daemon() called while we have suspended connections.\n")); for (pos = daemon->connections_tail; NULL != pos; pos = pos->prev) { shutdown (pos->socket_fd, SHUT_RDWR); #if MHD_WINSOCK_SOCKETS if ( (used_thr_p_c) && (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "e")) ) MHD_PANIC (_ ( "Failed to signal shutdown via inter-thread communication channel.\n")); #endif } /* now, collect per-connection threads */ if (used_thr_p_c) { pos = daemon->connections_tail; while (NULL != pos) { if (! pos->thread_joined) { MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); if (! MHD_join_thread_ (pos->pid.handle)) MHD_PANIC (_ ("Failed to join a thread.\n")); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); pos->thread_joined = true; /* The thread may have concurrently modified the DLL, need to restart from the beginning */ pos = daemon->connections_tail; continue; } pos = pos->prev; } } MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #ifdef UPGRADE_SUPPORT /* Finished threads with "upgraded" connections need to be moved * to cleanup list by resume_suspended_connections(). */ /* "Upgraded" connections that were not closed explicitly by * application should be moved to cleanup list too. */ if (upg_allowed) { daemon->resuming = true; /* Force check for pending resume. */ MHD_resume_suspended_connections_ (daemon); } #endif /* UPGRADE_SUPPORT */ /* now that we're alone, move everyone to cleanup */ while (NULL != (pos = daemon->connections_tail)) { if ( (used_thr_p_c) && (! pos->thread_joined) ) MHD_PANIC (_ ("Failed to join a thread.\n")); close_connection (pos); } MHD_connection_cleanup_ (daemon); } /* end of daemon_close_all_connections.c */ libmicrohttpd-1.0.1/src/lib/response_from_callback.c0000644000175000017500000000550114417460232016240 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/response_from_callback.c * @brief implementation of MHD_response_from_callback() * @author Christian Grothoff */ #include "internal.h" /** * Create a response action. The response object can be extended with * header information and then be used any number of times. * * @param sc status code to return * @param size size of the data portion of the response, #MHD_SIZE_UNKNOWN for unknown * @param block_size preferred block size for querying crc (advisory only, * MHD may still call @a crc using smaller chunks); this * is essentially the buffer size used for IO, clients * should pick a value that is appropriate for IO and * memory performance requirements * @param crc callback to use to obtain response data * @param crc_cls extra argument to @a crc * @param crfc callback to call to free @a crc_cls resources * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ struct MHD_Response * MHD_response_from_callback (enum MHD_HTTP_StatusCode sc, uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc) { struct MHD_Response *response; mhd_assert (NULL != crc); mhd_assert (0 != block_size); if (NULL == (response = MHD_calloc_ (1, sizeof (struct MHD_Response) + block_size))) return NULL; response->fd = -1; response->status_code = sc; response->data = (void *) &response[1]; response->data_buffer_size = block_size; if (! MHD_mutex_init_ (&response->mutex)) { free (response); return NULL; } response->crc = crc; response->crfc = crfc; response->crc_cls = crc_cls; response->reference_count = 1; response->total_size = size; return response; } /* end of response_from_callback.c */ libmicrohttpd-1.0.1/src/lib/request_info.c0000644000175000017500000000565514417460232014260 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/request_info.c * @brief implementation of MHD_request_get_information_sz() * @author Christian Grothoff */ #include "internal.h" /** * Obtain information about the given request. * Use wrapper macro #MHD_request_get_information() instead of direct use * of this function. * * @param request what request to get information about * @param info_type what information is desired? * @param[out] return_value pointer to union where requested information will * be stored * @param return_value_size size of union MHD_RequestInformation at compile * time * @return #MHD_YES on success, #MHD_NO on error * (@a info_type is unknown, NULL pointer etc.) * @ingroup specialized */ enum MHD_Bool MHD_request_get_information_sz (struct MHD_Request *request, enum MHD_RequestInformationType info_type, union MHD_RequestInformation *return_value, size_t return_value_size) { #define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \ return MHD_NO switch (info_type) { case MHD_REQUEST_INFORMATION_CONNECTION: CHECK_SIZE (struct MHD_Connection *); return_value->connection = request->connection; return MHD_YES; case MHD_REQUEST_INFORMATION_CLIENT_CONTEXT: CHECK_SIZE (void **); return_value->request_context = &request->client_context; return MHD_YES; case MHD_REQUEST_INFORMATION_HTTP_VERSION: CHECK_SIZE (const char *); return_value->http_version = request->version_s; return MHD_YES; case MHD_REQUEST_INFORMATION_HTTP_METHOD: CHECK_SIZE (const char *); return_value->http_method = request->method_s; return MHD_YES; case MHD_REQUEST_INFORMATION_HEADER_SIZE: CHECK_SIZE (size_t); if ( (MHD_REQUEST_HEADERS_RECEIVED > request->state) || (MHD_REQUEST_CLOSED == request->state) ) return MHD_NO; /* invalid, too early! */ return_value->header_size = request->header_size; return MHD_YES; default: return MHD_NO; } #undef CHECK_SIZE } /* end of request_info.c */ libmicrohttpd-1.0.1/src/lib/mhd_str.h0000644000175000017500000002467114417460232013221 /* This file is part of libmicrohttpd Copyright (C) 2015, 2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_str.h * @brief Header for string manipulating helpers * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_STR_H #define MHD_STR_H 1 #include "mhd_options.h" #include #include #ifdef HAVE_STDBOOL_H #include #endif /* HAVE_STDBOOL_H */ #ifdef MHD_FAVOR_SMALL_CODE #include "mhd_limits.h" #endif /* MHD_FAVOR_SMALL_CODE */ #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ /* * Block of functions/macros that use US-ASCII charset as required by HTTP * standards. Not affected by current locale settings. */ #ifndef MHD_FAVOR_SMALL_CODE /** * Check two string for equality, ignoring case of US-ASCII letters. * @param str1 first string to compare * @param str2 second string to compare * @return non-zero if two strings are equal, zero otherwise. */ int MHD_str_equal_caseless_ (const char *str1, const char *str2); #else /* MHD_FAVOR_SMALL_CODE */ /* Reuse MHD_str_equal_caseless_n_() to reduce size */ #define MHD_str_equal_caseless_(s1,s2) MHD_str_equal_caseless_n_ ((s1),(s2), \ SIZE_MAX) #endif /* MHD_FAVOR_SMALL_CODE */ /** * Check two string for equality, ignoring case of US-ASCII letters and * checking not more than @a maxlen characters. * Compares up to first terminating null character, but not more than * first @a maxlen characters. * @param str1 first string to compare * @param str2 second string to compare * @param maxlen maximum number of characters to compare * @return non-zero if two strings are equal, zero otherwise. */ int MHD_str_equal_caseless_n_ (const char *const str1, const char *const str2, size_t maxlen); /** * Check whether @a str has case-insensitive @a token. * Token could be surrounded by spaces and tabs and delimited by comma. * Match succeed if substring between start, end of string or comma * contains only case-insensitive token and optional spaces and tabs. * @warning token must not contain null-charters except optional * terminating null-character. * @param str the string to check * @param token the token to find * @param token_len length of token, not including optional terminating * null-character. * @return non-zero if two strings are equal, zero otherwise. */ bool MHD_str_has_token_caseless_ (const char *str, const char *const token, size_t token_len); /** * Check whether @a str has case-insensitive static @a tkn. * Token could be surrounded by spaces and tabs and delimited by comma. * Match succeed if substring between start, end of string or comma * contains only case-insensitive token and optional spaces and tabs. * @warning tkn must be static string * @param str the string to check * @param tkn the static string of token to find * @return non-zero if two strings are equal, zero otherwise. */ #define MHD_str_has_s_token_caseless_(str,tkn) \ MHD_str_has_token_caseless_ ((str),(tkn),MHD_STATICSTR_LEN_ (tkn)) #ifndef MHD_FAVOR_SMALL_CODE /* Use individual function for each case to improve speed */ /** * Convert decimal US-ASCII digits in string to number in uint64_t. * Conversion stopped at first non-digit character. * @param str string to convert * @param out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_str_to_uint64_ (const char *str, uint64_t *out_val); /** * Convert not more then @a maxlen decimal US-ASCII digits in string to * number in uint64_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * @param str string to convert * @param maxlen maximum number of characters to process * @param out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_str_to_uint64_n_ (const char *str, size_t maxlen, uint64_t *out_val); /** * Convert hexadecimal US-ASCII digits in string to number in uint32_t. * Conversion stopped at first non-digit character. * @param str string to convert * @param out_val pointer to uint32_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint32_t or @a out_val is NULL */ size_t MHD_strx_to_uint32_ (const char *str, uint32_t *out_val); /** * Convert not more then @a maxlen hexadecimal US-ASCII digits in string * to number in uint32_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * @param str string to convert * @param maxlen maximum number of characters to process * @param out_val pointer to uint32_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint32_t or @a out_val is NULL */ size_t MHD_strx_to_uint32_n_ (const char *str, size_t maxlen, uint32_t *out_val); /** * Convert hexadecimal US-ASCII digits in string to number in uint64_t. * Conversion stopped at first non-digit character. * @param str string to convert * @param out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_strx_to_uint64_ (const char *str, uint64_t *out_val); /** * Convert not more then @a maxlen hexadecimal US-ASCII digits in string * to number in uint64_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * @param str string to convert * @param maxlen maximum number of characters to process * @param out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_strx_to_uint64_n_ (const char *str, size_t maxlen, uint64_t *out_val); #else /* MHD_FAVOR_SMALL_CODE */ /* Use one universal function and macros to reduce size */ /** * Generic function for converting not more then @a maxlen * hexadecimal or decimal US-ASCII digits in string to number. * Conversion stopped at first non-digit character or after @a maxlen * digits. * To be used only within macro. * @param str the string to convert * @param maxlen the maximum number of characters to process * @param out_val the pointer to uint64_t to store result of conversion * @param val_size the size of variable pointed by @a out_val * @param max_val the maximum decoded number * @param base the numeric base, 10 or 16 * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then @ max_val or @a out_val is NULL */ size_t MHD_str_to_uvalue_n_ (const char *str, size_t maxlen, void *out_val, size_t val_size, uint64_t max_val, int base); #define MHD_str_to_uint64_(s,ov) MHD_str_to_uvalue_n_ ((s),SIZE_MAX,(ov), \ sizeof(uint64_t), \ UINT64_MAX,10) #define MHD_str_to_uint64_n_(s,ml,ov) MHD_str_to_uvalue_n_ ((s),(ml),(ov), \ sizeof(uint64_t), \ UINT64_MAX,10) #define MHD_strx_to_sizet_(s,ov) MHD_str_to_uvalue_n_ ((s),SIZE_MAX,(ov), \ sizeof(size_t),SIZE_MAX, \ 16) #define MHD_strx_to_sizet_n_(s,ml,ov) MHD_str_to_uvalue_n_ ((s),(ml),(ov), \ sizeof(size_t), \ SIZE_MAX,16) #define MHD_strx_to_uint32_(s,ov) MHD_str_to_uvalue_n_ ((s),SIZE_MAX,(ov), \ sizeof(uint32_t), \ UINT32_MAX,16) #define MHD_strx_to_uint32_n_(s,ml,ov) MHD_str_to_uvalue_n_ ((s),(ml),(ov), \ sizeof(uint32_t), \ UINT32_MAX,16) #define MHD_strx_to_uint64_(s,ov) MHD_str_to_uvalue_n_ ((s),SIZE_MAX,(ov), \ sizeof(uint64_t), \ UINT64_MAX,16) #define MHD_strx_to_uint64_n_(s,ml,ov) MHD_str_to_uvalue_n_ ((s),(ml),(ov), \ sizeof(uint64_t), \ UINT64_MAX,16) #endif /* MHD_FAVOR_SMALL_CODE */ #endif /* MHD_STR_H */ libmicrohttpd-1.0.1/src/lib/daemon_get_timeout.c0000644000175000017500000001013014417460232015405 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_get_timeout.c * @brief function to obtain timeout for event loop * @author Christian Grothoff */ #include "internal.h" /** * Obtain timeout value for polling function for this daemon. * This function set value to amount of milliseconds for which polling * function (`select()` or `poll()`) should at most block, not the * timeout value set for connections. * It is important to always use this function, even if connection * timeout is not set, as in some cases MHD may already have more * data to process on next turn (data pending in TLS buffers, * connections are already ready with epoll etc.) and returned timeout * will be zero. * * @param daemon daemon to query for timeout * @param timeout set to the timeout (in milliseconds) * @return #MHD_SC_OK on success, #MHD_SC_NO_TIMEOUT if timeouts are * not used (or no connections exist that would * necessitate the use of a timeout right now), otherwise * an error code * @ingroup event */ enum MHD_StatusCode MHD_daemon_get_timeout (struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout) { time_t earliest_deadline; time_t now; struct MHD_Connection *pos; bool have_timeout; if (MHD_TM_EXTERNAL_EVENT_LOOP != daemon->threading_mode) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_CONFIGURATION_MISMATCH_FOR_GET_TIMEOUT, _ ("Illegal call to MHD_get_timeout.\n")); #endif return MHD_SC_CONFIGURATION_MISMATCH_FOR_GET_TIMEOUT; } if (daemon->data_already_pending) { /* Some data already waiting to be processed. */ *timeout = 0; return MHD_SC_OK; } #ifdef EPOLL_SUPPORT if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && ((NULL != daemon->eready_head) #if defined(UPGRADE_SUPPORT) && defined(HTTPS_SUPPORT) || (NULL != daemon->eready_urh_head) #endif /* UPGRADE_SUPPORT && HTTPS_SUPPORT */ ) ) { /* Some connection(s) already have some data pending. */ *timeout = 0; return MHD_SC_OK; } #endif /* EPOLL_SUPPORT */ have_timeout = false; earliest_deadline = 0; /* avoid compiler warnings */ for (pos = daemon->manual_timeout_tail; NULL != pos; pos = pos->prevX) { if (0 != pos->connection_timeout) { if ( (! have_timeout) || (earliest_deadline - pos->last_activity > pos->connection_timeout) ) earliest_deadline = pos->last_activity + pos->connection_timeout; have_timeout = true; } } /* normal timeouts are sorted, so we only need to look at the 'tail' (oldest) */ pos = daemon->normal_timeout_tail; if ( (NULL != pos) && (0 != pos->connection_timeout) ) { if ( (! have_timeout) || (earliest_deadline - pos->connection_timeout > pos->last_activity) ) earliest_deadline = pos->last_activity + pos->connection_timeout; have_timeout = true; } if (! have_timeout) return MHD_SC_NO_TIMEOUT; now = MHD_monotonic_sec_counter (); if (earliest_deadline < now) *timeout = 0; else { const time_t second_left = earliest_deadline - now; if (second_left > ULLONG_MAX / 1000) /* Ignore compiler warning: 'second_left' is always positive. */ *timeout = ULLONG_MAX; else *timeout = 1000LL * second_left; } return MHD_SC_OK; } /* end of daemon_get_timeout.c */ libmicrohttpd-1.0.1/src/lib/connection_cleanup.c0000644000175000017500000001225614417460232015416 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_cleanup.c * @brief function to clean up completed connections * @author Christian Grothoff */ #include "internal.h" #include "connection_cleanup.h" #include "daemon_ip_limit.h" #ifdef UPGRADE_SUPPORT /** * Finally cleanup upgrade-related resources. It should * be called when TLS buffers have been drained and * application signaled MHD by #MHD_UPGRADE_ACTION_CLOSE. * * @param connection handle to the upgraded connection to clean */ static void connection_cleanup_upgraded (struct MHD_Connection *connection) { struct MHD_UpgradeResponseHandle *urh = connection->request.urh; if (NULL == urh) return; #ifdef HTTPS_SUPPORT /* Signal remote client the end of TLS connection by * gracefully closing TLS session. */ { struct MHD_TLS_Plugin *tls; if (NULL != (tls = connection->daemon->tls_api)) (void) tls->shutdown_connection (tls->cls, connection->tls_cs); } if (MHD_INVALID_SOCKET != urh->mhd.socket) MHD_socket_close_chk_ (urh->mhd.socket); if (MHD_INVALID_SOCKET != urh->app.socket) MHD_socket_close_chk_ (urh->app.socket); #endif /* HTTPS_SUPPORT */ connection->request.urh = NULL; free (urh); } #endif /* UPGRADE_SUPPORT */ /** * Free resources associated with all closed connections. (destroy * responses, free buffers, etc.). All closed connections are kept in * the "cleanup" doubly-linked list. * * @remark To be called only from thread that process daemon's * select()/poll()/etc. * * @param daemon daemon to clean up */ void MHD_connection_cleanup_ (struct MHD_Daemon *daemon) { struct MHD_Connection *pos; MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); while (NULL != (pos = daemon->cleanup_tail)) { DLL_remove (daemon->cleanup_head, daemon->cleanup_tail, pos); MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); if ( (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) && (! pos->thread_joined) && (! MHD_join_thread_ (pos->pid.handle)) ) MHD_PANIC (_ ("Failed to join a thread.\n")); #ifdef UPGRADE_SUPPORT connection_cleanup_upgraded (pos); #endif /* UPGRADE_SUPPORT */ MHD_pool_destroy (pos->pool); #ifdef HTTPS_SUPPORT { struct MHD_TLS_Plugin *tls; if (NULL != (tls = daemon->tls_api)) tls->teardown_connection (tls->cls, pos->tls_cs); } #endif /* HTTPS_SUPPORT */ /* clean up the connection */ if (NULL != daemon->notify_connection_cb) daemon->notify_connection_cb (daemon->notify_connection_cb_cls, pos, MHD_CONNECTION_NOTIFY_CLOSED); MHD_ip_limit_del (daemon, (const struct sockaddr *) &pos->addr, pos->addr_len); #ifdef EPOLL_SUPPORT if (MHD_ELS_EPOLL == daemon->event_loop_syscall) { if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) { EDLL_remove (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EREADY_EDLL; } if ( (-1 != daemon->epoll_fd) && (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) ) { /* epoll documentation suggests that closing a FD automatically removes it from the epoll set; however, this is not true as if we fail to do manually remove it, we are still seeing an event for this fd in epoll, causing grief (use-after-free...) --- at least on my system. */if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, pos->socket_fd, NULL)) MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET; } } #endif if (NULL != pos->request.response) { MHD_response_queue_for_destroy (pos->request.response); pos->request.response = NULL; } if (MHD_INVALID_SOCKET != pos->socket_fd) MHD_socket_close_chk_ (pos->socket_fd); free (pos); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); daemon->connections--; daemon->at_limit = false; } MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } /* end of connection_cleanup.c */ libmicrohttpd-1.0.1/src/lib/action_suspend.c0000644000175000017500000001114614417460232014563 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/action_suspend.c * @brief implementation of MHD_action_suspend() * @author Christian Grothoff */ #include "internal.h" /** * The suspend action is being run. Suspend handling * of the given request. * * @param cls NULL * @param request the request to apply the action to * @return #MHD_SC_OK on success */ static enum MHD_StatusCode suspend_action (void *cls, struct MHD_Request *request) { (void) cls; struct MHD_Connection *connection = request->connection; struct MHD_Daemon *daemon = connection->daemon; MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); if (connection->resuming) { /* suspending again while we didn't even complete resuming yet */ connection->resuming = false; MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); return MHD_SC_OK; } if (daemon->threading_mode != MHD_TM_THREAD_PER_CONNECTION) { if (connection->connection_timeout == daemon->connection_default_timeout) XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); else XDLL_remove (daemon->manual_timeout_head, daemon->manual_timeout_tail, connection); } DLL_remove (daemon->connections_head, daemon->connections_tail, connection); mhd_assert (! connection->suspended); DLL_insert (daemon->suspended_connections_head, daemon->suspended_connections_tail, connection); connection->suspended = true; #ifdef EPOLL_SUPPORT if (MHD_ELS_EPOLL == daemon->event_loop_syscall) { if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) { EDLL_remove (daemon->eready_head, daemon->eready_tail, connection); connection->epoll_state &= ~MHD_EPOLL_STATE_IN_EREADY_EDLL; } if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) { if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, connection->socket_fd, NULL)) MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); connection->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET; } connection->epoll_state |= MHD_EPOLL_STATE_SUSPENDED; } #endif MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); return MHD_SC_OK; } /** * Suspend handling of network data for a given request. This can * be used to dequeue a request from MHD's event loop for a while. * * If you use this API in conjunction with a internal select or a * thread pool, you must set the option #MHD_USE_ITC to * ensure that a resumed request is immediately processed by MHD. * * Suspended requests continue to count against the total number of * requests allowed (per daemon, as well as per IP, if such limits * are set). Suspended requests will NOT time out; timeouts will * restart when the request handling is resumed. While a * request is suspended, MHD will not detect disconnects by the * client. * * The only safe time to suspend a request is from either a * #MHD_RequestHeaderCallback, #MHD_UploadCallback, or a * #MHD_RequestfetchResponseCallback. Suspending a request * at any other time will cause an assertion failure. * * Finally, it is an API violation to call #MHD_daemon_stop() while * having suspended requests (this will at least create memory and * socket leaks or lead to undefined behavior). You must explicitly * resume all requests before stopping the daemon. * * @return action to cause a request to be suspended. */ const struct MHD_Action * MHD_action_suspend (void) { static const struct MHD_Action suspend = { .action = &suspend_action, .action_cls = NULL }; return &suspend; } /* end of action_suspend.c */ libmicrohttpd-1.0.1/src/lib/daemon_close_all_connections.h0000644000175000017500000000256514417460232017441 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_close_all_connections.h * @brief function to close all connections open at a daemon * @author Christian Grothoff */ #ifndef DAEMON_CLOSE_ALL_CONNECTIONS_H #define DAEMON_CLOSE_ALL_CONNECTIONS_H /** * Close all connections for the daemon. Must only be called when * MHD_Daemon::shutdown was set to true. * * @remark To be called only from thread that process daemon's * select()/poll()/etc. * * @param daemon daemon to close down */ void MHD_daemon_close_all_connections_ (struct MHD_Daemon *daemon) MHD_NONNULL (1); #endif libmicrohttpd-1.0.1/src/lib/connection_info.c0000644000175000017500000000760714417460232014726 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_info.c * @brief implementation of MHD_connection_get_information_sz() * @author Christian Grothoff */ #include "internal.h" /** * Obtain information about the given connection. * Use wrapper macro #MHD_connection_get_information() instead of direct use * of this function. * * @param connection what connection to get information about * @param info_type what information is desired? * @param[out] return_value pointer to union where requested information will * be stored * @param return_value_size size of union MHD_ConnectionInformation at compile * time * @return #MHD_YES on success, #MHD_NO on error * (@a info_type is unknown, NULL pointer etc.) * @ingroup specialized */ enum MHD_Bool MHD_connection_get_information_sz (struct MHD_Connection *connection, enum MHD_ConnectionInformationType info_type, union MHD_ConnectionInformation *return_value, size_t return_value_size) { #define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \ return MHD_NO switch (info_type) { #ifdef HTTPS_SUPPORT case MHD_CONNECTION_INFORMATION_CIPHER_ALGO: CHECK_SIZE (int); if (NULL == connection->tls_cs) return MHD_NO; // return_value->cipher_algorithm // = gnutls_cipher_get (connection->tls_session); return MHD_NO; // FIXME: to be implemented case MHD_CONNECTION_INFORMATION_PROTOCOL: CHECK_SIZE (int); if (NULL == connection->tls_cs) return MHD_NO; // return_value->protocol // = gnutls_protocol_get_version (connection->tls_session); return MHD_NO; // FIXME: to be implemented case MHD_CONNECTION_INFORMATION_GNUTLS_SESSION: CHECK_SIZE (void *); if (NULL == connection->tls_cs) return MHD_NO; // return_value->tls_session = connection->tls_session; return MHD_NO; // FIXME: to be implemented #endif /* HTTPS_SUPPORT */ case MHD_CONNECTION_INFORMATION_CLIENT_ADDRESS: CHECK_SIZE (struct sockaddr *); return_value->client_addr = (const struct sockaddr *) &connection->addr; return MHD_YES; case MHD_CONNECTION_INFORMATION_DAEMON: CHECK_SIZE (struct MHD_Daemon *); return_value->daemon = connection->daemon; return MHD_YES; case MHD_CONNECTION_INFORMATION_CONNECTION_FD: CHECK_SIZE (MHD_socket); return_value->connect_fd = connection->socket_fd; return MHD_YES; case MHD_CONNECTION_INFORMATION_SOCKET_CONTEXT: CHECK_SIZE (void **); return_value->socket_context = &connection->socket_context; return MHD_YES; case MHD_CONNECTION_INFORMATION_CONNECTION_SUSPENDED: CHECK_SIZE (enum MHD_Bool); return_value->suspended = connection->suspended ? MHD_YES : MHD_NO; return MHD_YES; case MHD_CONNECTION_INFORMATION_CONNECTION_TIMEOUT: CHECK_SIZE (unsigned int); return_value->connection_timeout = (unsigned int) connection->connection_timeout; return MHD_YES; default: return MHD_NO; } #undef CHECK_SIZE } /* end of connection_info.c */ libmicrohttpd-1.0.1/src/lib/daemon_quiesce.c0000644000175000017500000001062214417460232014524 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_quiesce.c * @brief main functions to quiesce a daemon * @author Christian Grothoff */ #include "internal.h" /** * Stop accepting connections from the listening socket. Allows * clients to continue processing, but stops accepting new * connections. Note that the caller is responsible for closing the * returned socket; however, if MHD is run using threads (anything but * external select mode), it must not be closed until AFTER * #MHD_stop_daemon has been called (as it is theoretically possible * that an existing thread is still using it). * * Note that some thread modes require the caller to have passed * #MHD_USE_ITC when using this API. If this daemon is * in one of those modes and this option was not given to * #MHD_start_daemon, this function will return #MHD_INVALID_SOCKET. * * @param daemon daemon to stop accepting new connections for * @return old listen socket on success, #MHD_INVALID_SOCKET if * the daemon was already not listening anymore, or * was never started * @ingroup specialized */ MHD_socket MHD_daemon_quiesce (struct MHD_Daemon *daemon) { MHD_socket listen_socket; if (MHD_INVALID_SOCKET == (listen_socket = daemon->listen_socket)) return MHD_INVALID_SOCKET; if ( (daemon->disable_itc) && (MHD_TM_EXTERNAL_EVENT_LOOP != daemon->threading_mode) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_SYSCALL_QUIESCE_REQUIRES_ITC, "Using MHD_quiesce_daemon in this mode requires ITC.\n"); #endif return MHD_INVALID_SOCKET; } if (NULL != daemon->worker_pool) { unsigned int i; for (i = 0; i < daemon->worker_pool_size; i++) { struct MHD_Daemon *worker = &daemon->worker_pool[i]; worker->was_quiesced = true; #ifdef EPOLL_SUPPORT if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && (-1 != worker->epoll_fd) && (worker->listen_socket_in_epoll) ) { if (0 != epoll_ctl (worker->epoll_fd, EPOLL_CTL_DEL, listen_socket, NULL)) MHD_PANIC (_ ("Failed to remove listen FD from epoll set.\n")); worker->listen_socket_in_epoll = false; } else #endif if (MHD_ITC_IS_VALID_ (worker->itc)) { if (! MHD_itc_activate_ (worker->itc, "q")) MHD_PANIC (_ ( "Failed to signal quiesce via inter-thread communication channel.\n")); } } daemon->was_quiesced = true; #ifdef EPOLL_SUPPORT if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && (-1 != daemon->epoll_fd) && (daemon->listen_socket_in_epoll) ) { if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, listen_socket, NULL)) MHD_PANIC ("Failed to remove listen FD from epoll set.\n"); daemon->listen_socket_in_epoll = false; } #endif } if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "q")) ) MHD_PANIC (_ ( "Failed to signal quiesce via inter-thread communication channel.\n")); /* FIXME: we might want some bi-directional communication here (in both the thread-pool and single-thread case!) to be sure that the threads have stopped using the listen socket, otherwise there is still the possibility of a race between a thread accept()ing and the caller closing and re-binding the socket. */return listen_socket; } /* end of daemon_quiesce.c */ libmicrohttpd-1.0.1/src/lib/daemon_ip_limit.c0000644000175000017500000001702514441373361014703 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_ip_limit.c * @brief counting of connections per IP * @author Christian Grothoff */ #include "internal.h" #include "daemon_ip_limit.h" #ifdef HAVE_SEARCH_H #include #else #include "tsearch.h" #endif /** * Maintain connection count for single address. */ struct MHD_IPCount { /** * Address family. AF_INET or AF_INET6 for now. */ int family; /** * Actual address. */ union { /** * IPv4 address. */ struct in_addr ipv4; #ifdef HAVE_INET6 /** * IPv6 address. */ struct in6_addr ipv6; #endif } addr; /** * Counter. */ unsigned int count; }; /** * Trace up to and return master daemon. If the supplied daemon * is a master, then return the daemon itself. * * @param daemon handle to a daemon * @return master daemon handle */ static struct MHD_Daemon * get_master (struct MHD_Daemon *daemon) { while (NULL != daemon->master) daemon = daemon->master; return daemon; } /** * Lock shared structure for IP connection counts and connection DLLs. * * @param daemon handle to daemon where lock is */ static void MHD_ip_count_lock (struct MHD_Daemon *daemon) { MHD_mutex_lock_chk_ (&daemon->per_ip_connection_mutex); } /** * Unlock shared structure for IP connection counts and connection DLLs. * * @param daemon handle to daemon where lock is */ static void MHD_ip_count_unlock (struct MHD_Daemon *daemon) { MHD_mutex_unlock_chk_ (&daemon->per_ip_connection_mutex); } /** * Tree comparison function for IP addresses (supplied to tsearch() family). * We compare everything in the struct up through the beginning of the * 'count' field. * * @param a1 first address to compare * @param a2 second address to compare * @return -1, 0 or 1 depending on result of compare */ static int MHD_ip_addr_compare (const void *a1, const void *a2) { return memcmp (a1, a2, offsetof (struct MHD_IPCount, count)); } /** * Parse address and initialize @a key using the address. * * @param addr address to parse * @param addrlen number of bytes in @a addr * @param key where to store the parsed address * @return #MHD_YES on success and #MHD_NO otherwise (e.g., invalid address type) */ static int MHD_ip_addr_to_key (const struct sockaddr *addr, socklen_t addrlen, struct MHD_IPCount *key) { memset (key, 0, sizeof(*key)); /* IPv4 addresses */ if (sizeof (struct sockaddr_in) == addrlen) { const struct sockaddr_in *addr4 = (const struct sockaddr_in *) addr; key->family = AF_INET; memcpy (&key->addr.ipv4, &addr4->sin_addr, sizeof(addr4->sin_addr)); return MHD_YES; } #ifdef HAVE_INET6 /* IPv6 addresses */ if (sizeof (struct sockaddr_in6) == addrlen) { const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *) addr; key->family = AF_INET6; memcpy (&key->addr.ipv6, &addr6->sin6_addr, sizeof(addr6->sin6_addr)); return MHD_YES; } #endif /* Some other address */ return MHD_NO; } /** * Check if IP address is over its limit in terms of the number * of allowed concurrent connections. If the IP is still allowed, * increments the connection counter. * * @param daemon handle to daemon where connection counts are tracked * @param addr address to add (or increment counter) * @param addrlen number of bytes in @a addr * @return Return #MHD_YES if IP below limit, #MHD_NO if IP has surpassed limit. * Also returns #MHD_NO if fails to allocate memory. */ int MHD_ip_limit_add (struct MHD_Daemon *daemon, const struct sockaddr *addr, socklen_t addrlen) { struct MHD_IPCount *key; void **nodep; void *node; int result; daemon = get_master (daemon); /* Ignore if no connection limit assigned */ if (0 == daemon->ip_connection_limit) return MHD_YES; if (NULL == (key = malloc (sizeof(*key)))) return MHD_NO; /* Initialize key */ if (MHD_NO == MHD_ip_addr_to_key (addr, addrlen, key)) { /* Allow unhandled address types through */ free (key); return MHD_YES; } MHD_ip_count_lock (daemon); /* Search for the IP address */ if (NULL == (nodep = tsearch (key, &daemon->per_ip_connection_count, &MHD_ip_addr_compare))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_IP_COUNTER_FAILURE, _ ("Failed to add IP connection count node.\n")); #endif MHD_ip_count_unlock (daemon); free (key); return MHD_NO; } node = *nodep; /* If we got an existing node back, free the one we created */ if (node != key) free (key); key = (struct MHD_IPCount *) node; /* Test if there is room for another connection; if so, * increment count */ result = (key->count < daemon->ip_connection_limit) ? MHD_YES : MHD_NO; if (MHD_YES == result) ++key->count; MHD_ip_count_unlock (daemon); return result; } /** * Decrement connection count for IP address, removing from table * count reaches 0. * * @param daemon handle to daemon where connection counts are tracked * @param addr address to remove (or decrement counter) * @param addrlen number of bytes in @a addr */ void MHD_ip_limit_del (struct MHD_Daemon *daemon, const struct sockaddr *addr, socklen_t addrlen) { struct MHD_IPCount search_key; struct MHD_IPCount *found_key; void **nodep; daemon = get_master (daemon); /* Ignore if no connection limit assigned */ if (0 == daemon->ip_connection_limit) return; /* Initialize search key */ if (MHD_NO == MHD_ip_addr_to_key (addr, addrlen, &search_key)) return; MHD_ip_count_lock (daemon); /* Search for the IP address */ if (NULL == (nodep = tfind (&search_key, &daemon->per_ip_connection_count, &MHD_ip_addr_compare))) { /* Something's wrong if we couldn't find an IP address * that was previously added */ MHD_PANIC (_ ("Failed to find previously-added IP address.\n")); } found_key = (struct MHD_IPCount *) *nodep; /* Validate existing count for IP address */ if (0 == found_key->count) { MHD_PANIC (_ ("Previously-added IP address had counter of zero.\n")); } /* Remove the node entirely if count reduces to 0 */ if (0 == --found_key->count) { tdelete (found_key, &daemon->per_ip_connection_count, &MHD_ip_addr_compare); free (found_key); } MHD_ip_count_unlock (daemon); } /* end of daemon_ip_limit.c */ libmicrohttpd-1.0.1/src/lib/mhd_itc_types.h0000644000175000017500000000402614417460232014404 /* This file is part of libmicrohttpd Copyright (C) 2016 Karlson2k (Evgeny Grin), Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_itc_types.h * @brief Types for platform-independent inter-thread communication * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff * * Provides basic types for inter-thread communication. * Designed to be included by other headers. */ #ifndef MHD_ITC_TYPES_H #define MHD_ITC_TYPES_H 1 #include "mhd_options.h" /* Force socketpair on native W32 */ #if defined(_WIN32) && ! defined(__CYGWIN__) && ! defined(_MHD_ITC_SOCKETPAIR) #error _MHD_ITC_SOCKETPAIR is not defined on naitive W32 platform #endif /* _WIN32 && !__CYGWIN__ && !_MHD_ITC_SOCKETPAIR */ #if defined(_MHD_ITC_EVENTFD) /* **************** Optimized GNU/Linux ITC implementation by eventfd ********** */ /** * Data type for a MHD ITC. */ struct MHD_itc_ { int fd; }; #elif defined(_MHD_ITC_PIPE) /* **************** Standard UNIX ITC implementation by pipe ********** */ /** * Data type for a MHD ITC. */ struct MHD_itc_ { int fd[2]; }; #elif defined(_MHD_ITC_SOCKETPAIR) /* **************** ITC implementation by socket pair ********** */ #include "mhd_sockets.h" /** * Data type for a MHD ITC. */ struct MHD_itc_ { MHD_socket sk[2]; }; #endif /* _MHD_ITC_SOCKETPAIR */ #endif /* ! MHD_ITC_TYPES_H */ libmicrohttpd-1.0.1/src/lib/connection_call_handlers.c0000644000175000017500000035733014417460232016567 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_call_handlers.c * @brief call the connection's handlers based on the event trigger * @author Christian Grothoff */ #include "internal.h" #include "connection_call_handlers.h" #include "connection_update_last_activity.h" #include "connection_close.h" #ifdef MHD_LINUX_SOLARIS_SENDFILE #include #endif /* MHD_LINUX_SOLARIS_SENDFILE */ #if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_DARWIN_SENDFILE) #include #include #include #endif /* HAVE_FREEBSD_SENDFILE || HAVE_DARWIN_SENDFILE */ /** * sendfile() chuck size */ #define MHD_SENFILE_CHUNK_ (0x20000) /** * sendfile() chuck size for thread-per-connection */ #define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000) /** * Response text used when the request (http header) is too big to * be processed. * * Intentionally empty here to keep our memory footprint * minimal. */ #ifdef HAVE_MESSAGES #define REQUEST_TOO_BIG \ "Request too bigYour HTTP header was too big for the memory constraints of this webserver." #else #define REQUEST_TOO_BIG "" #endif /** * Response text used when the request (http header) does not * contain a "Host:" header and still claims to be HTTP 1.1. * * Intentionally empty here to keep our memory footprint * minimal. */ #ifdef HAVE_MESSAGES #define REQUEST_LACKS_HOST \ ""Host:" header requiredIn HTTP 1.1, requests must include a "Host:" header, and your HTTP 1.1 request lacked such a header." #else #define REQUEST_LACKS_HOST "" #endif /** * Response text used when the request (http header) is * malformed. * * Intentionally empty here to keep our memory footprint * minimal. */ #ifdef HAVE_MESSAGES #define REQUEST_MALFORMED \ "Request malformedYour HTTP request was syntactically incorrect." #else #define REQUEST_MALFORMED "" #endif /** * Response text used when there is an internal server error. * * Intentionally empty here to keep our memory footprint * minimal. */ #ifdef HAVE_MESSAGES #define INTERNAL_ERROR \ "Internal server errorPlease ask the developer of this Web server to carefully read the GNU libmicrohttpd documentation about connection management and blocking." #else #define INTERNAL_ERROR "" #endif #ifdef HAVE_FREEBSD_SENDFILE #ifdef SF_FLAGS /** * FreeBSD sendfile() flags */ static int freebsd_sendfile_flags_; /** * FreeBSD sendfile() flags for thread-per-connection */ static int freebsd_sendfile_flags_thd_p_c_; #endif /* SF_FLAGS */ /** * Initialises static variables. * * FIXME: make sure its actually called! */ void MHD_conn_init_static_ (void) { /* FreeBSD 11 and later allow to specify read-ahead size * and handles SF_NODISKIO differently. * SF_FLAGS defined only on FreeBSD 11 and later. */ #ifdef SF_FLAGS long sys_page_size = sysconf (_SC_PAGESIZE); if (0 > sys_page_size) { /* Failed to get page size. */ freebsd_sendfile_flags_ = SF_NODISKIO; freebsd_sendfile_flags_thd_p_c_ = SF_NODISKIO; } else { freebsd_sendfile_flags_ = SF_FLAGS ((uint16_t) (MHD_SENFILE_CHUNK_ / sys_page_size), SF_NODISKIO); freebsd_sendfile_flags_thd_p_c_ = SF_FLAGS ((uint16_t) (MHD_SENFILE_CHUNK_THR_P_C_ / sys_page_size), SF_NODISKIO); } #endif /* SF_FLAGS */ } #endif /* HAVE_FREEBSD_SENDFILE */ /** * Message to transmit when http 1.1 request is received */ #define HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n" /** * A serious error occurred, close the * connection (and notify the application). * * @param connection connection to close with error * @param sc the reason for closing the connection * @param emsg error message (can be NULL) */ static void connection_close_error (struct MHD_Connection *connection, enum MHD_StatusCode sc, const char *emsg) { #ifdef HAVE_MESSAGES if (NULL != emsg) MHD_DLOG (connection->daemon, sc, emsg); #else /* ! HAVE_MESSAGES */ (void) emsg; /* Mute compiler warning. */ (void) sc; #endif /* ! HAVE_MESSAGES */ MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_WITH_ERROR); } /** * Macro to only include error message in call to * #connection_close_error() if we have HAVE_MESSAGES. */ #ifdef HAVE_MESSAGES #define CONNECTION_CLOSE_ERROR(c, sc, emsg) connection_close_error (c, sc, emsg) #else #define CONNECTION_CLOSE_ERROR(c, sc, emsg) connection_close_error (c, sc, NULL) #endif /** * Try growing the read buffer. We initially claim half the available * buffer space for the read buffer (the other half being left for * management data structures; the write buffer can in the end take * virtually everything as the read buffer can be reduced to the * minimum necessary at that point. * * @param request the request for which to grow the buffer * @return true on success, false on failure */ static bool try_grow_read_buffer (struct MHD_Request *request) { struct MHD_Daemon *daemon = request->daemon; void *buf; size_t new_size; if (0 == request->read_buffer_size) new_size = daemon->connection_memory_limit_b / 2; else new_size = request->read_buffer_size + daemon->connection_memory_increment_b; buf = MHD_pool_reallocate (request->connection->pool, request->read_buffer, request->read_buffer_size, new_size); if (NULL == buf) return false; /* we can actually grow the buffer, do it! */ request->read_buffer = buf; request->read_buffer_size = new_size; return true; } /** * This function handles a particular request when it has been * determined that there is data to be read off a socket. * * @param request request to handle */ static void MHD_request_handle_read_ (struct MHD_Request *request) { struct MHD_Daemon *daemon = request->daemon; struct MHD_Connection *connection = request->connection; ssize_t bytes_read; if ( (MHD_REQUEST_CLOSED == request->state) || (connection->suspended) ) return; #ifdef HTTPS_SUPPORT { struct MHD_TLS_Plugin *tls; if ( (NULL != (tls = daemon->tls_api)) && (! tls->handshake (tls->cls, connection->tls_cs)) ) return; } #endif /* HTTPS_SUPPORT */ /* make sure "read" has a reasonable number of bytes in buffer to use per system call (if possible) */ if (request->read_buffer_offset + daemon->connection_memory_increment_b > request->read_buffer_size) try_grow_read_buffer (request); if (request->read_buffer_size == request->read_buffer_offset) return; /* No space for receiving data. */ bytes_read = connection->recv_cls (connection, &request->read_buffer [request->read_buffer_offset], request->read_buffer_size - request->read_buffer_offset); if (bytes_read < 0) { if (MHD_ERR_AGAIN_ == bytes_read) return; /* No new data to process. */ if (MHD_ERR_CONNRESET_ == bytes_read) { CONNECTION_CLOSE_ERROR (connection, (MHD_REQUEST_INIT == request->state) ? MHD_SC_CONNECTION_CLOSED : MHD_SC_CONNECTION_RESET_CLOSED, (MHD_REQUEST_INIT == request->state) ? NULL : _ ( "Socket disconnected while reading request.\n")); return; } CONNECTION_CLOSE_ERROR (connection, (MHD_REQUEST_INIT == request->state) ? MHD_SC_CONNECTION_CLOSED : MHD_SC_CONNECTION_READ_FAIL_CLOSED, (MHD_REQUEST_INIT == request->state) ? NULL : _ ( "Connection socket is closed due to error when reading request.\n")); return; } if (0 == bytes_read) { /* Remote side closed connection. */ connection->read_closed = true; MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_CLIENT_ABORT); return; } request->read_buffer_offset += bytes_read; MHD_connection_update_last_activity_ (connection); #if DEBUG_STATES MHD_DLOG (daemon, MHD_SC_STATE_MACHINE_STATUS_REPORT, _ ("In function %s handling connection at state: %s\n"), __FUNCTION__, MHD_state_to_string (request->state)); #endif switch (request->state) { case MHD_REQUEST_INIT: case MHD_REQUEST_URL_RECEIVED: case MHD_REQUEST_HEADER_PART_RECEIVED: case MHD_REQUEST_HEADERS_RECEIVED: case MHD_REQUEST_HEADERS_PROCESSED: case MHD_REQUEST_CONTINUE_SENDING: case MHD_REQUEST_CONTINUE_SENT: case MHD_REQUEST_BODY_RECEIVED: case MHD_REQUEST_FOOTER_PART_RECEIVED: /* nothing to do but default action */ if (connection->read_closed) { MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_READ_ERROR); } return; case MHD_REQUEST_CLOSED: return; #ifdef UPGRADE_SUPPORT case MHD_REQUEST_UPGRADE: mhd_assert (0); return; #endif /* UPGRADE_SUPPORT */ default: /* shrink read buffer to how much is actually used */ MHD_pool_reallocate (connection->pool, request->read_buffer, request->read_buffer_size + 1, request->read_buffer_offset); break; } return; } #if defined(_MHD_HAVE_SENDFILE) /** * Function for sending responses backed by file FD. * * @param connection the MHD connection structure * @return actual number of bytes sent */ static ssize_t sendfile_adapter (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; struct MHD_Request *request = &connection->request; struct MHD_Response *response = request->response; ssize_t ret; const int file_fd = response->fd; uint64_t left; uint64_t offsetu64; #ifndef HAVE_SENDFILE64 const uint64_t max_off_t = (uint64_t) OFF_T_MAX; #else /* HAVE_SENDFILE64 */ const uint64_t max_off_t = (uint64_t) OFF64_T_MAX; #endif /* HAVE_SENDFILE64 */ #ifdef MHD_LINUX_SOLARIS_SENDFILE #ifndef HAVE_SENDFILE64 off_t offset; #else /* HAVE_SENDFILE64 */ off64_t offset; #endif /* HAVE_SENDFILE64 */ #endif /* MHD_LINUX_SOLARIS_SENDFILE */ #ifdef HAVE_FREEBSD_SENDFILE off_t sent_bytes; int flags = 0; #endif #ifdef HAVE_DARWIN_SENDFILE off_t len; #endif /* HAVE_DARWIN_SENDFILE */ const bool used_thr_p_c = (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode); const size_t chunk_size = used_thr_p_c ? MHD_SENFILE_CHUNK_THR_P_C_ : MHD_SENFILE_CHUNK_; size_t send_size = 0; mhd_assert (MHD_resp_sender_sendfile == request->resp_sender); offsetu64 = request->response_write_position + response->fd_off; left = response->total_size - request->response_write_position; /* Do not allow system to stick sending on single fast connection: * use 128KiB chunks (2MiB for thread-per-connection). */ send_size = (left > chunk_size) ? chunk_size : (size_t) left; if (max_off_t < offsetu64) { /* Retry to send with standard 'send()'. */ request->resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; } #ifdef MHD_LINUX_SOLARIS_SENDFILE #ifndef HAVE_SENDFILE64 offset = (off_t) offsetu64; ret = sendfile (connection->socket_fd, file_fd, &offset, send_size); #else /* HAVE_SENDFILE64 */ offset = (off64_t) offsetu64; ret = sendfile64 (connection->socket_fd, file_fd, &offset, send_size); #endif /* HAVE_SENDFILE64 */ if (0 > ret) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) { #ifdef EPOLL_SUPPORT /* EAGAIN --- no longer write-ready */ connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; #endif /* EPOLL_SUPPORT */ return MHD_ERR_AGAIN_; } if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_ERR_AGAIN_; #ifdef HAVE_LINUX_SENDFILE if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EBADF_)) return MHD_ERR_BADF_; /* sendfile() failed with EINVAL if mmap()-like operations are not supported for FD or other 'unusual' errors occurred, so we should try to fall back to 'SEND'; see also this thread for info on odd libc/Linux behavior with sendfile: http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */request->resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; #else /* HAVE_SOLARIS_SENDFILE */ if ( (EAFNOSUPPORT == err) || (EINVAL == err) || (EOPNOTSUPP == err) ) { /* Retry with standard file reader. */ request->resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; } if ( (ENOTCONN == err) || (EPIPE == err) ) { return MHD_ERR_CONNRESET_; } return MHD_ERR_BADF_; /* Fail hard */ #endif /* HAVE_SOLARIS_SENDFILE */ } #ifdef EPOLL_SUPPORT else if (send_size > (size_t) ret) connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; #endif /* EPOLL_SUPPORT */ #elif defined(HAVE_FREEBSD_SENDFILE) #ifdef SF_FLAGS flags = used_thr_p_c ? freebsd_sendfile_flags_thd_p_c_ : freebsd_sendfile_flags_; #endif /* SF_FLAGS */ if (0 != sendfile (file_fd, connection->socket_fd, (off_t) offsetu64, send_size, NULL, &sent_bytes, flags)) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err) || MHD_SCKT_ERR_IS_EINTR_ (err) || (EBUSY == err) ) { mhd_assert (SSIZE_MAX >= sent_bytes); if (0 != sent_bytes) return (ssize_t) sent_bytes; return MHD_ERR_AGAIN_; } /* Some unrecoverable error. Possibly file FD is not suitable * for sendfile(). Retry with standard send(). */ request->resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; } mhd_assert (0 < sent_bytes); mhd_assert (SSIZE_MAX >= sent_bytes); ret = (ssize_t) sent_bytes; #elif defined(HAVE_DARWIN_SENDFILE) len = (off_t) send_size; /* chunk always fit */ if (0 != sendfile (file_fd, connection->socket_fd, (off_t) offsetu64, &len, NULL, 0)) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err) || MHD_SCKT_ERR_IS_EINTR_ (err)) { mhd_assert (0 <= len); mhd_assert (SSIZE_MAX >= len); mhd_assert (send_size >= (size_t) len); if (0 != len) return (ssize_t) len; return MHD_ERR_AGAIN_; } if ((ENOTCONN == err) || (EPIPE == err) ) return MHD_ERR_CONNRESET_; if ((ENOTSUP == err) || (EOPNOTSUPP == err) ) { /* This file FD is not suitable for sendfile(). * Retry with standard send(). */ request->resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; } return MHD_ERR_BADF_; /* Return hard error. */ } mhd_assert (0 <= len); mhd_assert (SSIZE_MAX >= len); mhd_assert (send_size >= (size_t) len); ret = (ssize_t) len; #endif /* HAVE_FREEBSD_SENDFILE */ return ret; } #endif /* _MHD_HAVE_SENDFILE */ /** * Check if we are done sending the write-buffer. If so, transition * into "next_state". * * @param connection connection to check write status for * @param next_state the next state to transition to * @return false if we are not done, true if we are */ static bool check_write_done (struct MHD_Request *request, enum MHD_REQUEST_STATE next_state) { if (request->write_buffer_append_offset != request->write_buffer_send_offset) return false; request->write_buffer_append_offset = 0; request->write_buffer_send_offset = 0; request->state = next_state; MHD_pool_reallocate (request->connection->pool, request->write_buffer, request->write_buffer_size, 0); request->write_buffer = NULL; request->write_buffer_size = 0; return true; } /** * Prepare the response buffer of this request for sending. Assumes * that the response mutex is already held. If the transmission is * complete, this function may close the socket (and return false). * * @param request the request handle * @return false if readying the response failed (the * lock on the response will have been released already * in this case). */ static bool try_ready_normal_body (struct MHD_Request *request) { struct MHD_Response *response = request->response; struct MHD_Connection *connection = request->connection; ssize_t ret; if (NULL == response->crc) return true; if ( (0 == response->total_size) || (request->response_write_position == response->total_size) ) return true; /* 0-byte response is always ready */ if ( (response->data_start <= request->response_write_position) && (response->data_size + response->data_start > request->response_write_position) ) return true; /* response already ready */ #if defined(_MHD_HAVE_SENDFILE) if (MHD_resp_sender_sendfile == request->resp_sender) { /* will use sendfile, no need to bother response crc */ return true; } #endif /* _MHD_HAVE_SENDFILE */ ret = response->crc (response->crc_cls, request->response_write_position, response->data, (size_t) MHD_MIN ((uint64_t) response->data_buffer_size, response->total_size - request->response_write_position)); if ( (((ssize_t) MHD_CONTENT_READER_END_OF_STREAM) == ret) || (((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret) ) { /* either error or http 1.0 transfer, close socket! */ response->total_size = request->response_write_position; MHD_mutex_unlock_chk_ (&response->mutex); if ( ((ssize_t) MHD_CONTENT_READER_END_OF_STREAM) == ret) MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_COMPLETED_OK); else CONNECTION_CLOSE_ERROR (connection, MHD_SC_APPLICATION_DATA_GENERATION_FAILURE_CLOSED, _ ( "Closing connection (application reported error generating data).\n")); return false; } response->data_start = request->response_write_position; response->data_size = ret; if (0 == ret) { request->state = MHD_REQUEST_NORMAL_BODY_UNREADY; MHD_mutex_unlock_chk_ (&response->mutex); return false; } return true; } /** * Prepare the response buffer of this request for sending. Assumes * that the response mutex is already held. If the transmission is * complete, this function may close the socket (and return false). * * @param connection the connection * @return false if readying the response failed */ static bool try_ready_chunked_body (struct MHD_Request *request) { struct MHD_Connection *connection = request->connection; struct MHD_Response *response = request->response; struct MHD_Daemon *daemon = request->daemon; ssize_t ret; char *buf; size_t size; char cbuf[10]; /* 10: max strlen of "%x\r\n" */ int cblen; if (NULL == response->crc) return true; if (0 == request->write_buffer_size) { size = MHD_MIN (daemon->connection_memory_limit_b, 2 * (0xFFFFFF + sizeof(cbuf) + 2)); do { size /= 2; if (size < 128) { MHD_mutex_unlock_chk_ (&response->mutex); /* not enough memory */ CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_POOL_MALLOC_FAILURE, _ ("Closing connection (out of memory).\n")); return false; } buf = MHD_pool_allocate (connection->pool, size, MHD_NO); } while (NULL == buf); request->write_buffer_size = size; request->write_buffer = buf; } if (0 == response->total_size) ret = 0; /* response must be empty, don't bother calling crc */ else if ( (response->data_start <= request->response_write_position) && (response->data_start + response->data_size > request->response_write_position) ) { /* difference between response_write_position and data_start is less than data_size which is size_t type, no need to check for overflow */ const size_t data_write_offset = (size_t) (request->response_write_position - response->data_start); /* buffer already ready, use what is there for the chunk */ ret = response->data_size - data_write_offset; if ( ((size_t) ret) > request->write_buffer_size - sizeof (cbuf) - 2) ret = request->write_buffer_size - sizeof (cbuf) - 2; memcpy (&request->write_buffer[sizeof (cbuf)], &response->data[data_write_offset], ret); } else { /* buffer not in range, try to fill it */ ret = response->crc (response->crc_cls, request->response_write_position, &request->write_buffer[sizeof (cbuf)], request->write_buffer_size - sizeof (cbuf) - 2); } if ( ((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret) { /* error, close socket! */ response->total_size = request->response_write_position; MHD_mutex_unlock_chk_ (&response->mutex); CONNECTION_CLOSE_ERROR (connection, MHD_SC_APPLICATION_DATA_GENERATION_FAILURE_CLOSED, _ ( "Closing connection (application error generating response).\n")); return false; } if ( (((ssize_t) MHD_CONTENT_READER_END_OF_STREAM) == ret) || (0 == response->total_size) ) { /* end of message, signal other side! */ memcpy (request->write_buffer, "0\r\n", 3); request->write_buffer_append_offset = 3; request->write_buffer_send_offset = 0; response->total_size = request->response_write_position; return true; } if (0 == ret) { request->state = MHD_REQUEST_CHUNKED_BODY_UNREADY; MHD_mutex_unlock_chk_ (&response->mutex); return false; } if (ret > 0xFFFFFF) ret = 0xFFFFFF; cblen = MHD_snprintf_ (cbuf, sizeof (cbuf), "%X\r\n", (unsigned int) ret); mhd_assert (cblen > 0); mhd_assert ((size_t) cblen < sizeof(cbuf)); memcpy (&request->write_buffer[sizeof (cbuf) - cblen], cbuf, cblen); memcpy (&request->write_buffer[sizeof (cbuf) + ret], "\r\n", 2); request->response_write_position += ret; request->write_buffer_send_offset = sizeof (cbuf) - cblen; request->write_buffer_append_offset = sizeof (cbuf) + ret + 2; return true; } /** * This function was created to handle writes to sockets when it has * been determined that the socket can be written to. * * @param request the request to handle */ static void MHD_request_handle_write_ (struct MHD_Request *request) { struct MHD_Daemon *daemon = request->daemon; struct MHD_Connection *connection = request->connection; struct MHD_Response *response; ssize_t ret; if (connection->suspended) return; #ifdef HTTPS_SUPPORT { struct MHD_TLS_Plugin *tls; if ( (NULL != (tls = daemon->tls_api)) && (! tls->handshake (tls->cls, connection->tls_cs)) ) return; } #endif /* HTTPS_SUPPORT */ #if DEBUG_STATES MHD_DLOG (daemon, MHD_SC_STATE_MACHINE_STATUS_REPORT, _ ("In function %s handling connection at state: %s\n"), __FUNCTION__, MHD_state_to_string (request->state)); #endif switch (request->state) { case MHD_REQUEST_INIT: case MHD_REQUEST_URL_RECEIVED: case MHD_REQUEST_HEADER_PART_RECEIVED: case MHD_REQUEST_HEADERS_RECEIVED: mhd_assert (0); return; case MHD_REQUEST_HEADERS_PROCESSED: return; case MHD_REQUEST_CONTINUE_SENDING: ret = connection->send_cls (connection, &HTTP_100_CONTINUE [request->continue_message_write_offset], MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE) - request->continue_message_write_offset); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) return; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_CONNECTION_WRITE_FAIL_CLOSED, _ ("Failed to send data in request for %s.\n"), request->url); #endif CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_WRITE_FAIL_CLOSED, NULL); return; } request->continue_message_write_offset += ret; MHD_connection_update_last_activity_ (connection); return; case MHD_REQUEST_CONTINUE_SENT: case MHD_REQUEST_BODY_RECEIVED: case MHD_REQUEST_FOOTER_PART_RECEIVED: case MHD_REQUEST_FOOTERS_RECEIVED: mhd_assert (0); return; case MHD_REQUEST_HEADERS_SENDING: ret = connection->send_cls (connection, &request->write_buffer [request->write_buffer_send_offset], request->write_buffer_append_offset - request->write_buffer_send_offset); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) return; CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_WRITE_FAIL_CLOSED, _ ( "Connection was closed while sending response headers.\n")); return; } request->write_buffer_send_offset += ret; MHD_connection_update_last_activity_ (connection); if (MHD_REQUEST_HEADERS_SENDING != request->state) return; check_write_done (request, MHD_REQUEST_HEADERS_SENT); return; case MHD_REQUEST_HEADERS_SENT: return; case MHD_REQUEST_NORMAL_BODY_READY: response = request->response; if (request->response_write_position < request->response->total_size) { uint64_t data_write_offset; if (NULL != response->crc) MHD_mutex_lock_chk_ (&response->mutex); if (! try_ready_normal_body (request)) { /* mutex was already unlocked by try_ready_normal_body */ return; } #if defined(_MHD_HAVE_SENDFILE) if (MHD_resp_sender_sendfile == request->resp_sender) { ret = sendfile_adapter (connection); } else #else /* ! _MHD_HAVE_SENDFILE */ if (1) #endif /* ! _MHD_HAVE_SENDFILE */ { data_write_offset = request->response_write_position - response->data_start; if (data_write_offset > (uint64_t) SIZE_MAX) MHD_PANIC (_ ("Data offset exceeds limit.\n")); ret = connection->send_cls (connection, &response->data [(size_t) data_write_offset], response->data_size - (size_t) data_write_offset); #if DEBUG_SEND_DATA if (ret > 0) fprintf (stderr, _ ("Sent %d-byte DATA response: `%.*s'\n"), (int) ret, (int) ret, &response->data[request->response_write_position - response->data_start]); #endif } if (NULL != response->crc) MHD_mutex_unlock_chk_ (&response->mutex); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) return; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_CONNECTION_WRITE_FAIL_CLOSED, _ ("Failed to send data in request for `%s'.\n"), request->url); #endif CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_WRITE_FAIL_CLOSED, NULL); return; } request->response_write_position += ret; MHD_connection_update_last_activity_ (connection); } if (request->response_write_position == request->response->total_size) request->state = MHD_REQUEST_FOOTERS_SENT; /* have no footers */ return; case MHD_REQUEST_NORMAL_BODY_UNREADY: mhd_assert (0); return; case MHD_REQUEST_CHUNKED_BODY_READY: ret = connection->send_cls (connection, &request->write_buffer [request->write_buffer_send_offset], request->write_buffer_append_offset - request->write_buffer_send_offset); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) return; CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_WRITE_FAIL_CLOSED, _ ( "Connection was closed while sending response body.\n")); return; } request->write_buffer_send_offset += ret; MHD_connection_update_last_activity_ (connection); if (MHD_REQUEST_CHUNKED_BODY_READY != request->state) return; check_write_done (request, (request->response->total_size == request->response_write_position) ? MHD_REQUEST_BODY_SENT : MHD_REQUEST_CHUNKED_BODY_UNREADY); return; case MHD_REQUEST_CHUNKED_BODY_UNREADY: case MHD_REQUEST_BODY_SENT: mhd_assert (0); return; case MHD_REQUEST_FOOTERS_SENDING: ret = connection->send_cls (connection, &request->write_buffer [request->write_buffer_send_offset], request->write_buffer_append_offset - request->write_buffer_send_offset); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) return; CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_WRITE_FAIL_CLOSED, _ ( "Connection was closed while sending response body.\n")); return; } request->write_buffer_send_offset += ret; MHD_connection_update_last_activity_ (connection); if (MHD_REQUEST_FOOTERS_SENDING != request->state) return; check_write_done (request, MHD_REQUEST_FOOTERS_SENT); return; case MHD_REQUEST_FOOTERS_SENT: mhd_assert (0); return; case MHD_REQUEST_CLOSED: return; #ifdef UPGRADE_SUPPORT case MHD_REQUEST_UPGRADE: mhd_assert (0); return; #endif /* UPGRADE_SUPPORT */ default: mhd_assert (0); CONNECTION_CLOSE_ERROR (connection, MHD_SC_STATEMACHINE_FAILURE_CONNECTION_CLOSED, _ ("Internal error.\n")); break; } } /** * Check whether request header contains particular token. * * Token could be surrounded by spaces and tabs and delimited by comma. * Case-insensitive match used for header names and tokens. * @param request the request to get values from * @param header the header name * @param token the token to find * @param token_len the length of token, not including optional * terminating null-character. * @return true if token is found in specified header, * false otherwise */ static bool MHD_lookup_header_token_ci (const struct MHD_Request *request, const char *header, const char *token, size_t token_len) { struct MHD_HTTP_Header *pos; if ( (NULL == request) || /* FIXME: require non-null? */ (NULL == header) || /* FIXME: require non-null? */ (0 == header[0]) || (NULL == token) || (0 == token[0]) ) return false; for (pos = request->headers_received; NULL != pos; pos = pos->next) { if ( (0 != (pos->kind & MHD_HEADER_KIND)) && ( (header == pos->header) || (MHD_str_equal_caseless_ (header, pos->header)) ) && (MHD_str_has_token_caseless_ (pos->value, token, token_len)) ) return true; } return false; } /** * Check whether request header contains particular static @a tkn. * * Token could be surrounded by spaces and tabs and delimited by comma. * Case-insensitive match used for header names and tokens. * @param r the request to get values from * @param h the header name * @param tkn the static string of token to find * @return true if token is found in specified header, * false otherwise */ #define MHD_lookup_header_s_token_ci(r,h,tkn) \ MHD_lookup_header_token_ci ((r),(h),(tkn),MHD_STATICSTR_LEN_ (tkn)) /** * Are we allowed to keep the given connection alive? We can use the * TCP stream for a second request if the connection is HTTP 1.1 and * the "Connection" header either does not exist or is not set to * "close", or if the connection is HTTP 1.0 and the "Connection" * header is explicitly set to "keep-alive". If no HTTP version is * specified (or if it is not 1.0 or 1.1), we definitively close the * connection. If the "Connection" header is not exactly "close" or * "keep-alive", we proceed to use the default for the respective HTTP * version (which is conservative for HTTP 1.0, but might be a bit * optimistic for HTTP 1.1). * * @param request the request to check for keepalive * @return #MHD_YES if (based on the request), a keepalive is * legal */ static bool keepalive_possible (struct MHD_Request *request) { if (MHD_CONN_MUST_CLOSE == request->keepalive) return false; if (NULL == request->version_s) return false; if ( (NULL != request->response) && (request->response->v10_only) ) return false; if (MHD_str_equal_caseless_ (request->version_s, MHD_HTTP_VERSION_1_1)) { if (MHD_lookup_header_s_token_ci (request, MHD_HTTP_HEADER_CONNECTION, "upgrade")) return false; if (MHD_lookup_header_s_token_ci (request, MHD_HTTP_HEADER_CONNECTION, "close")) return false; return true; } if (MHD_str_equal_caseless_ (request->version_s, MHD_HTTP_VERSION_1_0)) { if (MHD_lookup_header_s_token_ci (request, MHD_HTTP_HEADER_CONNECTION, "Keep-Alive")) return true; return false; } return false; } /** * Produce HTTP time stamp. * * @param date where to write the header, with * at least 128 bytes available space. * @param date_len number of bytes in @a date */ static void get_date_string (char *date, size_t date_len) { static const char *const days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static const char *const mons[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; struct tm now; time_t t; #if ! defined(HAVE_C11_GMTIME_S) && ! defined(HAVE_W32_GMTIME_S) && \ ! defined(HAVE_GMTIME_R) struct tm *pNow; #endif date[0] = 0; time (&t); #if defined(HAVE_C11_GMTIME_S) if (NULL == gmtime_s (&t, &now)) return; #elif defined(HAVE_W32_GMTIME_S) if (0 != gmtime_s (&now, &t)) return; #elif defined(HAVE_GMTIME_R) if (NULL == gmtime_r (&t, &now)) return; #else pNow = gmtime (&t); if (NULL == pNow) return; now = *pNow; #endif MHD_snprintf_ (date, date_len, "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n", days[now.tm_wday % 7], (unsigned int) now.tm_mday, mons[now.tm_mon % 12], (unsigned int) (1900 + now.tm_year), (unsigned int) now.tm_hour, (unsigned int) now.tm_min, (unsigned int) now.tm_sec); } /** * Check whether response header contains particular @a token. * * Token could be surrounded by spaces and tabs and delimited by comma. * Case-insensitive match used for header names and tokens. * @param response the response to query * @param key header name * @param token the token to find * @param token_len the length of token, not including optional * terminating null-character. * @return true if token is found in specified header, * false otherwise */ static bool check_response_header_token_ci (const struct MHD_Response *response, const char *key, const char *token, size_t token_len) { struct MHD_HTTP_Header *pos; if ( (NULL == key) || ('\0' == key[0]) || (NULL == token) || ('\0' == token[0]) ) return false; for (pos = response->first_header; NULL != pos; pos = pos->next) { if ( (pos->kind == MHD_HEADER_KIND) && MHD_str_equal_caseless_ (pos->header, key) && MHD_str_has_token_caseless_ (pos->value, token, token_len) ) return true; } return false; } /** * Check whether response header contains particular static @a tkn. * * Token could be surrounded by spaces and tabs and delimited by comma. * Case-insensitive match used for header names and tokens. * @param r the response to query * @param k header name * @param tkn the static string of token to find * @return true if token is found in specified header, * false otherwise */ #define check_response_header_s_token_ci(r,k,tkn) \ check_response_header_token_ci ((r),(k),(tkn),MHD_STATICSTR_LEN_ (tkn)) /** * Allocate the connection's write buffer and fill it with all of the * headers (or footers, if we have already sent the body) from the * HTTPd's response. If headers are missing in the response supplied * by the application, additional headers may be added here. * * @param request the request for which to build the response header * @return true on success, false on failure (out of memory) */ static bool build_header_response (struct MHD_Request *request) { struct MHD_Connection *connection = request->connection; struct MHD_Daemon *daemon = request->daemon; struct MHD_Response *response = request->response; size_t size; size_t off; struct MHD_HTTP_Header *pos; char code[256]; char date[128]; size_t datelen; char content_length_buf[128]; size_t content_length_len; char *data; enum MHD_ValueKind kind; bool client_requested_close; bool response_has_close; bool response_has_keepalive; const char *have_encoding; const char *have_content_length; bool must_add_close; bool must_add_chunked_encoding; bool must_add_keep_alive; bool must_add_content_length; mhd_assert (NULL != request->version_s); if (0 == request->version_s[0]) { data = MHD_pool_allocate (connection->pool, 0, MHD_YES); request->write_buffer = data; request->write_buffer_append_offset = 0; request->write_buffer_send_offset = 0; request->write_buffer_size = 0; return true; } if (MHD_REQUEST_FOOTERS_RECEIVED == request->state) { const char *reason_phrase; const char *version; reason_phrase = MHD_get_reason_phrase_for (response->status_code); version = (response->icy) ? "ICY" : ( (MHD_str_equal_caseless_ (MHD_HTTP_VERSION_1_0, request->version_s)) ? MHD_HTTP_VERSION_1_0 : MHD_HTTP_VERSION_1_1); MHD_snprintf_ (code, sizeof (code), "%s %u %s\r\n", version, response->status_code, reason_phrase); off = strlen (code); /* estimate size */ size = off + 2; /* +2 for extra "\r\n" at the end */ kind = MHD_HEADER_KIND; if ( (! daemon->suppress_date) && (NULL == MHD_response_get_header (response, MHD_HTTP_HEADER_DATE)) ) get_date_string (date, sizeof (date)); else date[0] = '\0'; datelen = strlen (date); size += datelen; } else { /* 2 bytes for final CRLF of a Chunked-Body */ size = 2; kind = MHD_FOOTER_KIND; off = 0; datelen = 0; } /* calculate extra headers we need to add, such as 'Connection: close', first see what was explicitly requested by the application */ must_add_close = false; must_add_chunked_encoding = false; must_add_keep_alive = false; must_add_content_length = false; response_has_close = false; switch (request->state) { case MHD_REQUEST_FOOTERS_RECEIVED: response_has_close = check_response_header_s_token_ci (response, MHD_HTTP_HEADER_CONNECTION, "close"); response_has_keepalive = check_response_header_s_token_ci (response, MHD_HTTP_HEADER_CONNECTION, "Keep-Alive"); client_requested_close = MHD_lookup_header_s_token_ci (request, MHD_HTTP_HEADER_CONNECTION, "close"); if (response->v10_only) request->keepalive = MHD_CONN_MUST_CLOSE; #ifdef UPGRADE_SUPPORT else if (NULL != response->upgrade_handler) /* If this connection will not be "upgraded", it must be closed. */ request->keepalive = MHD_CONN_MUST_CLOSE; #endif /* UPGRADE_SUPPORT */ /* now analyze chunked encoding situation */ request->have_chunked_upload = false; if ( (MHD_SIZE_UNKNOWN == response->total_size) && #ifdef UPGRADE_SUPPORT (NULL == response->upgrade_handler) && #endif /* UPGRADE_SUPPORT */ (! response_has_close) && (! client_requested_close) ) { /* size is unknown, and close was not explicitly requested; need to either to HTTP 1.1 chunked encoding or close the connection */ /* 'close' header doesn't exist yet, see if we need to add one; if the client asked for a close, no need to start chunk'ing */ if ( (keepalive_possible (request)) && (MHD_str_equal_caseless_ (MHD_HTTP_VERSION_1_1, request->version_s)) ) { have_encoding = MHD_response_get_header (response, MHD_HTTP_HEADER_TRANSFER_ENCODING); if (NULL == have_encoding) { must_add_chunked_encoding = true; request->have_chunked_upload = true; } else if (MHD_str_equal_caseless_ (have_encoding, "identity")) { /* application forced identity encoding, can't do 'chunked' */ must_add_close = true; } else { request->have_chunked_upload = true; } } else { /* Keep alive or chunking not possible => set close header if not present */ if (! response_has_close) must_add_close = true; } } /* check for other reasons to add 'close' header */ if ( ( (client_requested_close) || (connection->read_closed) || (MHD_CONN_MUST_CLOSE == request->keepalive)) && (! response_has_close) && #ifdef UPGRADE_SUPPORT (NULL == response->upgrade_handler) && #endif /* UPGRADE_SUPPORT */ (! response->v10_only) ) must_add_close = true; /* check if we should add a 'content length' header */ have_content_length = MHD_response_get_header (response, MHD_HTTP_HEADER_CONTENT_LENGTH); /* MHD_HTTP_NO_CONTENT, MHD_HTTP_NOT_MODIFIED and 1xx-status codes SHOULD NOT have a Content-Length according to spec; also chunked encoding / unknown length or CONNECT... */ if ( (MHD_SIZE_UNKNOWN != response->total_size) && (MHD_HTTP_NO_CONTENT != response->status_code) && (MHD_HTTP_NOT_MODIFIED != response->status_code) && (MHD_HTTP_OK <= response->status_code) && (NULL == have_content_length) && (request->method != MHD_METHOD_CONNECT) ) { /* Here we add a content-length if one is missing; however, for 'connect' methods, the responses MUST NOT include a content-length header *if* the response code is 2xx (in which case we expect there to be no body). Still, as we don't know the response code here in some cases, we simply only force adding a content-length header if this is not a 'connect' or if the response is not empty (which is kind of more sane, because if some crazy application did return content with a 2xx status code, then having a content-length might again be a good idea). Note that the change from 'SHOULD NOT' to 'MUST NOT' is a recent development of the HTTP 1.1 specification. */content_length_len = MHD_snprintf_ (content_length_buf, sizeof (content_length_buf), MHD_HTTP_HEADER_CONTENT_LENGTH ": " MHD_UNSIGNED_LONG_LONG_PRINTF "\r\n", (MHD_UNSIGNED_LONG_LONG) response->total_size); must_add_content_length = true; } /* check for adding keep alive */ if ( (! response_has_keepalive) && (! response_has_close) && (! must_add_close) && (MHD_CONN_MUST_CLOSE != request->keepalive) && #ifdef UPGRADE_SUPPORT (NULL == response->upgrade_handler) && #endif /* UPGRADE_SUPPORT */ (keepalive_possible (request)) ) must_add_keep_alive = true; break; case MHD_REQUEST_BODY_SENT: response_has_keepalive = false; break; default: mhd_assert (0); return MHD_NO; } if (MHD_CONN_MUST_CLOSE != request->keepalive) { if ( (must_add_close) || (response_has_close) ) request->keepalive = MHD_CONN_MUST_CLOSE; else if ( (must_add_keep_alive) || (response_has_keepalive) ) request->keepalive = MHD_CONN_USE_KEEPALIVE; } if (must_add_close) size += MHD_STATICSTR_LEN_ ("Connection: close\r\n"); if (must_add_keep_alive) size += MHD_STATICSTR_LEN_ ("Connection: Keep-Alive\r\n"); if (must_add_chunked_encoding) size += MHD_STATICSTR_LEN_ ("Transfer-Encoding: chunked\r\n"); if (must_add_content_length) size += content_length_len; mhd_assert (! (must_add_close && must_add_keep_alive) ); mhd_assert (! (must_add_chunked_encoding && must_add_content_length) ); for (pos = response->first_header; NULL != pos; pos = pos->next) { /* TODO: add proper support for excluding "Keep-Alive" token. */ if ( (pos->kind == kind) && (! ( (must_add_close) && (response_has_keepalive) && (MHD_str_equal_caseless_ (pos->header, MHD_HTTP_HEADER_CONNECTION)) && (MHD_str_equal_caseless_ (pos->value, "Keep-Alive")) ) ) ) size += strlen (pos->header) + strlen (pos->value) + 4; /* colon, space, linefeeds */ } /* produce data */ data = MHD_pool_allocate (connection->pool, size + 1, MHD_NO); if (NULL == data) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_CONNECTION_POOL_MALLOC_FAILURE, "Not enough memory for write!\n"); #endif return false; } if (MHD_REQUEST_FOOTERS_RECEIVED == request->state) { memcpy (data, code, off); } if (must_add_close) { /* we must add the 'Connection: close' header */ memcpy (&data[off], "Connection: close\r\n", MHD_STATICSTR_LEN_ ("Connection: close\r\n")); off += MHD_STATICSTR_LEN_ ("Connection: close\r\n"); } if (must_add_keep_alive) { /* we must add the 'Connection: Keep-Alive' header */ memcpy (&data[off], "Connection: Keep-Alive\r\n", MHD_STATICSTR_LEN_ ("Connection: Keep-Alive\r\n")); off += MHD_STATICSTR_LEN_ ("Connection: Keep-Alive\r\n"); } if (must_add_chunked_encoding) { /* we must add the 'Transfer-Encoding: chunked' header */ memcpy (&data[off], "Transfer-Encoding: chunked\r\n", MHD_STATICSTR_LEN_ ("Transfer-Encoding: chunked\r\n")); off += MHD_STATICSTR_LEN_ ("Transfer-Encoding: chunked\r\n"); } if (must_add_content_length) { /* we must add the 'Content-Length' header */ memcpy (&data[off], content_length_buf, content_length_len); off += content_length_len; } for (pos = response->first_header; NULL != pos; pos = pos->next) { /* TODO: add proper support for excluding "Keep-Alive" token. */ if ( (pos->kind == kind) && (! ( (must_add_close) && (response_has_keepalive) && (MHD_str_equal_caseless_ (pos->header, MHD_HTTP_HEADER_CONNECTION)) && (MHD_str_equal_caseless_ (pos->value, "Keep-Alive")) ) ) ) off += MHD_snprintf_ (&data[off], size - off, "%s: %s\r\n", pos->header, pos->value); } if (MHD_REQUEST_FOOTERS_RECEIVED == request->state) { memcpy (&data[off], date, datelen); off += datelen; } memcpy (&data[off], "\r\n", 2); off += 2; if (off != size) mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); request->write_buffer = data; request->write_buffer_append_offset = size; request->write_buffer_send_offset = 0; request->write_buffer_size = size + 1; return true; } /** * We encountered an error processing the request. Handle it properly * by stopping to read data and sending the indicated response code * and message. * * @param request the request * @param ec error code for MHD * @param status_code the response code to send (400, 413 or 414) * @param message the error message to send */ static void transmit_error_response (struct MHD_Request *request, enum MHD_StatusCode ec, enum MHD_HTTP_StatusCode status_code, const char *message) { struct MHD_Response *response; if (NULL == request->version_s) { /* we were unable to process the full header line, so we don't really know what version the client speaks; assume 1.0 */ request->version_s = MHD_HTTP_VERSION_1_0; } request->state = MHD_REQUEST_FOOTERS_RECEIVED; request->connection->read_closed = true; #ifdef HAVE_MESSAGES MHD_DLOG (request->daemon, ec, _ ( "Error processing request (HTTP response code is %u (`%s')). Closing connection.\n"), status_code, message); #endif if (NULL != request->response) { MHD_response_queue_for_destroy (request->response); request->response = NULL; } response = MHD_response_from_buffer (status_code, strlen (message), (void *) message, MHD_RESPMEM_PERSISTENT); request->response = response; /* Do not reuse this connection. */ request->keepalive = MHD_CONN_MUST_CLOSE; if (! build_header_response (request)) { /* oops - close! */ CONNECTION_CLOSE_ERROR (request->connection, ec, _ ( "Closing connection (failed to create response header).\n")); } else { request->state = MHD_REQUEST_HEADERS_SENDING; } } /** * Convert @a method to the respective enum value. * * @param method the method string to look up enum value for * @return resulting enum, or generic value for "unknown" */ static enum MHD_Method method_string_to_enum (const char *method) { static const struct { const char *key; enum MHD_Method value; } methods[] = { { "OPTIONS", MHD_METHOD_OPTIONS }, { "GET", MHD_METHOD_GET }, { "HEAD", MHD_METHOD_HEAD }, { "POST", MHD_METHOD_POST }, { "PUT", MHD_METHOD_PUT }, { "DELETE", MHD_METHOD_DELETE }, { "TRACE", MHD_METHOD_TRACE }, { "CONNECT", MHD_METHOD_CONNECT }, { "ACL", MHD_METHOD_ACL }, { "BASELINE_CONTROL", MHD_METHOD_BASELINE_CONTROL }, { "BIND", MHD_METHOD_BIND }, { "CHECKIN", MHD_METHOD_CHECKIN }, { "CHECKOUT", MHD_METHOD_CHECKOUT }, { "COPY", MHD_METHOD_COPY }, { "LABEL", MHD_METHOD_LABEL }, { "LINK", MHD_METHOD_LINK }, { "LOCK", MHD_METHOD_LOCK }, { "MERGE", MHD_METHOD_MERGE }, { "MKACTIVITY", MHD_METHOD_MKACTIVITY }, { "MKCOL", MHD_METHOD_MKCOL }, { "MKREDIRECTREF", MHD_METHOD_MKREDIRECTREF }, { "MKWORKSPACE", MHD_METHOD_MKWORKSPACE }, { "MOVE", MHD_METHOD_MOVE }, { "ORDERPATCH", MHD_METHOD_ORDERPATCH }, { "PRI", MHD_METHOD_PRI }, { "PROPFIND", MHD_METHOD_PROPFIND }, { "PROPPATCH", MHD_METHOD_PROPPATCH }, { "REBIND", MHD_METHOD_REBIND }, { "REPORT", MHD_METHOD_REPORT }, { "SEARCH", MHD_METHOD_SEARCH }, { "UNBIND", MHD_METHOD_UNBIND }, { "UNCHECKOUT", MHD_METHOD_UNCHECKOUT }, { "UNLINK", MHD_METHOD_UNLINK }, { "UNLOCK", MHD_METHOD_UNLOCK }, { "UPDATE", MHD_METHOD_UPDATE }, { "UPDATEDIRECTREF", MHD_METHOD_UPDATEDIRECTREF }, { "VERSION-CONTROL", MHD_METHOD_VERSION_CONTROL }, { NULL, MHD_METHOD_UNKNOWN } /* must be last! */ }; unsigned int i; for (i = 0; NULL != methods[i].key; i++) if (0 == MHD_str_equal_caseless_ (method, methods[i].key)) return methods[i].value; return MHD_METHOD_UNKNOWN; } /** * Add an entry to the HTTP headers of a request. If this fails, * transmit an error response (request too big). * * @param request the request for which a value should be set * @param kind kind of the value * @param key key for the value * @param value the value itself * @return false on failure (out of memory), true for success */ static bool request_add_header (struct MHD_Request *request, const char *key, const char *value, enum MHD_ValueKind kind) { if (MHD_NO == MHD_request_set_value (request, kind, key, value)) { #ifdef HAVE_MESSAGES MHD_DLOG (request->daemon, MHD_SC_CONNECTION_POOL_MALLOC_FAILURE, _ ("Not enough memory in pool to allocate header record!\n")); #endif transmit_error_response (request, MHD_SC_CLIENT_HEADER_TOO_BIG, MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, REQUEST_TOO_BIG); return false; } return true; } /** * Parse the first line of the HTTP HEADER. * * @param connection the connection (updated) * @param line the first line, not 0-terminated * @param line_len length of the first @a line * @return true if the line is ok, false if it is malformed */ static bool parse_initial_message_line (struct MHD_Request *request, char *line, size_t line_len) { struct MHD_Daemon *daemon = request->daemon; const char *curi; char *uri; char *http_version; char *args; unsigned int unused_num_headers; size_t url_end; if (NULL == (uri = memchr (line, ' ', line_len))) return false; /* serious error */ uri[0] = '\0'; request->method_s = line; request->method = method_string_to_enum (line); uri++; /* Skip any spaces. Not required by standard but allow to be more tolerant. */ while ( (' ' == uri[0]) && ( (size_t) (uri - line) < line_len) ) uri++; if ((size_t) (uri - line) == line_len) { curi = ""; uri = NULL; request->version_s = ""; args = NULL; url_end = line_len - (line - uri); // EH, this is garbage. FIXME! } else { curi = uri; /* Search from back to accept malformed URI with space */ http_version = line + line_len - 1; /* Skip any trailing spaces */ while ( (' ' == http_version[0]) && (http_version > uri) ) http_version--; /* Find first space in reverse direction */ while ( (' ' != http_version[0]) && (http_version > uri) ) http_version--; if (http_version > uri) { http_version[0] = '\0'; request->version_s = http_version + 1; args = memchr (uri, '?', http_version - uri); } else { request->version_s = ""; args = memchr (uri, '?', line_len - (uri - line)); } url_end = http_version - uri; } if ( (MHD_PSL_STRICT == daemon->protocol_strict_level) && (NULL != memchr (curi, ' ', url_end)) ) { /* space exists in URI and we are supposed to be strict, reject */ return MHD_NO; } if (NULL != daemon->early_uri_logger_cb) { request->client_context = daemon->early_uri_logger_cb (daemon->early_uri_logger_cb_cls, curi, request); } if (NULL != args) { args[0] = '\0'; args++; /* note that this call clobbers 'args' */ MHD_parse_arguments_ (request, MHD_GET_ARGUMENT_KIND, args, &request_add_header, &unused_num_headers); } if (NULL != uri) daemon->unescape_cb (daemon->unescape_cb_cls, request, uri); request->url = curi; return true; } /** * We have received (possibly the beginning of) a line in the * header (or footer). Validate (check for ":") and prepare * to process. * * @param request the request we're processing * @param line line from the header to process * @return true on success, false on error (malformed @a line) */ static bool process_header_line (struct MHD_Request *request, char *line) { struct MHD_Connection *connection = request->connection; char *colon; /* line should be normal header line, find colon */ colon = strchr (line, ':'); if (NULL == colon) { /* error in header line, die hard */ CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_PARSE_FAIL_CLOSED, _ ( "Received malformed line (no colon). Closing connection.\n")); return false; } if (MHD_PSL_PERMISSIVE != request->daemon->protocol_strict_level) { /* check for whitespace before colon, which is not allowed by RFC 7230 section 3.2.4; we count space ' ' and tab '\t', but not '\r\n' as those would have ended the line. */ const char *white; white = strchr (line, (unsigned char) ' '); if ( (NULL != white) && (white < colon) ) { CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_PARSE_FAIL_CLOSED, _ ( "Whitespace before colon forbidden by RFC 7230. Closing connection.\n")); return false; } white = strchr (line, (unsigned char) '\t'); if ( (NULL != white) && (white < colon) ) { CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_PARSE_FAIL_CLOSED, _ ( "Tab before colon forbidden by RFC 7230. Closing connection.\n")); return false; } } /* zero-terminate header */ colon[0] = '\0'; colon++; /* advance to value */ while ( ('\0' != colon[0]) && ( (' ' == colon[0]) || ('\t' == colon[0]) ) ) colon++; /* we do the actual adding of the connection header at the beginning of the while loop since we need to be able to inspect the *next* header line (in case it starts with a space...) */request->last = line; request->colon = colon; return true; } /** * Process a header value that spans multiple lines. * The previous line(s) are in connection->last. * * @param request the request we're processing * @param line the current input line * @param kind if the line is complete, add a header * of the given kind * @return true if the line was processed successfully */ static bool process_broken_line (struct MHD_Request *request, char *line, enum MHD_ValueKind kind) { struct MHD_Connection *connection = request->connection; char *last; char *tmp; size_t last_len; size_t tmp_len; last = request->last; if ( (' ' == line[0]) || ('\t' == line[0]) ) { /* value was continued on the next line, see http://www.jmarshall.com/easy/http/ */ last_len = strlen (last); /* skip whitespace at start of 2nd line */ tmp = line; while ( (' ' == tmp[0]) || ('\t' == tmp[0]) ) tmp++; tmp_len = strlen (tmp); /* FIXME: we might be able to do this better (faster!), as most likely 'last' and 'line' should already be adjacent in memory; however, doing this right gets tricky if we have a value continued over multiple lines (in which case we need to record how often we have done this so we can check for adjacency); also, in the case where these are not adjacent (not sure how it can happen!), we would want to allocate from the end of the pool, so as to not destroy the read-buffer's ability to grow nicely. */last = MHD_pool_reallocate (connection->pool, last, last_len + 1, last_len + tmp_len + 1); if (NULL == last) { transmit_error_response (request, MHD_SC_CLIENT_HEADER_TOO_BIG, MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, REQUEST_TOO_BIG); return MHD_NO; } memcpy (&last[last_len], tmp, tmp_len + 1); request->last = last; return MHD_YES; /* possibly more than 2 lines... */ } mhd_assert ( (NULL != last) && (NULL != request->colon) ); if (! request_add_header (request, last, request->colon, kind)) { transmit_error_response (request, MHD_SC_CLIENT_HEADER_TOO_BIG, MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, REQUEST_TOO_BIG); return false; } /* we still have the current line to deal with... */ if ('\0' != line[0]) { if (! process_header_line (request, line)) { transmit_error_response (request, MHD_SC_CONNECTION_PARSE_FAIL_CLOSED, MHD_HTTP_BAD_REQUEST, REQUEST_MALFORMED); return false; } } return true; } /** * Parse a single line of the HTTP header. Advance read_buffer (!) * appropriately. If the current line does not fit, consider growing * the buffer. If the line is far too long, close the connection. If * no line is found (incomplete, buffer too small, line too long), * return NULL. Otherwise return a pointer to the line. * * @param request request we're processing * @param[out] line_len pointer to variable that receive * length of line or NULL * @return NULL if no full line is available; note that the returned * string will not be 0-termianted */ static char * get_next_header_line (struct MHD_Request *request, size_t *line_len) { char *rbuf; size_t pos; if (0 == request->read_buffer_offset) return NULL; pos = 0; rbuf = request->read_buffer; while ( (pos < request->read_buffer_offset - 1) && ('\r' != rbuf[pos]) && ('\n' != rbuf[pos]) ) pos++; if ( (pos == request->read_buffer_offset - 1) && ('\n' != rbuf[pos]) ) { /* not found, consider growing... */ if ( (request->read_buffer_offset == request->read_buffer_size) && (! try_grow_read_buffer (request)) ) { transmit_error_response (request, MHD_SC_CLIENT_HEADER_TOO_BIG, (NULL != request->url) ? MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE : MHD_HTTP_URI_TOO_LONG, REQUEST_TOO_BIG); } if (line_len) *line_len = 0; return NULL; } if (line_len) *line_len = pos; /* found, check if we have proper LFCR */ if ( ('\r' == rbuf[pos]) && ('\n' == rbuf[pos + 1]) ) rbuf[pos++] = '\0'; /* skip both r and n */ rbuf[pos++] = '\0'; request->read_buffer += pos; request->read_buffer_size -= pos; request->read_buffer_offset -= pos; return rbuf; } /** * Check whether is possible to force push socket buffer content as * partial packet. * MHD use different buffering logic depending on whether flushing of * socket buffer is possible or not. * If flushing IS possible than MHD activates extra buffering before * sending data to prevent sending partial packets and flush pending * data in socket buffer to push last partial packet to client after * sending logical completed part of data (for example: after sending * full response header or full response message). * If flushing IS NOT possible than MHD activates no buffering (no * delay sending) when it going to send formed fully completed logical * part of data and activate normal buffering after sending. * For idled keep-alive connection MHD always activate normal * buffering. * * @param connection connection to check * @return true if force push is possible, false otherwise */ static bool socket_flush_possible (struct MHD_Connection *connection) { (void) connection; /* Mute compiler warning. */ #if defined(TCP_CORK) || defined(TCP_PUSH) return true; #else /* !TCP_CORK && !TCP_PUSH */ return false; #endif /* !TCP_CORK && !TCP_PUSH */ } /** * Activate extra buffering mode on connection socket to prevent * sending of partial packets. * * @param connection connection to be processed * @return true on success, false otherwise */ static bool socket_start_extra_buffering (struct MHD_Connection *connection) { bool res = false; (void) connection; /* Mute compiler warning. */ #if defined(TCP_CORK) || defined(TCP_NOPUSH) const MHD_SCKT_OPT_BOOL_ on_val = 1; #if defined(TCP_NODELAY) const MHD_SCKT_OPT_BOOL_ off_val = 0; #endif /* TCP_NODELAY */ mhd_assert (NULL != connection); #if defined(TCP_NOPUSH) && ! defined(TCP_CORK) /* Buffer data before sending */ res = (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NOPUSH, (const void *) &on_val, sizeof (on_val))) ? true : false; #if defined(TCP_NODELAY) /* Enable Nagle's algorithm */ /* TCP_NODELAY may interfere with TCP_NOPUSH */ res &= (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, (const void *) &off_val, sizeof (off_val))) ? true : false; #endif /* TCP_NODELAY */ #else /* TCP_CORK */ #if defined(TCP_NODELAY) /* Enable Nagle's algorithm */ /* TCP_NODELAY may prevent enabling TCP_CORK. Resulting buffering mode depends solely on TCP_CORK result, so ignoring return code here. */ (void) setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, (const void *) &off_val, sizeof (off_val)); #endif /* TCP_NODELAY */ /* Send only full packets */ res = (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, (const void *) &on_val, sizeof (on_val))) ? true : false; #endif /* TCP_CORK */ #endif /* TCP_CORK || TCP_NOPUSH */ return res; } /** * Activate no buffering mode (no delay sending) on connection socket. * * @param connection connection to be processed * @return true on success, false otherwise */ static bool socket_start_no_buffering (struct MHD_Connection *connection) { #if defined(TCP_NODELAY) bool res = true; const MHD_SCKT_OPT_BOOL_ on_val = 1; #if defined(TCP_CORK) || defined(TCP_NOPUSH) const MHD_SCKT_OPT_BOOL_ off_val = 0; #endif /* TCP_CORK || TCP_NOPUSH */ (void) connection; /* Mute compiler warning. */ mhd_assert (NULL != connection); #if defined(TCP_CORK) /* Allow partial packets */ res &= (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, (const void *) &off_val, sizeof (off_val))) ? true : false; #endif /* TCP_CORK */ #if defined(TCP_NODELAY) /* Disable Nagle's algorithm for sending packets without delay */ res &= (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, (const void *) &on_val, sizeof (on_val))) ? true : false; #endif /* TCP_NODELAY */ #if defined(TCP_NOPUSH) && ! defined(TCP_CORK) /* Disable extra buffering */ res &= (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NOPUSH, (const void *) &off_val, sizeof (off_val))) ? true : false; #endif /* TCP_NOPUSH && !TCP_CORK */ return res; #else /* !TCP_NODELAY */ return false; #endif /* !TCP_NODELAY */ } /** * Activate no buffering mode (no delay sending) on connection socket * and push to client data pending in socket buffer. * * @param connection connection to be processed * @return true on success, false otherwise */ static bool socket_start_no_buffering_flush (struct MHD_Connection *connection) { bool res = true; #if defined(TCP_NOPUSH) && ! defined(TCP_CORK) const int dummy = 0; #endif /* !TCP_CORK */ if (NULL == connection) return false; /* FIXME: use MHD_NONNULL? */ res = socket_start_no_buffering (connection); #if defined(TCP_NOPUSH) && ! defined(TCP_CORK) /* Force flush data with zero send otherwise Darwin and some BSD systems will add 5 seconds delay. Not required with TCP_CORK as switching off TCP_CORK always flushes socket buffer. */ res &= (0 <= MHD_send_ (connection->socket_fd, &dummy, 0)) ? true : false; #endif /* TCP_NOPUSH && !TCP_CORK*/ return res; } /** * Activate normal buffering mode on connection socket. * * @param connection connection to be processed * @return true on success, false otherwise */ static bool socket_start_normal_buffering (struct MHD_Connection *connection) { #if defined(TCP_NODELAY) bool res = true; const MHD_SCKT_OPT_BOOL_ off_val = 0; #if defined(TCP_CORK) MHD_SCKT_OPT_BOOL_ cork_val = 0; socklen_t param_size = sizeof (cork_val); #endif /* TCP_CORK */ mhd_assert (NULL != connection); #if defined(TCP_CORK) /* Allow partial packets */ /* Disabling TCP_CORK will flush partial packet even if TCP_CORK wasn't enabled before so try to check current value of TCP_CORK to prevent unrequested flushing */ if ( (0 != getsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, (void *) &cork_val, ¶m_size)) || (0 != cork_val)) res &= (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, (const void *) &off_val, sizeof (off_val))) ? true : false; #elif defined(TCP_NOPUSH) /* Disable extra buffering */ /* No need to check current value as disabling TCP_NOPUSH will not flush partial packet if TCP_NOPUSH wasn't enabled before */ res &= (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NOPUSH, (const void *) &off_val, sizeof (off_val))) ? true : false; #endif /* TCP_NOPUSH && !TCP_CORK */ /* Enable Nagle's algorithm for normal buffering */ res &= (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, (const void *) &off_val, sizeof (off_val))) ? true : false; return res; #else /* !TCP_NODELAY */ return false; #endif /* !TCP_NODELAY */ } /** * Do we (still) need to send a 100 continue * message for this request? * * @param request the request to test * @return false if we don't need 100 CONTINUE, true if we do */ static bool need_100_continue (struct MHD_Request *request) { const char *expect; return ( (NULL == request->response) && (NULL != request->version_s) && (MHD_str_equal_caseless_ (request->version_s, MHD_HTTP_VERSION_1_1)) && (NULL != (expect = MHD_request_lookup_value (request, MHD_HEADER_KIND, MHD_HTTP_HEADER_EXPECT))) && (MHD_str_equal_caseless_ (expect, "100-continue")) && (request->continue_message_write_offset < MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE)) ); } /** * Parse the cookie header (see RFC 2109). * * @param request request to parse header of * @return true for success, false for failure (malformed, out of memory) */ static int parse_cookie_header (struct MHD_Request *request) { const char *hdr; char *cpy; char *pos; char *sce; char *semicolon; char *equals; char *ekill; char old; int quotes; hdr = MHD_request_lookup_value (request, MHD_HEADER_KIND, MHD_HTTP_HEADER_COOKIE); if (NULL == hdr) return true; cpy = MHD_pool_allocate (request->connection->pool, strlen (hdr) + 1, MHD_YES); if (NULL == cpy) { #ifdef HAVE_MESSAGES MHD_DLOG (request->daemon, MHD_SC_COOKIE_POOL_ALLOCATION_FAILURE, _ ("Not enough memory in pool to parse cookies!\n")); #endif transmit_error_response (request, MHD_SC_COOKIE_POOL_ALLOCATION_FAILURE, MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, REQUEST_TOO_BIG); return false; } memcpy (cpy, hdr, strlen (hdr) + 1); pos = cpy; while (NULL != pos) { while (' ' == *pos) pos++; /* skip spaces */ sce = pos; while ( ((*sce) != '\0') && ((*sce) != ',') && ((*sce) != ';') && ((*sce) != '=') ) sce++; /* remove tailing whitespace (if any) from key */ ekill = sce - 1; while ( (*ekill == ' ') && (ekill >= pos) ) *(ekill--) = '\0'; old = *sce; *sce = '\0'; if (old != '=') { /* value part omitted, use empty string... */ if (! request_add_header (request, pos, "", MHD_COOKIE_KIND)) return false; if (old == '\0') break; pos = sce + 1; continue; } equals = sce + 1; quotes = 0; semicolon = equals; while ( ('\0' != semicolon[0]) && ( (0 != quotes) || ( (';' != semicolon[0]) && (',' != semicolon[0]) ) ) ) { if ('"' == semicolon[0]) quotes = (quotes + 1) & 1; semicolon++; } if ('\0' == semicolon[0]) semicolon = NULL; if (NULL != semicolon) { semicolon[0] = '\0'; semicolon++; } /* remove quotes */ if ( ('"' == equals[0]) && ('"' == equals[strlen (equals) - 1]) ) { equals[strlen (equals) - 1] = '\0'; equals++; } if (! request_add_header (request, pos, equals, MHD_COOKIE_KIND)) return false; pos = semicolon; } return true; } /** * Parse the various headers; figure out the size * of the upload and make sure the headers follow * the protocol. Advance to the appropriate state. * * @param request request we're processing */ static void parse_request_headers (struct MHD_Request *request) { struct MHD_Daemon *daemon = request->daemon; struct MHD_Connection *connection = request->connection; const char *clen; struct MHD_Response *response; const char *enc; const char *end; parse_cookie_header (request); /* FIXME: return value ignored! */ if ( (MHD_PSL_STRICT == daemon->protocol_strict_level) && (NULL != request->version_s) && (MHD_str_equal_caseless_ (MHD_HTTP_VERSION_1_1, request->version_s)) && (NULL == MHD_request_lookup_value (request, MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST)) ) { /* die, http 1.1 request without host and we are pedantic */ request->state = MHD_REQUEST_FOOTERS_RECEIVED; connection->read_closed = true; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_HOST_HEADER_MISSING, _ ("Received HTTP 1.1 request without `Host' header.\n")); #endif mhd_assert (NULL == request->response); response = MHD_response_from_buffer (MHD_HTTP_BAD_REQUEST, MHD_STATICSTR_LEN_ (REQUEST_LACKS_HOST), REQUEST_LACKS_HOST, MHD_RESPMEM_PERSISTENT); request->response = response; // FIXME: state machine advance? return; } request->remaining_upload_size = 0; enc = MHD_request_lookup_value (request, MHD_HEADER_KIND, MHD_HTTP_HEADER_TRANSFER_ENCODING); if (NULL != enc) { request->remaining_upload_size = MHD_SIZE_UNKNOWN; if (MHD_str_equal_caseless_ (enc, "chunked")) request->have_chunked_upload = true; return; } clen = MHD_request_lookup_value (request, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_LENGTH); if (NULL == clen) return; end = clen + MHD_str_to_uint64_ (clen, &request->remaining_upload_size); if ( (clen == end) || ('\0' != *end) ) { request->remaining_upload_size = 0; #ifdef HAVE_MESSAGES MHD_DLOG (request->daemon, MHD_SC_CONTENT_LENGTH_MALFORMED, "Failed to parse `Content-Length' header. Closing connection.\n"); #endif CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONTENT_LENGTH_MALFORMED, NULL); } } /** * Call the handler of the application for this * request. * * @param request request we're processing */ static void call_request_handler (struct MHD_Request *request) { struct MHD_Daemon *daemon = request->daemon; struct MHD_Connection *connection = request->connection; const struct MHD_Action *action; if (NULL != request->response) return; /* already queued a response */ if (NULL == (action = daemon->rc (daemon->rc_cls, request, request->url, request->method))) { /* serious internal error, close connection */ CONNECTION_CLOSE_ERROR (connection, MHD_SC_APPLICATION_CALLBACK_FAILURE_CLOSED, _ ( "Application reported internal error, closing connection.\n")); return; } action->action (action->action_cls, request); } /** * Call the handler of the application for this request. Handles * chunking of the upload as well as normal uploads. * * @param request request we're processing */ static void process_request_body (struct MHD_Request *request) { struct MHD_Daemon *daemon = request->daemon; struct MHD_Connection *connection = request->connection; size_t available; bool instant_retry; char *buffer_head; if (NULL != request->response) return; /* already queued a response */ buffer_head = request->read_buffer; available = request->read_buffer_offset; do { size_t to_be_processed; size_t left_unprocessed; size_t processed_size; instant_retry = false; if ( (request->have_chunked_upload) && (MHD_SIZE_UNKNOWN == request->remaining_upload_size) ) { if ( (request->current_chunk_offset == request->current_chunk_size) && (0LLU != request->current_chunk_offset) && (available >= 2) ) { size_t i; /* skip new line at the *end* of a chunk */ i = 0; if ( ('\r' == buffer_head[i]) || ('\n' == buffer_head[i]) ) i++; /* skip 1st part of line feed */ if ( ('\r' == buffer_head[i]) || ('\n' == buffer_head[i]) ) i++; /* skip 2nd part of line feed */ if (0 == i) { /* malformed encoding */ CONNECTION_CLOSE_ERROR (connection, MHD_SC_CHUNKED_ENCODING_MALFORMED, _ ( "Received malformed HTTP request (bad chunked encoding). Closing connection.\n")); return; } available -= i; buffer_head += i; request->current_chunk_offset = 0; request->current_chunk_size = 0; } if (request->current_chunk_offset < request->current_chunk_size) { uint64_t cur_chunk_left; /* we are in the middle of a chunk, give as much as possible to the client (without crossing chunk boundaries) */ cur_chunk_left = request->current_chunk_size - request->current_chunk_offset; if (cur_chunk_left > available) { to_be_processed = available; } else { /* cur_chunk_left <= (size_t)available */ to_be_processed = (size_t) cur_chunk_left; if (available > to_be_processed) instant_retry = true; } } else { size_t i; size_t end_size; bool malformed; /* we need to read chunk boundaries */ i = 0; while (i < available) { if ( ('\r' == buffer_head[i]) || ('\n' == buffer_head[i]) || (';' == buffer_head[i]) ) break; i++; if (i >= 16) break; } end_size = i; /* find beginning of CRLF (skip over chunk extensions) */ if (';' == buffer_head[i]) { while (i < available) { if ( ('\r' == buffer_head[i]) || ('\n' == buffer_head[i]) ) break; i++; } } /* take '\n' into account; if '\n' is the unavailable character, we will need to wait until we have it before going further */ if ( (i + 1 >= available) && ! ( (1 == i) && (2 == available) && ('0' == buffer_head[0]) ) ) break; /* need more data... */ i++; malformed = (end_size >= 16); if (! malformed) { size_t num_dig = MHD_strx_to_uint64_n_ (buffer_head, end_size, &request->current_chunk_size); malformed = (end_size != num_dig); } if (malformed) { /* malformed encoding */ CONNECTION_CLOSE_ERROR (connection, MHD_SC_CHUNKED_ENCODING_MALFORMED, _ ( "Received malformed HTTP request (bad chunked encoding). Closing connection.\n")); return; } /* skip 2nd part of line feed */ if ( (i < available) && ( ('\r' == buffer_head[i]) || ('\n' == buffer_head[i]) ) ) i++; buffer_head += i; available -= i; request->current_chunk_offset = 0; if (available > 0) instant_retry = true; if (0LLU == request->current_chunk_size) { request->remaining_upload_size = 0; break; } continue; } } else { /* no chunked encoding, give all to the client */ if ( (0 != request->remaining_upload_size) && (MHD_SIZE_UNKNOWN != request->remaining_upload_size) && (request->remaining_upload_size < available) ) { to_be_processed = (size_t) request->remaining_upload_size; } else { /** * 1. no chunked encoding, give all to the client * 2. client may send large chunked data, but only a smaller part is available at one time. */ to_be_processed = available; } } left_unprocessed = to_be_processed; #if FIXME_OLD_STYLE if (MHD_NO == daemon->rc (daemon->rc_cls, request, request->url, request->method, request->version, buffer_head, &left_unprocessed, &request->client_context)) { /* serious internal error, close connection */ CONNECTION_CLOSE_ERROR (connection, MHD_SC_APPLICATION_CALLBACK_FAILURE_CLOSED, _ ( "Application reported internal error, closing connection.\n")); return; } #endif if (left_unprocessed > to_be_processed) mhd_panic (mhd_panic_cls, __FILE__, __LINE__ #ifdef HAVE_MESSAGES , _ ("libmicrohttpd API violation.\n") #else , NULL #endif ); if (0 != left_unprocessed) { instant_retry = false; /* client did not process everything */ #ifdef HAVE_MESSAGES /* client did not process all upload data, complain if the setup was incorrect, which may prevent us from handling the rest of the request */ if ( (MHD_TM_EXTERNAL_EVENT_LOOP == daemon->threading_mode) && (! connection->suspended) ) MHD_DLOG (daemon, MHD_SC_APPLICATION_HUNG_CONNECTION, _ ( "WARNING: incomplete upload processing and connection not suspended may result in hung connection.\n")); #endif } processed_size = to_be_processed - left_unprocessed; if (request->have_chunked_upload) request->current_chunk_offset += processed_size; /* dh left "processed" bytes in buffer for next time... */ buffer_head += processed_size; available -= processed_size; if (MHD_SIZE_UNKNOWN != request->remaining_upload_size) request->remaining_upload_size -= processed_size; } while (instant_retry); if (available > 0) memmove (request->read_buffer, buffer_head, available); request->read_buffer_offset = available; } /** * Clean up the state of the given connection and move it into the * clean up queue for final disposal. * @remark To be called only from thread that process connection's * recv(), send() and response. * * @param connection handle for the connection to clean up */ static void cleanup_connection (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; if (connection->request.in_cleanup) return; /* Prevent double cleanup. */ connection->request.in_cleanup = true; if (NULL != connection->request.response) { MHD_response_queue_for_destroy (connection->request.response); connection->request.response = NULL; } MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); if (connection->suspended) { DLL_remove (daemon->suspended_connections_head, daemon->suspended_connections_tail, connection); connection->suspended = false; } else { if (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) { if (connection->connection_timeout == daemon->connection_default_timeout) XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); else XDLL_remove (daemon->manual_timeout_head, daemon->manual_timeout_tail, connection); } DLL_remove (daemon->connections_head, daemon->connections_tail, connection); } DLL_insert (daemon->cleanup_head, daemon->cleanup_tail, connection); connection->resuming = false; connection->request.in_idle = false; MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); if (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) { /* if we were at the connection limit before and are in thread-per-connection mode, signal the main thread to resume accepting connections */ if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "c")) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ITC_USE_FAILED, _ ( "Failed to signal end of connection via inter-thread communication channel.\n")); #endif } } } #ifdef EPOLL_SUPPORT /** * Perform epoll() processing, possibly moving the connection back into * the epoll() set if needed. * * @param connection connection to process * @return true if we should continue to process the * connection (not dead yet), false if it died */ static bool connection_epoll_update_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) && (0 == (connection->epoll_state & MHD_EPOLL_STATE_SUSPENDED)) && ( ( (MHD_EVENT_LOOP_INFO_WRITE == connection->request.event_loop_info) && (0 == (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY))) || ( (MHD_EVENT_LOOP_INFO_READ == connection->request.event_loop_info) && (0 == (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) ) ) ) { /* add to epoll set */ struct epoll_event event; event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET; event.data.ptr = connection; if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, connection->socket_fd, &event)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_EPOLL_CTL_ADD_FAILED, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif connection->request.state = MHD_REQUEST_CLOSED; cleanup_connection (connection); return false; } connection->epoll_state |= MHD_EPOLL_STATE_IN_EPOLL_SET; } return true; } #endif /** * Update the 'event_loop_info' field of this connection based on the * state that the connection is now in. May also close the connection * or perform other updates to the connection if needed to prepare for * the next round of the event loop. * * @param connection connection to get poll set for */ static void connection_update_event_loop_info (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; struct MHD_Request *request = &connection->request; /* Do not update states of suspended connection */ if (connection->suspended) return; /* States will be updated after resume. */ #ifdef HTTPS_SUPPORT { struct MHD_TLS_Plugin *tls; if ( (NULL != (tls = daemon->tls_api)) && (tls->update_event_loop_info (tls->cls, connection->tls_cs, &request->event_loop_info)) ) return; /* TLS has decided what to do */ } #endif /* HTTPS_SUPPORT */ while (1) { #if DEBUG_STATES MHD_DLOG (daemon, MHD_SC_STATE_MACHINE_STATUS_REPORT, _ ("In function %s handling connection at state: %s\n"), __FUNCTION__, MHD_state_to_string (request->state)); #endif switch (request->state) { case MHD_REQUEST_INIT: case MHD_REQUEST_URL_RECEIVED: case MHD_REQUEST_HEADER_PART_RECEIVED: /* while reading headers, we always grow the read buffer if needed, no size-check required */ if ( (request->read_buffer_offset == request->read_buffer_size) && (! try_grow_read_buffer (request)) ) { transmit_error_response (request, MHD_SC_CLIENT_HEADER_TOO_BIG, (NULL != request->url) ? MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE : MHD_HTTP_URI_TOO_LONG, REQUEST_TOO_BIG); continue; } if (! connection->read_closed) request->event_loop_info = MHD_EVENT_LOOP_INFO_READ; else request->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK; break; case MHD_REQUEST_HEADERS_RECEIVED: mhd_assert (0); break; case MHD_REQUEST_HEADERS_PROCESSED: mhd_assert (0); break; case MHD_REQUEST_CONTINUE_SENDING: request->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; break; case MHD_REQUEST_CONTINUE_SENT: if (request->read_buffer_offset == request->read_buffer_size) { if ( (! try_grow_read_buffer (request)) && (MHD_TM_EXTERNAL_EVENT_LOOP != daemon->threading_mode) ) { /* failed to grow the read buffer, and the client which is supposed to handle the received data in a *blocking* fashion (in this mode) did not handle the data as it was supposed to! => we would either have to do busy-waiting (on the client, which would likely fail), or if we do nothing, we would just timeout on the connection (if a timeout is even set!). Solution: we kill the connection with an error */transmit_error_response (request, MHD_SC_APPLICATION_HUNG_CONNECTION_CLOSED, MHD_HTTP_INTERNAL_SERVER_ERROR, INTERNAL_ERROR); continue; } } if ( (request->read_buffer_offset < request->read_buffer_size) && (! connection->read_closed) ) request->event_loop_info = MHD_EVENT_LOOP_INFO_READ; else request->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK; break; case MHD_REQUEST_BODY_RECEIVED: case MHD_REQUEST_FOOTER_PART_RECEIVED: /* while reading footers, we always grow the read buffer if needed, no size-check required */ if (connection->read_closed) { CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_READ_FAIL_CLOSED, NULL); continue; } request->event_loop_info = MHD_EVENT_LOOP_INFO_READ; /* transition to FOOTERS_RECEIVED happens in read handler */ break; case MHD_REQUEST_FOOTERS_RECEIVED: request->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK; break; case MHD_REQUEST_HEADERS_SENDING: /* headers in buffer, keep writing */ request->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; break; case MHD_REQUEST_HEADERS_SENT: mhd_assert (0); break; case MHD_REQUEST_NORMAL_BODY_READY: request->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; break; case MHD_REQUEST_NORMAL_BODY_UNREADY: request->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK; break; case MHD_REQUEST_CHUNKED_BODY_READY: request->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; break; case MHD_REQUEST_CHUNKED_BODY_UNREADY: request->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK; break; case MHD_REQUEST_BODY_SENT: mhd_assert (0); break; case MHD_REQUEST_FOOTERS_SENDING: request->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; break; case MHD_REQUEST_FOOTERS_SENT: mhd_assert (0); break; case MHD_REQUEST_CLOSED: request->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; return; /* do nothing, not even reading */ #ifdef UPGRADE_SUPPORT case MHD_REQUEST_UPGRADE: mhd_assert (0); break; #endif /* UPGRADE_SUPPORT */ default: mhd_assert (0); } break; } } /** * This function was created to handle per-request processing that * has to happen even if the socket cannot be read or written to. * @remark To be called only from thread that process request's * recv(), send() and response. * * @param request the request to handle * @return true if we should continue to process the * request (not dead yet), false if it died */ bool MHD_request_handle_idle_ (struct MHD_Request *request) { struct MHD_Daemon *daemon = request->daemon; struct MHD_Connection *connection = request->connection; char *line; size_t line_len; bool ret; request->in_idle = true; while (! connection->suspended) { #ifdef HTTPS_SUPPORT struct MHD_TLS_Plugin *tls; if ( (NULL != (tls = daemon->tls_api)) && (! tls->idle_ready (tls->cls, connection->tls_cs)) ) break; #endif /* HTTPS_SUPPORT */ #if DEBUG_STATES MHD_DLOG (daemon, MHD_SC_STATE_MACHINE_STATUS_REPORT, _ ("In function %s handling connection at state: %s\n"), __FUNCTION__, MHD_state_to_string (request->state)); #endif switch (request->state) { case MHD_REQUEST_INIT: line = get_next_header_line (request, &line_len); /* Check for empty string, as we might want to tolerate 'spurious' empty lines; also NULL means we didn't get a full line yet; line is not 0-terminated here. */ if ( (NULL == line) || (0 == line[0]) ) { if (MHD_REQUEST_INIT != request->state) continue; if (connection->read_closed) { CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_READ_FAIL_CLOSED, NULL); continue; } break; } if (MHD_NO == parse_initial_message_line (request, line, line_len)) CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_CLOSED, NULL); else request->state = MHD_REQUEST_URL_RECEIVED; continue; case MHD_REQUEST_URL_RECEIVED: line = get_next_header_line (request, NULL); if (NULL == line) { if (MHD_REQUEST_URL_RECEIVED != request->state) continue; if (connection->read_closed) { CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_READ_FAIL_CLOSED, NULL); continue; } break; } if (0 == line[0]) { request->state = MHD_REQUEST_HEADERS_RECEIVED; request->header_size = (size_t) (line - request->read_buffer); continue; } if (! process_header_line (request, line)) { transmit_error_response (request, MHD_SC_CONNECTION_PARSE_FAIL_CLOSED, MHD_HTTP_BAD_REQUEST, REQUEST_MALFORMED); break; } request->state = MHD_REQUEST_HEADER_PART_RECEIVED; continue; case MHD_REQUEST_HEADER_PART_RECEIVED: line = get_next_header_line (request, NULL); if (NULL == line) { if (request->state != MHD_REQUEST_HEADER_PART_RECEIVED) continue; if (connection->read_closed) { CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_READ_FAIL_CLOSED, NULL); continue; } break; } if (MHD_NO == process_broken_line (request, line, MHD_HEADER_KIND)) continue; if (0 == line[0]) { request->state = MHD_REQUEST_HEADERS_RECEIVED; request->header_size = (size_t) (line - request->read_buffer); continue; } continue; case MHD_REQUEST_HEADERS_RECEIVED: parse_request_headers (request); if (MHD_REQUEST_CLOSED == request->state) continue; request->state = MHD_REQUEST_HEADERS_PROCESSED; if (connection->suspended) break; continue; case MHD_REQUEST_HEADERS_PROCESSED: call_request_handler (request); /* first call */ if (MHD_REQUEST_CLOSED == request->state) continue; if (need_100_continue (request)) { request->state = MHD_REQUEST_CONTINUE_SENDING; if (socket_flush_possible (connection)) socket_start_extra_buffering (connection); else socket_start_no_buffering (connection); break; } if ( (NULL != request->response) && ( (MHD_METHOD_POST == request->method) || (MHD_METHOD_PUT == request->method) ) ) { /* we refused (no upload allowed!) */ request->remaining_upload_size = 0; /* force close, in case client still tries to upload... */ connection->read_closed = true; } request->state = (0 == request->remaining_upload_size) ? MHD_REQUEST_FOOTERS_RECEIVED : MHD_REQUEST_CONTINUE_SENT; if (connection->suspended) break; continue; case MHD_REQUEST_CONTINUE_SENDING: if (request->continue_message_write_offset == MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE)) { request->state = MHD_REQUEST_CONTINUE_SENT; if (! socket_flush_possible (connection)) socket_start_no_buffering_flush (connection); else socket_start_normal_buffering (connection); continue; } break; case MHD_REQUEST_CONTINUE_SENT: if (0 != request->read_buffer_offset) { process_request_body (request); /* loop call */ if (MHD_REQUEST_CLOSED == request->state) continue; } if ( (0 == request->remaining_upload_size) || ( (MHD_SIZE_UNKNOWN == request->remaining_upload_size) && (0 == request->read_buffer_offset) && (connection->read_closed) ) ) { if ( (request->have_chunked_upload) && (! connection->read_closed) ) request->state = MHD_REQUEST_BODY_RECEIVED; else request->state = MHD_REQUEST_FOOTERS_RECEIVED; if (connection->suspended) break; continue; } break; case MHD_REQUEST_BODY_RECEIVED: line = get_next_header_line (request, NULL); if (NULL == line) { if (request->state != MHD_REQUEST_BODY_RECEIVED) continue; if (connection->read_closed) { CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_CLOSED, NULL); continue; } break; } if (0 == line[0]) { request->state = MHD_REQUEST_FOOTERS_RECEIVED; if (connection->suspended) break; continue; } if (MHD_NO == process_header_line (request, line)) { transmit_error_response (request, MHD_SC_CONNECTION_PARSE_FAIL_CLOSED, MHD_HTTP_BAD_REQUEST, REQUEST_MALFORMED); break; } request->state = MHD_REQUEST_FOOTER_PART_RECEIVED; continue; case MHD_REQUEST_FOOTER_PART_RECEIVED: line = get_next_header_line (request, NULL); if (NULL == line) { if (request->state != MHD_REQUEST_FOOTER_PART_RECEIVED) continue; if (connection->read_closed) { CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_CLOSED, NULL); continue; } break; } if (MHD_NO == process_broken_line (request, line, MHD_FOOTER_KIND)) continue; if (0 == line[0]) { request->state = MHD_REQUEST_FOOTERS_RECEIVED; if (connection->suspended) break; continue; } continue; case MHD_REQUEST_FOOTERS_RECEIVED: call_request_handler (request); /* "final" call */ if (request->state == MHD_REQUEST_CLOSED) continue; if (NULL == request->response) break; /* try again next time */ if (! build_header_response (request)) { /* oops - close! */ CONNECTION_CLOSE_ERROR (connection, MHD_SC_FAILED_RESPONSE_HEADER_GENERATION, _ ( "Closing connection (failed to create response header).\n")); continue; } request->state = MHD_REQUEST_HEADERS_SENDING; if (MHD_NO != socket_flush_possible (connection)) socket_start_extra_buffering (connection); else socket_start_no_buffering (connection); break; case MHD_REQUEST_HEADERS_SENDING: /* no default action */ break; case MHD_REQUEST_HEADERS_SENT: /* Some clients may take some actions right after header receive */ if (MHD_NO != socket_flush_possible (connection)) socket_start_no_buffering_flush (connection); #ifdef UPGRADE_SUPPORT if (NULL != request->response->upgrade_handler) { socket_start_normal_buffering (connection); request->state = MHD_REQUEST_UPGRADE; #if FIXME_LEGACY_STYLE /* This request is "upgraded". Pass socket to application. */ if (! MHD_response_execute_upgrade_ (request->response, request)) { /* upgrade failed, fail hard */ CONNECTION_CLOSE_ERROR (connection, MHD_SC_CONNECTION_CLOSED, NULL); continue; } #endif /* Response is not required anymore for this request. */ { struct MHD_Response *const resp = request->response; request->response = NULL; MHD_response_queue_for_destroy (resp); } continue; } #endif /* UPGRADE_SUPPORT */ if (MHD_NO != socket_flush_possible (connection)) socket_start_extra_buffering (connection); else socket_start_normal_buffering (connection); if (request->have_chunked_upload) request->state = MHD_REQUEST_CHUNKED_BODY_UNREADY; else request->state = MHD_REQUEST_NORMAL_BODY_UNREADY; continue; case MHD_REQUEST_NORMAL_BODY_READY: /* nothing to do here */ break; case MHD_REQUEST_NORMAL_BODY_UNREADY: if (NULL != request->response->crc) MHD_mutex_lock_chk_ (&request->response->mutex); if (0 == request->response->total_size) { if (NULL != request->response->crc) MHD_mutex_unlock_chk_ (&request->response->mutex); request->state = MHD_REQUEST_BODY_SENT; continue; } if (try_ready_normal_body (request)) { if (NULL != request->response->crc) MHD_mutex_unlock_chk_ (&request->response->mutex); request->state = MHD_REQUEST_NORMAL_BODY_READY; /* Buffering for flushable socket was already enabled*/ if (MHD_NO == socket_flush_possible (connection)) socket_start_no_buffering (connection); break; } /* mutex was already unlocked by "try_ready_normal_body */ /* not ready, no socket action */ break; case MHD_REQUEST_CHUNKED_BODY_READY: /* nothing to do here */ break; case MHD_REQUEST_CHUNKED_BODY_UNREADY: if (NULL != request->response->crc) MHD_mutex_lock_chk_ (&request->response->mutex); if ( (0 == request->response->total_size) || (request->response_write_position == request->response->total_size) ) { if (NULL != request->response->crc) MHD_mutex_unlock_chk_ (&request->response->mutex); request->state = MHD_REQUEST_BODY_SENT; continue; } if (try_ready_chunked_body (request)) { if (NULL != request->response->crc) MHD_mutex_unlock_chk_ (&request->response->mutex); request->state = MHD_REQUEST_CHUNKED_BODY_READY; /* Buffering for flushable socket was already enabled */ if (MHD_NO == socket_flush_possible (connection)) socket_start_no_buffering (connection); continue; } /* mutex was already unlocked by try_ready_chunked_body */ break; case MHD_REQUEST_BODY_SENT: if (! build_header_response (request)) { /* oops - close! */ CONNECTION_CLOSE_ERROR (connection, MHD_SC_FAILED_RESPONSE_HEADER_GENERATION, _ ( "Closing connection (failed to create response header).\n")); continue; } if ( (! request->have_chunked_upload) || (request->write_buffer_send_offset == request->write_buffer_append_offset) ) request->state = MHD_REQUEST_FOOTERS_SENT; else request->state = MHD_REQUEST_FOOTERS_SENDING; continue; case MHD_REQUEST_FOOTERS_SENDING: /* no default action */ break; case MHD_REQUEST_FOOTERS_SENT: { struct MHD_Response *response = request->response; if (MHD_HTTP_PROCESSING == response->status_code) { /* After this type of response, we allow sending another! */ request->state = MHD_REQUEST_HEADERS_PROCESSED; MHD_response_queue_for_destroy (response); request->response = NULL; /* FIXME: maybe partially reset memory pool? */ continue; } if (socket_flush_possible (connection)) socket_start_no_buffering_flush (connection); else socket_start_normal_buffering (connection); if (NULL != response->termination_cb) { response->termination_cb (response->termination_cb_cls, MHD_REQUEST_TERMINATED_COMPLETED_OK, request->client_context); } MHD_response_queue_for_destroy (response); request->response = NULL; } if ( (MHD_CONN_USE_KEEPALIVE != request->keepalive) || (connection->read_closed) ) { /* have to close for some reason */ MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_COMPLETED_OK); MHD_pool_destroy (connection->pool); connection->pool = NULL; request->read_buffer = NULL; request->read_buffer_size = 0; request->read_buffer_offset = 0; } else { /* can try to keep-alive */ if (socket_flush_possible (connection)) socket_start_normal_buffering (connection); request->version_s = NULL; request->state = MHD_REQUEST_INIT; request->last = NULL; request->colon = NULL; request->header_size = 0; request->keepalive = MHD_CONN_KEEPALIVE_UNKOWN; /* Reset the read buffer to the starting size, preserving the bytes we have already read. */ request->read_buffer = MHD_pool_reset (connection->pool, request->read_buffer, request->read_buffer_offset, daemon->connection_memory_limit_b / 2); request->read_buffer_size = daemon->connection_memory_limit_b / 2; } // FIXME: this is too much, NULLs out some of the things // initialized above... memset (request, 0, sizeof (struct MHD_Request)); request->daemon = daemon; request->connection = connection; continue; case MHD_REQUEST_CLOSED: cleanup_connection (connection); request->in_idle = false; return false; #ifdef UPGRADE_SUPPORT case MHD_REQUEST_UPGRADE: request->in_idle = false; return true; /* keep open */ #endif /* UPGRADE_SUPPORT */ default: mhd_assert (0); break; } break; } if (! connection->suspended) { time_t timeout; timeout = connection->connection_timeout; if ( (0 != timeout) && (timeout <= (MHD_monotonic_sec_counter () - connection->last_activity)) ) { MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); request->in_idle = false; return true; } } connection_update_event_loop_info (connection); ret = true; #ifdef EPOLL_SUPPORT if ( (! connection->suspended) && (MHD_ELS_EPOLL == daemon->event_loop_syscall) ) { ret = connection_epoll_update_ (connection); } #endif /* EPOLL_SUPPORT */ request->in_idle = false; return ret; } /** * Call the handlers for a connection in the appropriate order based * on the readiness as detected by the event loop. * * @param con connection to handle * @param read_ready set if the socket is ready for reading * @param write_ready set if the socket is ready for writing * @param force_close set if a hard error was detected on the socket; * if this information is not available, simply pass #MHD_NO * @return #MHD_YES to continue normally, * #MHD_NO if a serious error was encountered and the * connection is to be closed. */ // FIXME: rename connection->request? int MHD_connection_call_handlers_ (struct MHD_Connection *con, bool read_ready, bool write_ready, bool force_close) { struct MHD_Daemon *daemon = con->daemon; int ret; bool states_info_processed = false; /* Fast track flag */ bool on_fasttrack = (con->request.state == MHD_REQUEST_INIT); #ifdef HTTPS_SUPPORT if (con->tls_read_ready) read_ready = true; #endif /* HTTPS_SUPPORT */ if (! force_close) { if ( (MHD_EVENT_LOOP_INFO_READ == con->request.event_loop_info) && read_ready) { MHD_request_handle_read_ (&con->request); ret = MHD_request_handle_idle_ (&con->request); states_info_processed = true; } /* No need to check value of 'ret' here as closed connection * cannot be in MHD_EVENT_LOOP_INFO_WRITE state. */ if ( (MHD_EVENT_LOOP_INFO_WRITE == con->request.event_loop_info) && write_ready) { MHD_request_handle_write_ (&con->request); ret = MHD_request_handle_idle_ (&con->request); states_info_processed = true; } } else { MHD_connection_close_ (con, MHD_REQUEST_TERMINATED_WITH_ERROR); return MHD_request_handle_idle_ (&con->request); } if (! states_info_processed) { /* Connection is not read or write ready, but external conditions * may be changed and need to be processed. */ ret = MHD_request_handle_idle_ (&con->request); } /* Fast track for fast connections. */ /* If full request was read by single read_handler() invocation and headers were completely prepared by single MHD_request_handle_idle_() then try not to wait for next sockets polling and send response immediately. As writeability of socket was not checked and it may have some data pending in system buffers, use this optimization only for non-blocking sockets. *//* No need to check 'ret' as connection is always in * MHD_CONNECTION_CLOSED state if 'ret' is equal 'MHD_NO'. */else if (on_fasttrack && con->sk_nonblck) { if (MHD_REQUEST_HEADERS_SENDING == con->request.state) { MHD_request_handle_write_ (&con->request); /* Always call 'MHD_request_handle_idle_()' after each read/write. */ ret = MHD_request_handle_idle_ (&con->request); } /* If all headers were sent by single write_handler() and * response body is prepared by single MHD_request_handle_idle_() * call - continue. */ if ((MHD_REQUEST_NORMAL_BODY_READY == con->request.state) || (MHD_REQUEST_CHUNKED_BODY_READY == con->request.state)) { MHD_request_handle_write_ (&con->request); ret = MHD_request_handle_idle_ (&con->request); } } /* All connection's data and states are processed for this turn. * If connection already has more data to be processed - use * zero timeout for next select()/poll(). */ /* Thread-per-connection do not need global zero timeout as * connections are processed individually. */ /* Note: no need to check for read buffer availability for * TLS read-ready connection in 'read info' state as connection * without space in read buffer will be market as 'info block'. */ if ( (! daemon->data_already_pending) && (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) ) { if (MHD_EVENT_LOOP_INFO_BLOCK == con->request.event_loop_info) daemon->data_already_pending = true; #ifdef HTTPS_SUPPORT else if ( (con->tls_read_ready) && (MHD_EVENT_LOOP_INFO_READ == con->request.event_loop_info) ) daemon->data_already_pending = true; #endif /* HTTPS_SUPPORT */ } return ret; } /* end of connection_call_handlers.c */ libmicrohttpd-1.0.1/src/lib/tsearch.c0000644000175000017500000000676614417460232013212 /* * Tree search generalized from Knuth (6.2.2) Algorithm T just like * the AT&T man page says. * * The node_t structure is for internal use only, lint doesn't grok it. * * Written by reading the System V Interface Definition, not the code. * * Totally public domain. */ #include "tsearch.h" #include typedef struct node { const void *key; struct node *llink; struct node *rlink; } node_t; /* $NetBSD: tsearch.c,v 1.5 2005/11/29 03:12:00 christos Exp $ */ /* find or insert datum into search tree */ void * tsearch (const void *vkey, /* key to be located */ void **vrootp, /* address of tree root */ int (*compar)(const void *, const void *)) { node_t *q; node_t **rootp = (node_t **) vrootp; if (NULL == rootp) return NULL; while (*rootp != NULL) { /* Knuth's T1: */ int r; if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */ return *rootp; /* we found it! */ rootp = (r < 0) ? &(*rootp)->llink : /* T3: follow left branch */ &(*rootp)->rlink; /* T4: follow right branch */ } q = malloc (sizeof(node_t)); /* T5: key not found */ if (q) { /* make new node */ *rootp = q; /* link new node to old */ q->key = vkey; /* initialize new node */ q->llink = q->rlink = NULL; } return q; } /* $NetBSD: tfind.c,v 1.5 2005/03/23 08:16:53 kleink Exp $ */ /* find a node, or return NULL */ void * tfind (const void *vkey, /* key to be found */ void *const *vrootp, /* address of the tree root */ int (*compar)(const void *, const void *)) { node_t *const *rootp = (node_t *const *) vrootp; if (NULL == rootp) return NULL; while (*rootp != NULL) { /* T1: */ int r; if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */ return *rootp; /* key found */ rootp = (r < 0) ? &(*rootp)->llink : /* T3: follow left branch */ &(*rootp)->rlink; /* T4: follow right branch */ } return NULL; } /* $NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */ /* * delete node with given key * * vkey: key to be deleted * vrootp: address of the root of the tree * compar: function to carry out node comparisons */ void * tdelete (const void *__restrict vkey, void **__restrict vrootp, int (*compar)(const void *, const void *)) { node_t **rootp = (node_t **) vrootp; node_t *p; node_t *q; node_t *r; int cmp; if ((rootp == NULL) || ((p = *rootp) == NULL)) return NULL; while ((cmp = (*compar)(vkey, (*rootp)->key)) != 0) { p = *rootp; rootp = (cmp < 0) ? &(*rootp)->llink : /* follow llink branch */ &(*rootp)->rlink; /* follow rlink branch */ if (*rootp == NULL) return NULL; /* key not found */ } r = (*rootp)->rlink; /* D1: */ if ((q = (*rootp)->llink) == NULL) /* Left NULL? */ { q = r; } else if (r != NULL) { /* Right link is NULL? */ if (r->llink == NULL) { /* D2: Find successor */ r->llink = q; q = r; } else { /* D3: Find NULL link */ for (q = r->llink; q->llink != NULL; q = r->llink) r = q; r->llink = q->rlink; q->llink = (*rootp)->llink; q->rlink = (*rootp)->rlink; } } free (*rootp); /* D4: Free node */ *rootp = q; /* link parent to new node */ return p; } /* end of tsearch.c */ libmicrohttpd-1.0.1/src/lib/reason_phrase.c0000644000175000017500000000766414417460232014410 /* This file is part of libmicrohttpd Copyright (C) 2007, 2011, 2017 Christian Grothoff, Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file reason_phrase.c * @brief Tables of the string response phrases * @author Elliot Glaysher * @author Christian Grothoff (minor code clean up) * @author Karlson2k (Evgeny Grin) */ #include "internal.h" #ifndef NULL #define NULL ((void*) 0) #endif static const char *const invalid_hundred[] = { NULL }; static const char *const one_hundred[] = { "Continue", "Switching Protocols", "Processing" }; static const char *const two_hundred[] = { "OK", "Created", "Accepted", "Non-Authoritative Information", "No Content", "Reset Content", "Partial Content", "Multi-Status", "Already Reported", "Unknown", "Unknown", /* 210 */ "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", /* 215 */ "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", /* 220 */ "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", /* 225 */ "IM Used" }; static const char *const three_hundred[] = { "Multiple Choices", "Moved Permanently", "Found", "See Other", "Not Modified", "Use Proxy", "Switch Proxy", "Temporary Redirect", "Permanent Redirect" }; static const char *const four_hundred[] = { "Bad Request", "Unauthorized", "Payment Required", "Forbidden", "Not Found", "Method Not Allowed", "Not Acceptable", "Proxy Authentication Required", "Request Timeout", "Conflict", "Gone", "Length Required", "Precondition Failed", "Payload Too Large", "URI Too Long", "Unsupported Media Type", "Range Not Satisfiable", "Expectation Failed", "Unknown", "Unknown", "Unknown", /* 420 */ "Misdirected Request", "Unprocessable Entity", "Locked", "Failed Dependency", "Unordered Collection", "Upgrade Required", "Unknown", "Precondition Required", "Too Many Requests", "Unknown", /* 430 */ "Request Header Fields Too Large", "Unknown", "Unknown", "Unknown", "Unknown", /* 435 */ "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", /* 440 */ "Unknown", "Unknown", "Unknown", "No Response", "Unknown", /* 445 */ "Unknown", "Unknown", "Unknown", "Retry With", "Blocked by Windows Parental Controls", /* 450 */ "Unavailable For Legal Reasons" }; static const char *const five_hundred[] = { "Internal Server Error", "Not Implemented", "Bad Gateway", "Service Unavailable", "Gateway Timeout", "HTTP Version Not Supported", "Variant Also Negotiates", "Insufficient Storage", "Loop Detected", "Bandwidth Limit Exceeded", "Not Extended", "Network Authentication Required" }; struct MHD_Reason_Block { size_t max; const char *const *data; }; #define BLOCK(m) { (sizeof(m) / sizeof(char*)), m } static const struct MHD_Reason_Block reasons[] = { BLOCK (invalid_hundred), BLOCK (one_hundred), BLOCK (two_hundred), BLOCK (three_hundred), BLOCK (four_hundred), BLOCK (five_hundred), }; const char * MHD_get_reason_phrase_for (enum MHD_HTTP_StatusCode code) { if ( (code >= 100) && (code < 600) && (reasons[code / 100].max > (code % 100)) ) return reasons[code / 100].data[code % 100]; return "Unknown"; } libmicrohttpd-1.0.1/src/lib/daemon_start.c0000644000175000017500000007113614441373361014235 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_start.c * @brief functions to start a daemon * @author Christian Grothoff */ #include "internal.h" #include "connection_cleanup.h" #include "daemon_close_all_connections.h" #include "daemon_select.h" #include "daemon_poll.h" #include "daemon_epoll.h" #include "request_resume.h" /** * Set listen socket options to allow port rebinding (or not) * depending on how MHD was configured. * * @param[in,out] daemon the daemon with the listen socket to configure * @return #MHD_SC_OK on success (or non-fatal errors) */ static enum MHD_StatusCode configure_listen_reuse (struct MHD_Daemon *daemon) { const MHD_SCKT_OPT_BOOL_ on = 1; /* Apply the socket options according to listening_address_reuse. */ if (daemon->allow_address_reuse) { /* User requested to allow reusing listening address:port. */ #ifndef MHD_WINSOCK_SOCKETS /* Use SO_REUSEADDR on non-W32 platforms, and do not fail if * it doesn't work. */ if (0 > setsockopt (daemon->listen_socket, SOL_SOCKET, SO_REUSEADDR, (void *) &on, sizeof (on))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_ADDRESS_REUSE_ENABLE_FAILED, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_SC_LISTEN_ADDRESS_REUSE_ENABLE_FAILED; } return MHD_SC_OK; #endif /* ! MHD_WINSOCK_SOCKETS */ /* Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms. * Fail if SO_REUSEPORT is not defined or setsockopt fails. */ /* SO_REUSEADDR on W32 has the same semantics as SO_REUSEPORT on BSD/Linux */ #if defined(MHD_WINSOCK_SOCKETS) || defined(SO_REUSEPORT) if (0 > setsockopt (daemon->listen_socket, SOL_SOCKET, #ifndef MHD_WINSOCK_SOCKETS SO_REUSEPORT, #else /* MHD_WINSOCK_SOCKETS */ SO_REUSEADDR, #endif /* MHD_WINSOCK_SOCKETS */ (void *) &on, sizeof (on))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_ADDRESS_REUSE_ENABLE_FAILED, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_SC_LISTEN_ADDRESS_REUSE_ENABLE_FAILED; } return MHD_SC_OK; #else /* !MHD_WINSOCK_SOCKETS && !SO_REUSEPORT */ /* we're supposed to allow address:port re-use, but on this platform we cannot; fail hard */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_ADDRESS_REUSE_ENABLE_NOT_SUPPORTED, _ ( "Cannot allow listening address reuse: SO_REUSEPORT not defined.\n")); #endif return MHD_SC_LISTEN_ADDRESS_REUSE_ENABLE_NOT_SUPPORTED; #endif /* !MHD_WINSOCK_SOCKETS && !SO_REUSEPORT */ } /* if (! daemon->allow_address_reuse) */ /* User requested to disallow reusing listening address:port. * Do nothing except for Windows where SO_EXCLUSIVEADDRUSE * is used and Solaris with SO_EXCLBIND. * Fail if MHD was compiled for W32 without SO_EXCLUSIVEADDRUSE * or setsockopt fails. */ #if (defined(MHD_WINSOCK_SOCKETS) && defined(SO_EXCLUSIVEADDRUSE)) || \ (defined(__sun) && defined(SO_EXCLBIND)) if (0 > setsockopt (daemon->listen_socket, SOL_SOCKET, #ifdef SO_EXCLUSIVEADDRUSE SO_EXCLUSIVEADDRUSE, #else /* SO_EXCLBIND */ SO_EXCLBIND, #endif /* SO_EXCLBIND */ (void *) &on, sizeof (on))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_ADDRESS_REUSE_DISABLE_FAILED, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_SC_LISTEN_ADDRESS_REUSE_DISABLE_FAILED; } return MHD_SC_OK; #elif defined(MHD_WINSOCK_SOCKETS) /* SO_EXCLUSIVEADDRUSE not defined on W32? */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_ADDRESS_REUSE_DISABLE_NOT_SUPPORTED, _ ( "Cannot disallow listening address reuse: SO_EXCLUSIVEADDRUSE not defined.\n")); #endif return MHD_SC_LISTEN_ADDRESS_REUSE_DISABLE_NOT_SUPPORTED; #endif /* MHD_WINSOCK_SOCKETS */ /* Not on WINSOCK, simply doing nothing will do */ return MHD_SC_OK; } /** * Open, configure and bind the listen socket (if required). * * @param[in,out] daemon daemon to open the socket for * @return #MHD_SC_OK on success */ static enum MHD_StatusCode open_listen_socket (struct MHD_Daemon *daemon) { enum MHD_StatusCode sc; socklen_t addrlen; struct sockaddr_storage ss; const struct sockaddr *sa; int pf; bool use_v6; if (MHD_INVALID_SOCKET != daemon->listen_socket) return MHD_SC_OK; /* application opened it for us! */ pf = -1; /* Determine address family */ switch (daemon->listen_af) { case MHD_AF_NONE: if (0 == daemon->listen_sa_len) { /* no listening desired, that's OK */ return MHD_SC_OK; } /* we have a listen address, get AF from there! */ switch (daemon->listen_sa.ss_family) { case AF_INET: pf = PF_INET; use_v6 = false; break; #ifdef AF_INET6 case AF_INET6: pf = PF_INET6; use_v6 = true; break; #endif #ifdef AF_UNIX case AF_UNIX: pf = PF_UNIX; use_v6 = false; break; #endif default: return MHD_SC_AF_NOT_SUPPORTED_BY_BUILD; } /* switch on ss_family */ break; /* MHD_AF_NONE */ case MHD_AF_AUTO: #ifdef HAVE_INET6 pf = PF_INET6; use_v6 = true; #else pf = PF_INET; use_v6 = false; #endif break; case MHD_AF_INET4: use_v6 = false; pf = PF_INET; break; case MHD_AF_INET6: case MHD_AF_DUAL: #ifdef HAVE_INET6 pf = PF_INET6; use_v6 = true; break; #else #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_IPV6_NOT_SUPPORTED_BY_BUILD, _ ("IPv6 not supported by this build.\n")); #endif return MHD_SC_IPV6_NOT_SUPPORTED_BY_BUILD; #endif } mhd_assert (-1 != pf); /* try to open listen socket */ try_open_listen_socket: daemon->listen_socket = MHD_socket_create_listen_ (pf); if ( (MHD_INVALID_SOCKET == daemon->listen_socket) && (MHD_AF_AUTO == daemon->listen_af) && (use_v6) ) { use_v6 = false; pf = PF_INET; goto try_open_listen_socket; } if (MHD_INVALID_SOCKET == daemon->listen_socket) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_FAILED_TO_OPEN_LISTEN_SOCKET, _ ("Failed to create socket for listening: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_SC_FAILED_TO_OPEN_LISTEN_SOCKET; } if (MHD_SC_OK != (sc = configure_listen_reuse (daemon))) return sc; /* configure for dual stack (or not) */ if (use_v6) { #if defined IPPROTO_IPV6 && defined IPV6_V6ONLY /* Note: "IPV6_V6ONLY" is declared by Windows Vista ff., see "IPPROTO_IPV6 Socket Options" (http://msdn.microsoft.com/en-us/library/ms738574%28v=VS.85%29.aspx); and may also be missing on older POSIX systems; good luck if you have any of those, your IPv6 socket may then also bind against IPv4 anyway... */ const MHD_SCKT_OPT_BOOL_ v6_only = (MHD_AF_INET6 == daemon->listen_af); if (0 > setsockopt (daemon->listen_socket, IPPROTO_IPV6, IPV6_V6ONLY, (const void *) &v6_only, sizeof (v6_only))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_DUAL_STACK_CONFIGURATION_FAILED, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif } #else #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_DUAL_STACK_CONFIGURATION_NOT_SUPPORTED, _ ( "Cannot explicitly setup dual stack behavior on this platform.\n")); #endif #endif } /* Determine address to bind to */ if (0 != daemon->listen_sa_len) { /* Bind address explicitly given */ sa = (const struct sockaddr *) &daemon->listen_sa; addrlen = daemon->listen_sa_len; } else { /* Compute bind address based on port and AF */ #ifdef HAVE_INET6 if (use_v6) { #ifdef IN6ADDR_ANY_INIT static const struct in6_addr static_in6any = IN6ADDR_ANY_INIT; #endif struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) &ss; addrlen = sizeof (struct sockaddr_in6); memset (sin6, 0, sizeof (struct sockaddr_in6)); sin6->sin6_family = AF_INET6; sin6->sin6_port = htons (daemon->listen_port); #ifdef IN6ADDR_ANY_INIT sin6->sin6_addr = static_in6any; #endif #if HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN sin6->sin6_len = sizeof (struct sockaddr_in6); #endif } else #endif { struct sockaddr_in *sin4 = (struct sockaddr_in *) &ss; addrlen = sizeof (struct sockaddr_in); memset (sin4, 0, sizeof (struct sockaddr_in)); sin4->sin_family = AF_INET; sin4->sin_port = htons (daemon->listen_port); if (0 != INADDR_ANY) sin4->sin_addr.s_addr = htonl (INADDR_ANY); #if HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sin4->sin_len = sizeof (struct sockaddr_in); #endif } sa = (const struct sockaddr *) &ss; } /* actually do the bind() */ if (-1 == bind (daemon->listen_socket, sa, addrlen)) { #ifdef HAVE_MESSAGES unsigned int port = 0; switch (sa->sa_family) { case AF_INET: if (addrlen == sizeof (struct sockaddr_in)) port = ntohs (((const struct sockaddr_in *) sa)->sin_port); else port = UINT16_MAX + 1; /* indicate size error */ break; case AF_INET6: if (addrlen == sizeof (struct sockaddr_in6)) port = ntohs (((const struct sockaddr_in6 *) sa)->sin6_port); else port = UINT16_MAX + 1; /* indicate size error */ break; default: port = UINT_MAX; /* AF_UNIX? */ break; } MHD_DLOG (daemon, MHD_SC_LISTEN_SOCKET_BIND_FAILED, _ ("Failed to bind to port %u: %s\n"), port, MHD_socket_last_strerr_ ()); #endif return MHD_SC_LISTEN_SOCKET_BIND_FAILED; } /* setup TCP_FASTOPEN */ #ifdef TCP_FASTOPEN if (MHD_FOM_DISABLE != daemon->fast_open_method) { if (0 != setsockopt (daemon->listen_socket, IPPROTO_TCP, TCP_FASTOPEN, &daemon->fo_queue_length, sizeof (daemon->fo_queue_length))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_FAST_OPEN_FAILURE, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif if (MHD_FOM_REQUIRE == daemon->fast_open_method) return MHD_SC_FAST_OPEN_FAILURE; } } #endif /* setup listening */ if (0 > listen (daemon->listen_socket, daemon->listen_backlog)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_FAILURE, _ ("Failed to listen for connections: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_SC_LISTEN_FAILURE; } return MHD_SC_OK; } /** * Obtain the listen port number from the socket (if it * was not explicitly set by us, i.e. if we were given * a listen socket or if the port was 0 and the OS picked * a free one). * * @param[in,out] daemon daemon to obtain the port number for */ static void get_listen_port_number (struct MHD_Daemon *daemon) { struct sockaddr_storage servaddr; socklen_t addrlen; if ( (0 != daemon->listen_port) || (MHD_INVALID_SOCKET == daemon->listen_socket) ) return; /* nothing to be done */ memset (&servaddr, 0, sizeof (struct sockaddr_storage)); addrlen = sizeof (servaddr); if (0 != getsockname (daemon->listen_socket, (struct sockaddr *) &servaddr, &addrlen)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_PORT_INTROSPECTION_FAILURE, _ ("Failed to get listen port number: %s\n"), MHD_socket_last_strerr_ ()); #endif /* HAVE_MESSAGES */ return; } #ifdef MHD_POSIX_SOCKETS if (sizeof (servaddr) < addrlen) { /* should be impossible with `struct sockaddr_storage` */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_PORT_INTROSPECTION_FAILURE, _ ( "Failed to get listen port number (`struct sockaddr_storage` too small!?).\n")); #endif /* HAVE_MESSAGES */ return; } #endif /* MHD_POSIX_SOCKETS */ switch (servaddr.ss_family) { case AF_INET: { struct sockaddr_in *s4 = (struct sockaddr_in *) &servaddr; daemon->listen_port = ntohs (s4->sin_port); break; } #ifdef HAVE_INET6 case AF_INET6: { struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) &servaddr; daemon->listen_port = ntohs (s6->sin6_port); break; } #endif /* HAVE_INET6 */ #ifdef AF_UNIX case AF_UNIX: daemon->listen_port = 0; /* special value for UNIX domain sockets */ break; #endif default: #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_PORT_INTROSPECTION_UNKNOWN_AF, _ ("Unknown address family!\n")); #endif daemon->listen_port = 0; /* ugh */ break; } } #ifdef EPOLL_SUPPORT /** * Setup file descriptor to be used for epoll() control. * * @param daemon the daemon to setup epoll FD for * @return the epoll() fd to use */ static int setup_epoll_fd (struct MHD_Daemon *daemon) { int fd; #ifndef HAVE_MESSAGES (void) daemon; /* Mute compiler warning. */ #endif /* ! HAVE_MESSAGES */ #ifdef USE_EPOLL_CREATE1 fd = epoll_create1 (EPOLL_CLOEXEC); #else /* ! USE_EPOLL_CREATE1 */ fd = epoll_create (MAX_EVENTS); #endif /* ! USE_EPOLL_CREATE1 */ if (MHD_INVALID_SOCKET == fd) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_EPOLL_CTL_CREATE_FAILED, _ ("Call to epoll_create1 failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_INVALID_SOCKET; } #if ! defined(USE_EPOLL_CREATE1) if (! MHD_socket_noninheritable_ (fd)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_EPOLL_CTL_CONFIGURE_NOINHERIT_FAILED, _ ("Failed to set noninheritable mode on epoll FD.\n")); #endif } #endif /* ! USE_EPOLL_CREATE1 */ return fd; } /** * Setup epoll() FD for the daemon and initialize it to listen * on the listen FD. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon daemon to initialize for epoll() * @return #MHD_SC_OK on success */ static enum MHD_StatusCode setup_epoll_to_listen (struct MHD_Daemon *daemon) { struct epoll_event event; MHD_socket ls; /* FIXME: update function! */ daemon->epoll_fd = setup_epoll_fd (daemon); if (-1 == daemon->epoll_fd) return MHD_SC_EPOLL_CTL_CREATE_FAILED; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if (! daemon->disallow_upgrade) { daemon->epoll_upgrade_fd = setup_epoll_fd (daemon); if (MHD_INVALID_SOCKET == daemon->epoll_upgrade_fd) return MHD_SC_EPOLL_CTL_CREATE_FAILED; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if ( (MHD_INVALID_SOCKET == (ls = daemon->listen_socket)) || (daemon->was_quiesced) ) return MHD_SC_OK; /* non-listening daemon */ event.events = EPOLLIN; event.data.ptr = daemon; if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, ls, &event)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_EPOLL_CTL_ADD_FAILED, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_SC_EPOLL_CTL_ADD_FAILED; } daemon->listen_socket_in_epoll = true; if (MHD_ITC_IS_VALID_ (daemon->itc)) { event.events = EPOLLIN; event.data.ptr = (void *) daemon->epoll_itc_marker; if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, MHD_itc_r_fd_ (daemon->itc), &event)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_EPOLL_CTL_ADD_FAILED, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_SC_EPOLL_CTL_ADD_FAILED; } } return MHD_SC_OK; } #endif /** * Thread that runs the polling loop until the daemon * is explicitly shut down. * * @param cls `struct MHD_Deamon` to run select loop in a thread for * @return always 0 (on shutdown) */ static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ MHD_polling_thread (void *cls) { struct MHD_Daemon *daemon = cls; MHD_thread_init_ (&daemon->pid); while (! daemon->shutdown) { switch (daemon->event_loop_syscall) { case MHD_ELS_AUTO: MHD_PANIC ("MHD_ELS_AUTO should have been mapped to preferred style.\n"); break; case MHD_ELS_SELECT: MHD_daemon_select_ (daemon, MHD_YES); break; case MHD_ELS_POLL: #ifdef HAVE_POLL MHD_daemon_poll_ (daemon, MHD_YES); #else MHD_PANIC ("MHD_ELS_POLL not supported, should have failed earlier.\n"); #endif break; case MHD_ELS_EPOLL: #ifdef EPOLL_SUPPORT MHD_daemon_epoll_ (daemon, MHD_YES); #else MHD_PANIC ("MHD_ELS_EPOLL not supported, should have failed earlier.\n"); #endif break; } MHD_connection_cleanup_ (daemon); } /* Resume any pending for resume connections, join * all connection's threads (if any) and finally cleanup * everything. */ if (! daemon->disallow_suspend_resume) MHD_resume_suspended_connections_ (daemon); MHD_daemon_close_all_connections_ (daemon); return (MHD_THRD_RTRN_TYPE_) 0; } /** * Setup the thread pool (if needed). * * @param[in,out] daemon daemon to setup thread pool for * @return #MHD_SC_OK on success */ static enum MHD_StatusCode setup_thread_pool (struct MHD_Daemon *daemon) { /* Coarse-grained count of connections per thread (note error * due to integer division). Also keep track of how many * connections are leftover after an equal split. */ unsigned int conns_per_thread = daemon->global_connection_limit / daemon->threading_mode; unsigned int leftover_conns = daemon->global_connection_limit % daemon->threading_mode; int i; enum MHD_StatusCode sc; /* Allocate memory for pooled objects */ daemon->worker_pool = MHD_calloc_ (daemon->threading_mode, sizeof (struct MHD_Daemon)); if (NULL == daemon->worker_pool) return MHD_SC_THREAD_POOL_MALLOC_FAILURE; /* Start the workers in the pool */ for (i = 0; i < daemon->threading_mode; i++) { /* Create copy of the Daemon object for each worker */ struct MHD_Daemon *d = &daemon->worker_pool[i]; memcpy (d, daemon, sizeof (struct MHD_Daemon)); /* Adjust pooling params for worker daemons; note that memcpy() has already copied MHD_USE_INTERNAL_POLLING_THREAD thread mode into the worker threads. */ d->master = daemon; d->worker_pool_size = 0; d->worker_pool = NULL; /* Divide available connections evenly amongst the threads. * Thread indexes in [0, leftover_conns) each get one of the * leftover connections. */ d->global_connection_limit = conns_per_thread; if (((unsigned int) i) < leftover_conns) ++d->global_connection_limit; if (! daemon->disable_itc) { if (! MHD_itc_init_ (d->itc)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ITC_INITIALIZATION_FAILED, _ ( "Failed to create worker inter-thread communication channel: %s\n"), MHD_itc_last_strerror_ () ); #endif sc = MHD_SC_ITC_INITIALIZATION_FAILED; goto thread_failed; } if ( (MHD_ELS_SELECT == daemon->event_loop_syscall) && (! MHD_SCKT_FD_FITS_FDSET_ (MHD_itc_r_fd_ (d->itc), NULL)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ITC_DESCRIPTOR_TOO_LARGE, _ ( "File descriptor for inter-thread communication channel exceeds maximum value.\n")); #endif MHD_itc_destroy_chk_ (d->itc); sc = MHD_SC_ITC_DESCRIPTOR_TOO_LARGE; goto thread_failed; } } else { MHD_itc_set_invalid_ (d->itc); } #ifdef EPOLL_SUPPORT if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && (MHD_SC_OK != (sc = setup_epoll_to_listen (d))) ) goto thread_failed; #endif /* Must init cleanup connection mutex for each worker */ if (! MHD_mutex_init_ (&d->cleanup_connection_mutex)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_THREAD_POOL_CREATE_MUTEX_FAILURE, _ ("MHD failed to initialize cleanup connection mutex.\n")); #endif if (! daemon->disable_itc) MHD_itc_destroy_chk_ (d->itc); sc = MHD_SC_THREAD_POOL_CREATE_MUTEX_FAILURE; goto thread_failed; } /* Spawn the worker thread */ if (! MHD_create_named_thread_ (&d->pid, "MHD-worker", daemon->thread_stack_limit_b, &MHD_polling_thread, d)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_THREAD_POOL_LAUNCH_FAILURE, _ ("Failed to create pool thread: %s\n"), MHD_strerror_ (errno)); #endif /* Free memory for this worker; cleanup below handles * all previously-created workers. */ if (! daemon->disable_itc) MHD_itc_destroy_chk_ (d->itc); MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex); sc = MHD_SC_THREAD_POOL_LAUNCH_FAILURE; goto thread_failed; } } /* end for() */ return MHD_SC_OK; thread_failed: /* If no worker threads created, then shut down normally. Calling MHD_stop_daemon (as we do below) doesn't work here since it assumes a 0-sized thread pool means we had been in the default MHD_USE_INTERNAL_POLLING_THREAD mode. */ if (0 == i) { if (NULL != daemon->worker_pool) { free (daemon->worker_pool); daemon->worker_pool = NULL; } return MHD_SC_THREAD_LAUNCH_FAILURE; } /* Shutdown worker threads we've already created. Pretend as though we had fully initialized our daemon, but with a smaller number of threads than had been requested. */ daemon->worker_pool_size = i; daemon->listen_socket = MHD_daemon_quiesce (daemon); return sc; } /** * Start a webserver. * * @param daemon daemon to start; you can no longer set * options on this daemon after this call! * @return #MHD_SC_OK on success * @ingroup event */ enum MHD_StatusCode MHD_daemon_start (struct MHD_Daemon *daemon) { enum MHD_StatusCode sc; if (MHD_ELS_AUTO == daemon->event_loop_syscall) { #if EPOLL_SUPPORT /* We do not support thread-per-connection in combination with epoll, so use poll in this case, otherwise prefer epoll. */ if (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) daemon->event_loop_syscall = MHD_ELS_POLL; else daemon->event_loop_syscall = MHD_ELS_EPOLL; #elif defined(HAVE_POLL) daemon->event_loop_syscall = MHD_ELS_POLL; #else daemon->event_loop_syscall = MHD_ELS_SELECT; #endif } #ifdef EPOLL_SUPPORT if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && (0 == daemon->worker_pool_size) && (MHD_INVALID_SOCKET != daemon->listen_socket) && (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_SYSCALL_THREAD_COMBINATION_INVALID, _ ( "Combining MHD_USE_THREAD_PER_CONNECTION and MHD_USE_EPOLL is not supported.\n")); #endif return MHD_SC_SYSCALL_THREAD_COMBINATION_INVALID; } #endif /* Setup ITC */ if ( (! daemon->disable_itc) && (0 == daemon->worker_pool_size) ) { if (! MHD_itc_init_ (daemon->itc)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ITC_INITIALIZATION_FAILED, _ ("Failed to create inter-thread communication channel: %s\n"), MHD_itc_last_strerror_ ()); #endif return MHD_SC_ITC_INITIALIZATION_FAILED; } if ( (MHD_ELS_SELECT == daemon->event_loop_syscall) && (! MHD_SCKT_FD_FITS_FDSET_ (MHD_itc_r_fd_ (daemon->itc), NULL)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ITC_DESCRIPTOR_TOO_LARGE, _ ( "File descriptor for inter-thread communication channel exceeds maximum value.\n")); #endif return MHD_SC_ITC_DESCRIPTOR_TOO_LARGE; } } if (MHD_SC_OK != (sc = open_listen_socket (daemon))) return sc; /* Check listen socket is in range (if we are limited) */ if ( (MHD_INVALID_SOCKET != daemon->listen_socket) && (MHD_ELS_SELECT == daemon->event_loop_syscall) && (! MHD_SCKT_FD_FITS_FDSET_ (daemon->listen_socket, NULL)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_SOCKET_TOO_LARGE, _ ("Socket descriptor larger than FD_SETSIZE: %d > %d\n"), daemon->listen_socket, FD_SETSIZE); #endif return MHD_SC_LISTEN_SOCKET_TOO_LARGE; } /* set listen socket to non-blocking */ if ( (MHD_INVALID_SOCKET != daemon->listen_socket) && (! MHD_socket_nonblocking_ (daemon->listen_socket)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LISTEN_SOCKET_NONBLOCKING_FAILURE, _ ("Failed to set nonblocking mode on listening socket: %s\n"), MHD_socket_last_strerr_ ()); #endif if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) || (daemon->worker_pool_size > 0) ) { /* Accept must be non-blocking. Multiple children may wake * up to handle a new connection, but only one will win the * race. The others must immediately return. As this is * not possible, we must fail hard here. */ return MHD_SC_LISTEN_SOCKET_NONBLOCKING_FAILURE; } } #ifdef EPOLL_SUPPORT /* Setup epoll */ if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && (0 == daemon->worker_pool_size) && (MHD_INVALID_SOCKET != daemon->listen_socket) && (MHD_SC_OK != (sc = setup_epoll_to_listen (daemon))) ) return sc; #endif /* Setup main listen thread (only if we have no thread pool or external event loop and do have a listen socket) */ /* FIXME: why no worker thread if we have no listen socket? */ if ( ( (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) || (1 == daemon->threading_mode) ) && (MHD_INVALID_SOCKET != daemon->listen_socket) && (! MHD_create_named_thread_ (&daemon->pid, (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) ? "MHD-listen" : "MHD-single", daemon->thread_stack_limit_b, &MHD_polling_thread, daemon) ) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_THREAD_MAIN_LAUNCH_FAILURE, _ ("Failed to create listen thread: %s\n"), MHD_strerror_ (errno)); #endif return MHD_SC_THREAD_MAIN_LAUNCH_FAILURE; } /* Setup worker threads */ /* FIXME: why no thread pool if we have no listen socket? */ if ( (1 < daemon->threading_mode) && (MHD_INVALID_SOCKET != daemon->listen_socket) && (MHD_SC_OK != (sc = setup_thread_pool (daemon))) ) return sc; /* make sure we know our listen port (if any) */ get_listen_port_number (daemon); return MHD_SC_OK; } /* end of daemon_start.c */ libmicrohttpd-1.0.1/src/lib/connection_finish_forward.c0000644000175000017500000000626114417460232016772 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_finish_forward.c * @brief complete upgrade socket forwarding operation in TLS mode * @author Christian Grothoff */ #include "internal.h" #include "connection_finish_forward.h" #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Stop TLS forwarding on upgraded connection and * reflect remote disconnect state to socketpair. * @remark In thread-per-connection mode this function * can be called from any thread, in other modes this * function must be called only from thread that process * daemon's select()/poll()/etc. * * @param connection the upgraded connection */ void MHD_connection_finish_forward_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; struct MHD_UpgradeResponseHandle *urh = connection->request.urh; if (NULL == daemon->tls_api) return; /* Nothing to do with non-TLS connection. */ if (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) DLL_remove (daemon->urh_head, daemon->urh_tail, urh); #if EPOLL_SUPPORT if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && (0 != epoll_ctl (daemon->epoll_upgrade_fd, EPOLL_CTL_DEL, connection->socket_fd, NULL)) ) { MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); } if (urh->in_eready_list) { EDLL_remove (daemon->eready_urh_head, daemon->eready_urh_tail, urh); urh->in_eready_list = false; } #endif /* EPOLL_SUPPORT */ if (MHD_INVALID_SOCKET != urh->mhd.socket) { #if EPOLL_SUPPORT if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && (0 != epoll_ctl (daemon->epoll_upgrade_fd, EPOLL_CTL_DEL, urh->mhd.socket, NULL)) ) { MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); } #endif /* EPOLL_SUPPORT */ /* Reflect remote disconnect to application by breaking * socketpair connection. */ shutdown (urh->mhd.socket, SHUT_RDWR); } /* Socketpair sockets will remain open as they will be * used with MHD_UPGRADE_ACTION_CLOSE. They will be * closed by MHD_cleanup_upgraded_connection_() during * connection's final cleanup. */} #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT*/ /* end of connection_finish_forward.c */ libmicrohttpd-1.0.1/src/lib/daemon_poll.h0000644000175000017500000000445014417460232014043 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_poll.h * @brief non-public functions provided by daemon_poll.c * @author Christian Grothoff */ #ifndef DAEMON_POLL_H #define DAEMON_POLL_H #ifdef HAVE_POLL /** * Process all of our connections and possibly the server * socket using poll(). * * @param daemon daemon to run poll loop for * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_poll_all_ (struct MHD_Daemon *daemon, bool may_block) MHD_NONNULL (1); /** * Process only the listen socket using poll(). * * @param daemon daemon to run poll loop for * @param may_block true if blocking, false if non-blocking * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_poll_listen_socket_ (struct MHD_Daemon *daemon, bool may_block) MHD_NONNULL (1); /** * Do poll()-based processing. * * @param daemon daemon to run poll()-loop for * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_poll_ (struct MHD_Daemon *daemon, bool may_block) MHD_NONNULL (1); #endif #ifdef HTTPS_SUPPORT #ifdef HAVE_POLL /** * Process upgraded connection with a poll() loop. * We are in our own thread, only processing @a con * * @param con connection to process */ void MHD_daemon_upgrade_connection_with_poll_ (struct MHD_Connection *con) MHD_NONNULL (1); #endif #endif #endif libmicrohttpd-1.0.1/src/lib/connection_update_last_activity.c0000644000175000017500000000465514417460232020214 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_update_last_activity.c * @brief functions to add connection to our active set * @author Christian Grothoff */ #include "internal.h" #include "connection_update_last_activity.h" /** * Update the 'last_activity' field of the connection to the current time * and move the connection to the head of the 'normal_timeout' list if * the timeout for the connection uses the default value. * * @param connection the connection that saw some activity */ void MHD_connection_update_last_activity_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; if (0 == connection->connection_timeout) return; /* Skip update of activity for connections without timeout timer. */ if (connection->suspended) return; /* no activity on suspended connections */ connection->last_activity = MHD_monotonic_sec_counter (); if (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) return; /* each connection has personal timeout */ if (connection->connection_timeout != daemon->connection_default_timeout) return; /* custom timeout, no need to move it in "normal" DLL */ MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); /* move connection to head of timeout list (by remove + add operation) */ XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); XDLL_insert (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } /* end of connection_update_last_activity.c */ libmicrohttpd-1.0.1/src/lib/daemon_create.c0000644000175000017500000000750314417460232014335 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_create.c * @brief main functions to create a daemon * @author Christian Grothoff */ #include "internal.h" #include "init.h" /** * Logging implementation that logs to a file given * as the @a cls. * * @param cls a `FILE *` to log to * @param sc status code of the event (ignored) * @param fm format string (`printf()`-style) * @param ap arguments to @a fm * @ingroup logging */ static void file_logger (void *cls, enum MHD_StatusCode sc, const char *fm, va_list ap) { FILE *f = cls; (void) sc; (void) vfprintf (f, fm, ap); } /** * Process escape sequences ('%HH') Updates val in place; the * result should be UTF-8 encoded and cannot be larger than the input. * The result must also still be 0-terminated. * * @param cls closure (use NULL) * @param req handle to request, not used * @param val value to unescape (modified in the process) * @return length of the resulting val (strlen(val) maybe * shorter afterwards due to elimination of escape sequences) */ static size_t unescape_wrapper (void *cls, struct MHD_Request *req, char *val) { (void) cls; /* Mute compiler warning. */ (void) req; /* Mute compiler warning. */ return MHD_http_unescape (val); } /** * Create (but do not yet start) an MHD daemon. * Usually, you will want to set various options before * starting the daemon with #MHD_daemon_start(). * * @param cb function to be called for incoming requests * @param cb_cls closure for @a cb * @return NULL on error */ struct MHD_Daemon * MHD_daemon_create (MHD_RequestCallback cb, void *cb_cls) { struct MHD_Daemon *daemon; MHD_check_global_init_ (); if (NULL == (daemon = malloc (sizeof (struct MHD_Daemon)))) return NULL; memset (daemon, 0, sizeof (struct MHD_Daemon)); #ifdef EPOLL_SUPPORT daemon->epoll_itc_marker = "itc_marker"; #endif daemon->rc = cb; daemon->rc_cls = cb_cls; daemon->logger = &file_logger; daemon->logger_cls = stderr; daemon->unescape_cb = &unescape_wrapper; daemon->connection_memory_limit_b = POOL_SIZE_DEFAULT; daemon->connection_memory_increment_b = BUF_INC_SIZE_DEFAULT; #if ENABLE_DAUTH daemon->digest_nc_length = DIGEST_NC_LENGTH_DEFAULT; #endif daemon->listen_backlog = LISTEN_BACKLOG_DEFAULT; daemon->fo_queue_length = FO_QUEUE_LENGTH_DEFAULT; daemon->listen_socket = MHD_INVALID_SOCKET; if (! MHD_mutex_init_ (&daemon->cleanup_connection_mutex)) { free (daemon); return NULL; } if (! MHD_mutex_init_ (&daemon->per_ip_connection_mutex)) { (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex); free (daemon); return NULL; } #ifdef DAUTH_SUPPORT if (! MHD_mutex_init_ (&daemon->nnc_lock)) { (void) MHD_mutex_destroy_ (&daemon->cleanup_connection_mutex); (void) MHD_mutex_destroy_ (&daemon->per_ip_connection_mutex); free (daemon); return NULL; } #endif return daemon; } /* end of daemon_create.c */ libmicrohttpd-1.0.1/src/lib/mhd_threads.c0000644000175000017500000002362614417460232014035 /* This file is part of libmicrohttpd Copyright (C) 2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_threads.c * @brief Implementation for thread functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_threads.h" #ifdef MHD_USE_W32_THREADS #include "mhd_limits.h" #include #endif #ifdef MHD_USE_THREAD_NAME_ #include #ifdef HAVE_PTHREAD_NP_H #include #endif /* HAVE_PTHREAD_NP_H */ #endif /* MHD_USE_THREAD_NAME_ */ #include #ifndef MHD_USE_THREAD_NAME_ #define MHD_set_thread_name_(t, n) (void) #define MHD_set_cur_thread_name_(n) (void) #else /* MHD_USE_THREAD_NAME_ */ #if defined(MHD_USE_POSIX_THREADS) #if defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || \ defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) # define MHD_USE_THREAD_ATTR_SETNAME 1 #endif \ /* HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD || HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI */ #if defined(HAVE_PTHREAD_SETNAME_NP_GNU) || \ defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) \ || defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) /** * Set thread name * * @param thread_id ID of thread * @param thread_name name to set * @return non-zero on success, zero otherwise */ static int MHD_set_thread_name_ (const MHD_thread_ID_ thread_id, const char *thread_name) { if (NULL == thread_name) return 0; #if defined(HAVE_PTHREAD_SETNAME_NP_GNU) return ! pthread_setname_np (thread_id, thread_name); #elif defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) /* FreeBSD and OpenBSD use different name and void return type */ pthread_set_name_np (thread_id, thread_name); return ! 0; #elif defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) /* NetBSD use 3 arguments: second argument is string in printf-like format, * third argument is single argument for printf; * OSF1 use 3 arguments too, but last one always must be zero (NULL). * MHD doesn't use '%' in thread names, so both form are used in same way. */return ! pthread_setname_np (thread_id, thread_name, 0); #endif /* HAVE_PTHREAD_SETNAME_NP_NETBSD */ } #ifndef __QNXNTO__ /** * Set current thread name * @param n name to set * @return non-zero on success, zero otherwise */ #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_ (pthread_self (),(n)) #else /* __QNXNTO__ */ /* Special case for QNX Neutrino - using zero for thread ID sets name faster. */ #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_ (0,(n)) #endif /* __QNXNTO__ */ #elif defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) /** * Set current thread name * @param n name to set * @return non-zero on success, zero otherwise */ #define MHD_set_cur_thread_name_(n) (! (pthread_setname_np ((n)))) #endif /* HAVE_PTHREAD_SETNAME_NP_DARWIN */ #elif defined(MHD_USE_W32_THREADS) #ifndef _MSC_FULL_VER /* Thread name available only for VC-compiler */ #else /* _MSC_FULL_VER */ /** * Set thread name * * @param thread_id ID of thread, -1 for current thread * @param thread_name name to set * @return non-zero on success, zero otherwise */ static int MHD_set_thread_name_ (const MHD_thread_ID_ thread_id, const char *thread_name) { static const DWORD VC_SETNAME_EXC = 0x406D1388; #pragma pack(push,8) struct thread_info_struct { DWORD type; /* Must be 0x1000. */ LPCSTR name; /* Pointer to name (in user address space). */ DWORD ID; /* Thread ID (-1 = caller thread). */ DWORD flags; /* Reserved for future use, must be zero. */ } thread_info; #pragma pack(pop) if (NULL == thread_name) return 0; thread_info.type = 0x1000; thread_info.name = thread_name; thread_info.ID = thread_id; thread_info.flags = 0; __try { /* This exception is intercepted by debugger */ RaiseException (VC_SETNAME_EXC, 0, sizeof (thread_info) / sizeof(ULONG_PTR), (ULONG_PTR *) &thread_info); } __except (EXCEPTION_EXECUTE_HANDLER) {} return ! 0; } /** * Set current thread name * @param n name to set * @return non-zero on success, zero otherwise */ #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_ (-1,(n)) #endif /* _MSC_FULL_VER */ #endif /* MHD_USE_W32_THREADS */ #endif /* MHD_USE_THREAD_NAME_ */ /** * Create a thread and set the attributes according to our options. * * @param thread handle to initialize * @param stack_size size of stack for new thread, 0 for default * @param start_routine main function of thread * @param arg argument for start_routine * @return non-zero on success; zero otherwise (with errno set) */ int MHD_create_thread_ (MHD_thread_handle_ID_ *thread, size_t stack_size, MHD_THREAD_START_ROUTINE_ start_routine, void *arg) { #if defined(MHD_USE_POSIX_THREADS) int res; if (0 != stack_size) { pthread_attr_t attr; res = pthread_attr_init (&attr); if (0 == res) { res = pthread_attr_setstacksize (&attr, stack_size); if (0 == res) res = pthread_create (&(thread->handle), &attr, start_routine, arg); pthread_attr_destroy (&attr); } } else res = pthread_create (&(thread->handle), NULL, start_routine, arg); if (0 != res) errno = res; return ! res; #elif defined(MHD_USE_W32_THREADS) #if SIZE_MAX != UINT_MAX if (stack_size > UINT_MAX) { errno = EINVAL; return 0; } #endif /* SIZE_MAX != UINT_MAX */ thread->handle = (MHD_thread_handle_) _beginthreadex (NULL, (unsigned int) stack_size, start_routine, arg, 0, NULL); if ((MHD_thread_handle_) - 1 == thread->handle) return 0; return ! 0; #endif } #ifdef MHD_USE_THREAD_NAME_ #ifndef MHD_USE_THREAD_ATTR_SETNAME struct MHD_named_helper_param_ { /** * Real thread start routine */ MHD_THREAD_START_ROUTINE_ start_routine; /** * Argument for thread start routine */ void *arg; /** * Name for thread */ const char *name; }; static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ named_thread_starter (void *data) { struct MHD_named_helper_param_ *const param = (struct MHD_named_helper_param_ *) data; void *arg; MHD_THREAD_START_ROUTINE_ thr_func; if (NULL == data) return (MHD_THRD_RTRN_TYPE_) 0; MHD_set_cur_thread_name_ (param->name); arg = param->arg; thr_func = param->start_routine; free (data); return thr_func (arg); } #endif /* ! MHD_USE_THREAD_ATTR_SETNAME */ /** * Create a named thread and set the attributes according to our options. * * @param thread handle to initialize * @param thread_name name for new thread * @param stack_size size of stack for new thread, 0 for default * @param start_routine main function of thread * @param arg argument for start_routine * @return non-zero on success; zero otherwise (with errno set) */ int MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread, const char *thread_name, size_t stack_size, MHD_THREAD_START_ROUTINE_ start_routine, void *arg) { #if defined(MHD_USE_THREAD_ATTR_SETNAME) int res; pthread_attr_t attr; res = pthread_attr_init (&attr); if (0 == res) { #if defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) /* NetBSD use 3 arguments: second argument is string in printf-like format, * third argument is single argument for printf; * OSF1 use 3 arguments too, but last one always must be zero (NULL). * MHD doesn't use '%' in thread names, so both form are used in same way. */res = pthread_attr_setname_np (&attr, thread_name, 0); #elif defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) res = pthread_attr_setname_np (&attr, thread_name); #else #error No pthread_attr_setname_np() function. #endif if ((res == 0) && (0 != stack_size) ) res = pthread_attr_setstacksize (&attr, stack_size); if (0 == res) res = pthread_create (&(thread->handle), &attr, start_routine, arg); pthread_attr_destroy (&attr); } if (0 != res) errno = res; return ! res; #else /* ! MHD_USE_THREAD_ATTR_SETNAME */ struct MHD_named_helper_param_ *param; if (NULL == thread_name) { errno = EINVAL; return 0; } param = malloc (sizeof (struct MHD_named_helper_param_)); if (NULL == param) return 0; param->start_routine = start_routine; param->arg = arg; param->name = thread_name; /* Set thread name in thread itself to avoid problems with * threads which terminated before name is set in other thread. */ if (! MHD_create_thread_ (thread, stack_size, &named_thread_starter, (void *) param)) { free (param); return 0; } return ! 0; #endif /* ! MHD_USE_THREAD_ATTR_SETNAME */ } #endif /* MHD_USE_THREAD_NAME_ */ libmicrohttpd-1.0.1/src/lib/mhd_sockets.h0000644000175000017500000007064714417460232014070 /* This file is part of libmicrohttpd Copyright (C) 2014-2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_sockets.c * @brief Header for platform-independent sockets abstraction * @author Karlson2k (Evgeny Grin) * * Provides basic abstraction for sockets. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid * variable modification in function parameters. */ #ifndef MHD_SOCKETS_H #define MHD_SOCKETS_H 1 #include "mhd_options.h" #include #if ! defined(MHD_POSIX_SOCKETS) && ! defined(MHD_WINSOCK_SOCKETS) # if ! defined(_WIN32) || defined(__CYGWIN__) # define MHD_POSIX_SOCKETS 1 # else /* defined(_WIN32) && !defined(__CYGWIN__) */ # define MHD_WINSOCK_SOCKETS 1 # endif /* defined(_WIN32) && !defined(__CYGWIN__) */ #endif /* !MHD_POSIX_SOCKETS && !MHD_WINSOCK_SOCKETS */ /* * MHD require headers that define socket type, socket basic functions * (socket(), accept(), listen(), bind(), send(), recv(), select()), socket * parameters like SOCK_CLOEXEC, SOCK_NONBLOCK, additional socket functions * (poll(), epoll(), accept4()), struct timeval and other types, required * for socket function. */ #if defined(MHD_POSIX_SOCKETS) # ifdef HAVE_SYS_TYPES_H # include /* required on old platforms */ # endif # ifdef HAVE_SYS_SOCKET_H # include # endif # if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS) # ifdef HAVE_SOCKLIB_H # include # endif /* HAVE_SOCKLIB_H */ # ifdef HAVE_INETLIB_H # include # endif /* HAVE_INETLIB_H */ # include /* required for FD_SET (bzero() function) */ # endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */ # ifdef HAVE_NETINET_IN_H # include # endif /* HAVE_NETINET_IN_H */ # ifdef HAVE_ARPA_INET_H # include # endif # ifdef HAVE_NET_IF_H # include # endif # ifdef HAVE_SYS_TIME_H # include # endif # ifdef HAVE_TIME_H # include # endif # ifdef HAVE_NETDB_H # include # endif # ifdef HAVE_SYS_SELECT_H # include # endif # ifdef EPOLL_SUPPORT # include # endif # ifdef HAVE_NETINET_TCP_H /* for TCP_FASTOPEN and TCP_CORK */ # include # endif # ifdef HAVE_STRING_H # include /* for strerror() */ # endif #elif defined(MHD_WINSOCK_SOCKETS) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif /* !WIN32_LEAN_AND_MEAN */ # include # include #endif /* MHD_WINSOCK_SOCKETS */ #if defined(HAVE_POLL_H) && defined(HAVE_POLL) # include #endif #include #if defined(_MSC_FULL_VER) && ! defined (_SSIZE_T_DEFINED) # include # define _SSIZE_T_DEFINED typedef intptr_t ssize_t; #endif /* !_SSIZE_T_DEFINED */ #include "mhd_limits.h" #ifdef _MHD_FD_SETSIZE_IS_DEFAULT # define _MHD_SYS_DEFAULT_FD_SETSIZE FD_SETSIZE #else /* ! _MHD_FD_SETSIZE_IS_DEFAULT */ # include "sysfdsetsize.h" # define _MHD_SYS_DEFAULT_FD_SETSIZE get_system_fdsetsize_value () #endif /* ! _MHD_FD_SETSIZE_IS_DEFAULT */ #ifndef MHD_PANIC # include # include /* Simple implementation of MHD_PANIC, to be used outside lib */ # define MHD_PANIC(msg) do { fprintf (stderr, \ "Abnormal termination at %d line in file %s: %s\n", \ (int) __LINE__, __FILE__, msg); abort (); \ } while (0) #endif /* ! MHD_PANIC */ #ifndef MHD_SOCKET_DEFINED /** * MHD_socket is type for socket FDs */ # if defined(MHD_POSIX_SOCKETS) typedef int MHD_socket; # define MHD_INVALID_SOCKET (-1) # elif defined(MHD_WINSOCK_SOCKETS) typedef SOCKET MHD_socket; # define MHD_INVALID_SOCKET (INVALID_SOCKET) # endif /* MHD_WINSOCK_SOCKETS */ # define MHD_SOCKET_DEFINED 1 #endif /* ! MHD_SOCKET_DEFINED */ #ifdef SOCK_CLOEXEC # define MAYBE_SOCK_CLOEXEC SOCK_CLOEXEC #else /* ! SOCK_CLOEXEC */ # define MAYBE_SOCK_CLOEXEC 0 #endif /* ! SOCK_CLOEXEC */ #ifdef HAVE_SOCK_NONBLOCK # define MAYBE_SOCK_NONBLOCK SOCK_NONBLOCK #else /* ! HAVE_SOCK_NONBLOCK */ # define MAYBE_SOCK_NONBLOCK 0 #endif /* ! HAVE_SOCK_NONBLOCK */ #ifdef MSG_NOSIGNAL # define MAYBE_MSG_NOSIGNAL MSG_NOSIGNAL #else /* ! MSG_NOSIGNAL */ # define MAYBE_MSG_NOSIGNAL 0 #endif /* ! MSG_NOSIGNAL */ #if ! defined(SHUT_WR) && defined(SD_SEND) # define SHUT_WR SD_SEND #endif #if ! defined(SHUT_RD) && defined(SD_RECEIVE) # define SHUT_RD SD_RECEIVE #endif #if ! defined(SHUT_RDWR) && defined(SD_BOTH) # define SHUT_RDWR SD_BOTH #endif #if HAVE_ACCEPT4 + 0 != 0 && (defined(HAVE_SOCK_NONBLOCK) || \ defined(SOCK_CLOEXEC)) # define USE_ACCEPT4 1 #endif #if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC) # define USE_EPOLL_CREATE1 1 #endif /* HAVE_EPOLL_CREATE1 && EPOLL_CLOEXEC */ #ifdef TCP_FASTOPEN /** * Default TCP fastopen queue size. */ #define MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT 10 #endif /** * MHD_SCKT_OPT_BOOL_ is type for bool parameters for setsockopt()/getsockopt() */ #ifdef MHD_POSIX_SOCKETS typedef int MHD_SCKT_OPT_BOOL_; #else /* MHD_WINSOCK_SOCKETS */ typedef BOOL MHD_SCKT_OPT_BOOL_; #endif /* MHD_WINSOCK_SOCKETS */ /** * MHD_SCKT_SEND_SIZE_ is type used to specify size for send and recv * functions */ #if ! defined(MHD_WINSOCK_SOCKETS) typedef size_t MHD_SCKT_SEND_SIZE_; #else typedef int MHD_SCKT_SEND_SIZE_; #endif /** * MHD_SCKT_SEND_MAX_SIZE_ is maximum send()/recv() size value. */ #if ! defined(MHD_WINSOCK_SOCKETS) # define MHD_SCKT_SEND_MAX_SIZE_ SSIZE_MAX #else # define MHD_SCKT_SEND_MAX_SIZE_ INT_MAX #endif /** * MHD_socket_close_(fd) close any FDs (non-W32) / close only socket * FDs (W32). Note that on HP-UNIX, this function may leak the FD if * errno is set to EINTR. Do not use HP-UNIX. * * @param fd descriptor to close * @return boolean true on success (error codes like EINTR and EIO are * counted as success, only EBADF counts as an error!), * boolean false otherwise. */ #if ! defined(MHD_WINSOCK_SOCKETS) # define MHD_socket_close_(fd) ((0 == close ((fd))) || (EBADF != errno)) #else # define MHD_socket_close_(fd) (0 == closesocket ((fd))) #endif /** * MHD_socket_close_chk_(fd) close socket and abort execution * if error is detected. * @param fd socket to close */ #define MHD_socket_close_chk_(fd) do { \ if (! MHD_socket_close_ (fd)) \ MHD_PANIC (_ ("Close socket failed.\n")); \ } while (0) /** * MHD_send_ is wrapper for system's send() * @param s the socket to use * @param b the buffer with data to send * @param l the length of data in @a b * @return ssize_t type value */ #define MHD_send_(s,b,l) \ ((ssize_t) send ((s),(const void*) (b),((MHD_SCKT_SEND_SIZE_) l), \ MAYBE_MSG_NOSIGNAL)) /** * MHD_recv_ is wrapper for system's recv() * @param s the socket to use * @param b the buffer for data to receive * @param l the length of @a b * @return ssize_t type value */ #define MHD_recv_(s,b,l) \ ((ssize_t) recv ((s),(void*) (b),((MHD_SCKT_SEND_SIZE_) l), 0)) /** * Check whether FD can be added to fd_set with specified FD_SETSIZE. * @param fd the fd to check * @param pset the pointer to fd_set to check or NULL to check * whether FD can be used with fd_sets. * @param setsize the value of FD_SETSIZE. * @return boolean true if FD can be added to fd_set, * boolean false otherwise. */ #if defined(MHD_POSIX_SOCKETS) # define MHD_SCKT_FD_FITS_FDSET_SETSIZE_(fd,pset,setsize) ((fd) < \ ((MHD_socket) \ setsize)) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_SCKT_FD_FITS_FDSET_SETSIZE_(fd,pset,setsize) ( ((void*) (pset)== \ (void*) 0) || \ (((fd_set*) (pset)) \ ->fd_count < \ ((unsigned) \ setsize)) || \ (FD_ISSET ((fd), \ (pset))) ) #endif /** * Check whether FD can be added to fd_set with current FD_SETSIZE. * @param fd the fd to check * @param pset the pointer to fd_set to check or NULL to check * whether FD can be used with fd_sets. * @return boolean true if FD can be added to fd_set, * boolean false otherwise. */ #define MHD_SCKT_FD_FITS_FDSET_(fd,pset) MHD_SCKT_FD_FITS_FDSET_SETSIZE_ ((fd), \ (pset), \ FD_SETSIZE) /** * Add FD to fd_set with specified FD_SETSIZE. * @param fd the fd to add * @param pset the valid pointer to fd_set. * @param setsize the value of FD_SETSIZE. * @note To work on W32 with value of FD_SETSIZE different from currently defined value, * system definition of FD_SET() is not used. */ #if defined(MHD_POSIX_SOCKETS) # define MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_(fd,pset,setsize) FD_SET ((fd), \ (pset)) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_(fd,pset,setsize) \ do { \ u_int _i_ = 0; \ fd_set*const _s_ = (fd_set*) (pset); \ while ((_i_ < _s_->fd_count) && ((fd) != _s_->fd_array [_i_])) {++_i_;} \ if ((_i_ == _s_->fd_count)) {_s_->fd_array [_s_->fd_count ++] = (fd);} \ } while (0) #endif /* MHD_SYS_select_ is wrapper macro for system select() function */ #if ! defined(MHD_WINSOCK_SOCKETS) # define MHD_SYS_select_(n,r,w,e,t) select ((n),(r),(w),(e),(t)) #else # define MHD_SYS_select_(n,r,w,e,t) \ ( ( (((void*) (r) == (void*) 0) || ((fd_set*) (r))->fd_count == 0) && \ (((void*) (w) == (void*) 0) || ((fd_set*) (w))->fd_count == 0) && \ (((void*) (e) == (void*) 0) || ((fd_set*) (e))->fd_count == 0) ) ? \ ( ((void*) (t) == (void*) 0) ? 0 : \ (Sleep (((struct timeval*) (t))->tv_sec * 1000 \ + ((struct timeval*) (t))->tv_usec / 1000), 0) ) : \ (select ((int) 0,(r),(w),(e),(t))) ) #endif #if defined(HAVE_POLL) /* MHD_sys_poll_ is wrapper macro for system poll() function */ # if ! defined(MHD_WINSOCK_SOCKETS) # define MHD_sys_poll_ poll # else /* MHD_WINSOCK_SOCKETS */ # define MHD_sys_poll_ WSAPoll # endif /* MHD_WINSOCK_SOCKETS */ # ifdef POLLPRI # define MHD_POLLPRI_OR_ZERO POLLPRI # else /* ! POLLPRI */ # define MHD_POLLPRI_OR_ZERO 0 # endif /* ! POLLPRI */ # ifdef POLLRDBAND # define MHD_POLLRDBAND_OR_ZERO POLLRDBAND # else /* ! POLLRDBAND */ # define MHD_POLLRDBAND_OR_ZERO 0 # endif /* ! POLLRDBAND */ # ifdef POLLNVAL # define MHD_POLLNVAL_OR_ZERO POLLNVAL # else /* ! POLLNVAL */ # define MHD_POLLNVAL_OR_ZERO 0 # endif /* ! POLLNVAL */ /* MHD_POLL_EVENTS_ERR_DISC is 'events' mask for errors and disconnect. * Note: Out-of-band data is treated as error. */ # if defined(_WIN32) && ! defined(__CYGWIN__) # define MHD_POLL_EVENTS_ERR_DISC POLLRDBAND # elif defined(__linux__) # define MHD_POLL_EVENTS_ERR_DISC POLLPRI # else /* ! __linux__ */ # define MHD_POLL_EVENTS_ERR_DISC (MHD_POLLPRI_OR_ZERO \ | MHD_POLLRDBAND_OR_ZERO) # endif /* ! __linux__ */ /* MHD_POLL_REVENTS_ERR_DISC is 'revents' mask for errors and disconnect. * Note: Out-of-band data is treated as error. */ # define MHD_POLL_REVENTS_ERR_DISC \ (MHD_POLLPRI_OR_ZERO | MHD_POLLRDBAND_OR_ZERO | MHD_POLLNVAL_OR_ZERO \ | POLLERR | POLLHUP) /* MHD_POLL_REVENTS_ERRROR is 'revents' mask for errors. * Note: Out-of-band data is treated as error. */ # define MHD_POLL_REVENTS_ERRROR \ (MHD_POLLPRI_OR_ZERO | MHD_POLLRDBAND_OR_ZERO | MHD_POLLNVAL_OR_ZERO \ | POLLERR) #endif /* HAVE_POLL */ #define MHD_SCKT_MISSING_ERR_CODE_ 31450 #if defined(MHD_POSIX_SOCKETS) # if defined(EAGAIN) # define MHD_SCKT_EAGAIN_ EAGAIN # elif defined(EWOULDBLOCK) # define MHD_SCKT_EAGAIN_ EWOULDBLOCK # else /* !EAGAIN && !EWOULDBLOCK */ # define MHD_SCKT_EAGAIN_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* !EAGAIN && !EWOULDBLOCK */ # if defined(EWOULDBLOCK) # define MHD_SCKT_EWOULDBLOCK_ EWOULDBLOCK # elif defined(EAGAIN) # define MHD_SCKT_EWOULDBLOCK_ EAGAIN # else /* !EWOULDBLOCK && !EAGAIN */ # define MHD_SCKT_EWOULDBLOCK_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* !EWOULDBLOCK && !EAGAIN */ # ifdef EINTR # define MHD_SCKT_EINTR_ EINTR # else /* ! EINTR */ # define MHD_SCKT_EINTR_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EINTR */ # ifdef ECONNRESET # define MHD_SCKT_ECONNRESET_ ECONNRESET # else /* ! ECONNRESET */ # define MHD_SCKT_ECONNRESET_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ECONNRESET */ # ifdef ECONNABORTED # define MHD_SCKT_ECONNABORTED_ ECONNABORTED # else /* ! ECONNABORTED */ # define MHD_SCKT_ECONNABORTED_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ECONNABORTED */ # ifdef ENOTCONN # define MHD_SCKT_ENOTCONN_ ENOTCONN # else /* ! ENOTCONN */ # define MHD_SCKT_ENOTCONN_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOTCONN */ # ifdef EMFILE # define MHD_SCKT_EMFILE_ EMFILE # else /* ! EMFILE */ # define MHD_SCKT_EMFILE_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EMFILE */ # ifdef ENFILE # define MHD_SCKT_ENFILE_ ENFILE # else /* ! ENFILE */ # define MHD_SCKT_ENFILE_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENFILE */ # ifdef ENOMEM # define MHD_SCKT_ENOMEM_ ENOMEM # else /* ! ENOMEM */ # define MHD_SCKT_ENOMEM_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOMEM */ # ifdef ENOBUFS # define MHD_SCKT_ENOBUFS_ ENOBUFS # else /* ! ENOBUFS */ # define MHD_SCKT_ENOBUFS_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOBUFS */ # ifdef EBADF # define MHD_SCKT_EBADF_ EBADF # else /* ! EBADF */ # define MHD_SCKT_EBADF_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EBADF */ # ifdef ENOTSOCK # define MHD_SCKT_ENOTSOCK_ ENOTSOCK # else /* ! ENOTSOCK */ # define MHD_SCKT_ENOTSOCK_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOTSOCK */ # ifdef EINVAL # define MHD_SCKT_EINVAL_ EINVAL # else /* ! EINVAL */ # define MHD_SCKT_EINVAL_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EINVAL */ # ifdef EFAULT # define MHD_SCKT_EFAUL_ EFAULT # else /* ! EFAULT */ # define MHD_SCKT_EFAUL_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EFAULT */ # ifdef ENOSYS # define MHD_SCKT_ENOSYS_ ENOSYS # else /* ! ENOSYS */ # define MHD_SCKT_ENOSYS_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOSYS */ # ifdef ENOTSUP # define MHD_SCKT_ENOTSUP_ ENOTSUP # else /* ! ENOTSUP */ # define MHD_SCKT_ENOTSUP_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOTSUP */ # ifdef EOPNOTSUPP # define MHD_SCKT_EOPNOTSUPP_ EOPNOTSUPP # else /* ! EOPNOTSUPP */ # define MHD_SCKT_EOPNOTSUPP_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EOPNOTSUPP */ # ifdef EACCES # define MHD_SCKT_EACCESS_ EACCES # else /* ! EACCES */ # define MHD_SCKT_EACCESS_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EACCES */ # ifdef ENETDOWN # define MHD_SCKT_ENETDOWN_ ENETDOWN # else /* ! ENETDOWN */ # define MHD_SCKT_ENETDOWN_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENETDOWN */ #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_SCKT_EAGAIN_ WSAEWOULDBLOCK # define MHD_SCKT_EWOULDBLOCK_ WSAEWOULDBLOCK # define MHD_SCKT_EINTR_ WSAEINTR # define MHD_SCKT_ECONNRESET_ WSAECONNRESET # define MHD_SCKT_ECONNABORTED_ WSAECONNABORTED # define MHD_SCKT_ENOTCONN_ WSAENOTCONN # define MHD_SCKT_EMFILE_ WSAEMFILE # define MHD_SCKT_ENFILE_ MHD_SCKT_MISSING_ERR_CODE_ # define MHD_SCKT_ENOMEM_ MHD_SCKT_MISSING_ERR_CODE_ # define MHD_SCKT_ENOBUFS_ WSAENOBUFS # define MHD_SCKT_EBADF_ WSAEBADF # define MHD_SCKT_ENOTSOCK_ WSAENOTSOCK # define MHD_SCKT_EINVAL_ WSAEINVAL # define MHD_SCKT_EFAUL_ WSAEFAULT # define MHD_SCKT_ENOSYS_ MHD_SCKT_MISSING_ERR_CODE_ # define MHD_SCKT_ENOTSUP_ MHD_SCKT_MISSING_ERR_CODE_ # define MHD_SCKT_EOPNOTSUPP_ WSAEOPNOTSUPP # define MHD_SCKT_EACCESS_ WSAEACCES # define MHD_SCKT_ENETDOWN_ WSAENETDOWN #endif /** * MHD_socket_error_ return system native error code for last socket error. * @return system error code for last socket error. */ #if defined(MHD_POSIX_SOCKETS) # define MHD_socket_get_error_() (errno) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_socket_get_error_() WSAGetLastError () #endif #ifdef MHD_WINSOCK_SOCKETS /* POSIX-W32 sockets compatibility functions */ /** * Return pointer to string description of specified WinSock error * @param err the WinSock error code. * @return pointer to string description of specified WinSock error. */ const char *MHD_W32_strerror_winsock_ (int err); #endif /* MHD_WINSOCK_SOCKETS */ /* MHD_socket_last_strerr_ is description string of specified socket error code */ #if defined(MHD_POSIX_SOCKETS) # define MHD_socket_strerr_(err) strerror ((err)) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_socket_strerr_(err) MHD_W32_strerror_winsock_ ((err)) #endif /* MHD_socket_last_strerr_ is description string of last errno (non-W32) / * description string of last socket error (W32) */ #define MHD_socket_last_strerr_() MHD_socket_strerr_ (MHD_socket_get_error_ ()) /** * MHD_socket_fset_error_() set socket system native error code. */ #if defined(MHD_POSIX_SOCKETS) # define MHD_socket_fset_error_(err) (errno = (err)) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_socket_fset_error_(err) (WSASetLastError ((err))) #endif /** * MHD_socket_try_set_error_() set socket system native error code if * specified code is defined on system. * @return non-zero if specified @a err code is defined on system * and error was set; * zero if specified @a err code is not defined on system * and error was not set. */ #define MHD_socket_try_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ != (err)) ? \ (MHD_socket_fset_error_ ((err)), ! 0) : \ 0) /** * MHD_socket_set_error_() set socket system native error code to * specified code or replacement code if specified code is not * defined on system. */ #if defined(MHD_POSIX_SOCKETS) # if defined(ENOSYS) # define MHD_socket_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ == (err)) ? \ (errno = ENOSYS) : (errno = (err)) ) # elif defined(EOPNOTSUPP) # define MHD_socket_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ == (err)) ? \ (errno = EOPNOTSUPP) : (errno = \ (err)) ) # elif defined (EFAULT) # define MHD_socket_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ == (err)) ? \ (errno = EFAULT) : (errno = (err)) ) # elif defined (EINVAL) # define MHD_socket_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ == (err)) ? \ (errno = EINVAL) : (errno = (err)) ) # else /* !EOPNOTSUPP && !EFAULT && !EINVAL */ # warning \ No suitable replacement for missing socket error code is found. Edit this file and add replacement code which is defined on system. # define MHD_socket_set_error_(err) (errno = (err)) # endif /* !EOPNOTSUPP && !EFAULT && !EINVAL*/ #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_socket_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ == (err)) ? \ (WSASetLastError ((WSAEOPNOTSUPP))) : \ (WSASetLastError ((err))) ) #endif /** * Check whether given socket error is equal to specified system * native MHD_SCKT_E*_ code. * If platform don't have specific error code, result is * always boolean false. * @return boolean true if @a code is real error code and * @a err equals to MHD_SCKT_E*_ @a code; * boolean false otherwise */ #define MHD_SCKT_ERR_IS_(err,code) ( (MHD_SCKT_MISSING_ERR_CODE_ != (code)) && \ ((code) == (err)) ) /** * Check whether last socket error is equal to specified system * native MHD_SCKT_E*_ code. * If platform don't have specific error code, result is * always boolean false. * @return boolean true if @a code is real error code and * last socket error equals to MHD_SCKT_E*_ @a code; * boolean false otherwise */ #define MHD_SCKT_LAST_ERR_IS_(code) MHD_SCKT_ERR_IS_ (MHD_socket_get_error_ (), \ (code)) /* Specific error code checks */ /** * Check whether given socket error is equal to system's * socket error codes for EINTR. * @return boolean true if @a err is equal to sockets' EINTR code; * boolean false otherwise. */ #define MHD_SCKT_ERR_IS_EINTR_(err) MHD_SCKT_ERR_IS_ ((err),MHD_SCKT_EINTR_) /** * Check whether given socket error is equal to system's * socket error codes for EAGAIN or EWOULDBLOCK. * @return boolean true if @a err is equal to sockets' EAGAIN or EWOULDBLOCK codes; * boolean false otherwise. */ #if MHD_SCKT_EAGAIN_ == MHD_SCKT_EWOULDBLOCK_ # define MHD_SCKT_ERR_IS_EAGAIN_(err) MHD_SCKT_ERR_IS_ ((err),MHD_SCKT_EAGAIN_) #else /* MHD_SCKT_EAGAIN_ != MHD_SCKT_EWOULDBLOCK_ */ # define MHD_SCKT_ERR_IS_EAGAIN_(err) (MHD_SCKT_ERR_IS_ ((err), \ MHD_SCKT_EAGAIN_) || \ MHD_SCKT_ERR_IS_ ((err), \ MHD_SCKT_EWOULDBLOCK_) ) #endif /* MHD_SCKT_EAGAIN_ != MHD_SCKT_EWOULDBLOCK_ */ /** * Check whether given socket error is any kind of "low resource" error. * @return boolean true if @a err is any kind of "low resource" error, * boolean false otherwise. */ #define MHD_SCKT_ERR_IS_LOW_RESOURCES_(err) (MHD_SCKT_ERR_IS_ ((err), \ MHD_SCKT_EMFILE_) \ || \ MHD_SCKT_ERR_IS_ ((err), \ MHD_SCKT_ENFILE_) \ || \ MHD_SCKT_ERR_IS_ ((err), \ MHD_SCKT_ENOMEM_) \ || \ MHD_SCKT_ERR_IS_ ((err), \ MHD_SCKT_ENOBUFS_) ) /** * Check whether is given socket error is type of "incoming connection * was disconnected before 'accept()' is called". * @return boolean true is @a err match described socket error code, * boolean false otherwise. */ #if defined(MHD_POSIX_SOCKETS) # define MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_(err) MHD_SCKT_ERR_IS_ ((err), \ MHD_SCKT_ECONNABORTED_) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_(err) MHD_SCKT_ERR_IS_ ((err), \ MHD_SCKT_ECONNRESET_) #endif /** * Check whether is given socket error is type of "connection was terminated * by remote side". * @return boolean true is @a err match described socket error code, * boolean false otherwise. */ #define MHD_SCKT_ERR_IS_REMOTE_DISCNN_(err) (MHD_SCKT_ERR_IS_ ((err), \ MHD_SCKT_ECONNRESET_) \ || \ MHD_SCKT_ERR_IS_ ((err), \ MHD_SCKT_ECONNABORTED_)) /* Specific error code set */ /** * Set socket's error code to ENOMEM or equivalent if ENOMEM is not * available on platform. */ #if MHD_SCKT_MISSING_ERR_CODE_ != MHD_SCKT_ENOMEM_ # define MHD_socket_set_error_to_ENOMEM() MHD_socket_set_error_ ( \ MHD_SCKT_ENOMEM_) #elif MHD_SCKT_MISSING_ERR_CODE_ != MHD_SCKT_ENOBUFS_ # define MHD_socket_set_error_to_ENOMEM() MHD_socket_set_error_ ( \ MHD_SCKT_ENOBUFS_) #else # warning \ No suitable replacement for ENOMEM error codes is found. Edit this file and add replacement code which is defined on system. # define MHD_socket_set_error_to_ENOMEM() MHD_socket_set_error_ ( \ MHD_SCKT_ENOMEM_) #endif /* Socket functions */ #if defined(AF_LOCAL) # define MHD_SCKT_LOCAL AF_LOCAL #elif defined(AF_UNIX) # define MHD_SCKT_LOCAL AF_UNIX #endif /* AF_UNIX */ #if defined(MHD_POSIX_SOCKETS) && defined(MHD_SCKT_LOCAL) # define MHD_socket_pair_(fdarr) (! socketpair (MHD_SCKT_LOCAL, SOCK_STREAM, 0, \ (fdarr))) # if defined(HAVE_SOCK_NONBLOCK) # define MHD_socket_pair_nblk_(fdarr) (! socketpair (MHD_SCKT_LOCAL, \ SOCK_STREAM \ | SOCK_NONBLOCK, 0, \ (fdarr))) # endif /* HAVE_SOCK_NONBLOCK*/ #elif defined(MHD_WINSOCK_SOCKETS) /** * Create pair of mutually connected TCP/IP sockets on loopback address * @param sockets_pair array to receive resulted sockets * @param non_blk if set to non-zero value, sockets created in non-blocking mode * otherwise sockets will be in blocking mode * @return non-zero if succeeded, zero otherwise */ int MHD_W32_socket_pair_ (SOCKET sockets_pair[2], int non_blk); # define MHD_socket_pair_(fdarr) MHD_W32_socket_pair_ ((fdarr), 0) # define MHD_socket_pair_nblk_(fdarr) MHD_W32_socket_pair_ ((fdarr), 1) #endif /** * Add @a fd to the @a set. If @a fd is * greater than @a max_fd, set @a max_fd to @a fd. * * @param fd file descriptor to add to the @a set * @param set set to modify * @param max_fd maximum value to potentially update * @param fd_setsize value of FD_SETSIZE * @return non-zero if succeeded, zero otherwise */ int MHD_add_to_fd_set_ (MHD_socket fd, fd_set *set, MHD_socket *max_fd, unsigned int fd_setsize); /** * Change socket options to be non-blocking. * * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise */ int MHD_socket_nonblocking_ (MHD_socket sock); /** * Change socket options to be non-inheritable. * * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise * @warning Does not set socket error on W32. */ int MHD_socket_noninheritable_ (MHD_socket sock); #if defined(SOL_SOCKET) && defined(SO_NOSIGPIPE) static const int _MHD_socket_int_one = 1; /** * Change socket options to no signal on remote disconnect. * * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise */ # define MHD_socket_nosignal_(sock) \ (! setsockopt ((sock),SOL_SOCKET,SO_NOSIGPIPE,&_MHD_socket_int_one, \ sizeof(_MHD_socket_int_one))) #endif /* SOL_SOCKET && SO_NOSIGPIPE */ /** * Create a listen socket, with noninheritable flag if possible. * * @param pf protocol family to use * @return created socket or MHD_INVALID_SOCKET in case of errors */ MHD_socket MHD_socket_create_listen_ (int pf); #endif /* ! MHD_SOCKETS_H */ libmicrohttpd-1.0.1/src/lib/connection_call_handlers.h0000644000175000017500000000441114417460232016561 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_call_handlers.h * @brief function to call event handlers based on event mask * @author Christian Grothoff */ #ifndef CONNECTION_CALL_HANDLERS_H #define CONNECTION_CALL_HANDLERS_H /** * Call the handlers for a connection in the appropriate order based * on the readiness as detected by the event loop. * * @param con connection to handle * @param read_ready set if the socket is ready for reading * @param write_ready set if the socket is ready for writing * @param force_close set if a hard error was detected on the socket; * if this information is not available, simply pass #MHD_NO * @return #MHD_YES to continue normally, * #MHD_NO if a serious error was encountered and the * connection is to be closed. */ int MHD_connection_call_handlers_ (struct MHD_Connection *con, bool read_ready, bool write_ready, bool force_close) MHD_NONNULL (1); /** * This function was created to handle per-request processing that * has to happen even if the socket cannot be read or written to. * @remark To be called only from thread that process request's * recv(), send() and response. * * @param request the request to handle * @return true if we should continue to process the * request (not dead yet), false if it died */ bool MHD_request_handle_idle_ (struct MHD_Request *request) MHD_NONNULL (1); #endif libmicrohttpd-1.0.1/src/lib/action_from_response.c0000644000175000017500000001052114417460232015757 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/action_from_response.c * @brief implementation of #MHD_action_from_response() * @author Christian Grothoff */ #include "internal.h" #include "connection_call_handlers.h" /** * A response was given as the desired action for a @a request. * Queue the response for the request. * * @param cls the `struct MHD_Response` * @param request the request we are processing * @return #MHD_SC_OK on success */ static enum MHD_StatusCode response_action (void *cls, struct MHD_Request *request) { struct MHD_Response *response = cls; struct MHD_Daemon *daemon = request->daemon; /* If daemon was shut down in parallel, * response will be aborted now or on later stage. */ if (daemon->shutdown) return MHD_SC_DAEMON_ALREADY_SHUTDOWN; #ifdef UPGRADE_SUPPORT if ( (NULL != response->upgrade_handler) && daemon->disallow_upgrade) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_UPGRADE_ON_DAEMON_WITH_UPGRADE_DISALLOWED, _ ( "Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n")); #endif return MHD_SC_UPGRADE_ON_DAEMON_WITH_UPGRADE_DISALLOWED; } #endif /* UPGRADE_SUPPORT */ request->response = response; #if defined(_MHD_HAVE_SENDFILE) if ( (-1 == response->fd) #if HTTPS_SUPPORT || (NULL != daemon->tls_api) #endif ) request->resp_sender = MHD_resp_sender_std; else request->resp_sender = MHD_resp_sender_sendfile; #endif /* _MHD_HAVE_SENDFILE */ if ( (MHD_METHOD_HEAD == request->method) || (MHD_HTTP_OK > response->status_code) || (MHD_HTTP_NO_CONTENT == response->status_code) || (MHD_HTTP_NOT_MODIFIED == response->status_code) ) { /* if this is a "HEAD" request, or a status code for which a body is not allowed, pretend that we have already sent the full message body. */ request->response_write_position = response->total_size; } if ( (MHD_REQUEST_HEADERS_PROCESSED == request->state) && ( (MHD_METHOD_POST == request->method) || (MHD_METHOD_PUT == request->method) ) ) { /* response was queued "early", refuse to read body / footers or further requests! */ request->connection->read_closed = true; request->state = MHD_REQUEST_FOOTERS_RECEIVED; } if (! request->in_idle) (void) MHD_request_handle_idle_ (request); return MHD_SC_OK; } /** * Converts a @a response to an action. If @a consume * is set, the reference to the @a response is consumed * by the conversion. If @a consume is #MHD_NO, then * the response can be converted to actions in the future. * However, the @a response is frozen by this step and * must no longer be modified (i.e. by setting headers). * * @param response response to convert, not NULL * @param destroy_after_use should the response object be consumed? * @return corresponding action, never returns NULL * * Implementation note: internally, this is largely just * a cast (and possibly an RC increment operation), * as a response *is* an action. As no memory is * allocated, this operation cannot fail. */ _MHD_EXTERN const struct MHD_Action * MHD_action_from_response (struct MHD_Response *response, enum MHD_Bool destroy_after_use) { response->action.action = &response_action; response->action.action_cls = response; if (! destroy_after_use) { MHD_mutex_lock_chk_ (&response->mutex); response->reference_count++; MHD_mutex_unlock_chk_ (&response->mutex); } return &response->action; } /* end of action_from_response */ libmicrohttpd-1.0.1/src/lib/daemon_select.h0000644000175000017500000000331114417460232014347 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_select.h * @brief non-public functions provided by daemon_select.c * @author Christian Grothoff */ #ifndef DAEMON_SELECT_H #define DAEMON_SELECT_H /** * Main internal select() call. Will compute select sets, call * select() and then #internal_run_from_select() with the result. * * @param daemon daemon to run select() loop for * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_select_ (struct MHD_Daemon *daemon, int may_block) MHD_NONNULL (1); #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Process upgraded connection with a select loop. * We are in our own thread, only processing @a con * * @param con connection to process */ void MHD_daemon_upgrade_connection_with_select_ (struct MHD_Connection *con) MHD_NONNULL (1); #endif #endif libmicrohttpd-1.0.1/src/lib/connection_cleanup.h0000644000175000017500000000260514417460232015420 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_cleanup.h * @brief functions to cleanup completed connection * @author Christian Grothoff */ #ifndef CONNECTION_CLEANUP_H #define CONNECTION_CLEANUP_H /** * Free resources associated with all closed connections. (destroy * responses, free buffers, etc.). All closed connections are kept in * the "cleanup" doubly-linked list. * * @remark To be called only from thread that process daemon's * select()/poll()/etc. * * @param daemon daemon to clean up */ void MHD_connection_cleanup_ (struct MHD_Daemon *daemon) MHD_NONNULL (1); #endif libmicrohttpd-1.0.1/src/lib/action_continue.c0000644000175000017500000000325714417460232014732 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/action_continue.c * @brief implementation of MHD_action_continue() * @author Christian Grothoff */ #include "internal.h" /** * The continue action is being run. Continue * handling the upload. * * @param cls NULL * @param request the request to apply the action to * @return #MHD_SC_OK on success */ static enum MHD_StatusCode cont_action (void *cls, struct MHD_Request *request) { (void) cls; (void) request; /* not sure yet, but this function body may just legitimately stay empty... */ return MHD_SC_OK; } /** * Action telling MHD to continue processing the upload. * * @return action operation, never NULL */ const struct MHD_Action * MHD_action_continue (void) { static struct MHD_Action acont = { .action = &cont_action, .action_cls = NULL }; return &acont; } /* end of action_continue.c */ libmicrohttpd-1.0.1/src/lib/Makefile.in0000644000175000017500000032210314566140141013443 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @W32_SHARED_LIB_EXP_TRUE@am__append_1 = $(lt_cv_objdir)/libmicrohttpd2.lib $(lt_cv_objdir)/libmicrohttpd2.def $(lt_cv_objdir)/libmicrohttpd2.exp @W32_SHARED_LIB_EXP_TRUE@am__append_2 = $(lt_cv_objdir)/libmicrohttpd2.lib $(lt_cv_objdir)/libmicrohttpd2.def $(lt_cv_objdir)/libmicrohttpd2.exp @W32_STATIC_LIB_TRUE@am__append_3 = $(lt_cv_objdir)/libmicrohttpd2-static.lib @W32_STATIC_LIB_TRUE@am__append_4 = $(lt_cv_objdir)/libmicrohttpd2-static.lib @MHD_HAVE_TLS_PLUGIN_TRUE@am__append_5 = \ @MHD_HAVE_TLS_PLUGIN_TRUE@ -ldl @HAVE_W32_TRUE@am__append_6 = $(MHD_DLL_RES_LO) @USE_COVERAGE_TRUE@am__append_7 = --coverage @MHD_USE_SYS_TSEARCH_FALSE@am__append_8 = \ @MHD_USE_SYS_TSEARCH_FALSE@ tsearch.c tsearch.h subdir = src/lib ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = libmicrohttpd2_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__append_6) am__libmicrohttpd2_la_SOURCES_DIST = action_continue.c \ action_from_response.c action_parse_post.c \ action_process_upload.c action_suspend.c connection_add.c \ connection_add.h connection_call_handlers.c \ connection_call_handlers.h connection_cleanup.c \ connection_cleanup.h connection_close.c connection_close.h \ connection_finish_forward.c connection_finish_forward.h \ connection_info.c connection_options.c \ connection_update_last_activity.c \ connection_update_last_activity.h \ daemon_close_all_connections.c daemon_close_all_connections.h \ daemon_create.c daemon_destroy.c daemon_epoll.c daemon_epoll.h \ daemon_get_timeout.c daemon_info.c daemon_ip_limit.c \ daemon_ip_limit.h daemon_options.c daemon_poll.c daemon_poll.h \ daemon_run.c daemon_select.c daemon_select.h daemon_start.c \ daemon_quiesce.c init.c init.h internal.c internal.h \ memorypool.c memorypool.h mhd_assert.h mhd_byteorder.h \ mhd_compat.c mhd_compat.h mhd_itc.c mhd_itc.h mhd_itc_types.h \ mhd_limits.h mhd_locks.h mhd_mono_clock.c mhd_mono_clock.h \ mhd_str.c mhd_str.h mhd_sockets.c mhd_sockets.h mhd_threads.c \ mhd_threads.h response.c response_for_upgrade.c \ response_from_buffer.c response_from_callback.c \ response_from_fd.c response_options.c reason_phrase.c \ request.c request_info.c request_resume.c request_resume.h \ sysfdsetsize.c sysfdsetsize.h upgrade_process.c \ upgrade_process.h panic.c version.c tsearch.c tsearch.h @MHD_USE_SYS_TSEARCH_FALSE@am__objects_1 = \ @MHD_USE_SYS_TSEARCH_FALSE@ libmicrohttpd2_la-tsearch.lo am_libmicrohttpd2_la_OBJECTS = libmicrohttpd2_la-action_continue.lo \ libmicrohttpd2_la-action_from_response.lo \ libmicrohttpd2_la-action_parse_post.lo \ libmicrohttpd2_la-action_process_upload.lo \ libmicrohttpd2_la-action_suspend.lo \ libmicrohttpd2_la-connection_add.lo \ libmicrohttpd2_la-connection_call_handlers.lo \ libmicrohttpd2_la-connection_cleanup.lo \ libmicrohttpd2_la-connection_close.lo \ libmicrohttpd2_la-connection_finish_forward.lo \ libmicrohttpd2_la-connection_info.lo \ libmicrohttpd2_la-connection_options.lo \ libmicrohttpd2_la-connection_update_last_activity.lo \ libmicrohttpd2_la-daemon_close_all_connections.lo \ libmicrohttpd2_la-daemon_create.lo \ libmicrohttpd2_la-daemon_destroy.lo \ libmicrohttpd2_la-daemon_epoll.lo \ libmicrohttpd2_la-daemon_get_timeout.lo \ libmicrohttpd2_la-daemon_info.lo \ libmicrohttpd2_la-daemon_ip_limit.lo \ libmicrohttpd2_la-daemon_options.lo \ libmicrohttpd2_la-daemon_poll.lo \ libmicrohttpd2_la-daemon_run.lo \ libmicrohttpd2_la-daemon_select.lo \ libmicrohttpd2_la-daemon_start.lo \ libmicrohttpd2_la-daemon_quiesce.lo libmicrohttpd2_la-init.lo \ libmicrohttpd2_la-internal.lo libmicrohttpd2_la-memorypool.lo \ libmicrohttpd2_la-mhd_compat.lo libmicrohttpd2_la-mhd_itc.lo \ libmicrohttpd2_la-mhd_mono_clock.lo \ libmicrohttpd2_la-mhd_str.lo libmicrohttpd2_la-mhd_sockets.lo \ libmicrohttpd2_la-mhd_threads.lo libmicrohttpd2_la-response.lo \ libmicrohttpd2_la-response_for_upgrade.lo \ libmicrohttpd2_la-response_from_buffer.lo \ libmicrohttpd2_la-response_from_callback.lo \ libmicrohttpd2_la-response_from_fd.lo \ libmicrohttpd2_la-response_options.lo \ libmicrohttpd2_la-reason_phrase.lo \ libmicrohttpd2_la-request.lo libmicrohttpd2_la-request_info.lo \ libmicrohttpd2_la-request_resume.lo \ libmicrohttpd2_la-sysfdsetsize.lo \ libmicrohttpd2_la-upgrade_process.lo \ libmicrohttpd2_la-panic.lo libmicrohttpd2_la-version.lo \ $(am__objects_1) libmicrohttpd2_la_OBJECTS = $(am_libmicrohttpd2_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libmicrohttpd2_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) \ $(libmicrohttpd2_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = \ ./$(DEPDIR)/libmicrohttpd2_la-action_continue.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-action_from_response.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-action_parse_post.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-action_process_upload.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-action_suspend.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-connection_add.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-connection_call_handlers.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-connection_cleanup.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-connection_close.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-connection_finish_forward.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-connection_info.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-connection_options.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-connection_update_last_activity.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_close_all_connections.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_create.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_destroy.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_epoll.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_get_timeout.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_info.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_ip_limit.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_options.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_poll.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_quiesce.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_run.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_select.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-daemon_start.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-init.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-internal.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-memorypool.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-mhd_compat.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-mhd_itc.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-mhd_mono_clock.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-mhd_sockets.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-mhd_str.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-mhd_threads.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-panic.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-reason_phrase.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-request.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-request_info.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-request_resume.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-response.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-response_for_upgrade.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-response_from_buffer.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-response_from_callback.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-response_from_fd.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-response_options.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-sysfdsetsize.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-tsearch.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-upgrade_process.Plo \ ./$(DEPDIR)/libmicrohttpd2_la-version.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libmicrohttpd2_la_SOURCES) DIST_SOURCES = $(am__libmicrohttpd2_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac DATA = $(noinst_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.in \ $(top_srcdir)/build-aux/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # This Makefile.am is in the public domain AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/lib AM_CFLAGS = $(HIDDEN_VISIBILITY_CFLAGS) $(am__append_7) # Call "libmicrohttpd2" for now, but only while under # development. Once we have 'compat' working, this should be changed! noinst_LTLIBRARIES = \ libmicrohttpd2.la noinst_DATA = $(am__append_1) $(am__append_3) MOSTLYCLEANFILES = $(am__append_2) $(am__append_4) @W32_SHARED_LIB_EXP_FALSE@W32_MHD_LIB_LDFLAGS = @W32_SHARED_LIB_EXP_TRUE@W32_MHD_LIB_LDFLAGS = -Wl,--output-def,$(lt_cv_objdir)/libmicrohttpd2.def -XCClinker -static-libgcc libmicrohttpd2_la_SOURCES = action_continue.c action_from_response.c \ action_parse_post.c action_process_upload.c action_suspend.c \ connection_add.c connection_add.h connection_call_handlers.c \ connection_call_handlers.h connection_cleanup.c \ connection_cleanup.h connection_close.c connection_close.h \ connection_finish_forward.c connection_finish_forward.h \ connection_info.c connection_options.c \ connection_update_last_activity.c \ connection_update_last_activity.h \ daemon_close_all_connections.c daemon_close_all_connections.h \ daemon_create.c daemon_destroy.c daemon_epoll.c daemon_epoll.h \ daemon_get_timeout.c daemon_info.c daemon_ip_limit.c \ daemon_ip_limit.h daemon_options.c daemon_poll.c daemon_poll.h \ daemon_run.c daemon_select.c daemon_select.h daemon_start.c \ daemon_quiesce.c init.c init.h internal.c internal.h \ memorypool.c memorypool.h mhd_assert.h mhd_byteorder.h \ mhd_compat.c mhd_compat.h mhd_itc.c mhd_itc.h mhd_itc_types.h \ mhd_limits.h mhd_locks.h mhd_mono_clock.c mhd_mono_clock.h \ mhd_str.c mhd_str.h mhd_sockets.c mhd_sockets.h mhd_threads.c \ mhd_threads.h response.c response_for_upgrade.c \ response_from_buffer.c response_from_callback.c \ response_from_fd.c response_options.c reason_phrase.c \ request.c request_info.c request_resume.c request_resume.h \ sysfdsetsize.c sysfdsetsize.h upgrade_process.c \ upgrade_process.h panic.c version.c $(am__append_8) libmicrohttpd2_la_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) \ -DBUILDING_MHD_LIB=1 libmicrohttpd2_la_CFLAGS = \ $(AM_CFLAGS) $(MHD_LIB_CFLAGS) $(MHD_TLS_LIB_CFLAGS) libmicrohttpd2_la_LDFLAGS = $(MHD_LIB_LDFLAGS) $(W32_MHD_LIB_LDFLAGS) \ $(MHD_TLS_LIB_LDFLAGS) -version-info 0:0:0 $(am__append_5) libmicrohttpd2_la_LIBADD = $(MHD_LIBDEPS) $(MHD_TLS_LIBDEPS) \ $(am__append_6) @HAVE_W32_TRUE@MHD_DLL_RES_SRC = ../microhttpd/microhttpd_dll_res.rc @HAVE_W32_TRUE@MHD_DLL_RES_LO = libmicrohttpd2_la-$(MHD_DLL_RES_SRC:.rc=.lo) @HAVE_W32_TRUE@EXTRA_libmicrohttpd2_la_DEPENDENCIES = $(MHD_DLL_RES_LO) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj .rc $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/lib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/lib/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libmicrohttpd2.la: $(libmicrohttpd2_la_OBJECTS) $(libmicrohttpd2_la_DEPENDENCIES) $(EXTRA_libmicrohttpd2_la_DEPENDENCIES) $(AM_V_CCLD)$(libmicrohttpd2_la_LINK) $(libmicrohttpd2_la_OBJECTS) $(libmicrohttpd2_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-action_continue.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-action_from_response.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-action_parse_post.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-action_process_upload.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-action_suspend.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-connection_add.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-connection_call_handlers.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-connection_cleanup.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-connection_close.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-connection_finish_forward.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-connection_info.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-connection_options.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-connection_update_last_activity.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_close_all_connections.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_create.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_destroy.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_epoll.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_get_timeout.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_info.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_ip_limit.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_options.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_poll.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_quiesce.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_run.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_select.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-daemon_start.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-init.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-internal.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-memorypool.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-mhd_compat.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-mhd_itc.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-mhd_mono_clock.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-mhd_sockets.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-mhd_str.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-mhd_threads.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-panic.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-reason_phrase.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-request.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-request_info.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-request_resume.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-response.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-response_for_upgrade.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-response_from_buffer.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-response_from_callback.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-response_from_fd.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-response_options.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-sysfdsetsize.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-tsearch.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-upgrade_process.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd2_la-version.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< libmicrohttpd2_la-action_continue.lo: action_continue.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-action_continue.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-action_continue.Tpo -c -o libmicrohttpd2_la-action_continue.lo `test -f 'action_continue.c' || echo '$(srcdir)/'`action_continue.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-action_continue.Tpo $(DEPDIR)/libmicrohttpd2_la-action_continue.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='action_continue.c' object='libmicrohttpd2_la-action_continue.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-action_continue.lo `test -f 'action_continue.c' || echo '$(srcdir)/'`action_continue.c libmicrohttpd2_la-action_from_response.lo: action_from_response.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-action_from_response.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-action_from_response.Tpo -c -o libmicrohttpd2_la-action_from_response.lo `test -f 'action_from_response.c' || echo '$(srcdir)/'`action_from_response.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-action_from_response.Tpo $(DEPDIR)/libmicrohttpd2_la-action_from_response.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='action_from_response.c' object='libmicrohttpd2_la-action_from_response.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-action_from_response.lo `test -f 'action_from_response.c' || echo '$(srcdir)/'`action_from_response.c libmicrohttpd2_la-action_parse_post.lo: action_parse_post.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-action_parse_post.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-action_parse_post.Tpo -c -o libmicrohttpd2_la-action_parse_post.lo `test -f 'action_parse_post.c' || echo '$(srcdir)/'`action_parse_post.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-action_parse_post.Tpo $(DEPDIR)/libmicrohttpd2_la-action_parse_post.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='action_parse_post.c' object='libmicrohttpd2_la-action_parse_post.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-action_parse_post.lo `test -f 'action_parse_post.c' || echo '$(srcdir)/'`action_parse_post.c libmicrohttpd2_la-action_process_upload.lo: action_process_upload.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-action_process_upload.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-action_process_upload.Tpo -c -o libmicrohttpd2_la-action_process_upload.lo `test -f 'action_process_upload.c' || echo '$(srcdir)/'`action_process_upload.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-action_process_upload.Tpo $(DEPDIR)/libmicrohttpd2_la-action_process_upload.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='action_process_upload.c' object='libmicrohttpd2_la-action_process_upload.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-action_process_upload.lo `test -f 'action_process_upload.c' || echo '$(srcdir)/'`action_process_upload.c libmicrohttpd2_la-action_suspend.lo: action_suspend.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-action_suspend.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-action_suspend.Tpo -c -o libmicrohttpd2_la-action_suspend.lo `test -f 'action_suspend.c' || echo '$(srcdir)/'`action_suspend.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-action_suspend.Tpo $(DEPDIR)/libmicrohttpd2_la-action_suspend.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='action_suspend.c' object='libmicrohttpd2_la-action_suspend.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-action_suspend.lo `test -f 'action_suspend.c' || echo '$(srcdir)/'`action_suspend.c libmicrohttpd2_la-connection_add.lo: connection_add.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-connection_add.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-connection_add.Tpo -c -o libmicrohttpd2_la-connection_add.lo `test -f 'connection_add.c' || echo '$(srcdir)/'`connection_add.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-connection_add.Tpo $(DEPDIR)/libmicrohttpd2_la-connection_add.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection_add.c' object='libmicrohttpd2_la-connection_add.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-connection_add.lo `test -f 'connection_add.c' || echo '$(srcdir)/'`connection_add.c libmicrohttpd2_la-connection_call_handlers.lo: connection_call_handlers.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-connection_call_handlers.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-connection_call_handlers.Tpo -c -o libmicrohttpd2_la-connection_call_handlers.lo `test -f 'connection_call_handlers.c' || echo '$(srcdir)/'`connection_call_handlers.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-connection_call_handlers.Tpo $(DEPDIR)/libmicrohttpd2_la-connection_call_handlers.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection_call_handlers.c' object='libmicrohttpd2_la-connection_call_handlers.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-connection_call_handlers.lo `test -f 'connection_call_handlers.c' || echo '$(srcdir)/'`connection_call_handlers.c libmicrohttpd2_la-connection_cleanup.lo: connection_cleanup.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-connection_cleanup.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-connection_cleanup.Tpo -c -o libmicrohttpd2_la-connection_cleanup.lo `test -f 'connection_cleanup.c' || echo '$(srcdir)/'`connection_cleanup.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-connection_cleanup.Tpo $(DEPDIR)/libmicrohttpd2_la-connection_cleanup.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection_cleanup.c' object='libmicrohttpd2_la-connection_cleanup.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-connection_cleanup.lo `test -f 'connection_cleanup.c' || echo '$(srcdir)/'`connection_cleanup.c libmicrohttpd2_la-connection_close.lo: connection_close.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-connection_close.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-connection_close.Tpo -c -o libmicrohttpd2_la-connection_close.lo `test -f 'connection_close.c' || echo '$(srcdir)/'`connection_close.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-connection_close.Tpo $(DEPDIR)/libmicrohttpd2_la-connection_close.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection_close.c' object='libmicrohttpd2_la-connection_close.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-connection_close.lo `test -f 'connection_close.c' || echo '$(srcdir)/'`connection_close.c libmicrohttpd2_la-connection_finish_forward.lo: connection_finish_forward.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-connection_finish_forward.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-connection_finish_forward.Tpo -c -o libmicrohttpd2_la-connection_finish_forward.lo `test -f 'connection_finish_forward.c' || echo '$(srcdir)/'`connection_finish_forward.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-connection_finish_forward.Tpo $(DEPDIR)/libmicrohttpd2_la-connection_finish_forward.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection_finish_forward.c' object='libmicrohttpd2_la-connection_finish_forward.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-connection_finish_forward.lo `test -f 'connection_finish_forward.c' || echo '$(srcdir)/'`connection_finish_forward.c libmicrohttpd2_la-connection_info.lo: connection_info.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-connection_info.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-connection_info.Tpo -c -o libmicrohttpd2_la-connection_info.lo `test -f 'connection_info.c' || echo '$(srcdir)/'`connection_info.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-connection_info.Tpo $(DEPDIR)/libmicrohttpd2_la-connection_info.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection_info.c' object='libmicrohttpd2_la-connection_info.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-connection_info.lo `test -f 'connection_info.c' || echo '$(srcdir)/'`connection_info.c libmicrohttpd2_la-connection_options.lo: connection_options.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-connection_options.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-connection_options.Tpo -c -o libmicrohttpd2_la-connection_options.lo `test -f 'connection_options.c' || echo '$(srcdir)/'`connection_options.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-connection_options.Tpo $(DEPDIR)/libmicrohttpd2_la-connection_options.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection_options.c' object='libmicrohttpd2_la-connection_options.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-connection_options.lo `test -f 'connection_options.c' || echo '$(srcdir)/'`connection_options.c libmicrohttpd2_la-connection_update_last_activity.lo: connection_update_last_activity.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-connection_update_last_activity.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-connection_update_last_activity.Tpo -c -o libmicrohttpd2_la-connection_update_last_activity.lo `test -f 'connection_update_last_activity.c' || echo '$(srcdir)/'`connection_update_last_activity.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-connection_update_last_activity.Tpo $(DEPDIR)/libmicrohttpd2_la-connection_update_last_activity.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection_update_last_activity.c' object='libmicrohttpd2_la-connection_update_last_activity.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-connection_update_last_activity.lo `test -f 'connection_update_last_activity.c' || echo '$(srcdir)/'`connection_update_last_activity.c libmicrohttpd2_la-daemon_close_all_connections.lo: daemon_close_all_connections.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_close_all_connections.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_close_all_connections.Tpo -c -o libmicrohttpd2_la-daemon_close_all_connections.lo `test -f 'daemon_close_all_connections.c' || echo '$(srcdir)/'`daemon_close_all_connections.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_close_all_connections.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_close_all_connections.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_close_all_connections.c' object='libmicrohttpd2_la-daemon_close_all_connections.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_close_all_connections.lo `test -f 'daemon_close_all_connections.c' || echo '$(srcdir)/'`daemon_close_all_connections.c libmicrohttpd2_la-daemon_create.lo: daemon_create.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_create.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_create.Tpo -c -o libmicrohttpd2_la-daemon_create.lo `test -f 'daemon_create.c' || echo '$(srcdir)/'`daemon_create.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_create.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_create.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_create.c' object='libmicrohttpd2_la-daemon_create.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_create.lo `test -f 'daemon_create.c' || echo '$(srcdir)/'`daemon_create.c libmicrohttpd2_la-daemon_destroy.lo: daemon_destroy.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_destroy.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_destroy.Tpo -c -o libmicrohttpd2_la-daemon_destroy.lo `test -f 'daemon_destroy.c' || echo '$(srcdir)/'`daemon_destroy.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_destroy.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_destroy.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_destroy.c' object='libmicrohttpd2_la-daemon_destroy.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_destroy.lo `test -f 'daemon_destroy.c' || echo '$(srcdir)/'`daemon_destroy.c libmicrohttpd2_la-daemon_epoll.lo: daemon_epoll.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_epoll.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_epoll.Tpo -c -o libmicrohttpd2_la-daemon_epoll.lo `test -f 'daemon_epoll.c' || echo '$(srcdir)/'`daemon_epoll.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_epoll.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_epoll.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_epoll.c' object='libmicrohttpd2_la-daemon_epoll.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_epoll.lo `test -f 'daemon_epoll.c' || echo '$(srcdir)/'`daemon_epoll.c libmicrohttpd2_la-daemon_get_timeout.lo: daemon_get_timeout.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_get_timeout.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_get_timeout.Tpo -c -o libmicrohttpd2_la-daemon_get_timeout.lo `test -f 'daemon_get_timeout.c' || echo '$(srcdir)/'`daemon_get_timeout.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_get_timeout.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_get_timeout.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_get_timeout.c' object='libmicrohttpd2_la-daemon_get_timeout.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_get_timeout.lo `test -f 'daemon_get_timeout.c' || echo '$(srcdir)/'`daemon_get_timeout.c libmicrohttpd2_la-daemon_info.lo: daemon_info.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_info.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_info.Tpo -c -o libmicrohttpd2_la-daemon_info.lo `test -f 'daemon_info.c' || echo '$(srcdir)/'`daemon_info.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_info.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_info.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_info.c' object='libmicrohttpd2_la-daemon_info.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_info.lo `test -f 'daemon_info.c' || echo '$(srcdir)/'`daemon_info.c libmicrohttpd2_la-daemon_ip_limit.lo: daemon_ip_limit.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_ip_limit.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_ip_limit.Tpo -c -o libmicrohttpd2_la-daemon_ip_limit.lo `test -f 'daemon_ip_limit.c' || echo '$(srcdir)/'`daemon_ip_limit.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_ip_limit.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_ip_limit.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_ip_limit.c' object='libmicrohttpd2_la-daemon_ip_limit.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_ip_limit.lo `test -f 'daemon_ip_limit.c' || echo '$(srcdir)/'`daemon_ip_limit.c libmicrohttpd2_la-daemon_options.lo: daemon_options.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_options.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_options.Tpo -c -o libmicrohttpd2_la-daemon_options.lo `test -f 'daemon_options.c' || echo '$(srcdir)/'`daemon_options.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_options.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_options.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_options.c' object='libmicrohttpd2_la-daemon_options.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_options.lo `test -f 'daemon_options.c' || echo '$(srcdir)/'`daemon_options.c libmicrohttpd2_la-daemon_poll.lo: daemon_poll.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_poll.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_poll.Tpo -c -o libmicrohttpd2_la-daemon_poll.lo `test -f 'daemon_poll.c' || echo '$(srcdir)/'`daemon_poll.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_poll.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_poll.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_poll.c' object='libmicrohttpd2_la-daemon_poll.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_poll.lo `test -f 'daemon_poll.c' || echo '$(srcdir)/'`daemon_poll.c libmicrohttpd2_la-daemon_run.lo: daemon_run.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_run.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_run.Tpo -c -o libmicrohttpd2_la-daemon_run.lo `test -f 'daemon_run.c' || echo '$(srcdir)/'`daemon_run.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_run.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_run.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_run.c' object='libmicrohttpd2_la-daemon_run.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_run.lo `test -f 'daemon_run.c' || echo '$(srcdir)/'`daemon_run.c libmicrohttpd2_la-daemon_select.lo: daemon_select.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_select.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_select.Tpo -c -o libmicrohttpd2_la-daemon_select.lo `test -f 'daemon_select.c' || echo '$(srcdir)/'`daemon_select.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_select.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_select.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_select.c' object='libmicrohttpd2_la-daemon_select.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_select.lo `test -f 'daemon_select.c' || echo '$(srcdir)/'`daemon_select.c libmicrohttpd2_la-daemon_start.lo: daemon_start.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_start.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_start.Tpo -c -o libmicrohttpd2_la-daemon_start.lo `test -f 'daemon_start.c' || echo '$(srcdir)/'`daemon_start.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_start.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_start.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_start.c' object='libmicrohttpd2_la-daemon_start.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_start.lo `test -f 'daemon_start.c' || echo '$(srcdir)/'`daemon_start.c libmicrohttpd2_la-daemon_quiesce.lo: daemon_quiesce.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-daemon_quiesce.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-daemon_quiesce.Tpo -c -o libmicrohttpd2_la-daemon_quiesce.lo `test -f 'daemon_quiesce.c' || echo '$(srcdir)/'`daemon_quiesce.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-daemon_quiesce.Tpo $(DEPDIR)/libmicrohttpd2_la-daemon_quiesce.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon_quiesce.c' object='libmicrohttpd2_la-daemon_quiesce.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-daemon_quiesce.lo `test -f 'daemon_quiesce.c' || echo '$(srcdir)/'`daemon_quiesce.c libmicrohttpd2_la-init.lo: init.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-init.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-init.Tpo -c -o libmicrohttpd2_la-init.lo `test -f 'init.c' || echo '$(srcdir)/'`init.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-init.Tpo $(DEPDIR)/libmicrohttpd2_la-init.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='init.c' object='libmicrohttpd2_la-init.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-init.lo `test -f 'init.c' || echo '$(srcdir)/'`init.c libmicrohttpd2_la-internal.lo: internal.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-internal.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-internal.Tpo -c -o libmicrohttpd2_la-internal.lo `test -f 'internal.c' || echo '$(srcdir)/'`internal.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-internal.Tpo $(DEPDIR)/libmicrohttpd2_la-internal.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='internal.c' object='libmicrohttpd2_la-internal.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-internal.lo `test -f 'internal.c' || echo '$(srcdir)/'`internal.c libmicrohttpd2_la-memorypool.lo: memorypool.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-memorypool.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-memorypool.Tpo -c -o libmicrohttpd2_la-memorypool.lo `test -f 'memorypool.c' || echo '$(srcdir)/'`memorypool.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-memorypool.Tpo $(DEPDIR)/libmicrohttpd2_la-memorypool.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='memorypool.c' object='libmicrohttpd2_la-memorypool.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-memorypool.lo `test -f 'memorypool.c' || echo '$(srcdir)/'`memorypool.c libmicrohttpd2_la-mhd_compat.lo: mhd_compat.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-mhd_compat.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-mhd_compat.Tpo -c -o libmicrohttpd2_la-mhd_compat.lo `test -f 'mhd_compat.c' || echo '$(srcdir)/'`mhd_compat.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-mhd_compat.Tpo $(DEPDIR)/libmicrohttpd2_la-mhd_compat.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_compat.c' object='libmicrohttpd2_la-mhd_compat.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-mhd_compat.lo `test -f 'mhd_compat.c' || echo '$(srcdir)/'`mhd_compat.c libmicrohttpd2_la-mhd_itc.lo: mhd_itc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-mhd_itc.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-mhd_itc.Tpo -c -o libmicrohttpd2_la-mhd_itc.lo `test -f 'mhd_itc.c' || echo '$(srcdir)/'`mhd_itc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-mhd_itc.Tpo $(DEPDIR)/libmicrohttpd2_la-mhd_itc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_itc.c' object='libmicrohttpd2_la-mhd_itc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-mhd_itc.lo `test -f 'mhd_itc.c' || echo '$(srcdir)/'`mhd_itc.c libmicrohttpd2_la-mhd_mono_clock.lo: mhd_mono_clock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-mhd_mono_clock.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-mhd_mono_clock.Tpo -c -o libmicrohttpd2_la-mhd_mono_clock.lo `test -f 'mhd_mono_clock.c' || echo '$(srcdir)/'`mhd_mono_clock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-mhd_mono_clock.Tpo $(DEPDIR)/libmicrohttpd2_la-mhd_mono_clock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_mono_clock.c' object='libmicrohttpd2_la-mhd_mono_clock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-mhd_mono_clock.lo `test -f 'mhd_mono_clock.c' || echo '$(srcdir)/'`mhd_mono_clock.c libmicrohttpd2_la-mhd_str.lo: mhd_str.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-mhd_str.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-mhd_str.Tpo -c -o libmicrohttpd2_la-mhd_str.lo `test -f 'mhd_str.c' || echo '$(srcdir)/'`mhd_str.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-mhd_str.Tpo $(DEPDIR)/libmicrohttpd2_la-mhd_str.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_str.c' object='libmicrohttpd2_la-mhd_str.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-mhd_str.lo `test -f 'mhd_str.c' || echo '$(srcdir)/'`mhd_str.c libmicrohttpd2_la-mhd_sockets.lo: mhd_sockets.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-mhd_sockets.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-mhd_sockets.Tpo -c -o libmicrohttpd2_la-mhd_sockets.lo `test -f 'mhd_sockets.c' || echo '$(srcdir)/'`mhd_sockets.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-mhd_sockets.Tpo $(DEPDIR)/libmicrohttpd2_la-mhd_sockets.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_sockets.c' object='libmicrohttpd2_la-mhd_sockets.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-mhd_sockets.lo `test -f 'mhd_sockets.c' || echo '$(srcdir)/'`mhd_sockets.c libmicrohttpd2_la-mhd_threads.lo: mhd_threads.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-mhd_threads.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-mhd_threads.Tpo -c -o libmicrohttpd2_la-mhd_threads.lo `test -f 'mhd_threads.c' || echo '$(srcdir)/'`mhd_threads.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-mhd_threads.Tpo $(DEPDIR)/libmicrohttpd2_la-mhd_threads.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_threads.c' object='libmicrohttpd2_la-mhd_threads.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-mhd_threads.lo `test -f 'mhd_threads.c' || echo '$(srcdir)/'`mhd_threads.c libmicrohttpd2_la-response.lo: response.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-response.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-response.Tpo -c -o libmicrohttpd2_la-response.lo `test -f 'response.c' || echo '$(srcdir)/'`response.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-response.Tpo $(DEPDIR)/libmicrohttpd2_la-response.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='response.c' object='libmicrohttpd2_la-response.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-response.lo `test -f 'response.c' || echo '$(srcdir)/'`response.c libmicrohttpd2_la-response_for_upgrade.lo: response_for_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-response_for_upgrade.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-response_for_upgrade.Tpo -c -o libmicrohttpd2_la-response_for_upgrade.lo `test -f 'response_for_upgrade.c' || echo '$(srcdir)/'`response_for_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-response_for_upgrade.Tpo $(DEPDIR)/libmicrohttpd2_la-response_for_upgrade.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='response_for_upgrade.c' object='libmicrohttpd2_la-response_for_upgrade.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-response_for_upgrade.lo `test -f 'response_for_upgrade.c' || echo '$(srcdir)/'`response_for_upgrade.c libmicrohttpd2_la-response_from_buffer.lo: response_from_buffer.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-response_from_buffer.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-response_from_buffer.Tpo -c -o libmicrohttpd2_la-response_from_buffer.lo `test -f 'response_from_buffer.c' || echo '$(srcdir)/'`response_from_buffer.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-response_from_buffer.Tpo $(DEPDIR)/libmicrohttpd2_la-response_from_buffer.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='response_from_buffer.c' object='libmicrohttpd2_la-response_from_buffer.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-response_from_buffer.lo `test -f 'response_from_buffer.c' || echo '$(srcdir)/'`response_from_buffer.c libmicrohttpd2_la-response_from_callback.lo: response_from_callback.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-response_from_callback.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-response_from_callback.Tpo -c -o libmicrohttpd2_la-response_from_callback.lo `test -f 'response_from_callback.c' || echo '$(srcdir)/'`response_from_callback.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-response_from_callback.Tpo $(DEPDIR)/libmicrohttpd2_la-response_from_callback.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='response_from_callback.c' object='libmicrohttpd2_la-response_from_callback.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-response_from_callback.lo `test -f 'response_from_callback.c' || echo '$(srcdir)/'`response_from_callback.c libmicrohttpd2_la-response_from_fd.lo: response_from_fd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-response_from_fd.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-response_from_fd.Tpo -c -o libmicrohttpd2_la-response_from_fd.lo `test -f 'response_from_fd.c' || echo '$(srcdir)/'`response_from_fd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-response_from_fd.Tpo $(DEPDIR)/libmicrohttpd2_la-response_from_fd.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='response_from_fd.c' object='libmicrohttpd2_la-response_from_fd.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-response_from_fd.lo `test -f 'response_from_fd.c' || echo '$(srcdir)/'`response_from_fd.c libmicrohttpd2_la-response_options.lo: response_options.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-response_options.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-response_options.Tpo -c -o libmicrohttpd2_la-response_options.lo `test -f 'response_options.c' || echo '$(srcdir)/'`response_options.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-response_options.Tpo $(DEPDIR)/libmicrohttpd2_la-response_options.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='response_options.c' object='libmicrohttpd2_la-response_options.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-response_options.lo `test -f 'response_options.c' || echo '$(srcdir)/'`response_options.c libmicrohttpd2_la-reason_phrase.lo: reason_phrase.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-reason_phrase.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-reason_phrase.Tpo -c -o libmicrohttpd2_la-reason_phrase.lo `test -f 'reason_phrase.c' || echo '$(srcdir)/'`reason_phrase.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-reason_phrase.Tpo $(DEPDIR)/libmicrohttpd2_la-reason_phrase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='reason_phrase.c' object='libmicrohttpd2_la-reason_phrase.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-reason_phrase.lo `test -f 'reason_phrase.c' || echo '$(srcdir)/'`reason_phrase.c libmicrohttpd2_la-request.lo: request.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-request.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-request.Tpo -c -o libmicrohttpd2_la-request.lo `test -f 'request.c' || echo '$(srcdir)/'`request.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-request.Tpo $(DEPDIR)/libmicrohttpd2_la-request.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='request.c' object='libmicrohttpd2_la-request.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-request.lo `test -f 'request.c' || echo '$(srcdir)/'`request.c libmicrohttpd2_la-request_info.lo: request_info.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-request_info.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-request_info.Tpo -c -o libmicrohttpd2_la-request_info.lo `test -f 'request_info.c' || echo '$(srcdir)/'`request_info.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-request_info.Tpo $(DEPDIR)/libmicrohttpd2_la-request_info.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='request_info.c' object='libmicrohttpd2_la-request_info.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-request_info.lo `test -f 'request_info.c' || echo '$(srcdir)/'`request_info.c libmicrohttpd2_la-request_resume.lo: request_resume.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-request_resume.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-request_resume.Tpo -c -o libmicrohttpd2_la-request_resume.lo `test -f 'request_resume.c' || echo '$(srcdir)/'`request_resume.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-request_resume.Tpo $(DEPDIR)/libmicrohttpd2_la-request_resume.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='request_resume.c' object='libmicrohttpd2_la-request_resume.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-request_resume.lo `test -f 'request_resume.c' || echo '$(srcdir)/'`request_resume.c libmicrohttpd2_la-sysfdsetsize.lo: sysfdsetsize.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-sysfdsetsize.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-sysfdsetsize.Tpo -c -o libmicrohttpd2_la-sysfdsetsize.lo `test -f 'sysfdsetsize.c' || echo '$(srcdir)/'`sysfdsetsize.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-sysfdsetsize.Tpo $(DEPDIR)/libmicrohttpd2_la-sysfdsetsize.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sysfdsetsize.c' object='libmicrohttpd2_la-sysfdsetsize.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-sysfdsetsize.lo `test -f 'sysfdsetsize.c' || echo '$(srcdir)/'`sysfdsetsize.c libmicrohttpd2_la-upgrade_process.lo: upgrade_process.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-upgrade_process.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-upgrade_process.Tpo -c -o libmicrohttpd2_la-upgrade_process.lo `test -f 'upgrade_process.c' || echo '$(srcdir)/'`upgrade_process.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-upgrade_process.Tpo $(DEPDIR)/libmicrohttpd2_la-upgrade_process.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='upgrade_process.c' object='libmicrohttpd2_la-upgrade_process.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-upgrade_process.lo `test -f 'upgrade_process.c' || echo '$(srcdir)/'`upgrade_process.c libmicrohttpd2_la-panic.lo: panic.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-panic.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-panic.Tpo -c -o libmicrohttpd2_la-panic.lo `test -f 'panic.c' || echo '$(srcdir)/'`panic.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-panic.Tpo $(DEPDIR)/libmicrohttpd2_la-panic.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='panic.c' object='libmicrohttpd2_la-panic.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-panic.lo `test -f 'panic.c' || echo '$(srcdir)/'`panic.c libmicrohttpd2_la-version.lo: version.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-version.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-version.Tpo -c -o libmicrohttpd2_la-version.lo `test -f 'version.c' || echo '$(srcdir)/'`version.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-version.Tpo $(DEPDIR)/libmicrohttpd2_la-version.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='version.c' object='libmicrohttpd2_la-version.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-version.lo `test -f 'version.c' || echo '$(srcdir)/'`version.c libmicrohttpd2_la-tsearch.lo: tsearch.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd2_la-tsearch.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd2_la-tsearch.Tpo -c -o libmicrohttpd2_la-tsearch.lo `test -f 'tsearch.c' || echo '$(srcdir)/'`tsearch.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd2_la-tsearch.Tpo $(DEPDIR)/libmicrohttpd2_la-tsearch.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tsearch.c' object='libmicrohttpd2_la-tsearch.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd2_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd2_la-tsearch.lo `test -f 'tsearch.c' || echo '$(srcdir)/'`tsearch.c mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(DATA) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/libmicrohttpd2_la-action_continue.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-action_from_response.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-action_parse_post.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-action_process_upload.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-action_suspend.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_add.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_call_handlers.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_cleanup.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_close.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_finish_forward.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_info.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_options.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_update_last_activity.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_close_all_connections.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_create.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_destroy.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_epoll.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_get_timeout.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_info.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_ip_limit.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_options.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_poll.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_quiesce.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_run.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_select.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_start.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-init.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-internal.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-memorypool.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_compat.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_itc.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_mono_clock.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_sockets.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_str.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_threads.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-panic.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-reason_phrase.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-request.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-request_info.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-request_resume.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response_for_upgrade.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response_from_buffer.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response_from_callback.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response_from_fd.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response_options.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-sysfdsetsize.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-tsearch.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-upgrade_process.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-version.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/libmicrohttpd2_la-action_continue.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-action_from_response.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-action_parse_post.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-action_process_upload.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-action_suspend.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_add.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_call_handlers.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_cleanup.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_close.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_finish_forward.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_info.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_options.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-connection_update_last_activity.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_close_all_connections.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_create.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_destroy.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_epoll.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_get_timeout.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_info.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_ip_limit.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_options.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_poll.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_quiesce.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_run.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_select.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-daemon_start.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-init.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-internal.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-memorypool.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_compat.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_itc.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_mono_clock.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_sockets.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_str.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-mhd_threads.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-panic.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-reason_phrase.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-request.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-request_info.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-request_resume.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response_for_upgrade.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response_from_buffer.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response_from_callback.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response_from_fd.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-response_options.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-sysfdsetsize.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-tsearch.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-upgrade_process.Plo -rm -f ./$(DEPDIR)/libmicrohttpd2_la-version.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-noinstLTLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am .PRECIOUS: Makefile @W32_SHARED_LIB_EXP_TRUE@$(lt_cv_objdir)/libmicrohttpd2.def: libmicrohttpd2.la @W32_SHARED_LIB_EXP_TRUE@$(lt_cv_objdir)/libmicrohttpd2.exp: $(lt_cv_objdir)/libmicrohttpd2.lib @W32_SHARED_LIB_EXP_TRUE@$(lt_cv_objdir)/libmicrohttpd2.lib: $(lt_cv_objdir)/libmicrohttpd2.def libmicrohttpd2.la $(libmicrohttpd2_la_OBJECTS) @USE_MS_LIB_TOOL_TRUE@@W32_SHARED_LIB_EXP_TRUE@ @echo Creating $@ and libmicrohttpd2.exp by $(MS_LIB_TOOL)... && \ @USE_MS_LIB_TOOL_TRUE@@W32_SHARED_LIB_EXP_TRUE@ dll_name=`$(EGREP) -o dlname=\'.+\' libmicrohttpd2.la` && \ @USE_MS_LIB_TOOL_TRUE@@W32_SHARED_LIB_EXP_TRUE@ dll_name=$${dll_name#*\'} && dll_name=$${dll_name%\'} && test -n "$$dll_name" && \ @USE_MS_LIB_TOOL_TRUE@@W32_SHARED_LIB_EXP_TRUE@ echo Creating $$dll_name by $(MS_LIB_TOOL).. && cd "$(lt_cv_objdir)" && \ @USE_MS_LIB_TOOL_TRUE@@W32_SHARED_LIB_EXP_TRUE@ $(MS_LIB_TOOL) -def:libmicrohttpd2.def -name:$$dll_name -out:libmicrohttpd2.lib $(libmicrohttpd2_la_OBJECTS:.lo=.o) && cd .. @USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@ @echo Creating $@ and libmicrohttpd2.exp by $(DLLTOOL)... && \ @USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@ dll_name=`$(EGREP) -o dlname=\'.+\' libmicrohttpd2.la` && \ @USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@ dll_name=$${dll_name#*\'} && dll_name=$${dll_name%\'} && test -n "$$dll_name" && \ @USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@ echo Creating $$dll_name by $(DLLTOOL).. && cd "$(lt_cv_objdir)" && \ @USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@ $(DLLTOOL) -d ./libmicrohttpd2.def -D $$dll_name -l libmicrohttpd2.lib $(libmicrohttpd2_la_OBJECTS:.lo=.o) -e ./libmicrohttpd2.exp && cd .. &&\ @USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@ echo Created libmicrohttpd2.exp and libmicrohttpd2.lib. @W32_STATIC_LIB_TRUE@$(lt_cv_objdir)/libmicrohttpd2-static.lib: libmicrohttpd2.la $(libmicrohttpd2_la_OBJECTS) @USE_MS_LIB_TOOL_TRUE@@W32_STATIC_LIB_TRUE@ $(MS_LIB_TOOL) -out:$@ $(libmicrohttpd2_la_OBJECTS:.lo=.o) @USE_MS_LIB_TOOL_FALSE@@W32_STATIC_LIB_TRUE@ cp $(lt_cv_objdir)/libmicrohttpd2.a $@ # General rule is not required, but keep it just in case @HAVE_W32_TRUE@.rc.lo: @HAVE_W32_TRUE@ $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $< -o $@ # To add dll resource only to .dll file and exclude it form static # lib, a little trick was used. Allow libtool to create file.lo, # file.o and .libs/file.lo, .libs/file.o files, then overwrite file.o # by empty object generated from empty c-file. Later libtool will # use .libs/file.o for shared lib and empty file.o for static lib. # This implementation is based on trick found in liblzma. # Note: windres does not understand '-isystem' flag, so all # possible '-isystem' flags are replaced by simple '-I' flags. @HAVE_W32_TRUE@$(MHD_DLL_RES_LO): $(MHD_DLL_RES_SRC) @HAVE_W32_TRUE@ RC_CPP_FLAGS=" $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd2_la_CPPFLAGS) $(CPPFLAGS) " && \ @HAVE_W32_TRUE@ $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $${RC_CPP_FLAGS// -isystem / -I } $< -o $@ && \ @HAVE_W32_TRUE@ echo > $@-empty.c && $(CC) $(AM_CFLAGS) $(CFLAGS) -c $@-empty.c -o $(@:.lo=.o) && rm -f $@-empty.c # TBD! #libmicrohttpd2_la_SOURCES += \ # postprocessor.c # TBD! #libmicrohttpd2_la_SOURCES += \ # digestauth.c \ # md5.c md5.h # TBD! #libmicrohttpd2_la_SOURCES += \ # basicauth.c \ # base64.c base64.h # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/src/lib/memorypool.c0000644000175000017500000002015114417460232013743 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009, 2010, 2018 Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file memorypool.c * @brief memory pool * @author Christian Grothoff */ #include "memorypool.h" /* define MAP_ANONYMOUS for Mac OS X */ #if defined(MAP_ANON) && ! defined(MAP_ANONYMOUS) #define MAP_ANONYMOUS MAP_ANON #endif #ifndef MAP_FAILED #define MAP_FAILED ((void*) -1) #endif /** * Align to 2x word size (as GNU libc does). */ #define ALIGN_SIZE (2 * sizeof(void*)) /** * Round up 'n' to a multiple of ALIGN_SIZE. */ #define ROUND_TO_ALIGN(n) ((n + (ALIGN_SIZE - 1)) & (~(ALIGN_SIZE - 1))) /** * Handle for a memory pool. Pools are not reentrant and must not be * used by multiple threads. */ struct MemoryPool { /** * Pointer to the pool's memory */ char *memory; /** * Size of the pool. */ size_t size; /** * Offset of the first unallocated byte. */ size_t pos; /** * Offset of the last unallocated byte. */ size_t end; /** * false if pool was malloc'ed, true if mmapped (VirtualAlloc'ed for W32). */ bool is_mmap; }; /** * Free the memory given by @a ptr. Calls "free(ptr)". This function * should be used to free the username returned by * #MHD_digest_auth_get_username(). * @note Since v0.9.56 * * @param ptr pointer to free. */ _MHD_EXTERN void MHD_free (void *ptr) { free (ptr); } /** * Create a memory pool. * * @param max maximum size of the pool * @return NULL on error */ struct MemoryPool * MHD_pool_create (size_t max) { struct MemoryPool *pool; pool = malloc (sizeof (struct MemoryPool)); if (NULL == pool) return NULL; #if defined(MAP_ANONYMOUS) || defined(_WIN32) if (max <= 32 * 1024) pool->memory = MAP_FAILED; else #if defined(MAP_ANONYMOUS) && ! defined(_WIN32) pool->memory = mmap (NULL, max, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); #elif defined(_WIN32) pool->memory = VirtualAlloc (NULL, max, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #endif #else pool->memory = MAP_FAILED; #endif if ( (MAP_FAILED == pool->memory) || (NULL == pool->memory)) { pool->memory = malloc (max); if (NULL == pool->memory) { free (pool); return NULL; } pool->is_mmap = false; } else { pool->is_mmap = true; } pool->pos = 0; pool->end = max; pool->size = max; return pool; } /** * Destroy a memory pool. * * @param pool memory pool to destroy */ void MHD_pool_destroy (struct MemoryPool *pool) { if (NULL == pool) return; if (! pool->is_mmap) free (pool->memory); else #if defined(MAP_ANONYMOUS) && ! defined(_WIN32) munmap (pool->memory, pool->size); #elif defined(_WIN32) VirtualFree (pool->memory, 0, MEM_RELEASE); #else abort (); #endif free (pool); } /** * Check how much memory is left in the @a pool * * @param pool pool to check * @return number of bytes still available in @a pool */ size_t MHD_pool_get_free (struct MemoryPool *pool) { return (pool->end - pool->pos); } /** * Allocate size bytes from the pool. * * @param pool memory pool to use for the operation * @param size number of bytes to allocate * @param from_end allocate from end of pool (set to #MHD_YES); * use this for small, persistent allocations that * will never be reallocated * @return NULL if the pool cannot support size more * bytes */ void * MHD_pool_allocate (struct MemoryPool *pool, size_t size, int from_end) { void *ret; size_t asize; asize = ROUND_TO_ALIGN (size); if ( (0 == asize) && (0 != size) ) return NULL; /* size too close to SIZE_MAX */ if ( (pool->pos + asize > pool->end) || (pool->pos + asize < pool->pos)) return NULL; if (from_end == MHD_YES) { ret = &pool->memory[pool->end - asize]; pool->end -= asize; } else { ret = &pool->memory[pool->pos]; pool->pos += asize; } return ret; } /** * Reallocate a block of memory obtained from the pool. * This is particularly efficient when growing or * shrinking the block that was last (re)allocated. * If the given block is not the most recently * (re)allocated block, the memory of the previous * allocation may be leaked until the pool is * destroyed (and copying the data maybe required). * * @param pool memory pool to use for the operation * @param old the existing block * @param old_size the size of the existing block * @param new_size the new size of the block * @return new address of the block, or * NULL if the pool cannot support @a new_size * bytes (old continues to be valid for @a old_size) */ void * MHD_pool_reallocate (struct MemoryPool *pool, void *old, size_t old_size, size_t new_size) { void *ret; size_t asize; asize = ROUND_TO_ALIGN (new_size); if ( (0 == asize) && (0 != new_size) ) return NULL; /* new_size too close to SIZE_MAX */ if ( (pool->end < old_size) || (pool->end < asize) ) return NULL; /* unsatisfiable or bogus request */ if ( (pool->pos >= old_size) && (&pool->memory[pool->pos - old_size] == old) ) { /* was the previous allocation - optimize! */ if (pool->pos + asize - old_size <= pool->end) { /* fits */ pool->pos += asize - old_size; if (asize < old_size) /* shrinking - zero again! */ memset (&pool->memory[pool->pos], 0, old_size - asize); return old; } /* does not fit */ return NULL; } if (asize <= old_size) return old; /* cannot shrink, no need to move */ if ((pool->pos + asize >= pool->pos) && (pool->pos + asize <= pool->end)) { /* fits */ ret = &pool->memory[pool->pos]; if (0 != old_size) memmove (ret, old, old_size); pool->pos += asize; return ret; } /* does not fit */ return NULL; } /** * Clear all entries from the memory pool except * for @a keep of the given @a size. The pointer * returned should be a buffer of @a new_size where * the first @a copy_bytes are from @a keep. * * @param pool memory pool to use for the operation * @param keep pointer to the entry to keep (maybe NULL) * @param copy_bytes how many bytes need to be kept at this address * @param new_size how many bytes should the allocation we return have? * (should be larger or equal to @a copy_bytes) * @return addr new address of @a keep (if it had to change) */ void * MHD_pool_reset (struct MemoryPool *pool, void *keep, size_t copy_bytes, size_t new_size) { if ( (NULL != keep) && (keep != pool->memory) ) { if (0 != copy_bytes) memmove (pool->memory, keep, copy_bytes); keep = pool->memory; } pool->end = pool->size; /* technically not needed, but safer to zero out */ if (pool->size > copy_bytes) memset (&pool->memory[copy_bytes], 0, pool->size - copy_bytes); if (NULL != keep) pool->pos = ROUND_TO_ALIGN (new_size); return keep; } /* end of memorypool.c */ libmicrohttpd-1.0.1/src/lib/connection_update_last_activity.h0000644000175000017500000000264114417460232020212 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_update_last_activity.h * @brief function to update last activity of a connection * @author Christian Grothoff */ #ifndef CONNECTION_UPDATE_LAST_ACTIVITY_H #define CONNECTION_UPDATE_LAST_ACTIVITY_H /** * Update the 'last_activity' field of the connection to the current time * and move the connection to the head of the 'normal_timeout' list if * the timeout for the connection uses the default value. * * @param connection the connection that saw some activity */ void MHD_connection_update_last_activity_ (struct MHD_Connection *connection) MHD_NONNULL (1); #endif libmicrohttpd-1.0.1/src/lib/mhd_str.c0000644000175000017500000004766314417460232013222 /* This file is part of libmicrohttpd Copyright (C) 2015, 2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_str.c * @brief Functions implementations for string manipulating * @author Karlson2k (Evgeny Grin) */ #include "mhd_str.h" #ifdef HAVE_STDBOOL_H #include #endif #include "mhd_limits.h" #ifdef MHD_FAVOR_SMALL_CODE #ifdef _MHD_static_inline #undef _MHD_static_inline #endif /* _MHD_static_inline */ /* Do not force inlining and do not use macro functions, use normal static functions instead. This may give more flexibility for size optimizations. */ #define _MHD_static_inline static #ifndef INLINE_FUNC #define INLINE_FUNC 1 #endif /* !INLINE_FUNC */ #endif /* MHD_FAVOR_SMALL_CODE */ /* * Block of functions/macros that use US-ASCII charset as required by HTTP * standards. Not affected by current locale settings. */ #ifdef INLINE_FUNC #if 0 /* Disable unused functions. */ /** * Check whether character is lower case letter in US-ASCII * * @param c character to check * @return non-zero if character is lower case letter, zero otherwise */ _MHD_static_inline bool isasciilower (char c) { return (c >= 'a') && (c <= 'z'); } #endif /* Disable unused functions. */ /** * Check whether character is upper case letter in US-ASCII * * @param c character to check * @return non-zero if character is upper case letter, zero otherwise */ _MHD_static_inline bool isasciiupper (char c) { return (c >= 'A') && (c <= 'Z'); } #if 0 /* Disable unused functions. */ /** * Check whether character is letter in US-ASCII * * @param c character to check * @return non-zero if character is letter in US-ASCII, zero otherwise */ _MHD_static_inline bool isasciialpha (char c) { return isasciilower (c) || isasciiupper (c); } #endif /* Disable unused functions. */ /** * Check whether character is decimal digit in US-ASCII * * @param c character to check * @return non-zero if character is decimal digit, zero otherwise */ _MHD_static_inline bool isasciidigit (char c) { return (c >= '0') && (c <= '9'); } #if 0 /* Disable unused functions. */ /** * Check whether character is hexadecimal digit in US-ASCII * * @param c character to check * @return non-zero if character is decimal digit, zero otherwise */ _MHD_static_inline bool isasciixdigit (char c) { return isasciidigit (c) || ( (c >= 'A') && (c <= 'F') ) || ( (c >= 'a') && (c <= 'f') ); } /** * Check whether character is decimal digit or letter in US-ASCII * * @param c character to check * @return non-zero if character is decimal digit or letter, zero otherwise */ _MHD_static_inline bool isasciialnum (char c) { return isasciialpha (c) || isasciidigit (c); } #endif /* Disable unused functions. */ /** * Convert US-ASCII character to lower case. * If character is upper case letter in US-ASCII than it's converted to lower * case analog. If character is NOT upper case letter than it's returned * unmodified. * * @param c character to convert * @return converted to lower case character */ _MHD_static_inline char toasciilower (char c) { return isasciiupper (c) ? (c - 'A' + 'a') : c; } #if 0 /* Disable unused functions. */ /** * Convert US-ASCII character to upper case. * If character is lower case letter in US-ASCII than it's converted to upper * case analog. If character is NOT lower case letter than it's returned * unmodified. * * @param c character to convert * @return converted to upper case character */ _MHD_static_inline char toasciiupper (char c) { return isasciilower (c) ? (c - 'a' + 'A') : c; } #endif /* Disable unused functions. */ #if defined(MHD_FAVOR_SMALL_CODE) /* Used only in MHD_str_to_uvalue_n_() */ /** * Convert US-ASCII decimal digit to its value. * * @param c character to convert * @return value of decimal digit or -1 if @ c is not decimal digit */ _MHD_static_inline int todigitvalue (char c) { if (isasciidigit (c)) return (unsigned char) (c - '0'); return -1; } #endif /* MHD_FAVOR_SMALL_CODE */ /** * Convert US-ASCII hexadecimal digit to its value. * * @param c character to convert * @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit */ _MHD_static_inline int toxdigitvalue (char c) { if (isasciidigit (c)) return (unsigned char) (c - '0'); if ( (c >= 'A') && (c <= 'F') ) return (unsigned char) (c - 'A' + 10); if ( (c >= 'a') && (c <= 'f') ) return (unsigned char) (c - 'a' + 10); return -1; } #else /* !INLINE_FUNC */ /** * Checks whether character is lower case letter in US-ASCII * * @param c character to check * @return boolean true if character is lower case letter, * boolean false otherwise */ #define isasciilower(c) (((char) (c)) >= 'a' && ((char) (c)) <= 'z') /** * Checks whether character is upper case letter in US-ASCII * * @param c character to check * @return boolean true if character is upper case letter, * boolean false otherwise */ #define isasciiupper(c) (((char) (c)) >= 'A' && ((char) (c)) <= 'Z') /** * Checks whether character is letter in US-ASCII * * @param c character to check * @return boolean true if character is letter, boolean false * otherwise */ #define isasciialpha(c) (isasciilower (c) || isasciiupper (c)) /** * Check whether character is decimal digit in US-ASCII * * @param c character to check * @return boolean true if character is decimal digit, boolean false * otherwise */ #define isasciidigit(c) (((char) (c)) >= '0' && ((char) (c)) <= '9') /** * Check whether character is hexadecimal digit in US-ASCII * * @param c character to check * @return boolean true if character is hexadecimal digit, * boolean false otherwise */ #define isasciixdigit(c) (isasciidigit ((c)) || \ (((char) (c)) >= 'A' && ((char) (c)) <= 'F') || \ (((char) (c)) >= 'a' && ((char) (c)) <= 'f') ) /** * Check whether character is decimal digit or letter in US-ASCII * * @param c character to check * @return boolean true if character is decimal digit or letter, * boolean false otherwise */ #define isasciialnum(c) (isasciialpha (c) || isasciidigit (c)) /** * Convert US-ASCII character to lower case. * If character is upper case letter in US-ASCII than it's converted to lower * case analog. If character is NOT upper case letter than it's returned * unmodified. * * @param c character to convert * @return converted to lower case character */ #define toasciilower(c) ((isasciiupper (c)) ? (((char) (c)) - 'A' + 'a') : \ ((char) (c))) /** * Convert US-ASCII character to upper case. * If character is lower case letter in US-ASCII than it's converted to upper * case analog. If character is NOT lower case letter than it's returned * unmodified. * * @param c character to convert * @return converted to upper case character */ #define toasciiupper(c) ((isasciilower (c)) ? (((char) (c)) - 'a' + 'A') : \ ((char) (c))) /** * Convert US-ASCII decimal digit to its value. * * @param c character to convert * @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit */ #define todigitvalue(c) (isasciidigit (c) ? (int) (((char) (c)) - '0') : \ (int) (-1)) /** * Convert US-ASCII hexadecimal digit to its value. * @param c character to convert * @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit */ #define toxdigitvalue(c) (isasciidigit (c) ? (int) (((char) (c)) - '0') : \ ( (((char) (c)) >= 'A' && ((char) (c)) <= 'F') ? \ (int) (((unsigned char) (c)) - 'A' + 10) : \ ( (((char) (c)) >= 'a' && ((char) (c)) <= 'f') ? \ (int) (((unsigned char) (c)) - 'a' + 10) : \ (int) (-1) ))) #endif /* !INLINE_FUNC */ #ifndef MHD_FAVOR_SMALL_CODE /** * Check two string for equality, ignoring case of US-ASCII letters. * * @param str1 first string to compare * @param str2 second string to compare * @return non-zero if two strings are equal, zero otherwise. */ int MHD_str_equal_caseless_ (const char *str1, const char *str2) { while (0 != (*str1)) { const char c1 = *str1; const char c2 = *str2; if ( (c1 != c2) && (toasciilower (c1) != toasciilower (c2)) ) return 0; str1++; str2++; } return 0 == (*str2); } #endif /* ! MHD_FAVOR_SMALL_CODE */ /** * Check two string for equality, ignoring case of US-ASCII letters and * checking not more than @a maxlen characters. * Compares up to first terminating null character, but not more than * first @a maxlen characters. * * @param str1 first string to compare * @param str2 second string to compare * @param maxlen maximum number of characters to compare * @return non-zero if two strings are equal, zero otherwise. */ int MHD_str_equal_caseless_n_ (const char *const str1, const char *const str2, size_t maxlen) { size_t i; for (i = 0; i < maxlen; ++i) { const char c1 = str1[i]; const char c2 = str2[i]; if (0 == c2) return 0 == c1; if ( (c1 != c2) && (toasciilower (c1) != toasciilower (c2)) ) return 0; } return ! 0; } /** * Check whether @a str has case-insensitive @a token. * Token could be surrounded by spaces and tabs and delimited by comma. * Match succeed if substring between start, end (of string) or comma * contains only case-insensitive token and optional spaces and tabs. * @warning token must not contain null-charters except optional * terminating null-character. * @param str the string to check * @param token the token to find * @param token_len length of token, not including optional terminating * null-character. * @return non-zero if two strings are equal, zero otherwise. */ bool MHD_str_has_token_caseless_ (const char *str, const char *const token, size_t token_len) { if (0 == token_len) return false; while (0 != *str) { size_t i; /* Skip all whitespaces and empty tokens. */ while (' ' == *str || '\t' == *str || ',' == *str) str++; /* Check for token match. */ i = 0; while (1) { const char sc = *(str++); const char tc = token[i++]; if (0 == sc) return false; if ( (sc != tc) && (toasciilower (sc) != toasciilower (tc)) ) break; if (i >= token_len) { /* Check whether substring match token fully or * has additional unmatched chars at tail. */ while (' ' == *str || '\t' == *str) str++; /* End of (sub)string? */ if ((0 == *str) || (',' == *str) ) return true; /* Unmatched chars at end of substring. */ break; } } /* Find next substring. */ while (0 != *str && ',' != *str) str++; } return false; } #ifndef MHD_FAVOR_SMALL_CODE /* Use individual function for each case */ /** * Convert decimal US-ASCII digits in string to number in uint64_t. * Conversion stopped at first non-digit character. * * @param str string to convert * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_str_to_uint64_ (const char *str, uint64_t *out_val) { const char *const start = str; uint64_t res; if (! str || ! out_val || ! isasciidigit (str[0])) return 0; res = 0; do { const int digit = (unsigned char) (*str) - '0'; if ( (res > (UINT64_MAX / 10)) || ( (res == (UINT64_MAX / 10)) && ((uint64_t) digit > (UINT64_MAX % 10)) ) ) return 0; res *= 10; res += digit; str++; } while (isasciidigit (*str)); *out_val = res; return str - start; } /** * Convert not more then @a maxlen decimal US-ASCII digits in string to * number in uint64_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * * @param str string to convert * @param maxlen maximum number of characters to process * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_str_to_uint64_n_ (const char *str, size_t maxlen, uint64_t *out_val) { uint64_t res; size_t i; if (! str || ! maxlen || ! out_val || ! isasciidigit (str[0])) return 0; res = 0; i = 0; do { const int digit = (unsigned char) str[i] - '0'; if ( (res > (UINT64_MAX / 10)) || ( (res == (UINT64_MAX / 10)) && ((uint64_t) digit > (UINT64_MAX % 10)) ) ) return 0; res *= 10; res += digit; i++; } while ( (i < maxlen) && isasciidigit (str[i]) ); *out_val = res; return i; } /** * Convert hexadecimal US-ASCII digits in string to number in uint32_t. * Conversion stopped at first non-digit character. * * @param str string to convert * @param[out] out_val pointer to uint32_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint32_t or @a out_val is NULL */ size_t MHD_strx_to_uint32_ (const char *str, uint32_t *out_val) { const char *const start = str; uint32_t res; int digit; if (! str || ! out_val) return 0; res = 0; digit = toxdigitvalue (*str); while (digit >= 0) { if ( (res < (UINT32_MAX / 16)) || ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit <= (UINT32_MAX % 16)) ) ) { res *= 16; res += digit; } else return 0; str++; digit = toxdigitvalue (*str); } if (str - start > 0) *out_val = res; return str - start; } /** * Convert not more then @a maxlen hexadecimal US-ASCII digits in string * to number in uint32_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * * @param str string to convert * @param maxlen maximum number of characters to process * @param[out] out_val pointer to uint32_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint32_t or @a out_val is NULL */ size_t MHD_strx_to_uint32_n_ (const char *str, size_t maxlen, uint32_t *out_val) { size_t i; uint32_t res; int digit; if (! str || ! out_val) return 0; res = 0; i = 0; while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) { if ( (res > (UINT32_MAX / 16)) || ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit > (UINT32_MAX % 16)) ) ) return 0; res *= 16; res += digit; i++; } if (i) *out_val = res; return i; } /** * Convert hexadecimal US-ASCII digits in string to number in uint64_t. * Conversion stopped at first non-digit character. * * @param str string to convert * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_strx_to_uint64_ (const char *str, uint64_t *out_val) { const char *const start = str; uint64_t res; int digit; if (! str || ! out_val) return 0; res = 0; digit = toxdigitvalue (*str); while (digit >= 0) { if ( (res < (UINT64_MAX / 16)) || ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit <= (UINT64_MAX % 16)) ) ) { res *= 16; res += digit; } else return 0; str++; digit = toxdigitvalue (*str); } if (str - start > 0) *out_val = res; return str - start; } /** * Convert not more then @a maxlen hexadecimal US-ASCII digits in string * to number in uint64_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * * @param str string to convert * @param maxlen maximum number of characters to process * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_strx_to_uint64_n_ (const char *str, size_t maxlen, uint64_t *out_val) { size_t i; uint64_t res; int digit; if (! str || ! out_val) return 0; res = 0; i = 0; while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) { if ( (res > (UINT64_MAX / 16)) || ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit > (UINT64_MAX % 16)) ) ) return 0; res *= 16; res += digit; i++; } if (i) *out_val = res; return i; } #else /* MHD_FAVOR_SMALL_CODE */ /** * Generic function for converting not more then @a maxlen * hexadecimal or decimal US-ASCII digits in string to number. * Conversion stopped at first non-digit character or after @a maxlen * digits. * To be used only within macro. * * @param str the string to convert * @param maxlen the maximum number of characters to process * @param out_val the pointer to variable to store result of conversion * @param val_size the size of variable pointed by @a out_val, in bytes, 4 or 8 * @param max_val the maximum decoded number * @param base the numeric base, 10 or 16 * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then @max_val, @val_size is not 16/32 or @a out_val is NULL */ size_t MHD_str_to_uvalue_n_ (const char *str, size_t maxlen, void *out_val, size_t val_size, uint64_t max_val, int base) { size_t i; uint64_t res; int digit; const uint64_t max_v_div_b = max_val / base; const uint64_t max_v_mod_b = max_val % base; /* 'digit->value' must be function, not macro */ int (*const dfunc)(char) = (base == 16) ? toxdigitvalue : todigitvalue; if (! str || ! out_val || ((base != 16) && (base != 10)) ) return 0; res = 0; i = 0; while (maxlen > i && 0 <= (digit = dfunc (str[i]))) { if ( ((max_v_div_b) < res) || (( (max_v_div_b) == res) && ( (max_v_mod_b) < (uint64_t) digit) ) ) return 0; res *= base; res += digit; i++; } if (i) { if (8 == val_size) *(uint64_t *) out_val = res; else if (4 == val_size) *(uint32_t *) out_val = (uint32_t) res; else return 0; } return i; } #endif /* MHD_FAVOR_SMALL_CODE */ libmicrohttpd-1.0.1/src/lib/connection_finish_forward.h0000644000175000017500000000274614417460232017003 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_finish_forward.h * @brief complete upgrade socket forwarding operation in TLS mode * @author Christian Grothoff */ #ifndef CONNECTION_FINISH_FORWARD_H #define CONNECTION_FINISH_FORWARD_H /** * Stop TLS forwarding on upgraded connection and * reflect remote disconnect state to socketpair. * * @remark In thread-per-connection mode this function * can be called from any thread, in other modes this * function must be called only from thread that process * daemon's select()/poll()/etc. * * @param connection the upgraded connection */ void MHD_connection_finish_forward_ (struct MHD_Connection *connection) MHD_NONNULL (1); #endif libmicrohttpd-1.0.1/src/lib/mhd_sockets.c0000644000175000017500000003513514417460232014054 /* This file is part of libmicrohttpd Copyright (C) 2014-2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_sockets.c * @brief Implementation for sockets functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_sockets.h" #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #ifdef MHD_WINSOCK_SOCKETS /** * Return pointer to string description of specified WinSock error * @param err the WinSock error code. * @return pointer to string description of specified WinSock error. */ const char * MHD_W32_strerror_winsock_ (int err) { switch (err) { case 0: return "No error"; case WSA_INVALID_HANDLE: return "Specified event object handle is invalid"; case WSA_NOT_ENOUGH_MEMORY: return "Insufficient memory available"; case WSA_INVALID_PARAMETER: return "One or more parameters are invalid"; case WSA_OPERATION_ABORTED: return "Overlapped operation aborted"; case WSA_IO_INCOMPLETE: return "Overlapped I/O event object not in signaled state"; case WSA_IO_PENDING: return "Overlapped operations will complete later"; case WSAEINTR: return "Interrupted function call"; case WSAEBADF: return "File handle is not valid"; case WSAEACCES: return "Permission denied"; case WSAEFAULT: return "Bad address"; case WSAEINVAL: return "Invalid argument"; case WSAEMFILE: return "Too many open files"; case WSAEWOULDBLOCK: return "Resource temporarily unavailable"; case WSAEINPROGRESS: return "Operation now in progress"; case WSAEALREADY: return "Operation already in progress"; case WSAENOTSOCK: return "Socket operation on nonsocket"; case WSAEDESTADDRREQ: return "Destination address required"; case WSAEMSGSIZE: return "Message too long"; case WSAEPROTOTYPE: return "Protocol wrong type for socket"; case WSAENOPROTOOPT: return "Bad protocol option"; case WSAEPROTONOSUPPORT: return "Protocol not supported"; case WSAESOCKTNOSUPPORT: return "Socket type not supported"; case WSAEOPNOTSUPP: return "Operation not supported"; case WSAEPFNOSUPPORT: return "Protocol family not supported"; case WSAEAFNOSUPPORT: return "Address family not supported by protocol family"; case WSAEADDRINUSE: return "Address already in use"; case WSAEADDRNOTAVAIL: return "Cannot assign requested address"; case WSAENETDOWN: return "Network is down"; case WSAENETUNREACH: return "Network is unreachable"; case WSAENETRESET: return "Network dropped connection on reset"; case WSAECONNABORTED: return "Software caused connection abort"; case WSAECONNRESET: return "Connection reset by peer"; case WSAENOBUFS: return "No buffer space available"; case WSAEISCONN: return "Socket is already connected"; case WSAENOTCONN: return "Socket is not connected"; case WSAESHUTDOWN: return "Cannot send after socket shutdown"; case WSAETOOMANYREFS: return "Too many references"; case WSAETIMEDOUT: return "Connection timed out"; case WSAECONNREFUSED: return "Connection refused"; case WSAELOOP: return "Cannot translate name"; case WSAENAMETOOLONG: return "Name too long"; case WSAEHOSTDOWN: return "Host is down"; case WSAEHOSTUNREACH: return "No route to host"; case WSAENOTEMPTY: return "Directory not empty"; case WSAEPROCLIM: return "Too many processes"; case WSAEUSERS: return "User quota exceeded"; case WSAEDQUOT: return "Disk quota exceeded"; case WSAESTALE: return "Stale file handle reference"; case WSAEREMOTE: return "Item is remote"; case WSASYSNOTREADY: return "Network subsystem is unavailable"; case WSAVERNOTSUPPORTED: return "Winsock.dll version out of range"; case WSANOTINITIALISED: return "Successful WSAStartup not yet performed"; case WSAEDISCON: return "Graceful shutdown in progress"; case WSAENOMORE: return "No more results"; case WSAECANCELLED: return "Call has been canceled"; case WSAEINVALIDPROCTABLE: return "Procedure call table is invalid"; case WSAEINVALIDPROVIDER: return "Service provider is invalid"; case WSAEPROVIDERFAILEDINIT: return "Service provider failed to initialize"; case WSASYSCALLFAILURE: return "System call failure"; case WSASERVICE_NOT_FOUND: return "Service not found"; case WSATYPE_NOT_FOUND: return "Class type not found"; case WSA_E_NO_MORE: return "No more results"; case WSA_E_CANCELLED: return "Call was canceled"; case WSAEREFUSED: return "Database query was refused"; case WSAHOST_NOT_FOUND: return "Host not found"; case WSATRY_AGAIN: return "Nonauthoritative host not found"; case WSANO_RECOVERY: return "This is a nonrecoverable error"; case WSANO_DATA: return "Valid name, no data record of requested type"; case WSA_QOS_RECEIVERS: return "QoS receivers"; case WSA_QOS_SENDERS: return "QoS senders"; case WSA_QOS_NO_SENDERS: return "No QoS senders"; case WSA_QOS_NO_RECEIVERS: return "QoS no receivers"; case WSA_QOS_REQUEST_CONFIRMED: return "QoS request confirmed"; case WSA_QOS_ADMISSION_FAILURE: return "QoS admission error"; case WSA_QOS_POLICY_FAILURE: return "QoS policy failure"; case WSA_QOS_BAD_STYLE: return "QoS bad style"; case WSA_QOS_BAD_OBJECT: return "QoS bad object"; case WSA_QOS_TRAFFIC_CTRL_ERROR: return "QoS traffic control error"; case WSA_QOS_GENERIC_ERROR: return "QoS generic error"; case WSA_QOS_ESERVICETYPE: return "QoS service type error"; case WSA_QOS_EFLOWSPEC: return "QoS flowspec error"; case WSA_QOS_EPROVSPECBUF: return "Invalid QoS provider buffer"; case WSA_QOS_EFILTERSTYLE: return "Invalid QoS filter style"; case WSA_QOS_EFILTERTYPE: return "Invalid QoS filter type"; case WSA_QOS_EFILTERCOUNT: return "Incorrect QoS filter count"; case WSA_QOS_EOBJLENGTH: return "Invalid QoS object length"; case WSA_QOS_EFLOWCOUNT: return "Incorrect QoS flow count"; case WSA_QOS_EUNKOWNPSOBJ: return "Unrecognized QoS object"; case WSA_QOS_EPOLICYOBJ: return "Invalid QoS policy object"; case WSA_QOS_EFLOWDESC: return "Invalid QoS flow descriptor"; case WSA_QOS_EPSFLOWSPEC: return "Invalid QoS provider-specific flowspec"; case WSA_QOS_EPSFILTERSPEC: return "Invalid QoS provider-specific filterspec"; case WSA_QOS_ESDMODEOBJ: return "Invalid QoS shape discard mode object"; case WSA_QOS_ESHAPERATEOBJ: return "Invalid QoS shaping rate object"; case WSA_QOS_RESERVED_PETYPE: return "Reserved policy QoS element type"; } return "Unknown winsock error"; } /** * Create pair of mutually connected TCP/IP sockets on loopback address * @param sockets_pair array to receive resulted sockets * @param non_blk if set to non-zero value, sockets created in non-blocking mode * otherwise sockets will be in blocking mode * @return non-zero if succeeded, zero otherwise */ int MHD_W32_socket_pair_ (SOCKET sockets_pair[2], int non_blk) { int i; if (! sockets_pair) { WSASetLastError (WSAEFAULT); return 0; } #define PAIRMAXTRYIES 800 for (i = 0; i < PAIRMAXTRYIES; i++) { struct sockaddr_in listen_addr; SOCKET listen_s; static const int c_addinlen = sizeof(struct sockaddr_in); /* help compiler to optimize */ int addr_len = c_addinlen; unsigned long on_val = 1; unsigned long off_val = 0; listen_s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); if (INVALID_SOCKET == listen_s) break; /* can't create even single socket */ listen_addr.sin_family = AF_INET; listen_addr.sin_port = 0; /* same as htons(0) */ listen_addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); if ( ((0 == bind (listen_s, (struct sockaddr *) &listen_addr, c_addinlen)) && (0 == listen (listen_s, 1) ) && (0 == getsockname (listen_s, (struct sockaddr *) &listen_addr, &addr_len))) ) { SOCKET client_s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); struct sockaddr_in accepted_from_addr; struct sockaddr_in client_addr; SOCKET server_s; if (INVALID_SOCKET == client_s) { /* try again */ closesocket (listen_s); continue; } if ( (0 != ioctlsocket (client_s, FIONBIO, &on_val)) || ( (0 != connect (client_s, (struct sockaddr *) &listen_addr, c_addinlen)) && (WSAGetLastError () != WSAEWOULDBLOCK)) ) { /* try again */ closesocket (listen_s); closesocket (client_s); continue; } addr_len = c_addinlen; server_s = accept (listen_s, (struct sockaddr *) &accepted_from_addr, &addr_len); if (INVALID_SOCKET == server_s) { /* try again */ closesocket (listen_s); closesocket (client_s); continue; } addr_len = c_addinlen; if ( (0 == getsockname (client_s, (struct sockaddr *) &client_addr, &addr_len)) && (accepted_from_addr.sin_family == client_addr.sin_family) && (accepted_from_addr.sin_port == client_addr.sin_port) && (accepted_from_addr.sin_addr.s_addr == client_addr.sin_addr.s_addr) && ( (0 != non_blk) ? (0 == ioctlsocket (server_s, FIONBIO, &on_val)) : (0 == ioctlsocket (client_s, FIONBIO, &off_val)) ) ) { closesocket (listen_s); sockets_pair[0] = server_s; sockets_pair[1] = client_s; return ! 0; } closesocket (server_s); closesocket (client_s); } closesocket (listen_s); } sockets_pair[0] = INVALID_SOCKET; sockets_pair[1] = INVALID_SOCKET; WSASetLastError (WSAECONNREFUSED); return 0; } #endif /* MHD_WINSOCK_SOCKETS */ /** * Add @a fd to the @a set. If @a fd is * greater than @a max_fd, set @a max_fd to @a fd. * * @param fd file descriptor to add to the @a set * @param set set to modify * @param max_fd maximum value to potentially update * @param fd_setsize value of FD_SETSIZE * @return non-zero if succeeded, zero otherwise */ int MHD_add_to_fd_set_ (MHD_socket fd, fd_set *set, MHD_socket *max_fd, unsigned int fd_setsize) { if ( (NULL == set) || (MHD_INVALID_SOCKET == fd) ) return 0; if (! MHD_SCKT_FD_FITS_FDSET_SETSIZE_ (fd, set, fd_setsize)) return 0; MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_ (fd, set, fd_setsize); if ( (NULL != max_fd) && ( (fd > *max_fd) || (MHD_INVALID_SOCKET == *max_fd) ) ) *max_fd = fd; return ! 0; } /** * Change socket options to be non-blocking. * * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise */ int MHD_socket_nonblocking_ (MHD_socket sock) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (sock, F_GETFL); if (-1 == flags) return 0; if ( ((flags | O_NONBLOCK) != flags) && (0 != fcntl (sock, F_SETFL, flags | O_NONBLOCK)) ) return 0; #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 1; if (0 != ioctlsocket (sock, FIONBIO, &flags)) return 0; #endif /* MHD_WINSOCK_SOCKETS */ return ! 0; } /** * Change socket options to be non-inheritable. * * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise * @warning Does not set socket error on W32. */ int MHD_socket_noninheritable_ (MHD_socket sock) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (sock, F_GETFD); if (-1 == flags) return 0; if ( ((flags | FD_CLOEXEC) != flags) && (0 != fcntl (sock, F_SETFD, flags | FD_CLOEXEC)) ) return 0; #elif defined(MHD_WINSOCK_SOCKETS) if (! SetHandleInformation ((HANDLE) sock, HANDLE_FLAG_INHERIT, 0)) return 0; #endif /* MHD_WINSOCK_SOCKETS */ return ! 0; } /** * Create a listen socket, with noninheritable flag if possible. * * @param pf protocol family to use * @return created socket or MHD_INVALID_SOCKET in case of errors */ MHD_socket MHD_socket_create_listen_ (int pf) { MHD_socket fd; int cloexec_set; #if defined(MHD_POSIX_SOCKETS) && defined(SOCK_CLOEXEC) fd = socket (pf, SOCK_STREAM | SOCK_CLOEXEC, 0); cloexec_set = ! 0; #elif defined(MHD_WINSOCK_SOCKETS) && defined (WSA_FLAG_NO_HANDLE_INHERIT) fd = WSASocketW (pf, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_NO_HANDLE_INHERIT); cloexec_set = ! 0; #else /* !SOCK_CLOEXEC */ fd = MHD_INVALID_SOCKET; #endif /* !SOCK_CLOEXEC */ if (MHD_INVALID_SOCKET == fd) { fd = socket (pf, SOCK_STREAM, 0); cloexec_set = 0; } if (MHD_INVALID_SOCKET == fd) return MHD_INVALID_SOCKET; #ifdef MHD_socket_nosignal_ if (! MHD_socket_nosignal_ (fd)) { const int err = MHD_socket_get_error_ (); (void) MHD_socket_close_ (fd); MHD_socket_fset_error_ (err); return MHD_INVALID_SOCKET; } #endif /* MHD_socket_nosignal_ */ if (! cloexec_set) (void) MHD_socket_noninheritable_ (fd); return fd; } libmicrohttpd-1.0.1/src/lib/mhd_limits.h0000644000175000017500000001025414417460232013702 /* This file is part of libmicrohttpd Copyright (C) 2015 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_limits.h * @brief limits values definitions * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_LIMITS_H #define MHD_LIMITS_H #include "platform.h" #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ #define MHD_UNSIGNED_TYPE_MAX_(type) ((type) - 1) /* Assume 8 bits per byte, no padding bits. */ #define MHD_SIGNED_TYPE_MAX_(type) \ ( (type) ((( ((type) 1) << (sizeof(type) * 8 - 2)) - 1) * 2 + 1) ) #define MHD_TYPE_IS_SIGNED_(type) (((type) 0)>((type) - 1)) #ifndef UINT_MAX #ifdef __UINT_MAX__ #define UINT_MAX __UINT_MAX__ #else /* ! __UINT_MAX__ */ #define UINT_MAX MHD_UNSIGNED_TYPE_MAX_ (unsigned int) #endif /* ! __UINT_MAX__ */ #endif /* !UINT_MAX */ #ifndef LONG_MAX #ifdef __LONG_MAX__ #define LONG_MAX __LONG_MAX__ #else /* ! __LONG_MAX__ */ #define LONG_MAX MHD_SIGNED_TYPE_MAX (long) #endif /* ! __LONG_MAX__ */ #endif /* !OFF_T_MAX */ #ifndef ULLONG_MAX #define ULLONG_MAX MHD_UNSIGNED_TYPE_MAX_ (MHD_UNSIGNED_LONG_LONG) #endif /* !ULLONG_MAX */ #ifndef INT32_MAX #ifdef __INT32_MAX__ #define INT32_MAX __INT32_MAX__ #else /* ! __INT32_MAX__ */ #define INT32_MAX ((int32_t) 0x7FFFFFFF) #endif /* ! __INT32_MAX__ */ #endif /* !INT32_MAX */ #ifndef UINT32_MAX #ifdef __UINT32_MAX__ #define UINT32_MAX __UINT32_MAX__ #else /* ! __UINT32_MAX__ */ #define UINT32_MAX ((int32_t) 0xFFFFFFFF) #endif /* ! __UINT32_MAX__ */ #endif /* !UINT32_MAX */ #ifndef UINT64_MAX #ifdef __UINT64_MAX__ #define UINT64_MAX __UINT64_MAX__ #else /* ! __UINT64_MAX__ */ #define UINT64_MAX ((uint64_t) 0xFFFFFFFFFFFFFFFF) #endif /* ! __UINT64_MAX__ */ #endif /* !UINT64_MAX */ #ifndef INT64_MAX #ifdef __INT64_MAX__ #define INT64_MAX __INT64_MAX__ #else /* ! __INT64_MAX__ */ #define INT64_MAX ((int64_t) 0x7FFFFFFFFFFFFFFF) #endif /* ! __UINT64_MAX__ */ #endif /* !INT64_MAX */ #ifndef SIZE_MAX #ifdef __SIZE_MAX__ #define SIZE_MAX __SIZE_MAX__ #elif defined(UINTPTR_MAX) #define SIZE_MAX UINTPTR_MAX #else /* ! __SIZE_MAX__ */ #define SIZE_MAX MHD_UNSIGNED_TYPE_MAX_ (size_t) #endif /* ! __SIZE_MAX__ */ #endif /* !SIZE_MAX */ #ifndef SSIZE_MAX #ifdef __SSIZE_MAX__ #define SSIZE_MAX __SSIZE_MAX__ #elif defined(PTRDIFF_MAX) #define SSIZE_MAX PTRDIFF_MAX #elif defined(INTPTR_MAX) #define SSIZE_MAX INTPTR_MAX #else #define SSIZE_MAN MHD_SIGNED_TYPE_MAX_ (ssize_t) #endif #endif /* ! SSIZE_MAX */ #ifndef OFF_T_MAX #ifdef OFF_MAX #define OFF_T_MAX OFF_MAX #elif defined(OFFT_MAX) #define OFF_T_MAX OFFT_MAX #elif defined(__APPLE__) && defined(__MACH__) #define OFF_T_MAX INT64_MAX #else #define OFF_T_MAX MHD_SIGNED_TYPE_MAX_ (off_t) #endif #endif /* !OFF_T_MAX */ #if defined(_LARGEFILE64_SOURCE) && ! defined(OFF64_T_MAX) #define OFF64_T_MAX MHD_SIGNED_TYPE_MAX_ (uint64_t) #endif /* _LARGEFILE64_SOURCE && !OFF64_T_MAX */ #ifndef TIME_T_MAX #define TIME_T_MAX ((time_t) \ (MHD_TYPE_IS_SIGNED_ (time_t) ? \ MHD_SIGNED_TYPE_MAX_ (time_t) : \ MHD_UNSIGNED_TYPE_MAX_ (time_t))) #endif /* !TIME_T_MAX */ #ifndef TIMEVAL_TV_SEC_MAX #ifndef _WIN32 #define TIMEVAL_TV_SEC_MAX TIME_T_MAX #else /* _WIN32 */ #define TIMEVAL_TV_SEC_MAX LONG_MAX #endif /* _WIN32 */ #endif /* !TIMEVAL_TV_SEC_MAX */ #ifndef MHD_FD_BLOCK_SIZE #ifdef _WIN32 #define MHD_FD_BLOCK_SIZE 16384 /* 16k */ #else /* _WIN32 */ #define MHD_FD_BLOCK_SIZE 4096 /* 4k */ #endif /* _WIN32 */ #endif /* !MHD_FD_BLOCK_SIZE */ #endif /* MHD_LIMITS_H */ libmicrohttpd-1.0.1/src/lib/request_resume.h0000644000175000017500000000256014417460232014622 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/request_resume.h * @brief implementation of MHD_request_resume() * @author Christian Grothoff */ #ifndef REQUEST_RESUME_H #define REQUEST_RESUME_H /** * Run through the suspended connections and move any that are no * longer suspended back to the active state. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon daemon context * @return true if a connection was actually resumed */ bool MHD_resume_suspended_connections_ (struct MHD_Daemon *daemon) MHD_NONNULL (1); #endif libmicrohttpd-1.0.1/src/lib/mhd_assert.h0000644000175000017500000000271314417460232013703 /* This file is part of libmicrohttpd Copyright (C) 2017 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/mhd_assert.h * @brief macros for mhd_assert() * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_ASSERT_H #define MHD_ASSERT_H 1 #include "mhd_options.h" #ifdef NDEBUG # define mhd_assert(ignore) ((void) 0) #else /* _DEBUG */ # ifdef HAVE_ASSERT # include # define mhd_assert(CHK) assert (CHK) # else /* ! HAVE_ASSERT */ # include # include # define mhd_assert(CHK) \ do { \ if (! (CHK)) { \ fprintf (stderr, "%s:%u Assertion failed: %s\nProgram aborted.\n", \ __FILE__, (unsigned) __LINE__, #CHK); \ fflush (stderr); abort (); } \ } while (0) # endif /* ! HAVE_ASSERT */ #endif /* _DEBUG */ #endif /* ! MHD_ASSERT_H */ libmicrohttpd-1.0.1/src/lib/init.c0000644000175000017500000000703614417460232012513 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/init.c * @brief initialization routines * @author Christian Grothoff */ #include "internal.h" #include "init.h" #ifndef _AUTOINIT_FUNCS_ARE_SUPPORTED /** * Track global initialisation */ volatile unsigned int global_init_count = 0; #ifdef MHD_MUTEX_STATIC_DEFN_INIT_ /** * Global initialisation mutex */ MHD_MUTEX_STATIC_DEFN_INIT_ (global_init_mutex_); #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ #endif #if defined(_WIN32) && ! defined(__CYGWIN__) /** * Track initialization of winsock */ static int mhd_winsock_inited_ = 0; #endif /** * Default implementation of the panic function, * prints an error message and aborts. * * @param cls unused * @param file name of the file with the problem * @param line line number with the problem * @param reason error message with details */ static void mhd_panic_std (void *cls, const char *file, unsigned int line, const char *reason) { (void) cls; /* Mute compiler warning. */ #ifdef HAVE_MESSAGES fprintf (stderr, _ ("Fatal error in GNU libmicrohttpd %s:%u: %s\n"), file, line, reason); #else /* ! HAVE_MESSAGES */ (void) file; /* Mute compiler warning. */ (void) line; /* Mute compiler warning. */ (void) reason; /* Mute compiler warning. */ #endif abort (); } /** * Globally initialize library. */ void MHD_init (void) { #if defined(_WIN32) && ! defined(__CYGWIN__) WSADATA wsd; #endif /* _WIN32 && ! __CYGWIN__ */ if (NULL == mhd_panic) mhd_panic = &mhd_panic_std; #if defined(_WIN32) && ! defined(__CYGWIN__) if (0 != WSAStartup (MAKEWORD (2, 2), &wsd)) MHD_PANIC (_ ("Failed to initialize winsock.\n")); mhd_winsock_inited_ = 1; if ( (2 != LOBYTE (wsd.wVersion)) && (2 != HIBYTE (wsd.wVersion)) ) MHD_PANIC (_ ("Winsock version 2.2 is not available.\n")); #endif MHD_monotonic_sec_counter_init (); #ifdef HAVE_FREEBSD_SENDFILE MHD_conn_init_static_ (); #endif /* HAVE_FREEBSD_SENDFILE */ } /** * Global teardown work. */ void MHD_fini (void) { #if defined(_WIN32) && ! defined(__CYGWIN__) if (mhd_winsock_inited_) WSACleanup (); #endif MHD_monotonic_sec_counter_finish (); } #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED _SET_INIT_AND_DEINIT_FUNCS (MHD_init, MHD_fini); #else /** * Check whether global initialisation was performed * and call initialiser if necessary. */ void MHD_check_global_init_ (void) { #ifdef MHD_MUTEX_STATIC_DEFN_INIT_ MHD_mutex_lock_chk_ (&global_init_mutex_); #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ if (0 == global_init_count++) MHD_init (); #ifdef MHD_MUTEX_STATIC_DEFN_INIT_ MHD_mutex_unlock_chk_ (&global_init_mutex_); #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ } #endif libmicrohttpd-1.0.1/src/lib/daemon_select.c0000644000175000017500000006307014417460232014352 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_select.c * @brief function to run select()-based event loop of a daemon * @author Christian Grothoff */ #include "internal.h" #include "connection_add.h" #include "connection_call_handlers.h" #include "connection_cleanup.h" #include "connection_finish_forward.h" #include "daemon_select.h" #include "daemon_epoll.h" #include "request_resume.h" #include "upgrade_process.h" /** * We defined a macro with the same name as a function we * are implementing here. Need to undef the macro to avoid * causing a conflict. */ #undef MHD_daemon_get_fdset /** * Obtain the `select()` sets for this daemon. Daemon's FDs will be * added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO * for each fd_set before calling this function. FD_SETSIZE is assumed * to be platform's default. * * This function should only be called in when MHD is configured to * use external select with 'select()' or with 'epoll'. In the latter * case, it will only add the single 'epoll()' file descriptor used by * MHD to the sets. It's necessary to use #MHD_daemon_get_timeout() in * combination with this function. * * This function must be called only for daemon started without * #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @return #MHD_SC_OK on success, otherwise error code * @ingroup event */ enum MHD_StatusCode MHD_daemon_get_fdset (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd) { return MHD_daemon_get_fdset2 (daemon, read_fd_set, write_fd_set, except_fd_set, max_fd, _MHD_SYS_DEFAULT_FD_SETSIZE); } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Obtain the select() file descriptor sets for the * given @a urh. * * @param urh upgrade handle to wait for * @param[out] rs read set to initialize * @param[out] ws write set to initialize * @param[out] es except set to initialize * @param[out] max_fd maximum FD to update * @param fd_setsize value of FD_SETSIZE * @return true on success, false on error */ static bool urh_to_fdset (struct MHD_UpgradeResponseHandle *urh, fd_set *rs, fd_set *ws, fd_set *es, MHD_socket *max_fd, unsigned int fd_setsize) { const MHD_socket conn_sckt = urh->connection->socket_fd; const MHD_socket mhd_sckt = urh->mhd.socket; bool res = true; /* Do not add to 'es' only if socket is closed * or not used anymore. */ if (MHD_INVALID_SOCKET != conn_sckt) { if ( (urh->in_buffer_used < urh->in_buffer_size) && (! MHD_add_to_fd_set_ (conn_sckt, rs, max_fd, fd_setsize)) ) res = false; if ( (0 != urh->out_buffer_used) && (! MHD_add_to_fd_set_ (conn_sckt, ws, max_fd, fd_setsize)) ) res = false; /* Do not monitor again for errors if error was detected before as * error state is remembered. */ if ((0 == (urh->app.celi & MHD_EPOLL_STATE_ERROR)) && ((0 != urh->in_buffer_size) || (0 != urh->out_buffer_size) || (0 != urh->out_buffer_used))) MHD_add_to_fd_set_ (conn_sckt, es, max_fd, fd_setsize); } if (MHD_INVALID_SOCKET != mhd_sckt) { if ( (urh->out_buffer_used < urh->out_buffer_size) && (! MHD_add_to_fd_set_ (mhd_sckt, rs, max_fd, fd_setsize)) ) res = false; if ( (0 != urh->in_buffer_used) && (! MHD_add_to_fd_set_ (mhd_sckt, ws, max_fd, fd_setsize)) ) res = false; /* Do not monitor again for errors if error was detected before as * error state is remembered. */ if ((0 == (urh->mhd.celi & MHD_EPOLL_STATE_ERROR)) && ((0 != urh->out_buffer_size) || (0 != urh->in_buffer_size) || (0 != urh->in_buffer_used))) MHD_add_to_fd_set_ (mhd_sckt, es, max_fd, fd_setsize); } return res; } #endif /** * Internal version of #MHD_daemon_get_fdset2(). * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @param fd_setsize value of FD_SETSIZE * @return #MHD_SC_OK on success * @ingroup event */ static enum MHD_StatusCode internal_get_fdset2 (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize) { struct MHD_Connection *pos; struct MHD_Connection *posn; enum MHD_StatusCode result = MHD_SC_OK; MHD_socket ls; if (daemon->shutdown) return MHD_SC_DAEMON_ALREADY_SHUTDOWN; ls = daemon->listen_socket; if ( (MHD_INVALID_SOCKET != ls) && (! daemon->was_quiesced) && (! MHD_add_to_fd_set_ (ls, read_fd_set, max_fd, fd_setsize)) ) result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE; /* Add all sockets to 'except_fd_set' as well to watch for * out-of-band data. However, ignore errors if INFO_READ * or INFO_WRITE sockets will not fit 'except_fd_set'. */ /* Start from oldest connections. Make sense for W32 FDSETs. */ for (pos = daemon->connections_tail; NULL != pos; pos = posn) { posn = pos->prev; switch (pos->request.event_loop_info) { case MHD_EVENT_LOOP_INFO_READ: if (! MHD_add_to_fd_set_ (pos->socket_fd, read_fd_set, max_fd, fd_setsize)) result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE; #ifdef MHD_POSIX_SOCKETS MHD_add_to_fd_set_ (pos->socket_fd, except_fd_set, max_fd, fd_setsize); #endif /* MHD_POSIX_SOCKETS */ break; case MHD_EVENT_LOOP_INFO_WRITE: if (! MHD_add_to_fd_set_ (pos->socket_fd, write_fd_set, max_fd, fd_setsize)) result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE; #ifdef MHD_POSIX_SOCKETS MHD_add_to_fd_set_ (pos->socket_fd, except_fd_set, max_fd, fd_setsize); #endif /* MHD_POSIX_SOCKETS */ break; case MHD_EVENT_LOOP_INFO_BLOCK: if ( (NULL == except_fd_set) || ! MHD_add_to_fd_set_ (pos->socket_fd, except_fd_set, max_fd, fd_setsize)) result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE; break; case MHD_EVENT_LOOP_INFO_CLEANUP: /* this should never happen */ break; } } #ifdef MHD_WINSOCK_SOCKETS /* W32 use limited array for fd_set so add INFO_READ/INFO_WRITE sockets * only after INFO_BLOCK sockets to ensure that INFO_BLOCK sockets will * not be pushed out. */ for (pos = daemon->connections_tail; NULL != pos; pos = posn) { posn = pos->prev; MHD_add_to_fd_set_ (pos->socket_fd, except_fd_set, max_fd, fd_setsize); } #endif /* MHD_WINSOCK_SOCKETS */ #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) { struct MHD_UpgradeResponseHandle *urh; for (urh = daemon->urh_tail; NULL != urh; urh = urh->prev) { if (! urh_to_fdset (urh, read_fd_set, write_fd_set, except_fd_set, max_fd, fd_setsize)) result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE; } } #endif return result; } /** * Obtain the `select()` sets for this daemon. Daemon's FDs will be * added to fd_sets. To get only daemon FDs in fd_sets, call FD_ZERO * for each fd_set before calling this function. * * Passing custom FD_SETSIZE as @a fd_setsize allow usage of * larger/smaller than platform's default fd_sets. * * This function should only be called in when MHD is configured to * use external select with 'select()' or with 'epoll'. In the latter * case, it will only add the single 'epoll' file descriptor used by * MHD to the sets. It's necessary to use #MHD_get_timeout() in * combination with this function. * * This function must be called only for daemon started * without #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @param fd_setsize value of FD_SETSIZE * @return #MHD_SC_OK on success, otherwise error code * @ingroup event */ enum MHD_StatusCode MHD_daemon_get_fdset2 (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize) { if ( (MHD_TM_EXTERNAL_EVENT_LOOP != daemon->threading_mode) || (MHD_ELS_POLL == daemon->event_loop_syscall) ) return MHD_SC_CONFIGURATION_MISMATCH_FOR_GET_FDSET; #ifdef EPOLL_SUPPORT if (MHD_ELS_EPOLL == daemon->event_loop_syscall) { if (daemon->shutdown) return MHD_SC_DAEMON_ALREADY_SHUTDOWN; /* we're in epoll mode, use the epoll FD as a stand-in for the entire event set */ return MHD_add_to_fd_set_ (daemon->epoll_fd, read_fd_set, max_fd, fd_setsize) ? MHD_SC_OK : MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE; } #endif return internal_get_fdset2 (daemon, read_fd_set, write_fd_set, except_fd_set, max_fd, fd_setsize); } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Update the @a urh based on the ready FDs in * the @a rs, @a ws, and @a es. * * @param urh upgrade handle to update * @param rs read result from select() * @param ws write result from select() * @param es except result from select() */ static void urh_from_fdset (struct MHD_UpgradeResponseHandle *urh, const fd_set *rs, const fd_set *ws, const fd_set *es) { const MHD_socket conn_sckt = urh->connection->socket_fd; const MHD_socket mhd_sckt = urh->mhd.socket; /* Reset read/write ready, preserve error state. */ urh->app.celi &= (~MHD_EPOLL_STATE_READ_READY & ~MHD_EPOLL_STATE_WRITE_READY); urh->mhd.celi &= (~MHD_EPOLL_STATE_READ_READY & ~MHD_EPOLL_STATE_WRITE_READY); if (MHD_INVALID_SOCKET != conn_sckt) { if (FD_ISSET (conn_sckt, rs)) urh->app.celi |= MHD_EPOLL_STATE_READ_READY; if (FD_ISSET (conn_sckt, ws)) urh->app.celi |= MHD_EPOLL_STATE_WRITE_READY; if (FD_ISSET (conn_sckt, es)) urh->app.celi |= MHD_EPOLL_STATE_ERROR; } if ((MHD_INVALID_SOCKET != mhd_sckt)) { if (FD_ISSET (mhd_sckt, rs)) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; if (FD_ISSET (mhd_sckt, ws)) urh->mhd.celi |= MHD_EPOLL_STATE_WRITE_READY; if (FD_ISSET (mhd_sckt, es)) urh->mhd.celi |= MHD_EPOLL_STATE_ERROR; } } #endif /** * Internal version of #MHD_run_from_select(). * * @param daemon daemon to run select loop for * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @return #MHD_SC_OK on success * @ingroup event */ static enum MHD_StatusCode internal_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set) { MHD_socket ds; struct MHD_Connection *pos; struct MHD_Connection *prev; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) struct MHD_UpgradeResponseHandle *urh; struct MHD_UpgradeResponseHandle *urhn; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /* Reset. New value will be set when connections are processed. */ /* Note: no-op for thread-per-connection as it is always false in that mode. */ daemon->data_already_pending = false; /* Clear ITC to avoid spinning select */ /* Do it before any other processing so new signals will trigger select again and will be processed */ if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (FD_ISSET (MHD_itc_r_fd_ (daemon->itc), read_fd_set)) ) MHD_itc_clear_ (daemon->itc); /* select connection thread handling type */ if ( (MHD_INVALID_SOCKET != (ds = daemon->listen_socket)) && (! daemon->was_quiesced) && (FD_ISSET (ds, read_fd_set)) ) (void) MHD_accept_connection_ (daemon); if (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) { /* do not have a thread per connection, process all connections now */ prev = daemon->connections_tail; while (NULL != (pos = prev)) { prev = pos->prev; ds = pos->socket_fd; if (MHD_INVALID_SOCKET == ds) continue; MHD_connection_call_handlers_ (pos, FD_ISSET (ds, read_fd_set), FD_ISSET (ds, write_fd_set), FD_ISSET (ds, except_fd_set)); } } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /* handle upgraded HTTPS connections */ for (urh = daemon->urh_tail; NULL != urh; urh = urhn) { urhn = urh->prev; /* update urh state based on select() output */ urh_from_fdset (urh, read_fd_set, write_fd_set, except_fd_set); /* call generic forwarding function for passing data */ MHD_upgrade_response_handle_process_ (urh); /* Finished forwarding? */ if ( (0 == urh->in_buffer_size) && (0 == urh->out_buffer_size) && (0 == urh->in_buffer_used) && (0 == urh->out_buffer_used) ) { MHD_connection_finish_forward_ (urh->connection); urh->clean_ready = true; /* Resuming will move connection to cleanup list. */ MHD_request_resume (&urh->connection->request); } } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ MHD_connection_cleanup_ (daemon); return MHD_SC_OK; } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Process upgraded connection with a select loop. * We are in our own thread, only processing @a con * * @param con connection to process */ void MHD_daemon_upgrade_connection_with_select_ (struct MHD_Connection *con) { struct MHD_UpgradeResponseHandle *urh = con->request.urh; while ( (0 != urh->in_buffer_size) || (0 != urh->out_buffer_size) || (0 != urh->in_buffer_used) || (0 != urh->out_buffer_used) ) { /* use select */ fd_set rs; fd_set ws; fd_set es; MHD_socket max_fd; int num_ready; bool result; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); max_fd = MHD_INVALID_SOCKET; result = urh_to_fdset (urh, &rs, &ws, &es, &max_fd, FD_SETSIZE); if (! result) { #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE, _ ("Error preparing select.\n")); #endif break; } /* FIXME: does this check really needed? */ if (MHD_INVALID_SOCKET != max_fd) { struct timeval *tvp; struct timeval tv; if ( (con->tls_read_ready) && (urh->in_buffer_used < urh->in_buffer_size)) { /* No need to wait if incoming data is already pending in TLS buffers. */ tv.tv_sec = 0; tv.tv_usec = 0; tvp = &tv; } else tvp = NULL; num_ready = MHD_SYS_select_ (max_fd + 1, &rs, &ws, &es, tvp); } else num_ready = 0; if (num_ready < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, MHD_SC_UNEXPECTED_SELECT_ERROR, _ ("Error during select (%d): `%s'\n"), err, MHD_socket_strerr_ (err)); #endif break; } urh_from_fdset (urh, &rs, &ws, &es); MHD_upgrade_response_handle_process_ (urh); } } #endif /** * Run webserver operations. This method should be called by clients * in combination with #MHD_get_fdset and #MHD_get_timeout() if the * client-controlled select method is used. * * You can use this function instead of #MHD_run if you called * `select()` on the result from #MHD_get_fdset. File descriptors in * the sets that are not controlled by MHD will be ignored. Calling * this function instead of #MHD_run is more efficient as MHD will not * have to call `select()` again to determine which operations are * ready. * * This function cannot be used with daemon started with * #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to run select loop for * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @return #MHD_SC_OK on success * @ingroup event */ enum MHD_StatusCode MHD_daemon_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set) { if ( (MHD_TM_EXTERNAL_EVENT_LOOP != daemon->threading_mode) || (MHD_ELS_POLL == daemon->event_loop_syscall) ) return MHD_SC_CONFIGURATION_MISMATCH_FOR_RUN_SELECT; if (MHD_ELS_EPOLL == daemon->event_loop_syscall) { #ifdef EPOLL_SUPPORT enum MHD_StatusCode sc; sc = MHD_daemon_epoll_ (daemon, MHD_NO); MHD_connection_cleanup_ (daemon); return sc; #else /* ! EPOLL_SUPPORT */ return MHD_NO; #endif /* ! EPOLL_SUPPORT */ } /* Resuming external connections when using an extern mainloop */ if (! daemon->disallow_suspend_resume) (void) MHD_resume_suspended_connections_ (daemon); return internal_run_from_select (daemon, read_fd_set, write_fd_set, except_fd_set); } /** * Main internal select() call. Will compute select sets, call * select() and then #internal_run_from_select() with the result. * * @param daemon daemon to run select() loop for * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_select_ (struct MHD_Daemon *daemon, int may_block) { int num_ready; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; struct timeval timeout; struct timeval *tv; MHD_UNSIGNED_LONG_LONG ltimeout; MHD_socket ls; enum MHD_StatusCode sc; enum MHD_StatusCode sc2; timeout.tv_sec = 0; timeout.tv_usec = 0; if (daemon->shutdown) return MHD_SC_DAEMON_ALREADY_SHUTDOWN; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); maxsock = MHD_INVALID_SOCKET; sc = MHD_SC_OK; if ( (! daemon->disallow_suspend_resume) && (MHD_resume_suspended_connections_ (daemon)) && (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) ) may_block = MHD_NO; if (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) { /* single-threaded, go over everything */ if (MHD_SC_OK != (sc = internal_get_fdset2 (daemon, &rs, &ws, &es, &maxsock, FD_SETSIZE))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, sc, _ ("Could not obtain daemon fdsets.\n")); #endif } } else { /* accept only, have one thread per connection */ if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_socket)) && (! daemon->was_quiesced) && (! MHD_add_to_fd_set_ (ls, &rs, &maxsock, FD_SETSIZE)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE, _ ("Could not add listen socket to fdset.\n")); #endif return MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE; } } if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), &rs, &maxsock, FD_SETSIZE)) ) { #if defined(MHD_WINSOCK_SOCKETS) /* fdset limit reached, new connections cannot be handled. Remove listen socket FD from fdset and retry to add ITC FD. */ if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_socket)) && (! daemon->was_quiesced) ) { FD_CLR (ls, &rs); if (! MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), &rs, &maxsock, FD_SETSIZE)) { #endif /* MHD_WINSOCK_SOCKETS */ sc = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, sc, _ ( "Could not add control inter-thread communication channel FD to fdset.\n")); #endif #if defined(MHD_WINSOCK_SOCKETS) } } #endif /* MHD_WINSOCK_SOCKETS */ } /* Stop listening if we are at the configured connection limit */ /* If we're at the connection limit, no point in really accepting new connections; however, make sure we do not miss the shutdown OR the termination of an existing connection; so only do this optimization if we have a signaling ITC in place. */ if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_socket)) && (MHD_ITC_IS_VALID_ (daemon->itc)) && ( (daemon->connections == daemon->global_connection_limit) || (daemon->at_limit) ) ) { FD_CLR (ls, &rs); } tv = NULL; if (MHD_SC_OK != sc) may_block = MHD_NO; if (MHD_NO == may_block) { timeout.tv_usec = 0; timeout.tv_sec = 0; tv = &timeout; } else if ( (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) && (MHD_SC_OK == MHD_daemon_get_timeout (daemon, <imeout)) ) { /* ltimeout is in ms */ timeout.tv_usec = (ltimeout % 1000) * 1000; if (ltimeout / 1000 > TIMEVAL_TV_SEC_MAX) timeout.tv_sec = TIMEVAL_TV_SEC_MAX; else timeout.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) (ltimeout / 1000); tv = &timeout; } num_ready = MHD_SYS_select_ (maxsock + 1, &rs, &ws, &es, tv); if (daemon->shutdown) return MHD_SC_DAEMON_ALREADY_SHUTDOWN; if (num_ready < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) return sc; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_UNEXPECTED_SELECT_ERROR, _ ("select failed: %s\n"), MHD_socket_strerr_ (err)); #endif return MHD_SC_UNEXPECTED_SELECT_ERROR; } if (MHD_SC_OK != (sc2 = internal_run_from_select (daemon, &rs, &ws, &es))) return sc2; return sc; } /* end of daemon_select.c */ libmicrohttpd-1.0.1/src/lib/version.c0000644000175000017500000001221614417460232013231 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/version.c * @brief versioning and optional feature tests * @author Christian Grothoff */ #include "internal.h" /** * Obtain the version of this library * * @return static version string, e.g. "0.9.9" * @ingroup specialized */ const char * MHD_get_version (void) { #ifdef PACKAGE_VERSION return PACKAGE_VERSION; #else /* !PACKAGE_VERSION */ static char ver[12] = "\0\0\0\0\0\0\0\0\0\0\0"; if (0 == ver[0]) { int res = MHD_snprintf_ (ver, sizeof(ver), "%x.%x.%x", (((int) MHD_VERSION >> 24) & 0xFF), (((int) MHD_VERSION >> 16) & 0xFF), (((int) MHD_VERSION >> 8) & 0xFF)); if ((0 >= res) || (sizeof(ver) <= res)) return "0.0.0"; /* Can't return real version*/ } return ver; #endif /* !PACKAGE_VERSION */ } /** * Get information about supported MHD features. * Indicate that MHD was compiled with or without support for * particular feature. Some features require additional support * by kernel. Kernel support is not checked by this function. * * @param feature type of requested information * @return #MHD_YES if feature is supported by MHD, #MHD_NO if * feature is not supported or feature is unknown. * @ingroup specialized */ _MHD_EXTERN enum MHD_Bool MHD_is_feature_supported (enum MHD_Feature feature) { switch (feature) { case MHD_FEATURE_MESSAGES: #ifdef HAVE_MESSAGES return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_TLS: #ifdef HTTPS_SUPPORT return MHD_YES; #else /* ! HTTPS_SUPPORT */ return MHD_NO; #endif /* ! HTTPS_SUPPORT */ case MHD_FEATURE_HTTPS_CERT_CALLBACK: #if defined(HTTPS_SUPPORT) && GNUTLS_VERSION_MAJOR >= 3 return MHD_YES; #else /* !HTTPS_SUPPORT || GNUTLS_VERSION_MAJOR < 3 */ return MHD_NO; #endif /* !HTTPS_SUPPORT || GNUTLS_VERSION_MAJOR < 3 */ case MHD_FEATURE_IPv6: #ifdef HAVE_INET6 return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_IPv6_ONLY: #if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_POLL: #ifdef HAVE_POLL return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_EPOLL: #ifdef EPOLL_SUPPORT return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET: #ifdef HAVE_LISTEN_SHUTDOWN return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_SOCKETPAIR: #ifdef _MHD_ITC_SOCKETPAIR return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_TCP_FASTOPEN: #ifdef TCP_FASTOPEN return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_BASIC_AUTH: #ifdef BAUTH_SUPPORT return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_DIGEST_AUTH: #ifdef DAUTH_SUPPORT return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_POSTPROCESSOR: #ifdef HAVE_POSTPROCESSOR return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_HTTPS_KEY_PASSWORD: #if defined(HTTPS_SUPPORT) && GNUTLS_VERSION_NUMBER >= 0x030111 return MHD_YES; #else /* !HTTPS_SUPPORT || GNUTLS_VERSION_NUMBER < 0x030111 */ return MHD_NO; #endif /* !HTTPS_SUPPORT || GNUTLS_VERSION_NUMBER < 0x030111 */ case MHD_FEATURE_LARGE_FILE: #if defined(HAVE_PREAD64) || defined(_WIN32) return MHD_YES; #elif defined(HAVE_PREAD) return (sizeof(uint64_t) > sizeof(off_t)) ? MHD_NO : MHD_YES; #elif defined(HAVE_LSEEK64) return MHD_YES; #else return (sizeof(uint64_t) > sizeof(off_t)) ? MHD_NO : MHD_YES; #endif case MHD_FEATURE_THREAD_NAMES: #if defined(MHD_USE_THREAD_NAME_) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_UPGRADE: #if defined(UPGRADE_SUPPORT) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_RESPONSES_SHARED_FD: #if defined(HAVE_PREAD64) || defined(HAVE_PREAD) || defined(_WIN32) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_AUTODETECT_BIND_PORT: #ifdef MHD_USE_GETSOCKNAME return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_AUTOSUPPRESS_SIGPIPE: #if defined(MHD_WINSOCK_SOCKETS) || defined(MHD_socket_nosignal_) || \ defined (MSG_NOSIGNAL) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_SENDFILE: #ifdef _MHD_HAVE_SENDFILE return MHD_YES; #else return MHD_NO; #endif } return MHD_NO; } libmicrohttpd-1.0.1/src/lib/daemon_epoll.c0000644000175000017500000004213314417460232014203 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_epoll.c * @brief functions to run epoll()-based event loop * @author Christian Grothoff */ #include "internal.h" #include "connection_add.h" #include "connection_call_handlers.h" #include "connection_finish_forward.h" #include "daemon_epoll.h" #include "upgrade_process.h" #include "request_resume.h" #ifdef EPOLL_SUPPORT /** * How many events to we process at most per epoll() call? Trade-off * between required stack-size and number of system calls we have to * make; 128 should be way enough to avoid more than one system call * for most scenarios, and still be moderate in stack size * consumption. Embedded systems might want to choose a smaller value * --- but why use epoll() on such a system in the first place? */ #define MAX_EVENTS 128 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Checks whether @a urh has some data to process. * * @param urh upgrade handler to analyse * @return 'true' if @a urh has some data to process, * 'false' otherwise */ static bool is_urh_ready (struct MHD_UpgradeResponseHandle *const urh) { const struct MHD_Connection *const connection = urh->connection; if ( (0 == urh->in_buffer_size) && (0 == urh->out_buffer_size) && (0 == urh->in_buffer_used) && (0 == urh->out_buffer_used) ) return false; if (connection->daemon->shutdown) return true; if ( ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->app.celi)) || (connection->tls_read_ready) ) && (urh->in_buffer_used < urh->in_buffer_size) ) return true; if ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->mhd.celi)) && (urh->out_buffer_used < urh->out_buffer_size) ) return true; if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->app.celi)) && (urh->out_buffer_used > 0) ) return true; if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->mhd.celi)) && (urh->in_buffer_used > 0) ) return true; return false; } /** * Do epoll()-based processing for TLS connections that have been * upgraded. This requires a separate epoll() invocation as we * cannot use the `struct MHD_Connection` data structures for * the `union epoll_data` in this case. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon the daemmon for which we process connections * @return #MHD_SC_OK on success */ static enum MHD_StatusCode run_epoll_for_upgrade (struct MHD_Daemon *daemon) { struct epoll_event events[MAX_EVENTS]; int num_events; struct MHD_UpgradeResponseHandle *pos; struct MHD_UpgradeResponseHandle *prev; num_events = MAX_EVENTS; while (MAX_EVENTS == num_events) { unsigned int i; /* update event masks */ num_events = epoll_wait (daemon->epoll_upgrade_fd, events, MAX_EVENTS, 0); if (-1 == num_events) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_SC_OK; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_UNEXPECTED_EPOLL_WAIT_ERROR, _ ("Call to epoll_wait failed: %s\n"), MHD_socket_strerr_ (err)); #endif return MHD_SC_UNEXPECTED_EPOLL_WAIT_ERROR; } for (i = 0; i < (unsigned int) num_events; i++) { struct UpgradeEpollHandle *const ueh = events[i].data.ptr; struct MHD_UpgradeResponseHandle *const urh = ueh->urh; bool new_err_state = false; if (urh->clean_ready) continue; /* Update ueh state based on what is ready according to epoll() */ if (0 != (events[i].events & EPOLLIN)) ueh->celi |= MHD_EPOLL_STATE_READ_READY; if (0 != (events[i].events & EPOLLOUT)) ueh->celi |= MHD_EPOLL_STATE_WRITE_READY; if (0 != (events[i].events & EPOLLHUP)) ueh->celi |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY; if ( (0 == (ueh->celi & MHD_EPOLL_STATE_ERROR)) && (0 != (events[i].events & (EPOLLERR | EPOLLPRI))) ) { /* Process new error state only one time * and avoid continuously marking this connection * as 'ready'. */ ueh->celi |= MHD_EPOLL_STATE_ERROR; new_err_state = true; } if (! urh->in_eready_list) { if (new_err_state || is_urh_ready (urh)) { EDLL_insert (daemon->eready_urh_head, daemon->eready_urh_tail, urh); urh->in_eready_list = true; } } } } prev = daemon->eready_urh_tail; while (NULL != (pos = prev)) { prev = pos->prevE; MHD_upgrade_response_handle_process_ (pos); if (! is_urh_ready (pos)) { EDLL_remove (daemon->eready_urh_head, daemon->eready_urh_tail, pos); pos->in_eready_list = false; } /* Finished forwarding? */ if ( (0 == pos->in_buffer_size) && (0 == pos->out_buffer_size) && (0 == pos->in_buffer_used) && (0 == pos->out_buffer_used) ) { MHD_connection_finish_forward_ (pos->connection); pos->clean_ready = true; /* If 'pos->was_closed' already was set to true, connection * will be moved immediately to cleanup list. Otherwise * connection will stay in suspended list until 'pos' will * be marked with 'was_closed' by application. */ MHD_request_resume (&pos->connection->request); } } return MHD_SC_OK; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /** * Do epoll()-based processing (this function is allowed to * block if @a may_block is set to #MHD_YES). * * @param daemon daemon to run poll loop for * @param may_block true if blocking, false if non-blocking * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_epoll_ (struct MHD_Daemon *daemon, bool may_block) { #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) static const char *const upgrade_marker = "upgrade_ptr"; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ struct MHD_Connection *pos; struct MHD_Connection *prev; struct epoll_event events[MAX_EVENTS]; struct epoll_event event; int timeout_ms; MHD_UNSIGNED_LONG_LONG timeout_ll; int num_events; unsigned int i; MHD_socket ls; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) bool run_upgraded = false; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if (-1 == daemon->epoll_fd) return MHD_SC_EPOLL_FD_INVALID; /* we're down! */ if (daemon->shutdown) return MHD_SC_DAEMON_ALREADY_SHUTDOWN; if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_socket)) && (! daemon->was_quiesced) && (daemon->connections < daemon->global_connection_limit) && (! daemon->listen_socket_in_epoll) && (! daemon->at_limit) ) { event.events = EPOLLIN; event.data.ptr = daemon; if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, ls, &event)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_EPOLL_CTL_ADD_FAILED, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_SC_EPOLL_CTL_ADD_FAILED; } daemon->listen_socket_in_epoll = true; } if ( (daemon->was_quiesced) && (daemon->listen_socket_in_epoll) ) { if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, ls, NULL)) MHD_PANIC ("Failed to remove listen FD from epoll set.\n"); daemon->listen_socket_in_epoll = false; } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if ( (! daemon->upgrade_fd_in_epoll) && (-1 != daemon->epoll_upgrade_fd) ) { event.events = EPOLLIN | EPOLLOUT; event.data.ptr = (void *) upgrade_marker; if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, daemon->epoll_upgrade_fd, &event)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_EPOLL_CTL_ADD_FAILED, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_SC_EPOLL_CTL_ADD_FAILED; } daemon->upgrade_fd_in_epoll = true; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if ( (daemon->listen_socket_in_epoll) && ( (daemon->connections == daemon->global_connection_limit) || (daemon->at_limit) || (daemon->was_quiesced) ) ) { /* we're at the connection limit, disable listen socket for event loop for now */ if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, ls, NULL)) MHD_PANIC (_ ("Failed to remove listen FD from epoll set.\n")); daemon->listen_socket_in_epoll = false; } if ( (! daemon->disallow_suspend_resume) && (MHD_resume_suspended_connections_ (daemon)) ) may_block = false; if (may_block) { if (MHD_SC_OK == /* FIXME: distinguish between NO_TIMEOUT and errors */ MHD_daemon_get_timeout (daemon, &timeout_ll)) { if (timeout_ll >= (MHD_UNSIGNED_LONG_LONG) INT_MAX) timeout_ms = INT_MAX; else timeout_ms = (int) timeout_ll; } else timeout_ms = -1; } else timeout_ms = 0; /* Reset. New value will be set when connections are processed. */ /* Note: Used mostly for uniformity here as same situation is * signaled in epoll mode by non-empty eready DLL. */ daemon->data_already_pending = false; /* drain 'epoll' event queue; need to iterate as we get at most MAX_EVENTS in one system call here; in practice this should pretty much mean only one round, but better an extra loop here than unfair behavior... */ num_events = MAX_EVENTS; while (MAX_EVENTS == num_events) { /* update event masks */ num_events = epoll_wait (daemon->epoll_fd, events, MAX_EVENTS, timeout_ms); if (-1 == num_events) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_SC_OK; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_UNEXPECTED_EPOLL_WAIT_ERROR, _ ("Call to epoll_wait failed: %s\n"), MHD_socket_strerr_ (err)); #endif return MHD_SC_UNEXPECTED_EPOLL_WAIT_ERROR; } for (i = 0; i < (unsigned int) num_events; i++) { /* First, check for the values of `ptr` that would indicate that this event is not about a normal connection. */ if (NULL == events[i].data.ptr) continue; /* shutdown signal! */ #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if (upgrade_marker == events[i].data.ptr) { /* activity on an upgraded connection, we process those in a separate epoll() */ run_upgraded = true; continue; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if (daemon->epoll_itc_marker == events[i].data.ptr) { /* It's OK to clear ITC here as all external conditions will be processed later. */ MHD_itc_clear_ (daemon->itc); continue; } if (daemon == events[i].data.ptr) { /* Check for error conditions on listen socket. */ /* FIXME: Initiate MHD_quiesce_daemon() to prevent busy waiting? */ if (0 == (events[i].events & (EPOLLERR | EPOLLHUP))) { unsigned int series_length = 0; /* Run 'accept' until it fails or daemon at limit of connections. * Do not accept more then 10 connections at once. The rest will * be accepted on next turn (level trigger is used for listen * socket). */ while ( (MHD_SC_OK == MHD_accept_connection_ (daemon)) && (series_length < 10) && (daemon->connections < daemon->global_connection_limit) && (! daemon->at_limit) ) series_length++; } continue; } /* this is an event relating to a 'normal' connection, remember the event and if appropriate mark the connection as 'eready'. */ pos = events[i].data.ptr; /* normal processing: update read/write data */ if (0 != (events[i].events & (EPOLLPRI | EPOLLERR | EPOLLHUP))) { pos->epoll_state |= MHD_EPOLL_STATE_ERROR; if (0 == (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) { EDLL_insert (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL; } } else { if (0 != (events[i].events & EPOLLIN)) { pos->epoll_state |= MHD_EPOLL_STATE_READ_READY; if ( ( (MHD_EVENT_LOOP_INFO_READ == pos->request.event_loop_info) || (pos->request.read_buffer_size > pos->request.read_buffer_offset) ) && (0 == (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL) ) ) { EDLL_insert (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL; } } if (0 != (events[i].events & EPOLLOUT)) { pos->epoll_state |= MHD_EPOLL_STATE_WRITE_READY; if ( (MHD_EVENT_LOOP_INFO_WRITE == pos->request.event_loop_info) && (0 == (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL) ) ) { EDLL_insert (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL; } } } } } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if (run_upgraded) run_epoll_for_upgrade (daemon); /* FIXME: return value? */ #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /* process events for connections */ prev = daemon->eready_tail; while (NULL != (pos = prev)) { prev = pos->prevE; MHD_connection_call_handlers_ (pos, 0 != (pos->epoll_state & MHD_EPOLL_STATE_READ_READY), 0 != (pos->epoll_state & MHD_EPOLL_STATE_WRITE_READY), 0 != (pos->epoll_state & MHD_EPOLL_STATE_ERROR)); if (MHD_EPOLL_STATE_IN_EREADY_EDLL == (pos->epoll_state & (MHD_EPOLL_STATE_SUSPENDED | MHD_EPOLL_STATE_IN_EREADY_EDLL))) { if ( ((MHD_EVENT_LOOP_INFO_READ == pos->request.event_loop_info) && (0 == (pos->epoll_state & MHD_EPOLL_STATE_READ_READY)) ) || ((MHD_EVENT_LOOP_INFO_WRITE == pos->request.event_loop_info) && (0 == (pos->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) ) || (MHD_EVENT_LOOP_INFO_CLEANUP == pos->request.event_loop_info) ) { EDLL_remove (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EREADY_EDLL; } } } /* Finally, handle timed-out connections; we need to do this here as the epoll mechanism won't call the 'MHD_request_handle_idle_()' on everything, as the other event loops do. As timeouts do not get an explicit event, we need to find those connections that might have timed out here. Connections with custom timeouts must all be looked at, as we do not bother to sort that (presumably very short) list. */prev = daemon->manual_timeout_tail; while (NULL != (pos = prev)) { prev = pos->prevX; MHD_request_handle_idle_ (&pos->request); } /* Connections with the default timeout are sorted by prepending them to the head of the list whenever we touch the connection; thus it suffices to iterate from the tail until the first connection is NOT timed out */ prev = daemon->normal_timeout_tail; while (NULL != (pos = prev)) { prev = pos->prevX; MHD_request_handle_idle_ (&pos->request); if (MHD_REQUEST_CLOSED != pos->request.state) break; /* sorted by timeout, no need to visit the rest! */ } return MHD_SC_OK; } #endif /* end of daemon_epoll.c */ libmicrohttpd-1.0.1/src/lib/mhd_itc.h0000644000175000017500000002465414417460232013171 /* This file is part of libmicrohttpd Copyright (C) 2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_itc.h * @brief Header for platform-independent inter-thread communication * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff * * Provides basic abstraction for inter-thread communication. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid * variable modification in function parameters. */ #ifndef MHD_ITC_H #define MHD_ITC_H 1 #include "mhd_itc_types.h" #include #ifndef MHD_PANIC # include # include /* Simple implementation of MHD_PANIC, to be used outside lib */ # define MHD_PANIC(msg) do { fprintf (stderr, \ "Abnormal termination at %d line in file %s: %s\n", \ (int) __LINE__, __FILE__, msg); abort (); \ } while (0) #endif /* ! MHD_PANIC */ #if defined(_MHD_ITC_EVENTFD) /* **************** Optimized GNU/Linux ITC implementation by eventfd ********** */ #include #include /* for uint64_t */ #ifdef HAVE_UNISTD_H #include /* for read(), write(), errno */ #endif /* HAVE_UNISTD_H */ #ifdef HAVE_STRING_H #include /* for strerror() */ #endif /** * Initialise ITC by generating eventFD * @param itc the itc to initialise * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_init_(itc) (-1 != ((itc).fd = eventfd (0, EFD_CLOEXEC \ | EFD_NONBLOCK))) /** * Get description string of last errno for itc operations. */ #define MHD_itc_last_strerror_() strerror (errno) /** * Internal static const helper for MHD_itc_activate_() */ static const uint64_t _MHD_itc_wr_data = 1; /** * Activate signal on @a itc * @param itc the itc to use * @param str ignored * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_activate_(itc, str) \ ((write ((itc).fd, (const void*) &_MHD_itc_wr_data, 8) > 0) || (EAGAIN == \ errno)) /** * Return read FD of @a itc which can be used for poll(), select() etc. * @param itc the itc to get FD * @return FD of read side */ #define MHD_itc_r_fd_(itc) ((itc).fd) /** * Return write FD of @a itc * @param itc the itc to get FD * @return FD of write side */ #define MHD_itc_w_fd_(itc) ((itc).fd) /** * Clear signaled state on @a itc * @param itc the itc to clear */ #define MHD_itc_clear_(itc) \ do { uint64_t __b; int __r; \ __r = read ((itc).fd, &__b, sizeof(__b)); \ (void) __r; } while (0) /** * Destroy previously initialised ITC. Note that close() * on some platforms returns odd errors, so we ONLY fail * if the errno is EBADF. * @param itc the itc to destroy * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_destroy_(itc) ((0 == close ((itc).fd)) || (EBADF != errno)) /** * Check whether ITC has valid value. * * Macro check whether @a itc value is valid (allowed), * macro does not check whether @a itc was really initialised. * @param itc the itc to check * @return boolean true if @a itc has valid value, * boolean false otherwise. */ #define MHD_ITC_IS_VALID_(itc) (-1 != ((itc).fd)) /** * Set @a itc to invalid value. * @param itc the itc to set */ #define MHD_itc_set_invalid_(itc) ((itc).fd = -1) #elif defined(_MHD_ITC_PIPE) /* **************** Standard UNIX ITC implementation by pipe ********** */ #if defined(HAVE_PIPE2_FUNC) && defined(HAVE_FCNTL_H) # include /* for O_CLOEXEC, O_NONBLOCK */ #endif /* HAVE_PIPE2_FUNC && HAVE_FCNTL_H */ #ifdef HAVE_UNISTD_H #include /* for read(), write(), errno */ #endif /* HAVE_UNISTD_H */ #ifdef HAVE_STRING_H #include /* for strerror() */ #endif /** * Initialise ITC by generating pipe * @param itc the itc to initialise * @return non-zero if succeeded, zero otherwise */ #ifdef HAVE_PIPE2_FUNC # define MHD_itc_init_(itc) (! pipe2 ((itc).fd, O_CLOEXEC | O_NONBLOCK)) #else /* ! HAVE_PIPE2_FUNC */ # define MHD_itc_init_(itc) \ ( (! pipe ((itc).fd)) ? \ (MHD_itc_nonblocking_ ((itc)) ? \ (! 0) : \ (MHD_itc_destroy_ ((itc)), 0) ) \ : (0) ) #endif /* ! HAVE_PIPE2_FUNC */ /** * Get description string of last errno for itc operations. */ #define MHD_itc_last_strerror_() strerror (errno) /** * Activate signal on @a itc * @param itc the itc to use * @param str one-symbol string, useful only for strace debug * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_activate_(itc, str) \ ((write ((itc).fd[1], (const void*) (str), 1) > 0) || (EAGAIN == errno)) /** * Return read FD of @a itc which can be used for poll(), select() etc. * @param itc the itc to get FD * @return FD of read side */ #define MHD_itc_r_fd_(itc) ((itc).fd[0]) /** * Return write FD of @a itc * @param itc the itc to get FD * @return FD of write side */ #define MHD_itc_w_fd_(itc) ((itc).fd[1]) /** * Clear signaled state on @a itc * @param itc the itc to clear */ #define MHD_itc_clear_(itc) do \ { long __b; \ while (0 < read ((itc).fd[0], &__b, sizeof(__b))) \ {} } while (0) /** * Destroy previously initialised ITC * @param itc the itc to destroy * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_destroy_(itc) \ ( (0 == close ((itc).fd[0])) ? \ (0 == close ((itc).fd[1])) : \ ((close ((itc).fd[1])), 0) ) /** * Check whether ITC has valid value. * * Macro check whether @a itc value is valid (allowed), * macro does not check whether @a itc was really initialised. * @param itc the itc to check * @return boolean true if @a itc has valid value, * boolean false otherwise. */ #define MHD_ITC_IS_VALID_(itc) (-1 != (itc).fd[0]) /** * Set @a itc to invalid value. * @param itc the itc to set */ #define MHD_itc_set_invalid_(itc) ((itc).fd[0] = (itc).fd[1] = -1) #ifndef HAVE_PIPE2_FUNC /** * Change itc FD options to be non-blocking. * * @param fd the FD to manipulate * @return non-zero if succeeded, zero otherwise */ int MHD_itc_nonblocking_ (struct MHD_itc_ itc); #endif /* ! HAVE_PIPE2_FUNC */ #elif defined(_MHD_ITC_SOCKETPAIR) /* **************** ITC implementation by socket pair ********** */ #include "mhd_sockets.h" /** * Initialise ITC by generating socketpair * @param itc the itc to initialise * @return non-zero if succeeded, zero otherwise */ #ifdef MHD_socket_pair_nblk_ # define MHD_itc_init_(itc) MHD_socket_pair_nblk_ ((itc).sk) #else /* ! MHD_socket_pair_nblk_ */ # define MHD_itc_init_(itc) \ (MHD_socket_pair_ ((itc).sk) ? \ (MHD_itc_nonblocking_ ((itc)) ? \ (! 0) : \ (MHD_itc_destroy_ ((itc)), 0) ) \ : (0)) #endif /* ! MHD_socket_pair_nblk_ */ /** * Get description string of last error for itc operations. */ #define MHD_itc_last_strerror_() MHD_socket_last_strerr_ () /** * Activate signal on @a itc * @param itc the itc to use * @param str one-symbol string, useful only for strace debug * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_activate_(itc, str) \ ((MHD_send_ ((itc).sk[1], (str), 1) > 0) || \ (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))) /** * Return read FD of @a itc which can be used for poll(), select() etc. * @param itc the itc to get FD * @return FD of read side */ #define MHD_itc_r_fd_(itc) ((itc).sk[0]) /** * Return write FD of @a itc * @param itc the itc to get FD * @return FD of write side */ #define MHD_itc_w_fd_(itc) ((itc).sk[1]) /** * Clear signaled state on @a itc * @param itc the itc to clear */ #define MHD_itc_clear_(itc) do \ { long __b; \ while (0 < recv ((itc).sk[0], \ (char*) &__b, \ sizeof(__b), 0)) \ {} } while (0) /** * Destroy previously initialised ITC * @param itc the itc to destroy * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_destroy_(itc) \ (MHD_socket_close_ ((itc).sk[0]) ? \ MHD_socket_close_ ((itc).sk[1]) : \ ((void) MHD_socket_close_ ((itc).sk[1]), 0) ) /** * Check whether ITC has valid value. * * Macro check whether @a itc value is valid (allowed), * macro does not check whether @a itc was really initialised. * @param itc the itc to check * @return boolean true if @a itc has valid value, * boolean false otherwise. */ #define MHD_ITC_IS_VALID_(itc) (MHD_INVALID_SOCKET != (itc).sk[0]) /** * Set @a itc to invalid value. * @param itc the itc to set */ #define MHD_itc_set_invalid_(itc) ((itc).sk[0] = (itc).sk[1] = \ MHD_INVALID_SOCKET) #ifndef MHD_socket_pair_nblk_ # define MHD_itc_nonblocking_(pip) (MHD_socket_nonblocking_ ((pip).sk[0]) && \ MHD_socket_nonblocking_ ((pip).sk[1])) #endif /* ! MHD_socket_pair_nblk_ */ #endif /* _MHD_ITC_SOCKETPAIR */ /** * Destroy previously initialised ITC and abort execution * if error is detected. * @param itc the itc to destroy */ #define MHD_itc_destroy_chk_(itc) do { \ if (! MHD_itc_destroy_ (itc)) \ MHD_PANIC (_ ("Failed to destroy ITC.\n")); \ } while (0) /** * Check whether ITC has invalid value. * * Macro check whether @a itc value is invalid, * macro does not check whether @a itc was destroyed. * @param itc the itc to check * @return boolean true if @a itc has invalid value, * boolean false otherwise. */ #define MHD_ITC_IS_INVALID_(itc) (! MHD_ITC_IS_VALID_ (itc)) #endif /* MHD_ITC_H */ libmicrohttpd-1.0.1/src/lib/mhd_itc.c0000644000175000017500000000356214417460232013157 /* This file is part of libmicrohttpd Copyright (C) 2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_itc.c * @brief Implementation of inter-thread communication functions * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff */ #include "mhd_itc.h" #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include "internal.h" #if defined(_MHD_ITC_PIPE) #if ! defined(_WIN32) || defined(__CYGWIN__) #ifndef HAVE_PIPE2_FUNC /** * Change itc FD options to be non-blocking. * * @param itc the inter-thread communication primitive to manipulate * @return non-zero if succeeded, zero otherwise */ int MHD_itc_nonblocking_ (struct MHD_itc_ itc) { unsigned int i; for (i = 0; i < 2; i++) { int flags; flags = fcntl (itc.fd[i], F_GETFL); if (-1 == flags) return 0; if ( ((flags | O_NONBLOCK) != flags) && (0 != fcntl (itc.fd[i], F_SETFL, flags | O_NONBLOCK)) ) return 0; } return ! 0; } #endif /* ! HAVE_PIPE2_FUNC */ #endif /* !_WIN32 || __CYGWIN__ */ #endif /* _MHD_ITC_EVENTFD || _MHD_ITC_PIPE */ libmicrohttpd-1.0.1/src/lib/internal.c0000644000175000017500000001675014445225054013371 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/internal.c * @brief internal shared structures * @author Daniel Pittman * @author Christian Grothoff */ #include "internal.h" #include "mhd_str.h" #ifdef HAVE_MESSAGES #if DEBUG_STATES /** * State to string dictionary. */ const char * MHD_state_to_string (enum MHD_CONNECTION_STATE state) { switch (state) { case MHD_CONNECTION_INIT: return "connection init"; case MHD_CONNECTION_REQ_LINE_RECEIVED: return "connection url received"; case MHD_CONNECTION_REQ_HEADERS_RECEIVING: return "header receiving"; case MHD_CONNECTION_HEADERS_RECEIVED: return "headers received"; case MHD_CONNECTION_HEADERS_PROCESSED: return "headers processed"; case MHD_CONNECTION_CONTINUE_SENDING: return "continue sending"; case MHD_CONNECTION_CONTINUE_SENT: return "continue sent"; case MHD_CONNECTION_BODY_RECEIVED: return "body received"; case MHD_CONNECTION_FOOTERS_RECEIVING: return "footers receiving"; case MHD_CONNECTION_FOOTERS_RECEIVED: return "footers received"; case MHD_CONNECTION_HEADERS_SENDING: return "headers sending"; case MHD_CONNECTION_HEADERS_SENT: return "headers sent"; case MHD_CONNECTION_NORMAL_BODY_READY: return "normal body ready"; case MHD_CONNECTION_NORMAL_BODY_UNREADY: return "normal body unready"; case MHD_CONNECTION_CHUNKED_BODY_READY: return "chunked body ready"; case MHD_CONNECTION_CHUNKED_BODY_UNREADY: return "chunked body unready"; case MHD_CONNECTION_BODY_SENT: return "body sent"; case MHD_CONNECTION_FOOTERS_SENDING: return "footers sending"; case MHD_CONNECTION_FOOTERS_SENT: return "footers sent"; case MHD_CONNECTION_CLOSED: return "closed"; default: return "unrecognized connection state"; } } #endif #endif #ifdef HAVE_MESSAGES /** * fprintf-like helper function for logging debug * messages. */ void MHD_DLOG (const struct MHD_Daemon *daemon, enum MHD_StatusCode sc, const char *format, ...) { va_list va; if (NULL == daemon->logger) return; va_start (va, format); daemon->logger (daemon->logger_cls, sc, format, va); va_end (va); } #endif /** * Convert all occurrences of '+' to ' '. * * @param arg string that is modified (in place), must be 0-terminated */ void MHD_unescape_plus (char *arg) { char *p; for (p = strchr (arg, '+'); NULL != p; p = strchr (p + 1, '+')) *p = ' '; } /** * Process escape sequences ('%HH') Updates val in place; the * result should be UTF-8 encoded and cannot be larger than the input. * The result must also still be 0-terminated. * * @param val value to unescape (modified in the process) * @return length of the resulting val (strlen(val) maybe * shorter afterwards due to elimination of escape sequences) */ size_t MHD_http_unescape (char *val) { char *rpos = val; char *wpos = val; while ('\0' != *rpos) { uint32_t num; switch (*rpos) { case '%': if (2 == MHD_strx_to_uint32_n_ (rpos + 1, 2, &num)) { *wpos = (char) ((unsigned char) num); wpos++; rpos += 3; break; } /* TODO: add bad sequence handling */ /* intentional fall through! */ default: *wpos = *rpos; wpos++; rpos++; } } *wpos = '\0'; /* add 0-terminator */ return wpos - val; /* = strlen(val) */ } /** * Parse and unescape the arguments given by the client * as part of the HTTP request URI. * * @param request request to add headers to * @param kind header kind to pass to @a cb * @param[in,out] args argument URI string (after "?" in URI), * clobbered in the process! * @param cb function to call on each key-value pair found * @param[out] num_headers set to the number of headers found * @return false on failure (@a cb returned false), * true for success (parsing succeeded, @a cb always * returned true) */ bool MHD_parse_arguments_ (struct MHD_Request *request, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, unsigned int *num_headers) { struct MHD_Daemon *daemon = request->daemon; char *equals; char *amper; *num_headers = 0; while ( (NULL != args) && ('\0' != args[0]) ) { equals = strchr (args, '='); amper = strchr (args, '&'); if (NULL == amper) { /* last argument */ if (NULL == equals) { /* last argument, without '=' */ MHD_unescape_plus (args); daemon->unescape_cb (daemon->unescape_cb_cls, request, args); if (! cb (request, args, NULL, kind)) return false; (*num_headers)++; break; } /* got 'foo=bar' */ equals[0] = '\0'; equals++; MHD_unescape_plus (args); daemon->unescape_cb (daemon->unescape_cb_cls, request, args); MHD_unescape_plus (equals); daemon->unescape_cb (daemon->unescape_cb_cls, request, equals); if (! cb (request, args, equals, kind)) return false; (*num_headers)++; break; } /* amper is non-NULL here */ amper[0] = '\0'; amper++; if ( (NULL == equals) || (equals >= amper) ) { /* got 'foo&bar' or 'foo&bar=val', add key 'foo' with NULL for value */ MHD_unescape_plus (args); daemon->unescape_cb (daemon->unescape_cb_cls, request, args); if (! cb (request, args, NULL, kind)) return false; /* continue with 'bar' */ (*num_headers)++; args = amper; continue; } /* equals and amper are non-NULL here, and equals < amper, so we got regular 'foo=value&bar...'-kind of argument */ equals[0] = '\0'; equals++; MHD_unescape_plus (args); daemon->unescape_cb (daemon->unescape_cb_cls, request, args); MHD_unescape_plus (equals); daemon->unescape_cb (daemon->unescape_cb_cls, request, equals); if (! cb (request, args, equals, kind)) return false; (*num_headers)++; args = amper; } return true; } /* end of internal.c */ libmicrohttpd-1.0.1/src/lib/response_for_upgrade.c0000644000175000017500000000701414417460232015757 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/response_for_upgrade.c * @brief implementation of MHD_response_for_upgrade() * @author Christian Grothoff */ #include "internal.h" /** * Create a response object that can be used for 101 UPGRADE * responses, for example to implement WebSockets. After sending the * response, control over the data stream is given to the callback (which * can then, for example, start some bi-directional communication). * If the response is queued for multiple connections, the callback * will be called for each connection. The callback * will ONLY be called after the response header was successfully passed * to the OS; if there are communication errors before, the usual MHD * connection error handling code will be performed. * * MHD will automatically set the correct HTTP status * code (#MHD_HTTP_SWITCHING_PROTOCOLS). * Setting correct HTTP headers for the upgrade must be done * manually (this way, it is possible to implement most existing * WebSocket versions using this API; in fact, this API might be useful * for any protocol switch, not just WebSockets). Note that * draft-ietf-hybi-thewebsocketprotocol-00 cannot be implemented this * way as the header "HTTP/1.1 101 WebSocket Protocol Handshake" * cannot be generated; instead, MHD will always produce "HTTP/1.1 101 * Switching Protocols" (if the response code 101 is used). * * As usual, the response object can be extended with header * information and then be used any number of times (as long as the * header information is not connection-specific). * * @param upgrade_handler function to call with the "upgraded" socket * @param upgrade_handler_cls closure for @a upgrade_handler * @return NULL on error (i.e. invalid arguments, out of memory) */ struct MHD_Response * MHD_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, void *upgrade_handler_cls) { #ifdef UPGRADE_SUPPORT struct MHD_Response *response; mhd_assert (NULL != upgrade_handler); response = MHD_calloc_ (1, sizeof (struct MHD_Response)); if (NULL == response) return NULL; if (! MHD_mutex_init_ (&response->mutex)) { free (response); return NULL; } response->upgrade_handler = upgrade_handler; response->upgrade_handler_cls = upgrade_handler_cls; response->status_code = MHD_HTTP_SWITCHING_PROTOCOLS; response->total_size = MHD_SIZE_UNKNOWN; response->reference_count = 1; if (MHD_NO == MHD_response_add_header (response, MHD_HTTP_HEADER_CONNECTION, "Upgrade")) { MHD_response_queue_for_destroy (response); return NULL; } return response; #else return NULL; #endif } /* end of response_for_upgrade.c */ libmicrohttpd-1.0.1/src/lib/panic.c0000644000175000017500000000356314417460232012643 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/panic.c * @brief functions to panic (abort) * @author Christian Grothoff */ #include "internal.h" /** * Handler for fatal errors. */ MHD_PanicCallback mhd_panic = NULL; /** * Closure argument for #mhd_panic. */ void *mhd_panic_cls = NULL; /** * Sets the global error handler to a different implementation. @a cb * will only be called in the case of typically fatal, serious * internal consistency issues. These issues should only arise in the * case of serious memory corruption or similar problems with the * architecture. While @a cb is allowed to return and MHD will then * try to continue, this is never safe. * * The default implementation that is used if no panic function is set * simply prints an error message and calls `abort()`. Alternative * implementations might call `exit()` or other similar functions. * * @param cb new error handler * @param cls passed to @a cb * @ingroup logging */ void MHD_set_panic_func (MHD_PanicCallback cb, void *cls) { mhd_panic = cb; mhd_panic_cls = cls; } libmicrohttpd-1.0.1/src/lib/daemon_run.c0000644000175000017500000000530114417460232013670 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_run.c * @brief generic function to run event loop of a daemon * @author Christian Grothoff */ #include "internal.h" #include "connection_cleanup.h" #include "daemon_epoll.h" #include "daemon_poll.h" #include "daemon_select.h" /** * Run webserver operations (without blocking unless in client * callbacks). This method should be called by clients in combination * with #MHD_get_fdset if the client-controlled select method is used * and #MHD_get_timeout(). * * This function is a convenience method, which is useful if the * fd_sets from #MHD_get_fdset were not directly passed to `select()`; * with this function, MHD will internally do the appropriate `select()` * call itself again. While it is always safe to call #MHD_run (if * #MHD_USE_INTERNAL_POLLING_THREAD is not set), you should call * #MHD_run_from_select if performance is important (as it saves an * expensive call to `select()`). * * @param daemon daemon to run * @return #MHD_SC_OK on success * @ingroup event */ enum MHD_StatusCode MHD_daemon_run (struct MHD_Daemon *daemon) { enum MHD_StatusCode sc; if (daemon->shutdown) return MHD_SC_DAEMON_ALREADY_SHUTDOWN; if (MHD_TM_EXTERNAL_EVENT_LOOP != daemon->threading_mode) return MHD_SC_CONFIGURATION_MISMATCH_FOR_RUN_EXTERNAL; switch (daemon->event_loop_syscall) { case MHD_ELS_POLL: sc = MHD_daemon_poll_ (daemon, MHD_NO); MHD_connection_cleanup_ (daemon); return sc; #ifdef EPOLL_SUPPORT case MHD_ELS_EPOLL: sc = MHD_daemon_epoll_ (daemon, MHD_NO); MHD_connection_cleanup_ (daemon); return sc; #endif case MHD_ELS_SELECT: return MHD_daemon_select_ (daemon, MHD_NO); /* MHD_select does MHD_connection_cleanup_ already */ default: return MHD_SC_CONFIGURATION_UNEXPECTED_ELS; } } /* end of daemon_run.c */ libmicrohttpd-1.0.1/src/lib/mhd_compat.h0000644000175000017500000000537514417460232013674 /* This file is part of libmicrohttpd Copyright (C) 2014-2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_compat.h * @brief Header for platform missing functions. * @author Karlson2k (Evgeny Grin) * * Provides compatibility for platforms with some missing * functionality. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid * variable modification in function parameters. */ #ifndef MHD_COMPAT_H #define MHD_COMPAT_H 1 #include "mhd_options.h" #include #ifdef HAVE_STRING_H /* for strerror() */ #include #endif /* HAVE_STRING_H */ /* MHD_strerror_ is strerror */ #define MHD_strerror_(errnum) strerror ((errnum)) /* Platform-independent snprintf name */ #if defined(HAVE_SNPRINTF) #define MHD_snprintf_ snprintf #else /* ! HAVE_SNPRINTF */ #if defined(_WIN32) && ! defined(__CYGWIN__) /* Emulate snprintf function on W32 */ int W32_snprintf (char *__restrict s, size_t n, const char *__restrict format, ...); #define MHD_snprintf_ W32_snprintf #else /* ! _WIN32 || __CYGWIN__ */ #error \ Your platform does not support snprintf() and MHD does not know how to emulate it on your platform. #endif /* ! _WIN32 || __CYGWIN__ */ #endif /* ! HAVE_SNPRINTF */ #ifdef HAVE_RANDOM /** * Generate pseudo random number at least 30-bit wide. * @return pseudo random number at least 30-bit wide. */ #define MHD_random_() random () #else /* HAVE_RANDOM */ #ifdef HAVE_RAND /** * Generate pseudo random number at least 30-bit wide. * @return pseudo random number at least 30-bit wide. */ #define MHD_random_() ( (((long) rand ()) << 15) + (long) rand () ) #endif /* HAVE_RAND */ #endif /* HAVE_RANDOM */ #ifdef HAVE_CALLOC /** * MHD_calloc_ is platform-independent calloc() */ #define MHD_calloc_(n,s) calloc ((n),(s)) #else /* ! HAVE_CALLOC */ /** * MHD_calloc_ is platform-independent calloc() */ void *MHD_calloc_ (size_t nelem, size_t elsize); #endif /* ! HAVE_CALLOC */ #endif /* MHD_COMPAT_H */ libmicrohttpd-1.0.1/src/lib/mhd_locks.h0000644000175000017500000001321514417460232013514 /* This file is part of libmicrohttpd Copyright (C) 2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_locks.h * @brief Header for platform-independent locks abstraction * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff * * Provides basic abstraction for locks/mutex. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid * variable modification in function parameters. * * @warning Unlike pthread functions, most of functions return * nonzero on success. */ #ifndef MHD_LOCKS_H #define MHD_LOCKS_H 1 #include "mhd_options.h" #if defined(MHD_USE_W32_THREADS) # define MHD_W32_MUTEX_ 1 # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif /* !WIN32_LEAN_AND_MEAN */ # include #elif defined(HAVE_PTHREAD_H) && defined(MHD_USE_POSIX_THREADS) # define MHD_PTHREAD_MUTEX_ 1 # undef HAVE_CONFIG_H # include # define HAVE_CONFIG_H 1 #else # error No base mutex API is available. #endif #ifndef MHD_PANIC # include # include /* Simple implementation of MHD_PANIC, to be used outside lib */ # define MHD_PANIC(msg) do { fprintf (stderr, \ "Abnormal termination at %d line in file %s: %s\n", \ (int) __LINE__, __FILE__, msg); abort (); \ } while (0) #endif /* ! MHD_PANIC */ #if defined(MHD_PTHREAD_MUTEX_) typedef pthread_mutex_t MHD_mutex_; #elif defined(MHD_W32_MUTEX_) typedef CRITICAL_SECTION MHD_mutex_; #endif #if defined(MHD_PTHREAD_MUTEX_) /** * Initialise new mutex. * @param pmutex pointer to the mutex * @return nonzero on success, zero otherwise */ #define MHD_mutex_init_(pmutex) (! (pthread_mutex_init ((pmutex), NULL))) #elif defined(MHD_W32_MUTEX_) /** * Initialise new mutex. * @param pmutex pointer to mutex * @return nonzero on success, zero otherwise */ #define MHD_mutex_init_(pmutex) (InitializeCriticalSectionAndSpinCount ( \ (pmutex),16)) #endif #if defined(MHD_PTHREAD_MUTEX_) # if defined(PTHREAD_MUTEX_INITIALIZER) /** * Define static mutex and statically initialise it. */ # define MHD_MUTEX_STATIC_DEFN_INIT_(m) static MHD_mutex_ m = \ PTHREAD_MUTEX_INITIALIZER # endif /* PTHREAD_MUTEX_INITIALIZER */ #endif #if defined(MHD_PTHREAD_MUTEX_) /** * Destroy previously initialised mutex. * @param pmutex pointer to mutex * @return nonzero on success, zero otherwise */ #define MHD_mutex_destroy_(pmutex) (! (pthread_mutex_destroy ((pmutex)))) #elif defined(MHD_W32_MUTEX_) /** * Destroy previously initialised mutex. * @param pmutex pointer to mutex * @return Always nonzero */ #define MHD_mutex_destroy_(pmutex) (DeleteCriticalSection ((pmutex)), ! 0) #endif /** * Destroy previously initialised mutex and abort execution * if error is detected. * @param pmutex pointer to mutex */ #define MHD_mutex_destroy_chk_(pmutex) do { \ if (! MHD_mutex_destroy_ (pmutex)) \ MHD_PANIC (_ ("Failed to destroy mutex.\n")); \ } while (0) #if defined(MHD_PTHREAD_MUTEX_) /** * Acquire lock on previously initialised mutex. * If mutex was already locked by other thread, function * blocks until mutex becomes available. * @param pmutex pointer to mutex * @return nonzero on success, zero otherwise */ #define MHD_mutex_lock_(pmutex) (! (pthread_mutex_lock ((pmutex)))) #elif defined(MHD_W32_MUTEX_) /** * Acquire lock on previously initialised mutex. * If mutex was already locked by other thread, function * blocks until mutex becomes available. * @param pmutex pointer to mutex * @return Always nonzero */ #define MHD_mutex_lock_(pmutex) (EnterCriticalSection ((pmutex)), ! 0) #endif /** * Acquire lock on previously initialised mutex. * If mutex was already locked by other thread, function * blocks until mutex becomes available. * If error is detected, execution will be aborted. * @param pmutex pointer to mutex */ #define MHD_mutex_lock_chk_(pmutex) do { \ if (! MHD_mutex_lock_ (pmutex)) \ MHD_PANIC (_ ("Failed to lock mutex.\n")); \ } while (0) #if defined(MHD_PTHREAD_MUTEX_) /** * Unlock previously initialised and locked mutex. * @param pmutex pointer to mutex * @return nonzero on success, zero otherwise */ #define MHD_mutex_unlock_(pmutex) (! (pthread_mutex_unlock ((pmutex)))) #elif defined(MHD_W32_MUTEX_) /** * Unlock previously initialised and locked mutex. * @param pmutex pointer to mutex * @return Always nonzero */ #define MHD_mutex_unlock_(pmutex) (LeaveCriticalSection ((pmutex)), ! 0) #endif /** * Unlock previously initialised and locked mutex. * If error is detected, execution will be aborted. * @param pmutex pointer to mutex */ #define MHD_mutex_unlock_chk_(pmutex) do { \ if (! MHD_mutex_unlock_ (pmutex)) \ MHD_PANIC (_ ("Failed to unlock mutex.\n")); \ } while (0) #endif /* ! MHD_LOCKS_H */ libmicrohttpd-1.0.1/src/lib/connection_add.c0000644000175000017500000010620714417460232014517 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_add.c * @brief functions to add connection to our active set * @author Christian Grothoff */ #include "internal.h" #include "connection_add.h" #include "connection_call_handlers.h" #include "connection_close.h" #include "connection_finish_forward.h" #include "connection_update_last_activity.h" #include "daemon_ip_limit.h" #include "daemon_select.h" #include "daemon_poll.h" #include "mhd_sockets.h" #ifdef UPGRADE_SUPPORT /** * Main function of the thread that handles an individual connection * after it was "upgraded" when #MHD_USE_THREAD_PER_CONNECTION is set. * @remark To be called only from thread that process * connection's recv(), send() and response. * * @param con the connection this thread will handle */ static void thread_main_connection_upgrade (struct MHD_Connection *con) { #ifdef HTTPS_SUPPORT struct MHD_Daemon *daemon = con->daemon; /* Here, we need to bi-directionally forward until the application tells us that it is done with the socket; */ if ( (NULL != daemon->tls_api) && (MHD_ELS_POLL != daemon->event_loop_syscall) ) { MHD_daemon_upgrade_connection_with_select_ (con); } #ifdef HAVE_POLL else if (NULL != daemon->tls_api) { MHD_daemon_upgrade_connection_with_poll_ (con); } #endif /* end HTTPS */ #endif /* HTTPS_SUPPORT */ /* TLS forwarding was finished. Cleanup socketpair. */ MHD_connection_finish_forward_ (con); /* Do not set 'urh->clean_ready' yet as 'urh' will be used * in connection thread for a little while. */ } #endif /* UPGRADE_SUPPORT */ /** * Main function of the thread that handles an individual * connection when #MHD_USE_THREAD_PER_CONNECTION is set. * * @param data the `struct MHD_Connection` this thread will handle * @return always 0 */ static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ thread_main_handle_connection (void *data) { struct MHD_Connection *con = data; struct MHD_Daemon *daemon = con->daemon; int num_ready; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; struct timeval tv; struct timeval *tvp; time_t now; #if WINDOWS #ifdef HAVE_POLL int extra_slot; #endif /* HAVE_POLL */ #define EXTRA_SLOTS 1 #else /* !WINDOWS */ #define EXTRA_SLOTS 0 #endif /* !WINDOWS */ #ifdef HAVE_POLL struct pollfd p[1 + EXTRA_SLOTS]; #endif #undef EXTRA_SLOTS #ifdef HAVE_POLL const bool use_poll = (MHD_ELS_POLL == daemon->event_loop_syscall); #else /* ! HAVE_POLL */ const bool use_poll = false; #endif /* ! HAVE_POLL */ bool was_suspended = false; MHD_thread_init_ (&con->pid); while ( (! daemon->shutdown) && (MHD_REQUEST_CLOSED != con->request.state) ) { const time_t timeout = daemon->connection_default_timeout; #ifdef UPGRADE_SUPPORT struct MHD_UpgradeResponseHandle *const urh = con->request.urh; #else /* ! UPGRADE_SUPPORT */ static const void *const urh = NULL; #endif /* ! UPGRADE_SUPPORT */ if ( (con->suspended) && (NULL == urh) ) { /* Connection was suspended, wait for resume. */ was_suspended = true; if (! use_poll) { FD_ZERO (&rs); if (! MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), &rs, NULL, FD_SETSIZE)) { #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE, _ ("Failed to add FD to fd_set.\n")); #endif goto exit; } if (0 > MHD_SYS_select_ (MHD_itc_r_fd_ (daemon->itc) + 1, &rs, NULL, NULL, NULL)) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, MHD_SC_UNEXPECTED_SELECT_ERROR, _ ("Error during select (%d): `%s'\n"), err, MHD_socket_strerr_ (err)); #endif break; } } #ifdef HAVE_POLL else /* use_poll */ { p[0].events = POLLIN; p[0].fd = MHD_itc_r_fd_ (daemon->itc); p[0].revents = 0; if (0 > MHD_sys_poll_ (p, 1, -1)) { if (MHD_SCKT_LAST_ERR_IS_ (MHD_SCKT_EINTR_)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, MHD_SC_UNEXPECTED_POLL_ERROR, _ ("Error during poll: `%s'\n"), MHD_socket_last_strerr_ ()); #endif break; } } #endif /* HAVE_POLL */ MHD_itc_clear_ (daemon->itc); continue; /* Check again for resume. */ } /* End of "suspended" branch. */ if (was_suspended) { MHD_connection_update_last_activity_ (con); /* Reset timeout timer. */ /* Process response queued during suspend and update states. */ MHD_request_handle_idle_ (&con->request); was_suspended = false; } tvp = NULL; if ( (MHD_EVENT_LOOP_INFO_BLOCK == con->request.event_loop_info) #ifdef HTTPS_SUPPORT || ( (con->tls_read_ready) && (MHD_EVENT_LOOP_INFO_READ == con->request.event_loop_info) ) #endif /* HTTPS_SUPPORT */ ) { /* do not block: more data may be inside of TLS buffers waiting or * application must provide response data */ tv.tv_sec = 0; tv.tv_usec = 0; tvp = &tv; } if ( (NULL == tvp) && (timeout > 0) ) { now = MHD_monotonic_sec_counter (); if (now - con->last_activity > timeout) tv.tv_sec = 0; else { const time_t seconds_left = timeout - (now - con->last_activity); #if ! defined(_WIN32) || defined(__CYGWIN__) tv.tv_sec = seconds_left; #else /* _WIN32 && !__CYGWIN__ */ if (seconds_left > TIMEVAL_TV_SEC_MAX) tv.tv_sec = TIMEVAL_TV_SEC_MAX; else tv.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) seconds_left; #endif /* _WIN32 && ! __CYGWIN__ */ } tv.tv_usec = 0; tvp = &tv; } if (! use_poll) { /* use select */ bool err_state = false; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); maxsock = MHD_INVALID_SOCKET; switch (con->request.event_loop_info) { case MHD_EVENT_LOOP_INFO_READ: if (! MHD_add_to_fd_set_ (con->socket_fd, &rs, &maxsock, FD_SETSIZE)) err_state = true; break; case MHD_EVENT_LOOP_INFO_WRITE: if (! MHD_add_to_fd_set_ (con->socket_fd, &ws, &maxsock, FD_SETSIZE)) err_state = true; break; case MHD_EVENT_LOOP_INFO_BLOCK: if (! MHD_add_to_fd_set_ (con->socket_fd, &es, &maxsock, FD_SETSIZE)) err_state = true; break; case MHD_EVENT_LOOP_INFO_CLEANUP: /* how did we get here!? */ goto exit; } #if WINDOWS if (MHD_ITC_IS_VALID_ (daemon->itc) ) { if (! MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), &rs, &maxsock, FD_SETSIZE)) err_state = 1; } #endif if (err_state) { #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE, _ ("Failed to add FD to fd_set.\n")); #endif goto exit; } num_ready = MHD_SYS_select_ (maxsock + 1, &rs, &ws, &es, tvp); if (num_ready < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, MHD_SC_UNEXPECTED_SELECT_ERROR, _ ("Error during select (%d): `%s'\n"), err, MHD_socket_strerr_ (err)); #endif break; } #if WINDOWS /* Clear ITC before other processing so additional * signals will trigger select() again */ if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (FD_ISSET (MHD_itc_r_fd_ (daemon->itc), &rs)) ) MHD_itc_clear_ (daemon->itc); #endif if (MHD_NO == MHD_connection_call_handlers_ (con, FD_ISSET (con->socket_fd, &rs), FD_ISSET (con->socket_fd, &ws), FD_ISSET (con->socket_fd, &es)) ) goto exit; } #ifdef HAVE_POLL else { /* use poll */ memset (&p, 0, sizeof (p)); p[0].fd = con->socket_fd; switch (con->request.event_loop_info) { case MHD_EVENT_LOOP_INFO_READ: p[0].events |= POLLIN | MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_WRITE: p[0].events |= POLLOUT | MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_BLOCK: p[0].events |= MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_CLEANUP: /* how did we get here!? */ goto exit; } #if WINDOWS extra_slot = 0; if (MHD_ITC_IS_VALID_ (daemon->itc)) { p[1].events |= POLLIN; p[1].fd = MHD_itc_r_fd_ (daemon->itc); p[1].revents = 0; extra_slot = 1; } #endif if (MHD_sys_poll_ (p, #if WINDOWS 1 + extra_slot, #else 1, #endif (NULL == tvp) ? -1 : tv.tv_sec * 1000) < 0) { if (MHD_SCKT_LAST_ERR_IS_ (MHD_SCKT_EINTR_)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, MHD_SC_UNEXPECTED_POLL_ERROR, _ ("Error during poll: `%s'\n"), MHD_socket_last_strerr_ ()); #endif break; } #if WINDOWS /* Clear ITC before other processing so additional * signals will trigger poll() again */ if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (0 != (p[1].revents & (POLLERR | POLLHUP | POLLIN))) ) MHD_itc_clear_ (daemon->itc); #endif if (MHD_NO == MHD_connection_call_handlers_ (con, (0 != (p[0].revents & POLLIN)), (0 != (p[0].revents & POLLOUT)), (0 != (p[0].revents & (POLLERR | MHD_POLL_REVENTS_ERR_DISC))) )) goto exit; } #endif #ifdef UPGRADE_SUPPORT if (MHD_REQUEST_UPGRADE == con->request.state) { /* Normal HTTP processing is finished, * notify application. */ if (NULL != con->request.response->termination_cb) con->request.response->termination_cb (con->request.response->termination_cb_cls, MHD_REQUEST_TERMINATED_COMPLETED_OK, con->request.client_context); thread_main_connection_upgrade (con); /* MHD_connection_finish_forward_() was called by thread_main_connection_upgrade(). */ /* "Upgraded" data will not be used in this thread from this point. */ con->request.urh->clean_ready = true; /* If 'urh->was_closed' set to true, connection will be * moved immediately to cleanup list. Otherwise connection * will stay in suspended list until 'urh' will be marked * with 'was_closed' by application. */ MHD_request_resume (&con->request); /* skip usual clean up */ return (MHD_THRD_RTRN_TYPE_) 0; } #endif /* UPGRADE_SUPPORT */ } #if DEBUG_CLOSE #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, MHD_SC_THREAD_TERMINATING, _ ("Processing thread terminating. Closing connection.\n")); #endif #endif if (MHD_REQUEST_CLOSED != con->request.state) MHD_connection_close_ (con, (daemon->shutdown) ? MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN : MHD_REQUEST_TERMINATED_WITH_ERROR); MHD_request_handle_idle_ (&con->request); exit: if (NULL != con->request.response) { MHD_response_queue_for_destroy (con->request.response); con->request.response = NULL; } if (MHD_INVALID_SOCKET != con->socket_fd) { shutdown (con->socket_fd, SHUT_WR); /* 'socket_fd' can be used in other thread to signal shutdown. * To avoid data races, do not close socket here. Daemon will * use more connections only after cleanup anyway. */ } return (MHD_THRD_RTRN_TYPE_) 0; } /** * Callback for receiving data from the socket. * * @param connection the MHD connection structure * @param other where to write received data to * @param i maximum size of other (in bytes) * @return positive value for number of bytes actually received or * negative value for error number MHD_ERR_xxx_ */ static ssize_t recv_param_adapter (struct MHD_Connection *connection, void *other, size_t i) { ssize_t ret; if ( (MHD_INVALID_SOCKET == connection->socket_fd) || (MHD_REQUEST_CLOSED == connection->request.state) ) { return MHD_ERR_NOTCONN_; } if (i > MHD_SCKT_SEND_MAX_SIZE_) i = MHD_SCKT_SEND_MAX_SIZE_; /* return value limit */ ret = MHD_recv_ (connection->socket_fd, other, i); if (0 > ret) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) { #ifdef EPOLL_SUPPORT /* Got EAGAIN --- no longer read-ready */ connection->epoll_state &= ~MHD_EPOLL_STATE_READ_READY; #endif /* EPOLL_SUPPORT */ return MHD_ERR_AGAIN_; } if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_ERR_AGAIN_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_)) return MHD_ERR_CONNRESET_; /* Treat any other error as hard error. */ return MHD_ERR_NOTCONN_; } #ifdef EPOLL_SUPPORT else if (i > (size_t) ret) connection->epoll_state &= ~MHD_EPOLL_STATE_READ_READY; #endif /* EPOLL_SUPPORT */ return ret; } /** * Callback for writing data to the socket. * * @param connection the MHD connection structure * @param other data to write * @param i number of bytes to write * @return positive value for number of bytes actually sent or * negative value for error number MHD_ERR_xxx_ */ static ssize_t send_param_adapter (struct MHD_Connection *connection, const void *other, size_t i) { ssize_t ret; if ( (MHD_INVALID_SOCKET == connection->socket_fd) || (MHD_REQUEST_CLOSED == connection->request.state) ) { return MHD_ERR_NOTCONN_; } if (i > MHD_SCKT_SEND_MAX_SIZE_) i = MHD_SCKT_SEND_MAX_SIZE_; /* return value limit */ ret = MHD_send_ (connection->socket_fd, other, i); if (0 > ret) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) { #ifdef EPOLL_SUPPORT /* EAGAIN --- no longer write-ready */ connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; #endif /* EPOLL_SUPPORT */ return MHD_ERR_AGAIN_; } if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_ERR_AGAIN_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_)) return MHD_ERR_CONNRESET_; /* Treat any other error as hard error. */ return MHD_ERR_NOTCONN_; } #ifdef EPOLL_SUPPORT else if (i > (size_t) ret) connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; #endif /* EPOLL_SUPPORT */ return ret; } /** * Add another client connection to the set of connections * managed by MHD. This API is usually not needed (since * MHD will accept inbound connections on the server socket). * Use this API in special cases, for example if your HTTP * server is behind NAT and needs to connect out to the * HTTP client. * * The given client socket will be managed (and closed!) by MHD after * this call and must no longer be used directly by the application * afterwards. * * @param daemon daemon that manages the connection * @param client_socket socket to manage (MHD will expect * to receive an HTTP request from this socket next). * @param addr IP address of the client * @param addrlen number of bytes in @a addr * @param external_add perform additional operations needed due * to the application calling us directly * @param non_blck indicate that socket in non-blocking mode * @return #MHD_SC_OK on success */ static enum MHD_StatusCode internal_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen, bool external_add, bool non_blck) { enum MHD_StatusCode sc; struct MHD_Connection *connection; int eno = 0; /* Direct add to master daemon could happen only with "external" add mode. */ mhd_assert ( (NULL == daemon->worker_pool) || (external_add) ); if ( (external_add) && (NULL != daemon->worker_pool) ) { unsigned int i; /* have a pool, try to find a pool with capacity; we use the socket as the initial offset into the pool for load balancing */ for (i = 0; i < daemon->worker_pool_size; ++i) { struct MHD_Daemon *const worker = &daemon->worker_pool[(i + client_socket) % daemon->worker_pool_size]; if (worker->connections < worker->global_connection_limit) return internal_add_connection (worker, client_socket, addr, addrlen, true, non_blck); } /* all pools are at their connection limit, must refuse */ MHD_socket_close_chk_ (client_socket); #if ENFILE errno = ENFILE; #endif return MHD_SC_LIMIT_CONNECTIONS_REACHED; } if ( (! MHD_SCKT_FD_FITS_FDSET_ (client_socket, NULL)) && (MHD_ELS_SELECT == daemon->event_loop_syscall) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE, _ ("Socket descriptor larger than FD_SETSIZE: %d > %d\n"), (int) client_socket, (int) FD_SETSIZE); #endif MHD_socket_close_chk_ (client_socket); #if EINVAL errno = EINVAL; #endif return MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE; } #ifdef MHD_socket_nosignal_ if (! MHD_socket_nosignal_ (client_socket)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ACCEPT_CONFIGURE_NOSIGPIPE_FAILED, _ ("Failed to set SO_NOSIGPIPE on accepted socket: %s\n"), MHD_socket_last_strerr_ ()); #endif #ifndef MSG_NOSIGNAL /* Cannot use socket as it can produce SIGPIPE. */ #ifdef ENOTSOCK errno = ENOTSOCK; #endif /* ENOTSOCK */ return MHD_SC_ACCEPT_CONFIGURE_NOSIGPIPE_FAILED; #endif /* ! MSG_NOSIGNAL */ } #endif /* MHD_socket_nosignal_ */ #ifdef HAVE_MESSAGES #if DEBUG_CONNECT MHD_DLOG (daemon, MHD_SC_CONNECTION_ACCEPTED, _ ("Accepted connection on socket %d.\n"), client_socket); #endif #endif if ( (daemon->connections == daemon->global_connection_limit) || (MHD_NO == MHD_ip_limit_add (daemon, addr, addrlen)) ) { /* above connection limit - reject */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LIMIT_CONNECTIONS_REACHED, _ ( "Server reached connection limit. Closing inbound connection.\n")); #endif MHD_socket_close_chk_ (client_socket); #if ENFILE errno = ENFILE; #endif return MHD_SC_LIMIT_CONNECTIONS_REACHED; } /* apply connection acceptance policy if present */ if ( (NULL != daemon->accept_policy_cb) && (MHD_NO == daemon->accept_policy_cb (daemon->accept_policy_cb_cls, addr, addrlen)) ) { #if DEBUG_CLOSE #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ACCEPT_POLICY_REJECTED, _ ("Connection rejected by application. Closing connection.\n")); #endif #endif MHD_socket_close_chk_ (client_socket); MHD_ip_limit_del (daemon, addr, addrlen); #if EACCESS errno = EACCESS; #endif return MHD_SC_ACCEPT_POLICY_REJECTED; } if (NULL == (connection = MHD_calloc_ (1, sizeof (struct MHD_Connection)))) { eno = errno; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_CONNECTION_MALLOC_FAILURE, "Error allocating memory: %s\n", MHD_strerror_ (errno)); #endif MHD_socket_close_chk_ (client_socket); MHD_ip_limit_del (daemon, addr, addrlen); errno = eno; return MHD_SC_CONNECTION_MALLOC_FAILURE; } connection->pool = MHD_pool_create (daemon->connection_memory_limit_b); if (NULL == connection->pool) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_POOL_MALLOC_FAILURE, _ ("Error allocating memory: %s\n"), MHD_strerror_ (errno)); #endif MHD_socket_close_chk_ (client_socket); MHD_ip_limit_del (daemon, addr, addrlen); free (connection); #if ENOMEM errno = ENOMEM; #endif return MHD_SC_POOL_MALLOC_FAILURE; } connection->connection_timeout = daemon->connection_default_timeout; memcpy (&connection->addr, addr, addrlen); connection->addr_len = addrlen; connection->socket_fd = client_socket; connection->sk_nonblck = non_blck; connection->daemon = daemon; connection->last_activity = MHD_monotonic_sec_counter (); #ifdef HTTPS_SUPPORT if (NULL != daemon->tls_api) { connection->tls_cs = daemon->tls_api->setup_connection (daemon->tls_api->cls, NULL /* FIXME */); if (NULL == connection->tls_cs) { eno = EINVAL; sc = -1; // FIXME! goto cleanup; } } else #endif /* ! HTTPS_SUPPORT */ { /* set default connection handlers */ connection->recv_cls = &recv_param_adapter; connection->send_cls = &send_param_adapter; } MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); /* Firm check under lock. */ if (daemon->connections >= daemon->global_connection_limit) { MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); /* above connection limit - reject */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_LIMIT_CONNECTIONS_REACHED, _ ( "Server reached connection limit. Closing inbound connection.\n")); #endif #if ENFILE eno = ENFILE; #endif sc = MHD_SC_LIMIT_CONNECTIONS_REACHED; goto cleanup; } daemon->connections++; if (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) { XDLL_insert (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); } DLL_insert (daemon->connections_head, daemon->connections_tail, connection); MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); if (NULL != daemon->notify_connection_cb) daemon->notify_connection_cb (daemon->notify_connection_cb_cls, connection, MHD_CONNECTION_NOTIFY_STARTED); /* attempt to create handler thread */ if (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) { if (! MHD_create_named_thread_ (&connection->pid, "MHD-connection", daemon->thread_stack_limit_b, &thread_main_handle_connection, connection)) { eno = errno; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_THREAD_LAUNCH_FAILURE, "Failed to create a thread: %s\n", MHD_strerror_ (eno)); #endif sc = MHD_SC_THREAD_LAUNCH_FAILURE; goto cleanup; } } else { connection->pid = daemon->pid; } #ifdef EPOLL_SUPPORT if (MHD_ELS_EPOLL == daemon->event_loop_syscall) { if ( (! daemon->enable_turbo) || (external_add)) { /* Do not manipulate EReady DL-list in 'external_add' mode. */ struct epoll_event event; event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET; event.data.ptr = connection; if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, client_socket, &event)) { eno = errno; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_EPOLL_CTL_ADD_FAILED, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif sc = MHD_SC_EPOLL_CTL_ADD_FAILED; goto cleanup; } connection->epoll_state |= MHD_EPOLL_STATE_IN_EPOLL_SET; } else { connection->epoll_state |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY | MHD_EPOLL_STATE_IN_EREADY_EDLL; EDLL_insert (daemon->eready_head, daemon->eready_tail, connection); } } else /* This 'else' is combined with next 'if'. */ #endif if ( (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) && (external_add) && (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "n")) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ITC_USE_FAILED, _ ( "Failed to signal new connection via inter-thread communication channel (not necessarily fatal, continuing anyway).\n")); #endif } return MHD_SC_OK; cleanup: if (NULL != daemon->notify_connection_cb) daemon->notify_connection_cb (daemon->notify_connection_cb_cls, connection, MHD_CONNECTION_NOTIFY_CLOSED); #ifdef HTTPS_SUPPORT if ( (NULL != daemon->tls_api) && (NULL != connection->tls_cs) ) daemon->tls_api->teardown_connection (daemon->tls_api->cls, connection->tls_cs); #endif /* HTTPS_SUPPORT */ MHD_socket_close_chk_ (client_socket); MHD_ip_limit_del (daemon, addr, addrlen); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); if (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) { XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); } DLL_remove (daemon->connections_head, daemon->connections_tail, connection); MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); MHD_pool_destroy (connection->pool); free (connection); if (0 != eno) errno = eno; else errno = EINVAL; return sc; } /** * Add another client connection to the set of connections managed by * MHD. This API is usually not needed (since MHD will accept inbound * connections on the server socket). Use this API in special cases, * for example if your HTTP server is behind NAT and needs to connect * out to the HTTP client, or if you are building a proxy. * * If you use this API in conjunction with a internal select or a * thread pool, you must set the option #MHD_USE_ITC to ensure that * the freshly added connection is immediately processed by MHD. * * The given client socket will be managed (and closed!) by MHD after * this call and must no longer be used directly by the application * afterwards. * * @param daemon daemon that manages the connection * @param client_socket socket to manage (MHD will expect * to receive an HTTP request from this socket next). * @param addr IP address of the client * @param addrlen number of bytes in @a addr * @return #MHD_YES on success, #MHD_NO if this daemon could * not handle the connection (i.e. malloc() failed, etc). * The socket will be closed in any case; `errno` is * set to indicate further details about the error. * @ingroup specialized */ enum MHD_StatusCode MHD_daemon_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen) { bool sk_nonbl; if (! MHD_socket_nonblocking_ (client_socket)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ACCEPT_CONFIGURE_NONBLOCKING_FAILED, _ ("Failed to set nonblocking mode on new client socket: %s\n"), MHD_socket_last_strerr_ ()); #endif sk_nonbl = false; } else { sk_nonbl = true; } if ( (daemon->enable_turbo) && (! MHD_socket_noninheritable_ (client_socket)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ACCEPT_CONFIGURE_NOINHERIT_FAILED, _ ("Failed to set noninheritable mode on new client socket.\n")); #endif } return internal_add_connection (daemon, client_socket, addr, addrlen, true, sk_nonbl); } /** * Accept an incoming connection and create the MHD_Connection object * for it. This function also enforces policy by way of checking with * the accept policy callback. @remark To be called only from thread * that process daemon's select()/poll()/etc. * * @param daemon handle with the listen socket * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_accept_connection_ (struct MHD_Daemon *daemon) { struct sockaddr_storage addrstorage; struct sockaddr *addr = (struct sockaddr *) &addrstorage; socklen_t addrlen; MHD_socket s; MHD_socket fd; bool sk_nonbl; addrlen = sizeof (addrstorage); memset (addr, 0, sizeof (addrstorage)); if ( (MHD_INVALID_SOCKET == (fd = daemon->listen_socket)) || (daemon->was_quiesced) ) return MHD_SC_DAEMON_ALREADY_QUIESCED; #ifdef USE_ACCEPT4 s = accept4 (fd, addr, &addrlen, MAYBE_SOCK_CLOEXEC | MAYBE_SOCK_NONBLOCK); sk_nonbl = (0 != MAYBE_SOCK_NONBLOCK); #else /* ! USE_ACCEPT4 */ s = accept (fd, addr, &addrlen); sk_nonbl = false; #endif /* ! USE_ACCEPT4 */ if ( (MHD_INVALID_SOCKET == s) || (addrlen <= 0) ) { const int err = MHD_socket_get_error_ (); /* This could be a common occurrence with multiple worker threads */ if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINVAL_)) return MHD_SC_DAEMON_ALREADY_SHUTDOWN; /* can happen during shutdown, let's hope this is the cause... */ if (MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_ (err)) return MHD_SC_ACCEPT_FAST_DISCONNECT; /* do not print error if client just disconnected early */ if (MHD_SCKT_ERR_IS_EAGAIN_ (err) ) return MHD_SC_ACCEPT_FAILED_EAGAIN; if (MHD_INVALID_SOCKET != s) { MHD_socket_close_chk_ (s); } if (MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err) ) { /* system/process out of resources */ if (0 == daemon->connections) { #ifdef HAVE_MESSAGES /* Not setting 'at_limit' flag, as there is no way it would ever be cleared. Instead trying to produce bit fat ugly warning. */ MHD_DLOG (daemon, MHD_SC_ACCEPT_SYSTEM_LIMIT_REACHED_INSTANTLY, _ ( "Hit process or system resource limit at FIRST connection. This is really bad as there is no sane way to proceed. Will try busy waiting for system resources to become magically available.\n")); #endif return MHD_SC_ACCEPT_SYSTEM_LIMIT_REACHED_INSTANTLY; } else { MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); daemon->at_limit = true; MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ACCEPT_SYSTEM_LIMIT_REACHED, _ ( "Hit process or system resource limit at %u connections, temporarily suspending accept(). Consider setting a lower MHD_OPTION_CONNECTION_LIMIT.\n"), (unsigned int) daemon->connections); #endif return MHD_SC_ACCEPT_SYSTEM_LIMIT_REACHED; } } #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ACCEPT_FAILED_UNEXPECTEDLY, _ ("Error accepting connection: %s\n"), MHD_socket_strerr_ (err)); #endif return MHD_SC_ACCEPT_FAILED_UNEXPECTEDLY; } #if ! defined(USE_ACCEPT4) || ! defined(HAVE_SOCK_NONBLOCK) if (! MHD_socket_nonblocking_ (s)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ACCEPT_CONFIGURE_NONBLOCKING_FAILED, _ ( "Failed to set nonblocking mode on incoming connection socket: %s\n"), MHD_socket_last_strerr_ ()); #endif } else sk_nonbl = true; #endif /* !USE_ACCEPT4 || !HAVE_SOCK_NONBLOCK */ #if ! defined(USE_ACCEPT4) || ! defined(SOCK_CLOEXEC) if (! MHD_socket_noninheritable_ (s)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_ACCEPT_CONFIGURE_NOINHERIT_FAILED, _ ( "Failed to set noninheritable mode on incoming connection socket.\n")); #endif } #endif /* !USE_ACCEPT4 || !SOCK_CLOEXEC */ #ifdef HAVE_MESSAGES #if DEBUG_CONNECT MHD_DLOG (daemon, MHD_SC_CONNECTION_ACCEPTED, _ ("Accepted connection on socket %d.\n"), s); #endif #endif return internal_add_connection (daemon, s, addr, addrlen, false, sk_nonbl); } /* end of connection_add.c */ libmicrohttpd-1.0.1/src/lib/upgrade_process.c0000644000175000017500000003310714417460232014733 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/upgrade_process.c * @brief function to process upgrade activity (over TLS) * @author Christian Grothoff */ #include "internal.h" #include "upgrade_process.h" #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Performs bi-directional forwarding on upgraded HTTPS connections * based on the readiness state stored in the @a urh handle. * @remark To be called only from thread that process * connection's recv(), send() and response. * * @param urh handle to process */ void MHD_upgrade_response_handle_process_ (struct MHD_UpgradeResponseHandle *urh) { /* Help compiler to optimize: * pointers to 'connection' and 'daemon' are not changed * during this processing, so no need to chain dereference * each time. */ struct MHD_Connection *const connection = urh->connection; struct MHD_Daemon *const daemon = connection->daemon; /* Prevent data races: use same value of 'was_closed' throughout * this function. If 'was_closed' changed externally in the middle * of processing - it will be processed on next iteration. */ bool was_closed; struct MHD_TLS_Plugin *tls = daemon->tls_api; if (daemon->shutdown) { /* Daemon shutting down, application will not receive any more data. */ #ifdef HAVE_MESSAGES if (! urh->was_closed) { MHD_DLOG (daemon, MHD_SC_DAEMON_ALREADY_SHUTDOWN, _ ( "Initiated daemon shutdown while \"upgraded\" connection was not closed.\n")); } #endif urh->was_closed = true; } was_closed = urh->was_closed; if (was_closed) { /* Application was closed connections: no more data * can be forwarded to application socket. */ if (0 < urh->in_buffer_used) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_UPGRADE_FORWARD_INCOMPLETE, _ ( "Failed to forward to application " MHD_UNSIGNED_LONG_LONG_PRINTF \ " bytes of data received from remote side: application shut down socket.\n"), (MHD_UNSIGNED_LONG_LONG) urh->in_buffer_used); #endif } /* If application signaled MHD about socket closure then * check for any pending data even if socket is not marked * as 'ready' (signal may arrive after poll()/select()). * Socketpair for forwarding is always in non-blocking mode * so no risk that recv() will block the thread. */if (0 != urh->out_buffer_size) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; /* Discard any data received form remote. */ urh->in_buffer_used = 0; /* Do not try to push data to application. */ urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY; /* Reading from remote client is not required anymore. */ urh->in_buffer_size = 0; urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; connection->tls_read_ready = false; } /* On some platforms (W32, possibly Darwin) failed send() (send() will always * fail after remote disconnect was detected) may discard data in system * buffers received by system but not yet read by recv(). * So, before trying send() on any socket, recv() must be performed at first * otherwise last part of incoming data may be lost. *//* If disconnect or error was detected - try to read from socket * to dry data possibly pending is system buffers. */if (0 != (MHD_EPOLL_STATE_ERROR & urh->app.celi)) urh->app.celi |= MHD_EPOLL_STATE_READ_READY; if (0 != (MHD_EPOLL_STATE_ERROR & urh->mhd.celi)) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; /* * handle reading from remote TLS client */ if ( ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->app.celi)) || (connection->tls_read_ready) ) && (urh->in_buffer_used < urh->in_buffer_size) ) { ssize_t res; size_t buf_size; buf_size = urh->in_buffer_size - urh->in_buffer_used; if (buf_size > SSIZE_MAX) buf_size = SSIZE_MAX; connection->tls_read_ready = false; res = tls->recv (tls->cls, connection->tls_cs, &urh->in_buffer[urh->in_buffer_used], buf_size); if (0 >= res) { // FIXME: define GNUTLS-independent error codes! if (GNUTLS_E_INTERRUPTED != res) { urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; if (GNUTLS_E_AGAIN != res) { /* Unrecoverable error on socket was detected or * socket was disconnected/shut down. */ /* Stop trying to read from this TLS socket. */ urh->in_buffer_size = 0; } } } else /* 0 < res */ { urh->in_buffer_used += res; if (buf_size > (size_t) res) urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; else if (0 < tls->check_record_pending (tls->cls, connection->tls_cs)) connection->tls_read_ready = true; } if (MHD_EPOLL_STATE_ERROR == ((MHD_EPOLL_STATE_ERROR | MHD_EPOLL_STATE_READ_READY) & urh->app.celi)) { /* Unrecoverable error on socket was detected and all * pending data was read from system buffers. */ /* Stop trying to read from this TLS socket. */ urh->in_buffer_size = 0; } } /* * handle reading from application */ if ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->mhd.celi)) && (urh->out_buffer_used < urh->out_buffer_size) ) { ssize_t res; size_t buf_size; buf_size = urh->out_buffer_size - urh->out_buffer_used; if (buf_size > MHD_SCKT_SEND_MAX_SIZE_) buf_size = MHD_SCKT_SEND_MAX_SIZE_; res = MHD_recv_ (urh->mhd.socket, &urh->out_buffer[urh->out_buffer_used], buf_size); if (0 >= res) { const int err = MHD_socket_get_error_ (); if ((0 == res) || ((! MHD_SCKT_ERR_IS_EINTR_ (err)) && (! MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err)))) { urh->mhd.celi &= ~MHD_EPOLL_STATE_READ_READY; if ((0 == res) || (was_closed) || (0 != (MHD_EPOLL_STATE_ERROR & urh->mhd.celi)) || (! MHD_SCKT_ERR_IS_EAGAIN_ (err))) { /* Socket disconnect/shutdown was detected; * Application signaled about closure of 'upgraded' socket; * or persistent / unrecoverable error. */ /* Do not try to pull more data from application. */ urh->out_buffer_size = 0; } } } else /* 0 < res */ { urh->out_buffer_used += res; if (buf_size > (size_t) res) urh->mhd.celi &= ~MHD_EPOLL_STATE_READ_READY; } if ( (0 == (MHD_EPOLL_STATE_READ_READY & urh->mhd.celi)) && ( (0 != (MHD_EPOLL_STATE_ERROR & urh->mhd.celi)) || (was_closed) ) ) { /* Unrecoverable error on socket was detected and all * pending data was read from system buffers. */ /* Do not try to pull more data from application. */ urh->out_buffer_size = 0; } } /* * handle writing to remote HTTPS client */ if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->app.celi)) && (urh->out_buffer_used > 0) ) { ssize_t res; size_t data_size; data_size = urh->out_buffer_used; if (data_size > SSIZE_MAX) data_size = SSIZE_MAX; res = tls->send (tls->cls, connection->tls_cs, urh->out_buffer, data_size); if (0 >= res) { // FIXME: define GNUTLS-independent error codes! if (GNUTLS_E_INTERRUPTED != res) { urh->app.celi &= ~MHD_EPOLL_STATE_WRITE_READY; if (GNUTLS_E_INTERRUPTED != res) { /* TLS connection shut down or * persistent / unrecoverable error. */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_UPGRADE_FORWARD_INCOMPLETE, _ ( "Failed to forward to remote client " MHD_UNSIGNED_LONG_LONG_PRINTF \ " bytes of data received from application: %s\n"), (MHD_UNSIGNED_LONG_LONG) urh->out_buffer_used, tls->strerror (tls->cls, res)); #endif /* Discard any data unsent to remote. */ urh->out_buffer_used = 0; /* Do not try to pull more data from application. */ urh->out_buffer_size = 0; urh->mhd.celi &= ~MHD_EPOLL_STATE_READ_READY; } } } else /* 0 < res */ { const size_t next_out_buffer_used = urh->out_buffer_used - res; if (0 != next_out_buffer_used) { memmove (urh->out_buffer, &urh->out_buffer[res], next_out_buffer_used); if (data_size > (size_t) res) urh->app.celi &= ~MHD_EPOLL_STATE_WRITE_READY; } urh->out_buffer_used = next_out_buffer_used; } if ( (0 == urh->out_buffer_used) && (0 != (MHD_EPOLL_STATE_ERROR & urh->app.celi)) ) { /* Unrecoverable error on socket was detected and all * pending data was sent to remote. */ /* Do not try to send to remote anymore. */ urh->app.celi &= ~MHD_EPOLL_STATE_WRITE_READY; /* Do not try to pull more data from application. */ urh->out_buffer_size = 0; urh->mhd.celi &= ~MHD_EPOLL_STATE_READ_READY; } } /* * handle writing to application */ if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->mhd.celi)) && (urh->in_buffer_used > 0) ) { ssize_t res; size_t data_size; data_size = urh->in_buffer_used; if (data_size > MHD_SCKT_SEND_MAX_SIZE_) data_size = MHD_SCKT_SEND_MAX_SIZE_; res = MHD_send_ (urh->mhd.socket, urh->in_buffer, data_size); if (0 >= res) { const int err = MHD_socket_get_error_ (); if ( (! MHD_SCKT_ERR_IS_EINTR_ (err)) && (! MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err)) ) { urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY; if (! MHD_SCKT_ERR_IS_EAGAIN_ (err)) { /* Socketpair connection shut down or * persistent / unrecoverable error. */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, MHD_SC_UPGRADE_FORWARD_INCOMPLETE, _ ( "Failed to forward to application " MHD_UNSIGNED_LONG_LONG_PRINTF \ " bytes of data received from remote side: %s\n"), (MHD_UNSIGNED_LONG_LONG) urh->in_buffer_used, MHD_socket_strerr_ (err)); #endif /* Discard any data received form remote. */ urh->in_buffer_used = 0; /* Reading from remote client is not required anymore. */ urh->in_buffer_size = 0; urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; connection->tls_read_ready = false; } } } else /* 0 < res */ { const size_t next_in_buffer_used = urh->in_buffer_used - res; if (0 != next_in_buffer_used) { memmove (urh->in_buffer, &urh->in_buffer[res], next_in_buffer_used); if (data_size > (size_t) res) urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY; } urh->in_buffer_used = next_in_buffer_used; } if ( (0 == urh->in_buffer_used) && (0 != (MHD_EPOLL_STATE_ERROR & urh->mhd.celi)) ) { /* Do not try to push data to application. */ urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY; /* Reading from remote client is not required anymore. */ urh->in_buffer_size = 0; urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; connection->tls_read_ready = false; } } /* Check whether data is present in TLS buffers * and incoming forward buffer have some space. */ if ( (connection->tls_read_ready) && (urh->in_buffer_used < urh->in_buffer_size) && (MHD_TM_THREAD_PER_CONNECTION != daemon->threading_mode) ) daemon->data_already_pending = true; if ( (daemon->shutdown) && ( (0 != urh->out_buffer_size) || (0 != urh->out_buffer_used) ) ) { /* Daemon shutting down, discard any remaining forward data. */ #ifdef HAVE_MESSAGES if (0 < urh->out_buffer_used) MHD_DLOG (daemon, MHD_SC_UPGRADE_FORWARD_INCOMPLETE, _ ( "Failed to forward to remote client " MHD_UNSIGNED_LONG_LONG_PRINTF \ " bytes of data received from application: daemon shut down.\n"), (MHD_UNSIGNED_LONG_LONG) urh->out_buffer_used); #endif /* Discard any data unsent to remote. */ urh->out_buffer_used = 0; /* Do not try to sent to remote anymore. */ urh->app.celi &= ~MHD_EPOLL_STATE_WRITE_READY; /* Do not try to pull more data from application. */ urh->out_buffer_size = 0; urh->mhd.celi &= ~MHD_EPOLL_STATE_READ_READY; } } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /* end of upgrade_process.c */ libmicrohttpd-1.0.1/src/lib/response_from_buffer.c0000644000175000017500000000515414417460232015761 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/response_from_buffer.c * @brief implementation of MHD_response_from_buffer() * @author Christian Grothoff */ #include "internal.h" /** * Create a response object. The response object can be extended with * header information and then be used any number of times. * * @param sc status code to use for the response; * #MHD_HTTP_NO_CONTENT is only valid if @a size is 0; * @param size size of the data portion of the response * @param buffer size bytes containing the response's data portion * @param mode flags for buffer management * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ struct MHD_Response * MHD_response_from_buffer (enum MHD_HTTP_StatusCode sc, size_t size, void *buffer, enum MHD_ResponseMemoryMode mode) { struct MHD_Response *response; void *tmp; mhd_assert ( (NULL != buffer) || (0 == size) ); if (NULL == (response = MHD_calloc_ (1, sizeof (struct MHD_Response)))) return NULL; response->fd = -1; if (! MHD_mutex_init_ (&response->mutex)) { free (response); return NULL; } if ( (MHD_RESPMEM_MUST_COPY == mode) && (size > 0) ) { if (NULL == (tmp = malloc (size))) { MHD_mutex_destroy_chk_ (&response->mutex); free (response); return NULL; } memcpy (tmp, buffer, size); buffer = tmp; } if (MHD_RESPMEM_PERSISTENT != mode) { response->crfc = &free; response->crc_cls = buffer; } response->status_code = sc; response->reference_count = 1; response->total_size = size; response->data = buffer; response->data_size = size; return response; } /* end of response_from_buffer.c */ libmicrohttpd-1.0.1/src/lib/mhd_threads.h0000644000175000017500000002005114417460232014027 /* This file is part of libmicrohttpd Copyright (C) 2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_threads.h * @brief Header for platform-independent threads abstraction * @author Karlson2k (Evgeny Grin) * * Provides basic abstraction for threads. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid * variable modification in function parameters. * * @warning Unlike pthread functions, most of functions return * nonzero on success. */ #ifndef MHD_THREADS_H #define MHD_THREADS_H 1 #include "mhd_options.h" #ifdef HAVE_STDDEF_H # include /* for size_t */ #else /* ! HAVE_STDDEF_H */ # include /* for size_t */ #endif /* ! HAVE_STDDEF_H */ #if defined(MHD_USE_POSIX_THREADS) # undef HAVE_CONFIG_H # include # define HAVE_CONFIG_H 1 #elif defined(MHD_USE_W32_THREADS) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif /* !WIN32_LEAN_AND_MEAN */ # include #else # error No threading API is available. #endif #ifndef MHD_NO_THREAD_NAMES # if defined(MHD_USE_POSIX_THREADS) # if defined(HAVE_PTHREAD_SETNAME_NP_GNU) || \ defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || \ defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || \ defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) || \ defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || \ defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) # define MHD_USE_THREAD_NAME_ # endif /* HAVE_PTHREAD_SETNAME_NP */ # elif defined(MHD_USE_W32_THREADS) # ifdef _MSC_FULL_VER /* Thread names only available with VC compiler */ # define MHD_USE_THREAD_NAME_ # endif /* _MSC_FULL_VER */ # endif #endif #if defined(MHD_USE_POSIX_THREADS) typedef pthread_t MHD_thread_handle_; #elif defined(MHD_USE_W32_THREADS) typedef HANDLE MHD_thread_handle_; #endif #if defined(MHD_USE_POSIX_THREADS) # define MHD_THRD_RTRN_TYPE_ void* # define MHD_THRD_CALL_SPEC_ #elif defined(MHD_USE_W32_THREADS) # define MHD_THRD_RTRN_TYPE_ unsigned # define MHD_THRD_CALL_SPEC_ __stdcall #endif #if defined(MHD_USE_POSIX_THREADS) typedef pthread_t MHD_thread_ID_; #elif defined(MHD_USE_W32_THREADS) typedef DWORD MHD_thread_ID_; #endif /* Depending on implementation, pthread_create() MAY set thread ID into * provided pointer and after it start thread OR start thread and after * if set thread ID. In latter case, to avoid data races, additional * pthread_self() call is required in thread routine. Is some platform * is known for setting thread ID BEFORE starting thread macro * MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD could be defined * to save some resources. */ #if defined(MHD_USE_POSIX_THREADS) # ifdef MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD union _MHD_thread_handle_ID_ { MHD_thread_handle_ handle; /**< To be used in other threads */ MHD_thread_ID_ ID; /**< To be used in thread itself */ }; typedef union _MHD_thread_handle_ID_ MHD_thread_handle_ID_; # else /* ! MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD */ struct _MHD_thread_handle_ID_ { MHD_thread_handle_ handle; /**< To be used in other threads */ MHD_thread_ID_ ID; /**< To be used in thread itself */ }; typedef struct _MHD_thread_handle_ID_ MHD_thread_handle_ID_; # endif /* ! MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD */ #elif defined(MHD_USE_W32_THREADS) struct _MHD_thread_handle_ID_ { MHD_thread_handle_ handle; /**< To be used in other threads */ MHD_thread_ID_ ID; /**< To be used in thread itself */ }; typedef struct _MHD_thread_handle_ID_ MHD_thread_handle_ID_; #endif #if defined(MHD_USE_POSIX_THREADS) /** * Wait until specified thread is ended and free thread handle on success. * @param thread handle to watch * @return nonzero on success, zero otherwise */ #define MHD_join_thread_(thread) (! pthread_join ((thread), NULL)) #elif defined(MHD_USE_W32_THREADS) /** * Wait until specified thread is ended and free thread handle on success. * @param thread handle to watch * @return nonzero on success, zero otherwise */ #define MHD_join_thread_(thread) (WAIT_OBJECT_0 == WaitForSingleObject ( \ (thread), INFINITE) ? (CloseHandle ( \ (thread)), ! 0) : \ 0) #endif #if defined(MHD_USE_POSIX_THREADS) /** * Check whether provided thread ID match current thread. * @param ID thread ID to match * @return nonzero on match, zero otherwise */ #define MHD_thread_ID_match_current_(ID) (pthread_equal ((ID), pthread_self ())) #elif defined(MHD_USE_W32_THREADS) /** * Check whether provided thread ID match current thread. * @param ID thread ID to match * @return nonzero on match, zero otherwise */ #define MHD_thread_ID_match_current_(ID) (GetCurrentThreadId () == (ID)) #endif #if defined(MHD_USE_POSIX_THREADS) # ifdef MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD /** * Initialise thread ID. * @param thread_handle_ID_ptr pointer to thread handle-ID */ #define MHD_thread_init_(thread_handle_ID_ptr) (void) 0 # else /* ! MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD */ /** * Initialise thread ID. * @param thread_handle_ID_ptr pointer to thread handle-ID */ #define MHD_thread_init_(thread_handle_ID_ptr) ((thread_handle_ID_ptr)->ID = \ pthread_self ()) # endif /* ! MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD */ #elif defined(MHD_USE_W32_THREADS) /** * Initialise thread ID. * @param thread_handle_ID_ptr pointer to thread handle-ID */ #define MHD_thread_init_(thread_handle_ID_ptr) ((thread_handle_ID_ptr)->ID = \ GetCurrentThreadId ()) #endif /** * Signature of main function for a thread. * * @param cls closure argument for the function * @return termination code from the thread */ typedef MHD_THRD_RTRN_TYPE_ (MHD_THRD_CALL_SPEC_ *MHD_THREAD_START_ROUTINE_)(void *cls); /** * Create a thread and set the attributes according to our options. * * If thread is created, thread handle must be freed by MHD_join_thread_(). * * @param thread handle to initialize * @param stack_size size of stack for new thread, 0 for default * @param start_routine main function of thread * @param arg argument for start_routine * @return non-zero on success; zero otherwise */ int MHD_create_thread_ (MHD_thread_handle_ID_ *thread, size_t stack_size, MHD_THREAD_START_ROUTINE_ start_routine, void *arg); #ifndef MHD_USE_THREAD_NAME_ #define MHD_create_named_thread_(t,n,s,r,a) MHD_create_thread_ ((t),(s),(r),(a)) #else /* MHD_USE_THREAD_NAME_ */ /** * Create a named thread and set the attributes according to our options. * * @param thread handle to initialize * @param thread_name name for new thread * @param stack_size size of stack for new thread, 0 for default * @param start_routine main function of thread * @param arg argument for start_routine * @return non-zero on success; zero otherwise */ int MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread, const char *thread_name, size_t stack_size, MHD_THREAD_START_ROUTINE_ start_routine, void *arg); #endif /* MHD_USE_THREAD_NAME_ */ #endif /* ! MHD_THREADS_H */ libmicrohttpd-1.0.1/src/lib/daemon_epoll.h0000644000175000017500000000261314417460232014207 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_epoll.h * @brief non-public functions provided by daemon_epoll.c * @author Christian Grothoff */ #ifndef DAEMON_EPOLL_H #define DAEMON_EPOLL_H #ifdef EPOLL_SUPPORT /** * Do epoll()-based processing (this function is allowed to * block if @a may_block is set to #MHD_YES). * * @param daemon daemon to run poll loop for * @param may_block true if blocking, false if non-blocking * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_daemon_epoll_ (struct MHD_Daemon *daemon, bool may_block) MHD_NONNULL (1); #endif #endif libmicrohttpd-1.0.1/src/lib/mhd_mono_clock.h0000644000175000017500000000322214417460232014521 /* This file is part of libmicrohttpd Copyright (C) 2015 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_mono_clock.h * @brief internal monotonic clock functions declarations * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_MONO_CLOCK_H #define MHD_MONO_CLOCK_H 1 #include "mhd_options.h" #if defined(HAVE_TIME_H) #include #elif defined(HAVE_SYS_TYPES_H) #include #endif /** * Initialise monotonic seconds counter. */ void MHD_monotonic_sec_counter_init (void); /** * Deinitialise monotonic seconds counter by freeing any allocated resources */ void MHD_monotonic_sec_counter_finish (void); /** * Monotonic seconds counter, useful for timeout calculation. * Tries to be not affected by manually setting the system real time * clock or adjustments by NTP synchronization. * * @return number of seconds from some fixed moment */ time_t MHD_monotonic_sec_counter (void); #endif /* MHD_MONO_CLOCK_H */ libmicrohttpd-1.0.1/src/lib/connection_add.h0000644000175000017500000000265614417460232014527 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_add.h * @brief functions to add connection to our active set * @author Christian Grothoff */ #ifndef CONNECTION_ADD_H #define CONNECTION_ADD_H /** * Accept an incoming connection and create the MHD_Connection object * for it. This function also enforces policy by way of checking with * the accept policy callback. @remark To be called only from thread * that process daemon's select()/poll()/etc. * * @param daemon handle with the listen socket * @return #MHD_SC_OK on success */ enum MHD_StatusCode MHD_accept_connection_ (struct MHD_Daemon *daemon) MHD_NONNULL (1); #endif libmicrohttpd-1.0.1/src/lib/response.c0000644000175000017500000001552614417460232013411 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/response.c * @brief implementation of general response functions * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "internal.h" /** * Add a header or footer line to the response. * * @param response response to add a header to * @param kind header or footer * @param header the header to add * @param content value to add * @return false on error (i.e. invalid header or content format). */ static bool add_response_entry (struct MHD_Response *response, enum MHD_ValueKind kind, const char *header, const char *content) { struct MHD_HTTP_Header *hdr; if ( (NULL == header) || (NULL == content) || (0 == header[0]) || (0 == content[0]) || (NULL != strchr (header, '\t')) || (NULL != strchr (header, '\r')) || (NULL != strchr (header, '\n')) || (NULL != strchr (content, '\t')) || (NULL != strchr (content, '\r')) || (NULL != strchr (content, '\n')) ) return false; if (NULL == (hdr = malloc (sizeof (struct MHD_HTTP_Header)))) return false; if (NULL == (hdr->header = strdup (header))) { free (hdr); return false; } if (NULL == (hdr->value = strdup (content))) { free (hdr->header); free (hdr); return false; } hdr->kind = kind; hdr->next = response->first_header; response->first_header = hdr; return true; } /** * Explicitly decrease reference counter of a response object. If the * counter hits zero, destroys a response object and associated * resources. Usually, this is implicitly done by converting a * response to an action and returning the action to MHD. * * @param response response to decrement RC of * @ingroup response */ void MHD_response_queue_for_destroy (struct MHD_Response *response) { struct MHD_HTTP_Header *pos; MHD_mutex_lock_chk_ (&response->mutex); if (0 != --(response->reference_count)) { MHD_mutex_unlock_chk_ (&response->mutex); return; } MHD_mutex_unlock_chk_ (&response->mutex); MHD_mutex_destroy_chk_ (&response->mutex); if (NULL != response->crfc) response->crfc (response->crc_cls); while (NULL != response->first_header) { pos = response->first_header; response->first_header = pos->next; free (pos->header); free (pos->value); free (pos); } free (response); } /** * Add a header line to the response. * * @param response response to add a header to * @param header the header to add * @param content value to add * @return #MHD_NO on error (i.e. invalid header or content format), * or out of memory * @ingroup response */ enum MHD_Bool MHD_response_add_header (struct MHD_Response *response, const char *header, const char *content) { return add_response_entry (response, MHD_HEADER_KIND, header, content) ? MHD_YES : MHD_NO; } /** * Add a tailer line to the response. * * @param response response to add a footer to * @param footer the footer to add * @param content value to add * @return #MHD_NO on error (i.e. invalid footer or content format), * or out of memory * @ingroup response */ enum MHD_Bool MHD_response_add_trailer (struct MHD_Response *response, const char *footer, const char *content) { return add_response_entry (response, MHD_FOOTER_KIND, footer, content) ? MHD_YES : MHD_NO; } /** * Delete a header (or footer) line from the response. * * @param response response to remove a header from * @param header the header to delete * @param content value to delete * @return #MHD_NO on error (no such header known) * @ingroup response */ enum MHD_Bool MHD_response_del_header (struct MHD_Response *response, const char *header, const char *content) { struct MHD_HTTP_Header *pos; struct MHD_HTTP_Header *prev; prev = NULL; pos = response->first_header; while (NULL != pos) { if ((0 == strcmp (header, pos->header)) && (0 == strcmp (content, pos->value))) { free (pos->header); free (pos->value); if (NULL == prev) response->first_header = pos->next; else prev->next = pos->next; free (pos); return MHD_YES; } prev = pos; pos = pos->next; } return MHD_NO; } /** * Get all of the headers (and footers) added to a response. * * @param response response to query * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator * @return number of entries iterated over * @ingroup response */ unsigned int MHD_response_get_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls) { unsigned int numHeaders = 0; struct MHD_HTTP_Header *pos; for (pos = response->first_header; NULL != pos; pos = pos->next) { numHeaders++; if ( (NULL != iterator) && (MHD_YES != iterator (iterator_cls, pos->kind, pos->header, pos->value)) ) break; } return numHeaders; } /** * Get a particular header (or footer) from the response. * * @param response response to query * @param key which header to get * @return NULL if header does not exist * @ingroup response */ const char * MHD_response_get_header (struct MHD_Response *response, const char *key) { struct MHD_HTTP_Header *pos; for (pos = response->first_header; NULL != pos; pos = pos->next) { if (MHD_str_equal_caseless_ (pos->header, key)) return pos->value; } return NULL; } /* end of response.c */ libmicrohttpd-1.0.1/src/lib/upgrade_process.h0000644000175000017500000000266114417460232014741 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/upgrade_process.h * @brief function to process upgrade activity (over TLS) * @author Christian Grothoff */ #ifndef UPGRADE_PROCESS_H #define UPGRADE_PROCESS_H #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Performs bi-directional forwarding on upgraded HTTPS connections * based on the readiness state stored in the @a urh handle. * @remark To be called only from thread that process * connection's recv(), send() and response. * * @param urh handle to process */ void MHD_upgrade_response_handle_process_ (struct MHD_UpgradeResponseHandle *urh) MHD_NONNULL (1); #endif #endif libmicrohttpd-1.0.1/src/lib/init.h0000644000175000017500000000257214417460232012520 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/init.h * @brief functions to initialize library * @author Christian Grothoff */ #ifndef INIT_H #define INIT_H #include "internal.h" #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED /** * Do nothing - global initialisation is * performed by library constructor. */ #define MHD_check_global_init_() (void) 0 #else /* ! _AUTOINIT_FUNCS_ARE_SUPPORTED */ /** * Check whether global initialisation was performed * and call initialiser if necessary. */ void MHD_check_global_init_ (void); #endif /* ! _AUTOINIT_FUNCS_ARE_SUPPORTED */ #endif /* INIT_H */ libmicrohttpd-1.0.1/src/lib/connection_options.c0000644000175000017500000000773314417460232015466 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/connection_options.c * @brief functions to set per-connection options * @author Christian Grothoff */ #include "internal.h" /** * Set custom timeout for the given connection. Specified as the * number of seconds. Use zero for no timeout. Calling this function * will reset timeout timer. * * @param connection connection to configure timeout for * @param timeout_s new timeout in seconds */ void MHD_connection_set_timeout (struct MHD_Connection *connection, unsigned int timeout_s) { struct MHD_Daemon *daemon = connection->daemon; connection->last_activity = MHD_monotonic_sec_counter (); if (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) { /* Simple case, no need to lock to update DLLs */ connection->connection_timeout = (time_t) timeout_s; return; } MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); if (! connection->suspended) { if (connection->connection_timeout == daemon->connection_default_timeout) XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); else XDLL_remove (daemon->manual_timeout_head, daemon->manual_timeout_tail, connection); } connection->connection_timeout = (time_t) timeout_s; if (! connection->suspended) { if (connection->connection_timeout == daemon->connection_default_timeout) XDLL_insert (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); else XDLL_insert (daemon->manual_timeout_head, daemon->manual_timeout_tail, connection); } MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } /** * Update the 'last_activity' field of the connection to the current * time and move the connection to the head of the 'normal_timeout' * list if the timeout for the connection uses the default value. * * @param connection the connection that saw some activity */ void MHD_update_last_activity_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; if (0 == connection->connection_timeout) return; /* Skip update of activity for connections without timeout timer. */ if (connection->suspended) return; /* no activity on suspended connections */ connection->last_activity = MHD_monotonic_sec_counter (); if (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_mode) return; /* each connection has personal timeout */ if (connection->connection_timeout != daemon->connection_default_timeout) return; /* custom timeout, no need to move it in "normal" DLL */ MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); /* move connection to head of timeout list (by remove + add operation) */ XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); XDLL_insert (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } /* end of connection_options.c */ libmicrohttpd-1.0.1/src/lib/action_process_upload.c0000644000175000017500000000437214417460232016127 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/action_process_upload.c * @brief implementation of MHD_action_process_upload() * @author Christian Grothoff */ #include "internal.h" /** * Internal details about an upload action. */ struct UploadAction { /** * An upload action is an action. This field * must come first! */ struct MHD_Action action; MHD_UploadCallback uc; void *uc_cls; }; /** * The application wants to process uploaded data for * the given request. Do it! * * @param cls the `struct UploadAction` with the * function we are to call for upload data * @param request the request for which we are to process * upload data * @return #MHD_SC_OK on success */ static enum MHD_StatusCode upload_action (void *cls, struct MHD_Request *request) { struct UploadAction *ua = cls; (void) ua; // FIXME: implement! return -1; } /** * Create an action that handles an upload. * * @param uc function to call with uploaded data * @param uc_cls closure for @a uc * @return NULL on error (out of memory) * @ingroup action */ const struct MHD_Action * MHD_action_process_upload (MHD_UploadCallback uc, void *uc_cls) { struct UploadAction *ua; if (NULL == (ua = malloc (sizeof (struct UploadAction)))) return NULL; ua->action.action = &upload_action; ua->action.action_cls = ua; ua->uc = uc; ua->uc_cls = uc_cls; return &ua->action; } /* end of action_process_upload.c */ libmicrohttpd-1.0.1/src/lib/daemon_destroy.c0000644000175000017500000001337014417460232014562 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file lib/daemon_destroy.c * @brief main functions to destroy a daemon * @author Christian Grothoff */ #include "internal.h" #include "request_resume.h" #include "daemon_close_all_connections.h" /** * Stop all worker threads from the worker pool. * * @param daemon master daemon controlling the workers */ static void stop_workers (struct MHD_Daemon *daemon) { MHD_socket fd; unsigned int i; mhd_assert (1 < daemon->worker_pool_size); mhd_assert (1 < daemon->threading_mode); if (daemon->was_quiesced) fd = MHD_INVALID_SOCKET; /* Do not use FD if daemon was quiesced */ else fd = daemon->listen_socket; /* Let workers shutdown in parallel. */ for (i = 0; i < daemon->worker_pool_size; i++) { daemon->worker_pool[i].shutdown = true; if (MHD_ITC_IS_VALID_ (daemon->worker_pool[i].itc)) { if (! MHD_itc_activate_ (daemon->worker_pool[i].itc, "e")) MHD_PANIC (_ ( "Failed to signal shutdown via inter-thread communication channel.\n")); } else { /* Better hope shutdown() works... */ mhd_assert (MHD_INVALID_SOCKET != fd); } } #ifdef HAVE_LISTEN_SHUTDOWN if (MHD_INVALID_SOCKET != fd) { (void) shutdown (fd, SHUT_RDWR); } #endif /* HAVE_LISTEN_SHUTDOWN */ for (i = 0; i < daemon->worker_pool_size; ++i) { MHD_daemon_destroy (&daemon->worker_pool[i]); } free (daemon->worker_pool); daemon->worker_pool = NULL; /* FIXME: does this still hold? */ mhd_assert (MHD_ITC_IS_INVALID_ (daemon->itc)); #ifdef EPOLL_SUPPORT mhd_assert (-1 == daemon->epoll_fd); #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) mhd_assert (-1 == daemon->epoll_upgrade_fd); #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ #endif /* EPOLL_SUPPORT */ } /** * Shutdown and destroy an HTTP daemon. * * @param daemon daemon to stop * @ingroup event */ void MHD_daemon_destroy (struct MHD_Daemon *daemon) { MHD_socket fd; daemon->shutdown = true; if (daemon->was_quiesced) fd = MHD_INVALID_SOCKET; /* Do not use FD if daemon was quiesced */ else fd = daemon->listen_socket; /* FIXME: convert from here to microhttpd2-style API! */ if (NULL != daemon->worker_pool) { /* Master daemon with worker pool. */ stop_workers (daemon); } else { mhd_assert (0 == daemon->worker_pool_size); /* Worker daemon or single-thread daemon. */ if (MHD_TM_EXTERNAL_EVENT_LOOP != daemon->threading_mode) { /* Worker daemon or single daemon with internal thread(s). */ /* Separate thread(s) is used for polling sockets. */ if (MHD_ITC_IS_VALID_ (daemon->itc)) { if (! MHD_itc_activate_ (daemon->itc, "e")) MHD_PANIC (_ ( "Failed to signal shutdown via inter-thread communication channel.\n")); } else { #ifdef HAVE_LISTEN_SHUTDOWN if (MHD_INVALID_SOCKET != fd) { if (NULL == daemon->master) (void) shutdown (fd, SHUT_RDWR); } else #endif /* HAVE_LISTEN_SHUTDOWN */ mhd_assert (false); /* Should never happen */ } if (! MHD_join_thread_ (daemon->pid.handle)) { MHD_PANIC (_ ("Failed to join a thread.\n")); } /* close_all_connections() was called in daemon thread. */ } else { /* No internal threads are used for polling sockets (external event loop) */ MHD_daemon_close_all_connections_ (daemon); } if (MHD_ITC_IS_VALID_ (daemon->itc)) MHD_itc_destroy_chk_ (daemon->itc); #ifdef EPOLL_SUPPORT if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && (-1 != daemon->epoll_fd) ) MHD_socket_close_chk_ (daemon->epoll_fd); #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if ( (MHD_ELS_EPOLL == daemon->event_loop_syscall) && (-1 != daemon->epoll_upgrade_fd) ) MHD_socket_close_chk_ (daemon->epoll_upgrade_fd); #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ #endif /* EPOLL_SUPPORT */ MHD_mutex_destroy_chk_ (&daemon->cleanup_connection_mutex); } if (NULL != daemon->master) return; /* Cleanup that should be done only one time in master/single daemon. * Do not perform this cleanup in worker daemons. */ if (MHD_INVALID_SOCKET != fd) MHD_socket_close_chk_ (fd); /* TLS clean up */ #ifdef HTTPS_SUPPORT if (NULL != daemon->tls_api) { #if FIXME_TLS_API if (daemon->have_dhparams) { gnutls_dh_params_deinit (daemon->https_mem_dhparams); daemon->have_dhparams = false; } gnutls_priority_deinit (daemon->priority_cache); if (daemon->x509_cred) gnutls_certificate_free_credentials (daemon->x509_cred); #endif } #endif /* HTTPS_SUPPORT */ #ifdef DAUTH_SUPPORT free (daemon->nnc); MHD_mutex_destroy_chk_ (&daemon->nnc_lock); #endif MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex); free (daemon); } /* end of daemon_destroy.c */ libmicrohttpd-1.0.1/src/lib/request.c0000644000175000017500000001161014417460232013231 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file requests.c * @brief Methods for managing HTTP requests * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "internal.h" /** * Get all of the headers from the request. * * @param request request to get values from * @param kind types of values to iterate over, can be a bitmask * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator * @return number of entries iterated over * @ingroup request */ unsigned int MHD_request_get_values (struct MHD_Request *request, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) { int ret; struct MHD_HTTP_Header *pos; ret = 0; for (pos = request->headers_received; NULL != pos; pos = pos->next) { if (0 != (pos->kind & kind)) { ret++; if ( (NULL != iterator) && (MHD_YES != iterator (iterator_cls, pos->kind, pos->header, pos->value)) ) return ret; } } return ret; } /** * This function can be used to add an entry to the HTTP headers of a * request (so that the #MHD_request_get_values function will * return them -- and the `struct MHD_PostProcessor` will also see * them). This maybe required in certain situations (see Mantis * #1399) where (broken) HTTP implementations fail to supply values * needed by the post processor (or other parts of the application). * * This function MUST only be called from within the * request callbacks (otherwise, access maybe improperly * synchronized). Furthermore, the client must guarantee that the key * and value arguments are 0-terminated strings that are NOT freed * until the connection is closed. (The easiest way to do this is by * passing only arguments to permanently allocated strings.). * * @param request the request for which a * value should be set * @param kind kind of the value * @param key key for the value * @param value the value itself * @return #MHD_NO if the operation could not be * performed due to insufficient memory; * #MHD_YES on success * @ingroup request */ enum MHD_Bool MHD_request_set_value (struct MHD_Request *request, enum MHD_ValueKind kind, const char *key, const char *value) { struct MHD_HTTP_Header *pos; pos = MHD_pool_allocate (request->connection->pool, sizeof (struct MHD_HTTP_Header), MHD_YES); if (NULL == pos) return MHD_NO; pos->header = (char *) key; pos->value = (char *) value; pos->kind = kind; pos->next = NULL; /* append 'pos' to the linked list of headers */ if (NULL == request->headers_received_tail) { request->headers_received = pos; request->headers_received_tail = pos; } else { request->headers_received_tail->next = pos; request->headers_received_tail = pos; } return MHD_YES; } /** * Get a particular header value. If multiple * values match the kind, return any one of them. * * @param request request to get values from * @param kind what kind of value are we looking for * @param key the header to look for, NULL to lookup 'trailing' value without a key * @return NULL if no such item was found * @ingroup request */ const char * MHD_request_lookup_value (struct MHD_Request *request, enum MHD_ValueKind kind, const char *key) { struct MHD_HTTP_Header *pos; for (pos = request->headers_received; NULL != pos; pos = pos->next) { if ((0 != (pos->kind & kind)) && ( (key == pos->header) || ( (NULL != pos->header) && (NULL != key) && (MHD_str_equal_caseless_ (key, pos->header))))) return pos->value; } return NULL; } /* end of request.c */ libmicrohttpd-1.0.1/src/lib/mhd_compat.c0000644000175000017500000000545514417460232013666 /* This file is part of libmicrohttpd Copyright (C) 2014-2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_compat.c * @brief Implementation of platform missing functions. * @author Karlson2k (Evgeny Grin) */ #include "mhd_compat.h" #if defined(_WIN32) && ! defined(__CYGWIN__) #include #include #ifndef HAVE_SNPRINTF #include #include #endif /* HAVE_SNPRINTF */ #endif /* _WIN32 && !__CYGWIN__ */ #ifndef HAVE_CALLOC #include /* for memset() */ #endif /* ! HAVE_CALLOC */ #if defined(_WIN32) && ! defined(__CYGWIN__) #ifndef HAVE_SNPRINTF /* Emulate snprintf function on W32 */ int W32_snprintf (char *__restrict s, size_t n, const char *__restrict format, ...) { int ret; va_list args; if ( (0 != n) && (NULL != s) ) { va_start (args, format); ret = _vsnprintf (s, n, format, args); va_end (args); if ((int) n == ret) s[n - 1] = 0; if (ret >= 0) return ret; } va_start (args, format); ret = _vscprintf (format, args); va_end (args); if ( (0 <= ret) && (0 != n) && (NULL == s) ) return -1; return ret; } #endif /* HAVE_SNPRINTF */ #endif /* _WIN32 && !__CYGWIN__ */ #ifndef HAVE_CALLOC #ifdef __has_builtin # if __has_builtin (__builtin_mul_overflow) # define MHD_HAVE_NUL_OVERFLOW 1 # endif #elif __GNUC__ + 0 >= 5 # define MHD_HAVE_NUL_OVERFLOW 1 #endif /* __GNUC__ >= 5 */ void * MHD_calloc_ (size_t nelem, size_t elsize) { size_t alloc_size; void *ptr; #ifdef MHD_HAVE_NUL_OVERFLOW if (__builtin_mul_overflow (nelem, elsize, &alloc_size) || (0 == alloc_size)) return NULL; #else /* ! MHD_HAVE_NUL_OVERFLOW */ alloc_size = nelem * elsize; if ((0 == alloc_size) || (elsize != alloc_size / nelem)) return NULL; #endif /* ! MHD_HAVE_NUL_OVERFLOW */ ptr = malloc (alloc_size); if (NULL == ptr) return NULL; memset (ptr, 0, alloc_size); return ptr; } #endif /* ! HAVE_CALLOC */ libmicrohttpd-1.0.1/src/testcurl/0000755000175000017500000000000014566140216012557 5libmicrohttpd-1.0.1/src/testcurl/test_get_response_cleanup.c0000644000175000017500000002576314522742656020133 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file daemontest_get_response_cleanup.c * @brief Testcase for libmicrohttpd response cleanup * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include #include #include #ifndef _WIN32 #include #endif /* _WIN32 */ #ifndef WINDOWS #include #include #endif #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #include "mhd_has_in_name.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif static int oneone; static int ok; static pid_t fork_curl (const char *url) { pid_t ret; ret = fork (); if (ret != 0) return ret; execlp ("curl", "curl", "-s", "-N", "-o", "/dev/null", "-GET", url, NULL); fprintf (stderr, "Failed to exec curl: %s\n", strerror (errno)); _exit (-1); } static void kill_curl (pid_t pid) { int status; /* fprintf (stderr, "Killing curl\n"); */ kill (pid, SIGTERM); waitpid (pid, &status, 0); } static ssize_t push_callback (void *cls, uint64_t pos, char *buf, size_t max) { (void) cls; (void) pos; /* Unused. Silent compiler warning. */ if (max == 0) return 0; buf[0] = 'd'; return 1; } static void push_free_callback (void *cls) { int *ok_p = cls; /* fprintf (stderr, "Cleanup callback called!\n"); */ *ok_p = 0; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 32 * 1024, &push_callback, &ok, &push_free_callback); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) abort (); return ret; } static unsigned int testInternalGet (void) { struct MHD_Daemon *d; pid_t curl; uint16_t port; char url[127]; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1180; if (oneone) port += 10; } ok = 1; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (url, sizeof (url), "http://127.0.0.1:%u/", (unsigned int) port); curl = fork_curl (url); (void) sleep (1); kill_curl (curl); (void) sleep (1); /* fprintf (stderr, "Stopping daemon!\n"); */ MHD_stop_daemon (d); if (ok != 0) return 2; return 0; } static unsigned int testMultithreadedGet (void) { struct MHD_Daemon *d; pid_t curl; uint16_t port; char url[127]; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1181; if (oneone) port += 10; } ok = 1; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 2, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (url, sizeof (url), "http://127.0.0.1:%u/", (unsigned int) port); /* fprintf (stderr, "Forking cURL!\n"); */ curl = fork_curl (url); (void) sleep (1); kill_curl (curl); (void) sleep (1); curl = fork_curl (url); (void) sleep (1); if (ok != 0) { kill_curl (curl); MHD_stop_daemon (d); return 64; } kill_curl (curl); (void) sleep (1); /* fprintf (stderr, "Stopping daemon!\n"); */ MHD_stop_daemon (d); if (ok != 0) return 32; return 0; } static unsigned int testMultithreadedPoolGet (void) { struct MHD_Daemon *d; pid_t curl; uint16_t port; char url[127]; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1182; if (oneone) port += 10; } ok = 1; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 64; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (url, sizeof (url), "http://127.0.0.1:%u/", (unsigned int) port); curl = fork_curl (url); (void) sleep (1); kill_curl (curl); (void) sleep (1); /* fprintf (stderr, "Stopping daemon!\n"); */ MHD_stop_daemon (d); if (ok != 0) return 128; return 0; } static unsigned int testExternalGet (void) { struct MHD_Daemon *d; fd_set rs; fd_set ws; fd_set es; MHD_socket max; time_t start; struct timeval tv; pid_t curl; uint16_t port; char url[127]; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1183; if (oneone) port += 10; } ok = 1; d = MHD_start_daemon (MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (url, sizeof (url), "http://127.0.0.1:%u/", (unsigned int) port); curl = fork_curl (url); start = time (NULL); while ((time (NULL) - start < 2)) { max = 0; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) { MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (max + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } MHD_run (d); } kill_curl (curl); start = time (NULL); while ((time (NULL) - start < 2)) { max = 0; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) { MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (max + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } MHD_run (d); } /* fprintf (stderr, "Stopping daemon!\n"); */ MHD_stop_daemon (d); if (ok != 0) return 1024; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ #ifndef _WIN32 /* Solaris has no way to disable SIGPIPE on socket disconnect. */ if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTOSUPPRESS_SIGPIPE)) { struct sigaction act; act.sa_handler = SIG_IGN; sigaction (SIGPIPE, &act, NULL); } #endif /* _WIN32 */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalGet (); errorCount += testMultithreadedGet (); errorCount += testMultithreadedPoolGet (); } errorCount += testExternalGet (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_urlparse.c0000644000175000017500000001363514441373361015550 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009, 2011 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file daemontest_urlparse.c * @brief Testcase for libmicrohttpd url parsing * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include "mhd_has_in_name.h" #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #ifndef WINDOWS #include #include #endif static int oneone; static int matches; struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result test_values (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) { (void) cls; (void) kind; /* Unused. Silent compiler warning. */ if ( (0 == strcmp (key, "a")) && (0 == strcmp (value, "b")) ) matches += 1; if ( (0 == strcmp (key, "c")) && (0 == strcmp (value, "")) ) matches += 2; if ( (0 == strcmp (key, "d")) && (NULL == value) ) matches += 4; return MHD_YES; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } MHD_get_connection_values (connection, MHD_GET_ARGUMENT_KIND, &test_values, NULL); *req_cls = NULL; response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) abort (); return ret; } static unsigned int testInternalGet (uint32_t poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1510; if (oneone) port += 5; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world?a=b&c=&d"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; if (matches != 7) return 16; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; errorCount += testInternalGet (0); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_iplimit.c0000644000175000017500000002220714441373361015355 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_iplimit.c * @brief Testcase for libmicrohttpd limits per IP * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include "mhd_has_in_name.h" #ifndef WINDOWS #include #endif #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif static int oneone; struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) abort (); return ret; } static unsigned int testMultithreadedGet (void) { struct MHD_Daemon *d; char buf[2048]; int k; unsigned int success; unsigned int failure; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1260; if (oneone) port += 5; } /* Test only valid for HTTP/1.1 (uses persistent connections) */ if (! oneone) return 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 2, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } for (k = 0; k < 3; ++k) { struct CBC cbc[3]; CURL *cenv[3]; int i; success = 0; failure = 0; for (i = 0; i < 3; ++i) { CURL *c; CURLcode errornum; cenv[i] = c = curl_easy_init (); cbc[i].buf = buf; cbc[i].size = 2048; cbc[i].pos = 0; curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc[i]); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_FORBID_REUSE, 0L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); errornum = curl_easy_perform (c); if (CURLE_OK == errornum) success++; else failure++; } /* Cleanup the environments */ for (i = 0; i < 3; ++i) curl_easy_cleanup (cenv[i]); if ( (2 != success) || (1 != failure) ) { fprintf (stderr, "Unexpected number of success (%u) or failure (%u)\n", success, failure); MHD_stop_daemon (d); return 32; } (void) sleep (2); for (i = 0; i < 2; ++i) { if (cbc[i].pos != strlen ("/hello_world")) { MHD_stop_daemon (d); return 64; } if (0 != strncmp ("/hello_world", cbc[i].buf, strlen ("/hello_world"))) { MHD_stop_daemon (d); return 128; } } } MHD_stop_daemon (d); return 0; } static unsigned int testMultithreadedPoolGet (void) { struct MHD_Daemon *d; char buf[2048]; int k; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1261; if (oneone) port += 5; } /* Test only valid for HTTP/1.1 (uses persistent connections) */ if (! oneone) return 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 2, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } for (k = 0; k < 3; ++k) { struct CBC cbc[3]; CURL *cenv[3]; int i; for (i = 0; i < 3; ++i) { CURL *c; CURLcode errornum; cenv[i] = c = curl_easy_init (); cbc[i].buf = buf; cbc[i].size = 2048; cbc[i].pos = 0; curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc[i]); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_FORBID_REUSE, 0L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); errornum = curl_easy_perform (c); if ( ( (CURLE_OK != errornum) && (i < 2) ) || ( (CURLE_OK == errornum) && (i == 2) ) ) { int j; /* First 2 should succeed */ if (i < 2) fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); /* Last request should have failed */ else fprintf (stderr, "No error on IP address over limit\n"); for (j = 0; j < i; ++j) curl_easy_cleanup (cenv[j]); MHD_stop_daemon (d); return 32; } } /* Cleanup the environments */ for (i = 0; i < 3; ++i) curl_easy_cleanup (cenv[i]); (void) sleep (2); for (i = 0; i < 2; ++i) { if (cbc[i].pos != strlen ("/hello_world")) { MHD_stop_daemon (d); return 64; } if (0 != strncmp ("/hello_world", cbc[i].buf, strlen ("/hello_world"))) { MHD_stop_daemon (d); return 128; } } } MHD_stop_daemon (d); return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; errorCount |= testMultithreadedGet (); errorCount |= testMultithreadedPoolGet (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_toolarge.c0000644000175000017500000016011114530120375015511 /* This file is part of libmicrohttpd Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) Copyright (C) 2007, 2009, 2011 Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_toolarge.c * @brief Testcase for handling of data larger then buffers. * @details Testcases for handling of various situations when data cannot fit * the buffers. Address sanitizers and debug asserts should increase * number of problems detected by this test (detect actual overrun). * Tests start with valid sizes to ensure that normal data is processed * correctly and then sizes are monotonically increased to ensure that * overflow is handled correctly at all stages in all codepaths. * Tests with valid sizes are repeated several times to ensure that * tests are failed because of overflow, but because of second run. * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #include "mhd_has_param.h" #include "mhd_sockets.h" /* only macros used */ #ifdef HAVE_STRINGS_H #include #endif /* HAVE_STRINGS_H */ #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #ifndef WINDOWS #include #include #endif #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #if MHD_CPU_COUNT > 32 #undef MHD_CPU_COUNT /* Limit to reasonable value */ #define MHD_CPU_COUNT 32 #endif /* MHD_CPU_COUNT > 32 */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func(NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error details: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); fflush (stderr); exit (8); } /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 #define EXPECTED_URI_BASE_PATH "/a" #define URL_SCHEME_HOST "http:/" "/127.0.0.1" #define N1_HEADER_NAME "n" #define N1_HEADER_VALUE "1" #define N1_HEADER N1_HEADER_NAME ": " N1_HEADER_VALUE #define N1_HEADER_CRLF N1_HEADER "\r\n" #define BUFFER_SIZE 1024 /* The size of the test element that must pass the test */ #ifndef MHD_ASAN_POISON_ACTIVE #define TEST_OK_SIZE (BUFFER_SIZE - 384) #else /* MHD_ASAN_POISON_ACTIVE */ #define TEST_OK_SIZE (BUFFER_SIZE - 384 - 80) #endif /* MHD_ASAN_POISON_ACTIVE */ /* The size of the test element where tests are started */ #define TEST_START_SIZE (TEST_OK_SIZE - 16) /* The size of the test element that must definitely fail */ #define TEST_FAIL_SIZE (BUFFER_SIZE + 32) /* Special value for request many headers test. * MHD uses the same buffer to store headers strings and pointers to the strings * so allocation is multiplied for small request header. */ /* The size of the test element that must pass the test */ #define TEST_RQ_N1_OK_SIZE 50 /* The size of the test element where tests are started */ #define TEST_RQ_N1_START_SIZE (TEST_RQ_N1_OK_SIZE - 32) /* Global parameters */ static int verbose; /**< Be verbose */ static int oneone; /**< If false use HTTP/1.0 for requests*/ static uint16_t global_port; /**< MHD daemons listen port number */ static int large_req_method; /**< Large request method */ static int large_req_url; /**< Large request URL */ static int large_req_header_name; /**< Large request single header name */ static int large_req_header_value; /**< Large request single header value */ static int large_req_headers; /**< Large request headers */ static int large_rsp_header_name; /**< Large response single header name */ static int large_rsp_header_value; /**< Large response single header value */ static int large_rsp_headers; /**< Large response headers */ static int response_timeout_val = TIMEOUTS_VAL; /* Current test parameters */ /* * Moved to local variables * */ /* Static helper variables */ /* * None for this test * */ static void test_global_init (void) { libcurl_errbuf[0] = 0; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) externalErrorExit (); } static void test_global_cleanup (void) { curl_global_cleanup (); } struct headers_check_result { unsigned int num_n1_headers; size_t large_header_name_size; size_t large_header_value_size; int large_header_valid; }; static size_t lcurl_hdr_callback (char *buffer, size_t size, size_t nitems, void *userdata) { const size_t data_size = size * nitems; struct headers_check_result *check_res = (struct headers_check_result *) userdata; if ((6 == data_size) && (0 == memcmp (N1_HEADER_CRLF, buffer, 6))) check_res->num_n1_headers++; else if ((5 <= data_size) && ('0' == buffer[0])) { const char *const col_ptr = memchr (buffer, ':', data_size); if (0 != check_res->large_header_value_size) mhdErrorExitDesc ("Expected only one large header, " \ "but found two large headers in the reply"); if (NULL == col_ptr) check_res->large_header_valid = 0; else if ((size_t) (col_ptr - buffer) >= data_size - 2) check_res->large_header_valid = 0; else if (*(col_ptr + 1) != ' ') check_res->large_header_valid = 0; else { const char *const name = buffer; const size_t name_len = (size_t) (col_ptr - buffer); const size_t val_pos = name_len + 2; const size_t val_len = data_size - val_pos - 2; /* 2 = strlen("\r\n") */ const char *const value = buffer + val_pos; size_t i; check_res->large_header_name_size = name_len; check_res->large_header_value_size = val_len; check_res->large_header_valid = 1; /* To be reset if any problem found */ for (i = 1; i < name_len; i++) if ('a' + (char) (i % ('z' - 'a' + 1)) != name[i]) { fprintf (stderr, "Wrong sequence in reply header name " \ "at position %u. Expected '%c', got '%c'\n", (unsigned int) i, 'a' + (char) (i % ('z' - 'a' + 1)), name[i]); check_res->large_header_valid = 0; break; } for (i = 0; i < val_len; i++) if ('Z' - (char) (i % ('Z' - 'A' + 1)) != value[i]) { fprintf (stderr, "Wrong sequence in reply header value " \ "at position %u. Expected '%c', got '%c'\n", (unsigned int) i, 'Z' - (char) (i % ('Z' - 'A' + 1)), value[i]); check_res->large_header_valid = 0; break; } } } return data_size; } struct lcurl_data_cb_param { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct lcurl_data_cb_param *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) externalErrorExit (); /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } struct check_uri_cls { const char *volatile uri; }; static void * check_uri_cb (void *cls, const char *uri, struct MHD_Connection *con) { struct check_uri_cls *param = (struct check_uri_cls *) cls; (void) con; if (0 != strcmp (param->uri, uri)) { fprintf (stderr, "Wrong URI: `%s', line: %d\n", uri, __LINE__); exit (22); } return NULL; } struct mhd_header_checker_param { unsigned int num_n1_headers; size_t large_header_name_size; size_t large_header_value_size; int large_header_valid; }; static enum MHD_Result headerCheckerInterator (void *cls, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size) { struct mhd_header_checker_param *const param = (struct mhd_header_checker_param *) cls; if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); if (MHD_HEADER_KIND != kind) return MHD_YES; /* Continue iteration */ if (0 == key_size) mhdErrorExitDesc ("Zero key length"); if ((1 == key_size) && (1 == value_size) && ('n' == key[0]) && ('1' == value[0])) param->num_n1_headers++; else if ('0' == key[0]) { /* Found 'large' header */ size_t i; param->large_header_name_size = key_size; param->large_header_value_size = value_size; param->large_header_valid = 1; for (i = 1; i < key_size; i++) if ('a' + (char) (i % ('z' - 'a' + 1)) != key[i]) { fprintf (stderr, "Wrong sequence in request header name " \ "at position %u. Expected '%c', got '%c'\n", (unsigned int) i, 'a' + (char) (i % ('z' - 'a' + 1)), key[i]); param->large_header_valid = 0; break; } for (i = 0; i < value_size; i++) if ('Z' - (char) (i % ('Z' - 'A' + 1)) != value[i]) { fprintf (stderr, "Wrong sequence in request header value " \ "at position %u. Expected '%c', got '%c'\n", (unsigned int) i, 'Z' - (char) (i % ('Z' - 'A' + 1)), value[i]); param->large_header_valid = 0; break; } } return MHD_YES; } struct ahc_cls_type { const char *volatile rp_data; volatile size_t rp_data_size; volatile size_t rp_num_n1_hdrs; volatile size_t rp_large_hdr_name_size; volatile size_t rp_large_hdr_value_size; struct mhd_header_checker_param header_check_param; const char *volatile rq_method; const char *volatile rq_url; }; static enum MHD_Result ahcCheck (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; struct ahc_cls_type *const param = (struct ahc_cls_type *) cls; size_t i; if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); if (0 != strcmp (version, MHD_HTTP_VERSION_1_1)) mhdErrorExitDesc ("Unexpected HTTP version"); if (0 != strcmp (url, param->rq_url)) mhdErrorExitDesc ("Unexpected URI"); if (NULL != upload_data) mhdErrorExitDesc ("'upload_data' is not NULL"); if (NULL == upload_data_size) mhdErrorExitDesc ("'upload_data_size' pointer is NULL"); if (0 != *upload_data_size) mhdErrorExitDesc ("'*upload_data_size' value is not zero"); if (0 != strcmp (param->rq_method, method)) mhdErrorExitDesc ("Unexpected request method"); if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; if (1 > MHD_get_connection_values_n (connection, MHD_HEADER_KIND, &headerCheckerInterator, ¶m->header_check_param)) mhdErrorExitDesc ("Wrong number of headers in the request"); response = MHD_create_response_from_buffer_copy (param->rp_data_size, (const void *) param->rp_data); if (NULL == response) mhdErrorExitDesc ("Failed to create response"); for (i = 0; i < param->rp_num_n1_hdrs; i++) if (MHD_YES != MHD_add_response_header (response, N1_HEADER_NAME, N1_HEADER_VALUE)) mhdErrorExitDesc ("Cannot add header"); if (0 != param->rp_large_hdr_name_size) { const size_t large_hdr_name_size = param->rp_large_hdr_name_size; char *large_hrd_name; const size_t large_hdr_value_size = param->rp_large_hdr_value_size; char *large_hrd_value; large_hrd_name = malloc (large_hdr_name_size + 1); if (NULL == large_hrd_name) externalErrorExit (); if (0 != large_hdr_value_size) large_hrd_value = malloc (large_hdr_value_size + 1); else large_hrd_value = NULL; if ((0 != large_hdr_value_size) && (NULL == large_hrd_value)) externalErrorExit (); large_hrd_name[0] = '0'; /* Name starts with zero for unique identification */ for (i = 1; i < large_hdr_name_size; i++) large_hrd_name[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1)); large_hrd_name[large_hdr_name_size] = 0; for (i = 0; i < large_hdr_value_size; i++) large_hrd_value[i] = 'Z' - (char) (unsigned char) (i % ('Z' - 'A' + 1)); if (NULL != large_hrd_value) large_hrd_value[large_hdr_value_size] = 0; if (MHD_YES != MHD_add_response_header (response, large_hrd_name, large_hrd_value)) mhdErrorExitDesc ("Cannot add large header"); if (NULL != large_hrd_value) free (large_hrd_value); free (large_hrd_name); } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (MHD_YES != ret) mhdErrorExitDesc ("Failed to queue response"); return ret; } static CURL * curlEasyInitForTest (const char *queryPath, const char *method, uint16_t port, struct lcurl_data_cb_param *dcbp, struct headers_check_result *hdr_chk_result, struct curl_slist *headers) { CURL *c; c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, queryPath)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, (long) port)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, dcbp)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, (long) response_timeout_val)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, (long) response_timeout_val)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HEADERFUNCTION, lcurl_hdr_callback)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HEADERDATA, hdr_chk_result)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); if (CURLE_OK != curl_easy_setopt (c, CURLOPT_CUSTOMREQUEST, method)) libcurlErrorExitDesc ("curl_easy_setopt() failed"); if (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPHEADER, headers)) libcurlErrorExitDesc ("curl_easy_setopt() failed"); return c; } static CURLcode performQueryExternal (struct MHD_Daemon *d, CURL *c) { CURLM *multi; time_t start; struct timeval tv; CURLcode ret; ret = CURLE_FAILED_INIT; /* will be replaced with real result */ multi = NULL; multi = curl_multi_init (); if (multi == NULL) libcurlErrorExitDesc ("curl_multi_init() failed"); if (CURLM_OK != curl_multi_add_handle (multi, c)) libcurlErrorExitDesc ("curl_multi_add_handle() failed"); start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; int running; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL != multi) { curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) libcurlErrorExitDesc ("curl_multi_info_read() failed"); totalMsgs++; if (CURLMSG_DONE == msg->msg) ret = msg->data.result; } while (msgLeft > 0); if (1 != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); externalErrorExit (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); multi = NULL; } else { if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) libcurlErrorExitDesc ("curl_multi_fdset() failed"); } } if (NULL == multi) { /* libcurl has finished, check whether MHD still needs to perform cleanup */ if (0 != MHD_get_timeout64s (d)) break; /* MHD finished as well */ } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); tv.tv_sec = 0; tv.tv_usec = 1000; #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep (1); #endif } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); } return ret; } struct curlQueryParams { /* Destination path for CURL query */ const char *queryPath; /* Custom query method, NULL for default */ const char *method; /* Destination port for CURL query */ uint16_t queryPort; /* List of additional request headers */ struct curl_slist *headers; /* CURL query result error flag */ volatile unsigned int queryError; /* Response HTTP code, zero if no response */ volatile int responseCode; }; /* Returns zero for successful response and non-zero for failed response */ static unsigned int doCurlQueryInThread (struct MHD_Daemon *d, struct curlQueryParams *p, struct headers_check_result *hdr_res, const char *expected_data, size_t expected_data_size) { const union MHD_DaemonInfo *dinfo; CURL *c; struct lcurl_data_cb_param dcbp; CURLcode errornum; int use_external_poll; long resp_code; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_FLAGS); if (NULL == dinfo) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); use_external_poll = (0 == (dinfo->flags & MHD_USE_INTERNAL_POLLING_THREAD)); if (NULL == p->queryPath) abort (); if (0 == p->queryPort) abort (); /* Test must not fail due to test's internal buffer shortage */ dcbp.size = TEST_FAIL_SIZE * 2 + 1; dcbp.buf = malloc (dcbp.size); if (NULL == dcbp.buf) externalErrorExit (); dcbp.pos = 0; memset (hdr_res, 0, sizeof(*hdr_res)); c = curlEasyInitForTest (p->queryPath, p->method, p->queryPort, &dcbp, hdr_res, p->headers); if (! use_external_poll) errornum = curl_easy_perform (c); else errornum = performQueryExternal (d, c); if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &resp_code)) libcurlErrorExitDesc ("curl_easy_getinfo() failed"); p->responseCode = (int) resp_code; if ((CURLE_OK == errornum) && (200 != resp_code)) { fprintf (stderr, "Got reply with unexpected status code: %d\n", p->responseCode); mhdErrorExit (); } if (CURLE_OK != errornum) { if ((CURLE_GOT_NOTHING != errornum) && (CURLE_RECV_ERROR != errornum) && (CURLE_HTTP_RETURNED_ERROR != errornum)) { if (CURLE_OPERATION_TIMEDOUT == errornum) mhdErrorExitDesc ("Request was aborted due to timeout"); fprintf (stderr, "libcurl returned unexpected error: %s\n", curl_easy_strerror (errornum)); mhdErrorExitDesc ("Request failed due to unexpected error"); } p->queryError = 1; switch (resp_code) { case 0: /* No parsed response */ case 413: /* "Content Too Large" */ case 414: /* "URI Too Long" */ case 431: /* "Request Header Fields Too Large" */ case 501: /* "Not Implemented" */ /* Expected error codes */ break; default: fprintf (stderr, "Got reply with unexpected status code: %ld\n", resp_code); mhdErrorExit (); } } else { if (dcbp.pos != expected_data_size) mhdErrorExit ("libcurl reports wrong size of MHD reply body data"); else if (0 != memcmp (expected_data, dcbp.buf, expected_data_size)) mhdErrorExit ("libcurl reports wrong MHD reply body data"); else p->queryError = 0; } curl_easy_cleanup (c); free (dcbp.buf); return p->queryError; } /* Perform test queries, shut down MHD daemon, and free parameters */ static unsigned int performTestQueries (struct MHD_Daemon *d, uint16_t d_port, struct ahc_cls_type *ahc_param, struct check_uri_cls *uri_cb_param) { struct curlQueryParams qParam; unsigned int ret = 0; /* Return value */ struct headers_check_result rp_headers_check; char *buf; size_t i; size_t first_failed_at = 0; buf = malloc (TEST_FAIL_SIZE + 1 + strlen (URL_SCHEME_HOST)); if (NULL == buf) externalErrorExit (); /* Common parameters, to be individually overridden by specific test cases */ qParam.queryPort = d_port; qParam.method = NULL; /* Use libcurl default: GET */ qParam.queryPath = URL_SCHEME_HOST EXPECTED_URI_BASE_PATH; qParam.headers = NULL; /* No additional headers */ uri_cb_param->uri = EXPECTED_URI_BASE_PATH; ahc_param->rq_url = EXPECTED_URI_BASE_PATH; ahc_param->rq_method = "GET"; /* Default expected method */ ahc_param->rp_data = "~"; ahc_param->rp_data_size = 1; ahc_param->rp_large_hdr_name_size = 0; ahc_param->rp_large_hdr_value_size = 0; ahc_param->rp_num_n1_hdrs = 0; if (large_req_method) { for (i = 0; i < TEST_START_SIZE; i++) buf[i] = 'A' + (char) (unsigned char) (i % ('Z' - 'A' + 1)); for (; i <= TEST_FAIL_SIZE; i++) { buf[i] = 0; qParam.method = buf; ahc_param->rq_method = buf; memset (&ahc_param->header_check_param, 0, sizeof (ahc_param->header_check_param)); if (0 != doCurlQueryInThread (d, &qParam, &rp_headers_check, ahc_param->rp_data, ahc_param->rp_data_size)) { if ((0 != qParam.responseCode) && (501 != qParam.responseCode)) { fprintf (stderr, "Got reply with status code %d, " "while code 501 (\"Not Implemented\") is expected.\n", qParam.responseCode); mhdErrorExit (); } if (TEST_OK_SIZE >= i) { fprintf (stderr, "Request failed when running with the valid value size.\n"); ret = 1; /* Failed too early */ } if (0 == first_failed_at) { if (verbose) fprintf (stderr, "First failed size is %u.\n", (unsigned int) i); first_failed_at = i; } } else { if (TEST_FAIL_SIZE == i) { fprintf (stderr, "Request succeed with the largest size.\n"); ret = 1; /* Succeed with largest value */ } } if (0 != ahc_param->header_check_param.num_n1_headers) mhdErrorExitDesc ("Detected unexpected request headers"); if (0 != ahc_param->header_check_param.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large request header"); if (0 != rp_headers_check.num_n1_headers) mhdErrorExitDesc ("Detected unexpected reply headers"); if (0 != rp_headers_check.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large reply header"); buf[i] = 'A' + (char) (unsigned char) (i % ('Z' - 'A' + 1)); } } else if (large_req_url) { const size_t base_size = strlen (URL_SCHEME_HOST); char *const url = buf + base_size; memcpy (buf, URL_SCHEME_HOST, base_size); url[0] = '/'; for (i = 1; i < TEST_START_SIZE; i++) url[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1)); for (; i <= TEST_FAIL_SIZE; i++) { url[i] = 0; qParam.queryPath = buf; uri_cb_param->uri = url; ahc_param->rq_url = url; memset (&ahc_param->header_check_param, 0, sizeof (ahc_param->header_check_param)); if (0 != doCurlQueryInThread (d, &qParam, &rp_headers_check, ahc_param->rp_data, ahc_param->rp_data_size)) { if ((0 != qParam.responseCode) && (414 != qParam.responseCode)) { fprintf (stderr, "Got reply with status code %d, " "while code 414 (\"URI Too Long\") is expected.\n", qParam.responseCode); mhdErrorExit (); } if (TEST_OK_SIZE >= i) { fprintf (stderr, "Request failed when running with the valid value size.\n"); ret = 1; /* Failed too early */ } if (0 == first_failed_at) { if (verbose) fprintf (stderr, "First failed size is %u.\n", (unsigned int) i); first_failed_at = i; } } else { if (TEST_FAIL_SIZE == i) { fprintf (stderr, "Request succeed with the largest size.\n"); ret = 1; /* Succeed with largest value */ } } if (0 != ahc_param->header_check_param.num_n1_headers) mhdErrorExitDesc ("Detected unexpected request headers"); if (0 != ahc_param->header_check_param.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large request header"); if (0 != rp_headers_check.num_n1_headers) mhdErrorExitDesc ("Detected unexpected reply headers"); if (0 != rp_headers_check.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large reply header"); url[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1)); } } else if (large_req_header_name) { buf[0] = '0'; /* Name starts with zero for unique identification */ for (i = 1; i < TEST_START_SIZE; i++) buf[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1)); for (; i <= TEST_FAIL_SIZE; i++) { struct curl_slist *curl_headers; curl_headers = NULL; memcpy (buf + i, ": Z", 3); /* Note: strlen(": Z") is less than strlen(URL_SCHEME_HOST) */ buf[i + 3] = 0; curl_headers = curl_slist_append (curl_headers, buf); if (NULL == curl_headers) externalErrorExit (); qParam.headers = curl_headers; memset (&ahc_param->header_check_param, 0, sizeof (ahc_param->header_check_param)); if (0 != doCurlQueryInThread (d, &qParam, &rp_headers_check, ahc_param->rp_data, ahc_param->rp_data_size)) { if ((0 != qParam.responseCode) && (431 != qParam.responseCode)) { fprintf (stderr, "Got reply with status code %d, while code 431 " "(\"Request Header Fields Too Large\") is expected.\n", qParam.responseCode); mhdErrorExit (); } if (0 != ahc_param->header_check_param.large_header_name_size) { /* If large header was processed, it must be valid */ if (i != ahc_param->header_check_param.large_header_name_size) mhdErrorExitDesc ("Detected wrong large request header name size"); if (1 != ahc_param->header_check_param.large_header_value_size) mhdErrorExitDesc ("Detected wrong large request header value size"); if (0 == ahc_param->header_check_param.large_header_valid) mhdErrorExitDesc ("Detected wrong large request header"); } if (TEST_OK_SIZE >= i) { fprintf (stderr, "Request failed when running with the valid value size.\n"); ret = 1; /* Failed too early */ } if (0 == first_failed_at) { if (verbose) fprintf (stderr, "First failed size is %u.\n", (unsigned int) i); first_failed_at = i; } } else { if (i != ahc_param->header_check_param.large_header_name_size) mhdErrorExitDesc ("Detected wrong large request header name size"); if (1 != ahc_param->header_check_param.large_header_value_size) mhdErrorExitDesc ("Detected wrong large request header value size"); if (0 == ahc_param->header_check_param.large_header_valid) mhdErrorExitDesc ("Detected wrong large request header"); if (TEST_FAIL_SIZE == i) { fprintf (stderr, "Request succeed with the largest size.\n"); ret = 1; /* Succeed with largest value */ } } if (0 != ahc_param->header_check_param.num_n1_headers) mhdErrorExitDesc ("Detected unexpected request headers"); if (0 != rp_headers_check.num_n1_headers) mhdErrorExitDesc ("Detected unexpected reply headers"); if (0 != rp_headers_check.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large reply header"); curl_slist_free_all (curl_headers); buf[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1)); } } else if (large_req_header_value) { char *const hdr_value = buf + 3; /* Name starts with zero for unique identification */ memcpy (buf, "0: ", 3); /* Note: strlen(": Z") is less than strlen(URL_SCHEME_HOST) */ for (i = 0; i < TEST_START_SIZE; i++) hdr_value[i] = 'Z' - (char) (unsigned char) (i % ('Z' - 'A' + 1)); for (; i <= TEST_FAIL_SIZE; i++) { struct curl_slist *curl_headers; curl_headers = NULL; hdr_value[i] = 0; curl_headers = curl_slist_append (curl_headers, buf); if (NULL == curl_headers) externalErrorExit (); qParam.headers = curl_headers; memset (&ahc_param->header_check_param, 0, sizeof (ahc_param->header_check_param)); if (0 != doCurlQueryInThread (d, &qParam, &rp_headers_check, ahc_param->rp_data, ahc_param->rp_data_size)) { if ((0 != qParam.responseCode) && (431 != qParam.responseCode)) { fprintf (stderr, "Got reply with status code %d, while code 431 " "(\"Request Header Fields Too Large\") is expected.\n", qParam.responseCode); mhdErrorExit (); } if (0 != ahc_param->header_check_param.large_header_name_size) { /* If large header was processed, it must be valid */ if (1 != ahc_param->header_check_param.large_header_name_size) mhdErrorExitDesc ("Detected wrong large request header name size"); if (i != ahc_param->header_check_param.large_header_value_size) mhdErrorExitDesc ("Detected wrong large request header value size"); if (0 == ahc_param->header_check_param.large_header_valid) mhdErrorExitDesc ("Detected wrong large request header"); } if (TEST_OK_SIZE >= i) { fprintf (stderr, "Request failed when running with the valid value size.\n"); ret = 1; /* Failed too early */ } if (0 == first_failed_at) { if (verbose) fprintf (stderr, "First failed size is %u.\n", (unsigned int) i); first_failed_at = i; } } else { if (1 != ahc_param->header_check_param.large_header_name_size) mhdErrorExitDesc ("Detected wrong large request header name size"); if (i != ahc_param->header_check_param.large_header_value_size) mhdErrorExitDesc ("Detected wrong large request header value size"); if (0 == ahc_param->header_check_param.large_header_valid) mhdErrorExitDesc ("Detected wrong large request header"); if (TEST_FAIL_SIZE == i) { fprintf (stderr, "Request succeed with the largest size.\n"); ret = 1; /* Succeed with largest value */ } } if (0 != ahc_param->header_check_param.num_n1_headers) mhdErrorExitDesc ("Detected unexpected request headers"); if (0 != rp_headers_check.num_n1_headers) mhdErrorExitDesc ("Detected unexpected reply headers"); if (0 != rp_headers_check.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large reply header"); curl_slist_free_all (curl_headers); hdr_value[i] = 'Z' - (char) (unsigned char) (i % ('Z' - 'A' + 1)); } } else if (large_req_headers) { unsigned int num_hdrs = 0; struct curl_slist *curl_headers; const size_t hdr_size = strlen (N1_HEADER_CRLF); curl_headers = NULL; for (i = 0; i < TEST_RQ_N1_START_SIZE; i += hdr_size) { curl_headers = curl_slist_append (curl_headers, N1_HEADER); if (NULL == curl_headers) externalErrorExit (); num_hdrs++; } for (; i <= TEST_FAIL_SIZE; i += hdr_size) { qParam.headers = curl_headers; ahc_param->header_check_param.num_n1_headers = num_hdrs; memset (&ahc_param->header_check_param, 0, sizeof (ahc_param->header_check_param)); if (0 != doCurlQueryInThread (d, &qParam, &rp_headers_check, ahc_param->rp_data, ahc_param->rp_data_size)) { if ((0 != qParam.responseCode) && (431 != qParam.responseCode)) { fprintf (stderr, "Got reply with status code %d, while code 431 " "(\"Request Header Fields Too Large\") is expected.\n", qParam.responseCode); mhdErrorExit (); } if (0 != ahc_param->header_check_param.num_n1_headers) { /* If headers were processed, they must be valid */ if (num_hdrs != ahc_param->header_check_param.num_n1_headers) mhdErrorExitDesc ("Detected wrong number of request headers"); } if (TEST_RQ_N1_OK_SIZE >= i) { fprintf (stderr, "Request failed when running with the valid value size.\n"); ret = 1; /* Failed too early */ } if (0 == first_failed_at) { if (verbose) fprintf (stderr, "First failed size is %u.\n", (unsigned int) i); first_failed_at = i; } } else { if (num_hdrs != ahc_param->header_check_param.num_n1_headers) mhdErrorExitDesc ("Detected wrong number of request headers"); if (TEST_FAIL_SIZE == i) { fprintf (stderr, "Request succeed with the largest size.\n"); ret = 1; /* Succeed with largest value */ } } if (0 != ahc_param->header_check_param.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large request header"); if (0 != rp_headers_check.num_n1_headers) mhdErrorExitDesc ("Detected unexpected reply headers"); if (0 != rp_headers_check.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large reply header"); curl_headers = curl_slist_append (curl_headers, N1_HEADER); if (NULL == curl_headers) externalErrorExit (); num_hdrs++; } curl_slist_free_all (curl_headers); } else if (large_rsp_header_name) { for (i = TEST_START_SIZE; i <= TEST_FAIL_SIZE; i++) { ahc_param->rp_large_hdr_name_size = i; ahc_param->rp_large_hdr_value_size = 1; memset (&ahc_param->header_check_param, 0, sizeof (ahc_param->header_check_param)); if (0 != doCurlQueryInThread (d, &qParam, &rp_headers_check, ahc_param->rp_data, ahc_param->rp_data_size)) { (void) qParam.responseCode; /* TODO: check for the right response code */ if (0 != rp_headers_check.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large reply header"); if (TEST_OK_SIZE >= i) { fprintf (stderr, "Request failed when running with the valid value size.\n"); ret = 1; /* Failed too early */ } if (0 == first_failed_at) { if (verbose) fprintf (stderr, "First failed size is %u.\n", (unsigned int) i); first_failed_at = i; } } else { if (i != rp_headers_check.large_header_name_size) mhdErrorExitDesc ("Detected wrong large reply header name size"); if (1 != rp_headers_check.large_header_value_size) mhdErrorExitDesc ("Detected wrong large reply header value size"); if (0 == rp_headers_check.large_header_valid) mhdErrorExitDesc ("Detected wrong large reply header"); if (TEST_FAIL_SIZE == i) { fprintf (stderr, "Request succeed with the largest size.\n"); ret = 1; /* Succeed with largest value */ } } if (0 != ahc_param->header_check_param.num_n1_headers) mhdErrorExitDesc ("Detected unexpected request headers"); if (0 != ahc_param->header_check_param.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large request header"); if (0 != rp_headers_check.num_n1_headers) mhdErrorExitDesc ("Detected unexpected reply headers"); } } else if (large_rsp_header_value) { for (i = TEST_START_SIZE; i <= TEST_FAIL_SIZE; i++) { ahc_param->rp_large_hdr_name_size = 1; ahc_param->rp_large_hdr_value_size = i; memset (&ahc_param->header_check_param, 0, sizeof (ahc_param->header_check_param)); if (0 != doCurlQueryInThread (d, &qParam, &rp_headers_check, ahc_param->rp_data, ahc_param->rp_data_size)) { (void) qParam.responseCode; /* TODO: check for the right response code */ if (0 != rp_headers_check.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large reply header"); if (TEST_OK_SIZE >= i) { fprintf (stderr, "Request failed when running with the valid value size.\n"); ret = 1; /* Failed too early */ } if (0 == first_failed_at) { if (verbose) fprintf (stderr, "First failed size is %u.\n", (unsigned int) i); first_failed_at = i; } } else { if (1 != rp_headers_check.large_header_name_size) mhdErrorExitDesc ("Detected wrong large reply header name size"); if (i != rp_headers_check.large_header_value_size) mhdErrorExitDesc ("Detected wrong large reply header value size"); if (0 == rp_headers_check.large_header_valid) mhdErrorExitDesc ("Detected wrong large reply header"); if (TEST_FAIL_SIZE == i) { fprintf (stderr, "Request succeed with the largest size.\n"); ret = 1; /* Succeed with largest value */ } } if (0 != ahc_param->header_check_param.num_n1_headers) mhdErrorExitDesc ("Detected unexpected request headers"); if (0 != ahc_param->header_check_param.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large request header"); if (0 != rp_headers_check.num_n1_headers) mhdErrorExitDesc ("Detected unexpected reply headers"); } } else if (large_rsp_headers) { size_t num_hrds; const size_t hdr_size = strlen (N1_HEADER_CRLF); for (num_hrds = TEST_START_SIZE / hdr_size; num_hrds * hdr_size <= TEST_FAIL_SIZE; num_hrds++) { i = num_hrds * hdr_size; ahc_param->rp_num_n1_hdrs = num_hrds; memset (&ahc_param->header_check_param, 0, sizeof (ahc_param->header_check_param)); if (0 != doCurlQueryInThread (d, &qParam, &rp_headers_check, ahc_param->rp_data, ahc_param->rp_data_size)) { (void) qParam.responseCode; /* TODO: check for the right response code */ if (0 != rp_headers_check.num_n1_headers) mhdErrorExitDesc ("Detected unexpected reply headers"); if (TEST_OK_SIZE >= i) { fprintf (stderr, "Request failed when running with the valid value size.\n"); ret = 1; /* Failed too early */ } if (0 == first_failed_at) { if (verbose) fprintf (stderr, "First failed size is %u.\n", (unsigned int) i); first_failed_at = i; } } else { if (num_hrds != rp_headers_check.num_n1_headers) mhdErrorExitDesc ("Detected wrong number of reply headers"); if (TEST_FAIL_SIZE == i) { fprintf (stderr, "Request succeed with the largest size.\n"); ret = 1; /* Succeed with largest value */ } } if (0 != ahc_param->header_check_param.num_n1_headers) mhdErrorExitDesc ("Detected unexpected request headers"); if (0 != ahc_param->header_check_param.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large request header"); if (0 != rp_headers_check.large_header_name_size) mhdErrorExitDesc ("Detected unexpected large reply header"); } } else externalErrorExitDesc ("No valid test test was selected"); MHD_stop_daemon (d); free (buf); free (uri_cb_param); free (ahc_param); return ret; } enum testMhdThreadsType { testMhdThreadExternal = 0, testMhdThreadInternal = MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPerConnection = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPool }; enum testMhdPollType { testMhdPollBySelect = 0, testMhdPollByPoll = MHD_USE_POLL, testMhdPollByEpoll = MHD_USE_EPOLL, testMhdPollAuto = MHD_USE_AUTO }; /* Get number of threads for thread pool depending * on used poll function and test type. */ static unsigned int testNumThreadsForPool (enum testMhdPollType pollType) { unsigned int numThreads = MHD_CPU_COUNT; (void) pollType; /* Don't care about pollType for this test */ return numThreads; /* No practical limit for non-cleanup test */ } static struct MHD_Daemon * startTestMhdDaemon (enum testMhdThreadsType thrType, enum testMhdPollType pollType, uint16_t *pport, struct ahc_cls_type **ahc_param, struct check_uri_cls **uri_cb_param) { struct MHD_Daemon *d; const union MHD_DaemonInfo *dinfo; if ((NULL == ahc_param) || (NULL == uri_cb_param)) abort (); *ahc_param = (struct ahc_cls_type *) malloc (sizeof(struct ahc_cls_type)); if (NULL == *ahc_param) externalErrorExit (); *uri_cb_param = (struct check_uri_cls *) malloc (sizeof(struct check_uri_cls)); if (NULL == *uri_cb_param) externalErrorExit (); if ( (0 == *pport) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { *pport = 4100; if (large_req_method) *pport += 1; if (large_req_url) *pport += 2; if (large_req_header_name) *pport += 3; if (large_req_header_value) *pport += 4; if (large_req_headers) *pport += 5; if (large_rsp_header_name) *pport += 6; if (large_rsp_header_value) *pport += 7; if (large_rsp_headers) *pport += 8; if (! oneone) *pport += 16; } if (testMhdThreadExternal == thrType) d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0) | MHD_USE_NO_THREAD_SAFETY, *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_URI_LOG_CALLBACK, &check_uri_cb, *uri_cb_param, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) BUFFER_SIZE, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); else if (testMhdThreadInternalPool != thrType) d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0), *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_URI_LOG_CALLBACK, &check_uri_cb, *uri_cb_param, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) BUFFER_SIZE, MHD_OPTION_END); else d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | ((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0), *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_THREAD_POOL_SIZE, testNumThreadsForPool (pollType), MHD_OPTION_URI_LOG_CALLBACK, &check_uri_cb, *uri_cb_param, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) BUFFER_SIZE, MHD_OPTION_END); if (NULL == d) { fprintf (stderr, "Failed to start MHD daemon, errno=%d.\n", errno); abort (); } if (0 == *pport) { dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { fprintf (stderr, "MHD_get_daemon_info() failed.\n"); abort (); } *pport = dinfo->port; if (0 == global_port) global_port = *pport; /* Reuse the same port for all tests */ } return d; } /* Test runners */ static unsigned int testExternalGet (void) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; d = startTestMhdDaemon (testMhdThreadExternal, testMhdPollBySelect, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param); } static unsigned int testInternalGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; d = startTestMhdDaemon (testMhdThreadInternal, pollType, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param); } static unsigned int testMultithreadedGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; d = startTestMhdDaemon (testMhdThreadInternalPerConnection, pollType, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param); } static unsigned int testMultithreadedPoolGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; d = startTestMhdDaemon (testMhdThreadInternalPool, pollType, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param); } int main (int argc, char *const *argv) { unsigned int errorCount = 0; unsigned int test_result = 0; verbose = 0; if ((NULL == argv) || (0 == argv[0])) return 99; oneone = ! has_in_name (argv[0], "10"); large_req_method = has_in_name (argv[0], "_method") ? 1 : 0; large_req_url = has_in_name (argv[0], "_url") ? 1 : 0; large_req_header_name = has_in_name (argv[0], "_request_header_name") ? 1 : 0; large_req_header_value = has_in_name (argv[0], "_request_header_value") ? 1 : 0; large_req_headers = has_in_name (argv[0], "_request_headers") ? 1 : 0; large_rsp_header_name = has_in_name (argv[0], "_reply_header_name") ? 1 : 0; large_rsp_header_value = has_in_name (argv[0], "_reply_header_value") ? 1 : 0; large_rsp_headers = has_in_name (argv[0], "_reply_headers") ? 1 : 0; if (large_req_method + large_req_url + large_req_header_name + large_req_header_value + large_req_headers + large_rsp_header_name + large_rsp_header_value + large_rsp_headers != 1) return 99; verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); test_global_init (); /* Could be set to non-zero value to enforce using specific port * in the test */ global_port = 0; test_result = testExternalGet (); if (test_result) fprintf (stderr, "FAILED: testExternalGet () - %u.\n", test_result); else if (verbose) printf ("PASSED: testExternalGet ().\n"); errorCount += test_result; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { test_result = testInternalGet (testMhdPollAuto); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollAuto) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollBySelect).\n"); errorCount += test_result; #ifdef _MHD_HEAVY_TESTS /* Actually tests are not heavy, but took too long to complete while * not really provide any additional results. */ test_result = testInternalGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedPoolGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedGet (testMhdPollBySelect).\n"); errorCount += test_result; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { test_result = testInternalGet (testMhdPollByPoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByPoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByPoll).\n"); errorCount += test_result; } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { test_result = testInternalGet (testMhdPollByEpoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByEpoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByEpoll).\n"); errorCount += test_result; } #else /* Mute compiler warnings */ (void) testMultithreadedGet; (void) testMultithreadedPoolGet; #endif /* _MHD_HEAVY_TESTS */ } if (0 != errorCount) fprintf (stderr, "Error (code: %u)\n", errorCount); else if (verbose) printf ("All tests passed.\n"); test_global_cleanup (); return (errorCount == 0) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_delete.c0000644000175000017500000003735714530120375015156 /* This file is part of libmicrohttpd Copyright (C) 2007, 2016 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file daemontest_delete.c * @brief Testcase for libmicrohttpd DELETE operations * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #ifndef WINDOWS #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif static int oneone; struct CBC { char *buf; size_t pos; size_t size; }; static size_t putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) { size_t *pos = ptr; size_t wrt; wrt = size * nmemb; if (wrt > 8 - (*pos)) wrt = 8 - (*pos); memcpy (stream, &("Hello123"[*pos]), wrt); (*pos) += wrt; return wrt; } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { int *done = cls; struct MHD_Response *response; enum MHD_Result ret; (void) version; (void) req_cls; /* Unused. Silent compiler warning. */ if (0 != strcmp ("DELETE", method)) return MHD_NO; /* unexpected method */ if ((*done) == 0) { if (*upload_data_size != 8) return MHD_YES; /* not yet ready */ if (0 == memcmp (upload_data, "Hello123", 8)) { *upload_data_size = 0; } else { printf ("Invalid upload data `%8s'!\n", upload_data); return MHD_NO; } *done = 1; return MHD_YES; } response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int testInternalDelete (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1152; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; return 0; } static unsigned int testMultithreadedDelete (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1153; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testMultithreadedPoolDelete (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1154; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testExternalDelete (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; size_t pos = 0; int done_flag = 0; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1154; multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 8192; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 16384; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalDelete (); errorCount += testMultithreadedDelete (); errorCount += testMultithreadedPoolDelete (); } errorCount += testExternalDelete (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_quiesce.c0000644000175000017500000005643014522742656015360 /* This file is part of libmicrohttpd Copyright (C) 2013, 2015 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_quiesce.c * @brief Testcase for libmicrohttpd quiescing * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include #include #include "mhd_sockets.h" /* only macros used */ #include "mhd_has_in_name.h" #include "mhd_has_param.h" #ifndef WINDOWS #include #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __func__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), \ __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), \ __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func(NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), NULL, __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (8); } static void _checkCURLE_OK_func (CURLcode code, const char *curlFunc, const char *funcName, int lineNum) { if (CURLE_OK == code) return; fflush (stdout); if ((NULL != curlFunc) && (0 != curlFunc[0])) fprintf (stderr, "'%s' resulted in '%s'", curlFunc, curl_easy_strerror (code)); else fprintf (stderr, "libcurl function call resulted in '%s'", curl_easy_strerror (code)); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (9); } /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 4 #define MHD_URI_BASE_PATH "/hello_world" /* Global parameters */ static int verbose; /**< Be verbose */ static int oneone; /**< If false use HTTP/1.0 for requests*/ static uint16_t global_port; /**< MHD daemons listen port number */ struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; (void) cls; (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) { fprintf (stderr, "Unexpected HTTP method '%s'. ", method); externalErrorExit (); } if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); if (NULL == response) mhdErrorExitDesc ("MHD_create_response failed"); /* Make sure that connection will not be reused */ if (MHD_NO == MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "close")) mhdErrorExitDesc ("MHD_add_response_header() failed"); if (MHD_NO == MHD_queue_response (connection, MHD_HTTP_OK, response)) mhdErrorExitDesc ("MHD_queue_response() failed"); MHD_destroy_response (response); return MHD_YES; } static void request_completed (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode code) { int *done = (int *) cls; (void) connection; (void) req_cls; (void) code; /* Unused. Silent compiler warning. */ if (MHD_REQUEST_TERMINATED_COMPLETED_OK != code) { fprintf (stderr, "Unexpected termination code: %d. ", (int) code); mhdErrorExit (); } *done = 1; if (verbose) printf ("Notify callback has been called with OK code.\n"); } static void * ServeOneRequest (void *param) { struct MHD_Daemon *d; fd_set rs; fd_set ws; fd_set es; MHD_socket fd, max; time_t start; struct timeval tv; volatile int done = 0; if (NULL == param) externalErrorExit (); fd = *((MHD_socket *) param); d = MHD_start_daemon (MHD_USE_ERROR_LOG, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_LISTEN_SOCKET, fd, MHD_OPTION_NOTIFY_COMPLETED, &request_completed, &done, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) mhdErrorExit (); if (verbose) printf ("Started MHD daemon in ServeOneRequest().\n"); start = time (NULL); while ((time (NULL) - start < TIMEOUTS_VAL * 2) && done == 0) { max = 0; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) mhdErrorExit ("MHD_get_fdset() failed"); tv.tv_sec = 0; tv.tv_usec = 100000; if (-1 == MHD_SYS_select_ (max + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep ((DWORD) (tv.tv_sec * 1000 + tv.tv_usec / 1000)); #endif } MHD_run (d); } if (! done) mhdErrorExit ("ServeOneRequest() failed and finished by timeout"); fd = MHD_quiesce_daemon (d); if (MHD_INVALID_SOCKET == fd) mhdErrorExit ("MHD_quiesce_daemon() failed in ServeOneRequest()"); MHD_stop_daemon (d); return NULL; } static CURL * setupCURL (void *cbc) { CURL *c; c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" MHD_URI_BASE_PATH)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, (long) global_port)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, (long) (TIMEOUTS_VAL / 2))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, (long) TIMEOUTS_VAL)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); return c; } static unsigned int testGet (unsigned int type, int pool_count, uint32_t poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; MHD_socket fd; pthread_t thrd; char *thrdRet; if (verbose) printf ("testGet(%u, %d, %u) test started.\n", type, pool_count, (unsigned int) poll_flag); cbc.buf = buf; cbc.size = sizeof(buf); cbc.pos = 0; if (pool_count > 0) { d = MHD_start_daemon (type | MHD_USE_ERROR_LOG | MHD_USE_ITC | (enum MHD_FLAG) poll_flag, global_port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) pool_count, MHD_OPTION_END); } else { d = MHD_start_daemon (type | MHD_USE_ERROR_LOG | MHD_USE_ITC | (enum MHD_FLAG) poll_flag, global_port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); } if (d == NULL) mhdErrorExitDesc ("MHD_start_daemon() failed"); if (0 == global_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExit (); global_port = dinfo->port; } c = setupCURL (&cbc); checkCURLE_OK (curl_easy_perform (c)); if (cbc.pos != strlen (MHD_URI_BASE_PATH)) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) cbc.pos, (int) cbc.pos, cbc.buf, (unsigned) strlen (MHD_URI_BASE_PATH)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != strncmp (MHD_URI_BASE_PATH, cbc.buf, strlen (MHD_URI_BASE_PATH))) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) cbc.pos, cbc.buf); mhdErrorExitDesc ("Wrong returned data"); } if (verbose) printf ("Received valid response data.\n"); fd = MHD_quiesce_daemon (d); if (MHD_INVALID_SOCKET == fd) mhdErrorExitDesc ("MHD_quiesce_daemon failed"); if (0 != pthread_create (&thrd, NULL, &ServeOneRequest, (void *) &fd)) externalErrorExitDesc ("pthread_create() failed"); /* No need for the thread sync as socket is already listening, * so libcurl may start connecting before MHD is started in another thread */ cbc.pos = 0; checkCURLE_OK (curl_easy_perform (c)); if (cbc.pos != strlen (MHD_URI_BASE_PATH)) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) cbc.pos, (int) cbc.pos, cbc.buf, (unsigned) strlen (MHD_URI_BASE_PATH)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != strncmp (MHD_URI_BASE_PATH, cbc.buf, strlen (MHD_URI_BASE_PATH))) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) cbc.pos, cbc.buf); mhdErrorExitDesc ("Wrong returned data"); } if (0 != pthread_join (thrd, (void **) &thrdRet)) externalErrorExitDesc ("pthread_join() failed"); if (NULL != thrdRet) externalErrorExitDesc ("ServeOneRequest() returned non-NULL result"); if (verbose) { printf ("ServeOneRequest() thread was joined.\n"); fflush (stdout); } /* at this point, the forked server quiesced and quit, * so new requests should fail */ cbc.pos = 0; if (CURLE_OK == curl_easy_perform (c)) { fprintf (stderr, "curl_easy_perform() succeed while it should fail. "); fprintf (stderr, "Got %u bytes ('%.*s'), " "valid data would be %u bytes (%s). ", (unsigned) cbc.pos, (int) cbc.pos, cbc.buf, (unsigned) strlen (MHD_URI_BASE_PATH), MHD_URI_BASE_PATH); mhdErrorExitDesc ("Unexpected succeed request"); } if (verbose) printf ("curl_easy_perform() failed as expected.\n"); curl_easy_cleanup (c); MHD_stop_daemon (d); MHD_socket_close_chk_ (fd); if (verbose) { printf ("testGet(%u, %d, %u) test succeed.\n", type, pool_count, (unsigned int) poll_flag); fflush (stdout); } return 0; } static unsigned int testExternalGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; int running; struct CURLMsg *msg; time_t start; struct timeval tv; int i; MHD_socket fd = MHD_INVALID_SOCKET; if (verbose) printf ("testExternalGet test started.\n"); fd = MHD_INVALID_SOCKET; multi = NULL; cbc.buf = buf; cbc.size = sizeof(buf); cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG, global_port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) mhdErrorExitDesc ("Failed to start MHD daemon"); if (0 == global_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExit (); global_port = dinfo->port; } for (i = 0; i < 2; i++) { c = setupCURL (&cbc); multi = curl_multi_init (); if (multi == NULL) libcurlErrorExit (); mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) libcurlErrorExit (); start = time (NULL); while ( (time (NULL) - start < TIMEOUTS_VAL * 2) && (NULL != multi) ) { MHD_socket maxsock; int maxposixs; maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) libcurlErrorExit (); if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) mhdErrorExit (); #ifndef MHD_WINSOCK_SOCKETS if (maxsock > maxposixs) maxposixs = maxsock; #endif /* MHD_POSIX_SOCKETS */ tv.tv_sec = 0; tv.tv_usec = 100000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep ((DWORD) (tv.tv_sec * 1000 + tv.tv_usec / 1000)); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) { curl_fine = 1; if (verbose) printf ("libcurl reported success.\n"); } else if (i == 0) { fprintf (stderr, "curl_multi_perform() failed with '%s'. ", curl_easy_strerror (msg->data.result)); mhdErrorExit (); } } } if (i == 0) { if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); mhdErrorExit (); } /* MHD is running, result should be correct */ if (cbc.pos != strlen (MHD_URI_BASE_PATH)) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) cbc.pos, (int) cbc.pos, cbc.buf, (unsigned) strlen (MHD_URI_BASE_PATH)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != strncmp (MHD_URI_BASE_PATH, cbc.buf, strlen (MHD_URI_BASE_PATH))) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) cbc.pos, cbc.buf); mhdErrorExitDesc ("Wrong returned data"); } if (verbose) { printf ("First request was successful.\n"); fflush (stdout); } } else if (i == 1) { if (curl_fine) { fprintf (stderr, "libcurl returned OK code, while it shouldn't\n"); mhdErrorExit (); } if (verbose) printf ("Second request failed as expected.\n"); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; break; } MHD_run (d); } if (NULL != multi) mhdErrorExitDesc ("Test failed and finished by timeout"); if (0 == i) { /* quiesce the daemon on the 1st iteration, so the 2nd should fail */ fd = MHD_quiesce_daemon (d); if (MHD_INVALID_SOCKET == fd) mhdErrorExitDesc ("MHD_quiesce_daemon() failed"); } } MHD_stop_daemon (d); if (MHD_INVALID_SOCKET == fd) { fprintf (stderr, "Failed to MHD_quiesce_daemon() at some point. "); externalErrorExit (); } MHD_socket_close_chk_ (fd); if (verbose) { printf ("testExternalGet succeed.\n"); fflush (stdout); } return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; oneone = ! has_in_name (argv[0], "10"); verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) global_port = 0; else global_port = 1480 + (oneone ? 1 : 0); errorCount += testExternalGet (); if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, 0, 0); errorCount += testGet (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, 0, 0); errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, MHD_CPU_COUNT, 0); if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, 0, MHD_USE_POLL); errorCount += testGet (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, 0, MHD_USE_POLL); errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, MHD_CPU_COUNT, MHD_USE_POLL); } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, 0, MHD_USE_EPOLL); errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, MHD_CPU_COUNT, MHD_USE_EPOLL); } } if (0 != errorCount) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/mhd_has_in_name.h0000644000175000017500000000410714556022036015741 /* This file is part of libmicrohttpd Copyright (C) 2016-2021 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file testcurl/mhd_has_in_name.h * @brief Static functions and macros helpers for testsuite. * @author Karlson2k (Evgeny Grin) */ #include /** * Check whether program name contains specific @a marker string. * Only last component in pathname is checked for marker presence, * all leading directories names (if any) are ignored. Directories * separators are handled correctly on both non-W32 and W32 * platforms. * @param prog_name program name, may include path * @param marker marker to look for. * @return zero if any parameter is NULL or empty string or * @a prog_name ends with slash or @a marker is not found in * program name, non-zero if @a maker is found in program * name. */ static int has_in_name (const char *prog_name, const char *marker) { size_t name_pos; size_t pos; if (! prog_name || ! marker || ! prog_name[0] || ! marker[0]) return 0; pos = 0; name_pos = 0; while (prog_name[pos]) { if ('/' == prog_name[pos]) name_pos = pos + 1; #if defined(_WIN32) || defined(__CYGWIN__) else if ('\\' == prog_name[pos]) name_pos = pos + 1; #endif /* _WIN32 || __CYGWIN__ */ pos++; } if (name_pos == pos) return 0; return strstr (prog_name + name_pos, marker) != (char *) 0; } libmicrohttpd-1.0.1/src/testcurl/test_tricky.c0000644000175000017500000010651614530120375015213 /* This file is part of libmicrohttpd Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) Copyright (C) 2007, 2009, 2011 Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_toolarge.c * @brief Testcase for handling of untypical data. * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #include "mhd_has_param.h" #include "mhd_sockets.h" /* only macros used */ #ifdef HAVE_STRINGS_H #include #endif /* HAVE_STRINGS_H */ #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #ifndef WINDOWS #include #include #endif #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #if MHD_CPU_COUNT > 32 #undef MHD_CPU_COUNT /* Limit to reasonable value */ #define MHD_CPU_COUNT 32 #endif /* MHD_CPU_COUNT > 32 */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func(NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error details: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); fflush (stderr); exit (8); } /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 #define EXPECTED_URI_BASE_PATH "/a" #define EXPECTED_URI_BASE_PATH_TRICKY "/one\rtwo" #define URL_SCHEME "http:/" "/" #define URL_HOST "127.0.0.1" #define URL_SCHEME_HOST URL_SCHEME URL_HOST #define HEADER1_NAME "First" #define HEADER1_VALUE "1st" #define HEADER1 HEADER1_NAME ": " HEADER1_VALUE #define HEADER2_NAME "Second" #define HEADER2CR_VALUE "2\rnd" #define HEADER2CR HEADER2_NAME ": " HEADER2CR_VALUE /* Use headers when it would be properly supported by MHD #define HEADER3CR_NAME "Thi\rrd" #define HEADER3CR_VALUE "3r\rd" #define HEADER3CR HEADER3CR_NAME ": " HEADER3CR_VALUE */ #define HEADER4_NAME "Normal" #define HEADER4_VALUE "it's fine" #define HEADER4 HEADER4_NAME ": " HEADER4_VALUE /* Global parameters */ static int verbose; /**< Be verbose */ static int oneone; /**< If false use HTTP/1.0 for requests*/ static uint16_t global_port; /**< MHD daemons listen port number */ static int response_timeout_val = TIMEOUTS_VAL; static int tricky_url; /**< Tricky request URL */ static int tricky_header2; /**< Tricky request header2 */ /* Current test parameters */ /* * Moved to local variables * */ /* Static helper variables */ /* * None for this test * */ static void test_global_init (void) { libcurl_errbuf[0] = 0; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) externalErrorExit (); } static void test_global_cleanup (void) { curl_global_cleanup (); } struct headers_check_result { int dummy; /* no checks in this test */ }; static size_t lcurl_hdr_callback (char *buffer, size_t size, size_t nitems, void *userdata) { const size_t data_size = size * nitems; struct headers_check_result *check_res = (struct headers_check_result *) userdata; /* no checks in this test */ (void) check_res; (void) buffer; return data_size; } struct lcurl_data_cb_param { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct lcurl_data_cb_param *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) externalErrorExit (); /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } struct check_uri_cls { const char *volatile uri; }; static void * check_uri_cb (void *cls, const char *uri, struct MHD_Connection *con) { struct check_uri_cls *param = (struct check_uri_cls *) cls; (void) con; if (0 != strcmp (param->uri, uri)) { fprintf (stderr, "Wrong URI: `%s', line: %d\n", uri, __LINE__); exit (22); } return NULL; } struct mhd_header_checker_param { int found_header1; int found_header2; int found_header4; }; static enum MHD_Result headerCheckerInterator (void *cls, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size) { struct mhd_header_checker_param *const param = (struct mhd_header_checker_param *) cls; if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); if (MHD_HEADER_KIND != kind) return MHD_YES; /* Continue iteration */ if (0 == key_size) mhdErrorExitDesc ("Zero key length"); if ((strlen (HEADER1_NAME) == key_size) && (0 == memcmp (key, HEADER1_NAME, key_size))) { if ((strlen (HEADER1_VALUE) == value_size) && (0 == memcmp (value, HEADER1_VALUE, value_size))) param->found_header1 = 1; else fprintf (stderr, "Unexpected header value: '%.*s', expected: '%s'\n", (int) value_size, value, HEADER1_VALUE); } else if ((strlen (HEADER2_NAME) == key_size) && (0 == memcmp (key, HEADER2_NAME, key_size))) { if ((strlen (HEADER2CR_VALUE) == value_size) && (0 == memcmp (value, HEADER2CR_VALUE, value_size))) param->found_header2 = 1; else fprintf (stderr, "Unexpected header value: '%.*s', expected: '%s'\n", (int) value_size, value, HEADER2CR_VALUE); } else if ((strlen (HEADER4_NAME) == key_size) && (0 == memcmp (key, HEADER4_NAME, key_size))) { if ((strlen (HEADER4_VALUE) == value_size) && (0 == memcmp (value, HEADER4_VALUE, value_size))) param->found_header4 = 1; else fprintf (stderr, "Unexpected header value: '%.*s', expected: '%s'\n", (int) value_size, value, HEADER4_VALUE); } return MHD_YES; } struct ahc_cls_type { const char *volatile rp_data; volatile size_t rp_data_size; struct mhd_header_checker_param header_check_param; const char *volatile rq_method; const char *volatile rq_url; }; static enum MHD_Result ahcCheck (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; struct ahc_cls_type *const param = (struct ahc_cls_type *) cls; if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); if (0 != strcmp (version, MHD_HTTP_VERSION_1_1)) mhdErrorExitDesc ("Unexpected HTTP version"); if (0 != strcmp (url, param->rq_url)) mhdErrorExitDesc ("Unexpected URI"); if (NULL != upload_data) mhdErrorExitDesc ("'upload_data' is not NULL"); if (NULL == upload_data_size) mhdErrorExitDesc ("'upload_data_size' pointer is NULL"); if (0 != *upload_data_size) mhdErrorExitDesc ("'*upload_data_size' value is not zero"); if (0 != strcmp (param->rq_method, method)) mhdErrorExitDesc ("Unexpected request method"); if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; if (1 > MHD_get_connection_values_n (connection, MHD_HEADER_KIND, &headerCheckerInterator, ¶m->header_check_param)) mhdErrorExitDesc ("Wrong number of headers in the request"); response = MHD_create_response_from_buffer_copy (param->rp_data_size, (const void *) param->rp_data); if (NULL == response) mhdErrorExitDesc ("Failed to create response"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (MHD_YES != ret) mhdErrorExitDesc ("Failed to queue response"); return ret; } struct curlQueryParams { /* Destination path for CURL query */ const char *queryPath; #if CURL_AT_LEAST_VERSION (7, 62, 0) CURLU *url; #endif /* CURL_AT_LEAST_VERSION(7, 62, 0) */ /* Custom query method, NULL for default */ const char *method; /* Destination port for CURL query */ uint16_t queryPort; /* List of additional request headers */ struct curl_slist *headers; /* CURL query result error flag */ volatile unsigned int queryError; /* Response HTTP code, zero if no response */ volatile int responseCode; }; static CURL * curlEasyInitForTest (struct curlQueryParams *p, struct lcurl_data_cb_param *dcbp, struct headers_check_result *hdr_chk_result) { CURL *c; c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, p->queryPath)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, (long) p->queryPort)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, dcbp)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, (long) response_timeout_val)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, (long) response_timeout_val)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HEADERFUNCTION, lcurl_hdr_callback)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HEADERDATA, hdr_chk_result)) || #if CURL_AT_LEAST_VERSION (7, 42, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PATH_AS_IS, (long) 1)) || #endif /* CURL_AT_LEAST_VERSION(7, 42, 0) */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); if (CURLE_OK != curl_easy_setopt (c, CURLOPT_CUSTOMREQUEST, p->method)) libcurlErrorExitDesc ("curl_easy_setopt() failed"); if (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPHEADER, p->headers)) libcurlErrorExitDesc ("curl_easy_setopt() failed"); #if CURL_AT_LEAST_VERSION (7, 62, 0) if (NULL != p->url) { if (CURLE_OK != curl_easy_setopt (c, CURLOPT_CURLU, p->url)) libcurlErrorExitDesc ("curl_easy_setopt() failed"); } #endif /* CURL_AT_LEAST_VERSION(7, 62, 0) */ return c; } static CURLcode performQueryExternal (struct MHD_Daemon *d, CURL *c) { CURLM *multi; time_t start; struct timeval tv; CURLcode ret; ret = CURLE_FAILED_INIT; /* will be replaced with real result */ multi = NULL; multi = curl_multi_init (); if (multi == NULL) libcurlErrorExitDesc ("curl_multi_init() failed"); if (CURLM_OK != curl_multi_add_handle (multi, c)) libcurlErrorExitDesc ("curl_multi_add_handle() failed"); start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; int running; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL != multi) { curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) libcurlErrorExitDesc ("curl_multi_info_read() failed"); totalMsgs++; if (CURLMSG_DONE == msg->msg) ret = msg->data.result; } while (msgLeft > 0); if (1 != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); externalErrorExit (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); multi = NULL; } else { if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) libcurlErrorExitDesc ("curl_multi_fdset() failed"); } } if (NULL == multi) { /* libcurl has finished, check whether MHD still needs to perform cleanup */ if (0 != MHD_get_timeout64s (d)) break; /* MHD finished as well */ } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); tv.tv_sec = 0; tv.tv_usec = 1000; #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep (1); #endif } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); } return ret; } /* Returns zero for successful response and non-zero for failed response */ static unsigned int doCurlQueryInThread (struct MHD_Daemon *d, struct curlQueryParams *p, struct headers_check_result *hdr_res, const char *expected_data, size_t expected_data_size) { const union MHD_DaemonInfo *dinfo; CURL *c; struct lcurl_data_cb_param dcbp; CURLcode errornum; int use_external_poll; long resp_code; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_FLAGS); if (NULL == dinfo) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); use_external_poll = (0 == (dinfo->flags & MHD_USE_INTERNAL_POLLING_THREAD)); if (NULL == p->queryPath #if CURL_AT_LEAST_VERSION (7, 62, 0) && NULL == p->url #endif /* CURL_AT_LEAST_VERSION(7, 62, 0) */ ) abort (); if (0 == p->queryPort) abort (); /* Test must not fail due to test's internal buffer shortage */ dcbp.size = expected_data_size * 2 + 1; dcbp.buf = malloc (dcbp.size); if (NULL == dcbp.buf) externalErrorExit (); dcbp.pos = 0; memset (hdr_res, 0, sizeof(*hdr_res)); c = curlEasyInitForTest (p, &dcbp, hdr_res); if (! use_external_poll) errornum = curl_easy_perform (c); else errornum = performQueryExternal (d, c); if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &resp_code)) libcurlErrorExitDesc ("curl_easy_getinfo() failed"); p->responseCode = (int) resp_code; if ((CURLE_OK == errornum) && (200 != resp_code)) { fprintf (stderr, "Got reply with unexpected status code: %d\n", p->responseCode); mhdErrorExit (); } if (CURLE_OK != errornum) { if ((CURLE_GOT_NOTHING != errornum) && (CURLE_RECV_ERROR != errornum) && (CURLE_HTTP_RETURNED_ERROR != errornum)) { if (CURLE_OPERATION_TIMEDOUT == errornum) mhdErrorExitDesc ("Request was aborted due to timeout"); fprintf (stderr, "libcurl returned unexpected error: %s\n", curl_easy_strerror (errornum)); mhdErrorExitDesc ("Request failed due to unexpected error"); } p->queryError = 1; if ((0 != resp_code) && ((499 < resp_code) || (400 > resp_code))) /* TODO: add all expected error codes */ { fprintf (stderr, "Got reply with unexpected status code: %ld\n", resp_code); mhdErrorExit (); } } else { if (dcbp.pos != expected_data_size) mhdErrorExit ("libcurl reports wrong size of MHD reply body data"); else if (0 != memcmp (expected_data, dcbp.buf, expected_data_size)) mhdErrorExit ("libcurl reports wrong MHD reply body data"); else p->queryError = 0; } curl_easy_cleanup (c); free (dcbp.buf); return p->queryError; } /* Perform test queries, shut down MHD daemon, and free parameters */ static unsigned int performTestQueries (struct MHD_Daemon *d, uint16_t d_port, struct ahc_cls_type *ahc_param, struct check_uri_cls *uri_cb_param) { struct curlQueryParams qParam; unsigned int ret = 0; /* Return value */ struct headers_check_result rp_headers_check; struct curl_slist *curl_headers; curl_headers = NULL; /* Common parameters, to be individually overridden by specific test cases */ qParam.queryPort = d_port; qParam.method = NULL; /* Use libcurl default: GET */ qParam.queryPath = URL_SCHEME_HOST EXPECTED_URI_BASE_PATH; #if CURL_AT_LEAST_VERSION (7, 62, 0) qParam.url = NULL; #endif /* CURL_AT_LEAST_VERSION(7, 62, 0) */ qParam.headers = NULL; /* No additional headers */ uri_cb_param->uri = EXPECTED_URI_BASE_PATH; ahc_param->rq_url = EXPECTED_URI_BASE_PATH; ahc_param->rq_method = "GET"; /* Default expected method */ ahc_param->rp_data = "~"; ahc_param->rp_data_size = 1; curl_headers = curl_slist_append (curl_headers, HEADER1); if (NULL == curl_headers) externalErrorExit (); curl_headers = curl_slist_append (curl_headers, HEADER4); if (NULL == curl_headers) externalErrorExit (); qParam.headers = curl_headers; memset (&ahc_param->header_check_param, 0, sizeof (ahc_param->header_check_param)); if (tricky_url) { #if CURL_AT_LEAST_VERSION (7, 62, 0) CURLU *url; url = curl_url (); if (NULL == url) externalErrorExit (); qParam.url = url; if ((CURLUE_OK != curl_url_set (qParam.url, CURLUPART_SCHEME, "http", 0)) || (CURLUE_OK != curl_url_set (qParam.url, CURLUPART_HOST, URL_HOST, CURLU_PATH_AS_IS #ifdef CURLU_ALLOW_SPACE | CURLU_ALLOW_SPACE #endif /* CURLU_ALLOW_SPACE */ )) || (CURLUE_OK != curl_url_set (qParam.url, CURLUPART_PATH, EXPECTED_URI_BASE_PATH_TRICKY, 0))) libcurlErrorExit (); qParam.queryPath = NULL; uri_cb_param->uri = EXPECTED_URI_BASE_PATH_TRICKY; ahc_param->rq_url = EXPECTED_URI_BASE_PATH_TRICKY; if (0 != doCurlQueryInThread (d, &qParam, &rp_headers_check, ahc_param->rp_data, ahc_param->rp_data_size)) { /* TODO: Allow fail only if relevant MHD mode set */ if (0 == qParam.responseCode) { fprintf (stderr, "Request failed without any valid response.\n"); ret = 1; } else { if (verbose) printf ("Request failed with %d response code.\n", qParam.responseCode); (void) qParam.responseCode; /* TODO: check for the right response code */ ret = 0; } } else { if (200 != qParam.responseCode) { fprintf (stderr, "Request succeed with wrong response code: %d.\n", qParam.responseCode); ret = 1; } else { ret = 0; if (verbose) printf ("Request succeed.\n"); } if (! ahc_param->header_check_param.found_header1) mhdErrorExitDesc ("Required header1 was not detected in request"); if (! ahc_param->header_check_param.found_header4) mhdErrorExitDesc ("Required header4 was not detected in request"); } curl_url_cleanup (url); #else fprintf (stderr, "This test requires libcurl version 7.62.0 or newer.\n"); abort (); #endif /* CURL_AT_LEAST_VERSION(7, 62, 0) */ } else if (tricky_header2) { /* Reset libcurl headers */ qParam.headers = NULL; curl_slist_free_all (curl_headers); curl_headers = NULL; /* Set special libcurl headers */ curl_headers = curl_slist_append (curl_headers, HEADER1); if (NULL == curl_headers) externalErrorExit (); curl_headers = curl_slist_append (curl_headers, HEADER2CR); if (NULL == curl_headers) externalErrorExit (); curl_headers = curl_slist_append (curl_headers, HEADER4); if (NULL == curl_headers) externalErrorExit (); qParam.headers = curl_headers; if (0 != doCurlQueryInThread (d, &qParam, &rp_headers_check, ahc_param->rp_data, ahc_param->rp_data_size)) { /* TODO: Allow fail only if relevant MHD mode set */ if (0 == qParam.responseCode) { fprintf (stderr, "Request failed without any valid response.\n"); ret = 1; } else { if (verbose) printf ("Request failed with %d response code.\n", qParam.responseCode); (void) qParam.responseCode; /* TODO: check for the right response code */ ret = 0; } } else { if (200 != qParam.responseCode) { fprintf (stderr, "Request succeed with wrong response code: %d.\n", qParam.responseCode); ret = 1; } else { ret = 0; if (verbose) printf ("Request succeed.\n"); } if (! ahc_param->header_check_param.found_header1) mhdErrorExitDesc ("Required header1 was not detected in request"); if (! ahc_param->header_check_param.found_header2) mhdErrorExitDesc ("Required header2 was not detected in request"); if (! ahc_param->header_check_param.found_header4) mhdErrorExitDesc ("Required header4 was not detected in request"); } } else externalErrorExitDesc ("No valid test test was selected"); MHD_stop_daemon (d); curl_slist_free_all (curl_headers); free (uri_cb_param); free (ahc_param); return ret; } enum testMhdThreadsType { testMhdThreadExternal = 0, testMhdThreadInternal = MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPerConnection = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPool }; enum testMhdPollType { testMhdPollBySelect = 0, testMhdPollByPoll = MHD_USE_POLL, testMhdPollByEpoll = MHD_USE_EPOLL, testMhdPollAuto = MHD_USE_AUTO }; /* Get number of threads for thread pool depending * on used poll function and test type. */ static unsigned int testNumThreadsForPool (enum testMhdPollType pollType) { unsigned int numThreads = MHD_CPU_COUNT; (void) pollType; /* Don't care about pollType for this test */ return numThreads; /* No practical limit for non-cleanup test */ } static struct MHD_Daemon * startTestMhdDaemon (enum testMhdThreadsType thrType, enum testMhdPollType pollType, uint16_t *pport, struct ahc_cls_type **ahc_param, struct check_uri_cls **uri_cb_param) { struct MHD_Daemon *d; const union MHD_DaemonInfo *dinfo; if ((NULL == ahc_param) || (NULL == uri_cb_param)) abort (); *ahc_param = (struct ahc_cls_type *) malloc (sizeof(struct ahc_cls_type)); if (NULL == *ahc_param) externalErrorExit (); *uri_cb_param = (struct check_uri_cls *) malloc (sizeof(struct check_uri_cls)); if (NULL == *uri_cb_param) externalErrorExit (); if ( (0 == *pport) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { *pport = 4150; if (tricky_url) *pport += 1; if (tricky_header2) *pport += 2; if (! oneone) *pport += 16; } if (testMhdThreadExternal == thrType) d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0) | MHD_USE_NO_THREAD_SAFETY, *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_URI_LOG_CALLBACK, &check_uri_cb, *uri_cb_param, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); else if (testMhdThreadInternalPool != thrType) d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0), *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_URI_LOG_CALLBACK, &check_uri_cb, *uri_cb_param, MHD_OPTION_END); else d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | ((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0), *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_THREAD_POOL_SIZE, testNumThreadsForPool (pollType), MHD_OPTION_URI_LOG_CALLBACK, &check_uri_cb, *uri_cb_param, MHD_OPTION_END); if (NULL == d) { fprintf (stderr, "Failed to start MHD daemon, errno=%d.\n", errno); abort (); } if (0 == *pport) { dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { fprintf (stderr, "MHD_get_daemon_info() failed.\n"); abort (); } *pport = dinfo->port; if (0 == global_port) global_port = *pport; /* Reuse the same port for all tests */ } return d; } /* Test runners */ static unsigned int testExternalGet (void) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; d = startTestMhdDaemon (testMhdThreadExternal, testMhdPollBySelect, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param); } static unsigned int testInternalGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; d = startTestMhdDaemon (testMhdThreadInternal, pollType, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param); } static unsigned int testMultithreadedGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; d = startTestMhdDaemon (testMhdThreadInternalPerConnection, pollType, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param); } static unsigned int testMultithreadedPoolGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; d = startTestMhdDaemon (testMhdThreadInternalPool, pollType, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param); } int main (int argc, char *const *argv) { unsigned int errorCount = 0; unsigned int test_result = 0; verbose = 0; if ((NULL == argv) || (0 == argv[0])) return 99; oneone = ! has_in_name (argv[0], "10"); tricky_url = has_in_name (argv[0], "_url") ? 1 : 0; tricky_header2 = has_in_name (argv[0], "_header2") ? 1 : 0; if (1 != tricky_url + tricky_header2) return 99; verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); #if ! CURL_AT_LEAST_VERSION (7, 62, 0) if (tricky_url) { fprintf (stderr, "This test requires libcurl version 7.62.0 or newer.\n"); return 77; } #endif /* ! CURL_AT_LEAST_VERSION(7, 62, 0) */ test_global_init (); /* Could be set to non-zero value to enforce using specific port * in the test */ global_port = 0; test_result = testExternalGet (); if (test_result) fprintf (stderr, "FAILED: testExternalGet () - %u.\n", test_result); else if (verbose) printf ("PASSED: testExternalGet ().\n"); errorCount += test_result; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { test_result = testInternalGet (testMhdPollAuto); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollAuto) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollBySelect).\n"); errorCount += test_result; #ifdef _MHD_HEAVY_TESTS /* Actually tests are not heavy, but took too long to complete while * not really provide any additional results. */ test_result = testInternalGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedPoolGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedGet (testMhdPollBySelect).\n"); errorCount += test_result; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { test_result = testInternalGet (testMhdPollByPoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByPoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByPoll).\n"); errorCount += test_result; } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { test_result = testInternalGet (testMhdPollByEpoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByEpoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByEpoll).\n"); errorCount += test_result; } #else /* Mute compiler warnings */ (void) testMultithreadedGet; (void) testMultithreadedPoolGet; #endif /* _MHD_HEAVY_TESTS */ } if (0 != errorCount) fprintf (stderr, "Error (code: %u)\n", errorCount); else if (verbose) printf ("All tests passed.\n"); test_global_cleanup (); return (errorCount == 0) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_get_chunked.c0000644000175000017500000005305314556013673016175 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_get_chunked.c * @brief Testcase for libmicrohttpd GET operations with chunked content encoding * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #ifndef WINDOWS #include #endif #include "mhd_has_in_name.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #define HDR_CHUNKED_ENCODING MHD_HTTP_HEADER_TRANSFER_ENCODING ": chunked" #define RESP_FOOTER_NAME "Footer" #define RESP_FOOTER_VALUE "working" #define RESP_FOOTER RESP_FOOTER_NAME ": " RESP_FOOTER_VALUE #define RESP_BLOCK_SIZE 128 #define RESP_BLOCK_QUANTIY 10 #define RESP_SIZE (RESP_BLOCK_SIZE * RESP_BLOCK_QUANTIY) /** * Use "Connection: close" header? */ static int conn_close; /** * Use static string response instead of callback-generated? */ static int resp_string; /** * Use response with known size? */ static int resp_sized; /** * Use empty (zero-sized) response? */ static int resp_empty; /** * Force chunked response by response header? */ static int chunked_forced; /** * MHD port used for testing */ static uint16_t port_global; struct headers_check_result { int found_chunked; int found_footer; }; static size_t lcurl_hdr_callback (char *buffer, size_t size, size_t nitems, void *userdata) { const size_t data_size = size * nitems; struct headers_check_result *check_res = (struct headers_check_result *) userdata; if ((data_size == strlen (HDR_CHUNKED_ENCODING) + 2) && (0 == memcmp (buffer, HDR_CHUNKED_ENCODING "\r\n", data_size))) check_res->found_chunked = 1; if ((data_size == strlen (RESP_FOOTER) + 2) && (0 == memcmp (buffer, RESP_FOOTER "\r\n", data_size))) check_res->found_footer = 1; return data_size; } struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } /** * MHD content reader callback that returns data in chunks. */ static ssize_t crc (void *cls, uint64_t pos, char *buf, size_t max) { struct MHD_Response **responseptr = cls; if (resp_empty || (pos == RESP_SIZE - RESP_BLOCK_SIZE)) { /* Add footer with the last block */ if (MHD_YES != MHD_add_response_footer (*responseptr, RESP_FOOTER_NAME, RESP_FOOTER_VALUE)) abort (); } if (resp_empty || (pos == RESP_SIZE)) return MHD_CONTENT_READER_END_OF_STREAM; if (max < RESP_BLOCK_SIZE) abort (); /* should not happen in this testcase... */ memset (buf, 'A' + (char) (unsigned char) (pos / RESP_BLOCK_SIZE), RESP_BLOCK_SIZE); return RESP_BLOCK_SIZE; } /** * Dummy function that frees the "responseptr". */ static void crcf (void *ptr) { free (ptr); } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } if (! resp_string) { struct MHD_Response **responseptr; responseptr = malloc (sizeof (struct MHD_Response *)); if (NULL == responseptr) _exit (99); response = MHD_create_response_from_callback (resp_sized ? RESP_SIZE : MHD_SIZE_UNKNOWN, 1024, &crc, responseptr, &crcf); *responseptr = response; } else { if (! resp_empty) { size_t pos; static const size_t resp_size = RESP_SIZE; char *buf = malloc (resp_size); if (NULL == buf) _exit (99); for (pos = 0; pos < resp_size; pos += RESP_BLOCK_SIZE) memset (buf + pos, 'A' + (char) (unsigned char) (pos / RESP_BLOCK_SIZE), RESP_BLOCK_SIZE); response = MHD_create_response_from_buffer_copy (resp_size, buf); free (buf); } else response = MHD_create_response_empty (MHD_RF_NONE); } if (NULL == response) abort (); if (chunked_forced) { if (MHD_NO == MHD_add_response_header (response, MHD_HTTP_HEADER_TRANSFER_ENCODING, "chunked")) abort (); } if (MHD_NO == MHD_add_response_header (response, MHD_HTTP_HEADER_TRAILER, RESP_FOOTER_NAME)) abort (); if (resp_string || (resp_sized && resp_empty)) { /* There is no chance to add footer later */ if (MHD_YES != MHD_add_response_footer (response, RESP_FOOTER_NAME, RESP_FOOTER_VALUE)) abort (); } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int validate (struct CBC cbc, unsigned int ebase) { int i; char buf[RESP_BLOCK_SIZE]; if (resp_empty) { if (0 != cbc.pos) { fprintf (stderr, "Got %u bytes instead of zero!\n", (unsigned int) cbc.pos); return 1; } return 0; } if (cbc.pos != RESP_SIZE) { fprintf (stderr, "Got %u bytes instead of 1280!\n", (unsigned int) cbc.pos); return ebase; } for (i = 0; i < RESP_BLOCK_QUANTIY; i++) { memset (buf, 'A' + i, RESP_BLOCK_SIZE); if (0 != memcmp (buf, &cbc.buf[i * RESP_BLOCK_SIZE], RESP_BLOCK_SIZE)) { fprintf (stderr, "Got `%.*s'\nWant `%.*s'\n", RESP_BLOCK_SIZE, &cbc.buf[i * RESP_BLOCK_SIZE], RESP_BLOCK_SIZE, buf); return ebase * 2; } } return 0; } static unsigned int testInternalGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; struct curl_slist *h_list = NULL; struct headers_check_result hdr_check; port = port_global; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; if (0 == port_global) port_global = port; /* Re-use the same port for all checks */ } hdr_check.found_chunked = 0; hdr_check.found_footer = 0; c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_HEADERFUNCTION, lcurl_hdr_callback); curl_easy_setopt (c, CURLOPT_HEADERDATA, &hdr_check); curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (conn_close) { h_list = curl_slist_append (h_list, "Connection: close"); if (NULL == h_list) abort (); curl_easy_setopt (c, CURLOPT_HTTPHEADER, h_list); } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); curl_slist_free_all (h_list); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); curl_slist_free_all (h_list); MHD_stop_daemon (d); if (1 != hdr_check.found_chunked) { fprintf (stderr, "Chunked encoding header was not found in the response\n"); return 8; } if (1 != hdr_check.found_footer) { fprintf (stderr, "The specified footer was not found in the response\n"); return 16; } return validate (cbc, 4); } static unsigned int testMultithreadedGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; struct curl_slist *h_list = NULL; struct headers_check_result hdr_check; port = port_global; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; if (0 == port_global) port_global = port; /* Re-use the same port for all checks */ } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); hdr_check.found_chunked = 0; hdr_check.found_footer = 0; curl_easy_setopt (c, CURLOPT_HEADERFUNCTION, lcurl_hdr_callback); curl_easy_setopt (c, CURLOPT_HEADERDATA, &hdr_check); if (conn_close) { h_list = curl_slist_append (h_list, "Connection: close"); if (NULL == h_list) abort (); curl_easy_setopt (c, CURLOPT_HTTPHEADER, h_list); } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); curl_slist_free_all (h_list); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); curl_slist_free_all (h_list); MHD_stop_daemon (d); if (1 != hdr_check.found_chunked) { fprintf (stderr, "Chunked encoding header was not found in the response\n"); return 8; } if (1 != hdr_check.found_footer) { fprintf (stderr, "The specified footer was not found in the response\n"); return 16; } return validate (cbc, 64); } static unsigned int testMultithreadedPoolGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; struct curl_slist *h_list = NULL; struct headers_check_result hdr_check; port = port_global; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; if (0 == port_global) port_global = port; /* Re-use the same port for all checks */ } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); hdr_check.found_chunked = 0; hdr_check.found_footer = 0; curl_easy_setopt (c, CURLOPT_HEADERFUNCTION, lcurl_hdr_callback); curl_easy_setopt (c, CURLOPT_HEADERDATA, &hdr_check); if (conn_close) { h_list = curl_slist_append (h_list, "Connection: close"); if (NULL == h_list) abort (); curl_easy_setopt (c, CURLOPT_HTTPHEADER, h_list); } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); curl_slist_free_all (h_list); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); curl_slist_free_all (h_list); MHD_stop_daemon (d); if (1 != hdr_check.found_chunked) { fprintf (stderr, "Chunked encoding header was not found in the response\n"); return 8; } if (1 != hdr_check.found_footer) { fprintf (stderr, "The specified footer was not found in the response\n"); return 16; } return validate (cbc, 64); } static unsigned int testExternalGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; uint16_t port; struct curl_slist *h_list = NULL; struct headers_check_result hdr_check; port = port_global; multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; if (0 == port_global) port_global = port; /* Re-use the same port for all checks */ } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 5L); curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); hdr_check.found_chunked = 0; hdr_check.found_footer = 0; curl_easy_setopt (c, CURLOPT_HEADERFUNCTION, lcurl_hdr_callback); curl_easy_setopt (c, CURLOPT_HEADERDATA, &hdr_check); if (conn_close) { h_list = curl_slist_append (h_list, "Connection: close"); if (NULL == h_list) abort (); curl_easy_setopt (c, CURLOPT_HTTPHEADER, h_list); } multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); curl_slist_free_all (h_list); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); curl_slist_free_all (h_list); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); curl_slist_free_all (h_list); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); curl_slist_free_all (h_list); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); curl_slist_free_all (h_list); h_list = NULL; c = NULL; multi = NULL; } MHD_run (d); } MHD_stop_daemon (d); if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } curl_slist_free_all (h_list); if (1 != hdr_check.found_chunked) { fprintf (stderr, "Chunked encoding header was not found in the response\n"); return 8; } if (1 != hdr_check.found_footer) { fprintf (stderr, "The specified footer was not found in the response\n"); return 16; } return validate (cbc, 8192); } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; conn_close = has_in_name (argv[0], "_close"); resp_string = has_in_name (argv[0], "_string"); resp_sized = has_in_name (argv[0], "_sized"); resp_empty = has_in_name (argv[0], "_empty"); chunked_forced = has_in_name (argv[0], "_forced"); if (resp_string) resp_sized = ! 0; if (resp_sized) chunked_forced = ! 0; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port_global = 0; else { port_global = 4100; if (conn_close) port_global += 1 << 0; if (resp_string) port_global += 1 << 1; if (resp_sized) port_global += 1 << 2; if (resp_empty) port_global += 1 << 3; if (chunked_forced) port_global += 1 << 4; } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalGet (); errorCount += testMultithreadedGet (); errorCount += testMultithreadedPoolGet (); } errorCount += testExternalGet (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_digestauth2.c0000644000175000017500000015247714556230011016135 /* This file is part of libmicrohttpd Copyright (C) 2010 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_digest2.c * @brief Testcase for MHD Digest Authorisation * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #if defined(MHD_HTTPS_REQUIRE_GCRYPT) && \ (defined(MHD_SHA256_TLSLIB) || defined(MHD_MD5_TLSLIB)) #define NEED_GCRYP_INIT 1 #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT && (MHD_SHA256_TLSLIB || MHD_MD5_TLSLIB) */ #ifndef _WIN32 #include #include #else #include #endif #include "mhd_has_param.h" #include "mhd_has_in_name.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __func__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func (NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func (NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func (NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func (errDesc, NULL, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), NULL, \ __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } /* Not actually used in this test */ static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (8); } #if 0 /* Function unused in this test */ static void _checkCURLE_OK_func (CURLcode code, const char *curlFunc, const char *funcName, int lineNum) { if (CURLE_OK == code) return; fflush (stdout); if ((NULL != curlFunc) && (0 != curlFunc[0])) fprintf (stderr, "'%s' resulted in '%s'", curlFunc, curl_easy_strerror (code)); else fprintf (stderr, "libcurl function call resulted in '%s'", curl_easy_strerror (code)); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (9); } #endif /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 10 #define MHD_URI_BASE_PATH "/bar%20foo?key=value" #define MHD_URI_BASE_PATH2 "/another_path" /* Should not fit buffer in the stack */ #define MHD_URI_BASE_PATH3 \ "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \ "/path?with%20some=parameters" #define REALM_VAL "TestRealm" #define USERNAME1 "test_user" /* The hex form of MD5("test_user:TestRealm") */ #define USERHASH1_MD5_HEX "c53c601503ff176f18f623725fba4281" #define USERHASH1_MD5_BIN 0xc5, 0x3c, 0x60, 0x15, 0x03, 0xff, 0x17, 0x6f, \ 0x18, 0xf6, 0x23, 0x72, 0x5f, 0xba, 0x42, 0x81 /* The hex form of SHA-256("test_user:TestRealm") */ #define USERHASH1_SHA256_HEX \ "090c7e06b77d6614cf5fe6cafa004d2e5f8fb36ba45a0e35eacb2eb7728f34de" /* The binary form of SHA-256("test_user:TestRealm") */ #define USERHASH1_SHA256_BIN 0x09, 0x0c, 0x7e, 0x06, 0xb7, 0x7d, 0x66, 0x14, \ 0xcf, 0x5f, 0xe6, 0xca, 0xfa, 0x00, 0x4d, 0x2e, 0x5f, 0x8f, 0xb3, 0x6b, \ 0xa4, 0x5a, 0x0e, 0x35, 0xea, 0xcb, 0x2e, 0xb7, 0x72, 0x8f, 0x34, 0xde /* The hex form of MD5("test_user:TestRealm:test pass") */ #define USERDIGEST1_MD5_BIN 0xd8, 0xb4, 0xa6, 0xd0, 0x01, 0x13, 0x07, 0xb7, \ 0x67, 0x94, 0xea, 0x66, 0x86, 0x03, 0x6b, 0x43 /* The binary form of SHA-256("test_user:TestRealm:test pass") */ #define USERDIGEST1_SHA256_BIN 0xc3, 0x4e, 0x16, 0x5a, 0x17, 0x0f, 0xe5, \ 0xac, 0x04, 0xf1, 0x6e, 0x46, 0x48, 0x2b, 0xa0, 0xc6, 0x56, 0xc1, 0xfb, \ 0x8f, 0x66, 0xa6, 0xd6, 0x3f, 0x91, 0x12, 0xf8, 0x56, 0xa5, 0xec, 0x6d, \ 0x6d #define PASSWORD_VALUE "test pass" #define OPAQUE_VALUE "opaque+content" /* Base64 character set */ #define PAGE \ "libmicrohttpd demo page" \ "Access granted" #define DENIED \ "libmicrohttpd - Access denied" \ "Access denied" /* Global parameters */ static int verbose; static int test_oldapi; static int test_userhash; static int test_userdigest; static int test_sha256; static int test_rfc2069; /* Bind DAuth nonces to everything except URI */ static int test_bind_all; /* Bind DAuth nonces to URI */ static int test_bind_uri; static int curl_uses_usehash; /* Static helper variables */ static const char userhash1_md5_hex[] = USERHASH1_MD5_HEX; static const uint8_t userhash1_md5_bin[] = { USERHASH1_MD5_BIN }; static const char userhash1_sha256_hex[] = USERHASH1_SHA256_HEX; static const uint8_t userhash1_sha256_bin[] = { USERHASH1_SHA256_BIN }; static const char *userhash_hex; static size_t userhash_hex_len; static const uint8_t *userhash_bin; static const uint8_t userdigest1_md5_bin[] = { USERDIGEST1_MD5_BIN }; static const uint8_t userdigest1_sha256_bin[] = { USERDIGEST1_SHA256_BIN }; static const uint8_t *userdigest_bin; static size_t userdigest_bin_size; static const char *username_ptr; static void test_global_init (void) { libcurl_errbuf[0] = 0; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) externalErrorExit (); username_ptr = USERNAME1; if (! test_sha256) { userhash_hex = userhash1_md5_hex; userhash_hex_len = MHD_STATICSTR_LEN_ (userhash1_md5_hex); userhash_bin = userhash1_md5_bin; if ((userhash_hex_len / 2) != \ (sizeof(userhash1_md5_bin) / sizeof(userhash1_md5_bin[0]))) externalErrorExitDesc ("Wrong size of the 'userhash1_md5_bin' array"); userdigest_bin = userdigest1_md5_bin; userdigest_bin_size = (sizeof(userdigest1_md5_bin) / sizeof(userdigest1_md5_bin[0])); } else { userhash_hex = userhash1_sha256_hex; userhash_hex_len = MHD_STATICSTR_LEN_ (userhash1_sha256_hex); userhash_bin = userhash1_sha256_bin; if ((userhash_hex_len / 2) != \ (sizeof(userhash1_sha256_bin) \ / sizeof(userhash1_sha256_bin[0]))) externalErrorExitDesc ("Wrong size of the 'userhash1_sha256_bin' array"); userdigest_bin = userdigest1_sha256_bin; userdigest_bin_size = (sizeof(userdigest1_sha256_bin) / sizeof(userdigest1_sha256_bin[0])); } } static void test_global_cleanup (void) { curl_global_cleanup (); } static int gen_good_rnd (void *rnd_buf, size_t rnd_buf_size) { if (1024 < rnd_buf_size) externalErrorExitDesc ("Too large amount of random data " \ "is requested"); #ifndef _WIN32 if (1) { const int urand_fd = open ("/dev/urandom", O_RDONLY); if (0 <= urand_fd) { size_t pos = 0; do { ssize_t res = read (urand_fd, ((uint8_t *) rnd_buf) + pos, rnd_buf_size - pos); if (0 > res) break; pos += (size_t) res; } while (rnd_buf_size > pos); (void) close (urand_fd); if (rnd_buf_size == pos) return ! 0; /* Success */ } } #else /* _WIN32 */ if (1) { HCRYPTPROV cpr_hndl; if (CryptAcquireContextW (&cpr_hndl, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { if (CryptGenRandom (cpr_hndl, (DWORD) rnd_buf_size, (BYTE *) rnd_buf)) { (void) CryptReleaseContext (cpr_hndl, 0); return ! 0; /* Success */ } (void) CryptReleaseContext (cpr_hndl, 0); } } #endif /* _WIN32 */ return 0; /* Failure */ } struct CBC { char *buf; size_t pos; size_t size; }; struct req_track { /** * The number of used URI, zero-based */ unsigned int uri_num; /** * The number of request for URI. * This includes number of unauthorised requests. */ unsigned int req_num; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) mhdErrorExitDesc ("Wrong too large data"); /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result res; static int already_called_marker; struct req_track *const tr_p = (struct req_track *) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (&already_called_marker != *req_cls) { /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; } if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) mhdErrorExitDesc ("Unexpected HTTP method"); tr_p->req_num++; if (2 < tr_p->req_num) mhdErrorExitDesc ("Received more than two requests for the same URI"); response = NULL; if (! test_oldapi) { struct MHD_DigestAuthInfo *dinfo; const enum MHD_DigestAuthAlgo3 algo3 = test_sha256 ? MHD_DIGEST_AUTH_ALGO3_SHA256 : MHD_DIGEST_AUTH_ALGO3_MD5; const enum MHD_DigestAuthQOP qop = test_rfc2069 ? MHD_DIGEST_AUTH_QOP_NONE : MHD_DIGEST_AUTH_QOP_AUTH; dinfo = MHD_digest_auth_get_request_info3 (connection); if (NULL != dinfo) { /* Got any kind of Digest response. Check it, it must be valid */ struct MHD_DigestAuthUsernameInfo *uname; enum MHD_DigestAuthResult check_res; enum MHD_DigestAuthResult expect_res; if (curl_uses_usehash) { if (MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH != dinfo->uname_type) { fprintf (stderr, "Unexpected 'uname_type'.\n" "Expected: %d\tRecieved: %d. ", (int) MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH, (int) dinfo->uname_type); mhdErrorExitDesc ("Wrong 'uname_type'"); } else if (dinfo->userhash_hex_len != userhash_hex_len) { fprintf (stderr, "'userhash_hex_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) userhash_hex_len, (unsigned) dinfo->userhash_hex_len); mhdErrorExitDesc ("Wrong 'userhash_hex_len'"); } else if (0 != memcmp (dinfo->userhash_hex, userhash_hex, dinfo->userhash_hex_len)) { fprintf (stderr, "'userhash_hex' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", userhash_hex, (int) dinfo->userhash_hex_len, dinfo->userhash_hex); mhdErrorExitDesc ("Wrong 'userhash_hex'"); } else if (NULL == dinfo->userhash_bin) mhdErrorExitDesc ("'userhash_bin' is NULL"); else if (0 != memcmp (dinfo->userhash_bin, userhash_bin, dinfo->username_len / 2)) mhdErrorExitDesc ("Wrong 'userhash_bin'"); else if (NULL != dinfo->username) mhdErrorExitDesc ("'username' is NOT NULL"); else if (0 != dinfo->username_len) mhdErrorExitDesc ("'username_len' is NOT zero"); } else { if (MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD != dinfo->uname_type) { fprintf (stderr, "Unexpected 'uname_type'.\n" "Expected: %d\tRecieved: %d. ", (int) MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD, (int) dinfo->uname_type); mhdErrorExitDesc ("Wrong 'uname_type'"); } else if (NULL == dinfo->username) mhdErrorExitDesc ("'username' is NULL"); else if (dinfo->username_len != strlen (username_ptr)) { fprintf (stderr, "'username_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) strlen (username_ptr), (unsigned) dinfo->username_len); mhdErrorExitDesc ("Wrong 'username_len'"); } else if (0 != memcmp (dinfo->username, username_ptr, dinfo->username_len)) { fprintf (stderr, "'username' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", username_ptr, (int) dinfo->username_len, dinfo->username); mhdErrorExitDesc ("Wrong 'username'"); } else if (NULL != dinfo->userhash_hex) mhdErrorExitDesc ("'userhash_hex' is NOT NULL"); else if (0 != dinfo->userhash_hex_len) mhdErrorExitDesc ("'userhash_hex_len' is NOT zero"); else if (NULL != dinfo->userhash_bin) mhdErrorExitDesc ("'userhash_bin' is NOT NULL"); } if (algo3 != dinfo->algo3) { fprintf (stderr, "Unexpected 'algo3'.\n" "Expected: %d\tRecieved: %d. ", (int) algo3, (int) dinfo->algo3); mhdErrorExitDesc ("Wrong 'algo3'"); } if (! test_rfc2069) { if ( #if CURL_AT_LEAST_VERSION (7,37,1) 10 >= dinfo->cnonce_len #else /* libcurl before 7.37.1 */ 8 > dinfo->cnonce_len #endif /* libcurl before 7.37.1 */ ) { fprintf (stderr, "Unexpected small 'cnonce_len': %ld. ", (long) dinfo->cnonce_len); mhdErrorExitDesc ("Wrong 'cnonce_len'"); } } else { if (0 != dinfo->cnonce_len) { fprintf (stderr, "'cnonce_len' is not zero: %ld. ", (long) dinfo->cnonce_len); mhdErrorExitDesc ("Wrong 'cnonce_len'"); } } if (NULL == dinfo->opaque) mhdErrorExitDesc ("'opaque' is NULL"); else if (dinfo->opaque_len != MHD_STATICSTR_LEN_ (OPAQUE_VALUE)) { fprintf (stderr, "'opaque_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) MHD_STATICSTR_LEN_ (OPAQUE_VALUE), (unsigned) dinfo->opaque_len); mhdErrorExitDesc ("Wrong 'opaque_len'"); } else if (0 != memcmp (dinfo->opaque, OPAQUE_VALUE, dinfo->opaque_len)) { fprintf (stderr, "'opaque' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", OPAQUE_VALUE, (int) dinfo->opaque_len, dinfo->opaque); mhdErrorExitDesc ("Wrong 'opaque'"); } else if (qop != dinfo->qop) { fprintf (stderr, "Unexpected 'qop'.\n" "Expected: %d\tRecieved: %d. ", (int) qop, (int) dinfo->qop); mhdErrorExitDesc ("Wrong 'qop'"); } else if (NULL == dinfo->realm) mhdErrorExitDesc ("'realm' is NULL"); else if (dinfo->realm_len != MHD_STATICSTR_LEN_ (REALM_VAL)) { fprintf (stderr, "'realm_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) MHD_STATICSTR_LEN_ (REALM_VAL), (unsigned) dinfo->realm_len); mhdErrorExitDesc ("Wrong 'realm_len'"); } else if (0 != memcmp (dinfo->realm, REALM_VAL, dinfo->realm_len)) { fprintf (stderr, "'realm' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", OPAQUE_VALUE, (int) dinfo->realm_len, dinfo->realm); mhdErrorExitDesc ("Wrong 'realm'"); } MHD_free (dinfo); uname = MHD_digest_auth_get_username3 (connection); if (NULL == uname) mhdErrorExitDesc ("MHD_digest_auth_get_username3() returned NULL"); if (curl_uses_usehash) { if (MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH != uname->uname_type) { fprintf (stderr, "Unexpected 'uname_type'.\n" "Expected: %d\tRecieved: %d. ", (int) MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH, (int) uname->uname_type); mhdErrorExitDesc ("Wrong 'uname_type'"); } else if (uname->userhash_hex_len != userhash_hex_len) { fprintf (stderr, "'userhash_hex_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) userhash_hex_len, (unsigned) uname->userhash_hex_len); mhdErrorExitDesc ("Wrong 'userhash_hex_len'"); } else if (0 != memcmp (uname->userhash_hex, userhash_hex, uname->userhash_hex_len)) { fprintf (stderr, "'username' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", userhash_hex, (int) uname->userhash_hex_len, uname->userhash_hex); mhdErrorExitDesc ("Wrong 'userhash_hex'"); } else if (NULL == uname->userhash_bin) mhdErrorExitDesc ("'userhash_bin' is NULL"); else if (0 != memcmp (uname->userhash_bin, userhash_bin, uname->username_len / 2)) mhdErrorExitDesc ("Wrong 'userhash_bin'"); else if (NULL != uname->username) mhdErrorExitDesc ("'username' is NOT NULL"); else if (0 != uname->username_len) mhdErrorExitDesc ("'username_len' is NOT zero"); } else { if (MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD != uname->uname_type) { fprintf (stderr, "Unexpected 'uname_type'.\n" "Expected: %d\tRecieved: %d. ", (int) MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD, (int) uname->uname_type); mhdErrorExitDesc ("Wrong 'uname_type'"); } else if (NULL == uname->username) mhdErrorExitDesc ("'username' is NULL"); else if (uname->username_len != strlen (username_ptr)) { fprintf (stderr, "'username_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) strlen (username_ptr), (unsigned) uname->username_len); mhdErrorExitDesc ("Wrong 'username_len'"); } else if (0 != memcmp (uname->username, username_ptr, uname->username_len)) { fprintf (stderr, "'username' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", username_ptr, (int) uname->username_len, uname->username); mhdErrorExitDesc ("Wrong 'username'"); } else if (NULL != uname->userhash_hex) mhdErrorExitDesc ("'userhash_hex' is NOT NULL"); else if (0 != uname->userhash_hex_len) mhdErrorExitDesc ("'userhash_hex_len' is NOT zero"); else if (NULL != uname->userhash_bin) mhdErrorExitDesc ("'userhash_bin' is NOT NULL"); } if (algo3 != uname->algo3) { fprintf (stderr, "Unexpected 'algo3'.\n" "Expected: %d\tRecieved: %d. ", (int) algo3, (int) uname->algo3); mhdErrorExitDesc ("Wrong 'algo3'"); } MHD_free (uname); if (! test_userdigest) check_res = MHD_digest_auth_check3 (connection, REALM_VAL, username_ptr, PASSWORD_VALUE, 50 * TIMEOUTS_VAL, 0, (enum MHD_DigestAuthMultiQOP) qop, (enum MHD_DigestAuthMultiAlgo3) algo3); else check_res = MHD_digest_auth_check_digest3 (connection, REALM_VAL, username_ptr, userdigest_bin, userdigest_bin_size, 50 * TIMEOUTS_VAL, 0, (enum MHD_DigestAuthMultiQOP) qop, (enum MHD_DigestAuthMultiAlgo3) algo3); if (test_rfc2069) { if ((0 != tr_p->uri_num) && (1 == tr_p->req_num)) expect_res = MHD_DAUTH_NONCE_STALE; else expect_res = MHD_DAUTH_OK; } else if (test_bind_uri) { if ((0 != tr_p->uri_num) && (1 == tr_p->req_num)) expect_res = MHD_DAUTH_NONCE_OTHER_COND; else expect_res = MHD_DAUTH_OK; } else expect_res = MHD_DAUTH_OK; switch (check_res) { /* Conditionally valid results */ case MHD_DAUTH_OK: if (expect_res == MHD_DAUTH_OK) { if (verbose) printf ("Got valid auth check result: MHD_DAUTH_OK.\n"); } else mhdErrorExitDesc ("MHD_digest_auth_check[_digest]3()' returned " \ "MHD_DAUTH_OK"); break; case MHD_DAUTH_NONCE_STALE: if (expect_res == MHD_DAUTH_NONCE_STALE) { if (verbose) printf ("Got expected auth check result: MHD_DAUTH_NONCE_STALE.\n"); } else mhdErrorExitDesc ("MHD_digest_auth_check[_digest]3()' returned " \ "MHD_DAUTH_NONCE_STALE"); break; case MHD_DAUTH_NONCE_OTHER_COND: if (expect_res == MHD_DAUTH_NONCE_OTHER_COND) { if (verbose) printf ("Got expected auth check result: " "MHD_DAUTH_NONCE_OTHER_COND.\n"); } else mhdErrorExitDesc ("MHD_digest_auth_check[_digest]3()' returned " \ "MHD_DAUTH_NONCE_OTHER_COND"); break; /* Invalid results */ case MHD_DAUTH_NONCE_WRONG: mhdErrorExitDesc ("MHD_digest_auth_check[_digest]3()' returned " \ "MHD_DAUTH_NONCE_WRONG"); break; case MHD_DAUTH_ERROR: externalErrorExitDesc ("General error returned " \ "by 'MHD_digest_auth_check[_digest]3()'"); break; case MHD_DAUTH_WRONG_USERNAME: mhdErrorExitDesc ("MHD_digest_auth_check[_digest]3()' returned " \ "MHD_DAUTH_WRONG_USERNAME"); break; case MHD_DAUTH_RESPONSE_WRONG: mhdErrorExitDesc ("MHD_digest_auth_check[_digest]3()' returned " \ "MHD_DAUTH_RESPONSE_WRONG"); break; case MHD_DAUTH_WRONG_HEADER: mhdErrorExitDesc ("MHD_digest_auth_check[_digest]3()' returned " \ "MHD_DAUTH_WRONG_HEADER"); break; case MHD_DAUTH_WRONG_REALM: case MHD_DAUTH_WRONG_URI: case MHD_DAUTH_WRONG_QOP: case MHD_DAUTH_WRONG_ALGO: case MHD_DAUTH_TOO_LARGE: fprintf (stderr, "'MHD_digest_auth_check[_digest]3()' returned " "unexpected result: %d. ", check_res); mhdErrorExitDesc ("Wrong returned code"); break; default: fprintf (stderr, "'MHD_digest_auth_check[_digest]3()' returned " "impossible result code: %d. ", check_res); mhdErrorExitDesc ("Impossible returned code"); } fflush (stderr); fflush (stdout); if (MHD_DAUTH_OK == check_res) { response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE), (const void *) PAGE); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); if (MHD_YES != MHD_queue_response (connection, MHD_HTTP_OK, response)) mhdErrorExitDesc ("'MHD_queue_response()' failed"); } else if ((MHD_DAUTH_NONCE_STALE == check_res) || (MHD_DAUTH_NONCE_OTHER_COND == check_res)) { response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (DENIED), (const void *) DENIED); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); res = MHD_queue_auth_required_response3 (connection, REALM_VAL, OPAQUE_VALUE, "/", response, 1, (enum MHD_DigestAuthMultiQOP) qop, (enum MHD_DigestAuthMultiAlgo3) algo3, test_userhash, 0); if (MHD_YES != res) mhdErrorExitDesc ("'MHD_queue_auth_required_response3()' failed"); } else externalErrorExitDesc ("Wrong 'check_res' value"); } else { /* No Digest auth header */ if ((1 != tr_p->req_num) || (0 != tr_p->uri_num)) { fprintf (stderr, "Received request number %u for URI number %u " "without Digest Authorisation header. ", tr_p->req_num, tr_p->uri_num + 1); mhdErrorExitDesc ("Wrong requests sequence"); } response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (DENIED), (const void *) DENIED); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); res = MHD_queue_auth_required_response3 ( connection, REALM_VAL, OPAQUE_VALUE, "/", response, 0, (enum MHD_DigestAuthMultiQOP) qop, (enum MHD_DigestAuthMultiAlgo3) algo3, test_userhash, 0); if (MHD_YES != res) mhdErrorExitDesc ("'MHD_queue_auth_required_response3()' failed"); } } else if (2 == test_oldapi) { /* Use old API v2 */ char *username; int check_res; int expect_res; username = MHD_digest_auth_get_username (connection); if (NULL != username) { /* Has a valid username in header */ if (0 != strcmp (username, username_ptr)) { fprintf (stderr, "'username' does not match.\n" "Expected: '%s'\tRecieved: '%s'. ", username_ptr, username); mhdErrorExitDesc ("Wrong 'username'"); } MHD_free (username); if (! test_userdigest) check_res = MHD_digest_auth_check2 (connection, REALM_VAL, username_ptr, PASSWORD_VALUE, 50 * TIMEOUTS_VAL, test_sha256 ? MHD_DIGEST_ALG_SHA256 : MHD_DIGEST_ALG_MD5); else check_res = MHD_digest_auth_check_digest2 (connection, REALM_VAL, username_ptr, userdigest_bin, userdigest_bin_size, 50 * TIMEOUTS_VAL, test_sha256 ? MHD_DIGEST_ALG_SHA256 : MHD_DIGEST_ALG_MD5); if (test_bind_uri) { if ((0 != tr_p->uri_num) && (1 == tr_p->req_num)) expect_res = MHD_INVALID_NONCE; else expect_res = MHD_YES; } else expect_res = MHD_YES; if (expect_res != check_res) { fprintf (stderr, "'MHD_digest_auth_check[_digest]2()' returned " "unexpected result '%d', while expected is '%d. ", check_res, expect_res); mhdErrorExitDesc ("Wrong 'MHD_digest_auth_check[_digest]2()' result"); } response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE), (const void *) PAGE); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); if (MHD_YES == expect_res) { if (MHD_YES != MHD_queue_response (connection, MHD_HTTP_OK, response)) mhdErrorExitDesc ("'MHD_queue_response()' failed"); } else if (MHD_INVALID_NONCE == expect_res) { if (MHD_YES != MHD_queue_auth_fail_response2 (connection, REALM_VAL, OPAQUE_VALUE, response, 1, test_sha256 ? MHD_DIGEST_ALG_SHA256 : MHD_DIGEST_ALG_MD5)) mhdErrorExitDesc ("'MHD_queue_auth_fail_response2()' failed"); } else externalErrorExitDesc ("Wrong 'check_res' value"); } else { /* Has no valid username in header */ if ((1 != tr_p->req_num) || (0 != tr_p->uri_num)) { fprintf (stderr, "Received request number %u for URI number %u " "without Digest Authorisation header. ", tr_p->req_num, tr_p->uri_num + 1); mhdErrorExitDesc ("Wrong requests sequence"); } response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (DENIED), (const void *) DENIED); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); res = MHD_queue_auth_fail_response2 (connection, REALM_VAL, OPAQUE_VALUE, response, 0, test_sha256 ? MHD_DIGEST_ALG_SHA256 : MHD_DIGEST_ALG_MD5); if (MHD_YES != res) mhdErrorExitDesc ("'MHD_queue_auth_fail_response2()' failed"); } } else if (1 == test_oldapi) { /* Use old API v1 */ char *username; int check_res; int expect_res; username = MHD_digest_auth_get_username (connection); if (NULL != username) { /* Has a valid username in header */ if (0 != strcmp (username, username_ptr)) { fprintf (stderr, "'username' does not match.\n" "Expected: '%s'\tRecieved: '%s'. ", username_ptr, username); mhdErrorExitDesc ("Wrong 'username'"); } MHD_free (username); if (! test_userdigest) check_res = MHD_digest_auth_check (connection, REALM_VAL, username_ptr, PASSWORD_VALUE, 50 * TIMEOUTS_VAL); else check_res = MHD_digest_auth_check_digest (connection, REALM_VAL, username_ptr, userdigest_bin, 50 * TIMEOUTS_VAL); if (test_bind_uri) { if ((0 != tr_p->uri_num) && (1 == tr_p->req_num)) expect_res = MHD_INVALID_NONCE; else expect_res = MHD_YES; } else expect_res = MHD_YES; if (expect_res != check_res) { fprintf (stderr, "'MHD_digest_auth_check[_digest]()' returned " "unexpected result '%d', while expected is '%d. ", check_res, expect_res); mhdErrorExitDesc ("Wrong 'MHD_digest_auth_check[_digest]()' result"); } response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE), (const void *) PAGE); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); if (MHD_YES == expect_res) { if (MHD_YES != MHD_queue_response (connection, MHD_HTTP_OK, response)) mhdErrorExitDesc ("'MHD_queue_response()' failed"); } else if (MHD_INVALID_NONCE == expect_res) { if (MHD_YES != MHD_queue_auth_fail_response (connection, REALM_VAL, OPAQUE_VALUE, response, 1)) mhdErrorExitDesc ("'MHD_queue_auth_fail_response()' failed"); } else externalErrorExitDesc ("Wrong 'check_res' value"); } else { /* Has no valid username in header */ if ((1 != tr_p->req_num) || (0 != tr_p->uri_num)) { fprintf (stderr, "Received request number %u for URI number %u " "without Digest Authorisation header. ", tr_p->req_num, tr_p->uri_num + 1); mhdErrorExitDesc ("Wrong requests sequence"); } response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (DENIED), (const void *) DENIED); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); res = MHD_queue_auth_fail_response (connection, REALM_VAL, OPAQUE_VALUE, response, 0); if (MHD_YES != res) mhdErrorExitDesc ("'MHD_queue_auth_fail_response()' failed"); } } else externalErrorExitDesc ("Wrong 'test_oldapi' value"); MHD_destroy_response (response); return MHD_YES; } /** * * @param c the CURL handle to use * @param port the port to set * @param uri_num the number of URI, should be 0, 1 or 2 */ static void setCURL_rq_path (CURL *c, uint16_t port, unsigned int uri_num) { const char *req_path; char uri[512]; int res; if (0 == uri_num) req_path = MHD_URI_BASE_PATH; else if (1 == uri_num) req_path = MHD_URI_BASE_PATH2; else req_path = MHD_URI_BASE_PATH3; /* A workaround for some old libcurl versions, which ignore the specified * port by CURLOPT_PORT when authorisation is used. */ res = snprintf (uri, (sizeof(uri) / sizeof(uri[0])), "http://127.0.0.1:%u%s", (unsigned int) port, req_path); if ((0 >= res) || ((sizeof(uri) / sizeof(uri[0])) <= (size_t) res)) externalErrorExitDesc ("Cannot form request URL"); if (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, uri)) libcurlErrorExitDesc ("Cannot set request URL"); } static CURL * setupCURL (void *cbc, uint16_t port) { CURL *c; c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 0L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPAUTH, (long) CURLAUTH_DIGEST)) || #if CURL_AT_LEAST_VERSION (7,19,1) /* Need version 7.19.1 for separate username and password */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_USERNAME, username_ptr)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PASSWORD, PASSWORD_VALUE)) || #endif /* CURL_AT_LEAST_VERSION(7,19,1) */ #ifdef _DEBUG (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) || #endif /* _DEBUG */ #if CURL_AT_LEAST_VERSION (7, 85, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http")) || #elif CURL_AT_LEAST_VERSION (7, 19, 4) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) || #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ #if CURL_AT_LEAST_VERSION (7, 45, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) || #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) port)))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); setCURL_rq_path (c, port, 0); return c; } static CURLcode performQueryExternal (struct MHD_Daemon *d, CURL *c, CURLM **multi_reuse) { CURLM *multi; time_t start; struct timeval tv; CURLcode ret; ret = CURLE_FAILED_INIT; /* will be replaced with real result */ if (NULL != *multi_reuse) multi = *multi_reuse; else { multi = curl_multi_init (); if (multi == NULL) libcurlErrorExitDesc ("curl_multi_init() failed"); *multi_reuse = multi; } if (CURLM_OK != curl_multi_add_handle (multi, c)) libcurlErrorExitDesc ("curl_multi_add_handle() failed"); start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; int running; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL != multi) { curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) libcurlErrorExitDesc ("curl_multi_info_read() failed"); totalMsgs++; if (CURLMSG_DONE == msg->msg) ret = msg->data.result; } while (msgLeft > 0); if (1 != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); externalErrorExit (); } curl_multi_remove_handle (multi, c); multi = NULL; } else { if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) libcurlErrorExitDesc ("curl_multi_fdset() failed"); } } if (NULL == multi) { /* libcurl has finished, check whether MHD still needs to perform cleanup */ if (0 != MHD_get_timeout64s (d)) break; /* MHD finished as well */ } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); tv.tv_sec = 0; tv.tv_usec = 200000; #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep (200); #endif } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); } return ret; } /** * Check request result * @param curl_code the CURL easy return code * @param pcbc the pointer struct CBC * @return non-zero if success, zero if failed */ static unsigned int check_result (CURLcode curl_code, CURL *c, struct CBC *pcbc) { long code; if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code)) libcurlErrorExit (); if (MHD_HTTP_OK != code) { fprintf (stderr, "Request returned wrong code: %ld.\n", code); return 0; } if (CURLE_OK != curl_code) { fflush (stdout); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n" "libcurl error description: '%s'.\n", curl_easy_strerror (curl_code), libcurl_errbuf); else fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n", curl_easy_strerror (curl_code)); fflush (stderr); return 0; } if (pcbc->pos != MHD_STATICSTR_LEN_ (PAGE)) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) pcbc->pos, (int) pcbc->pos, pcbc->buf, (unsigned) MHD_STATICSTR_LEN_ (PAGE)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != memcmp (PAGE, pcbc->buf, pcbc->pos)) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) pcbc->pos, pcbc->buf); mhdErrorExitDesc ("Wrong returned data"); } return 1; } static unsigned int testDigestAuth (void) { unsigned int dauth_nonce_bind; struct MHD_Daemon *d; uint16_t port; struct CBC cbc; struct req_track rq_tr; char buf[2048]; CURL *c; CURLM *multi_reuse; int failed = 0; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 4210; if (1) { uint8_t salt[8]; /* Use local variable to test MHD "copy" function */ if (! gen_good_rnd (salt, sizeof(salt))) { fprintf (stderr, "WARNING: the random buffer (used as salt value) is not " "initialised completely, nonce generation may be " "predictable in this test.\n"); fflush (stderr); } dauth_nonce_bind = MHD_DAUTH_BIND_NONCE_NONE; if (test_bind_all) dauth_nonce_bind |= (MHD_DAUTH_BIND_NONCE_CLIENT_IP | MHD_DAUTH_BIND_NONCE_REALM); if (test_bind_uri) dauth_nonce_bind |= MHD_DAUTH_BIND_NONCE_URI_PARAMS; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, &rq_tr, MHD_OPTION_DIGEST_AUTH_RANDOM_COPY, sizeof (salt), salt, MHD_OPTION_NONCE_NC_SIZE, 300, MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE, dauth_nonce_bind, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); } if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); port = dinfo->port; } /* First request */ rq_tr.req_num = 0; rq_tr.uri_num = 0; cbc.buf = buf; cbc.size = sizeof (buf); cbc.pos = 0; memset (cbc.buf, 0, cbc.size); c = setupCURL (&cbc, port); multi_reuse = NULL; /* First request */ if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc)) { fflush (stderr); if (verbose) printf ("Got first expected response.\n"); fflush (stdout); } else { fprintf (stderr, "First request FAILED.\n"); failed = 1; } cbc.pos = 0; /* Reset buffer position */ rq_tr.req_num = 0; /* Second request */ setCURL_rq_path (c, port, ++rq_tr.uri_num); if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc)) { fflush (stderr); if (verbose) printf ("Got second expected response.\n"); fflush (stdout); } else { fprintf (stderr, "Second request FAILED.\n"); failed = 1; } cbc.pos = 0; /* Reset buffer position */ rq_tr.req_num = 0; /* Third request */ if (NULL != multi_reuse) curl_multi_cleanup (multi_reuse); multi_reuse = NULL; /* Force new connection */ setCURL_rq_path (c, port, ++rq_tr.uri_num); if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc)) { fflush (stderr); if (verbose) printf ("Got third expected response.\n"); fflush (stdout); } else { fprintf (stderr, "Third request FAILED.\n"); failed = 1; } curl_easy_cleanup (c); if (NULL != multi_reuse) curl_multi_cleanup (multi_reuse); MHD_stop_daemon (d); return failed ? 1 : 0; } int main (int argc, char *const *argv) { #if ! CURL_AT_LEAST_VERSION (7,19,1) (void) argc; (void) argv; /* Unused. Silent compiler warning. */ /* Need version 7.19.1 or newer for separate username and password */ fprintf (stderr, "Required libcurl at least version 7.19.1" " to run this test.\n"); return 77; #else /* CURL_AT_LEAST_VERSION(7,19,1) */ unsigned int errorCount = 0; const curl_version_info_data *const curl_info = curl_version_info (CURLVERSION_NOW); int curl_sspi; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ #ifdef NEED_GCRYP_INIT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* GCRYCTL_INITIALIZATION_FINISHED */ #endif /* NEED_GCRYP_INIT */ /* Test type and test parameters */ verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); test_oldapi = 0; if (has_in_name (argv[0], "_oldapi1")) test_oldapi = 1; if (has_in_name (argv[0], "_oldapi2")) test_oldapi = 2; test_userhash = has_in_name (argv[0], "_userhash"); test_userdigest = has_in_name (argv[0], "_userdigest"); test_sha256 = has_in_name (argv[0], "_sha256"); test_rfc2069 = has_in_name (argv[0], "_rfc2069"); test_bind_all = has_in_name (argv[0], "_bind_all"); test_bind_uri = has_in_name (argv[0], "_bind_uri"); /* Wrong test types combinations */ if (1 == test_oldapi) { if (test_sha256) return 99; } if (test_oldapi) { if (test_userhash || test_rfc2069) return 99; } if (test_rfc2069) { if (test_userhash) return 99; } /* Curl version and known bugs checks */ curl_sspi = 0; #ifdef CURL_VERSION_SSPI if (0 != (curl_info->features & CURL_VERSION_SSPI)) curl_sspi = 1; #endif /* CURL_VERSION_SSPI */ if ((CURL_VERSION_BITS (7,63,0) > curl_info->version_num) && (CURL_VERSION_BITS (7,62,0) <= curl_info->version_num) ) { fprintf (stderr, "libcurl version 7.62.x has bug in processing " "URI with GET arguments for Digest Auth.\n"); fprintf (stderr, "This test with libcurl %u.%u.%u cannot be performed.\n", 0xFF & (curl_info->version_num >> 16), 0xFF & (curl_info->version_num >> 8), 0xFF & (curl_info->version_num >> 0)); return 77; } if (test_sha256) { if (curl_sspi) { fprintf (stderr, "Windows SSPI API does not support SHA-256 digests.\n"); return 77; } else if (CURL_VERSION_BITS (7,57,0) > curl_info->version_num) { fprintf (stderr, "Required libcurl at least version 7.57.0 " "to run this test with SHA-256.\n"); fprintf (stderr, "This libcurl version %u.%u.%u " "does not support SHA-256.\n", 0xFF & (curl_info->version_num >> 16), 0xFF & (curl_info->version_num >> 8), 0xFF & (curl_info->version_num >> 0)); return 77; } } if (test_userhash) { if (curl_sspi) { printf ("WARNING: Windows SSPI API does not support 'userhash'.\n"); printf ("This test just checks Digest Auth compatibility with " "the clients without 'userhash' support " "when 'userhash=true' is specified by MHD.\n"); curl_uses_usehash = 0; } else if (CURL_VERSION_BITS (7,57,0) > curl_info->version_num) { printf ("WARNING: libcurl before version 7.57.0 does not " "support 'userhash'.\n"); printf ("This test just checks Digest Auth compatibility with " "libcurl version %u.%u.%u without 'userhash' support " "when 'userhash=true' is specified by MHD.\n", 0xFF & (curl_info->version_num >> 16), 0xFF & (curl_info->version_num >> 8), 0xFF & (curl_info->version_num >> 0)); curl_uses_usehash = 0; } else if (CURL_VERSION_BITS (7,81,0) > curl_info->version_num) { fprintf (stderr, "Required libcurl at least version 7.81.0 " "to run this test with userhash.\n"); fprintf (stderr, "This libcurl version %u.%u.%u has broken digest " "calculation when userhash is used.\n", 0xFF & (curl_info->version_num >> 16), 0xFF & (curl_info->version_num >> 8), 0xFF & (curl_info->version_num >> 0)); return 77; } else curl_uses_usehash = ! 0; } else curl_uses_usehash = 0; test_global_init (); errorCount += testDigestAuth (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); test_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ #endif /* CURL_AT_LEAST_VERSION(7,19,1) */ } libmicrohttpd-1.0.1/src/testcurl/mhd_has_param.h0000644000175000017500000000327714441373361015445 /* This file is part of libmicrohttpd Copyright (C) 2016-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file testcurl/mhd_has_param.h * @brief Static functions and macros helpers for testsuite. * @author Karlson2k (Evgeny Grin) */ #include /** * Check whether one of strings in array is equal to @a param. * String @a argv[0] is ignored. * @param argc number of strings in @a argv, as passed to main function * @param argv array of strings, as passed to main function * @param param parameter to look for. * @return zero if @a argv is NULL, @a param is NULL or empty string, * @a argc is less then 2 or @a param is not found in @a argv, * non-zero if one of strings in @a argv is equal to @a param. */ static int has_param (int argc, char *const argv[], const char *param) { int i; if (! argv || ! param || ! param[0]) return 0; for (i = 1; i < argc; i++) { if (argv[i] && (strcmp (argv[i], param) == 0) ) return ! 0; } return 0; } libmicrohttpd-1.0.1/src/testcurl/test_postform.c0000644000175000017500000005041614530120375015554 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2023 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_postform.c * @brief Testcase for libmicrohttpd POST operations using multipart/postform data * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #ifdef HAVE_GCRYPT_H #include #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include #ifndef WINDOWS #include #endif #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #if CURL_AT_LEAST_VERSION (7,56,0) #define HAS_CURL_MIME 1 #endif /* CURL_AT_LEAST_VERSION(7,56,0) */ #include "mhd_has_in_name.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif static int oneone; struct CBC { char *buf; size_t pos; size_t size; }; static void completed_cb (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { struct MHD_PostProcessor *pp = *req_cls; (void) cls; (void) connection; (void) toe; /* Unused. Silent compiler warning. */ if (NULL != pp) MHD_destroy_post_processor (pp); *req_cls = NULL; } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } /** * Note that this post_iterator is not perfect * in that it fails to support incremental processing. * (to be fixed in the future) */ static enum MHD_Result post_iterator (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *value, uint64_t off, size_t size) { int *eok = cls; (void) kind; (void) filename; (void) content_type; /* Unused. Silent compiler warning. */ (void) transfer_encoding; (void) off; /* Unused. Silent compiler warning. */ #if 0 fprintf (stderr, "PI sees %s-%.*s\n", key, size, value); #endif if ((0 == strcmp (key, "name")) && (size == strlen ("daniel")) && (0 == strncmp (value, "daniel", size))) (*eok) |= 1; if ((0 == strcmp (key, "project")) && (size == strlen ("curl")) && (0 == strncmp (value, "curl", size))) (*eok) |= 2; return MHD_YES; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int eok; struct MHD_Response *response; struct MHD_PostProcessor *pp; enum MHD_Result ret; (void) cls; (void) version; /* Unused. Silent compiler warning. */ if (0 != strcmp ("POST", method)) { printf ("METHOD: %s\n", method); return MHD_NO; /* unexpected method */ } pp = *req_cls; if (pp == NULL) { eok = 0; pp = MHD_create_post_processor (connection, 1024, &post_iterator, &eok); if (NULL == pp) abort (); *req_cls = pp; } if (MHD_YES != MHD_post_process (pp, upload_data, *upload_data_size)) abort (); if ((eok == 3) && (0 == *upload_data_size)) { response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); MHD_destroy_post_processor (pp); *req_cls = NULL; return ret; } *upload_data_size = 0; return MHD_YES; } struct mhd_test_postdata { #if defined(HAS_CURL_MIME) curl_mime *mime; #else /* ! HAS_CURL_MIME */ struct curl_httppost *post; #endif /* ! HAS_CURL_MIME */ }; /* Return non-zero if succeed */ static int add_test_form (CURL *handle, struct mhd_test_postdata *postdata) { #if defined(HAS_CURL_MIME) postdata->mime = curl_mime_init (handle); if (NULL == postdata->mime) return 0; else { curl_mimepart *part; part = curl_mime_addpart (postdata->mime); if (NULL != part) { if ( (CURLE_OK == curl_mime_data (part, "daniel", CURL_ZERO_TERMINATED)) && (CURLE_OK == curl_mime_name (part, "name")) ) { part = curl_mime_addpart (postdata->mime); if (NULL != part) { if ( (CURLE_OK == curl_mime_data (part, "curl", CURL_ZERO_TERMINATED)) && (CURLE_OK == curl_mime_name (part, "project")) ) { if (CURLE_OK == curl_easy_setopt (handle, CURLOPT_MIMEPOST, postdata->mime)) { return ! 0; } } } } } } curl_mime_free (postdata->mime); postdata->mime = NULL; return 0; #else /* ! HAS_CURL_MIME */ postdata->post = NULL; struct curl_httppost *last = NULL; if (0 == curl_formadd (&postdata->post, &last, CURLFORM_COPYNAME, "name", CURLFORM_COPYCONTENTS, "daniel", CURLFORM_END)) { if (0 == curl_formadd (&postdata->post, &last, CURLFORM_COPYNAME, "project", CURLFORM_COPYCONTENTS, "curl", CURLFORM_END)) { if (CURLE_OK == curl_easy_setopt (handle, CURLOPT_HTTPPOST, postdata->post)) { return ! 0; } } } curl_formfree (postdata->post); return 0; #endif /* ! HAS_CURL_MIME */ } static void free_test_form (struct mhd_test_postdata *postdata) { #if defined(HAS_CURL_MIME) if (NULL != postdata->mime) curl_mime_free (postdata->mime); #else /* ! HAS_CURL_MIME */ if (NULL != postdata->post) curl_formfree (postdata->post); #endif /* ! HAS_CURL_MIME */ } static unsigned int testInternalPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; struct mhd_test_postdata form; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1390; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (! add_test_form (c, &form)) { fprintf (stderr, "libcurl form initialisation error.\n"); curl_easy_cleanup (c); return 2; } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); free_test_form (&form); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); free_test_form (&form); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; return 0; } static unsigned int testMultithreadedPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; struct mhd_test_postdata form; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1390; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 5L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (! add_test_form (c, &form)) { fprintf (stderr, "libcurl form initialisation error.\n"); curl_easy_cleanup (c); return 2; } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); free_test_form (&form); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); free_test_form (&form); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testMultithreadedPoolPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; struct mhd_test_postdata form; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1391; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 5L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (! add_test_form (c, &form)) { fprintf (stderr, "libcurl form initialisation error.\n"); curl_easy_cleanup (c); return 2; } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); free_test_form (&form); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); free_test_form (&form); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testExternalPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; struct mhd_test_postdata form; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1392; if (oneone) port += 10; } multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (! add_test_form (c, &form)) { fprintf (stderr, "libcurl form initialisation error.\n"); curl_easy_cleanup (c); return 2; } multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); free_test_form (&form); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); free_test_form (&form); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); free_test_form (&form); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); free_test_form (&form); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } free_test_form (&form); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 8192; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 16384; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ #ifdef MHD_HTTPS_REQUIRE_GCRYPT #ifdef HAVE_GCRYPT_H gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalPost (); errorCount += testMultithreadedPost (); errorCount += testMultithreadedPoolPost (); } errorCount += testExternalPost (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/Makefile.am0000644000175000017500000004033714556245274014553 # This Makefile.am is in the public domain EMPTY_ITEM = @HEAVY_TESTS_NOTPARALLEL@ SUBDIRS = . AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/microhttpd \ -DMHD_CPU_COUNT=$(CPU_COUNT) \ $(CPPFLAGS_ac) $(LIBCURL_CPPFLAGS) AM_CFLAGS = $(CFLAGS_ac) @LIBGCRYPT_CFLAGS@ AM_LDFLAGS = $(LDFLAGS_ac) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) if USE_COVERAGE AM_CFLAGS += -fprofile-arcs -ftest-coverage endif if ENABLE_HTTPS SUBDIRS += https endif LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ @LIBCURL@ $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la THREAD_ONLY_TESTS = \ test_urlparse \ test_long_header \ test_long_header11 \ test_iplimit11 \ test_termination \ $(EMPTY_ITEM) if HEAVY_TESTS THREAD_ONLY_TESTS += \ test_add_conn_cleanup \ test_add_conn_cleanup_nolisten \ test_timeout \ $(EMPTY_ITEM) endif if HAVE_POSIX_THREADS if HEAVY_TESTS THREAD_ONLY_TESTS += \ perf_get_concurrent11 \ $(EMPTY_ITEM) endif THREAD_ONLY_TESTS += \ test_get_wait \ test_get_wait11 \ $(EMPTY_ITEM) if HEAVY_TESTS THREAD_ONLY_TESTS += \ test_concurrent_stop \ test_quiesce \ $(EMPTY_ITEM) endif if HAVE_CURL_BINARY THREAD_ONLY_TESTS += \ test_quiesce_stream endif endif if HEAVY_TESTS if HAVE_POSIX_THREADS THREAD_ONLY_TESTS += \ perf_get_concurrent endif endif if RUN_LIBCURL_TESTS check_PROGRAMS = \ test_get \ test_head \ test_head10 \ test_get_iovec \ test_get_sendfile \ test_get_close \ test_get_close10 \ test_get_keep_alive \ test_get_keep_alive10 \ test_delete \ test_patch \ test_put \ test_add_conn \ test_add_conn_nolisten \ test_process_headers \ test_process_arguments \ test_toolarge_method \ test_toolarge_url \ test_toolarge_request_header_name \ test_toolarge_request_header_value \ test_toolarge_request_headers \ test_toolarge_reply_header_name \ test_toolarge_reply_header_value \ test_toolarge_reply_headers \ test_tricky_url \ test_tricky_header2 \ test_large_put \ test_get11 \ test_get_iovec11 \ test_get_sendfile11 \ test_patch11 \ test_put11 \ test_large_put11 \ test_large_put_inc11 \ test_put_broken_len10 \ test_put_broken_len \ test_get_chunked \ test_get_chunked_close \ test_get_chunked_string \ test_get_chunked_close_string \ test_get_chunked_empty \ test_get_chunked_close_empty \ test_get_chunked_string_empty \ test_get_chunked_close_string_empty \ test_get_chunked_sized \ test_get_chunked_close_sized \ test_get_chunked_empty_sized \ test_get_chunked_close_empty_sized \ test_get_chunked_forced \ test_get_chunked_close_forced \ test_get_chunked_empty_forced \ test_get_chunked_close_empty_forced \ test_put_chunked \ test_callback \ test_get_header_fold \ test_put_header_fold \ test_put_large_header_fold \ test_put_header_fold_last \ test_put_header_fold_large \ test_get_header_double_fold \ test_put_header_double_fold \ test_put_large_header_double_fold \ test_put_header_double_fold_last \ test_put_header_double_fold_large \ $(EMPTY_ITEM) if ENABLE_COOKIE check_PROGRAMS += \ test_parse_cookies_discp_p2 \ test_parse_cookies_discp_p1 \ test_parse_cookies_discp_zero \ test_parse_cookies_discp_n2 \ test_parse_cookies_discp_n3 endif if HEAVY_TESTS check_PROGRAMS += \ perf_get endif if ENABLE_BAUTH check_PROGRAMS += \ test_basicauth test_basicauth_preauth \ test_basicauth_oldapi test_basicauth_preauth_oldapi endif if HAVE_POSTPROCESSOR check_PROGRAMS += \ test_post \ test_postform \ test_post_loop \ test_post11 \ test_postform11 \ test_post_loop11 endif if ENABLE_DAUTH if ENABLE_MD5 THREAD_ONLY_TESTS += \ test_digestauth \ test_digestauth_with_arguments \ test_digestauth_concurrent endif if ENABLE_SHA256 THREAD_ONLY_TESTS += \ test_digestauth_sha256 endif if ENABLE_MD5 check_PROGRAMS += \ test_digestauth_emu_ext \ test_digestauth_emu_ext_oldapi \ test_digestauth2 \ test_digestauth2_rfc2069 \ test_digestauth2_rfc2069_userdigest \ test_digestauth2_oldapi1 \ test_digestauth2_oldapi2 \ test_digestauth2_userhash \ test_digestauth2_userdigest \ test_digestauth2_oldapi1_userdigest \ test_digestauth2_oldapi2_userdigest \ test_digestauth2_userhash_userdigest \ test_digestauth2_bind_all \ test_digestauth2_bind_uri \ test_digestauth2_oldapi1_bind_all \ test_digestauth2_oldapi1_bind_uri endif if ENABLE_SHA256 check_PROGRAMS += \ test_digestauth2_sha256 \ test_digestauth2_sha256_userhash \ test_digestauth2_oldapi2_sha256 \ test_digestauth2_sha256_userdigest \ test_digestauth2_oldapi2_sha256_userdigest \ test_digestauth2_sha256_userhash_userdigest endif endif if HEAVY_TESTS if HAVE_FORK_WAITPID if HAVE_CURL_BINARY check_PROGRAMS += test_get_response_cleanup endif endif endif if USE_POSIX_THREADS check_PROGRAMS += \ $(THREAD_ONLY_TESTS) endif if USE_W32_THREADS check_PROGRAMS += \ $(THREAD_ONLY_TESTS) endif TESTS = $(check_PROGRAMS) endif test_concurrent_stop_SOURCES = \ test_concurrent_stop.c test_concurrent_stop_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_concurrent_stop_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_get_SOURCES = \ test_get.c mhd_has_in_name.h mhd_has_param.h test_head_SOURCES = \ test_head.c mhd_has_in_name.h mhd_has_param.h test_head10_SOURCES = \ test_head.c mhd_has_in_name.h mhd_has_param.h test_quiesce_SOURCES = \ test_quiesce.c mhd_has_param.h mhd_has_in_name.h test_quiesce_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_quiesce_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_quiesce_stream_SOURCES = \ test_quiesce_stream.c test_quiesce_stream_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_quiesce_stream_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_callback_SOURCES = \ test_callback.c perf_get_SOURCES = \ perf_get.c \ mhd_has_in_name.h perf_get_concurrent_SOURCES = \ perf_get_concurrent.c \ mhd_has_in_name.h perf_get_concurrent_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) perf_get_concurrent_LDADD = \ $(PTHREAD_LIBS) $(LDADD) perf_get_concurrent11_SOURCES = \ perf_get_concurrent.c \ mhd_has_in_name.h perf_get_concurrent11_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) perf_get_concurrent11_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_basicauth_SOURCES = \ test_basicauth.c test_basicauth_preauth_SOURCES = \ test_basicauth.c test_basicauth_oldapi_SOURCES = \ test_basicauth.c test_basicauth_preauth_oldapi_SOURCES = \ test_basicauth.c test_digestauth_SOURCES = \ test_digestauth.c test_digestauth_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) test_digestauth_sha256_SOURCES = \ test_digestauth_sha256.c test_digestauth_sha256_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) test_digestauth_with_arguments_SOURCES = \ test_digestauth_with_arguments.c test_digestauth_with_arguments_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) test_digestauth_concurrent_SOURCES = \ test_digestauth_concurrent.c test_digestauth_concurrent_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_digestauth_concurrent_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) $(PTHREAD_LIBS) $(LDADD) test_digestauth_emu_ext_SOURCES = \ test_digestauth_emu_ext.c test_digestauth_emu_ext_oldapi_SOURCES = \ test_digestauth_emu_ext.c test_digestauth2_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_rfc2069_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_rfc2069_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi1_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi2_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_userhash_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_sha256_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi2_sha256_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_sha256_userhash_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi1_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi2_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_userhash_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_sha256_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi2_sha256_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_sha256_userhash_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_bind_all_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_bind_uri_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi1_bind_all_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi1_bind_uri_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_get_iovec_SOURCES = \ test_get_iovec.c mhd_has_in_name.h test_get_sendfile_SOURCES = \ test_get_sendfile.c mhd_has_in_name.h test_get_wait_SOURCES = \ test_get_wait.c \ mhd_has_in_name.h test_get_wait_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_get_wait_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_get_wait11_SOURCES = \ test_get_wait.c \ mhd_has_in_name.h test_get_wait11_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_get_wait11_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_urlparse_SOURCES = \ test_urlparse.c mhd_has_in_name.h test_get_response_cleanup_SOURCES = \ test_get_response_cleanup.c mhd_has_in_name.h test_get_chunked_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_string_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_string_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_empty_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_empty_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_string_empty_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_string_empty_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_sized_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_sized_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_empty_sized_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_empty_sized_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_forced_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_forced_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_empty_forced_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_empty_forced_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_post_SOURCES = \ test_post.c mhd_has_in_name.h test_process_headers_SOURCES = \ test_process_headers.c mhd_has_in_name.h test_parse_cookies_discp_zero_SOURCES = \ test_parse_cookies.c mhd_has_in_name.h mhd_has_param.h test_parse_cookies_discp_p2_SOURCES = \ $(test_parse_cookies_discp_zero_SOURCES) test_parse_cookies_discp_p1_SOURCES = \ $(test_parse_cookies_discp_zero_SOURCES) test_parse_cookies_discp_n2_SOURCES = \ $(test_parse_cookies_discp_zero_SOURCES) test_parse_cookies_discp_n3_SOURCES = \ $(test_parse_cookies_discp_zero_SOURCES) test_process_arguments_SOURCES = \ test_process_arguments.c mhd_has_in_name.h test_postform_SOURCES = \ test_postform.c mhd_has_in_name.h test_postform_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) test_post_loop_SOURCES = \ test_post_loop.c mhd_has_in_name.h test_delete_SOURCES = \ test_delete.c mhd_has_in_name.h test_patch_SOURCES = \ test_patch.c mhd_has_in_name.h test_patch11_SOURCES = \ test_patch.c mhd_has_in_name.h test_put_SOURCES = \ test_put.c mhd_has_in_name.h test_put_chunked_SOURCES = \ test_put_chunked.c test_add_conn_SOURCES = \ test_add_conn.c mhd_has_in_name.h mhd_has_param.h test_add_conn_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_add_conn_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_add_conn_nolisten_SOURCES = \ test_add_conn.c mhd_has_in_name.h mhd_has_param.h test_add_conn_nolisten_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_add_conn_nolisten_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_add_conn_cleanup_SOURCES = \ test_add_conn.c mhd_has_in_name.h mhd_has_param.h test_add_conn_cleanup_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_add_conn_cleanup_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_add_conn_cleanup_nolisten_SOURCES = \ test_add_conn.c mhd_has_in_name.h mhd_has_param.h test_add_conn_cleanup_nolisten_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_add_conn_cleanup_nolisten_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_get11_SOURCES = \ test_get.c mhd_has_in_name.h mhd_has_param.h test_get_iovec11_SOURCES = \ test_get_iovec.c mhd_has_in_name.h test_get_sendfile11_SOURCES = \ test_get_sendfile.c mhd_has_in_name.h test_get_close_SOURCES = \ test_get_close_keep_alive.c mhd_has_in_name.h mhd_has_param.h test_get_close10_SOURCES = \ test_get_close_keep_alive.c mhd_has_in_name.h mhd_has_param.h test_get_keep_alive_SOURCES = \ test_get_close_keep_alive.c mhd_has_in_name.h mhd_has_param.h test_get_keep_alive10_SOURCES = \ test_get_close_keep_alive.c mhd_has_in_name.h mhd_has_param.h test_post11_SOURCES = \ test_post.c mhd_has_in_name.h test_postform11_SOURCES = \ test_postform.c mhd_has_in_name.h test_postform11_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) test_post_loop11_SOURCES = \ test_post_loop.c mhd_has_in_name.h test_put11_SOURCES = \ test_put.c mhd_has_in_name.h test_large_put_SOURCES = \ test_large_put.c mhd_has_in_name.h mhd_has_param.h test_large_put11_SOURCES = \ test_large_put.c mhd_has_in_name.h mhd_has_param.h test_large_put_inc11_SOURCES = \ test_large_put.c mhd_has_in_name.h mhd_has_param.h test_long_header_SOURCES = \ test_long_header.c mhd_has_in_name.h test_long_header11_SOURCES = \ test_long_header.c mhd_has_in_name.h test_iplimit11_SOURCES = \ test_iplimit.c mhd_has_in_name.h test_termination_SOURCES = \ test_termination.c test_timeout_SOURCES = \ test_timeout.c mhd_has_in_name.h test_toolarge_method_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_url_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_request_header_name_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_request_header_value_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_request_headers_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_reply_header_name_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_reply_header_value_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_reply_headers_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_tricky_url_SOURCES = \ test_tricky.c mhd_has_in_name.h mhd_has_param.h test_tricky_header2_SOURCES = \ test_tricky.c mhd_has_in_name.h mhd_has_param.h test_put_broken_len_SOURCES = \ test_put_broken_len.c mhd_has_in_name.h mhd_has_param.h test_put_broken_len10_SOURCES = $(test_put_broken_len_SOURCES) test_put_header_fold_SOURCES = \ test_put_header_fold.c mhd_has_in_name.h mhd_has_param.h test_put_large_header_fold_SOURCES = $(test_put_header_fold_SOURCES) test_get_header_fold_SOURCES = $(test_put_header_fold_SOURCES) test_put_header_fold_last_SOURCES = $(test_put_header_fold_SOURCES) test_put_header_fold_large_SOURCES = $(test_put_header_fold_SOURCES) test_put_header_double_fold_SOURCES = $(test_put_header_fold_SOURCES) test_put_large_header_double_fold_SOURCES = $(test_put_large_header_fold_SOURCES) test_get_header_double_fold_SOURCES = $(test_put_header_fold_SOURCES) test_put_header_double_fold_last_SOURCES = $(test_put_header_fold_last_SOURCES) test_put_header_double_fold_large_SOURCES = $(test_put_header_fold_large_SOURCES) libmicrohttpd-1.0.1/src/testcurl/test_get_sendfile.c0000644000175000017500000004341614530120375016335 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_get_sendfile.c * @brief Testcase for libmicrohttpd response from FD * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include #include #include "mhd_sockets.h" #include "mhd_has_in_name.h" #ifndef WINDOWS #include #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #define TESTSTR \ "This is the content of the test file we are sending using sendfile (if available)" static char *sourcefile; static int oneone; struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; int fd; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; fd = open (sourcefile, O_RDONLY); if (fd == -1) { fprintf (stderr, "Failed to open `%s': %s\n", sourcefile, strerror (errno)); exit (1); } response = MHD_create_response_from_fd (strlen (TESTSTR), fd); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) abort (); return ret; } static unsigned int testInternalGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1200; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen (TESTSTR)) return 4; if (0 != strncmp (TESTSTR, cbc.buf, strlen (TESTSTR))) return 8; return 0; } static unsigned int testMultithreadedGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1201; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen (TESTSTR)) return 64; if (0 != strncmp (TESTSTR, cbc.buf, strlen (TESTSTR))) return 128; return 0; } static unsigned int testMultithreadedPoolGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1202; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen (TESTSTR)) return 64; if (0 != strncmp (TESTSTR, cbc.buf, strlen (TESTSTR))) return 128; return 0; } static unsigned int testExternalGet (int thread_unsafe) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1203; if (oneone) port += 10; } multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | (thread_unsafe ? MHD_USE_NO_THREAD_SAFETY : 0), port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen (TESTSTR)) { fprintf (stderr, "Got %.*s instead of %s!\n", (int) cbc.pos, cbc.buf, TESTSTR); return 8192; } if (0 != strncmp (TESTSTR, cbc.buf, strlen (TESTSTR))) return 16384; return 0; } static unsigned int testUnknownPortGet (void) { struct MHD_Daemon *d; const union MHD_DaemonInfo *di; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; struct sockaddr_in addr; socklen_t addr_len = sizeof(addr); memset (&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = 0; addr.sin_addr.s_addr = INADDR_ANY; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR, &addr, MHD_OPTION_END); if (d == NULL) return 32768; if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) { di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD); if (di == NULL) return 65536; if (0 != getsockname (di->listen_fd, (struct sockaddr *) &addr, &addr_len)) return 131072; if (addr.sin_family != AF_INET) return 26214; port = (uint16_t) ntohs (addr.sin_port); } else { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (buf, sizeof(buf), "http://127.0.0.1:%u/", (unsigned int) port); c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, buf); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 524288; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen (TESTSTR)) return 1048576; if (0 != strncmp (TESTSTR, cbc.buf, strlen (TESTSTR))) return 2097152; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; const char *tmp; FILE *f; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if ( (NULL == (tmp = getenv ("TMPDIR"))) && (NULL == (tmp = getenv ("TMP"))) && (NULL == (tmp = getenv ("TEMP"))) ) tmp = "/tmp"; sourcefile = malloc (strlen (tmp) + 32); snprintf (sourcefile, strlen (tmp) + 32, "%s/%s%s", tmp, "test-mhd-sendfile", oneone ? "11" : ""); f = fopen (sourcefile, "w"); if (NULL == f) { fprintf (stderr, "failed to write test file\n"); free (sourcefile); return 1; } if (1 != fwrite (TESTSTR, strlen (TESTSTR), 1, f)) abort (); fclose (f); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalGet (); errorCount += testMultithreadedGet (); errorCount += testMultithreadedPoolGet (); errorCount += testUnknownPortGet (); errorCount += testExternalGet (0); } errorCount += testExternalGet (! 0); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); unlink (sourcefile); free (sourcefile); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/https/0000755000175000017500000000000014566140216013721 5libmicrohttpd-1.0.1/src/testcurl/https/tls_test_keys.h0000644000175000017500000002460714441373361016720 /* This file is part of libmicrohttpd Copyright (C) 2006, 2007, 2008 Christian Grothoff (and other contributing authors) Copyright (C) 2021-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MHD_TLS_TEST_KEYS_H #define MHD_TLS_TEST_KEYS_H /* Test Certificates */ /* Certificate Authority cert */ static const char ca_cert_pem[] = "-----BEGIN CERTIFICATE-----\n\ MIIGITCCBAmgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx\n\ DzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwGTW9zY293MRswGQYDVQQKDBJ0ZXN0\n\ LWxpYm1pY3JvaHR0cGQxITAfBgkqhkiG9w0BCQEWEm5vYm9keUBleGFtcGxlLm9y\n\ ZzEQMA4GA1UEAwwHdGVzdC1DQTAgFw0yMTA0MDcxNzM2MThaGA8yMTIxMDMxNDE3\n\ MzYxOFowgYExCzAJBgNVBAYTAlJVMQ8wDQYDVQQIDAZNb3Njb3cxDzANBgNVBAcM\n\ Bk1vc2NvdzEbMBkGA1UECgwSdGVzdC1saWJtaWNyb2h0dHBkMSEwHwYJKoZIhvcN\n\ AQkBFhJub2JvZHlAZXhhbXBsZS5vcmcxEDAOBgNVBAMMB3Rlc3QtQ0EwggIiMA0G\n\ CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDdaWupA4qZjCBNkJoJOm5xnCaizl36\n\ ZLUwp4xBL/YfXPWE3LkmAREiVI/YnAb8l6G7CJnz8dTsOJWkNXG6T1KVP5/2RvBI\n\ IaaaufRIAl7hEnj1j9E2hQlV2fxF2ZNhz+nqi0LqKV4LJSpclkXADf2FA9HsVRP/\n\ B7zYh+DP0fSU8V6bsu8XCeRGshroAPrc8rH8lFEEXpNLNIqQr8yKx6SmdB6hfja6\n\ 6SQ0++qBhl0aJtn4LHWZohgjBmkIaGFPYIJLgxQ/xyp2Grz2q7lGKJ+zBkBF8iOP\n\ t3x+F1hSCBnr/DGYWmjEm5tYm+7pyuriPddXdCc8+qa2LxMZo3EXxLo5YISpPCyw\n\ Z7V3YAOZTr3m1C24LiYvPehCq1CTIkhhmqtlVJXU7ISD48cx9y+5Pi34wtbTI/gN\n\ x4voyTLAfyavKMmIpxxIRsWldiF2n06HdvCRVdihDQUad10ygTmWf1J/s2ZETAtH\n\ QaSd7MD389t6nQFtTIXigsNKnnDPlrtxt7rOLvLQeR0K04Gzrf/scheOanRAfOXH\n\ KNBFU7YkDFG8rqizlC65rx9qeXFYXQcHZTuqxK7tgZnSgJat3E70VbTSCsEEG7eR\n\ bNX/fChUKAIIpWaiW6HDlKLl6m2y+BzM91umBsKOqTvntMVFBSF9pVYlXK854aIR\n\ q8A2Xujd012seQIDAQABo4GfMIGcMAsGA1UdDwQEAwICpDASBgNVHRMBAf8ECDAG\n\ AQH/AgEBMB0GA1UdDgQWBBRYdUPApWoxw4U13Rqsjf9AHdbpLDATBgNVHSUEDDAK\n\ BggrBgEFBQcDATAkBglghkgBhvhCAQ0EFxYVVGVzdCBsaWJtaWNyb2h0dHBkIENB\n\ MB8GA1UdIwQYMBaAFFh1Q8ClajHDhTXdGqyN/0Ad1uksMA0GCSqGSIb3DQEBCwUA\n\ A4ICAQBvrrcTKVeI1EYnXo4BQD4oCvf9z1fYQmL21EbHwgjg1nmaPkvStgWAc5p1\n\ kKwySrpEMKXfu68X76RccXZyWWIamEjz2OCWYZgjX6d6FpjhLphL8WxXDy5C9eay\n\ ixN7+URz2XQoi22wqR+tCPDhrIzcMPyMkx/6gRgcYeDnaFrkdSeSsKsID4plfcIj\n\ ISWJDvv+IAgrtsG1NVHnGwpAv0od3A8/4/fR6PPyewaU3aydvjZ7Au8O9DGDjlU9\n\ 9HdlOkkY6GVJ1pfGZib7cV7lhy0D2kj1g9xZh97YjpoUfppPl9r+6A8gDm0hXlAD\n\ TlzNYlwTb681ZEoSd9PiLEY8HETssHlays2dYXdcNwAEp69iIHz8q1Q98Be9LScl\n\ WEzgaOT9U7lpIw/MWbELoMsC+Ecs1cVWBIuiIq8aSG2kRr1x3S8yVXbAohAXif2s\n\ E6puieM/VJ25iaNhkbLmDkk58QVVmn9NZNv6ETxuSQMp9e0EwbVlj68vzClQ91Y/\n\ nmAiGcLFUEwB9G0szv9+vR+oDW4IkvdFZSUbcICd2cnynnwAD395onqS4hEZO1xM\n\ Gy5ZldbTMTjgn7fChNopz15ChPBnwFIjhm+S0CyiLRQAowfknRVq2IBkj7/5kOWg\n\ 4mcxcq76HoQWK/8X/8RFL1eFVAvY7TNHYJ0RS51DMuwCNQictA==\n\ -----END CERTIFICATE-----"; /* test server key */ static const char srv_signed_key_pem[] = "-----BEGIN PRIVATE KEY-----\n\ MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCff7amw9zNSE+h\n\ rOMhBrzbbsJluUP3gmd8nOKY5MUimoPkxmAXfp2L0il+MPZT/ZEmo11q0k6J2jfG\n\ UBQ+oZW9ahNZ9gCDjbYlBblo/mqTai+LdeLO3qk53d0zrZKXvCO6sA3uKpG2WR+g\n\ +sNKxfYpIHCpanqBU6O+degIV/+WKy3nQ2Fwp7K5HUNj1u0pg0QQ18yf68LTnKFU\n\ HFjZmmaaopWki5wKSBieHivzQy6w+04HSTogHHRK/y/UcoJNSG7xnHmoPPo1vLT8\n\ CMRIYnSSgU3wJ43XBJ80WxrC2dcoZjV2XZz+XdQwCD4ZrC1ihykcAmiQA+sauNm7\n\ dztOMkGzAgMBAAECggEAIbKDzlvXDG/YkxnJqrKXt+yAmak4mNQuNP+YSCEdHSBz\n\ +SOILa6MbnvqVETX5grOXdFp7SWdfjZiTj2g6VKOJkSA7iKxHRoVf2DkOTB3J8np\n\ XZd8YaRdMGKVV1O2guQ20Dxd1RGdU18k9YfFNsj4Jtw5sTFTzHr1P0n9ybV9xCXp\n\ znSxVfRg8U6TcMHoRDJR9EMKQMO4W3OQEmreEPoGt2/+kMuiHjclxLtbwDxKXTLP\n\ pD0gdg3ibvlufk/ccKl/yAglDmd0dfW22oS7NgvRKUve7tzDxY1Q6O5v8BCnLFSW\n\ D+z4hS1PzooYRXRkM0xYudvPkryPyu+1kEpw3fNsoQKBgQDRfXJo82XQvlX8WPdZ\n\ Ts3PfBKKMVu3Wf8J3SYpuvYT816qR3ot6e4Ivv5ZCQkdDwzzBKe2jAv6JddMJIhx\n\ pkGHc0KKOodd9HoBewOd8Td++hapJAGaGblhL5beIidLKjXDjLqtgoHRGlv5Cojo\n\ zHa7Viel1eOPPcBumhp83oJ+mQKBgQDC6PmdETZdrW3QPm7ZXxRzF1vvpC55wmPg\n\ pRfTRM059jzRzAk0QiBgVp3yk2a6Ob3mB2MLfQVDgzGf37h2oO07s5nspSFZTFnM\n\ KgSjFy0xVOAVDLe+0VpbmLp1YUTYvdCNowaoTE7++5rpePUDu3BjAifx07/yaSB+\n\ W+YPOfOuKwKBgQCGK6g5G5qcJSuBIaHZ6yTZvIdLRu2M8vDral5k3793a6m3uWvB\n\ OFAh/eF9ONJDcD5E7zhTLEMHhXDs7YEN+QODMwjs6yuDu27gv97DK5j1lEsrLUpx\n\ XgRjAE3KG2m7NF+WzO1K74khWZaKXHrvTvTEaxudlO3X8h7rN3u7ee9uEQKBgQC2\n\ wI1zeTUZhsiFTlTPWfgppchdHPs6zUqq0wFQ5Zzr8Pa72+zxY+NJkU2NqinTCNsG\n\ ePykQ/gQgk2gUrt595AYv2De40IuoYk9BlTMuql0LNniwsbykwd/BOgnsSlFdEy8\n\ 0RQn70zOhgmNSg2qDzDklJvxghLi7zE5aV9//V1/ewKBgFRHHZN1a8q/v8AAOeoB\n\ ROuXfgDDpxNNUKbzLL5MO5odgZGi61PBZlxffrSOqyZoJkzawXycNtoBP47tcVzT\n\ QPq5ZOB3kjHTcN7dRLmPWjji9h4O3eHCX67XaPVMSWiMuNtOZIg2an06+jxGFhLE\n\ qdJNJ1DkyUc9dN2cliX4R+rG\n\ -----END PRIVATE KEY-----"; /* test server CA signed certificates */ static const char srv_signed_cert_pem[] = "-----BEGIN CERTIFICATE-----\n\ MIIFSzCCAzOgAwIBAgIBBDANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx\n\ DzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwGTW9zY293MRswGQYDVQQKDBJ0ZXN0\n\ LWxpYm1pY3JvaHR0cGQxITAfBgkqhkiG9w0BCQEWEm5vYm9keUBleGFtcGxlLm9y\n\ ZzEQMA4GA1UEAwwHdGVzdC1DQTAgFw0yMjA0MjAxODQzMDJaGA8yMTIyMDMyNjE4\n\ NDMwMlowZTELMAkGA1UEBhMCUlUxDzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwG\n\ TW9zY293MRswGQYDVQQKDBJ0ZXN0LWxpYm1pY3JvaHR0cGQxFzAVBgNVBAMMDnRl\n\ c3QtbWhkc2VydmVyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn3+2\n\ psPczUhPoazjIQa8227CZblD94JnfJzimOTFIpqD5MZgF36di9IpfjD2U/2RJqNd\n\ atJOido3xlAUPqGVvWoTWfYAg422JQW5aP5qk2ovi3Xizt6pOd3dM62Sl7wjurAN\n\ 7iqRtlkfoPrDSsX2KSBwqWp6gVOjvnXoCFf/list50NhcKeyuR1DY9btKYNEENfM\n\ n+vC05yhVBxY2ZpmmqKVpIucCkgYnh4r80MusPtOB0k6IBx0Sv8v1HKCTUhu8Zx5\n\ qDz6Nby0/AjESGJ0koFN8CeN1wSfNFsawtnXKGY1dl2c/l3UMAg+GawtYocpHAJo\n\ kAPrGrjZu3c7TjJBswIDAQABo4HmMIHjMAsGA1UdDwQEAwIFoDAMBgNVHRMBAf8E\n\ AjAAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMBMDEGA1UdEQQqMCiCDnRlc3QtbWhk\n\ c2VydmVyhwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMB0GA1UdDgQWBBQ57Z06WJae\n\ 8fJIHId4QGx/HsRgDDAoBglghkgBhvhCAQ0EGxYZVGVzdCBsaWJtaWNyb2h0dHBk\n\ IHNlcnZlcjARBglghkgBhvhCAQEEBAMCBkAwHwYDVR0jBBgwFoAUWHVDwKVqMcOF\n\ Nd0arI3/QB3W6SwwDQYJKoZIhvcNAQELBQADggIBAI7Lggm/XzpugV93H5+KV48x\n\ X+Ct8unNmPCSzCaI5hAHGeBBJpvD0KME5oiJ5p2wfCtK5Dt9zzf0S0xYdRKqU8+N\n\ aKIvPoU1hFixXLwTte1qOp6TviGvA9Xn2Fc4n36dLt6e9aiqDnqPbJgBwcVO82ll\n\ HJxVr3WbrAcQTB3irFUMqgAke/Cva9Bw79VZgX4ghb5EnejDzuyup4pHGzV10Myv\n\ hdg+VWZbAxpCe0S4eKmstZC7mWsFCLeoRTf/9Pk1kQ6+azbTuV/9QOBNfFi8QNyb\n\ 18jUjmm8sc2HKo8miCGqb2sFqaGD918hfkWmR+fFkzQ3DZQrT+eYbKq2un3k0pMy\n\ UySy8SRn1eadfab+GwBVb68I9TrPRMrJsIzysNXMX4iKYl2fFE/RSNnaHtPw0C8y\n\ B7memyxPRl+H2xg6UjpoKYh3+8e44/XKm0rNIzXjrwA8f8gnw2TbqmMDkj1YqGnC\n\ SCj5A27zUzaf2pT/YsnQXIWOJjVvbEI+YKj34wKWyTrXA093y8YI8T3mal7Kr9YM\n\ WiIyPts0/aVeziM0Gunglz+8Rj1VesL52FTurobqusPgM/AME82+qb/qnxuPaCKj\n\ OT1qAbIblaRuWqCsid8BzP7ZQiAnAWgMRSUg1gzDwSwRhrYQRRWAyn/Qipzec+27\n\ /w0gW9EVWzFhsFeGEssi\n\ -----END CERTIFICATE-----"; /* test server self signed certificates */ static const char srv_self_signed_cert_pem[] = "-----BEGIN CERTIFICATE-----\n" "MIIDJzCCAg+gAwIBAgIUOKf6e6Heee2XA+yF5St3t+fVM40wDQYJKoZIhvcNAQEF\n" "BQAwFDESMBAGA1UEAwwJbG9jYWxob3N0MCAXDTIyMTAxMDA4MzQ0N1oYDzIxMjIw\n" "OTE2MDgzNDQ3WjAUMRIwEAYDVQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEB\n" "AQUAA4IBDwAwggEKAoIBAQClivgF8Xq0ekQli++0l7Q5JFwJCuLf04Cb1UKIS80U\n" "CfphFd1ILJepNw4bWR3OV1sRI1vFiw6LnCz53vOwVNyiZ+sMGi4bDX4AV9Xd+F83\n" "xhG8AjOmKTayW0TxSIvt47Qd5S/4fgraxMtvqrRRBen30iKOwX7uNF/4dYb9vdin\n" "OldV/e8uzbqSurMGkNDznOeSaNBmdO/7x0VMFZM2hwmHyiiw75/j4BhUlLCcMEvK\n" "oN+YHNCNcTt3Qm1vVuiGXmh9QreOV09Gc1SzAltxF2gmI0jzw8r/duz18QXMNsMw\n" "El/Ah4+02gR70L7qlgttN1NPU3RJpK/L34J7yg649wHTAgMBAAGjbzBtMB0GA1Ud\n" "DgQWBBROVferD+YYcV1YEnFgC0jYm5X9BjAfBgNVHSMEGDAWgBROVferD+YYcV1Y\n" "EnFgC0jYm5X9BjAPBgNVHRMBAf8EBTADAQH/MBoGA1UdEQQTMBGCCWxvY2FsaG9z\n" "dIcEfwAAATANBgkqhkiG9w0BAQUFAAOCAQEAoRbozsm5xXdNX3VO++s2LMzw5KM9\n" "RpIInHNkMJbnyLJFKJ8DF7nTxSGCA38YMkX3tphPNKZXbg+V64Dqr/XpzOVyiinU\n" "7hIwyUdSSKKyErZxIWR97lY6Q3SOyPAg8ZElbtvSsSzmd772VE23VTXGDi7AW0PQ\n" "hag9N2EEnHURMvID15O+UXyFpDdyUyQIbx3HuswsGDH9xBTm4irLyrZwO0KwKg5a\n" "JBeUiPs0SYRRfn9/MoE6VwAnmOCg3LLR6ZPU3hQtTPLHj2Op1g5fey3X3X6lC+JC\n" "K6dNZc1zBFPz8KANGUsFYbmoP2bvAAA+6KwCnZZEflUgE7/HFEmQhVOezw==\n" "-----END CERTIFICATE-----\n"; /* test server key */ static const char srv_self_signed_key_pem[] = "-----BEGIN PRIVATE KEY-----\n" "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQClivgF8Xq0ekQl\n" "i++0l7Q5JFwJCuLf04Cb1UKIS80UCfphFd1ILJepNw4bWR3OV1sRI1vFiw6LnCz5\n" "3vOwVNyiZ+sMGi4bDX4AV9Xd+F83xhG8AjOmKTayW0TxSIvt47Qd5S/4fgraxMtv\n" "qrRRBen30iKOwX7uNF/4dYb9vdinOldV/e8uzbqSurMGkNDznOeSaNBmdO/7x0VM\n" "FZM2hwmHyiiw75/j4BhUlLCcMEvKoN+YHNCNcTt3Qm1vVuiGXmh9QreOV09Gc1Sz\n" "AltxF2gmI0jzw8r/duz18QXMNsMwEl/Ah4+02gR70L7qlgttN1NPU3RJpK/L34J7\n" "yg649wHTAgMBAAECggEAERbbCtYGakoy7cNX8Ac3Kiz4OVC/4gZWAQBPeX2FwrtS\n" "9yHIMbK0x1mxIZ6eBpabBpZlW2vDCSOKuxLKiloAWt2qdJnhR5apesSWhe8leT7/\n" "xq5dgZpAlMH6SIRKObknd2yY+qicW0A0licDrVeUcypkueL8xP9wJtiPInOuQXkI\n" "QROhB13eStRuRKYwOn5gtwAHJ+J1DFKKiqpBOkrSYf4625StGegJO9+bjK0ei+0W\n" "tp6unpiwA/lXTgz6Xim1Z3fzWs4XjFgVKzK5s/6yBJjr8spHX6lv7QsahP4w6HZ/\n" "VcRxP6cJNd/otiTEtJXpbxiiyccwXm/AOcOn22P1cQKBgQDAnY/0G/ap/G98pneE\n" "suzNXhWOQ8JoL8d66Io8vwTvfiJggfgUcwblI7pPCrSlaZMR7/q6JImE53lZtPk8\n" "eI3c9lN0ocr8E7+huDpYdk7cMYj9SuxySsXoMLiMqzHFi+NcIhKMF56kk6a5CFCt\n" "yP1Ofy76LVweGE3XvTwpwE7wUQKBgQDcBLyH1cC71s0I0Gz28AyELV9hPhasjAKO\n" "12CVbeBVTPd+28uk/3o80wSrTksc6H5ehAA2aTvrb4OhwssWNL+D0fS8YK2cJ3V0\n" "FJxGAM266+vC4d/8jRTHJnc+6PP3ix5t6vAt+K2Y0fePtefLqf4ebgXx/ODAj3J2\n" "aZKBldjK4wKBgGIRFpTLk/eR/dUyEBHw4x3gdAsdtqJDCUYrlQ4+ly20Q55tLbiD\n" "pBQP77CEm9rH+MgeLcKODbIsBB3HRUojet7wTydHpMhY6a1V1ebqPVZgpgWIGwBJ\n" "z59bBusf0lRo15Y2Bslq0SurvSvh7um8NjO8D1fytj7gUumvgC0lq0sxAoGBAI1+\n" "kkx9IBTtIDER8XGhkTsT/uoHxwcyh5abVmbjIclZ1TUFX2L+Vft17ePJVy8BKfvY\n" "wlY7uShBMBNAteDTDXNV/CGFv0DUc4myk4nFjIkwng9XufeuN3WX/Eo+AF/rXSdt\n" "VwcJjYLhTWdjoe1tppqlQTeN3HCaEA+s92ZVGvXnAoGAMCXGS6WZl1e5wsHRq0Yy\n" "8Ef2Wrk620bBjKHolkTfvgfhlvxeZM1sv1ioZGsOeQ0z7O7wdJhvL0M/WAG+3yQj\n" "HSXp81T1vOICPwNYZf8xcvbLKmvj7rHFt6ZAZF2o4EK8ReZTRyA3DUpBCDY+s3FN\n" "GmBv0D7N3QP0CT3SzfQrPkc=\n" "-----END PRIVATE KEY-----\n"; #endif libmicrohttpd-1.0.1/src/testcurl/https/test_https_get_iovec.c0000644000175000017500000002625414441373361020244 /* This file is part of libmicrohttpd Copyright (C) 2007-2021 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_https_get_iovec.c * @brief Testcase for libmicrohttpd HTTPS GET operations using an iovec * @author Sagie Amir * @author Karlson2k (Evgeny Grin) * @author Lawrence Sebald */ /* * This testcase is derived from the test_https_get.c testcase. This version * adds the usage of a scatter/gather array for storing the response data. */ #include "platform.h" #include "microhttpd.h" #include #include #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include "tls_test_keys.h" static uint16_t global_port; /* Use large enough pieces (>16KB) to test partially consumed * data as TLS doesn't take more than 16KB by a single call. */ #define TESTSTR_IOVLEN 20480 #define TESTSTR_IOVCNT 30 #define TESTSTR_SIZE (TESTSTR_IOVCNT * TESTSTR_IOVLEN) static void iov_free_callback (void *cls) { free (cls); } static int check_read_data (const void *ptr, size_t len) { const int *buf; size_t i; if (len % sizeof(int)) return -1; buf = (const int *) ptr; for (i = 0; i < len / sizeof(int); ++i) { if (buf[i] != (int) i) return -1; } return 0; } static enum MHD_Result iovec_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; int *data; struct MHD_IoVec iov[TESTSTR_IOVCNT]; int i; int j; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ /* Create some test data. */ if (NULL == (data = malloc (TESTSTR_SIZE))) return MHD_NO; for (j = 0; j < TESTSTR_IOVCNT; ++j) { int *chunk; /* Assign chunks of memory area in the reverse order * to make non-continous set of data therefore * possible buffer overruns could be detected */ chunk = data + (((TESTSTR_IOVCNT - 1) - (unsigned int) j) * (TESTSTR_SIZE / TESTSTR_IOVCNT / sizeof(int))); iov[j].iov_base = chunk; iov[j].iov_len = TESTSTR_SIZE / TESTSTR_IOVCNT; for (i = 0; i < (int) (TESTSTR_IOVLEN / sizeof(int)); ++i) chunk[i] = i + (j * (int) (TESTSTR_IOVLEN / sizeof(int))); } response = MHD_create_response_from_iovec (iov, TESTSTR_IOVCNT, &iov_free_callback, data); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int test_iovec_transfer (void *cls, uint16_t port, const char *cipher_suite, int proto_version) { size_t len; unsigned int ret = 0; struct CBC cbc; char url[255]; (void) cls; /* Unused. Silent compiler warning. */ len = TESTSTR_SIZE; if (NULL == (cbc.buf = malloc (sizeof (char) * len))) { fprintf (stderr, MHD_E_MEM); return 1; } cbc.size = len; cbc.pos = 0; if (gen_test_uri (url, sizeof (url), port)) { ret = 1; goto cleanup; } if (CURLE_OK != send_curl_req (url, &cbc, cipher_suite, proto_version)) { ret = 1; goto cleanup; } if ((cbc.pos != TESTSTR_SIZE) || (0 != check_read_data (cbc.buf, cbc.pos))) { fprintf (stderr, "Error: local file & received file differ.\n"); ret = 1; } cleanup: free (cbc.buf); return ret; } /* perform a HTTP GET request via SSL/TLS */ static unsigned int test_secure_get (FILE *test_fd, const char *cipher_suite, int proto_version) { unsigned int ret; struct MHD_Daemon *d; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 3045; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, port, NULL, NULL, &iovec_ahc, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_END); if (d == NULL) { fprintf (stderr, MHD_E_SERVER_INIT); return 1; } if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 1; } port = dinfo->port; } ret = test_iovec_transfer (test_fd, port, cipher_suite, proto_version); MHD_stop_daemon (d); return ret; } static enum MHD_Result ahc_empty (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; struct MHD_IoVec iov; (void) cls; (void) url; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; iov.iov_base = NULL; iov.iov_len = 0; response = MHD_create_response_from_iovec (&iov, 1, NULL, NULL); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) { fprintf (stderr, "Failed to queue response.\n"); _exit (20); } return ret; } static int curlExcessFound (CURL *c, curl_infotype type, char *data, size_t size, void *cls) { static const char *excess_found = "Excess found"; const size_t str_size = strlen (excess_found); (void) c; /* Unused. Silence compiler warning. */ #ifdef _DEBUG if ((CURLINFO_TEXT == type) || (CURLINFO_HEADER_IN == type) || (CURLINFO_HEADER_OUT == type)) fprintf (stderr, "%.*s", (int) size, data); #endif /* _DEBUG */ if ((CURLINFO_TEXT == type) && (size >= str_size) && (0 == strncmp (excess_found, data, str_size))) *(int *) cls = 1; return 0; } static unsigned int testEmptyGet (unsigned int poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; int excess_found = 0; if ( (0 == global_port) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { global_port = 1225; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag | MHD_USE_TLS, global_port, NULL, NULL, &ahc_empty, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_END); if (d == NULL) return 4194304; if (0 == global_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } global_port = dinfo->port; } c = curl_easy_init (); #ifdef _DEBUG curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); #endif curl_easy_setopt (c, CURLOPT_URL, "https://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_PORT, (long) global_port); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &curlExcessFound); curl_easy_setopt (c, CURLOPT_DEBUGDATA, &excess_found); curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 8388608; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != 0) return 16777216; if (excess_found) return 33554432; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ #ifdef MHD_HTTPS_REQUIRE_GCRYPT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ if (! testsuite_curl_global_init ()) return 99; if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); curl_global_cleanup (); return 77; } errorCount += test_secure_get (NULL, NULL, CURL_SSLVERSION_DEFAULT); errorCount += testEmptyGet (0); curl_global_cleanup (); return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/mhdhost1.key0000644000175000017500000000325014417460232016100 -----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDFvkuTBN+821Z4 VJgA+gTOrBUBFbEMNHY99CaYG2seEw0RDJQJOD41rTSERBtxlvPt+BLQU5jWGPIw UlqY0Y/TfUe8xLvMc1AngdsTPR3US54+CMS9ZoUwWdxMoafTsKf17dFy/aKEn8gj zB/emH+T9RM6/rZiEizZ8xAzksPqhf26UomEBo68VPqHKsHXF7edWE9PQ+ytReWT LbneTtdcQAhY7p0tmcrfvtSJEMkicVL0U3+GiMVv7yBwHKj+ff0scwG2nlYYzn7E bAQfJiTC2dozwgQqh9tQ0RFBPdyA+/jM3ufLcvCWNHYDVzmAdeYo7sbbjm1t+ptW 06Hf7VslAgMBAAECggEALshrttezW0oFNijFYY3FL2Q0//Gy1nFe/B9UNi5edFoL gFoad+fvh+F3iEdYutH82fMT+GeexCBYxCfnuTnzLhT4sOdWivNJJl+phe6yrPRK 9uA6M5kar6rC3Ppt6z5jLmLaZ7ssBPaMcjOr4ozvugCEUTPL0H3+UH4Z+imh4kzw MgLsF8QkWPCF/fxsVhCwC3y3Dctl3oLh6qQFudYKtymRjk2I7zFAuQGsGoYonPbF 1LZ6xHOjegXtqhC0pK8Kpn4N7LgYVVNPT1TAckQ9GDDi0IgMYwIsSQb/ncaV5Cwb 9tPqBv1Oi2ayINeXrG5J/G8S1cEbIzdSL8ZqG+CcjQKBgQD1c89Rh/Hbc0zxxgdR eGx6oOtNjAZ3zgnNyVnXiZ7mXtbCcjMHJhcW41RL8lg+mhKfj9MgXamDP/R4X2In H358dEekfN4wjogeXs9lmh48cGC7zez4/RS752OmrwmhOqkKDa7dy+SLR5QJ3L2n 4k/2eQwTlXpuPIMrBT1hUvsA3wKBgQDOPaTy03oXX1bwwX6sHUTrQTKAC52v4hQl bya+6t+VGpj+cdWzxRFoR5mN85b9Kkj1nAFx+6zioOPLUOZhnnqihlQBwm06gH1p v3qkxuXOhnMPJsNg4lltUq/18UlSQwFZuKr7G2vDhckHwZdlu06P/rlA9K5Kxjzi gX3I+XoQewKBgQDrn/YYXXmW4jOuMR0bX5A7lDjuY4pd/iO5Mh6V453vpoFhfoFv zmgB588nbQi7Z+qS1F2nx2IQBhgoaeBukDQ7QuD3jYs6b8lJ5lgQQAfgmzyxbPic +U6rJ3CpNYT4Crj1VrdUYgQOlHMPmKFUBdQfVop6TleOdXaxmMEYqbEdXwKBgQCz xZwQZjJYSSyZc7CdCm5Wul/wqS9sbp6s+rRFWqpFaAfQUx26M582zKKWz6vfRYqP PMsttfk/Gos1YHFQyjmPjZOQbQ+VHQc0tEmNdCpA2YVVwa4wt1zIJHlo4kfNQsbc lFHFzGMk7WsMLb1wWdLjRV/ptN5wI1hTABjKpFu4HQKBgExQNTHMxzpAAh9XFiJ3 oGvf+9+JtjmrgKsR0T7q60xjOYH0E2rznvvBVNeZlAc+tjawmedxiuiitmjQUteG hW4ncX0UcqFPm7Ahqo9+NDemJlV7DYHRcvL/xVNUbr8yV7OpHILd4Hk/s8J4QGl/ bC1zEehy8q0jMywvSR8vsS1v -----END PRIVATE KEY----- libmicrohttpd-1.0.1/src/testcurl/https/test_tls_options.c0000644000175000017500000003403414441373361017426 /* This file is part of libmicrohttpd Copyright (C) 2007, 2016 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_tls_options.c * @brief Testcase for libmicrohttpd HTTPS TLS version match/mismatch * @author Sagie Amir * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include "tls_test_keys.h" /* * HTTP access handler call back * used to query negotiated security parameters */ static enum MHD_Result simple_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (NULL == *req_cls) { *req_cls = (void *) &simple_ahc; return MHD_YES; } response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (EMPTY_PAGE), EMPTY_PAGE); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } enum check_result { CHECK_RES_OK = 0, CHECK_RES_ERR = 1, CHECK_RES_MHD_START_FAILED = 17, CHECK_RES_CURL_TLS_INIT_FAIL = 18, CHECK_RES_CURL_TLS_CONN_FAIL = 19, CHECK_RES_HARD_ERROR = 99 }; static enum check_result check_tls_match_inner (enum know_gnutls_tls_id tls_ver_mhd, enum know_gnutls_tls_id tls_ver_libcurl, uint16_t *pport, struct MHD_Daemon **d_ptr, struct CBC *pcbc, CURL **c_ptr) { CURLcode errornum; char url[256]; int libcurl_tls_set; CURL *c; struct MHD_Daemon *d; /* setup test */ d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, *pport, NULL, NULL, &simple_ahc, NULL, MHD_OPTION_HTTPS_PRIORITIES, priorities_map[tls_ver_mhd], MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); fflush (stderr); fflush (stdout); *d_ptr = d; if (d == NULL) { fprintf (stderr, "MHD_start_daemon() with %s failed.\n", tls_names[tls_ver_mhd]); return CHECK_RES_MHD_START_FAILED; } if (0 == *pport) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { fprintf (stderr, "MHD_get_daemon_info() failed.\n"); return CHECK_RES_ERR; } *pport = dinfo->port; /* Use the same port for rest of the checks */ } if (0 != gen_test_uri (url, sizeof (url), *pport)) { fprintf (stderr, "failed to generate URI.\n"); return CHECK_RES_CURL_TLS_INIT_FAIL; } c = curl_easy_init (); fflush (stderr); fflush (stdout); *c_ptr = c; if (NULL == c) { fprintf (stderr, "curl_easy_init() failed.\n"); return CHECK_RES_HARD_ERROR; } #ifdef _DEBUG curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); #endif if ((CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_URL, url))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_TIMEOUT, 10L))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 10L))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_WRITEDATA, pcbc))) || /* TLS options */ /* currently skip any peer authentication */ (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)))) { fflush (stderr); fflush (stdout); fprintf (stderr, "Error setting libcurl option: %s.\n", curl_easy_strerror (errornum)); return CHECK_RES_HARD_ERROR; } libcurl_tls_set = 0; #if CURL_AT_LEAST_VERSION (7,54,0) if (CURL_SSLVERSION_MAX_DEFAULT != libcurl_tls_max_vers_map[tls_ver_libcurl]) { errornum = curl_easy_setopt (c, CURLOPT_SSLVERSION, libcurl_tls_vers_map[tls_ver_libcurl] | libcurl_tls_max_vers_map[tls_ver_libcurl]); if (CURLE_OK == errornum) libcurl_tls_set = 1; else { fprintf (stderr, "Error setting libcurl TLS version range: " "%s.\nRetrying with minimum TLS version only.\n", curl_easy_strerror (errornum)); } } #endif /* CURL_AT_LEAST_VERSION(7,54,0) */ if (! libcurl_tls_set && (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_SSLVERSION, libcurl_tls_vers_map[tls_ver_libcurl])))) { fprintf (stderr, "Error setting libcurl minimum TLS version: %s.\n", curl_easy_strerror (errornum)); return CHECK_RES_CURL_TLS_INIT_FAIL; } errornum = curl_easy_perform (c); fflush (stderr); fflush (stdout); if (CURLE_OK != errornum) { if ((CURLE_SSL_CONNECT_ERROR == errornum) || (CURLE_SSL_CIPHER == errornum)) { fprintf (stderr, "libcurl request failed due to TLS error: '%s'\n", curl_easy_strerror (errornum)); return CHECK_RES_CURL_TLS_CONN_FAIL; } else { fprintf (stderr, "curl_easy_perform failed: '%s'\n", curl_easy_strerror (errornum)); return CHECK_RES_ERR; } } return CHECK_RES_OK; } /** * negotiate a secure connection with server with specific TLS versions * set for MHD and for libcurl */ static enum check_result check_tls_match (enum know_gnutls_tls_id tls_ver_mhd, enum know_gnutls_tls_id tls_ver_libcurl, uint16_t *pport) { CURL *c; struct CBC cbc; enum check_result ret; struct MHD_Daemon *d; if (NULL == (cbc.buf = malloc (sizeof (char) * 255))) return CHECK_RES_HARD_ERROR; cbc.size = 255; cbc.pos = 0; d = NULL; c = NULL; ret = check_tls_match_inner (tls_ver_mhd, tls_ver_libcurl, pport, &d, &cbc, &c); fflush (stderr); fflush (stdout); if (NULL != d) MHD_stop_daemon (d); if (NULL != c) curl_easy_cleanup (c); free (cbc.buf); return ret; } static unsigned int test_first_supported_versions (void) { enum know_gnutls_tls_id ver_for_check; /**< TLS version used for test */ const gnutls_protocol_t *vers_list; /**< The list of GnuTLS supported TLS versions */ uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; /* Use system automatic assignment */ else port = 3080; /* Use predefined port, may break parallel testing of another MHD build */ vers_list = gnutls_protocol_list (); if (NULL == vers_list) { fprintf (stderr, "Error getting GnuTLS supported TLS versions"); return 99; } for (ver_for_check = KNOWN_TLS_MIN; KNOWN_TLS_MAX >= ver_for_check; ++ver_for_check) { const gnutls_protocol_t *ver_ptr; /**< The pointer to the position on the @a vers_list */ enum check_result res; for (ver_ptr = vers_list; 0 != *ver_ptr; ++ver_ptr) { if (ver_for_check == (enum know_gnutls_tls_id) *ver_ptr) break; } if (0 == *ver_ptr) { printf ("%s is not supported by GnuTLS, skipping.\n\n", tls_names[ver_for_check]); fflush (stdout); continue; } if (CURL_SSLVERSION_LAST == libcurl_tls_vers_map[ver_for_check]) { printf ("%s is not supported by libcurl, skipping.\n\n", tls_names[ver_for_check]); fflush (stdout); continue; } /* Found some TLS version that supported by GnuTLS and should be supported by libcurl (but in practice support depends on used TLS library) */ if (KNOWN_TLS_MIN != ver_for_check) printf ("\n"); printf ("Starting check with MHD set to '%s' and " "libcurl set to '%s' (successful connection is expected)...\n", tls_names[ver_for_check], tls_names[ver_for_check]); fflush (stdout); /* Check with MHD and libcurl set to the same TLS version */ res = check_tls_match (ver_for_check, ver_for_check, &port); if (CHECK_RES_HARD_ERROR == res) { fprintf (stderr, "Hard error. Test stopped.\n"); fflush (stderr); return 99; } else if (CHECK_RES_ERR == res) { printf ("Test failed.\n"); fflush (stdout); return 2; } else if (CHECK_RES_MHD_START_FAILED == res) { printf ("Skipping '%s' as MHD cannot be started with this setting.\n", tls_names[ver_for_check]); fflush (stdout); continue; } else if (CHECK_RES_CURL_TLS_INIT_FAIL == res) { printf ("Skipping '%s' as libcurl rejected this setting.\n", tls_names[ver_for_check]); fflush (stdout); continue; } else if (CHECK_RES_CURL_TLS_CONN_FAIL == res) { printf ("Skipping '%s' as it is not supported by current libcurl " "and GnuTLS combination.\n", tls_names[ver_for_check]); fflush (stdout); continue; } printf ("Connection succeeded for MHD set to '%s' and " "libcurl set to '%s'.\n\n", tls_names[ver_for_check], tls_names[ver_for_check]); /* Check with libcurl set to the next TLS version relative to MHD setting */ if (KNOWN_TLS_MAX == ver_for_check) { printf ("Test is incomplete as the latest known TLS version ('%s') " "was found as minimum working version.\nThere is no space to " "advance to the next version.\nAssuming that test is fine.\n", tls_names[ver_for_check]); fflush (stdout); return 0; } if (CURL_SSLVERSION_LAST == libcurl_tls_vers_map[ver_for_check + 1]) { printf ("Test is incomplete as '%s' is the latest version supported " "by libcurl.\nThere is no space to " "advance to the next version.\nAssuming that test is fine.\n", tls_names[ver_for_check]); fflush (stdout); return 0; } printf ("Starting check with MHD set to '%s' and " "minimum libcurl TLS version set to '%s' " "(failed connection is expected)...\n", tls_names[ver_for_check], tls_names[ver_for_check + 1]); fflush (stdout); res = check_tls_match (ver_for_check, ver_for_check + 1, &port); if (CHECK_RES_HARD_ERROR == res) { fprintf (stderr, "Hard error. Test stopped.\n"); fflush (stderr); return 99; } else if (CHECK_RES_ERR == res) { printf ("Test failed.\n"); fflush (stdout); return 2; } else if (CHECK_RES_MHD_START_FAILED == res) { printf ("MHD cannot be started for the second time with " "the same setting.\n"); fflush (stdout); return 4; } else if (CHECK_RES_CURL_TLS_INIT_FAIL == res) { printf ("'%s' has been rejected by libcurl.\n" "Assuming that test is fine.\n", tls_names[ver_for_check + 1]); fflush (stdout); return 0; } else if (CHECK_RES_CURL_TLS_CONN_FAIL == res) { printf ("As expected, libcurl cannot connect to MHD when libcurl " "minimum TLS version is set to '%s' while MHD TLS version set " "to '%s'.\n" "Test succeeded.\n", tls_names[ver_for_check + 1], tls_names[ver_for_check]); fflush (stdout); return 0; } } fprintf (stderr, "The test skipped: No know TLS versions are supported by " "both MHD and libcurl.\n"); fflush (stderr); return 77; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; const char *ssl_version; (void) argc; /* Unused. Silent compiler warning. */ #ifdef MHD_HTTPS_REQUIRE_GCRYPT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ if (! testsuite_curl_global_init ()) return 99; ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); curl_global_cleanup (); return 77; } errorCount = test_first_supported_versions (); fflush (stderr); fflush (stdout); curl_global_cleanup (); if (77 == errorCount) return 77; else if (99 == errorCount) return 99; print_test_result (errorCount, argv[0]); return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/test-ca.key0000644000175000017500000000625714417460232015723 -----BEGIN RSA PRIVATE KEY----- MIIJKgIBAAKCAgEA3WlrqQOKmYwgTZCaCTpucZwmos5d+mS1MKeMQS/2H1z1hNy5 JgERIlSP2JwG/JehuwiZ8/HU7DiVpDVxuk9SlT+f9kbwSCGmmrn0SAJe4RJ49Y/R NoUJVdn8RdmTYc/p6otC6ileCyUqXJZFwA39hQPR7FUT/we82Ifgz9H0lPFem7Lv FwnkRrIa6AD63PKx/JRRBF6TSzSKkK/MisekpnQeoX42uukkNPvqgYZdGibZ+Cx1 maIYIwZpCGhhT2CCS4MUP8cqdhq89qu5RiifswZARfIjj7d8fhdYUggZ6/wxmFpo xJubWJvu6crq4j3XV3QnPPqmti8TGaNxF8S6OWCEqTwssGe1d2ADmU695tQtuC4m Lz3oQqtQkyJIYZqrZVSV1OyEg+PHMfcvuT4t+MLW0yP4DceL6MkywH8mryjJiKcc SEbFpXYhdp9Oh3bwkVXYoQ0FGnddMoE5ln9Sf7NmREwLR0GknezA9/Pbep0BbUyF 4oLDSp5wz5a7cbe6zi7y0HkdCtOBs63/7HIXjmp0QHzlxyjQRVO2JAxRvK6os5Qu ua8fanlxWF0HB2U7qsSu7YGZ0oCWrdxO9FW00grBBBu3kWzV/3woVCgCCKVmoluh w5Si5eptsvgczPdbpgbCjqk757TFRQUhfaVWJVyvOeGiEavANl7o3dNdrHkCAwEA AQKCAgEA2nPJ4j75P9gOgxj5scMx9uve/uDnvkYgszmMW0DL8FPSdd0k3AdPdXTD XC9NgWjGDHhHFXXz44FMu3BzniPnUhQtalrBdhmlfKGeEHIuVJjaOUZFYCpQdKEX k39BN89gdqYiRlC8Vfi8XA90EDJ9gQCs3SVwDj7/JxChUcpQK6gd9TbNSQjcbpgJ jgBxgw/9Zjyb1tjNMPVNBcY95Gtn20dUdXfG3hFrRM+Mp3D/aO8OPhr3iLZyZBRO CxqZcCzDQWe50dda4J4u9J2ntj4cmxC+14Q5a/HYZbv4yy7tDHWOJUiGd/0jf4CS b59isgfb8JBMqpCPbc7yZGhrC81xAZdsw0jvDYgGUf86785983clipdCVJIKMqZm yjoo2DuSaivCGnaWUV1f+W2CgigpSXcDQ1/gDMt7xVoZNpfmdTgZzthUxXK3dFYO Jwem/ls6KD5THKpkHuA9BpnoksnpZqREK5FdMw8hCUpJEe1kXy4ZlQB91Ya74HQ0 tgygL9BwEXDJ2vU14Onq8CH+Ul4kOzXnqMae35eKj1+/QI2PP1Wuk/vypSmrurfm 3YLsnwm7OYSuWrAfFRmGTMhfny3v1xlw1ynmVBvxgQ2v2czxKGw8JG+9LoqbSB5O GP05Gpcys1CwR9Z2EjfExFNcWFIJQjwcZemlgHHwvHCBy1fz0AUCggEBAPSnznDv Wuj3gTkUDfNFTplsa8z3GIyrfBYDUyGJ51YiN5C2myGRcu60r5iMl4hxXC6mL4Cd 5ew8LsXojPmC0sWZ2Cp+uhSH5FZaMNRumg4R8EA0Phwi0iBgDXM5318reMZF3BUr FSTn9a3nBkFpYMw1hxBlLj0o6S0TfZBmviTJUO7eiq6mAdO43l320Pw7E6xSWble QQaXzk2yGr2bV02heZcWfw+Fnui6xLruWZbVdvh+Q5KEJv90y9HcXm14LXiPRMBg zYvbW6tVZSQeXTs4wGC1RAZWZC7MG0XOoVj18WGx8hSZQND6awxFwHbItSlv05TX QkJ9ybZ7bcOQT78CggEBAOetsug2BQejAwRbbAsC078Vlr6PUspHmeT1Efp8ArFq rsmx2n2EoIcZSLkedZK1cXN7HMxVz1U0yx7k/OLIKlsfGNQdAQhCW875mbn0ET0c jUNpeJRXL6U5pwdPrsENyyAPsDyCsBT4ArGuEIFIxPlWtZTBzOAhJN9AwB5KW8g/ zg1mwv1TCNNlQu3Ex46egI3cCUk+6b1BNwPuSKhuP+P22Vg+JBhIY+/iSJvgSRfP 3LCNU0ds2D5xiwJNVwzVtrn3wIaYHj6S7lhfVGWdvQb8RsF9kyR06yJNTUyyybZ0 pTHeRwNtbUoTeBUlwoBac6izNyGGguA42pDYmoAcEccCggEAfXgZrV1zWAqmoOki BmLC3nf2CRWn52yCpJ9r4MVieI/vwy2C/YIkWTsc2rUveW/5gIsFzYYsxixPKHwM 4GExStmNPK3lLGZMueRjKm7WXuTgO20PdUp+TNA11aQWZC5dMAHfzpNbsqOrIVZb pOwwEkpZTBU303HJs65NNOMcHK2J7hb/NHY6daRXlgTgRJrfif5puWEXJBRyXvI6 OIcUDOIFA3EsFH/IcT5nah6Wn342F1ZZvSg8/8GcTbIgUy/Q0gVXkvmSMGl8569R wWY5FggS0QXlLwLbOgy+59wCbycidaHWrq2xyfrDL3YOMFzaW7fX4HtMpeDws781 GZhG7QKCAQEAhCfJTjzCUcDjD7E2yHEsaGvgOYN4Lnr5hmllgAUNZDb+zX7uq3rk NyxtF2wQlUd7F+y6WLT6OBiNZWop9xNHVgM/HoAM/rEbvc0Tq8dVrg6DZljbt4Kk YxOn+7uwa996ZyeL2HiUCOIQZ1prf9QKyFB19A042QEPD2rYLG8uO+RpnatovyiG eE/jBc6iJvCzVDiX83g3zQVOZKegOrPpLhi5kmSgIlno6AWkdYZTK4oe0XdMcgnc sIIEUaPcbC3ctehlomFTn04hN7fpZK2+DiYKFoWTUdB/8Gk4FvBFsBaJxRCOYZ4i IYdJkIahlKYEI89XO4CHV3AW/VkRiNJ6MQKCAQEAhosdYqtpJtdRJ3FWM4i6Miua OBEg7FU4JTH/0cekj0UMYFww3KK9c4KEdgVwRtsvLTZ++CXZ3XF9Er+6nPmC6nAo 46b3Ow7rPzpm18jUNWMW0s+CZwKWkGe1sbek81L8SBCDRJKKhl6XgiPHGB/i8g65 ZQv3B47BPflrjxJCQVADHpdW5vo0xY7xRr9zKYoAl4LQBTwLVMTP229iIcBFvRPp rs4KUecFQfEyXrJLwgQTl0uBItO86BWopCdh7T/0A7BjBk9jdklJNgml8Ctq+Yt9 nqduIeW3c1aNqbNhn+IA27WW+tv+yzA4gNPS/OWr8J67HDGm4WSUAFGMLwmcSw== -----END RSA PRIVATE KEY----- libmicrohttpd-1.0.1/src/testcurl/https/test_https_get.c0000644000175000017500000001654414441373361017060 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_https_get.c * @brief Testcase for libmicrohttpd HTTPS GET operations * @author Sagie Amir * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include "tls_test_keys.h" static uint16_t global_port; /* perform a HTTP GET request via SSL/TLS */ static unsigned int test_secure_get (const char *cipher_suite, int proto_version) { unsigned int ret; struct MHD_Daemon *d; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 3041; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, port, NULL, NULL, &http_ahc, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_END); if (d == NULL) { fprintf (stderr, MHD_E_SERVER_INIT); return 1; } if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 1; } port = dinfo->port; } ret = test_https_transfer (NULL, port, cipher_suite, proto_version); MHD_stop_daemon (d); return ret; } static enum MHD_Result ahc_empty (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) url; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; response = MHD_create_response_empty (MHD_RF_NONE); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) { fprintf (stderr, "Failed to queue response.\n"); _exit (20); } return ret; } static int curlExcessFound (CURL *c, curl_infotype type, char *data, size_t size, void *cls) { static const char *excess_found = "Excess found"; const size_t str_size = strlen (excess_found); (void) c; /* Unused. Silence compiler warning. */ #ifdef _DEBUG if ((CURLINFO_TEXT == type) || (CURLINFO_HEADER_IN == type) || (CURLINFO_HEADER_OUT == type)) fprintf (stderr, "%.*s", (int) size, data); #endif /* _DEBUG */ if ((CURLINFO_TEXT == type) && (size >= str_size) && (0 == strncmp (excess_found, data, str_size))) *(int *) cls = 1; return 0; } static unsigned int testEmptyGet (unsigned int poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; int excess_found = 0; if ( (0 == global_port) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { global_port = 1225; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag | MHD_USE_TLS, global_port, NULL, NULL, &ahc_empty, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_END); if (d == NULL) return 4194304; if (0 == global_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } global_port = dinfo->port; } c = curl_easy_init (); #ifdef _DEBUG curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); #endif curl_easy_setopt (c, CURLOPT_URL, "https://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_PORT, (long) global_port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &curlExcessFound); curl_easy_setopt (c, CURLOPT_DEBUGDATA, &excess_found); curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 8388608; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != 0) return 16777216; if (excess_found) return 33554432; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ #ifdef MHD_HTTPS_REQUIRE_GCRYPT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ if (! testsuite_curl_global_init ()) return 99; if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); curl_global_cleanup (); return 77; } errorCount += test_secure_get (NULL, CURL_SSLVERSION_DEFAULT); errorCount += testEmptyGet (0); curl_global_cleanup (); return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/test_empty_response.c0000644000175000017500000001576114441373361020133 /* This file is part of libmicrohttpd Copyright (C) 2013 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_empty_response.c * @brief Testcase for libmicrohttpd HTTPS GET operations with empty reply * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include #include #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include "tls_test_keys.h" static int oneone; static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ response = MHD_create_response_empty (MHD_RF_NONE); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int testInternalSelectGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; int maxposixs; /* Max socket number unused on W32 */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 3000; multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_TLS | MHD_USE_INTERNAL_POLLING_THREAD, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); #ifdef _DEBUG curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); #endif curl_easy_setopt (c, CURLOPT_URL, "https://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); /* TLS options */ curl_easy_setopt (c, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT); curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 != maxposixs) { if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) abort (); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws. fd_count) || (0 != es.fd_count) ) abort (); Sleep (1000); #endif } } else (void) sleep (1); curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != 0) return 8192; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ oneone = 1; if (! testsuite_curl_global_init ()) return 99; if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); curl_global_cleanup (); return 77; } if (0 != (errorCount = testInternalSelectGet ())) fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount); curl_global_cleanup (); return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/test_https_time_out.c0000644000175000017500000001557014441373361020124 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_https_time_out.c * @brief: daemon TLS timeout test * * @author Sagie Amir * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include "tls_test_common.h" #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #ifdef HAVE_SIGNAL_H #include #endif /* HAVE_SIGNAL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ #include "mhd_sockets.h" /* only macros used */ #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #include "tls_test_keys.h" static const unsigned int timeout_val = 2; static volatile unsigned int num_connects = 0; static volatile unsigned int num_disconnects = 0; /** * Pause execution for specified number of milliseconds. * @param ms the number of milliseconds to sleep */ static void _MHD_sleep (uint32_t ms) { #if defined(_WIN32) Sleep (ms); #elif defined(HAVE_NANOSLEEP) struct timespec slp = {ms / 1000, (ms % 1000) * 1000000}; struct timespec rmn; int num_retries = 0; while (0 != nanosleep (&slp, &rmn)) { if (num_retries++ > 8) break; slp = rmn; } #elif defined(HAVE_USLEEP) uint64_t us = ms * 1000; do { uint64_t this_sleep; if (999999 < us) this_sleep = 999999; else this_sleep = us; /* Ignore return value as it could be void */ usleep (this_sleep); us -= this_sleep; } while (us > 0); #else sleep ((ms + 999) / 1000); #endif } static void socket_cb (void *cls, struct MHD_Connection *c, void **socket_context, enum MHD_ConnectionNotificationCode toe) { if (NULL == socket_context) abort (); if (NULL == c) abort (); if (NULL != cls) abort (); if (MHD_CONNECTION_NOTIFY_STARTED == toe) { num_connects++; #ifdef _DEBUG fprintf (stderr, "MHD: Connection has started.\n"); #endif /* _DEBUG */ } else if (MHD_CONNECTION_NOTIFY_CLOSED == toe) { num_disconnects++; #ifdef _DEBUG fprintf (stderr, "MHD: Connection has closed.\n"); #endif /* _DEBUG */ } else abort (); } static unsigned int test_tls_session_time_out (gnutls_session_t session, uint16_t port) { int ret; MHD_socket sd; struct sockaddr_in sa; sd = socket (AF_INET, SOCK_STREAM, 0); if (sd == MHD_INVALID_SOCKET) { fprintf (stderr, "Failed to create socket: %s\n", strerror (errno)); return 2; } memset (&sa, '\0', sizeof (struct sockaddr_in)); sa.sin_family = AF_INET; sa.sin_port = htons (port); sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); ret = connect (sd, (struct sockaddr *) &sa, sizeof (struct sockaddr_in)); if (ret < 0) { fprintf (stderr, "Error: %s\n", MHD_E_FAILED_TO_CONNECT); MHD_socket_close_chk_ (sd); return 2; } #if (GNUTLS_VERSION_NUMBER + 0 >= 0x030109) && ! defined(_WIN64) gnutls_transport_set_int (session, (int) (sd)); #else /* GnuTLS before 3.1.9 or Win64 */ gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) (intptr_t) (sd)); #endif /* GnuTLS before 3.1.9 or Win64 */ ret = gnutls_handshake (session); if (ret < 0) { fprintf (stderr, "Handshake failed\n"); MHD_socket_close_chk_ (sd); return 2; } _MHD_sleep (timeout_val * 1000 + 1700); if (0 == num_connects) { fprintf (stderr, "MHD has not detected any connection attempt.\n"); MHD_socket_close_chk_ (sd); return 4; } /* check that server has closed the connection */ if (0 == num_disconnects) { fprintf (stderr, "MHD has not detected any disconnections.\n"); MHD_socket_close_chk_ (sd); return 1; } MHD_socket_close_chk_ (sd); return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; struct MHD_Daemon *d; gnutls_session_t session; gnutls_certificate_credentials_t xcred; uint16_t port; (void) argc; /* Unused. Silent compiler warning. */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 3070; #ifdef MHD_SEND_SPIPE_SUPPRESS_NEEDED #if defined(HAVE_SIGNAL_H) && defined(SIGPIPE) if (SIG_ERR == signal (SIGPIPE, SIG_IGN)) { fprintf (stderr, "Error suppressing SIGPIPE signal.\n"); exit (99); } #else /* ! HAVE_SIGNAL_H || ! SIGPIPE */ fprintf (stderr, "Cannot suppress SIGPIPE signal.\n"); /* exit (77); */ #endif #endif /* MHD_SEND_SPIPE_SUPPRESS_NEEDED */ #ifdef MHD_HTTPS_REQUIRE_GCRYPT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ if (GNUTLS_E_SUCCESS != gnutls_global_init ()) { fprintf (stderr, "Cannot initialize GnuTLS.\n"); exit (99); } gnutls_global_set_log_level (11); d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, port, NULL, NULL, &http_dummy_ahc, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout_val, MHD_OPTION_NOTIFY_CONNECTION, &socket_cb, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); if (NULL == d) { fprintf (stderr, MHD_E_SERVER_INIT); return -1; } if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 99; } port = dinfo->port; } if (0 != setup_session (&session, &xcred)) { fprintf (stderr, "failed to setup session\n"); return 1; } errorCount += test_tls_session_time_out (session, port); teardown_session (session, xcred); print_test_result (errorCount, argv[0]); MHD_stop_daemon (d); gnutls_global_deinit (); return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/Makefile.am0000644000175000017500000000661214556233374015711 # This Makefile.am is in the public domain EMPTY_ITEM = SUBDIRS = . @HEAVY_TESTS_NOTPARALLEL@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/microhttpd \ -DMHD_CPU_COUNT=$(CPU_COUNT) \ -DSRCDIR=\"$(srcdir)\" \ $(CPPFLAGS_ac) $(LIBCURL_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) AM_CFLAGS = $(CFLAGS_ac) @LIBGCRYPT_CFLAGS@ AM_LDFLAGS = $(LDFLAGS_ac) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) if USE_COVERAGE AM_CFLAGS += --coverage endif $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(MHD_TLS_LIB_LDFLAGS) $(MHD_TLS_LIBDEPS) @LIBGCRYPT_LIBS@ @LIBCURL@ if HAVE_GNUTLS_SNI TEST_HTTPS_SNI = test_https_sni endif if !HAVE_GNUTLS_MTHREAD_BROKEN HTTPS_PARALLEL_TESTS = \ test_https_time_out \ test_https_get_parallel \ test_https_get_parallel_threads endif THREAD_ONLY_TESTS = \ test_tls_options \ test_tls_authentication \ $(HTTPS_PARALLEL_TESTS) \ $(TEST_HTTPS_SNI) \ test_https_session_info \ test_https_session_info_append \ test_https_multi_daemon \ test_https_get \ test_empty_response \ test_https_get_iovec \ $(EMPTY_ITEM) check_PROGRAMS = \ test_https_get_select if USE_THREADS check_PROGRAMS += \ $(THREAD_ONLY_TESTS) endif EXTRA_DIST = \ test-ca.crt test-ca.key \ mhdhost1.crt mhdhost1.key \ mhdhost2.crt mhdhost2.key TESTS = \ $(check_PROGRAMS) test_https_time_out_SOURCES = \ test_https_time_out.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_tls_options_SOURCES = \ test_tls_options.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_parallel_SOURCES = \ test_https_get_parallel.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_parallel_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_https_get_parallel_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_empty_response_SOURCES = \ test_empty_response.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_parallel_threads_SOURCES = \ test_https_get_parallel_threads.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_parallel_threads_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_https_get_parallel_threads_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_tls_authentication_SOURCES = \ test_tls_authentication.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_session_info_SOURCES = \ test_https_session_info.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_session_info_append_SOURCES = $(test_https_session_info_SOURCES) test_https_multi_daemon_SOURCES = \ test_https_multi_daemon.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_SOURCES = \ test_https_get.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_iovec_SOURCES = \ test_https_get_iovec.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_sni_SOURCES = \ test_https_sni.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_select_SOURCES = \ test_https_get_select.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c libmicrohttpd-1.0.1/src/testcurl/https/tls_test_common.h0000644000175000017500000001561614556022036017232 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2017-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef TLS_TEST_COMMON_H_ #define TLS_TEST_COMMON_H_ #include "platform.h" #include "microhttpd.h" #include #include #include #include #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #define test_data "Hello World\n" #define ca_cert_file_name SRCDIR "/test-ca.crt" #define EMPTY_PAGE \ "Empty pageEmpty page" #define PAGE_NOT_FOUND \ "File not foundFile not found" #define MHD_E_MEM "Error: memory error\n" #define MHD_E_SERVER_INIT "Error: failed to start server\n" #define MHD_E_TEST_FILE_CREAT "Error: failed to setup test file\n" #define MHD_E_CERT_FILE_CREAT "Error: failed to setup test certificate\n" #define MHD_E_KEY_FILE_CREAT "Error: failed to setup test certificate\n" #define MHD_E_FAILED_TO_CONNECT \ "Error: server connection could not be established\n" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ /* The local copy if GnuTLS IDs to avoid long #ifdefs list with various * GnuTLS versions */ /** * The list of know (at the moment of writing) GnuTLS IDs of TLS versions. * Can be safely casted to/from @a gnutls_protocol_t. */ enum know_gnutls_tls_id { KNOWN_BAD = 0, /**< No TLS */ KNOWN_TLS_SSLv3 = 1, /**< GNUTLS_SSL3 */ KNOWN_TLS_V1_0 = 2, /**< GNUTLS_TLS1_0 */ KNOWN_TLS_V1_1 = 3, /**< GNUTLS_TLS1_1 */ KNOWN_TLS_V1_2 = 4, /**< GNUTLS_TLS1_2 */ KNOWN_TLS_V1_3 = 5, /**< GNUTLS_TLS1_3 */ KNOWN_TLS_MIN = KNOWN_TLS_SSLv3, /**< Minimum valid value */ KNOWN_TLS_MAX = KNOWN_TLS_V1_3 /**< Maximum valid value */ }; #define KNOW_TLS_IDS_COUNT 6 /* KNOWN_TLS_MAX + 1 */ /** * Map @a know_gnutls_tls_ids values to printable names. */ extern const char *tls_names[KNOW_TLS_IDS_COUNT]; /** * Map @a know_gnutls_tls_ids values to GnuTLS priorities strings. */ extern const char *priorities_map[KNOW_TLS_IDS_COUNT]; /** * Map @a know_gnutls_tls_ids values to GnuTLS priorities append strings. */ extern const char *priorities_append_map[KNOW_TLS_IDS_COUNT]; /** * Map @a know_gnutls_tls_ids values to libcurl @a CURLOPT_SSLVERSION value. */ extern const long libcurl_tls_vers_map[KNOW_TLS_IDS_COUNT]; #if CURL_AT_LEAST_VERSION (7,54,0) /** * Map @a know_gnutls_tls_ids values to libcurl @a CURLOPT_SSLVERSION value * for maximum supported TLS version. */ extern const long libcurl_tls_max_vers_map[KNOW_TLS_IDS_COUNT]; #endif /* CURL_AT_LEAST_VERSION(7,54,0) */ struct https_test_data { void *cls; uint16_t port; const char *cipher_suite; int proto_version; }; struct CBC { char *buf; size_t pos; size_t size; }; int curl_tls_is_gnutls (void); int curl_tls_is_openssl (void); int curl_tls_is_nss (void); int curl_tls_is_schannel (void); int curl_tls_is_sectransport (void); enum test_get_result { TEST_GET_OK = 0, TEST_GET_ERROR = 1, TEST_GET_MHD_ERROR = 16, TEST_GET_TRANSFER_ERROR = 17, TEST_GET_CURL_GEN_ERROR = 32, TEST_GET_CURL_CA_ERROR = 33, TEST_GET_CURL_NOT_IMPLT = 34, TEST_GET_HARD_ERROR = 999 }; /** * perform cURL request for file */ enum test_get_result test_daemon_get (void *cls, const char *cipher_suite, int proto_version, uint16_t port, int ver_peer); void print_test_result (unsigned int test_outcome, const char *test_name); size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx); enum MHD_Result http_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *upload_data, const char *version, size_t *upload_data_size, void **req_cls); enum MHD_Result http_dummy_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *upload_data, const char *version, size_t *upload_data_size, void **req_cls); /** * compile test URI * * @param[out] uri - char buffer into which the url is compiled * @param uri_len number of bytes available in @a url * @param port port to use for the test * @return 1 on error */ unsigned int gen_test_uri (char *uri, size_t uri_len, uint16_t port); CURLcode send_curl_req (char *url, struct CBC *cbc, const char *cipher_suite, int proto_version); unsigned int test_https_transfer (void *cls, uint16_t port, const char *cipher_suite, int proto_version); unsigned int setup_session (gnutls_session_t *session, gnutls_certificate_credentials_t *xcred); unsigned int teardown_session (gnutls_session_t session, gnutls_certificate_credentials_t xcred); unsigned int test_wrap (const char *test_name, unsigned int (*test_function)(void *cls, uint16_t port, const char *cipher_suite, int proto_version), void *cls, uint16_t port, unsigned int daemon_flags, const char *cipher_suite, int proto_version, ...); int testsuite_curl_global_init (void); /** * Check whether program name contains specific @a marker string. * Only last component in pathname is checked for marker presence, * all leading directories names (if any) are ignored. Directories * separators are handled correctly on both non-W32 and W32 * platforms. * @param prog_name program name, may include path * @param marker marker to look for. * @return zero if any parameter is NULL or empty string or * @a prog_name ends with slash or @a marker is not found in * program name, non-zero if @a maker is found in program * name. */ int has_in_name (const char *prog_name, const char *marker); #endif /* TLS_TEST_COMMON_H_ */ libmicrohttpd-1.0.1/src/testcurl/https/test_https_get_parallel_threads.c0000644000175000017500000001304714441373361022441 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_https_get_parallel_threads.c * @brief Testcase for libmicrohttpd HTTPS GET operations with multi-threaded * MHD daemon and several clients working in parallel * @author Sagie Amir * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) * * TODO: add test for external select! */ #include "platform.h" #include "microhttpd.h" #include #include #include #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include "tls_test_keys.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 4 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 4 #endif /** * used when spawning multiple threads executing curl server requests * */ static void * https_transfer_thread_adapter (void *args) { static int nonnull; struct https_test_data *cargs = args; unsigned int ret; ret = test_https_transfer (cargs->cls, cargs->port, cargs->cipher_suite, cargs->proto_version); if (ret == 0) return NULL; return &nonnull; } /** * Test non-parallel requests. * * @return: 0 upon all client requests returning '0', 1 otherwise. * * TODO : make client_count a parameter - number of curl client threads to spawn */ static unsigned int test_single_client (void *cls, uint16_t port, const char *cipher_suite, int curl_proto_version) { void *client_thread_ret; struct https_test_data client_args = { NULL, port, cipher_suite, curl_proto_version }; (void) cls; /* Unused. Silent compiler warning. */ client_thread_ret = https_transfer_thread_adapter (&client_args); if (client_thread_ret != NULL) return 1; return 0; } /** * Test parallel request handling. * * @return: 0 upon all client requests returning '0', 1 otherwise. * * TODO : make client_count a parameter - number of curl client threads to spawn */ static unsigned int test_parallel_clients (void *cls, uint16_t port, const char *cipher_suite, int curl_proto_version) { int i; int client_count = (MHD_CPU_COUNT - 1); void *client_thread_ret; pthread_t client_arr[client_count]; struct https_test_data client_args = { NULL, port, cipher_suite, curl_proto_version }; (void) cls; /* Unused. Silent compiler warning. */ for (i = 0; i < client_count; ++i) { if (pthread_create (&client_arr[i], NULL, &https_transfer_thread_adapter, &client_args) != 0) { fprintf (stderr, "Error: failed to spawn test client threads.\n"); return 1; } } /* check all client requests fulfilled correctly */ for (i = 0; i < client_count; ++i) { if ((pthread_join (client_arr[i], &client_thread_ret) != 0) || (client_thread_ret != NULL)) return 1; } return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; const char *ssl_version; uint16_t port; unsigned int iseed; (void) argc; /* Unused. Silent compiler warning. */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 3010; /* initialize random seed used by curl clients */ iseed = (unsigned int) time (NULL); #ifdef MHD_HTTPS_REQUIRE_GCRYPT #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ srand (iseed); if (! testsuite_curl_global_init ()) return 99; ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); curl_global_cleanup (); return 77; } errorCount += test_wrap ("multi threaded daemon, single client", &test_single_client, NULL, port, MHD_USE_TLS | MHD_USE_ERROR_LOG | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, NULL, CURL_SSLVERSION_DEFAULT, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); errorCount += test_wrap ("multi threaded daemon, parallel client", &test_parallel_clients, NULL, port, MHD_USE_TLS | MHD_USE_ERROR_LOG | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, NULL, CURL_SSLVERSION_DEFAULT, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); if (errorCount != 0) fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount); curl_global_cleanup (); return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/test_https_session_info.c0000644000175000017500000002551714441373361020777 /* This file is part of libmicrohttpd Copyright (C) 2007, 2016 Christian Grothoff Copyright (C) 2016-2021 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_https_session_info.c * @brief Testcase for libmicrohttpd HTTPS connection querying operations * @author Sagie Amir * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include "tls_test_keys.h" static int test_append_prio; /* * HTTP access handler call back * used to query negotiated security parameters */ static enum MHD_Result query_info_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; const union MHD_ConnectionInfo *conn_info; enum know_gnutls_tls_id *used_tls_ver; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ used_tls_ver = (enum know_gnutls_tls_id *) cls; if (NULL == *req_cls) { *req_cls = (void *) &query_info_ahc; return MHD_YES; } conn_info = MHD_get_connection_info (connection, MHD_CONNECTION_INFO_PROTOCOL); if (NULL == conn_info) { fflush (stderr); fflush (stdout); fprintf (stderr, "MHD_get_connection_info() failed.\n"); fflush (stderr); return MHD_NO; } if (0 == (unsigned int) conn_info->protocol) { fflush (stderr); fflush (stdout); fprintf (stderr, "MHD_get_connection_info()->protocol has " "wrong zero value.\n"); fflush (stderr); return MHD_NO; } *used_tls_ver = (enum know_gnutls_tls_id) conn_info->protocol; response = MHD_create_response_from_buffer_static (strlen (EMPTY_PAGE), EMPTY_PAGE); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } /** * negotiate a secure connection with server & query negotiated security parameters */ static unsigned int test_query_session (enum know_gnutls_tls_id tls_ver, uint16_t *pport) { CURL *c; struct CBC cbc; CURLcode errornum; char url[256]; enum know_gnutls_tls_id found_tls_ver; struct MHD_Daemon *d; if (NULL == (cbc.buf = malloc (sizeof (char) * 255))) return 99; cbc.size = 255; cbc.pos = 0; /* setup test */ found_tls_ver = KNOWN_BAD; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, *pport, NULL, NULL, &query_info_ahc, &found_tls_ver, test_append_prio ? MHD_OPTION_HTTPS_PRIORITIES_APPEND : MHD_OPTION_HTTPS_PRIORITIES, test_append_prio ? priorities_append_map[tls_ver] : priorities_map[tls_ver], MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); if (d == NULL) { free (cbc.buf); fprintf (stderr, "MHD_start_daemon() with %s failed.\n", tls_names[tls_ver]); fflush (stderr); return 77; } if (0 == *pport) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); free (cbc.buf); fprintf (stderr, "MHD_get_daemon_info() failed.\n"); fflush (stderr); return 10; } *pport = dinfo->port; /* Use the same port for rest of the checks */ } gen_test_uri (url, sizeof (url), *pport); c = curl_easy_init (); fflush (stderr); if (NULL == c) { fprintf (stderr, "curl_easy_init() failed.\n"); fflush (stderr); MHD_stop_daemon (d); free (cbc.buf); return 99; } #ifdef _DEBUG curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); #endif if ((CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_URL, url))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_TIMEOUT, 10L))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 10L))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc))) || /* TLS options */ /* currently skip any peer authentication */ (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L))) || (CURLE_OK != (errornum = curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)))) { curl_easy_cleanup (c); free (cbc.buf); MHD_stop_daemon (d); fflush (stderr); fflush (stdout); fprintf (stderr, "Error setting libcurl option: %s.\n", curl_easy_strerror (errornum)); fflush (stderr); return 99; } if (CURLE_OK != (errornum = curl_easy_perform (c))) { unsigned int ret; curl_easy_cleanup (c); free (cbc.buf); MHD_stop_daemon (d); fflush (stderr); fflush (stdout); if ((CURLE_SSL_CONNECT_ERROR == errornum) || (CURLE_SSL_CIPHER == errornum)) { ret = 77; fprintf (stderr, "libcurl request failed due to TLS error: '%s'\n", curl_easy_strerror (errornum)); } else { ret = 1; fprintf (stderr, "curl_easy_perform failed: '%s'\n", curl_easy_strerror (errornum)); } fflush (stderr); return ret; } curl_easy_cleanup (c); free (cbc.buf); MHD_stop_daemon (d); if (tls_ver != found_tls_ver) { fflush (stderr); fflush (stdout); fprintf (stderr, "MHD_get_connection_info (conn, " "MHD_CONNECTION_INFO_PROTOCOL) returned unexpected " "protocol version.\n" "\tReturned: %s (%u)\tExpected: %s (%u)\n", ((unsigned int) found_tls_ver) > KNOWN_TLS_MAX ? "[wrong value]" : tls_names[found_tls_ver], (unsigned int) found_tls_ver, tls_names[tls_ver], (unsigned int) tls_ver); fflush (stderr); return 2; } return 0; } static unsigned int test_all_supported_versions (void) { enum know_gnutls_tls_id ver_for_test; /**< TLS version used for test */ const gnutls_protocol_t *vers_list; /**< The list of GnuTLS supported TLS versions */ uint16_t port; unsigned int num_success; /**< Number of tests succeeded */ unsigned int num_failed; /**< Number of tests failed */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; /* Use system automatic assignment */ else port = 3060; /* Use predefined port, may break parallel testing of another MHD build */ vers_list = gnutls_protocol_list (); if (NULL == vers_list) { fprintf (stderr, "Error getting GnuTLS supported TLS versions"); return 99; } num_success = 0; num_failed = 0; for (ver_for_test = KNOWN_TLS_MIN; KNOWN_TLS_MAX >= ver_for_test; ++ver_for_test) { const gnutls_protocol_t *ver_ptr; /**< The pointer to the position on the @a vers_list */ unsigned int res; for (ver_ptr = vers_list; 0 != *ver_ptr; ++ver_ptr) { if (ver_for_test == (enum know_gnutls_tls_id) *ver_ptr) break; } if (0 == *ver_ptr) { printf ("%s is not supported by GnuTLS, skipping.\n\n", tls_names[ver_for_test]); fflush (stdout); continue; } printf ("Starting check for %s...\n", tls_names[ver_for_test]); fflush (stdout); res = test_query_session (ver_for_test, &port); fflush (stderr); fflush (stdout); if (99 == res) { fprintf (stderr, "Hard error. Test stopped.\n"); fflush (stderr); return 99; } else if (77 == res) { printf ("%s does not work with libcurl client and GnuTLS " "server combination, skipping.\n", tls_names[ver_for_test]); fflush (stdout); } else if (0 != res) { fprintf (stderr, "Check failed for %s.\n", tls_names[ver_for_test]); fflush (stderr); num_failed++; } else { printf ("Check succeeded for %s.\n", tls_names[ver_for_test]); fflush (stdout); num_success++; } printf ("\n"); fflush (stdout); } if (0 == num_failed) { if (0 == num_success) { fprintf (stderr, "No supported TLS version was found.\n"); fflush (stderr); return 77; } return 0; } return num_failed; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; const char *ssl_version; (void) argc; /* Unused. Silent compiler warning. */ #ifdef MHD_HTTPS_REQUIRE_GCRYPT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ test_append_prio = has_in_name (argv[0], "_append"); if (! testsuite_curl_global_init ()) return 99; ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); curl_global_cleanup (); return 77; } errorCount = test_all_supported_versions (); fflush (stderr); fflush (stdout); curl_global_cleanup (); if (77 == errorCount) return 77; else if (99 == errorCount) return 99; print_test_result (errorCount, argv[0]); return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/test_https_get_select.c0000644000175000017500000001764214530120375020411 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_https_get_select.c * @brief Testcase for libmicrohttpd HTTPS GET operations using external select * @author Sagie Amir * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include #include #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include "tls_test_keys.h" static int oneone; static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) abort (); return ret; } static unsigned int testExternalGet (unsigned int flags) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 3030; multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_TLS | flags, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); #ifdef _DEBUG curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); #endif curl_easy_setopt (c, CURLOPT_URL, "https://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); /* TLS options */ curl_easy_setopt (c, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT); curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 != maxposixs) { if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) abort (); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws. fd_count) || (0 != es.fd_count) ) abort (); Sleep (1000); #endif } } else (void) sleep (1); curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 8192; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 16384; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ oneone = 1; if (! testsuite_curl_global_init ()) return 99; if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); curl_global_cleanup (); return 77; } #ifdef EPOLL_SUPPORT errorCount += testExternalGet (MHD_USE_EPOLL); #endif if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) errorCount += testExternalGet (MHD_NO_FLAG); errorCount += testExternalGet (MHD_USE_NO_THREAD_SAFETY); curl_global_cleanup (); if (errorCount != 0) fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount); return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/mhdhost2.crt0000644000175000017500000000346614417460232016112 -----BEGIN CERTIFICATE----- MIIFJjCCAw6gAwIBAgIBBjANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx DzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwGTW9zY293MRswGQYDVQQKDBJ0ZXN0 LWxpYm1pY3JvaHR0cGQxITAfBgkqhkiG9w0BCQEWEm5vYm9keUBleGFtcGxlLm9y ZzEQMA4GA1UEAwwHdGVzdC1DQTAgFw0yMjA0MjAxODQ1MDVaGA8yMTIyMDMyNjE4 NDUwNVowXzELMAkGA1UEBhMCUlUxDzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwG TW9zY293MRswGQYDVQQKDBJ0ZXN0LWxpYm1pY3JvaHR0cGQxETAPBgNVBAMMCG1o ZGhvc3QyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy2v1c39RQPgG EqhYisiQX5QDTJFCr93B/KC96AqxXfUqxYHQZHHByeh2yHX5XeY+cwiza9Pb8kB5 Wyu5IV7pHYbLXetUQ7Ha8oCXcXZBihzMGjdTQApBvKES2rotkgxIArzFRk/KnO3D 2r87E2/fHqlHjg0Y8d58i846m7GSFpH2uAYogm2Zhi2ojE4O/qfaO6cSTdjUhDbM iDkQlf/fkq9o3ZeGzKXdzLC5PeIJ/7HbEcBJ0e6lyAFbYZtpTAtQ6/tuqAZTs3tM G5Yq3cAZY7x4vGECZaAWZAlgstBpCYd8b/dlXa8qvx4JuMF4q+7vVbgwHVoXsAzm ZAxSNy+dmQIDAQABo4HHMIHEMAsGA1UdDwQEAwIFoDAMBgNVHRMBAf8EAjAAMBYG A1UdJQEB/wQMMAoGCCsGAQUFBwMBMBMGA1UdEQQMMAqCCG1oZGhvc3QyMB0GA1Ud DgQWBBSB0kA6mqq1/wMzKke35+L6aZym9zAnBglghkgBhvhCAQ0EGhYYVGVzdCBs aWJtaWNyb2h0dHBkIGhvc3QyMBEGCWCGSAGG+EIBAQQEAwIGQDAfBgNVHSMEGDAW gBRYdUPApWoxw4U13Rqsjf9AHdbpLDANBgkqhkiG9w0BAQsFAAOCAgEAhEeSsKYb KWVhC3bVxXX4EynaHVWwrQaqNMtogt2akKBfZRzM6CHVvts8IrvcMdS4ZvXB2kL8 wDsYpVsNVgLLuSKXH2xJPZmYrGsUu++UcR4umvuV1kwFcA/Dc5XkW1EMcMvSPDs2 /gJFRCpx3UAs2/KCL2KASHGiOcNSf8aRLxI6KqWqQLxsZdK02HUNodqiG2UXIaHg shD7rAMSDN4CdG4cdSX3l45aL+BoYcEKi5XUoJMRjNrAGKMWUku089hr1gI617Jx gHKZxvSizGxCHhMkAPTT+9UyNFzd+3dS6cHx8oTFpnamNgMin3C88GCmu5YN6gCi af3imb8OaHFJ0k9M9acM++5sRfvRgZ/tQWnPdyg5TlLwwF14yLbz6e/DbxlmP7PG 3W3FbVST/creb2KTtwWFu187uKl4v1Xe5DC0I2gcOzq2g0GHbu8WjuD45Os/lc4v cqGctYRMUfqshmsK9PQCZmPcC5nqXf6iO8L1P9Gi0VDwT/WeHUvi87UVYsUgVuVt 0RxCE5Nqad8S7ziQj9Aa3xspPf7CKw6Obbp/UNui/YwaDufJho7qsBpp1lMnG5f4 qA8+yKUVADTnV5tJqgcDiRyBxOzb2CaGezTqNshUkVIpkHZsCpSdu9QrEOIzcaaA WXmQOPOpxW5QVf22mPJh/GZaqZ3/ZMmFabI= -----END CERTIFICATE----- libmicrohttpd-1.0.1/src/testcurl/https/test-ca.crt0000644000175000017500000000421314417460232015711 -----BEGIN CERTIFICATE----- MIIGITCCBAmgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx DzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwGTW9zY293MRswGQYDVQQKDBJ0ZXN0 LWxpYm1pY3JvaHR0cGQxITAfBgkqhkiG9w0BCQEWEm5vYm9keUBleGFtcGxlLm9y ZzEQMA4GA1UEAwwHdGVzdC1DQTAgFw0yMTA0MDcxNzM2MThaGA8yMTIxMDMxNDE3 MzYxOFowgYExCzAJBgNVBAYTAlJVMQ8wDQYDVQQIDAZNb3Njb3cxDzANBgNVBAcM Bk1vc2NvdzEbMBkGA1UECgwSdGVzdC1saWJtaWNyb2h0dHBkMSEwHwYJKoZIhvcN AQkBFhJub2JvZHlAZXhhbXBsZS5vcmcxEDAOBgNVBAMMB3Rlc3QtQ0EwggIiMA0G CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDdaWupA4qZjCBNkJoJOm5xnCaizl36 ZLUwp4xBL/YfXPWE3LkmAREiVI/YnAb8l6G7CJnz8dTsOJWkNXG6T1KVP5/2RvBI IaaaufRIAl7hEnj1j9E2hQlV2fxF2ZNhz+nqi0LqKV4LJSpclkXADf2FA9HsVRP/ B7zYh+DP0fSU8V6bsu8XCeRGshroAPrc8rH8lFEEXpNLNIqQr8yKx6SmdB6hfja6 6SQ0++qBhl0aJtn4LHWZohgjBmkIaGFPYIJLgxQ/xyp2Grz2q7lGKJ+zBkBF8iOP t3x+F1hSCBnr/DGYWmjEm5tYm+7pyuriPddXdCc8+qa2LxMZo3EXxLo5YISpPCyw Z7V3YAOZTr3m1C24LiYvPehCq1CTIkhhmqtlVJXU7ISD48cx9y+5Pi34wtbTI/gN x4voyTLAfyavKMmIpxxIRsWldiF2n06HdvCRVdihDQUad10ygTmWf1J/s2ZETAtH QaSd7MD389t6nQFtTIXigsNKnnDPlrtxt7rOLvLQeR0K04Gzrf/scheOanRAfOXH KNBFU7YkDFG8rqizlC65rx9qeXFYXQcHZTuqxK7tgZnSgJat3E70VbTSCsEEG7eR bNX/fChUKAIIpWaiW6HDlKLl6m2y+BzM91umBsKOqTvntMVFBSF9pVYlXK854aIR q8A2Xujd012seQIDAQABo4GfMIGcMAsGA1UdDwQEAwICpDASBgNVHRMBAf8ECDAG AQH/AgEBMB0GA1UdDgQWBBRYdUPApWoxw4U13Rqsjf9AHdbpLDATBgNVHSUEDDAK BggrBgEFBQcDATAkBglghkgBhvhCAQ0EFxYVVGVzdCBsaWJtaWNyb2h0dHBkIENB MB8GA1UdIwQYMBaAFFh1Q8ClajHDhTXdGqyN/0Ad1uksMA0GCSqGSIb3DQEBCwUA A4ICAQBvrrcTKVeI1EYnXo4BQD4oCvf9z1fYQmL21EbHwgjg1nmaPkvStgWAc5p1 kKwySrpEMKXfu68X76RccXZyWWIamEjz2OCWYZgjX6d6FpjhLphL8WxXDy5C9eay ixN7+URz2XQoi22wqR+tCPDhrIzcMPyMkx/6gRgcYeDnaFrkdSeSsKsID4plfcIj ISWJDvv+IAgrtsG1NVHnGwpAv0od3A8/4/fR6PPyewaU3aydvjZ7Au8O9DGDjlU9 9HdlOkkY6GVJ1pfGZib7cV7lhy0D2kj1g9xZh97YjpoUfppPl9r+6A8gDm0hXlAD TlzNYlwTb681ZEoSd9PiLEY8HETssHlays2dYXdcNwAEp69iIHz8q1Q98Be9LScl WEzgaOT9U7lpIw/MWbELoMsC+Ecs1cVWBIuiIq8aSG2kRr1x3S8yVXbAohAXif2s E6puieM/VJ25iaNhkbLmDkk58QVVmn9NZNv6ETxuSQMp9e0EwbVlj68vzClQ91Y/ nmAiGcLFUEwB9G0szv9+vR+oDW4IkvdFZSUbcICd2cnynnwAD395onqS4hEZO1xM Gy5ZldbTMTjgn7fChNopz15ChPBnwFIjhm+S0CyiLRQAowfknRVq2IBkj7/5kOWg 4mcxcq76HoQWK/8X/8RFL1eFVAvY7TNHYJ0RS51DMuwCNQictA== -----END CERTIFICATE----- libmicrohttpd-1.0.1/src/testcurl/https/test_https_get_parallel.c0000644000175000017500000001415214441373361020725 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_https_get_parallel.c * @brief Testcase for libmicrohttpd HTTPS GET operations with single-threaded * MHD daemon and several clients working in parallel * @author Sagie Amir * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include #include #include #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include "tls_test_keys.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 4 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 4 #endif /** * used when spawning multiple threads executing curl server requests * */ static void * https_transfer_thread_adapter (void *args) { static int nonnull; struct https_test_data *cargs = args; unsigned int ret; ret = test_https_transfer (NULL, cargs->port, cargs->cipher_suite, cargs->proto_version); if (ret == 0) return NULL; return &nonnull; } /** * Test non-parallel requests. * * @return: 0 upon all client requests returning '0', 1 otherwise. * * TODO : make client_count a parameter - number of curl client threads to spawn */ static unsigned int test_single_client (void *cls, uint16_t port, const char *cipher_suite, int curl_proto_version) { void *client_thread_ret; struct https_test_data client_args = { NULL, port, cipher_suite, curl_proto_version }; (void) cls; /* Unused. Silent compiler warning. */ client_thread_ret = https_transfer_thread_adapter (&client_args); if (client_thread_ret != NULL) return 1; return 0; } /** * Test parallel request handling. * * @return: 0 upon all client requests returning '0', 1 otherwise. * * TODO : make client_count a parameter - number of curl client threads to spawn */ static unsigned int test_parallel_clients (void *cls, uint16_t port, const char *cipher_suite, int curl_proto_version) { int i; int client_count = (MHD_CPU_COUNT - 1); void *client_thread_ret; pthread_t client_arr[client_count]; struct https_test_data client_args = { NULL, port, cipher_suite, curl_proto_version }; (void) cls; /* Unused. Silent compiler warning. */ for (i = 0; i < client_count; ++i) { if (pthread_create (&client_arr[i], NULL, &https_transfer_thread_adapter, &client_args) != 0) { fprintf (stderr, "Error: failed to spawn test client threads.\n"); return 1; } } /* check all client requests fulfilled correctly */ for (i = 0; i < client_count; ++i) { if ((pthread_join (client_arr[i], &client_thread_ret) != 0) || (client_thread_ret != NULL)) return 1; } return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; uint16_t port; unsigned int iseed; (void) argc; /* Unused. Silent compiler warning. */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 3020; /* initialize random seed used by curl clients */ iseed = (unsigned int) time (NULL); srand (iseed); if (! testsuite_curl_global_init ()) return 99; if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); return 77; } #ifdef EPOLL_SUPPORT errorCount += test_wrap ("single threaded daemon, single client, epoll", &test_single_client, NULL, port, MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG | MHD_USE_EPOLL, NULL, CURL_SSLVERSION_DEFAULT, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); #endif errorCount += test_wrap ("single threaded daemon, single client", &test_single_client, NULL, port, MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, NULL, CURL_SSLVERSION_DEFAULT, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); #ifdef EPOLL_SUPPORT errorCount += test_wrap ("single threaded daemon, parallel clients, epoll", &test_parallel_clients, NULL, port, MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG | MHD_USE_EPOLL, NULL, CURL_SSLVERSION_DEFAULT, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); #endif errorCount += test_wrap ("single threaded daemon, parallel clients", &test_parallel_clients, NULL, port, MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, NULL, CURL_SSLVERSION_DEFAULT, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); curl_global_cleanup (); if (errorCount != 0) fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], errorCount); return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/Makefile.in0000644000175000017500000021273714566140141015717 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @USE_COVERAGE_TRUE@am__append_1 = --coverage check_PROGRAMS = test_https_get_select$(EXEEXT) $(am__EXEEXT_5) @USE_THREADS_TRUE@am__append_2 = \ @USE_THREADS_TRUE@ $(THREAD_ONLY_TESTS) subdir = src/testcurl/https ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @HAVE_GNUTLS_MTHREAD_BROKEN_FALSE@am__EXEEXT_1 = test_https_time_out$(EXEEXT) \ @HAVE_GNUTLS_MTHREAD_BROKEN_FALSE@ test_https_get_parallel$(EXEEXT) \ @HAVE_GNUTLS_MTHREAD_BROKEN_FALSE@ test_https_get_parallel_threads$(EXEEXT) @HAVE_GNUTLS_SNI_TRUE@am__EXEEXT_2 = test_https_sni$(EXEEXT) am__EXEEXT_3 = am__EXEEXT_4 = test_tls_options$(EXEEXT) \ test_tls_authentication$(EXEEXT) $(am__EXEEXT_1) \ $(am__EXEEXT_2) test_https_session_info$(EXEEXT) \ test_https_session_info_append$(EXEEXT) \ test_https_multi_daemon$(EXEEXT) test_https_get$(EXEEXT) \ test_empty_response$(EXEEXT) test_https_get_iovec$(EXEEXT) \ $(am__EXEEXT_3) @USE_THREADS_TRUE@am__EXEEXT_5 = $(am__EXEEXT_4) am_test_empty_response_OBJECTS = test_empty_response.$(OBJEXT) \ tls_test_common.$(OBJEXT) test_empty_response_OBJECTS = $(am_test_empty_response_OBJECTS) test_empty_response_LDADD = $(LDADD) am__DEPENDENCIES_1 = test_empty_response_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_test_https_get_OBJECTS = test_https_get.$(OBJEXT) \ tls_test_common.$(OBJEXT) test_https_get_OBJECTS = $(am_test_https_get_OBJECTS) test_https_get_LDADD = $(LDADD) test_https_get_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_test_https_get_iovec_OBJECTS = test_https_get_iovec.$(OBJEXT) \ tls_test_common.$(OBJEXT) test_https_get_iovec_OBJECTS = $(am_test_https_get_iovec_OBJECTS) test_https_get_iovec_LDADD = $(LDADD) test_https_get_iovec_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_test_https_get_parallel_OBJECTS = \ test_https_get_parallel-test_https_get_parallel.$(OBJEXT) \ test_https_get_parallel-tls_test_common.$(OBJEXT) test_https_get_parallel_OBJECTS = \ $(am_test_https_get_parallel_OBJECTS) am__DEPENDENCIES_2 = $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) test_https_get_parallel_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_https_get_parallel_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_https_get_parallel_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_https_get_parallel_threads_OBJECTS = test_https_get_parallel_threads-test_https_get_parallel_threads.$(OBJEXT) \ test_https_get_parallel_threads-tls_test_common.$(OBJEXT) test_https_get_parallel_threads_OBJECTS = \ $(am_test_https_get_parallel_threads_OBJECTS) test_https_get_parallel_threads_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_https_get_parallel_threads_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_https_get_parallel_threads_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ am_test_https_get_select_OBJECTS = test_https_get_select.$(OBJEXT) \ tls_test_common.$(OBJEXT) test_https_get_select_OBJECTS = $(am_test_https_get_select_OBJECTS) test_https_get_select_LDADD = $(LDADD) test_https_get_select_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_test_https_multi_daemon_OBJECTS = \ test_https_multi_daemon.$(OBJEXT) tls_test_common.$(OBJEXT) test_https_multi_daemon_OBJECTS = \ $(am_test_https_multi_daemon_OBJECTS) test_https_multi_daemon_LDADD = $(LDADD) test_https_multi_daemon_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_test_https_session_info_OBJECTS = \ test_https_session_info.$(OBJEXT) tls_test_common.$(OBJEXT) test_https_session_info_OBJECTS = \ $(am_test_https_session_info_OBJECTS) test_https_session_info_LDADD = $(LDADD) test_https_session_info_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__objects_1 = test_https_session_info.$(OBJEXT) \ tls_test_common.$(OBJEXT) am_test_https_session_info_append_OBJECTS = $(am__objects_1) test_https_session_info_append_OBJECTS = \ $(am_test_https_session_info_append_OBJECTS) test_https_session_info_append_LDADD = $(LDADD) test_https_session_info_append_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_test_https_sni_OBJECTS = test_https_sni.$(OBJEXT) \ tls_test_common.$(OBJEXT) test_https_sni_OBJECTS = $(am_test_https_sni_OBJECTS) test_https_sni_LDADD = $(LDADD) test_https_sni_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_test_https_time_out_OBJECTS = test_https_time_out.$(OBJEXT) \ tls_test_common.$(OBJEXT) test_https_time_out_OBJECTS = $(am_test_https_time_out_OBJECTS) test_https_time_out_LDADD = $(LDADD) test_https_time_out_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_test_tls_authentication_OBJECTS = \ test_tls_authentication.$(OBJEXT) tls_test_common.$(OBJEXT) test_tls_authentication_OBJECTS = \ $(am_test_tls_authentication_OBJECTS) test_tls_authentication_LDADD = $(LDADD) test_tls_authentication_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_test_tls_options_OBJECTS = test_tls_options.$(OBJEXT) \ tls_test_common.$(OBJEXT) test_tls_options_OBJECTS = $(am_test_tls_options_OBJECTS) test_tls_options_LDADD = $(LDADD) test_tls_options_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/test_empty_response.Po \ ./$(DEPDIR)/test_https_get.Po \ ./$(DEPDIR)/test_https_get_iovec.Po \ ./$(DEPDIR)/test_https_get_parallel-test_https_get_parallel.Po \ ./$(DEPDIR)/test_https_get_parallel-tls_test_common.Po \ ./$(DEPDIR)/test_https_get_parallel_threads-test_https_get_parallel_threads.Po \ ./$(DEPDIR)/test_https_get_parallel_threads-tls_test_common.Po \ ./$(DEPDIR)/test_https_get_select.Po \ ./$(DEPDIR)/test_https_multi_daemon.Po \ ./$(DEPDIR)/test_https_session_info.Po \ ./$(DEPDIR)/test_https_sni.Po \ ./$(DEPDIR)/test_https_time_out.Po \ ./$(DEPDIR)/test_tls_authentication.Po \ ./$(DEPDIR)/test_tls_options.Po ./$(DEPDIR)/tls_test_common.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(test_empty_response_SOURCES) $(test_https_get_SOURCES) \ $(test_https_get_iovec_SOURCES) \ $(test_https_get_parallel_SOURCES) \ $(test_https_get_parallel_threads_SOURCES) \ $(test_https_get_select_SOURCES) \ $(test_https_multi_daemon_SOURCES) \ $(test_https_session_info_SOURCES) \ $(test_https_session_info_append_SOURCES) \ $(test_https_sni_SOURCES) $(test_https_time_out_SOURCES) \ $(test_tls_authentication_SOURCES) $(test_tls_options_SOURCES) DIST_SOURCES = $(test_empty_response_SOURCES) \ $(test_https_get_SOURCES) $(test_https_get_iovec_SOURCES) \ $(test_https_get_parallel_SOURCES) \ $(test_https_get_parallel_threads_SOURCES) \ $(test_https_get_select_SOURCES) \ $(test_https_multi_daemon_SOURCES) \ $(test_https_session_info_SOURCES) \ $(test_https_session_info_append_SOURCES) \ $(test_https_sni_SOURCES) $(test_https_time_out_SOURCES) \ $(test_tls_authentication_SOURCES) $(test_tls_options_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ check recheck distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' RECHECK_LOGS = $(TEST_LOGS) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in \ $(top_srcdir)/build-aux/depcomp \ $(top_srcdir)/build-aux/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # This Makefile.am is in the public domain EMPTY_ITEM = SUBDIRS = . AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/microhttpd \ -DMHD_CPU_COUNT=$(CPU_COUNT) \ -DSRCDIR=\"$(srcdir)\" \ $(CPPFLAGS_ac) $(LIBCURL_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) AM_CFLAGS = $(CFLAGS_ac) @LIBGCRYPT_CFLAGS@ $(am__append_1) AM_LDFLAGS = $(LDFLAGS_ac) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(MHD_TLS_LIB_LDFLAGS) $(MHD_TLS_LIBDEPS) @LIBGCRYPT_LIBS@ @LIBCURL@ @HAVE_GNUTLS_SNI_TRUE@TEST_HTTPS_SNI = test_https_sni @HAVE_GNUTLS_MTHREAD_BROKEN_FALSE@HTTPS_PARALLEL_TESTS = \ @HAVE_GNUTLS_MTHREAD_BROKEN_FALSE@ test_https_time_out \ @HAVE_GNUTLS_MTHREAD_BROKEN_FALSE@ test_https_get_parallel \ @HAVE_GNUTLS_MTHREAD_BROKEN_FALSE@ test_https_get_parallel_threads THREAD_ONLY_TESTS = \ test_tls_options \ test_tls_authentication \ $(HTTPS_PARALLEL_TESTS) \ $(TEST_HTTPS_SNI) \ test_https_session_info \ test_https_session_info_append \ test_https_multi_daemon \ test_https_get \ test_empty_response \ test_https_get_iovec \ $(EMPTY_ITEM) EXTRA_DIST = \ test-ca.crt test-ca.key \ mhdhost1.crt mhdhost1.key \ mhdhost2.crt mhdhost2.key TESTS = \ $(check_PROGRAMS) test_https_time_out_SOURCES = \ test_https_time_out.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_tls_options_SOURCES = \ test_tls_options.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_parallel_SOURCES = \ test_https_get_parallel.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_parallel_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_https_get_parallel_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_empty_response_SOURCES = \ test_empty_response.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_parallel_threads_SOURCES = \ test_https_get_parallel_threads.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_parallel_threads_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_https_get_parallel_threads_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_tls_authentication_SOURCES = \ test_tls_authentication.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_session_info_SOURCES = \ test_https_session_info.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_session_info_append_SOURCES = $(test_https_session_info_SOURCES) test_https_multi_daemon_SOURCES = \ test_https_multi_daemon.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_SOURCES = \ test_https_get.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_iovec_SOURCES = \ test_https_get_iovec.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_sni_SOURCES = \ test_https_sni.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c test_https_get_select_SOURCES = \ test_https_get_select.c \ tls_test_keys.h \ tls_test_common.h \ tls_test_common.c all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/testcurl/https/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/testcurl/https/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list test_empty_response$(EXEEXT): $(test_empty_response_OBJECTS) $(test_empty_response_DEPENDENCIES) $(EXTRA_test_empty_response_DEPENDENCIES) @rm -f test_empty_response$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_empty_response_OBJECTS) $(test_empty_response_LDADD) $(LIBS) test_https_get$(EXEEXT): $(test_https_get_OBJECTS) $(test_https_get_DEPENDENCIES) $(EXTRA_test_https_get_DEPENDENCIES) @rm -f test_https_get$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_https_get_OBJECTS) $(test_https_get_LDADD) $(LIBS) test_https_get_iovec$(EXEEXT): $(test_https_get_iovec_OBJECTS) $(test_https_get_iovec_DEPENDENCIES) $(EXTRA_test_https_get_iovec_DEPENDENCIES) @rm -f test_https_get_iovec$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_https_get_iovec_OBJECTS) $(test_https_get_iovec_LDADD) $(LIBS) test_https_get_parallel$(EXEEXT): $(test_https_get_parallel_OBJECTS) $(test_https_get_parallel_DEPENDENCIES) $(EXTRA_test_https_get_parallel_DEPENDENCIES) @rm -f test_https_get_parallel$(EXEEXT) $(AM_V_CCLD)$(test_https_get_parallel_LINK) $(test_https_get_parallel_OBJECTS) $(test_https_get_parallel_LDADD) $(LIBS) test_https_get_parallel_threads$(EXEEXT): $(test_https_get_parallel_threads_OBJECTS) $(test_https_get_parallel_threads_DEPENDENCIES) $(EXTRA_test_https_get_parallel_threads_DEPENDENCIES) @rm -f test_https_get_parallel_threads$(EXEEXT) $(AM_V_CCLD)$(test_https_get_parallel_threads_LINK) $(test_https_get_parallel_threads_OBJECTS) $(test_https_get_parallel_threads_LDADD) $(LIBS) test_https_get_select$(EXEEXT): $(test_https_get_select_OBJECTS) $(test_https_get_select_DEPENDENCIES) $(EXTRA_test_https_get_select_DEPENDENCIES) @rm -f test_https_get_select$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_https_get_select_OBJECTS) $(test_https_get_select_LDADD) $(LIBS) test_https_multi_daemon$(EXEEXT): $(test_https_multi_daemon_OBJECTS) $(test_https_multi_daemon_DEPENDENCIES) $(EXTRA_test_https_multi_daemon_DEPENDENCIES) @rm -f test_https_multi_daemon$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_https_multi_daemon_OBJECTS) $(test_https_multi_daemon_LDADD) $(LIBS) test_https_session_info$(EXEEXT): $(test_https_session_info_OBJECTS) $(test_https_session_info_DEPENDENCIES) $(EXTRA_test_https_session_info_DEPENDENCIES) @rm -f test_https_session_info$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_https_session_info_OBJECTS) $(test_https_session_info_LDADD) $(LIBS) test_https_session_info_append$(EXEEXT): $(test_https_session_info_append_OBJECTS) $(test_https_session_info_append_DEPENDENCIES) $(EXTRA_test_https_session_info_append_DEPENDENCIES) @rm -f test_https_session_info_append$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_https_session_info_append_OBJECTS) $(test_https_session_info_append_LDADD) $(LIBS) test_https_sni$(EXEEXT): $(test_https_sni_OBJECTS) $(test_https_sni_DEPENDENCIES) $(EXTRA_test_https_sni_DEPENDENCIES) @rm -f test_https_sni$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_https_sni_OBJECTS) $(test_https_sni_LDADD) $(LIBS) test_https_time_out$(EXEEXT): $(test_https_time_out_OBJECTS) $(test_https_time_out_DEPENDENCIES) $(EXTRA_test_https_time_out_DEPENDENCIES) @rm -f test_https_time_out$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_https_time_out_OBJECTS) $(test_https_time_out_LDADD) $(LIBS) test_tls_authentication$(EXEEXT): $(test_tls_authentication_OBJECTS) $(test_tls_authentication_DEPENDENCIES) $(EXTRA_test_tls_authentication_DEPENDENCIES) @rm -f test_tls_authentication$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_tls_authentication_OBJECTS) $(test_tls_authentication_LDADD) $(LIBS) test_tls_options$(EXEEXT): $(test_tls_options_OBJECTS) $(test_tls_options_DEPENDENCIES) $(EXTRA_test_tls_options_DEPENDENCIES) @rm -f test_tls_options$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_tls_options_OBJECTS) $(test_tls_options_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_empty_response.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_get.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_get_iovec.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_get_parallel-test_https_get_parallel.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_get_parallel-tls_test_common.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_get_parallel_threads-test_https_get_parallel_threads.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_get_parallel_threads-tls_test_common.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_get_select.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_multi_daemon.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_session_info.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_sni.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_https_time_out.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tls_authentication.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tls_options.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test_common.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< test_https_get_parallel-test_https_get_parallel.o: test_https_get_parallel.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_CFLAGS) $(CFLAGS) -MT test_https_get_parallel-test_https_get_parallel.o -MD -MP -MF $(DEPDIR)/test_https_get_parallel-test_https_get_parallel.Tpo -c -o test_https_get_parallel-test_https_get_parallel.o `test -f 'test_https_get_parallel.c' || echo '$(srcdir)/'`test_https_get_parallel.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_https_get_parallel-test_https_get_parallel.Tpo $(DEPDIR)/test_https_get_parallel-test_https_get_parallel.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_https_get_parallel.c' object='test_https_get_parallel-test_https_get_parallel.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_CFLAGS) $(CFLAGS) -c -o test_https_get_parallel-test_https_get_parallel.o `test -f 'test_https_get_parallel.c' || echo '$(srcdir)/'`test_https_get_parallel.c test_https_get_parallel-test_https_get_parallel.obj: test_https_get_parallel.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_CFLAGS) $(CFLAGS) -MT test_https_get_parallel-test_https_get_parallel.obj -MD -MP -MF $(DEPDIR)/test_https_get_parallel-test_https_get_parallel.Tpo -c -o test_https_get_parallel-test_https_get_parallel.obj `if test -f 'test_https_get_parallel.c'; then $(CYGPATH_W) 'test_https_get_parallel.c'; else $(CYGPATH_W) '$(srcdir)/test_https_get_parallel.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_https_get_parallel-test_https_get_parallel.Tpo $(DEPDIR)/test_https_get_parallel-test_https_get_parallel.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_https_get_parallel.c' object='test_https_get_parallel-test_https_get_parallel.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_CFLAGS) $(CFLAGS) -c -o test_https_get_parallel-test_https_get_parallel.obj `if test -f 'test_https_get_parallel.c'; then $(CYGPATH_W) 'test_https_get_parallel.c'; else $(CYGPATH_W) '$(srcdir)/test_https_get_parallel.c'; fi` test_https_get_parallel-tls_test_common.o: tls_test_common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_CFLAGS) $(CFLAGS) -MT test_https_get_parallel-tls_test_common.o -MD -MP -MF $(DEPDIR)/test_https_get_parallel-tls_test_common.Tpo -c -o test_https_get_parallel-tls_test_common.o `test -f 'tls_test_common.c' || echo '$(srcdir)/'`tls_test_common.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_https_get_parallel-tls_test_common.Tpo $(DEPDIR)/test_https_get_parallel-tls_test_common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls_test_common.c' object='test_https_get_parallel-tls_test_common.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_CFLAGS) $(CFLAGS) -c -o test_https_get_parallel-tls_test_common.o `test -f 'tls_test_common.c' || echo '$(srcdir)/'`tls_test_common.c test_https_get_parallel-tls_test_common.obj: tls_test_common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_CFLAGS) $(CFLAGS) -MT test_https_get_parallel-tls_test_common.obj -MD -MP -MF $(DEPDIR)/test_https_get_parallel-tls_test_common.Tpo -c -o test_https_get_parallel-tls_test_common.obj `if test -f 'tls_test_common.c'; then $(CYGPATH_W) 'tls_test_common.c'; else $(CYGPATH_W) '$(srcdir)/tls_test_common.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_https_get_parallel-tls_test_common.Tpo $(DEPDIR)/test_https_get_parallel-tls_test_common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls_test_common.c' object='test_https_get_parallel-tls_test_common.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_CFLAGS) $(CFLAGS) -c -o test_https_get_parallel-tls_test_common.obj `if test -f 'tls_test_common.c'; then $(CYGPATH_W) 'tls_test_common.c'; else $(CYGPATH_W) '$(srcdir)/tls_test_common.c'; fi` test_https_get_parallel_threads-test_https_get_parallel_threads.o: test_https_get_parallel_threads.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_threads_CFLAGS) $(CFLAGS) -MT test_https_get_parallel_threads-test_https_get_parallel_threads.o -MD -MP -MF $(DEPDIR)/test_https_get_parallel_threads-test_https_get_parallel_threads.Tpo -c -o test_https_get_parallel_threads-test_https_get_parallel_threads.o `test -f 'test_https_get_parallel_threads.c' || echo '$(srcdir)/'`test_https_get_parallel_threads.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_https_get_parallel_threads-test_https_get_parallel_threads.Tpo $(DEPDIR)/test_https_get_parallel_threads-test_https_get_parallel_threads.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_https_get_parallel_threads.c' object='test_https_get_parallel_threads-test_https_get_parallel_threads.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_threads_CFLAGS) $(CFLAGS) -c -o test_https_get_parallel_threads-test_https_get_parallel_threads.o `test -f 'test_https_get_parallel_threads.c' || echo '$(srcdir)/'`test_https_get_parallel_threads.c test_https_get_parallel_threads-test_https_get_parallel_threads.obj: test_https_get_parallel_threads.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_threads_CFLAGS) $(CFLAGS) -MT test_https_get_parallel_threads-test_https_get_parallel_threads.obj -MD -MP -MF $(DEPDIR)/test_https_get_parallel_threads-test_https_get_parallel_threads.Tpo -c -o test_https_get_parallel_threads-test_https_get_parallel_threads.obj `if test -f 'test_https_get_parallel_threads.c'; then $(CYGPATH_W) 'test_https_get_parallel_threads.c'; else $(CYGPATH_W) '$(srcdir)/test_https_get_parallel_threads.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_https_get_parallel_threads-test_https_get_parallel_threads.Tpo $(DEPDIR)/test_https_get_parallel_threads-test_https_get_parallel_threads.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_https_get_parallel_threads.c' object='test_https_get_parallel_threads-test_https_get_parallel_threads.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_threads_CFLAGS) $(CFLAGS) -c -o test_https_get_parallel_threads-test_https_get_parallel_threads.obj `if test -f 'test_https_get_parallel_threads.c'; then $(CYGPATH_W) 'test_https_get_parallel_threads.c'; else $(CYGPATH_W) '$(srcdir)/test_https_get_parallel_threads.c'; fi` test_https_get_parallel_threads-tls_test_common.o: tls_test_common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_threads_CFLAGS) $(CFLAGS) -MT test_https_get_parallel_threads-tls_test_common.o -MD -MP -MF $(DEPDIR)/test_https_get_parallel_threads-tls_test_common.Tpo -c -o test_https_get_parallel_threads-tls_test_common.o `test -f 'tls_test_common.c' || echo '$(srcdir)/'`tls_test_common.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_https_get_parallel_threads-tls_test_common.Tpo $(DEPDIR)/test_https_get_parallel_threads-tls_test_common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls_test_common.c' object='test_https_get_parallel_threads-tls_test_common.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_threads_CFLAGS) $(CFLAGS) -c -o test_https_get_parallel_threads-tls_test_common.o `test -f 'tls_test_common.c' || echo '$(srcdir)/'`tls_test_common.c test_https_get_parallel_threads-tls_test_common.obj: tls_test_common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_threads_CFLAGS) $(CFLAGS) -MT test_https_get_parallel_threads-tls_test_common.obj -MD -MP -MF $(DEPDIR)/test_https_get_parallel_threads-tls_test_common.Tpo -c -o test_https_get_parallel_threads-tls_test_common.obj `if test -f 'tls_test_common.c'; then $(CYGPATH_W) 'tls_test_common.c'; else $(CYGPATH_W) '$(srcdir)/tls_test_common.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_https_get_parallel_threads-tls_test_common.Tpo $(DEPDIR)/test_https_get_parallel_threads-tls_test_common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls_test_common.c' object='test_https_get_parallel_threads-tls_test_common.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_https_get_parallel_threads_CFLAGS) $(CFLAGS) -c -o test_https_get_parallel_threads-tls_test_common.obj `if test -f 'tls_test_common.c'; then $(CYGPATH_W) 'tls_test_common.c'; else $(CYGPATH_W) '$(srcdir)/tls_test_common.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: $(check_PROGRAMS) @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? test_https_get_select.log: test_https_get_select$(EXEEXT) @p='test_https_get_select$(EXEEXT)'; \ b='test_https_get_select'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_tls_options.log: test_tls_options$(EXEEXT) @p='test_tls_options$(EXEEXT)'; \ b='test_tls_options'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_tls_authentication.log: test_tls_authentication$(EXEEXT) @p='test_tls_authentication$(EXEEXT)'; \ b='test_tls_authentication'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_https_time_out.log: test_https_time_out$(EXEEXT) @p='test_https_time_out$(EXEEXT)'; \ b='test_https_time_out'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_https_get_parallel.log: test_https_get_parallel$(EXEEXT) @p='test_https_get_parallel$(EXEEXT)'; \ b='test_https_get_parallel'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_https_get_parallel_threads.log: test_https_get_parallel_threads$(EXEEXT) @p='test_https_get_parallel_threads$(EXEEXT)'; \ b='test_https_get_parallel_threads'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_https_sni.log: test_https_sni$(EXEEXT) @p='test_https_sni$(EXEEXT)'; \ b='test_https_sni'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_https_session_info.log: test_https_session_info$(EXEEXT) @p='test_https_session_info$(EXEEXT)'; \ b='test_https_session_info'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_https_session_info_append.log: test_https_session_info_append$(EXEEXT) @p='test_https_session_info_append$(EXEEXT)'; \ b='test_https_session_info_append'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_https_multi_daemon.log: test_https_multi_daemon$(EXEEXT) @p='test_https_multi_daemon$(EXEEXT)'; \ b='test_https_multi_daemon'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_https_get.log: test_https_get$(EXEEXT) @p='test_https_get$(EXEEXT)'; \ b='test_https_get'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_empty_response.log: test_empty_response$(EXEEXT) @p='test_empty_response$(EXEEXT)'; \ b='test_empty_response'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_https_get_iovec.log: test_https_get_iovec$(EXEEXT) @p='test_https_get_iovec$(EXEEXT)'; \ b='test_https_get_iovec'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-recursive -rm -f ./$(DEPDIR)/test_empty_response.Po -rm -f ./$(DEPDIR)/test_https_get.Po -rm -f ./$(DEPDIR)/test_https_get_iovec.Po -rm -f ./$(DEPDIR)/test_https_get_parallel-test_https_get_parallel.Po -rm -f ./$(DEPDIR)/test_https_get_parallel-tls_test_common.Po -rm -f ./$(DEPDIR)/test_https_get_parallel_threads-test_https_get_parallel_threads.Po -rm -f ./$(DEPDIR)/test_https_get_parallel_threads-tls_test_common.Po -rm -f ./$(DEPDIR)/test_https_get_select.Po -rm -f ./$(DEPDIR)/test_https_multi_daemon.Po -rm -f ./$(DEPDIR)/test_https_session_info.Po -rm -f ./$(DEPDIR)/test_https_sni.Po -rm -f ./$(DEPDIR)/test_https_time_out.Po -rm -f ./$(DEPDIR)/test_tls_authentication.Po -rm -f ./$(DEPDIR)/test_tls_options.Po -rm -f ./$(DEPDIR)/tls_test_common.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/test_empty_response.Po -rm -f ./$(DEPDIR)/test_https_get.Po -rm -f ./$(DEPDIR)/test_https_get_iovec.Po -rm -f ./$(DEPDIR)/test_https_get_parallel-test_https_get_parallel.Po -rm -f ./$(DEPDIR)/test_https_get_parallel-tls_test_common.Po -rm -f ./$(DEPDIR)/test_https_get_parallel_threads-test_https_get_parallel_threads.Po -rm -f ./$(DEPDIR)/test_https_get_parallel_threads-tls_test_common.Po -rm -f ./$(DEPDIR)/test_https_get_select.Po -rm -f ./$(DEPDIR)/test_https_multi_daemon.Po -rm -f ./$(DEPDIR)/test_https_session_info.Po -rm -f ./$(DEPDIR)/test_https_sni.Po -rm -f ./$(DEPDIR)/test_https_time_out.Po -rm -f ./$(DEPDIR)/test_tls_authentication.Po -rm -f ./$(DEPDIR)/test_tls_options.Po -rm -f ./$(DEPDIR)/tls_test_common.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) check-am install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--depfiles check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile @HEAVY_TESTS_NOTPARALLEL@ $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/src/testcurl/https/test_tls_authentication.c0000644000175000017500000001001314441373361020741 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_tls_authentication.c * @brief Testcase for libmicrohttpd HTTPS GET operations with CA-signed TLS server certificate * @author Sagie Amir * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include #include #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include "tls_test_keys.h" /* perform a HTTP GET request via SSL/TLS */ static unsigned int test_secure_get (void *cls, const char *cipher_suite, int proto_version) { enum test_get_result ret; struct MHD_Daemon *d; uint16_t port; (void) cls; /* Unused. Silent compiler warning. */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 3075; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, port, NULL, NULL, &http_ahc, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_END); if (d == NULL) { fprintf (stderr, MHD_E_SERVER_INIT); return 1; } if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 1; } port = dinfo->port; } ret = test_daemon_get (NULL, cipher_suite, proto_version, port, 1); MHD_stop_daemon (d); if (TEST_GET_HARD_ERROR == ret) return 99; if (TEST_GET_CURL_GEN_ERROR == ret) { fprintf (stderr, "libcurl error.\nTest aborted.\n"); return 99; } if ((TEST_GET_CURL_CA_ERROR == ret) || (TEST_GET_CURL_NOT_IMPLT == ret)) { fprintf (stderr, "libcurl TLS backend does not support custom CA.\n" "Test skipped.\n"); return 77; } return TEST_GET_OK == ret ? 0 : 1; } int main (int argc, char *const *argv) { unsigned int errorCount; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ #ifdef MHD_HTTPS_REQUIRE_GCRYPT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ if (! testsuite_curl_global_init ()) return 99; if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); curl_global_cleanup (); return 77; } #if ! CURL_AT_LEAST_VERSION (7,60,0) if (curl_tls_is_schannel ()) { fprintf (stderr, "libcurl before version 7.60.0 does not support " "custom CA with Schannel backend.\nTest skipped.\n"); curl_global_cleanup (); return 77; } #endif /* ! CURL_AT_LEAST_VERSION(7,60,0) */ errorCount = test_secure_get (NULL, NULL, CURL_SSLVERSION_DEFAULT); print_test_result (errorCount, argv[0]); curl_global_cleanup (); if (77 == errorCount) return 77; if (99 == errorCount) return 77; return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/mhdhost1.crt0000644000175000017500000000346614417460232016111 -----BEGIN CERTIFICATE----- MIIFJjCCAw6gAwIBAgIBBTANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx DzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwGTW9zY293MRswGQYDVQQKDBJ0ZXN0 LWxpYm1pY3JvaHR0cGQxITAfBgkqhkiG9w0BCQEWEm5vYm9keUBleGFtcGxlLm9y ZzEQMA4GA1UEAwwHdGVzdC1DQTAgFw0yMjA0MjAxODQ1MDVaGA8yMTIyMDMyNjE4 NDUwNVowXzELMAkGA1UEBhMCUlUxDzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwG TW9zY293MRswGQYDVQQKDBJ0ZXN0LWxpYm1pY3JvaHR0cGQxETAPBgNVBAMMCG1o ZGhvc3QxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxb5LkwTfvNtW eFSYAPoEzqwVARWxDDR2PfQmmBtrHhMNEQyUCTg+Na00hEQbcZbz7fgS0FOY1hjy MFJamNGP031HvMS7zHNQJ4HbEz0d1EuePgjEvWaFMFncTKGn07Cn9e3Rcv2ihJ/I I8wf3ph/k/UTOv62YhIs2fMQM5LD6oX9ulKJhAaOvFT6hyrB1xe3nVhPT0PsrUXl ky253k7XXEAIWO6dLZnK377UiRDJInFS9FN/hojFb+8gcByo/n39LHMBtp5WGM5+ xGwEHyYkwtnaM8IEKofbUNERQT3cgPv4zN7ny3LwljR2A1c5gHXmKO7G245tbfqb VtOh3+1bJQIDAQABo4HHMIHEMAsGA1UdDwQEAwIFoDAMBgNVHRMBAf8EAjAAMBYG A1UdJQEB/wQMMAoGCCsGAQUFBwMBMBMGA1UdEQQMMAqCCG1oZGhvc3QxMB0GA1Ud DgQWBBTTxzQ/fcuT83JlCzPx8qJzuHCG4jAnBglghkgBhvhCAQ0EGhYYVGVzdCBs aWJtaWNyb2h0dHBkIGhvc3QxMBEGCWCGSAGG+EIBAQQEAwIGQDAfBgNVHSMEGDAW gBRYdUPApWoxw4U13Rqsjf9AHdbpLDANBgkqhkiG9w0BAQsFAAOCAgEAMdHjWHxt 51LH3V8Um3djUh+QYVnYhxFVX4CIXMq2DAg7iYw6tg2S1SOm3R+qEB/rAHxRw/cd nekjx0zm2rAnn4SsIQg5rXzniM4dJ2UQJrn7m88fb/czjXCrvf6hGIXCSAw/YyU0 IkxXlOYv1mYNZBuVvFREUbqqK2Fn+ooIi816Q2UCQFMd+QI8+mn8eqK8XeJElKkt SR0WCLW7UkwYxOk73FCdrr1TlX9hAF76gTAK71OJN3F35hzg+pTAEe3nwFMZbG/k xHmVob51L+Op4Y15j1HoJxW0Ox+PuxVcp9EpC7Qb8UmtExAsYOuN2PP8hU+pmtE4 iYpCDckx6kT66ssjndaKziRmoxX/czvKCAwVDder6Ofl4SwGUEpE+0oO2ux6iNrl iKxRCvyBqErFlzlEj7oO3agqe83jtTH8bXzOCtx36lNVjCuADYI4o7r5NVHaGIx6 1q5BiZ5pj22EYgBZbRAgE1ZPxVBIZJKoHewmQqpcR5WsSeBIf8XDuytnadhv8NDN tpLMDry8KkUh7rtjrQIGb66BqCt0n1tz1/6nLlL9OF5kUt4902wCtN3SbotssfV3 NCX9X4udquRdcFwNLCSfZ505FqhYbeSLraDHJ46/96V//Vx4oAnULdcCm4QgGQmP EGEJDJkaCKKTGMHAvZAtgRchc/RTf59jhoc= -----END CERTIFICATE----- libmicrohttpd-1.0.1/src/testcurl/https/tls_test_common.c0000644000175000017500000004765614556023140017233 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2017-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file tls_test_common.c * @brief Common tls test functions * @author Sagie Amir * @author Karlson2k (Evgeny Grin) */ #include #include "tls_test_common.h" #include "tls_test_keys.h" /** * Map @a know_gnutls_tls_ids values to printable names. */ const char *tls_names[KNOW_TLS_IDS_COUNT] = { "Bad value", "SSL version 3", "TLS version 1.0", "TLS version 1.1", "TLS version 1.2", "TLS version 1.3" }; /** * Map @a know_gnutls_tls_ids values to GnuTLS priorities strings. */ const char *priorities_map[KNOW_TLS_IDS_COUNT] = { "NONE", "NORMAL:!VERS-ALL:+VERS-SSL3.0", "NORMAL:!VERS-ALL:+VERS-TLS1.0", "NORMAL:!VERS-ALL:+VERS-TLS1.1", "NORMAL:!VERS-ALL:+VERS-TLS1.2", "NORMAL:!VERS-ALL:+VERS-TLS1.3" }; /** * Map @a know_gnutls_tls_ids values to GnuTLS priorities append strings. */ const char *priorities_append_map[KNOW_TLS_IDS_COUNT] = { "NONE", "!VERS-ALL:+VERS-SSL3.0", "!VERS-ALL:+VERS-TLS1.0", "!VERS-ALL:+VERS-TLS1.1", "!VERS-ALL:+VERS-TLS1.2", "!VERS-ALL:+VERS-TLS1.3" }; /** * Map @a know_gnutls_tls_ids values to libcurl @a CURLOPT_SSLVERSION value. */ const long libcurl_tls_vers_map[KNOW_TLS_IDS_COUNT] = { CURL_SSLVERSION_LAST, /* bad value */ CURL_SSLVERSION_SSLv3, #if CURL_AT_LEAST_VERSION (7,34,0) CURL_SSLVERSION_TLSv1_0, #else /* CURL VER < 7.34.0 */ CURL_SSLVERSION_TLSv1, /* TLS 1.0 or later */ #endif /* CURL VER < 7.34.0 */ #if CURL_AT_LEAST_VERSION (7,34,0) CURL_SSLVERSION_TLSv1_1, #else /* CURL VER < 7.34.0 */ CURL_SSLVERSION_LAST, /* bad value, not supported by this libcurl version */ #endif /* CURL VER < 7.34.0 */ #if CURL_AT_LEAST_VERSION (7,34,0) CURL_SSLVERSION_TLSv1_2, #else /* CURL VER < 7.34.0 */ CURL_SSLVERSION_LAST, /* bad value, not supported by this libcurl version */ #endif /* CURL VER < 7.34.0 */ #if CURL_AT_LEAST_VERSION (7,52,0) CURL_SSLVERSION_TLSv1_3 #else /* CURL VER < 7.34.0 */ CURL_SSLVERSION_LAST /* bad value, not supported by this libcurl version */ #endif /* CURL VER < 7.34.0 */ }; #if CURL_AT_LEAST_VERSION (7,54,0) /** * Map @a know_gnutls_tls_ids values to libcurl @a CURLOPT_SSLVERSION value * for maximum supported TLS version. */ const long libcurl_tls_max_vers_map[KNOW_TLS_IDS_COUNT] = { CURL_SSLVERSION_MAX_DEFAULT, /* bad value */ CURL_SSLVERSION_MAX_DEFAULT, /* SSLv3 */ CURL_SSLVERSION_MAX_TLSv1_0, CURL_SSLVERSION_MAX_TLSv1_1, CURL_SSLVERSION_MAX_TLSv1_2, CURL_SSLVERSION_MAX_TLSv1_3 }; #endif /* CURL_AT_LEAST_VERSION(7,54,0) */ /* * test HTTPS transfer */ enum test_get_result test_daemon_get (void *cls, const char *cipher_suite, int proto_version, uint16_t port, int ver_peer) { CURL *c; struct CBC cbc; CURLcode errornum; CURLcode e; char url[255]; size_t len; (void) cls; /* Unused. Silence compiler warning. */ len = strlen (test_data); if (NULL == (cbc.buf = malloc (sizeof (char) * len))) { fprintf (stderr, MHD_E_MEM); return TEST_GET_HARD_ERROR; } cbc.size = len; cbc.pos = 0; /* construct url - this might use doc_path */ gen_test_uri (url, sizeof (url), port); c = curl_easy_init (); #ifdef _DEBUG curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); #endif if ((CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_URL, url))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_TIMEOUT, 10L))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 10L))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)))) { fprintf (stderr, "curl_easy_setopt failed: `%s'\n", curl_easy_strerror (e)); curl_easy_cleanup (c); free (cbc.buf); return TEST_GET_CURL_GEN_ERROR; } /* TLS options */ if ((CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSLVERSION, proto_version))) || ((NULL != cipher_suite) && (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_CIPHER_LIST, cipher_suite)))) || /* perform peer authentication */ /* TODO merge into send_curl_req */ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, ver_peer))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L)))) { fprintf (stderr, "HTTPS curl_easy_setopt failed: `%s'\n", curl_easy_strerror (e)); curl_easy_cleanup (c); free (cbc.buf); return TEST_GET_CURL_GEN_ERROR; } if (ver_peer && (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_CAINFO, ca_cert_file_name)))) { fprintf (stderr, "HTTPS curl_easy_setopt failed: `%s'\n", curl_easy_strerror (e)); curl_easy_cleanup (c); free (cbc.buf); return TEST_GET_CURL_CA_ERROR; } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); free (cbc.buf); if ((CURLE_SSL_CACERT_BADFILE == errornum) #if CURL_AT_LEAST_VERSION (7,21,5) || (CURLE_NOT_BUILT_IN == errornum) #endif /* CURL_AT_LEAST_VERSION (7,21,5) */ ) return TEST_GET_CURL_CA_ERROR; if (CURLE_OUT_OF_MEMORY == errornum) return TEST_GET_HARD_ERROR; return TEST_GET_ERROR; } curl_easy_cleanup (c); if (memcmp (cbc.buf, test_data, len) != 0) { fprintf (stderr, "Error: local data & received data differ.\n"); free (cbc.buf); return TEST_GET_TRANSFER_ERROR; } free (cbc.buf); return TEST_GET_OK; } void print_test_result (unsigned int test_outcome, const char *test_name) { if (test_outcome != 0) fprintf (stderr, "running test: %s [fail: %u]\n", test_name, test_outcome); #if 0 else fprintf (stdout, "running test: %s [pass]\n", test_name); #endif } size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) { fprintf (stderr, "Server data does not fit buffer.\n"); return 0; /* overflow */ } memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } /** * HTTP access handler call back */ enum MHD_Result http_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ response = MHD_create_response_from_buffer_static (strlen (test_data), test_data); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } /* HTTP access handler call back */ enum MHD_Result http_dummy_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { (void) cls; (void) connection; (void) url; (void) method; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ return 0; } /** * send a test http request to the daemon * @param url * @param cbc - may be null * @param cipher_suite * @param proto_version * @return */ /* TODO have test wrap consider a NULL cbc */ CURLcode send_curl_req (char *url, struct CBC *cbc, const char *cipher_suite, int proto_version) { CURL *c; CURLcode errornum; CURLcode e; c = curl_easy_init (); #ifdef _DEBUG curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); #endif if ((CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_URL, url))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_TIMEOUT, 60L))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 60L))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)))) { fprintf (stderr, "curl_easy_setopt failed: `%s'\n", curl_easy_strerror (e)); curl_easy_cleanup (c); return e; } if (cbc != NULL) { if ((CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)))) { fprintf (stderr, "curl_easy_setopt failed: `%s'\n", curl_easy_strerror (e)); curl_easy_cleanup (c); return e; } } /* TLS options */ if ((CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSLVERSION, proto_version))) || ((NULL != cipher_suite) && (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_CIPHER_LIST, cipher_suite)))) || /* currently skip any peer authentication */ (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L))) || (CURLE_OK != (e = curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 0L)))) { fprintf (stderr, "HTTPS curl_easy_setopt failed: `%s'\n", curl_easy_strerror (e)); curl_easy_cleanup (c); return e; } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); return errornum; } curl_easy_cleanup (c); return CURLE_OK; } /** * compile test URI * * @param[out] uri - char buffer into which the url is compiled * @param uri_len number of bytes available in @a url * @param port port to use for the test * @return 1 on error */ unsigned int gen_test_uri (char *uri, size_t uri_len, uint16_t port) { int res; res = snprintf (uri, uri_len, "https://127.0.0.1:%u/urlpath", (unsigned int) port); if (res <= 0) return 1; if ((size_t) res >= uri_len) return 1; return 0; } /** * test HTTPS data transfer */ unsigned int test_https_transfer (void *cls, uint16_t port, const char *cipher_suite, int proto_version) { size_t len; unsigned int ret = 0; struct CBC cbc; char url[255]; (void) cls; /* Unused. Silent compiler warning. */ len = strlen (test_data); if (NULL == (cbc.buf = malloc (sizeof (char) * len))) { fprintf (stderr, MHD_E_MEM); return 1; } cbc.size = len; cbc.pos = 0; if (gen_test_uri (url, sizeof (url), port)) { ret = 1; goto cleanup; } if (CURLE_OK != send_curl_req (url, &cbc, cipher_suite, proto_version)) { ret = 1; goto cleanup; } /* compare test data & daemon response */ if ( (len != strlen (test_data)) || (memcmp (cbc.buf, test_data, len) != 0) ) { fprintf (stderr, "Error: original data & received data differ.\n"); ret = 1; } cleanup: free (cbc.buf); return ret; } /** * setup test case * * @param d * @param daemon_flags * @param arg_list * @return port number on success or zero on failure */ static uint16_t setup_testcase (struct MHD_Daemon **d, uint16_t port, unsigned int daemon_flags, va_list arg_list) { *d = MHD_start_daemon_va (daemon_flags, port, NULL, NULL, &http_ahc, NULL, arg_list); if (*d == NULL) { fprintf (stderr, MHD_E_SERVER_INIT); return 0; } if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (*d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (*d); return 0; } port = dinfo->port; } return port; } static void teardown_testcase (struct MHD_Daemon *d) { MHD_stop_daemon (d); } unsigned int setup_session (gnutls_session_t *session, gnutls_certificate_credentials_t *xcred) { if (GNUTLS_E_SUCCESS == gnutls_init (session, GNUTLS_CLIENT)) { if (GNUTLS_E_SUCCESS == gnutls_set_default_priority (*session)) { if (GNUTLS_E_SUCCESS == gnutls_certificate_allocate_credentials (xcred)) { if (GNUTLS_E_SUCCESS == gnutls_credentials_set (*session, GNUTLS_CRD_CERTIFICATE, *xcred)) { return 0; } gnutls_certificate_free_credentials (*xcred); } } gnutls_deinit (*session); } return 1; } unsigned int teardown_session (gnutls_session_t session, gnutls_certificate_credentials_t xcred) { gnutls_deinit (session); gnutls_certificate_free_credentials (xcred); return 0; } /* TODO test_wrap: change sig to (setup_func, test, va_list test_arg) */ unsigned int test_wrap (const char *test_name, unsigned int (*test_function)(void *cls, uint16_t port, const char *cipher_suite, int proto_version), void *cls, uint16_t port, unsigned int daemon_flags, const char *cipher_suite, int proto_version, ...) { unsigned int ret; va_list arg_list; struct MHD_Daemon *d; (void) cls; /* Unused. Silent compiler warning. */ va_start (arg_list, proto_version); port = setup_testcase (&d, port, daemon_flags, arg_list); if (0 == port) { va_end (arg_list); fprintf (stderr, "Failed to setup testcase %s\n", test_name); return 1; } #if 0 fprintf (stdout, "running test: %s ", test_name); #endif ret = test_function (NULL, port, cipher_suite, proto_version); #if 0 if (ret == 0) { fprintf (stdout, "[pass]\n"); } else { fprintf (stdout, "[fail]\n"); } #endif teardown_testcase (d); va_end (arg_list); return ret; } static int inited_tls_is_gnutls = 0; static int inited_tls_is_openssl = 0; int curl_tls_is_gnutls (void) { const char *tlslib; if (inited_tls_is_gnutls) return 1; if (inited_tls_is_openssl) return 0; tlslib = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == tlslib) return 0; if (0 == strncmp (tlslib, "GnuTLS/", 7)) return 1; /* Multi-backends handled during initialization by setting variable */ return 0; } int curl_tls_is_openssl (void) { const char *tlslib; if (inited_tls_is_gnutls) return 0; if (inited_tls_is_openssl) return 1; tlslib = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == tlslib) return 0; if (0 == strncmp (tlslib, "OpenSSL/", 8)) return 1; /* Multi-backends handled during initialization by setting variable */ return 0; } int curl_tls_is_nss (void) { const char *tlslib; if (inited_tls_is_gnutls) return 0; if (inited_tls_is_openssl) return 0; tlslib = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == tlslib) return 0; if (0 == strncmp (tlslib, "NSS/", 4)) return 1; /* Handle multi-backends with selected backend */ if (NULL != strstr (tlslib," NSS/")) return 1; return 0; } int curl_tls_is_schannel (void) { const char *tlslib; if (inited_tls_is_gnutls) return 0; if (inited_tls_is_openssl) return 0; tlslib = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == tlslib) return 0; if ((0 == strncmp (tlslib, "Schannel", 8)) || (0 == strncmp (tlslib, "WinSSL", 6))) return 1; /* Handle multi-backends with selected backend */ if ((NULL != strstr (tlslib," Schannel")) || (NULL != strstr (tlslib, " WinSSL"))) return 1; return 0; } int curl_tls_is_sectransport (void) { const char *tlslib; if (inited_tls_is_gnutls) return 0; if (inited_tls_is_openssl) return 0; tlslib = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == tlslib) return 0; if (0 == strncmp (tlslib, "SecureTransport", 15)) return 1; /* Handle multi-backends with selected backend */ if (NULL != strstr (tlslib," SecureTransport")) return 1; return 0; } int testsuite_curl_global_init (void) { CURLcode res; #if LIBCURL_VERSION_NUM >= 0x073800 if (CURLSSLSET_OK != curl_global_sslset (CURLSSLBACKEND_GNUTLS, NULL, NULL)) { CURLsslset e; e = curl_global_sslset (CURLSSLBACKEND_OPENSSL, NULL, NULL); if (CURLSSLSET_TOO_LATE == e) fprintf (stderr, "WARNING: libcurl was already initialised.\n"); else if (CURLSSLSET_OK == e) inited_tls_is_openssl = 1; } else inited_tls_is_gnutls = 1; #endif /* LIBCURL_VERSION_NUM >= 0x07380 */ res = curl_global_init (CURL_GLOBAL_ALL); if (CURLE_OK != res) { fprintf (stderr, "libcurl initialisation error: %s\n", curl_easy_strerror (res)); return 0; } return 1; } /** * Check whether program name contains specific @a marker string. * Only last component in pathname is checked for marker presence, * all leading directories names (if any) are ignored. Directories * separators are handled correctly on both non-W32 and W32 * platforms. * @param prog_name program name, may include path * @param marker marker to look for. * @return zero if any parameter is NULL or empty string or * @a prog_name ends with slash or @a marker is not found in * program name, non-zero if @a maker is found in program * name. */ int has_in_name (const char *prog_name, const char *marker) { size_t name_pos; size_t pos; if (! prog_name || ! marker || ! prog_name[0] || ! marker[0]) return 0; pos = 0; name_pos = 0; while (prog_name[pos]) { if ('/' == prog_name[pos]) name_pos = pos + 1; #if defined(_WIN32) || defined(__CYGWIN__) else if ('\\' == prog_name[pos]) name_pos = pos + 1; #endif /* _WIN32 || __CYGWIN__ */ pos++; } if (name_pos == pos) return 0; return strstr (prog_name + name_pos, marker) != (char *) 0; } libmicrohttpd-1.0.1/src/testcurl/https/test_https_multi_daemon.c0000644000175000017500000001250114556022036020740 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_https_multi_daemon.c * @brief Testcase for libmicrohttpd multiple HTTPS daemon scenario * @author Sagie Amir * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include #include #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include "tls_test_keys.h" /* * assert initiating two separate daemons and having one shut down * doesn't affect the other */ static unsigned int test_concurent_daemon_pair (void *cls, const char *cipher_suite, int proto_version) { unsigned int ret; enum test_get_result res; struct MHD_Daemon *d1; struct MHD_Daemon *d2; uint16_t port1, port2; (void) cls; /* Unused. Silent compiler warning. */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port1 = port2 = 0; else { port1 = 3050; port2 = 3051; } d1 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, port1, NULL, NULL, &http_ahc, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); if (d1 == NULL) { fprintf (stderr, MHD_E_SERVER_INIT); return 1; } if (0 == port1) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d1, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { fprintf (stderr, "Cannot detect daemon bind port.\n"); MHD_stop_daemon (d1); return 1; } port1 = dinfo->port; } d2 = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, port2, NULL, NULL, &http_ahc, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); if (d2 == NULL) { MHD_stop_daemon (d1); fprintf (stderr, MHD_E_SERVER_INIT); return 1; } if (0 == port2) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d2, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { fprintf (stderr, "Cannot detect daemon bind port.\n"); MHD_stop_daemon (d1); MHD_stop_daemon (d2); return 1; } port2 = dinfo->port; } res = test_daemon_get (NULL, cipher_suite, proto_version, port1, 0); ret = (unsigned int) res; if ((TEST_GET_HARD_ERROR == res) || (TEST_GET_CURL_GEN_ERROR == res)) { fprintf (stderr, "libcurl error.\nTest aborted.\n"); MHD_stop_daemon (d2); MHD_stop_daemon (d1); return 99; } res = test_daemon_get (NULL, cipher_suite, proto_version, port2, 0); ret += (unsigned int) res; if ((TEST_GET_HARD_ERROR == res) || (TEST_GET_CURL_GEN_ERROR == res)) { fprintf (stderr, "libcurl error.\nTest aborted.\n"); MHD_stop_daemon (d2); MHD_stop_daemon (d1); return 99; } MHD_stop_daemon (d2); res = test_daemon_get (NULL, cipher_suite, proto_version, port1, 0); ret += (unsigned int) res; if ((TEST_GET_HARD_ERROR == res) || (TEST_GET_CURL_GEN_ERROR == res)) { fprintf (stderr, "libcurl error.\nTest aborted.\n"); MHD_stop_daemon (d1); return 99; } MHD_stop_daemon (d1); return ret; } int main (int argc, char *const *argv) { unsigned int errorCount; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ #ifdef MHD_HTTPS_REQUIRE_GCRYPT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ if (! testsuite_curl_global_init ()) return 99; if (NULL == curl_version_info (CURLVERSION_NOW)->ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); curl_global_cleanup (); return 77; } errorCount = test_concurent_daemon_pair (NULL, NULL, CURL_SSLVERSION_DEFAULT); print_test_result (errorCount, "concurent_daemon_pair"); curl_global_cleanup (); if (99 == errorCount) return 99; return errorCount != 0 ? 1 : 0; } libmicrohttpd-1.0.1/src/testcurl/https/mhdhost2.key0000644000175000017500000000325014417460232016101 -----BEGIN PRIVATE KEY----- MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDLa/Vzf1FA+AYS qFiKyJBflANMkUKv3cH8oL3oCrFd9SrFgdBkccHJ6HbIdfld5j5zCLNr09vyQHlb K7khXukdhstd61RDsdrygJdxdkGKHMwaN1NACkG8oRLaui2SDEgCvMVGT8qc7cPa vzsTb98eqUeODRjx3nyLzjqbsZIWkfa4BiiCbZmGLaiMTg7+p9o7pxJN2NSENsyI ORCV/9+Sr2jdl4bMpd3MsLk94gn/sdsRwEnR7qXIAVthm2lMC1Dr+26oBlOze0wb lirdwBljvHi8YQJloBZkCWCy0GkJh3xv92Vdryq/Hgm4wXir7u9VuDAdWhewDOZk DFI3L52ZAgMBAAECggEBAIS8cXFoBpEqRmwuRXhp3ys+3dg8gRNY1JgQG1sqfwoc TEiMqHqicB1b/wZXVNycvOs7JjiaCc9NmuKO6UKJN/v4VQN354g0qfXLSwbSb3m7 yMLijwQerT50rGTlT48ZTHPc0a1Lq54y17YJSncobKMJOpPKoBhTYVmovD2T5Qus EDFg8wLBA79YZnrImbt9hcRsi/bM341V3aSoPFdHz6NTi+5WA08oTiGCv6gThV8T PUCiy1uDJZ1gk3xne+APZfdTutVtwCYVw7mhgTHiL5tL1KCjDjzK3XgnfAWaN+wG ex9EYbn/uAxN57UrvdyvGtuBo01vs/XtsVlpRpmlBnECgYEA+L8D8UY36IubeMAl xFCoFSXSmT+2YtA6ISg4/8a14wpwAskJPW/Nf8CzzwbGA7QaDVeK4rTGDOwNQJV8 /fiTaG6vDI7GS3UkvSKStfJzoMRBTzCYp/TbkG/jW2i8tR1AATlQlGllx0BQVXhC iYpR/WzbxGi5iyB4K6WPbSKboh8CgYEA0VqUR7w+2PEEFXyFRL2drpzkWKk5RiIa cIzQk3VlrHztJp0g6w8MiWCIpzL+7BuBy72byxJwpFmOz4HYsEqc6mOF4xXezfYh oN0P1+/aH4NrpWmjb65TGrtwrmi2sJrmATmr9WKFxEIpgrbotOTDF7pIx9pY2ScA aohOxqb7eUcCgYAHtHL80D3/GAPy05DX6d+q+Abz9ENEAEssp8BMO+16YOJjU7LT klj9MgzfxsfvaW69Jw8IQq03zUAD1h2PCFoYjAUkEHAX+kLvENkWhbILMskLGOhB m5YJfU2/kRj3SzamUw4p6rHaYCWc4CK/e+daQDr2dH/6zUCrqW8t5DqJ5QKBgF8E voIkhV3PXiwmXRJLAXNMEDPRcoZLWja1IsGaqe/0r2o0LMmjBeygHMXOVndxMKL5 RumPUAK4ByJVa7Tv2HJlg1IDDiHq0W6ChvtaCGT/L+9el+hLdbqPUmBGdIyJcVUj CNIRyma+JLsIK2xW29k8GmZiyqqckgrIHQD6ru5nAoGAAcdAHQojvGs5dQ2Agqcn EOgF1dic7VgCjAEG4CNCydzskE92jEOgv2DI+oBPoLrtktHbewFrsxBBNbS+PcHY DyV5/WXf8wwwdkG1VLyw+dPeWNGWanvjllplckDXSGz1ia0s7ENNAt8o2MXdlZrQ MMHn0wo/1rTa1YroHF8cKVA= -----END PRIVATE KEY----- libmicrohttpd-1.0.1/src/testcurl/https/test_https_sni.c0000644000175000017500000002213114556022036017054 /* This file is part of libmicrohttpd Copyright (C) 2013, 2016 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_https_sni.c * @brief Testcase for libmicrohttpd HTTPS with SNI operations * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include #include #include #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #include "tls_test_common.h" #include /* This test only works with GnuTLS >= 3.0 */ #if GNUTLS_VERSION_MAJOR >= 3 #include /** * A hostname, server key and certificate. */ struct Hosts { struct Hosts *next; const char *hostname; gnutls_pcert_st pcrt; gnutls_privkey_t key; }; /** * Linked list of supported TLDs and respective certificates. */ static struct Hosts *hosts; /* Load the certificate and the private key. * (This code is largely taken from GnuTLS). */ static void load_keys (const char *hostname, const char *CERT_FILE, const char *KEY_FILE) { int ret; gnutls_datum_t data; struct Hosts *host; host = malloc (sizeof (struct Hosts)); if (NULL == host) abort (); host->hostname = hostname; host->next = hosts; hosts = host; ret = gnutls_load_file (CERT_FILE, &data); if (ret < 0) { fprintf (stderr, "*** Error loading certificate file %s.\n", CERT_FILE); exit (1); } ret = gnutls_pcert_import_x509_raw (&host->pcrt, &data, GNUTLS_X509_FMT_PEM, 0); if (ret < 0) { fprintf (stderr, "*** Error loading certificate file: %s\n", gnutls_strerror (ret)); exit (1); } gnutls_free (data.data); ret = gnutls_load_file (KEY_FILE, &data); if (ret < 0) { fprintf (stderr, "*** Error loading key file %s.\n", KEY_FILE); exit (1); } gnutls_privkey_init (&host->key); ret = gnutls_privkey_import_x509_raw (host->key, &data, GNUTLS_X509_FMT_PEM, NULL, 0); if (ret < 0) { fprintf (stderr, "*** Error loading key file: %s\n", gnutls_strerror (ret)); exit (1); } gnutls_free (data.data); } /** * @param session the session we are giving a cert for * @param req_ca_dn NULL on server side * @param nreqs length of req_ca_dn, and thus 0 on server side * @param pk_algos NULL on server side * @param pk_algos_length 0 on server side * @param pcert list of certificates (to be set) * @param pcert_length length of pcert (to be set) * @param pkey the private key (to be set) */ static int sni_callback (gnutls_session_t session, const gnutls_datum_t *req_ca_dn, int nreqs, const gnutls_pk_algorithm_t *pk_algos, int pk_algos_length, gnutls_pcert_st **pcert, unsigned int *pcert_length, gnutls_privkey_t *pkey) { char name[256]; size_t name_len; struct Hosts *host; unsigned int type; (void) req_ca_dn; (void) nreqs; (void) pk_algos; (void) pk_algos_length; /* Unused. Silent compiler warning. */ name_len = sizeof (name); if (GNUTLS_E_SUCCESS != gnutls_server_name_get (session, name, &name_len, &type, 0 /* index */)) return -1; for (host = hosts; NULL != host; host = host->next) if (0 == strncmp (name, host->hostname, name_len)) break; if (NULL == host) { fprintf (stderr, "Need certificate for %.*s\n", (int) name_len, name); return -1; } #if 0 fprintf (stderr, "Returning certificate for %.*s\n", (int) name_len, name); #endif *pkey = host->key; *pcert_length = 1; *pcert = &host->pcrt; return 0; } /* perform a HTTP GET request via SSL/TLS */ static int do_get (const char *url, uint16_t port) { CURL *c; struct CBC cbc; CURLcode errornum; size_t len; struct curl_slist *dns_info; char buf[256]; len = strlen (test_data); if (NULL == (cbc.buf = malloc (sizeof (char) * len))) { fprintf (stderr, MHD_E_MEM); return -1; } cbc.size = len; cbc.pos = 0; c = curl_easy_init (); #ifdef _DEBUG curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); #endif curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_TIMEOUT, 10L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 10L); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_CAINFO, SRCDIR "/test-ca.crt"); /* perform peer authentication */ /* TODO merge into send_curl_req */ curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 2L); sprintf (buf, "mhdhost1:%u:127.0.0.1", (unsigned int) port); dns_info = curl_slist_append (NULL, buf); sprintf (buf, "mhdhost2:%u:127.0.0.1", (unsigned int) port); dns_info = curl_slist_append (dns_info, buf); curl_easy_setopt (c, CURLOPT_RESOLVE, dns_info); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); free (cbc.buf); curl_slist_free_all (dns_info); return -1; } curl_easy_cleanup (c); curl_slist_free_all (dns_info); if (memcmp (cbc.buf, test_data, len) != 0) { fprintf (stderr, "Error: local file & received file differ.\n"); free (cbc.buf); return -1; } free (cbc.buf); return 0; } int main (int argc, char *const *argv) { unsigned int error_count = 0; struct MHD_Daemon *d; uint16_t port; const char *tls_backend; (void) argc; /* Unused. Silent compiler warning. */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 3065; #ifdef MHD_HTTPS_REQUIRE_GCRYPT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ if (! testsuite_curl_global_init ()) return 99; tls_backend = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == tls_backend) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); curl_global_cleanup (); return 77; } if (! curl_tls_is_gnutls () && ! curl_tls_is_openssl ()) { fprintf (stderr, "This test is reliable only with libcurl with GnuTLS or " "OpenSSL backends.\nSkipping the test as libcurl has '%s' " "backend.\n", tls_backend); curl_global_cleanup (); return 77; } load_keys ("mhdhost1", SRCDIR "/mhdhost1.crt", SRCDIR "/mhdhost1.key"); load_keys ("mhdhost2", SRCDIR "/mhdhost2.crt", SRCDIR "/mhdhost2.key"); d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS | MHD_USE_ERROR_LOG, port, NULL, NULL, &http_ahc, NULL, MHD_OPTION_HTTPS_CERT_CALLBACK, &sni_callback, MHD_OPTION_END); if (d == NULL) { fprintf (stderr, MHD_E_SERVER_INIT); return -1; } if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return -1; } port = dinfo->port; } if (0 != do_get ("https://mhdhost1/", port)) error_count++; if (0 != do_get ("https://mhdhost2/", port)) error_count++; MHD_stop_daemon (d); curl_global_cleanup (); if (error_count != 0) fprintf (stderr, "Failed test: %s, error: %u.\n", argv[0], error_count); return (0 != error_count) ? 1 : 0; } #else int main (void) { fprintf (stderr, "SNI not supported by GnuTLS < 3.0\n"); return 77; } #endif libmicrohttpd-1.0.1/src/testcurl/test_get_close_keep_alive.c0000644000175000017500000010547414556022036020043 /* This file is part of libmicrohttpd Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) Copyright (C) 2007, 2009, 2011 Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_get_close_keep_alive.c * @brief Testcase for libmicrohttpd "Close" and "Keep-Alive" connection. * @details Testcases for testing of MHD automatic choice between "Close" and * "Keep-Alive" connections. Also tested selected HTTP version and * "Connection:" headers. * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #include "mhd_has_param.h" #include "mhd_sockets.h" /* only macros used */ #ifdef HAVE_STRINGS_H #include #endif /* HAVE_STRINGS_H */ #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #ifndef WINDOWS #include #include #endif #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #if MHD_CPU_COUNT > 32 #undef MHD_CPU_COUNT /* Limit to reasonable value */ #define MHD_CPU_COUNT 32 #endif /* MHD_CPU_COUNT > 32 */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error details: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 #define EXPECTED_URI_BASE_PATH "/hello_world" #define EXPECTED_URI_QUERY "a=%26&b=c" #define EXPECTED_URI_FULL_PATH EXPECTED_URI_BASE_PATH "?" EXPECTED_URI_QUERY #define HDR_CONN_CLOSE_VALUE "close" #define HDR_CONN_CLOSE MHD_HTTP_HEADER_CONNECTION ": " \ HDR_CONN_CLOSE_VALUE #define HDR_CONN_KEEP_ALIVE_VALUE "Keep-Alive" #define HDR_CONN_KEEP_ALIVE MHD_HTTP_HEADER_CONNECTION ": " \ HDR_CONN_KEEP_ALIVE_VALUE /* Global parameters */ static int oneone; /**< Use HTTP/1.1 instead of HTTP/1.0 for requests*/ static int conn_close; /**< Don't use Keep-Alive */ static uint16_t global_port; /**< MHD daemons listen port number */ static int slow_reply = 0; /**< Slowdown MHD replies */ static int ignore_response_errors = 0; /**< Do not fail test if CURL returns error */ static int response_timeout_val = TIMEOUTS_VAL; /* Current test parameters */ /* Poor thread sync, but enough for the testing */ static volatile int mhd_add_close; /**< Add "Connection: close" header by MHD */ static volatile int mhd_set_10_cmptbl; /**< Set MHD_RF_HTTP_1_0_COMPATIBLE_STRICT response flag */ static volatile int mhd_set_10_server; /**< Set MHD_RF_HTTP_1_0_SERVER response flag */ static volatile int mhd_set_k_a_send; /**< Set MHD_RF_SEND_KEEP_ALIVE_HEADER response flag */ /* Static helper variables */ static struct curl_slist *curl_close_hdr; /**< CURL "Connection: close" header */ static struct curl_slist *curl_k_alive_hdr; /**< CURL "Connection: keep-alive" header */ static struct curl_slist *curl_both_hdrs; /**< CURL both "Connection: keep-alive" and "close" headers */ static void test_global_init (void) { libcurl_errbuf[0] = 0; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) externalErrorExit (); curl_close_hdr = NULL; curl_close_hdr = curl_slist_append (curl_close_hdr, HDR_CONN_CLOSE); if (NULL == curl_close_hdr) externalErrorExit (); curl_k_alive_hdr = NULL; curl_k_alive_hdr = curl_slist_append (curl_k_alive_hdr, HDR_CONN_KEEP_ALIVE); if (NULL == curl_k_alive_hdr) externalErrorExit (); curl_both_hdrs = NULL; curl_both_hdrs = curl_slist_append (curl_both_hdrs, HDR_CONN_KEEP_ALIVE); if (NULL == curl_both_hdrs) externalErrorExit (); curl_both_hdrs = curl_slist_append (curl_both_hdrs, HDR_CONN_CLOSE); if (NULL == curl_both_hdrs) externalErrorExit (); } static void test_global_cleanup (void) { curl_slist_free_all (curl_both_hdrs); curl_slist_free_all (curl_k_alive_hdr); curl_slist_free_all (curl_close_hdr); curl_global_cleanup (); } struct headers_check_result { int found_http11; int found_http10; int found_conn_close; int found_conn_keep_alive; }; static size_t lcurl_hdr_callback (char *buffer, size_t size, size_t nitems, void *userdata) { const size_t data_size = size * nitems; struct headers_check_result *check_res = (struct headers_check_result *) userdata; if ((strlen (MHD_HTTP_VERSION_1_1) < data_size) && (0 == memcmp (MHD_HTTP_VERSION_1_1, buffer, strlen (MHD_HTTP_VERSION_1_1)))) check_res->found_http11 = 1; else if ((strlen (MHD_HTTP_VERSION_1_0) < data_size) && (0 == memcmp (MHD_HTTP_VERSION_1_0, buffer, strlen (MHD_HTTP_VERSION_1_0)))) check_res->found_http10 = 1; else if ((data_size == strlen (HDR_CONN_CLOSE) + 2) && (0 == memcmp (buffer, HDR_CONN_CLOSE "\r\n", data_size))) check_res->found_conn_close = 1; else if ((data_size == strlen (HDR_CONN_KEEP_ALIVE) + 2) && (0 == memcmp (buffer, HDR_CONN_KEEP_ALIVE "\r\n", data_size))) check_res->found_conn_keep_alive = 1; return data_size; } struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) externalErrorExit (); /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static void * log_cb (void *cls, const char *uri, struct MHD_Connection *con) { (void) cls; (void) con; if (0 != strcmp (uri, EXPECTED_URI_FULL_PATH)) { fprintf (stderr, "Wrong URI: `%s', line: %d\n", uri, __LINE__); exit (22); } return NULL; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silence compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; if (slow_reply) usleep (200000); response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); if (NULL == response) { fprintf (stderr, "Failed to create response. Line: %d\n", __LINE__); exit (19); } if (mhd_add_close) { if (MHD_YES != MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, HDR_CONN_CLOSE_VALUE)) { fprintf (stderr, "Failed to add header. Line: %d\n", __LINE__); exit (19); } } if (MHD_YES != MHD_set_response_options (response, (mhd_set_10_cmptbl ? MHD_RF_HTTP_1_0_COMPATIBLE_STRICT : 0) | (mhd_set_10_server ? MHD_RF_HTTP_1_0_SERVER : 0) | (mhd_set_k_a_send ? MHD_RF_SEND_KEEP_ALIVE_HEADER : 0), MHD_RO_END)) { fprintf (stderr, "Failed to set response flags. Line: %d\n", __LINE__); exit (19); } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (MHD_YES != ret) { fprintf (stderr, "Failed to queue response. Line: %d\n", __LINE__); exit (19); } return ret; } struct curlQueryParams { /* Destination path for CURL query */ const char *queryPath; /* Destination port for CURL query */ uint16_t queryPort; /* CURL query result error flag */ volatile unsigned int queryError; }; static CURL * curlEasyInitForTest (const char *queryPath, uint16_t port, struct CBC *pcbc, struct headers_check_result *hdr_chk_result, int add_hdr_close, int add_hdr_k_alive) { CURL *c; c = curl_easy_init (); if (NULL == c) { fprintf (stderr, "curl_easy_init() failed.\n"); externalErrorExit (); } if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, queryPath)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, (long) port)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, pcbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, (long) response_timeout_val)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, (long) response_timeout_val)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HEADERFUNCTION, lcurl_hdr_callback)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HEADERDATA, hdr_chk_result)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0))) { fprintf (stderr, "curl_easy_setopt() failed.\n"); externalErrorExit (); } if (add_hdr_close && add_hdr_k_alive) { /* This combination is actually incorrect */ if (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPHEADER, curl_both_hdrs)) { fprintf (stderr, "Set libcurl HTTP header failed.\n"); externalErrorExit (); } } else if (add_hdr_close) { if (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPHEADER, curl_close_hdr)) { fprintf (stderr, "Set libcurl HTTP header failed.\n"); externalErrorExit (); } } else if (add_hdr_k_alive) { if (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPHEADER, curl_k_alive_hdr)) { fprintf (stderr, "Set libcurl HTTP header failed.\n"); externalErrorExit (); } } return c; } static void print_test_params (int add_hdr_close, int add_hdr_k_alive) { fprintf (stderr, "Request HTTP/%s| ", oneone ? "1.1" : "1.0"); fprintf (stderr, "Connection must be: %s| ", conn_close ? "close" : "keep-alive"); fprintf (stderr, "Request \"close\": %s| ", add_hdr_close ? " used" : "NOT used"); fprintf (stderr, "Request \"keep-alive\": %s| ", add_hdr_k_alive ? " used" : "NOT used"); fprintf (stderr, "MHD response \"close\": %s| ", mhd_add_close ? " used" : "NOT used"); fprintf (stderr, "MHD response 1.0 strict compatible: %s| ", mhd_set_10_cmptbl ? "yes" : " NO"); fprintf (stderr, "MHD response 1.0 server: %s| ", mhd_set_10_server ? "yes" : " NO"); fprintf (stderr, "MHD response send \"Keep-Alive\": %s|", mhd_set_k_a_send ? "yes" : " NO"); fprintf (stderr, "\n*** "); } static CURLcode performQueryExternal (struct MHD_Daemon *d, CURL *c) { CURLM *multi; time_t start; struct timeval tv; CURLcode ret; ret = CURLE_FAILED_INIT; /* will be replaced with real result */ multi = NULL; multi = curl_multi_init (); if (multi == NULL) { fprintf (stderr, "curl_multi_init() failed.\n"); externalErrorExit (); } if (CURLM_OK != curl_multi_add_handle (multi, c)) { fprintf (stderr, "curl_multi_add_handle() failed.\n"); externalErrorExit (); } start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; int running; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL != multi) { curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) { fprintf (stderr, "curl_multi_info_read failed, NULL returned.\n"); externalErrorExit (); } totalMsgs++; if (CURLMSG_DONE == msg->msg) ret = msg->data.result; } while (msgLeft > 0); if (1 != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); externalErrorExit (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); multi = NULL; } else { if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) { fprintf (stderr, "curl_multi_fdset() failed.\n"); externalErrorExit (); } } } if (NULL == multi) { /* libcurl has finished, check whether MHD still needs to perform cleanup */ if (0 != MHD_get_timeout64s (d)) break; /* MHD finished as well */ } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) { fprintf (stderr, "MHD_get_fdset() failed. Line: %d\n", __LINE__); exit (11); break; } tv.tv_sec = 0; tv.tv_usec = 1000; #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) { fprintf (stderr, "MHD_run_from_select() failed. Line: %d\n", __LINE__); exit (11); } } return ret; } static unsigned int getMhdActiveConnections (struct MHD_Daemon *d) { const union MHD_DaemonInfo *dinfo; /* The next method is unreliable unless it's known that no * connections are started or finished in parallel */ dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_CURRENT_CONNECTIONS); if (NULL == dinfo) { fprintf (stderr, "MHD_get_daemon_info() failed.\n"); abort (); } return dinfo->num_connections; } static unsigned int doCurlQueryInThread (struct MHD_Daemon *d, struct curlQueryParams *p, int add_hdr_close, int add_hdr_k_alive) { const union MHD_DaemonInfo *dinfo; CURL *c; char buf[2048]; struct CBC cbc; struct headers_check_result hdr_res; CURLcode errornum; int use_external_poll; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_FLAGS); if (NULL == dinfo) { fprintf (stderr, "MHD_get_daemon_info() failed.\n"); abort (); } use_external_poll = (0 == (dinfo->flags & MHD_USE_INTERNAL_POLLING_THREAD)); if (NULL == p->queryPath) abort (); if (0 == p->queryPort) abort (); cbc.buf = buf; cbc.size = sizeof(buf); cbc.pos = 0; hdr_res.found_http11 = 0; hdr_res.found_http10 = 0; hdr_res.found_conn_close = 0; hdr_res.found_conn_keep_alive = 0; c = curlEasyInitForTest (p->queryPath, p->queryPort, &cbc, &hdr_res, add_hdr_close, add_hdr_k_alive); if (! use_external_poll) errornum = curl_easy_perform (c); else errornum = performQueryExternal (d, c); if (ignore_response_errors) { p->queryError = 0; curl_easy_cleanup (c); return p->queryError; } if (CURLE_OK != errornum) { p->queryError = 1; fprintf (stderr, "libcurl query failed: `%s'\n", curl_easy_strerror (errornum)); libcurlErrorExit (); } else { if (cbc.pos != strlen (EXPECTED_URI_BASE_PATH)) { fprintf (stderr, "curl reports wrong size of MHD reply body data.\n"); p->queryError = 1; } else if (0 != strncmp (EXPECTED_URI_BASE_PATH, cbc.buf, strlen (EXPECTED_URI_BASE_PATH))) { fprintf (stderr, "curl reports wrong MHD reply body data.\n"); p->queryError = 1; } else p->queryError = 0; } if (! hdr_res.found_http11 && ! hdr_res.found_http10) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "No know HTTP versions were found in the " "reply header. Line: %d\n", __LINE__); exit (24); } else if (hdr_res.found_http11 && hdr_res.found_http10) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "Both HTTP/1.1 and HTTP/1.0 were found in the " "reply header. Line: %d\n", __LINE__); exit (24); } if (conn_close) { if (! hdr_res.found_conn_close) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "\"Connection: close\" was not found in" " MHD reply headers.\n"); p->queryError |= 2; } if (hdr_res.found_conn_keep_alive) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "\"Connection: keep-alive\" was found in" " MHD reply headers.\n"); p->queryError |= 2; } if (use_external_poll) { /* The number of MHD connection can queried only with external poll. * otherwise it creates a race condition. */ if (0 != getMhdActiveConnections (d)) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "MHD still has active connection " "after response has been sent.\n"); p->queryError |= 2; } } } else { /* Keep-Alive */ if (! oneone || mhd_set_10_server || mhd_set_k_a_send) { /* Should have "Connection: Keep-Alive" */ if (! hdr_res.found_conn_keep_alive) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "\"Connection: keep-alive\" was not found in" " MHD reply headers.\n"); p->queryError |= 2; } } else { /* Should NOT have "Connection: Keep-Alive" */ if (hdr_res.found_conn_keep_alive) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "\"Connection: keep-alive\" was found in" " MHD reply headers.\n"); p->queryError |= 2; } } if (hdr_res.found_conn_close) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "\"Connection: close\" was found in" " MHD reply headers.\n"); p->queryError |= 2; } if (use_external_poll) { /* The number of MHD connection can be queried only with external poll. * otherwise it creates a race condition. */ unsigned int num_conn = getMhdActiveConnections (d); if (0 == num_conn) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "MHD has no active connection " "after response has been sent.\n"); p->queryError |= 2; } else if (1 != num_conn) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "MHD has wrong number of active connection (%u) " "after response has been sent. Line: %d\n", num_conn, __LINE__); exit (23); } } } #if defined(CURL_AT_LEAST_VERSION) && CURL_AT_LEAST_VERSION (7, 45, 0) if (! use_external_poll) { /* libcurl closes connection socket with curl_multi_remove_handle () / curl_multi_cleanup() */ curl_socket_t curl_sckt; if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_ACTIVESOCKET, &curl_sckt)) { fprintf (stderr, "Failed to get libcurl active socket.\n"); libcurlErrorExit (); } if (conn_close && (CURL_SOCKET_BAD != curl_sckt)) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "libcurl still has active connection " "after performing the test query.\n"); p->queryError |= 2; } else if (! conn_close && (CURL_SOCKET_BAD == curl_sckt)) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "libcurl has no active connection " "after performing the test query.\n"); p->queryError |= 2; } } #endif if (! mhd_set_10_server) { /* Response must be HTTP/1.1 */ if (hdr_res.found_http10) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "Reply has HTTP/1.0 version, while it " "must be HTTP/1.1.\n"); p->queryError |= 4; } } else { /* Response must be HTTP/1.0 */ if (hdr_res.found_http11) { print_test_params (add_hdr_close, add_hdr_k_alive); fprintf (stderr, "Reply has HTTP/1.1 version, while it " "must be HTTP/1.0.\n"); p->queryError |= 4; } } curl_easy_cleanup (c); return p->queryError; } /* Perform test queries and shut down MHD daemon */ static unsigned int performTestQueries (struct MHD_Daemon *d, uint16_t d_port) { struct curlQueryParams qParam; unsigned int ret = 0; /* Return value */ int i = 0; /* masks */ const int m_mhd_close = 1 << (i++); const int m_10_cmptbl = 1 << (i++); const int m_10_server = 1 << (i++); const int m_k_a_send = 1 << (i++); const int m_client_close = 1 << (i++); const int m_client_k_alive = 1 << (i++); qParam.queryPath = "http://127.0.0.1" EXPECTED_URI_FULL_PATH; qParam.queryPort = d_port; /* Connect to the daemon */ for (i = (1 << i) - 1; 0 <= i; i--) { const int f_mhd_close = (0 == (i & m_mhd_close)); /**< Use MHD "close" header */ const int f_10_cmptbl = (0 == (i & m_10_cmptbl)); /**< Use MHD MHD_RF_HTTP_1_0_COMPATIBLE_STRICT flag */ const int f_10_server = (0 == (i & m_10_server)); /**< Use MHD MHD_RF_HTTP_1_0_SERVER flag */ const int f_k_a_send = (0 == (i & m_k_a_send)); /**< Use MHD MHD_RF_SEND_KEEP_ALIVE_HEADER flag */ const int f_client_close = (0 == (i & m_client_close)); /**< Use libcurl "close" header */ const int f_client_k_alive = (0 == (i & m_client_k_alive)); /**< Use libcurl "Keep-Alive" header */ int res_close; /**< Indicate the result of the test query should be closed connection */ if (f_mhd_close) /* Connection with server's "close" header must be always closed */ res_close = 1; else if (f_client_close) /* Connection with client's "close" header must be always closed */ res_close = 1; else if (f_10_cmptbl) /* Connection in strict HTTP/1.0 compatible mode must be always closed */ res_close = 1; else if (! oneone || f_10_server) /* With HTTP/1.0 client or server connection must be close unless client use "keep-alive" header */ res_close = ! f_client_k_alive; else res_close = 0; /* HTTP/1.1 is "keep-alive" by default */ if ((! ! res_close) != (! ! conn_close)) continue; /* Another mode is in test currently */ mhd_add_close = f_mhd_close; mhd_set_10_cmptbl = f_10_cmptbl; mhd_set_10_server = f_10_server; mhd_set_k_a_send = f_k_a_send; ret <<= 3; /* Remember errors for each step */ ret |= doCurlQueryInThread (d, &qParam, f_client_close, f_client_k_alive); } MHD_stop_daemon (d); return ret; } enum testMhdThreadsType { testMhdThreadExternal = 0, testMhdThreadInternal = MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPerConnection = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPool }; enum testMhdPollType { testMhdPollBySelect = 0, testMhdPollByPoll = MHD_USE_POLL, testMhdPollByEpoll = MHD_USE_EPOLL, testMhdPollAuto = MHD_USE_AUTO }; /* Get number of threads for thread pool depending * on used poll function and test type. */ static unsigned int testNumThreadsForPool (enum testMhdPollType pollType) { unsigned int numThreads = MHD_CPU_COUNT; (void) pollType; /* Don't care about pollType for this test */ return numThreads; /* No practical limit for non-cleanup test */ } static struct MHD_Daemon * startTestMhdDaemon (enum testMhdThreadsType thrType, enum testMhdPollType pollType, uint16_t *pport) { struct MHD_Daemon *d; const union MHD_DaemonInfo *dinfo; if ( (0 == *pport) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { *pport = 4050; if (oneone) *pport += 1; if (! conn_close) *pport += 2; } if (testMhdThreadExternal == thrType) d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType) | MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, *pport, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); else if (testMhdThreadInternalPool != thrType) d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType) | MHD_USE_ERROR_LOG, *pport, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_END); else d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | ((unsigned int) pollType) | MHD_USE_ERROR_LOG, *pport, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, testNumThreadsForPool (pollType), MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_END); if (NULL == d) { fprintf (stderr, "Failed to start MHD daemon, errno=%d.\n", errno); abort (); } if (0 == *pport) { dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { fprintf (stderr, "MHD_get_daemon_info() failed.\n"); abort (); } *pport = dinfo->port; if (0 == global_port) global_port = *pport; /* Reuse the same port for all tests */ } return d; } /* Test runners */ static unsigned int testExternalGet (void) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ d = startTestMhdDaemon (testMhdThreadExternal, testMhdPollBySelect, &d_port); return performTestQueries (d, d_port); } static unsigned int testInternalGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ d = startTestMhdDaemon (testMhdThreadInternal, pollType, &d_port); return performTestQueries (d, d_port); } static unsigned int testMultithreadedGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ d = startTestMhdDaemon (testMhdThreadInternalPerConnection, pollType, &d_port); return performTestQueries (d, d_port); } static unsigned int testMultithreadedPoolGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ d = startTestMhdDaemon (testMhdThreadInternalPool, pollType, &d_port); return performTestQueries (d, d_port); } int main (int argc, char *const *argv) { unsigned int errorCount = 0; unsigned int test_result = 0; int verbose = 0; if ((NULL == argv) || (0 == argv[0])) return 99; oneone = ! has_in_name (argv[0], "10"); conn_close = has_in_name (argv[0], "_close"); if (! conn_close && ! has_in_name (argv[0], "_keep_alive")) return 99; verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); test_global_init (); /* Could be set to non-zero value to enforce using specific port * in the test */ global_port = 0; test_result = testExternalGet (); if (test_result) fprintf (stderr, "FAILED: testExternalGet () - %u.\n", test_result); else if (verbose) printf ("PASSED: testExternalGet ().\n"); errorCount += test_result; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { test_result = testInternalGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedPoolGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedGet (testMhdPollBySelect).\n"); errorCount += test_result; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { test_result = testInternalGet (testMhdPollByPoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByPoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByPoll).\n"); errorCount += test_result; } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { test_result = testInternalGet (testMhdPollByEpoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByEpoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByEpoll).\n"); errorCount += test_result; } } if (0 != errorCount) fprintf (stderr, "Error (code: %u)\n", errorCount); else if (verbose) printf ("All tests passed.\n"); test_global_cleanup (); return (errorCount == 0) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_basicauth.c0000644000175000017500000005642114530120375015650 /* This file is part of libmicrohttpd Copyright (C) 2010 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_basicauth.c * @brief Testcase for libmicrohttpd Basic Authorisation * @author Amr Ali * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #ifndef WINDOWS #include #include #else #include #endif #include "mhd_has_param.h" #include "mhd_has_in_name.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __func__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), \ __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), \ __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func(NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), NULL, __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } /* Not actually used in this test */ static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (8); } #if 0 /* Function unused in this test */ static void _checkCURLE_OK_func (CURLcode code, const char *curlFunc, const char *funcName, int lineNum) { if (CURLE_OK == code) return; fflush (stdout); if ((NULL != curlFunc) && (0 != curlFunc[0])) fprintf (stderr, "'%s' resulted in '%s'", curlFunc, curl_easy_strerror (code)); else fprintf (stderr, "libcurl function call resulted in '%s'", curl_easy_strerror (code)); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (9); } #endif /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 10 #define MHD_URI_BASE_PATH "/bar%20foo%3Fkey%3Dvalue" #define REALM "TestRealm" #define USERNAME "Aladdin" #define PASSWORD "open sesame" #define PAGE \ "libmicrohttpd demo page" \ "Access granted" #define DENIED \ "libmicrohttpd - Access denied" \ "Access denied" struct CBC { char *buf; size_t pos; size_t size; }; static int verbose; static int preauth; static int oldapi; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) mhdErrorExitDesc ("Wrong too large data"); /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; static int already_called_marker; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (&already_called_marker != *req_cls) { /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; } if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) mhdErrorExitDesc ("Unexpected HTTP method"); /* require: USERNAME with password PASSWORD */ if (! oldapi) { struct MHD_BasicAuthInfo *creds; creds = MHD_basic_auth_get_username_password3 (connection); if (NULL != creds) { if (NULL == creds->username) mhdErrorExitDesc ("'username' is NULL"); else if (MHD_STATICSTR_LEN_ (USERNAME) != creds->username_len) { fprintf (stderr, "'username_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) MHD_STATICSTR_LEN_ (USERNAME), (unsigned) creds->username_len); mhdErrorExitDesc ("Wrong 'username_len'"); } else if (0 != memcmp (creds->username, USERNAME, creds->username_len)) { fprintf (stderr, "'username' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", USERNAME, (int) creds->username_len, creds->username); mhdErrorExitDesc ("Wrong 'username'"); } else if (0 != creds->username[creds->username_len]) mhdErrorExitDesc ("'username' is not zero-terminated"); else if (NULL == creds->password) mhdErrorExitDesc ("'password' is NULL"); else if (MHD_STATICSTR_LEN_ (PASSWORD) != creds->password_len) { fprintf (stderr, "'password_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) MHD_STATICSTR_LEN_ (PASSWORD), (unsigned) creds->password_len); mhdErrorExitDesc ("Wrong 'password_len'"); } else if (0 != memcmp (creds->password, PASSWORD, creds->password_len)) { fprintf (stderr, "'password' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", PASSWORD, (int) creds->password_len, creds->password); mhdErrorExitDesc ("Wrong 'username'"); } else if (0 != creds->password[creds->password_len]) mhdErrorExitDesc ("'password' is not zero-terminated"); MHD_free (creds); response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE), (const void *) PAGE); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); if (MHD_YES != ret) mhdErrorExitDesc ("'MHD_queue_response()' failed"); } else { response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (DENIED), (const void *) DENIED); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); ret = MHD_queue_basic_auth_required_response3 (connection, REALM, MHD_YES, response); if (MHD_YES != ret) mhdErrorExitDesc ("'MHD_queue_basic_auth_required_response3()' failed"); } } else { char *username; char *password; password = NULL; username = MHD_basic_auth_get_username_password (connection, &password); if (NULL != username) { if (0 != strcmp (username, USERNAME)) { fprintf (stderr, "'username' does not match.\n" "Expected: '%s'\tRecieved: '%s'. ", USERNAME, username); mhdErrorExitDesc ("Wrong 'username'"); } if (NULL == password) mhdErrorExitDesc ("The password pointer is NULL"); if (0 != strcmp (password, PASSWORD)) fprintf (stderr, "'password' does not match.\n" "Expected: '%s'\tRecieved: '%s'. ", PASSWORD, password); response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE), (const void *) PAGE); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); if (MHD_YES != ret) mhdErrorExitDesc ("'MHD_queue_response()' failed"); } else { if (NULL != password) mhdErrorExitDesc ("The password pointer is NOT NULL"); response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (DENIED), (const void *) DENIED); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); ret = MHD_queue_basic_auth_fail_response (connection, REALM, response); if (MHD_YES != ret) mhdErrorExitDesc ("'MHD_queue_basic_auth_fail_response()' failed"); } if (NULL != username) MHD_free (username); if (NULL != password) MHD_free (password); } MHD_destroy_response (response); return ret; } static CURL * setupCURL (void *cbc, uint16_t port, char *errbuf) { CURL *c; char url[512]; if (1) { int res; /* A workaround for some old libcurl versions, which ignore the specified * port by CURLOPT_PORT when authorisation is used. */ res = snprintf (url, (sizeof(url) / sizeof(url[0])), "http://127.0.0.1:%u%s", (unsigned int) port, MHD_URI_BASE_PATH); if ((0 >= res) || ((sizeof(url) / sizeof(url[0])) <= (size_t) res)) externalErrorExitDesc ("Cannot form request URL"); } c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)) || /* (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) || */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || #if CURL_AT_LEAST_VERSION (7, 85, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http")) || #elif CURL_AT_LEAST_VERSION (7, 19, 4) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) || #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ #if CURL_AT_LEAST_VERSION (7, 45, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) || #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) port))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, url))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); #if CURL_AT_LEAST_VERSION (7,21,3) if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_BASIC | (preauth ? 0 : CURLAUTH_ONLY))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_USERPWD, USERNAME ":" PASSWORD))) libcurlErrorExitDesc ("curl_easy_setopt() authorization options failed"); #else /* libcurl version before 7.21.3 */ if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_BASIC)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_USERPWD, USERNAME ":" PASSWORD))) libcurlErrorExitDesc ("curl_easy_setopt() authorization options failed"); #endif /* libcurl version before 7.21.3 */ return c; } static CURLcode performQueryExternal (struct MHD_Daemon *d, CURL *c) { CURLM *multi; time_t start; struct timeval tv; CURLcode ret; ret = CURLE_FAILED_INIT; /* will be replaced with real result */ multi = NULL; multi = curl_multi_init (); if (multi == NULL) libcurlErrorExitDesc ("curl_multi_init() failed"); if (CURLM_OK != curl_multi_add_handle (multi, c)) libcurlErrorExitDesc ("curl_multi_add_handle() failed"); start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; int running; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL != multi) { curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) libcurlErrorExitDesc ("curl_multi_info_read() failed"); totalMsgs++; if (CURLMSG_DONE == msg->msg) ret = msg->data.result; } while (msgLeft > 0); if (1 != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); externalErrorExit (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); multi = NULL; } else { if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) libcurlErrorExitDesc ("curl_multi_fdset() failed"); } } if (NULL == multi) { /* libcurl has finished, check whether MHD still needs to perform cleanup */ if (0 != MHD_get_timeout64s (d)) break; /* MHD finished as well */ } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); tv.tv_sec = 0; tv.tv_usec = 200000; #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep (200); #endif } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); } return ret; } /** * Check request result * @param curl_code the CURL easy return code * @param pcbc the pointer struct CBC * @return non-zero if success, zero if failed */ static unsigned int check_result (CURLcode curl_code, struct CBC *pcbc) { if (CURLE_OK != curl_code) { fflush (stdout); if (0 != libcurl_errbuf[0]) fprintf (stderr, "First request failed. " "libcurl error: '%s'.\n" "libcurl error description: '%s'.\n", curl_easy_strerror (curl_code), libcurl_errbuf); else fprintf (stderr, "First request failed. " "libcurl error: '%s'.\n", curl_easy_strerror (curl_code)); fflush (stderr); return 0; } if (pcbc->pos != strlen (PAGE)) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) pcbc->pos, (int) pcbc->pos, pcbc->buf, (unsigned) strlen (PAGE)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != memcmp (PAGE, pcbc->buf, pcbc->pos)) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) pcbc->pos, pcbc->buf); mhdErrorExitDesc ("Wrong returned data"); } return 1; } static unsigned int testBasicAuth (void) { struct MHD_Daemon *d; uint16_t port; struct CBC cbc; char buf[2048]; CURL *c; int failed = 0; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 4210; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); port = (uint16_t) dinfo->port; } /* First request */ cbc.buf = buf; cbc.size = sizeof (buf); cbc.pos = 0; memset (cbc.buf, 0, cbc.size); c = setupCURL (&cbc, port, libcurl_errbuf); if (check_result (performQueryExternal (d, c), &cbc)) { if (verbose) printf ("First request successful.\n"); } else { fprintf (stderr, "First request FAILED.\n"); failed = 1; } curl_easy_cleanup (c); /* Second request */ cbc.buf = buf; cbc.size = sizeof (buf); cbc.pos = 0; memset (cbc.buf, 0, cbc.size); c = setupCURL (&cbc, port, libcurl_errbuf); if (check_result (performQueryExternal (d, c), &cbc)) { if (verbose) printf ("Second request successful.\n"); } else { fprintf (stderr, "Second request FAILED.\n"); failed = 1; } curl_easy_cleanup (c); MHD_stop_daemon (d); return failed ? 1 : 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); preauth = has_in_name (argv[0], "_preauth"); #if ! CURL_AT_LEAST_VERSION (7,21,3) if (preauth) { fprintf (stderr, "libcurl version 7.21.3 or later is " "required to run this test.\n"); return 77; } #endif /* libcurl version before 7.21.3 */ #ifdef MHD_HTTPS_REQUIRE_GCRYPT #ifdef HAVE_GCRYPT_H gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ oldapi = has_in_name (argv[0], "_oldapi"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; errorCount += testBasicAuth (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_large_put.c0000644000175000017500000006664514530120375015700 /* This file is part of libmicrohttpd Copyright (C) 2007, 2008 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_large_put.c * @brief Testcase for libmicrohttpd PUT operations * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #ifndef WINDOWS #include #endif #include "mhd_has_in_name.h" #include "mhd_has_param.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func(NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error details: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); fflush (stderr); exit (8); } static int oneone; static int incr_read; /* Use incremental read */ static int verbose; /* Be verbose */ #define PUT_SIZE (256 * 1024) static char *put_buffer; struct CBC { char *buf; size_t pos; size_t size; }; static char * alloc_init (size_t buf_size) { static const char template[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz"; static const size_t templ_size = sizeof(template) / sizeof(char) - 1; char *buf; char *fill_ptr; size_t to_fill; buf = malloc (buf_size); if (NULL == buf) externalErrorExit (); fill_ptr = buf; to_fill = buf_size; while (to_fill > 0) { const size_t to_copy = to_fill > templ_size ? templ_size : to_fill; memcpy (fill_ptr, template, to_copy); fill_ptr += to_copy; to_fill -= to_copy; } return buf; } static size_t putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) { size_t *pos = (size_t *) ptr; size_t wrt; wrt = size * nmemb; /* Check for overflow. */ if (wrt / size != nmemb) libcurlErrorExitDesc ("Too large buffer size"); if (wrt > PUT_SIZE - (*pos)) wrt = PUT_SIZE - (*pos); memcpy (stream, &put_buffer[*pos], wrt); (*pos) += wrt; return wrt; } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) libcurlErrorExitDesc ("Too large buffer size"); memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { int *done = cls; struct MHD_Response *response; enum MHD_Result ret; static size_t processed; if (NULL == cls) mhdErrorExitDesc ("cls parameter is NULL"); if (0 != strcmp (version, oneone ? MHD_HTTP_VERSION_1_1 : MHD_HTTP_VERSION_1_0)) mhdErrorExitDesc ("Unexpected HTTP version"); if (NULL == url) mhdErrorExitDesc ("url parameter is NULL"); if (NULL == upload_data_size) mhdErrorExitDesc ("'upload_data_size' pointer is NULL"); if (0 != strcmp ("PUT", method)) mhdErrorExitDesc ("Unexpected request method"); /* unexpected method */ if ((*done) == 0) { size_t *pproc; if (NULL == *req_cls) { processed = 0; /* Safe as long as only one parallel request served. */ *req_cls = &processed; } pproc = (size_t *) *req_cls; if (0 == *upload_data_size) return MHD_YES; /* No data to process. */ if (*pproc + *upload_data_size > PUT_SIZE) mhdErrorExitDesc ("Incoming data larger than expected"); if ( (! incr_read) && (*upload_data_size != PUT_SIZE) ) return MHD_YES; /* Wait until whole request is received. */ if (0 != memcmp (upload_data, put_buffer + (*pproc), *upload_data_size)) mhdErrorExitDesc ("Incoming data does not match sent data"); *pproc += *upload_data_size; *upload_data_size = 0; /* Current block of data is fully processed. */ if (PUT_SIZE == *pproc) *done = 1; /* Whole request is processed. */ return MHD_YES; } response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); if (NULL == response) mhdErrorExitDesc ("Failed to create response"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int testPutInternalThread (unsigned int add_flag) { struct MHD_Daemon *d; CURL *c; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; char buf[2048]; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1270; if (oneone) port += 10; if (incr_read) port += 20; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | add_flag, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (incr_read ? 1024 : (PUT_SIZE * 4 / 3)), MHD_OPTION_END); if (d == NULL) mhdErrorExit (); if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExit (); port = dinfo->port; } c = curl_easy_init (); if (NULL == c) { fprintf (stderr, "curl_easy_init() failed.\n"); externalErrorExit (); } if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world")) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, (long) port)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_READDATA, &pos)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_UPLOAD, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, (long) 150)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, (long) 150)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0))) { fprintf (stderr, "curl_easy_setopt() failed.\n"); externalErrorExit (); } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) cbc.pos, (int) cbc.pos, cbc.buf, (unsigned) strlen ("/hello_world")); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) cbc.pos, cbc.buf); mhdErrorExitDesc ("Wrong returned data length"); } return 0; } static unsigned int testPutThreadPerConn (unsigned int add_flag) { struct MHD_Daemon *d; CURL *c; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; char buf[2048]; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1271; if (oneone) port += 10; if (incr_read) port += 20; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | add_flag, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (incr_read ? 1024 : (PUT_SIZE * 4)), MHD_OPTION_END); if (d == NULL) mhdErrorExit (); if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExit (); port = dinfo->port; } c = curl_easy_init (); if (NULL == c) { fprintf (stderr, "curl_easy_init() failed.\n"); externalErrorExit (); } if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world")) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, (long) port)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_READDATA, &pos)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_UPLOAD, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, (long) 150)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, (long) 150)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0))) { fprintf (stderr, "curl_easy_setopt() failed.\n"); externalErrorExit (); } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) cbc.pos, (int) cbc.pos, cbc.buf, (unsigned) strlen ("/hello_world")); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) cbc.pos, cbc.buf); mhdErrorExitDesc ("Wrong returned data length"); } return 0; } static unsigned int testPutThreadPool (unsigned int add_flag) { struct MHD_Daemon *d; CURL *c; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; char buf[2048]; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1272; if (oneone) port += 10; if (incr_read) port += 20; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | add_flag, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (incr_read ? 1024 : (PUT_SIZE * 4)), MHD_OPTION_END); if (d == NULL) mhdErrorExit (); if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExit (); port = dinfo->port; } c = curl_easy_init (); if (NULL == c) { fprintf (stderr, "curl_easy_init() failed.\n"); externalErrorExit (); } if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world")) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, (long) port)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_READDATA, &pos)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_UPLOAD, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, (long) 150)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, (long) 150)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0))) { fprintf (stderr, "curl_easy_setopt() failed.\n"); externalErrorExit (); } if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) cbc.pos, (int) cbc.pos, cbc.buf, (unsigned) strlen ("/hello_world")); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) cbc.pos, cbc.buf); mhdErrorExitDesc ("Wrong returned data length"); } return 0; } static unsigned int testPutExternal (void) { struct MHD_Daemon *d; CURL *c; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; int running; struct CURLMsg *msg; time_t start; struct timeval tv; size_t pos = 0; int done_flag = 0; char buf[2048]; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1273; if (oneone) port += 10; if (incr_read) port += 20; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; multi = NULL; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (incr_read ? 1024 : (PUT_SIZE * 4)), MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) mhdErrorExit (); if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExit (); port = dinfo->port; } c = curl_easy_init (); if (NULL == c) { fprintf (stderr, "curl_easy_init() failed.\n"); externalErrorExit (); } if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world")) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, (long) port)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_READDATA, &pos)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_UPLOAD, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, (long) 150)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, (long) 150)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0))) { fprintf (stderr, "curl_easy_setopt() failed.\n"); externalErrorExit (); } multi = curl_multi_init (); if (multi == NULL) libcurlErrorExit (); mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) libcurlErrorExit (); start = time (NULL); while ((time (NULL) - start < 45) && (multi != NULL)) { MHD_socket maxMHDsock; int maxcurlsock; maxMHDsock = MHD_INVALID_SOCKET; maxcurlsock = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); mret = curl_multi_perform (multi, &running); if ((CURLM_OK != mret) && (CURLM_CALL_MULTI_PERFORM != mret)) { fprintf (stderr, "curl_multi_perform() failed. Error: '%s'. ", curl_multi_strerror (mret)); libcurlErrorExit (); } if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxcurlsock)) libcurlErrorExitDesc ("curl_multi_fdset() failed"); if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMHDsock)) mhdErrorExit (); tv.tv_sec = 0; tv.tv_usec = 1000; #ifndef MHD_WINSOCK_SOCKETS if (maxMHDsock > maxcurlsock) maxcurlsock = maxMHDsock; #endif /* MHD_WINSOCK_SOCKETS */ if (-1 == select (maxcurlsock + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep ((DWORD) (tv.tv_sec * 1000 + tv.tv_usec / 1000)); #endif } mret = curl_multi_perform (multi, &running); if ((CURLM_OK != mret) && (CURLM_CALL_MULTI_PERFORM != mret)) { fprintf (stderr, "curl_multi_perform() failed. Error: '%s'. ", curl_multi_strerror (mret)); libcurlErrorExit (); } if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "curl_multi_perform() failed: '%s' ", curl_easy_strerror (msg->data.result)); libcurlErrorExit (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code "); mhdErrorExit (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) mhdErrorExitDesc ("Request has been aborted by timeout"); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) cbc.pos, (int) cbc.pos, cbc.buf, (unsigned) strlen ("/hello_world")); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) cbc.pos, cbc.buf); mhdErrorExitDesc ("Wrong returned data length"); } return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; unsigned int lastErr; oneone = has_in_name (argv[0], "11"); incr_read = has_in_name (argv[0], "_inc"); verbose = has_param (argc, argv, "-v"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 99; put_buffer = alloc_init (PUT_SIZE); if (NULL == put_buffer) return 99; lastErr = testPutExternal (); if (verbose && (0 != lastErr)) fprintf (stderr, "Error during testing with external select().\n"); errorCount += lastErr; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { lastErr = testPutInternalThread (0); if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with internal thread with select().\n"); errorCount += lastErr; lastErr = testPutThreadPerConn (0); if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with internal thread per connection with select().\n"); errorCount += lastErr; lastErr = testPutThreadPool (0); if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with thread pool per connection with select().\n"); errorCount += lastErr; if (MHD_is_feature_supported (MHD_FEATURE_POLL)) { lastErr = testPutInternalThread (MHD_USE_POLL); if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with internal thread with poll().\n"); errorCount += lastErr; lastErr = testPutThreadPerConn (MHD_USE_POLL); if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with internal thread per connection with poll().\n"); errorCount += lastErr; lastErr = testPutThreadPool (MHD_USE_POLL); if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with thread pool per connection with poll().\n"); errorCount += lastErr; } if (MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { lastErr = testPutInternalThread (MHD_USE_EPOLL); if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with internal thread with epoll.\n"); errorCount += lastErr; lastErr = testPutThreadPool (MHD_USE_EPOLL); if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with thread pool per connection with epoll.\n"); errorCount += lastErr; } } free (put_buffer); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); else if (verbose) printf ("All checks passed successfully.\n"); curl_global_cleanup (); return (errorCount == 0) ? 0 : 1; } libmicrohttpd-1.0.1/src/testcurl/test_digestauth_with_arguments.c0000644000175000017500000002252214555767064021204 /* This file is part of libmicrohttpd Copyright (C) 2010, 2012 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file daemontest_digestauth_with_arguments.c * @brief Testcase for libmicrohttpd Digest Auth with arguments * @author Amr Ali * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #if defined(MHD_HTTPS_REQUIRE_GCRYPT) && \ (defined(MHD_SHA256_TLSLIB) || defined(MHD_MD5_TLSLIB)) #define NEED_GCRYP_INIT 1 #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT && (MHD_SHA256_TLSLIB || MHD_MD5_TLSLIB) */ #ifndef WINDOWS #include #include #else #include #endif #define PAGE \ "libmicrohttpd demoAccess granted" #define DENIED \ "libmicrohttpd demoAccess denied" #define MY_OPAQUE "11733b200778ce33060f31c9af70a870ba96ddd4" struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; char *username; const char *password = "testpass"; const char *realm = "test@example.com"; enum MHD_Result ret; int ret_i; static int already_called_marker; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ if (&already_called_marker != *req_cls) { /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; } username = MHD_digest_auth_get_username (connection); if ( (username == NULL) || (0 != strcmp (username, "testuser")) ) { response = MHD_create_response_from_buffer_static (strlen (DENIED), DENIED); ret = MHD_queue_auth_fail_response2 (connection, realm, MY_OPAQUE, response, MHD_NO, MHD_DIGEST_ALG_MD5); MHD_destroy_response (response); return ret; } ret_i = MHD_digest_auth_check2 (connection, realm, username, password, 300, MHD_DIGEST_ALG_MD5); MHD_free (username); if (ret_i != MHD_YES) { response = MHD_create_response_from_buffer_static (strlen (DENIED), DENIED); if (NULL == response) fprintf (stderr, "MHD_create_response_from_buffer() failed.\n"); ret = MHD_queue_auth_fail_response2 (connection, realm, MY_OPAQUE, response, (MHD_INVALID_NONCE == ret_i) ? MHD_YES : MHD_NO, MHD_DIGEST_ALG_MD5); if (MHD_YES != ret) fprintf (stderr, "MHD_queue_auth_fail_response2() failed.\n"); MHD_destroy_response (response); return ret; } response = MHD_create_response_from_buffer_static (strlen (PAGE), PAGE); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int testDigestAuth (void) { CURL *c; CURLcode errornum; struct MHD_Daemon *d; struct CBC cbc; char buf[2048]; char rnd[8]; uint16_t port; char url[128]; #ifndef WINDOWS int fd; size_t len; size_t off = 0; #endif /* ! WINDOWS */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1160; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; #ifndef WINDOWS fd = open ("/dev/urandom", O_RDONLY); if (-1 == fd) { fprintf (stderr, "Failed to open `%s': %s\n", "/dev/urandom", strerror (errno)); return 1; } while (off < 8) { len = (size_t) read (fd, rnd + off, 8 - off); if (len == (size_t) -1) { fprintf (stderr, "Failed to read `%s': %s\n", "/dev/urandom", strerror (errno)); (void) close (fd); return 1; } off += len; } (void) close (fd); #else { HCRYPTPROV cc; BOOL b; b = CryptAcquireContext (&cc, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); if (b == 0) { fprintf (stderr, "Failed to acquire crypto provider context: %lu\n", GetLastError ()); return 1; } b = CryptGenRandom (cc, 8, (BYTE *) rnd); if (b == 0) { fprintf (stderr, "Failed to generate 8 random bytes: %lu\n", GetLastError ()); } CryptReleaseContext (cc, 0); if (b == 0) return 1; } #endif d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, MHD_OPTION_NONCE_NC_SIZE, 300, MHD_OPTION_DIGEST_AUTH_DEFAULT_MAX_NC, (uint32_t) 999, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (url, sizeof (url), "http://127.0.0.1:%u/bar%%20foo?" "key=value&more=even%%20more&empty&=no_key&&same=one&&same=two", (unsigned int) port); c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); curl_easy_setopt (c, CURLOPT_USERPWD, "testuser:testpass"); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen (PAGE)) return 4; if (0 != strncmp (PAGE, cbc.buf, strlen (PAGE))) return 8; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ #if (LIBCURL_VERSION_MAJOR == 7) && (LIBCURL_VERSION_MINOR == 62) if (1) { fprintf (stderr, "libcurl version 7.62.x has bug in processing" "URI with GET arguments for Digest Auth.\n"); fprintf (stderr, "This test cannot be performed.\n"); exit (77); } #endif /* libcurl version 7.62.x */ #ifdef MHD_HTTPS_REQUIRE_GCRYPT #ifdef HAVE_GCRYPT_H gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; errorCount += testDigestAuth (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/perf_get_concurrent.c0000644000175000017500000003533114556022036016703 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009, 2011 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file perf_get_concurrent.c * @brief benchmark concurrent GET operations * Note that we run libcurl on the machine at the * same time, so the execution time may be influenced * by the concurrent activity; it is quite possible * that more time is spend with libcurl than with MHD, * so the performance scores calculated with this code * should NOT be used to compare with other HTTP servers * (since MHD is actually better); only the relative * scores between MHD versions are meaningful. * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include #include "mhd_has_in_name.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif /** * How many rounds of operations do we do for each * test (total number of requests will be ROUNDS * PAR). * Ensure that free ports are not exhausted during test. */ #if MHD_CPU_COUNT > 8 #ifndef _WIN32 #define ROUNDS (1 + (30000 / 12) / MHD_CPU_COUNT) #else /* _WIN32 */ #define ROUNDS (1 + (3000 / 12) / MHD_CPU_COUNT) #endif /* _WIN32 */ #else #define ROUNDS 500 #endif /** * How many requests do we do in parallel? */ #define PAR MHD_CPU_COUNT /** * Do we use HTTP 1.1? */ static int oneone; /** * Response to return (re-used). */ static struct MHD_Response *response; /** * Time this round was started. */ static unsigned long long start_time; /** * Set to 1 if the worker threads are done. */ static volatile int signal_done; /** * Get the current timestamp * * @return current time in ms */ static unsigned long long now (void) { struct timeval tv; gettimeofday (&tv, NULL); return (((unsigned long long) tv.tv_sec * 1000LL) + ((unsigned long long) tv.tv_usec / 1000LL)); } /** * Start the timer. */ static void start_timer (void) { start_time = now (); } /** * Stop the timer and report performance * * @param desc description of the threading mode we used */ static void stop (const char *desc) { double rps = ((double) (PAR * ROUNDS * 1000)) / ((double) (now () - start_time)); fprintf (stderr, "Parallel GETs using %s: %f %s\n", desc, rps, "requests/s"); } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { (void) ptr; (void) ctx; /* Unused. Silent compiler warning. */ return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; enum MHD_Result ret; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; ret = MHD_queue_response (connection, MHD_HTTP_OK, response); if (ret == MHD_NO) abort (); return ret; } static void * thread_gets (void *param) { CURL *c; CURLcode errornum; unsigned int i; char *const url = (char *) param; static char curl_err_marker[] = "curl error"; c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, NULL); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); for (i = 0; i < ROUNDS; i++) { if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); return curl_err_marker; } } curl_easy_cleanup (c); return NULL; } static void * do_gets (void *param) { int j; pthread_t par[PAR]; char url[64]; uint16_t port = (uint16_t) (intptr_t) param; char *err = NULL; static char pthr_err_marker[] = "pthread_create error"; snprintf (url, sizeof (url), "http://127.0.0.1:%u/hello_world", (unsigned int) port); for (j = 0; j < PAR; j++) { if (0 != pthread_create (&par[j], NULL, &thread_gets, (void *) url)) { for (j--; j >= 0; j--) pthread_join (par[j], NULL); return pthr_err_marker; } } for (j = 0; j < PAR; j++) { char *ret_val; if ((0 != pthread_join (par[j], (void **) &ret_val)) || (NULL != ret_val) ) err = ret_val; } signal_done = 1; return err; } static unsigned int testInternalGet (uint16_t port, uint32_t poll_flag) { struct MHD_Daemon *d; const char *const test_desc = ((poll_flag & MHD_USE_AUTO) ? "internal thread with 'auto'" : (poll_flag & MHD_USE_POLL) ? "internal thread with poll()" : (poll_flag & MHD_USE_EPOLL) ? "internal thread with epoll" : "internal thread with select()"); const char *ret_val; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; signal_done = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } start_timer (); ret_val = do_gets ((void *) (intptr_t) port); if (! ret_val) stop (test_desc); MHD_stop_daemon (d); if (ret_val) { fprintf (stderr, "Error performing %s test: %s\n", test_desc, ret_val); return 4; } return 0; } static unsigned int testMultithreadedGet (uint16_t port, uint32_t poll_flag) { struct MHD_Daemon *d; const char *const test_desc = ((poll_flag & MHD_USE_AUTO) ? "internal thread with 'auto' and thread per connection" : (poll_flag & MHD_USE_POLL) ? "internal thread with poll() and thread per connection" : (poll_flag & MHD_USE_EPOLL) ? "internal thread with epoll and thread per connection" : "internal thread with select() and thread per connection"); const char *ret_val; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; signal_done = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } start_timer (); ret_val = do_gets ((void *) (intptr_t) port); if (! ret_val) stop (test_desc); MHD_stop_daemon (d); if (ret_val) { fprintf (stderr, "Error performing %s test: %s\n", test_desc, ret_val); return 4; } return 0; } static unsigned int testMultithreadedPoolGet (uint16_t port, uint32_t poll_flag) { struct MHD_Daemon *d; const char *const test_desc = ((poll_flag & MHD_USE_AUTO) ? "internal thread pool with 'auto'" : (poll_flag & MHD_USE_POLL) ? "internal thread pool with poll()" : (poll_flag & MHD_USE_EPOLL) ? "internal thread poll with epoll" : "internal thread pool with select()"); const char *ret_val; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; signal_done = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } start_timer (); ret_val = do_gets ((void *) (intptr_t) port); if (! ret_val) stop (test_desc); MHD_stop_daemon (d); if (ret_val) { fprintf (stderr, "Error performing %s test: %s\n", test_desc, ret_val); return 4; } return 0; } static unsigned int testExternalGet (uint16_t port) { struct MHD_Daemon *d; pthread_t tid; fd_set rs; fd_set ws; fd_set es; MHD_socket max; struct timeval tv; uint64_t tt64; char *ret_val; int ret = 0; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; signal_done = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } if (0 != pthread_create (&tid, NULL, &do_gets, (void *) (intptr_t) port)) { MHD_stop_daemon (d); return 512; } start_timer (); while (0 == signal_done) { max = 0; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) { MHD_stop_daemon (d); return 4096; } if (MHD_NO == MHD_get_timeout64 (d, &tt64)) tt64 = 1; #if ! defined(_WIN32) || defined(__CYGWIN__) tv.tv_sec = (time_t) (tt64 / 1000); #else /* Native W32 */ tv.tv_sec = (long) (tt64 / 1000); #endif /* Native W32 */ tv.tv_usec = ((long) (tt64 % 1000)) * 1000; if (-1 == select (max + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } ret |= 1024; break; #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } MHD_run_from_select (d, &rs, &ws, &es); } stop ("external select"); MHD_stop_daemon (d); if ((0 != pthread_join (tid, (void **) &ret_val)) || (NULL != ret_val) ) { fprintf (stderr, "%s\n", ret_val); ret |= 8; } if (ret) fprintf (stderr, "Error performing test.\n"); return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; uint16_t port = 1100; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (oneone) port += 15; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; response = MHD_create_response_from_buffer_copy (strlen ("/hello_world"), "/hello_world"); errorCount += testInternalGet (port++, 0); errorCount += testMultithreadedGet (port++, 0); errorCount += testMultithreadedPoolGet (port++, 0); errorCount += testExternalGet (port++); errorCount += testInternalGet (port++, MHD_USE_AUTO); errorCount += testMultithreadedGet (port++, MHD_USE_AUTO); errorCount += testMultithreadedPoolGet (port++, MHD_USE_AUTO); if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { errorCount += testInternalGet (port++, MHD_USE_POLL); errorCount += testMultithreadedGet (port++, MHD_USE_POLL); errorCount += testMultithreadedPoolGet (port++, MHD_USE_POLL); } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { errorCount += testInternalGet (port++, MHD_USE_EPOLL); errorCount += testMultithreadedPoolGet (port++, MHD_USE_EPOLL); } MHD_destroy_response (response); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return errorCount != 0; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_get.c0000644000175000017500000007333314530120375014465 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009, 2011 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_get.c * @brief Testcase for libmicrohttpd GET operations * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #include "mhd_has_param.h" #include "mhd_sockets.h" /* only macros used */ #define EXPECTED_URI_PATH "/hello_world?a=%26&b=c" #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #ifndef WINDOWS #include #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif static int oneone; static uint16_t global_port; struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static void * log_cb (void *cls, const char *uri, struct MHD_Connection *con) { (void) cls; (void) con; if (0 != strcmp (uri, EXPECTED_URI_PATH)) { fprintf (stderr, "Wrong URI: `%s'\n", uri); _exit (22); } return NULL; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; const char *v; (void) cls; (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silence compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; v = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "a"); if ( (NULL == v) || (0 != strcmp ("&", v)) ) { fprintf (stderr, "Found while looking for 'a=&': 'a=%s'\n", NULL == v ? "NULL" : v); _exit (17); } v = NULL; if (MHD_YES != MHD_lookup_connection_value_n (connection, MHD_GET_ARGUMENT_KIND, "b", 1, &v, NULL)) { fprintf (stderr, "Not found 'b' GET argument.\n"); _exit (18); } if ( (NULL == v) || (0 != strcmp ("c", v)) ) { fprintf (stderr, "Found while looking for 'b=c': 'b=%s'\n", NULL == v ? "NULL" : v); _exit (19); } response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) { fprintf (stderr, "Failed to queue response.\n"); _exit (19); } return ret; } static unsigned int testInternalGet (uint32_t poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; if ( (0 == global_port) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { global_port = 1220; if (oneone) global_port += 20; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, global_port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == global_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } global_port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH); curl_easy_setopt (c, CURLOPT_PORT, (long) global_port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; return 0; } static unsigned int testMultithreadedGet (uint32_t poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; if ( (0 == global_port) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { global_port = 1221; if (oneone) global_port += 20; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, global_port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == global_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } global_port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH); curl_easy_setopt (c, CURLOPT_PORT, (long) global_port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testMultithreadedPoolGet (uint32_t poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; if ( (0 == global_port) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { global_port = 1222; if (oneone) global_port += 20; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, global_port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == global_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } global_port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH); curl_easy_setopt (c, CURLOPT_PORT, (long) global_port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testExternalGet (int thread_unsafe) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; int maxposixs; int running; struct CURLMsg *msg; time_t start; struct timeval tv; if ( (0 == global_port) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { global_port = 1223; if (oneone) global_port += 20; } multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | (thread_unsafe ? MHD_USE_NO_THREAD_SAFETY : 0), global_port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == global_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } global_port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH); curl_easy_setopt (c, CURLOPT_PORT, (long) global_port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; #ifdef MHD_POSIX_SOCKETS if (maxsock > maxposixs) maxposixs = maxsock; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 8192; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 16384; return 0; } static unsigned int testUnknownPortGet (uint32_t poll_flag) { struct MHD_Daemon *d; const union MHD_DaemonInfo *di; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; struct sockaddr_in addr; socklen_t addr_len = sizeof(addr); memset (&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = 0; addr.sin_addr.s_addr = INADDR_ANY; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR, &addr, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_END); if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) { di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD); if (di == NULL) return 65536; if (0 != getsockname (di->listen_fd, (struct sockaddr *) &addr, &addr_len)) return 131072; if (addr.sin_family != AF_INET) return 26214; port = ntohs (addr.sin_port); } else { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (buf, sizeof(buf), "http://127.0.0.1:%u%s", (unsigned int) port, EXPECTED_URI_PATH); c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, buf); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 524288; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 1048576; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 2097152; return 0; } static unsigned int testStopRace (uint32_t poll_flag) { struct sockaddr_in sin; MHD_socket fd; struct MHD_Daemon *d; if ( (0 == global_port) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { global_port = 1224; if (oneone) global_port += 20; } d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, global_port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == global_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } global_port = dinfo->port; } fd = socket (PF_INET, SOCK_STREAM, 0); if (fd == MHD_INVALID_SOCKET) { fprintf (stderr, "socket error\n"); return 256; } memset (&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons (global_port); sin.sin_addr.s_addr = htonl (0x7f000001); if (connect (fd, (struct sockaddr *) (&sin), sizeof(sin)) < 0) { fprintf (stderr, "connect error\n"); MHD_socket_close_chk_ (fd); return 512; } /* printf("Waiting\n"); */ /* Let the thread get going. */ usleep (500000); /* printf("Stopping daemon\n"); */ MHD_stop_daemon (d); MHD_socket_close_chk_ (fd); /* printf("good\n"); */ return 0; } static enum MHD_Result ahc_empty (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) url; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp ("GET", method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; response = MHD_create_response_empty (MHD_RF_NONE); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) { fprintf (stderr, "Failed to queue response.\n"); _exit (20); } return ret; } static int curlExcessFound (CURL *c, curl_infotype type, char *data, size_t size, void *cls) { static const char *excess_found = "Excess found"; const size_t str_size = strlen (excess_found); (void) c; /* Unused. Silent compiler warning. */ if ((CURLINFO_TEXT == type) && (size >= str_size) && (0 == strncmp (excess_found, data, str_size))) *(int *) cls = 1; return 0; } static unsigned int testEmptyGet (uint32_t poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; int excess_found = 0; if ( (0 == global_port) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { global_port = 1225; if (oneone) global_port += 20; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, global_port, NULL, NULL, &ahc_empty, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_END); if (d == NULL) return 4194304; if (0 == global_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } global_port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1" EXPECTED_URI_PATH); curl_easy_setopt (c, CURLOPT_PORT, (long) global_port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &curlExcessFound); curl_easy_setopt (c, CURLOPT_DEBUGDATA, &excess_found); curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 8388608; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != 0) return 16777216; if (excess_found) return 33554432; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; unsigned int test_result = 0; int verbose = 0; if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); verbose = has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; global_port = 0; test_result = testExternalGet (! 0); if (test_result) fprintf (stderr, "FAILED: testExternalGet (!0) - %u.\n", test_result); else if (verbose) printf ("PASSED: testExternalGet ().\n"); errorCount += test_result; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { test_result += testExternalGet (0); if (test_result) fprintf (stderr, "FAILED: testExternalGet (0) - %u.\n", test_result); else if (verbose) printf ("PASSED: testExternalGet ().\n"); errorCount += test_result; test_result += testInternalGet (0); if (test_result) fprintf (stderr, "FAILED: testInternalGet (0) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (0).\n"); errorCount += test_result; test_result += testMultithreadedGet (0); if (test_result) fprintf (stderr, "FAILED: testMultithreadedGet (0) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedGet (0).\n"); errorCount += test_result; test_result += testMultithreadedPoolGet (0); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (0) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (0).\n"); errorCount += test_result; test_result += testUnknownPortGet (0); if (test_result) fprintf (stderr, "FAILED: testUnknownPortGet (0) - %u.\n", test_result); else if (verbose) printf ("PASSED: testUnknownPortGet (0).\n"); errorCount += test_result; test_result += testStopRace (0); if (test_result) fprintf (stderr, "FAILED: testStopRace (0) - %u.\n", test_result); else if (verbose) printf ("PASSED: testStopRace (0).\n"); errorCount += test_result; test_result += testEmptyGet (0); if (test_result) fprintf (stderr, "FAILED: testEmptyGet (0) - %u.\n", test_result); else if (verbose) printf ("PASSED: testEmptyGet (0).\n"); errorCount += test_result; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { test_result += testInternalGet (MHD_USE_POLL); if (test_result) fprintf (stderr, "FAILED: testInternalGet (MHD_USE_POLL) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (MHD_USE_POLL).\n"); errorCount += test_result; test_result += testMultithreadedGet (MHD_USE_POLL); if (test_result) fprintf (stderr, "FAILED: testMultithreadedGet (MHD_USE_POLL) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedGet (MHD_USE_POLL).\n"); errorCount += test_result; test_result += testMultithreadedPoolGet (MHD_USE_POLL); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (MHD_USE_POLL) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (MHD_USE_POLL).\n"); errorCount += test_result; test_result += testUnknownPortGet (MHD_USE_POLL); if (test_result) fprintf (stderr, "FAILED: testUnknownPortGet (MHD_USE_POLL) - %u.\n", test_result); else if (verbose) printf ("PASSED: testUnknownPortGet (MHD_USE_POLL).\n"); errorCount += test_result; test_result += testStopRace (MHD_USE_POLL); if (test_result) fprintf (stderr, "FAILED: testStopRace (MHD_USE_POLL) - %u.\n", test_result); else if (verbose) printf ("PASSED: testStopRace (MHD_USE_POLL).\n"); errorCount += test_result; test_result += testEmptyGet (MHD_USE_POLL); if (test_result) fprintf (stderr, "FAILED: testEmptyGet (MHD_USE_POLL) - %u.\n", test_result); else if (verbose) printf ("PASSED: testEmptyGet (MHD_USE_POLL).\n"); errorCount += test_result; } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { test_result += testInternalGet (MHD_USE_EPOLL); if (test_result) fprintf (stderr, "FAILED: testInternalGet (MHD_USE_EPOLL) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (MHD_USE_EPOLL).\n"); errorCount += test_result; test_result += testMultithreadedPoolGet (MHD_USE_EPOLL); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (MHD_USE_EPOLL) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (MHD_USE_EPOLL).\n"); errorCount += test_result; test_result += testUnknownPortGet (MHD_USE_EPOLL); if (test_result) fprintf (stderr, "FAILED: testUnknownPortGet (MHD_USE_EPOLL) - %u.\n", test_result); else if (verbose) printf ("PASSED: testUnknownPortGet (MHD_USE_EPOLL).\n"); errorCount += test_result; test_result += testEmptyGet (MHD_USE_EPOLL); if (test_result) fprintf (stderr, "FAILED: testEmptyGet (MHD_USE_EPOLL) - %u.\n", test_result); else if (verbose) printf ("PASSED: testEmptyGet (MHD_USE_EPOLL).\n"); errorCount += test_result; } } if (0 != errorCount) fprintf (stderr, "Error (code: %u)\n", errorCount); else if (verbose) printf ("All tests passed.\n"); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_put_broken_len.c0000644000175000017500000005100514530120375016704 /* This file is part of GNU libmicrohttpd Copyright (C) 2010 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file testcurl/test_head.c * @brief Testcase for PUT requests with broken Content-Length header * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #ifndef _WIN32 #include #include #else #include #endif #include "mhd_has_param.h" #include "mhd_has_in_name.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __func__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func (NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func (NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func (NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func (errDesc, NULL, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), NULL, \ __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (8); } /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 500000 #define EXPECTED_URI_BASE_PATH "/" #define EXISTING_URI EXPECTED_URI_BASE_PATH #define EXPECTED_URI_BASE_PATH_MISSING "/wrong_uri" #define URL_SCHEME "http:/" "/" #define URL_HOST "127.0.0.1" #define URL_SCHEME_HOST URL_SCHEME URL_HOST #define PAGE \ "libmicrohttpd demo page" \ "Success!" #define PAGE_404 \ "404 error" \ "Error 404: The requested URI does not exist" /* Global parameters */ static int verbose; static int oneone; /**< If false use HTTP/1.0 for requests*/ static struct curl_slist *hdr_broken_cnt_len = NULL; static void test_global_init (void) { libcurl_errbuf[0] = 0; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) externalErrorExit (); hdr_broken_cnt_len = curl_slist_append (hdr_broken_cnt_len, MHD_HTTP_HEADER_CONTENT_LENGTH ": 123bad"); } static void test_global_cleanup (void) { curl_slist_free_all (hdr_broken_cnt_len); curl_global_cleanup (); } struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { (void) ptr; /* Unused, mute compiler warning */ (void) ctx; /* Unused, mute compiler warning */ /* Discard data */ return size * nmemb; } struct ahc_cls_type { const char *rq_method; const char *rq_url; }; static enum MHD_Result ahcCheck (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker; struct MHD_Response *response; enum MHD_Result ret; struct ahc_cls_type *const param = (struct ahc_cls_type *) cls; unsigned int http_code; if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); if (oneone) { if (0 != strcmp (version, MHD_HTTP_VERSION_1_1)) mhdErrorExitDesc ("Unexpected HTTP version"); } else { if (0 != strcmp (version, MHD_HTTP_VERSION_1_0)) mhdErrorExitDesc ("Unexpected HTTP version"); } if (0 != strcmp (url, param->rq_url)) mhdErrorExitDesc ("Unexpected URI"); if (NULL != upload_data) mhdErrorExitDesc ("'upload_data' is not NULL"); if (NULL == upload_data_size) mhdErrorExitDesc ("'upload_data_size' pointer is NULL"); if (0 != *upload_data_size) mhdErrorExitDesc ("'*upload_data_size' value is not zero"); if (0 != strcmp (param->rq_method, method)) mhdErrorExitDesc ("Unexpected request method"); if (&marker != *req_cls) { *req_cls = ▮ return MHD_YES; } *req_cls = NULL; if (0 == strcmp (url, EXISTING_URI)) { response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE), PAGE); http_code = MHD_HTTP_OK; } else { response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE_404), PAGE_404); http_code = MHD_HTTP_NOT_FOUND; } if (NULL == response) mhdErrorExitDesc ("Failed to create response"); ret = MHD_queue_response (connection, http_code, response); MHD_destroy_response (response); if (MHD_YES != ret) mhdErrorExitDesc ("Failed to queue response"); return ret; } static int libcurl_debug_cb (CURL *handle, curl_infotype type, char *data, size_t size, void *userptr) { static const char excess_mark[] = "Excess found"; static const size_t excess_mark_len = MHD_STATICSTR_LEN_ (excess_mark); (void) handle; (void) userptr; #ifdef _DEBUG switch (type) { case CURLINFO_TEXT: fprintf (stderr, "* %.*s", (int) size, data); break; case CURLINFO_HEADER_IN: fprintf (stderr, "< %.*s", (int) size, data); break; case CURLINFO_HEADER_OUT: fprintf (stderr, "> %.*s", (int) size, data); break; case CURLINFO_DATA_IN: #if 0 fprintf (stderr, "<| %.*s\n", (int) size, data); #endif break; case CURLINFO_DATA_OUT: case CURLINFO_SSL_DATA_IN: case CURLINFO_SSL_DATA_OUT: case CURLINFO_END: default: break; } #endif /* _DEBUG */ if (CURLINFO_TEXT == type) { if ((size >= excess_mark_len) && (0 == memcmp (data, excess_mark, excess_mark_len))) mhdErrorExitDesc ("Extra data has been detected in MHD reply"); } return 0; } static CURL * setupCURL (void *cbc, uint16_t port) { CURL *c; c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 0L)) || #ifdef _DEBUG (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) || #endif /* _DEBUG */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &libcurl_debug_cb)) || #if CURL_AT_LEAST_VERSION (7, 85, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http")) || #elif CURL_AT_LEAST_VERSION (7, 19, 4) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) || #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ #if CURL_AT_LEAST_VERSION (7, 45, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) || #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) port)))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); if (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, URL_SCHEME_HOST EXPECTED_URI_BASE_PATH)) libcurlErrorExitDesc ("Cannot set request URI"); /* Set as a "custom" request, because no actual upload data is provided. */ if (CURLE_OK != curl_easy_setopt (c, CURLOPT_CUSTOMREQUEST, MHD_HTTP_METHOD_PUT)) libcurlErrorExitDesc ("curl_easy_setopt() failed"); if (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPHEADER, hdr_broken_cnt_len)) libcurlErrorExitDesc ("Cannot set '" MHD_HTTP_HEADER_CONTENT_LENGTH "'.\n"); return c; } static CURLcode performQueryExternal (struct MHD_Daemon *d, CURL *c, CURLM **multi_reuse) { CURLM *multi; time_t start; struct timeval tv; CURLcode ret; ret = CURLE_FAILED_INIT; /* will be replaced with real result */ if (NULL != *multi_reuse) multi = *multi_reuse; else { multi = curl_multi_init (); if (multi == NULL) libcurlErrorExitDesc ("curl_multi_init() failed"); *multi_reuse = multi; } if (CURLM_OK != curl_multi_add_handle (multi, c)) libcurlErrorExitDesc ("curl_multi_add_handle() failed"); start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; int running; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL != multi) { curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) libcurlErrorExitDesc ("curl_multi_info_read() failed"); totalMsgs++; if (CURLMSG_DONE == msg->msg) ret = msg->data.result; } while (msgLeft > 0); if (1 != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); externalErrorExit (); } curl_multi_remove_handle (multi, c); multi = NULL; } else { if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) libcurlErrorExitDesc ("curl_multi_fdset() failed"); } } if (NULL == multi) { /* libcurl has finished, check whether MHD still needs to perform cleanup */ if (0 != MHD_get_timeout64s (d)) break; /* MHD finished as well */ } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); tv.tv_sec = 0; tv.tv_usec = 200000; if (0 == MHD_get_timeout64s (d)) tv.tv_usec = 0; else { long curl_to = -1; curl_multi_timeout (multi, &curl_to); if (0 == curl_to) tv.tv_usec = 0; } #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep ((unsigned long) tv.tv_usec / 1000); #endif } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); } return ret; } /** * Check request result * @param curl_code the CURL easy return code * @param pcbc the pointer struct CBC * @return non-zero if success, zero if failed */ static unsigned int check_result (CURLcode curl_code, CURL *c, long expected_code) { long code; if (CURLE_OK != curl_code) { fflush (stdout); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n" "libcurl error description: '%s'.\n", curl_easy_strerror (curl_code), libcurl_errbuf); else fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n", curl_easy_strerror (curl_code)); fflush (stderr); return 0; } if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code)) libcurlErrorExit (); if (expected_code != code) { fprintf (stderr, "The response has wrong HTTP code: %ld\tExpected: %ld.\n", code, expected_code); return 0; } else if (verbose) printf ("The response has expected HTTP code: %ld\n", expected_code); return ! 0; } static unsigned int performTest (void) { struct MHD_Daemon *d; uint16_t port; struct CBC cbc; struct ahc_cls_type ahc_param; char buf[2048]; CURL *c; CURLM *multi_reuse; int failed = 0; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 4220 + oneone ? 0 : 1; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahcCheck, &ahc_param, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); port = dinfo->port; } /* First request */ ahc_param.rq_method = MHD_HTTP_METHOD_PUT; ahc_param.rq_url = EXPECTED_URI_BASE_PATH; cbc.buf = buf; cbc.size = sizeof (buf); cbc.pos = 0; memset (cbc.buf, 0, cbc.size); c = setupCURL (&cbc, port); multi_reuse = NULL; /* First request */ if (check_result (performQueryExternal (d, c, &multi_reuse), c, MHD_HTTP_BAD_REQUEST)) { fflush (stderr); if (verbose) printf ("Got first expected response.\n"); fflush (stdout); } else { fprintf (stderr, "First request FAILED.\n"); fflush (stderr); failed = 1; } /* Second request */ cbc.pos = 0; /* Reset buffer position */ if (check_result (performQueryExternal (d, c, &multi_reuse), c, MHD_HTTP_BAD_REQUEST)) { fflush (stderr); if (verbose) printf ("Got second expected response.\n"); fflush (stdout); } else { fprintf (stderr, "Second request FAILED.\n"); fflush (stderr); failed = 1; } /* Third request */ cbc.pos = 0; /* Reset buffer position */ if (NULL != multi_reuse) curl_multi_cleanup (multi_reuse); multi_reuse = NULL; /* Force new connection */ if (check_result (performQueryExternal (d, c, &multi_reuse), c, MHD_HTTP_BAD_REQUEST)) { fflush (stderr); if (verbose) printf ("Got third expected response.\n"); fflush (stdout); } else { fprintf (stderr, "Third request FAILED.\n"); fflush (stderr); failed = 1; } curl_easy_cleanup (c); if (NULL != multi_reuse) curl_multi_cleanup (multi_reuse); MHD_stop_daemon (d); return failed ? 1 : 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; /* Test type and test parameters */ verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); oneone = ! has_in_name (argv[0], "10"); test_global_init (); errorCount += performTest (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); test_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_put.c0000644000175000017500000003721114530120375014511 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file daemontest_put.c * @brief Testcase for libmicrohttpd PUT operations * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #ifndef WINDOWS #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif static int oneone; struct CBC { char *buf; size_t pos; size_t size; }; static size_t putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) { size_t *pos = ptr; size_t wrt; wrt = size * nmemb; if (wrt > 8 - (*pos)) wrt = 8 - (*pos); memcpy (stream, &("Hello123"[*pos]), wrt); (*pos) += wrt; return wrt; } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { int *done = cls; struct MHD_Response *response; enum MHD_Result ret; (void) version; (void) req_cls; /* Unused. Silent compiler warning. */ if (0 != strcmp ("PUT", method)) return MHD_NO; /* unexpected method */ if ((*done) == 0) { if (*upload_data_size != 8) return MHD_YES; /* not yet ready */ if (0 == memcmp (upload_data, "Hello123", 8)) { *upload_data_size = 0; } else { printf ("Invalid upload data `%8s'!\n", upload_data); return MHD_NO; } *done = 1; return MHD_YES; } response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int testInternalPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1450; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; return 0; } static unsigned int testMultithreadedPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1451; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testMultithreadedPoolPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1452; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testExternalPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; int maxposixs; /* Max socket number unused on W32 */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; size_t pos = 0; int done_flag = 0; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1453; if (oneone) port += 10; } multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } #ifdef MHD_POSIX_SOCKETS if (maxsock > maxposixs) maxposixs = maxsock; #endif /* MHD_POSIX_SOCKETS */ tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 8192; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 16384; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalPut (); errorCount += testMultithreadedPut (); errorCount += testMultithreadedPoolPut (); } errorCount += testExternalPut (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/Makefile.in0000644000175000017500000067202714566140141014557 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @USE_COVERAGE_TRUE@am__append_1 = -fprofile-arcs -ftest-coverage @ENABLE_HTTPS_TRUE@am__append_2 = https @HEAVY_TESTS_TRUE@am__append_3 = \ @HEAVY_TESTS_TRUE@ test_add_conn_cleanup \ @HEAVY_TESTS_TRUE@ test_add_conn_cleanup_nolisten \ @HEAVY_TESTS_TRUE@ test_timeout \ @HEAVY_TESTS_TRUE@ $(EMPTY_ITEM) @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@am__append_4 = \ @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@ perf_get_concurrent11 \ @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@ $(EMPTY_ITEM) @HAVE_POSIX_THREADS_TRUE@am__append_5 = \ @HAVE_POSIX_THREADS_TRUE@ test_get_wait \ @HAVE_POSIX_THREADS_TRUE@ test_get_wait11 \ @HAVE_POSIX_THREADS_TRUE@ $(EMPTY_ITEM) @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@am__append_6 = \ @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@ test_concurrent_stop \ @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@ test_quiesce \ @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@ $(EMPTY_ITEM) @HAVE_CURL_BINARY_TRUE@@HAVE_POSIX_THREADS_TRUE@am__append_7 = \ @HAVE_CURL_BINARY_TRUE@@HAVE_POSIX_THREADS_TRUE@ test_quiesce_stream @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@am__append_8 = \ @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@ perf_get_concurrent @RUN_LIBCURL_TESTS_TRUE@check_PROGRAMS = test_get$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_head$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_head10$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_iovec$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_sendfile$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_close$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_close10$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_keep_alive$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_keep_alive10$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_delete$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_patch$(EXEEXT) test_put$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_add_conn$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_add_conn_nolisten$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_process_headers$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_process_arguments$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_toolarge_method$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_toolarge_url$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_toolarge_request_header_name$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_toolarge_request_header_value$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_toolarge_request_headers$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_toolarge_reply_header_name$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_toolarge_reply_header_value$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_toolarge_reply_headers$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_tricky_url$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_tricky_header2$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_large_put$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get11$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_iovec11$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_sendfile11$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_patch11$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put11$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_large_put11$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_large_put_inc11$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_broken_len10$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_broken_len$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_close$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_string$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_close_string$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_empty$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_close_empty$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_string_empty$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_close_string_empty$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_sized$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_close_sized$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_empty_sized$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_close_empty_sized$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_forced$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_close_forced$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_empty_forced$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_chunked_close_empty_forced$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_chunked$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_callback$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_header_fold$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_header_fold$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_large_header_fold$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_header_fold_last$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_header_fold_large$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_get_header_double_fold$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_header_double_fold$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_large_header_double_fold$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_header_double_fold_last$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ test_put_header_double_fold_large$(EXEEXT) \ @RUN_LIBCURL_TESTS_TRUE@ $(am__EXEEXT_1) $(am__EXEEXT_2) \ @RUN_LIBCURL_TESTS_TRUE@ $(am__EXEEXT_3) $(am__EXEEXT_4) \ @RUN_LIBCURL_TESTS_TRUE@ $(am__EXEEXT_5) $(am__EXEEXT_6) \ @RUN_LIBCURL_TESTS_TRUE@ $(am__EXEEXT_7) $(am__EXEEXT_8) \ @RUN_LIBCURL_TESTS_TRUE@ $(am__EXEEXT_18) $(am__EXEEXT_19) @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__append_9 = \ @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_parse_cookies_discp_p2 \ @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_parse_cookies_discp_p1 \ @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_parse_cookies_discp_zero \ @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_parse_cookies_discp_n2 \ @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_parse_cookies_discp_n3 @HEAVY_TESTS_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__append_10 = \ @HEAVY_TESTS_TRUE@@RUN_LIBCURL_TESTS_TRUE@ perf_get @ENABLE_BAUTH_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__append_11 = \ @ENABLE_BAUTH_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_basicauth test_basicauth_preauth \ @ENABLE_BAUTH_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_basicauth_oldapi test_basicauth_preauth_oldapi @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__append_12 = \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_post \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_postform \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_post_loop \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_post11 \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_postform11 \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_post_loop11 @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__append_13 = \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth_with_arguments \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth_concurrent @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__append_14 = \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth_sha256 @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__append_15 = \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth_emu_ext \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth_emu_ext_oldapi \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2 \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_rfc2069 \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_rfc2069_userdigest \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi1 \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi2 \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_userhash \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_userdigest \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi1_userdigest \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi2_userdigest \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_userhash_userdigest \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_bind_all \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_bind_uri \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi1_bind_all \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi1_bind_uri @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__append_16 = \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_sha256 \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_sha256_userhash \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi2_sha256 \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_sha256_userdigest \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi2_sha256_userdigest \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_sha256_userhash_userdigest @HAVE_CURL_BINARY_TRUE@@HAVE_FORK_WAITPID_TRUE@@HEAVY_TESTS_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__append_17 = test_get_response_cleanup @RUN_LIBCURL_TESTS_TRUE@@USE_POSIX_THREADS_TRUE@am__append_18 = \ @RUN_LIBCURL_TESTS_TRUE@@USE_POSIX_THREADS_TRUE@ $(THREAD_ONLY_TESTS) @RUN_LIBCURL_TESTS_TRUE@@USE_W32_THREADS_TRUE@am__append_19 = \ @RUN_LIBCURL_TESTS_TRUE@@USE_W32_THREADS_TRUE@ $(THREAD_ONLY_TESTS) subdir = src/testcurl ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__EXEEXT_1 = @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__EXEEXT_2 = test_parse_cookies_discp_p2$(EXEEXT) \ @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_parse_cookies_discp_p1$(EXEEXT) \ @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_parse_cookies_discp_zero$(EXEEXT) \ @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_parse_cookies_discp_n2$(EXEEXT) \ @ENABLE_COOKIE_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_parse_cookies_discp_n3$(EXEEXT) @HEAVY_TESTS_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__EXEEXT_3 = \ @HEAVY_TESTS_TRUE@@RUN_LIBCURL_TESTS_TRUE@ perf_get$(EXEEXT) @ENABLE_BAUTH_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__EXEEXT_4 = test_basicauth$(EXEEXT) \ @ENABLE_BAUTH_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_basicauth_preauth$(EXEEXT) \ @ENABLE_BAUTH_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_basicauth_oldapi$(EXEEXT) \ @ENABLE_BAUTH_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_basicauth_preauth_oldapi$(EXEEXT) @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__EXEEXT_5 = test_post$(EXEEXT) \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_postform$(EXEEXT) \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_post_loop$(EXEEXT) \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_post11$(EXEEXT) \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_postform11$(EXEEXT) \ @HAVE_POSTPROCESSOR_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_post_loop11$(EXEEXT) @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__EXEEXT_6 = test_digestauth_emu_ext$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth_emu_ext_oldapi$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_rfc2069$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_rfc2069_userdigest$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi1$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi2$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_userhash$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_userdigest$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi1_userdigest$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi2_userdigest$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_userhash_userdigest$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_bind_all$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_bind_uri$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi1_bind_all$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi1_bind_uri$(EXEEXT) @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__EXEEXT_7 = test_digestauth2_sha256$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_sha256_userhash$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi2_sha256$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_sha256_userdigest$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_oldapi2_sha256_userdigest$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth2_sha256_userhash_userdigest$(EXEEXT) @HAVE_CURL_BINARY_TRUE@@HAVE_FORK_WAITPID_TRUE@@HEAVY_TESTS_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__EXEEXT_8 = test_get_response_cleanup$(EXEEXT) @HEAVY_TESTS_TRUE@am__EXEEXT_9 = test_add_conn_cleanup$(EXEEXT) \ @HEAVY_TESTS_TRUE@ test_add_conn_cleanup_nolisten$(EXEEXT) \ @HEAVY_TESTS_TRUE@ test_timeout$(EXEEXT) $(am__EXEEXT_1) @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@am__EXEEXT_10 = perf_get_concurrent11$(EXEEXT) \ @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@ $(am__EXEEXT_1) @HAVE_POSIX_THREADS_TRUE@am__EXEEXT_11 = test_get_wait$(EXEEXT) \ @HAVE_POSIX_THREADS_TRUE@ test_get_wait11$(EXEEXT) \ @HAVE_POSIX_THREADS_TRUE@ $(am__EXEEXT_1) @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@am__EXEEXT_12 = test_concurrent_stop$(EXEEXT) \ @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@ test_quiesce$(EXEEXT) \ @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@ $(am__EXEEXT_1) @HAVE_CURL_BINARY_TRUE@@HAVE_POSIX_THREADS_TRUE@am__EXEEXT_13 = test_quiesce_stream$(EXEEXT) @HAVE_POSIX_THREADS_TRUE@@HEAVY_TESTS_TRUE@am__EXEEXT_14 = perf_get_concurrent$(EXEEXT) @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__EXEEXT_15 = test_digestauth$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth_with_arguments$(EXEEXT) \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@@RUN_LIBCURL_TESTS_TRUE@ test_digestauth_concurrent$(EXEEXT) @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@@RUN_LIBCURL_TESTS_TRUE@am__EXEEXT_16 = test_digestauth_sha256$(EXEEXT) am__EXEEXT_17 = test_urlparse$(EXEEXT) test_long_header$(EXEEXT) \ test_long_header11$(EXEEXT) test_iplimit11$(EXEEXT) \ test_termination$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_9) \ $(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12) \ $(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15) \ $(am__EXEEXT_16) @RUN_LIBCURL_TESTS_TRUE@@USE_POSIX_THREADS_TRUE@am__EXEEXT_18 = $(am__EXEEXT_17) @RUN_LIBCURL_TESTS_TRUE@@USE_W32_THREADS_TRUE@am__EXEEXT_19 = $(am__EXEEXT_17) am_perf_get_OBJECTS = perf_get.$(OBJEXT) perf_get_OBJECTS = $(am_perf_get_OBJECTS) perf_get_LDADD = $(LDADD) perf_get_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_perf_get_concurrent_OBJECTS = \ perf_get_concurrent-perf_get_concurrent.$(OBJEXT) perf_get_concurrent_OBJECTS = $(am_perf_get_concurrent_OBJECTS) am__DEPENDENCIES_1 = am__DEPENDENCIES_2 = $(top_builddir)/src/microhttpd/libmicrohttpd.la perf_get_concurrent_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) perf_get_concurrent_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(perf_get_concurrent_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_perf_get_concurrent11_OBJECTS = \ perf_get_concurrent11-perf_get_concurrent.$(OBJEXT) perf_get_concurrent11_OBJECTS = $(am_perf_get_concurrent11_OBJECTS) perf_get_concurrent11_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) perf_get_concurrent11_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(perf_get_concurrent11_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_add_conn_OBJECTS = test_add_conn-test_add_conn.$(OBJEXT) test_add_conn_OBJECTS = $(am_test_add_conn_OBJECTS) test_add_conn_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_add_conn_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_add_conn_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ am_test_add_conn_cleanup_OBJECTS = \ test_add_conn_cleanup-test_add_conn.$(OBJEXT) test_add_conn_cleanup_OBJECTS = $(am_test_add_conn_cleanup_OBJECTS) test_add_conn_cleanup_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_add_conn_cleanup_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_add_conn_cleanup_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_add_conn_cleanup_nolisten_OBJECTS = \ test_add_conn_cleanup_nolisten-test_add_conn.$(OBJEXT) test_add_conn_cleanup_nolisten_OBJECTS = \ $(am_test_add_conn_cleanup_nolisten_OBJECTS) test_add_conn_cleanup_nolisten_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_add_conn_cleanup_nolisten_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_add_conn_cleanup_nolisten_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ am_test_add_conn_nolisten_OBJECTS = \ test_add_conn_nolisten-test_add_conn.$(OBJEXT) test_add_conn_nolisten_OBJECTS = $(am_test_add_conn_nolisten_OBJECTS) test_add_conn_nolisten_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_add_conn_nolisten_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_add_conn_nolisten_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_basicauth_OBJECTS = test_basicauth.$(OBJEXT) test_basicauth_OBJECTS = $(am_test_basicauth_OBJECTS) test_basicauth_LDADD = $(LDADD) test_basicauth_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_basicauth_oldapi_OBJECTS = test_basicauth.$(OBJEXT) test_basicauth_oldapi_OBJECTS = $(am_test_basicauth_oldapi_OBJECTS) test_basicauth_oldapi_LDADD = $(LDADD) test_basicauth_oldapi_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_basicauth_preauth_OBJECTS = test_basicauth.$(OBJEXT) test_basicauth_preauth_OBJECTS = $(am_test_basicauth_preauth_OBJECTS) test_basicauth_preauth_LDADD = $(LDADD) test_basicauth_preauth_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_basicauth_preauth_oldapi_OBJECTS = test_basicauth.$(OBJEXT) test_basicauth_preauth_oldapi_OBJECTS = \ $(am_test_basicauth_preauth_oldapi_OBJECTS) test_basicauth_preauth_oldapi_LDADD = $(LDADD) test_basicauth_preauth_oldapi_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_callback_OBJECTS = test_callback.$(OBJEXT) test_callback_OBJECTS = $(am_test_callback_OBJECTS) test_callback_LDADD = $(LDADD) test_callback_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_concurrent_stop_OBJECTS = \ test_concurrent_stop-test_concurrent_stop.$(OBJEXT) test_concurrent_stop_OBJECTS = $(am_test_concurrent_stop_OBJECTS) test_concurrent_stop_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_concurrent_stop_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_concurrent_stop_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_delete_OBJECTS = test_delete.$(OBJEXT) test_delete_OBJECTS = $(am_test_delete_OBJECTS) test_delete_LDADD = $(LDADD) test_delete_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth_OBJECTS = test_digestauth.$(OBJEXT) test_digestauth_OBJECTS = $(am_test_digestauth_OBJECTS) test_digestauth_DEPENDENCIES = $(am__DEPENDENCIES_2) am_test_digestauth2_OBJECTS = test_digestauth2.$(OBJEXT) test_digestauth2_OBJECTS = $(am_test_digestauth2_OBJECTS) test_digestauth2_LDADD = $(LDADD) test_digestauth2_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_bind_all_OBJECTS = test_digestauth2.$(OBJEXT) test_digestauth2_bind_all_OBJECTS = \ $(am_test_digestauth2_bind_all_OBJECTS) test_digestauth2_bind_all_LDADD = $(LDADD) test_digestauth2_bind_all_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_bind_uri_OBJECTS = test_digestauth2.$(OBJEXT) test_digestauth2_bind_uri_OBJECTS = \ $(am_test_digestauth2_bind_uri_OBJECTS) test_digestauth2_bind_uri_LDADD = $(LDADD) test_digestauth2_bind_uri_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_oldapi1_OBJECTS = test_digestauth2.$(OBJEXT) test_digestauth2_oldapi1_OBJECTS = \ $(am_test_digestauth2_oldapi1_OBJECTS) test_digestauth2_oldapi1_LDADD = $(LDADD) test_digestauth2_oldapi1_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_oldapi1_bind_all_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_oldapi1_bind_all_OBJECTS = \ $(am_test_digestauth2_oldapi1_bind_all_OBJECTS) test_digestauth2_oldapi1_bind_all_LDADD = $(LDADD) test_digestauth2_oldapi1_bind_all_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_oldapi1_bind_uri_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_oldapi1_bind_uri_OBJECTS = \ $(am_test_digestauth2_oldapi1_bind_uri_OBJECTS) test_digestauth2_oldapi1_bind_uri_LDADD = $(LDADD) test_digestauth2_oldapi1_bind_uri_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_oldapi1_userdigest_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_oldapi1_userdigest_OBJECTS = \ $(am_test_digestauth2_oldapi1_userdigest_OBJECTS) test_digestauth2_oldapi1_userdigest_LDADD = $(LDADD) test_digestauth2_oldapi1_userdigest_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_oldapi2_OBJECTS = test_digestauth2.$(OBJEXT) test_digestauth2_oldapi2_OBJECTS = \ $(am_test_digestauth2_oldapi2_OBJECTS) test_digestauth2_oldapi2_LDADD = $(LDADD) test_digestauth2_oldapi2_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_oldapi2_sha256_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_oldapi2_sha256_OBJECTS = \ $(am_test_digestauth2_oldapi2_sha256_OBJECTS) test_digestauth2_oldapi2_sha256_LDADD = $(LDADD) test_digestauth2_oldapi2_sha256_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_oldapi2_sha256_userdigest_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_oldapi2_sha256_userdigest_OBJECTS = \ $(am_test_digestauth2_oldapi2_sha256_userdigest_OBJECTS) test_digestauth2_oldapi2_sha256_userdigest_LDADD = $(LDADD) test_digestauth2_oldapi2_sha256_userdigest_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_oldapi2_userdigest_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_oldapi2_userdigest_OBJECTS = \ $(am_test_digestauth2_oldapi2_userdigest_OBJECTS) test_digestauth2_oldapi2_userdigest_LDADD = $(LDADD) test_digestauth2_oldapi2_userdigest_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_rfc2069_OBJECTS = test_digestauth2.$(OBJEXT) test_digestauth2_rfc2069_OBJECTS = \ $(am_test_digestauth2_rfc2069_OBJECTS) test_digestauth2_rfc2069_LDADD = $(LDADD) test_digestauth2_rfc2069_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_rfc2069_userdigest_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_rfc2069_userdigest_OBJECTS = \ $(am_test_digestauth2_rfc2069_userdigest_OBJECTS) test_digestauth2_rfc2069_userdigest_LDADD = $(LDADD) test_digestauth2_rfc2069_userdigest_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_sha256_OBJECTS = test_digestauth2.$(OBJEXT) test_digestauth2_sha256_OBJECTS = \ $(am_test_digestauth2_sha256_OBJECTS) test_digestauth2_sha256_LDADD = $(LDADD) test_digestauth2_sha256_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_sha256_userdigest_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_sha256_userdigest_OBJECTS = \ $(am_test_digestauth2_sha256_userdigest_OBJECTS) test_digestauth2_sha256_userdigest_LDADD = $(LDADD) test_digestauth2_sha256_userdigest_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_sha256_userhash_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_sha256_userhash_OBJECTS = \ $(am_test_digestauth2_sha256_userhash_OBJECTS) test_digestauth2_sha256_userhash_LDADD = $(LDADD) test_digestauth2_sha256_userhash_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_sha256_userhash_userdigest_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_sha256_userhash_userdigest_OBJECTS = \ $(am_test_digestauth2_sha256_userhash_userdigest_OBJECTS) test_digestauth2_sha256_userhash_userdigest_LDADD = $(LDADD) test_digestauth2_sha256_userhash_userdigest_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_userdigest_OBJECTS = test_digestauth2.$(OBJEXT) test_digestauth2_userdigest_OBJECTS = \ $(am_test_digestauth2_userdigest_OBJECTS) test_digestauth2_userdigest_LDADD = $(LDADD) test_digestauth2_userdigest_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_userhash_OBJECTS = test_digestauth2.$(OBJEXT) test_digestauth2_userhash_OBJECTS = \ $(am_test_digestauth2_userhash_OBJECTS) test_digestauth2_userhash_LDADD = $(LDADD) test_digestauth2_userhash_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth2_userhash_userdigest_OBJECTS = \ test_digestauth2.$(OBJEXT) test_digestauth2_userhash_userdigest_OBJECTS = \ $(am_test_digestauth2_userhash_userdigest_OBJECTS) test_digestauth2_userhash_userdigest_LDADD = $(LDADD) test_digestauth2_userhash_userdigest_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth_concurrent_OBJECTS = test_digestauth_concurrent-test_digestauth_concurrent.$(OBJEXT) test_digestauth_concurrent_OBJECTS = \ $(am_test_digestauth_concurrent_OBJECTS) test_digestauth_concurrent_DEPENDENCIES = $(am__DEPENDENCIES_2) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) test_digestauth_concurrent_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_digestauth_concurrent_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_digestauth_emu_ext_OBJECTS = \ test_digestauth_emu_ext.$(OBJEXT) test_digestauth_emu_ext_OBJECTS = \ $(am_test_digestauth_emu_ext_OBJECTS) test_digestauth_emu_ext_LDADD = $(LDADD) test_digestauth_emu_ext_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth_emu_ext_oldapi_OBJECTS = \ test_digestauth_emu_ext.$(OBJEXT) test_digestauth_emu_ext_oldapi_OBJECTS = \ $(am_test_digestauth_emu_ext_oldapi_OBJECTS) test_digestauth_emu_ext_oldapi_LDADD = $(LDADD) test_digestauth_emu_ext_oldapi_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_digestauth_sha256_OBJECTS = test_digestauth_sha256.$(OBJEXT) test_digestauth_sha256_OBJECTS = $(am_test_digestauth_sha256_OBJECTS) test_digestauth_sha256_DEPENDENCIES = $(am__DEPENDENCIES_2) am_test_digestauth_with_arguments_OBJECTS = \ test_digestauth_with_arguments.$(OBJEXT) test_digestauth_with_arguments_OBJECTS = \ $(am_test_digestauth_with_arguments_OBJECTS) test_digestauth_with_arguments_DEPENDENCIES = $(am__DEPENDENCIES_2) am_test_get_OBJECTS = test_get.$(OBJEXT) test_get_OBJECTS = $(am_test_get_OBJECTS) test_get_LDADD = $(LDADD) test_get_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get11_OBJECTS = test_get.$(OBJEXT) test_get11_OBJECTS = $(am_test_get11_OBJECTS) test_get11_LDADD = $(LDADD) test_get11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_OBJECTS = $(am_test_get_chunked_OBJECTS) test_get_chunked_LDADD = $(LDADD) test_get_chunked_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_close_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_close_OBJECTS = $(am_test_get_chunked_close_OBJECTS) test_get_chunked_close_LDADD = $(LDADD) test_get_chunked_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_close_empty_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_close_empty_OBJECTS = \ $(am_test_get_chunked_close_empty_OBJECTS) test_get_chunked_close_empty_LDADD = $(LDADD) test_get_chunked_close_empty_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_close_empty_forced_OBJECTS = \ test_get_chunked.$(OBJEXT) test_get_chunked_close_empty_forced_OBJECTS = \ $(am_test_get_chunked_close_empty_forced_OBJECTS) test_get_chunked_close_empty_forced_LDADD = $(LDADD) test_get_chunked_close_empty_forced_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_close_empty_sized_OBJECTS = \ test_get_chunked.$(OBJEXT) test_get_chunked_close_empty_sized_OBJECTS = \ $(am_test_get_chunked_close_empty_sized_OBJECTS) test_get_chunked_close_empty_sized_LDADD = $(LDADD) test_get_chunked_close_empty_sized_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_close_forced_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_close_forced_OBJECTS = \ $(am_test_get_chunked_close_forced_OBJECTS) test_get_chunked_close_forced_LDADD = $(LDADD) test_get_chunked_close_forced_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_close_sized_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_close_sized_OBJECTS = \ $(am_test_get_chunked_close_sized_OBJECTS) test_get_chunked_close_sized_LDADD = $(LDADD) test_get_chunked_close_sized_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_close_string_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_close_string_OBJECTS = \ $(am_test_get_chunked_close_string_OBJECTS) test_get_chunked_close_string_LDADD = $(LDADD) test_get_chunked_close_string_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_close_string_empty_OBJECTS = \ test_get_chunked.$(OBJEXT) test_get_chunked_close_string_empty_OBJECTS = \ $(am_test_get_chunked_close_string_empty_OBJECTS) test_get_chunked_close_string_empty_LDADD = $(LDADD) test_get_chunked_close_string_empty_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_empty_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_empty_OBJECTS = $(am_test_get_chunked_empty_OBJECTS) test_get_chunked_empty_LDADD = $(LDADD) test_get_chunked_empty_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_empty_forced_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_empty_forced_OBJECTS = \ $(am_test_get_chunked_empty_forced_OBJECTS) test_get_chunked_empty_forced_LDADD = $(LDADD) test_get_chunked_empty_forced_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_empty_sized_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_empty_sized_OBJECTS = \ $(am_test_get_chunked_empty_sized_OBJECTS) test_get_chunked_empty_sized_LDADD = $(LDADD) test_get_chunked_empty_sized_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_forced_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_forced_OBJECTS = \ $(am_test_get_chunked_forced_OBJECTS) test_get_chunked_forced_LDADD = $(LDADD) test_get_chunked_forced_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_sized_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_sized_OBJECTS = $(am_test_get_chunked_sized_OBJECTS) test_get_chunked_sized_LDADD = $(LDADD) test_get_chunked_sized_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_string_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_string_OBJECTS = \ $(am_test_get_chunked_string_OBJECTS) test_get_chunked_string_LDADD = $(LDADD) test_get_chunked_string_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_string_empty_OBJECTS = test_get_chunked.$(OBJEXT) test_get_chunked_string_empty_OBJECTS = \ $(am_test_get_chunked_string_empty_OBJECTS) test_get_chunked_string_empty_LDADD = $(LDADD) test_get_chunked_string_empty_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_close_OBJECTS = test_get_close_keep_alive.$(OBJEXT) test_get_close_OBJECTS = $(am_test_get_close_OBJECTS) test_get_close_LDADD = $(LDADD) test_get_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_close10_OBJECTS = test_get_close_keep_alive.$(OBJEXT) test_get_close10_OBJECTS = $(am_test_get_close10_OBJECTS) test_get_close10_LDADD = $(LDADD) test_get_close10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am__objects_1 = test_put_header_fold.$(OBJEXT) am_test_get_header_double_fold_OBJECTS = $(am__objects_1) test_get_header_double_fold_OBJECTS = \ $(am_test_get_header_double_fold_OBJECTS) test_get_header_double_fold_LDADD = $(LDADD) test_get_header_double_fold_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_header_fold_OBJECTS = $(am__objects_1) test_get_header_fold_OBJECTS = $(am_test_get_header_fold_OBJECTS) test_get_header_fold_LDADD = $(LDADD) test_get_header_fold_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_iovec_OBJECTS = test_get_iovec.$(OBJEXT) test_get_iovec_OBJECTS = $(am_test_get_iovec_OBJECTS) test_get_iovec_LDADD = $(LDADD) test_get_iovec_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_iovec11_OBJECTS = test_get_iovec.$(OBJEXT) test_get_iovec11_OBJECTS = $(am_test_get_iovec11_OBJECTS) test_get_iovec11_LDADD = $(LDADD) test_get_iovec11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_keep_alive_OBJECTS = test_get_close_keep_alive.$(OBJEXT) test_get_keep_alive_OBJECTS = $(am_test_get_keep_alive_OBJECTS) test_get_keep_alive_LDADD = $(LDADD) test_get_keep_alive_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_keep_alive10_OBJECTS = \ test_get_close_keep_alive.$(OBJEXT) test_get_keep_alive10_OBJECTS = $(am_test_get_keep_alive10_OBJECTS) test_get_keep_alive10_LDADD = $(LDADD) test_get_keep_alive10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_response_cleanup_OBJECTS = \ test_get_response_cleanup.$(OBJEXT) test_get_response_cleanup_OBJECTS = \ $(am_test_get_response_cleanup_OBJECTS) test_get_response_cleanup_LDADD = $(LDADD) test_get_response_cleanup_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_sendfile_OBJECTS = test_get_sendfile.$(OBJEXT) test_get_sendfile_OBJECTS = $(am_test_get_sendfile_OBJECTS) test_get_sendfile_LDADD = $(LDADD) test_get_sendfile_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_sendfile11_OBJECTS = test_get_sendfile.$(OBJEXT) test_get_sendfile11_OBJECTS = $(am_test_get_sendfile11_OBJECTS) test_get_sendfile11_LDADD = $(LDADD) test_get_sendfile11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_wait_OBJECTS = test_get_wait-test_get_wait.$(OBJEXT) test_get_wait_OBJECTS = $(am_test_get_wait_OBJECTS) test_get_wait_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_get_wait_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_get_wait_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ am_test_get_wait11_OBJECTS = test_get_wait11-test_get_wait.$(OBJEXT) test_get_wait11_OBJECTS = $(am_test_get_wait11_OBJECTS) test_get_wait11_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_get_wait11_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_get_wait11_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ am_test_head_OBJECTS = test_head.$(OBJEXT) test_head_OBJECTS = $(am_test_head_OBJECTS) test_head_LDADD = $(LDADD) test_head_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_head10_OBJECTS = test_head.$(OBJEXT) test_head10_OBJECTS = $(am_test_head10_OBJECTS) test_head10_LDADD = $(LDADD) test_head10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_iplimit11_OBJECTS = test_iplimit.$(OBJEXT) test_iplimit11_OBJECTS = $(am_test_iplimit11_OBJECTS) test_iplimit11_LDADD = $(LDADD) test_iplimit11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_large_put_OBJECTS = test_large_put.$(OBJEXT) test_large_put_OBJECTS = $(am_test_large_put_OBJECTS) test_large_put_LDADD = $(LDADD) test_large_put_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_large_put11_OBJECTS = test_large_put.$(OBJEXT) test_large_put11_OBJECTS = $(am_test_large_put11_OBJECTS) test_large_put11_LDADD = $(LDADD) test_large_put11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_large_put_inc11_OBJECTS = test_large_put.$(OBJEXT) test_large_put_inc11_OBJECTS = $(am_test_large_put_inc11_OBJECTS) test_large_put_inc11_LDADD = $(LDADD) test_large_put_inc11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_long_header_OBJECTS = test_long_header.$(OBJEXT) test_long_header_OBJECTS = $(am_test_long_header_OBJECTS) test_long_header_LDADD = $(LDADD) test_long_header_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_long_header11_OBJECTS = test_long_header.$(OBJEXT) test_long_header11_OBJECTS = $(am_test_long_header11_OBJECTS) test_long_header11_LDADD = $(LDADD) test_long_header11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am__objects_2 = test_parse_cookies.$(OBJEXT) am_test_parse_cookies_discp_n2_OBJECTS = $(am__objects_2) test_parse_cookies_discp_n2_OBJECTS = \ $(am_test_parse_cookies_discp_n2_OBJECTS) test_parse_cookies_discp_n2_LDADD = $(LDADD) test_parse_cookies_discp_n2_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_parse_cookies_discp_n3_OBJECTS = $(am__objects_2) test_parse_cookies_discp_n3_OBJECTS = \ $(am_test_parse_cookies_discp_n3_OBJECTS) test_parse_cookies_discp_n3_LDADD = $(LDADD) test_parse_cookies_discp_n3_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_parse_cookies_discp_p1_OBJECTS = $(am__objects_2) test_parse_cookies_discp_p1_OBJECTS = \ $(am_test_parse_cookies_discp_p1_OBJECTS) test_parse_cookies_discp_p1_LDADD = $(LDADD) test_parse_cookies_discp_p1_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_parse_cookies_discp_p2_OBJECTS = $(am__objects_2) test_parse_cookies_discp_p2_OBJECTS = \ $(am_test_parse_cookies_discp_p2_OBJECTS) test_parse_cookies_discp_p2_LDADD = $(LDADD) test_parse_cookies_discp_p2_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_parse_cookies_discp_zero_OBJECTS = \ test_parse_cookies.$(OBJEXT) test_parse_cookies_discp_zero_OBJECTS = \ $(am_test_parse_cookies_discp_zero_OBJECTS) test_parse_cookies_discp_zero_LDADD = $(LDADD) test_parse_cookies_discp_zero_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_patch_OBJECTS = test_patch.$(OBJEXT) test_patch_OBJECTS = $(am_test_patch_OBJECTS) test_patch_LDADD = $(LDADD) test_patch_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_patch11_OBJECTS = test_patch.$(OBJEXT) test_patch11_OBJECTS = $(am_test_patch11_OBJECTS) test_patch11_LDADD = $(LDADD) test_patch11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_post_OBJECTS = test_post.$(OBJEXT) test_post_OBJECTS = $(am_test_post_OBJECTS) test_post_LDADD = $(LDADD) test_post_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_post11_OBJECTS = test_post.$(OBJEXT) test_post11_OBJECTS = $(am_test_post11_OBJECTS) test_post11_LDADD = $(LDADD) test_post11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_post_loop_OBJECTS = test_post_loop.$(OBJEXT) test_post_loop_OBJECTS = $(am_test_post_loop_OBJECTS) test_post_loop_LDADD = $(LDADD) test_post_loop_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_post_loop11_OBJECTS = test_post_loop.$(OBJEXT) test_post_loop11_OBJECTS = $(am_test_post_loop11_OBJECTS) test_post_loop11_LDADD = $(LDADD) test_post_loop11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_postform_OBJECTS = test_postform.$(OBJEXT) test_postform_OBJECTS = $(am_test_postform_OBJECTS) test_postform_DEPENDENCIES = $(am__DEPENDENCIES_2) am_test_postform11_OBJECTS = test_postform.$(OBJEXT) test_postform11_OBJECTS = $(am_test_postform11_OBJECTS) test_postform11_DEPENDENCIES = $(am__DEPENDENCIES_2) am_test_process_arguments_OBJECTS = test_process_arguments.$(OBJEXT) test_process_arguments_OBJECTS = $(am_test_process_arguments_OBJECTS) test_process_arguments_LDADD = $(LDADD) test_process_arguments_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_process_headers_OBJECTS = test_process_headers.$(OBJEXT) test_process_headers_OBJECTS = $(am_test_process_headers_OBJECTS) test_process_headers_LDADD = $(LDADD) test_process_headers_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_OBJECTS = test_put.$(OBJEXT) test_put_OBJECTS = $(am_test_put_OBJECTS) test_put_LDADD = $(LDADD) test_put_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put11_OBJECTS = test_put.$(OBJEXT) test_put11_OBJECTS = $(am_test_put11_OBJECTS) test_put11_LDADD = $(LDADD) test_put11_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_broken_len_OBJECTS = test_put_broken_len.$(OBJEXT) test_put_broken_len_OBJECTS = $(am_test_put_broken_len_OBJECTS) test_put_broken_len_LDADD = $(LDADD) test_put_broken_len_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am__objects_3 = test_put_broken_len.$(OBJEXT) am_test_put_broken_len10_OBJECTS = $(am__objects_3) test_put_broken_len10_OBJECTS = $(am_test_put_broken_len10_OBJECTS) test_put_broken_len10_LDADD = $(LDADD) test_put_broken_len10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_chunked_OBJECTS = test_put_chunked.$(OBJEXT) test_put_chunked_OBJECTS = $(am_test_put_chunked_OBJECTS) test_put_chunked_LDADD = $(LDADD) test_put_chunked_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_header_double_fold_OBJECTS = $(am__objects_1) test_put_header_double_fold_OBJECTS = \ $(am_test_put_header_double_fold_OBJECTS) test_put_header_double_fold_LDADD = $(LDADD) test_put_header_double_fold_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am__objects_4 = $(am__objects_1) am_test_put_header_double_fold_large_OBJECTS = $(am__objects_4) test_put_header_double_fold_large_OBJECTS = \ $(am_test_put_header_double_fold_large_OBJECTS) test_put_header_double_fold_large_LDADD = $(LDADD) test_put_header_double_fold_large_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_header_double_fold_last_OBJECTS = $(am__objects_4) test_put_header_double_fold_last_OBJECTS = \ $(am_test_put_header_double_fold_last_OBJECTS) test_put_header_double_fold_last_LDADD = $(LDADD) test_put_header_double_fold_last_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_header_fold_OBJECTS = test_put_header_fold.$(OBJEXT) test_put_header_fold_OBJECTS = $(am_test_put_header_fold_OBJECTS) test_put_header_fold_LDADD = $(LDADD) test_put_header_fold_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_header_fold_large_OBJECTS = $(am__objects_1) test_put_header_fold_large_OBJECTS = \ $(am_test_put_header_fold_large_OBJECTS) test_put_header_fold_large_LDADD = $(LDADD) test_put_header_fold_large_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_header_fold_last_OBJECTS = $(am__objects_1) test_put_header_fold_last_OBJECTS = \ $(am_test_put_header_fold_last_OBJECTS) test_put_header_fold_last_LDADD = $(LDADD) test_put_header_fold_last_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_large_header_double_fold_OBJECTS = $(am__objects_4) test_put_large_header_double_fold_OBJECTS = \ $(am_test_put_large_header_double_fold_OBJECTS) test_put_large_header_double_fold_LDADD = $(LDADD) test_put_large_header_double_fold_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_large_header_fold_OBJECTS = $(am__objects_1) test_put_large_header_fold_OBJECTS = \ $(am_test_put_large_header_fold_OBJECTS) test_put_large_header_fold_LDADD = $(LDADD) test_put_large_header_fold_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_quiesce_OBJECTS = test_quiesce-test_quiesce.$(OBJEXT) test_quiesce_OBJECTS = $(am_test_quiesce_OBJECTS) test_quiesce_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_quiesce_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_quiesce_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ am_test_quiesce_stream_OBJECTS = \ test_quiesce_stream-test_quiesce_stream.$(OBJEXT) test_quiesce_stream_OBJECTS = $(am_test_quiesce_stream_OBJECTS) test_quiesce_stream_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) test_quiesce_stream_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_quiesce_stream_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_termination_OBJECTS = test_termination.$(OBJEXT) test_termination_OBJECTS = $(am_test_termination_OBJECTS) test_termination_LDADD = $(LDADD) test_termination_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_timeout_OBJECTS = test_timeout.$(OBJEXT) test_timeout_OBJECTS = $(am_test_timeout_OBJECTS) test_timeout_LDADD = $(LDADD) test_timeout_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_toolarge_method_OBJECTS = test_toolarge.$(OBJEXT) test_toolarge_method_OBJECTS = $(am_test_toolarge_method_OBJECTS) test_toolarge_method_LDADD = $(LDADD) test_toolarge_method_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_toolarge_reply_header_name_OBJECTS = test_toolarge.$(OBJEXT) test_toolarge_reply_header_name_OBJECTS = \ $(am_test_toolarge_reply_header_name_OBJECTS) test_toolarge_reply_header_name_LDADD = $(LDADD) test_toolarge_reply_header_name_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_toolarge_reply_header_value_OBJECTS = test_toolarge.$(OBJEXT) test_toolarge_reply_header_value_OBJECTS = \ $(am_test_toolarge_reply_header_value_OBJECTS) test_toolarge_reply_header_value_LDADD = $(LDADD) test_toolarge_reply_header_value_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_toolarge_reply_headers_OBJECTS = test_toolarge.$(OBJEXT) test_toolarge_reply_headers_OBJECTS = \ $(am_test_toolarge_reply_headers_OBJECTS) test_toolarge_reply_headers_LDADD = $(LDADD) test_toolarge_reply_headers_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_toolarge_request_header_name_OBJECTS = \ test_toolarge.$(OBJEXT) test_toolarge_request_header_name_OBJECTS = \ $(am_test_toolarge_request_header_name_OBJECTS) test_toolarge_request_header_name_LDADD = $(LDADD) test_toolarge_request_header_name_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_toolarge_request_header_value_OBJECTS = \ test_toolarge.$(OBJEXT) test_toolarge_request_header_value_OBJECTS = \ $(am_test_toolarge_request_header_value_OBJECTS) test_toolarge_request_header_value_LDADD = $(LDADD) test_toolarge_request_header_value_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_toolarge_request_headers_OBJECTS = test_toolarge.$(OBJEXT) test_toolarge_request_headers_OBJECTS = \ $(am_test_toolarge_request_headers_OBJECTS) test_toolarge_request_headers_LDADD = $(LDADD) test_toolarge_request_headers_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_toolarge_url_OBJECTS = test_toolarge.$(OBJEXT) test_toolarge_url_OBJECTS = $(am_test_toolarge_url_OBJECTS) test_toolarge_url_LDADD = $(LDADD) test_toolarge_url_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_tricky_header2_OBJECTS = test_tricky.$(OBJEXT) test_tricky_header2_OBJECTS = $(am_test_tricky_header2_OBJECTS) test_tricky_header2_LDADD = $(LDADD) test_tricky_header2_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_tricky_url_OBJECTS = test_tricky.$(OBJEXT) test_tricky_url_OBJECTS = $(am_test_tricky_url_OBJECTS) test_tricky_url_LDADD = $(LDADD) test_tricky_url_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_urlparse_OBJECTS = test_urlparse.$(OBJEXT) test_urlparse_OBJECTS = $(am_test_urlparse_OBJECTS) test_urlparse_LDADD = $(LDADD) test_urlparse_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/perf_get.Po \ ./$(DEPDIR)/perf_get_concurrent-perf_get_concurrent.Po \ ./$(DEPDIR)/perf_get_concurrent11-perf_get_concurrent.Po \ ./$(DEPDIR)/test_add_conn-test_add_conn.Po \ ./$(DEPDIR)/test_add_conn_cleanup-test_add_conn.Po \ ./$(DEPDIR)/test_add_conn_cleanup_nolisten-test_add_conn.Po \ ./$(DEPDIR)/test_add_conn_nolisten-test_add_conn.Po \ ./$(DEPDIR)/test_basicauth.Po ./$(DEPDIR)/test_callback.Po \ ./$(DEPDIR)/test_concurrent_stop-test_concurrent_stop.Po \ ./$(DEPDIR)/test_delete.Po ./$(DEPDIR)/test_digestauth.Po \ ./$(DEPDIR)/test_digestauth2.Po \ ./$(DEPDIR)/test_digestauth_concurrent-test_digestauth_concurrent.Po \ ./$(DEPDIR)/test_digestauth_emu_ext.Po \ ./$(DEPDIR)/test_digestauth_sha256.Po \ ./$(DEPDIR)/test_digestauth_with_arguments.Po \ ./$(DEPDIR)/test_get.Po ./$(DEPDIR)/test_get_chunked.Po \ ./$(DEPDIR)/test_get_close_keep_alive.Po \ ./$(DEPDIR)/test_get_iovec.Po \ ./$(DEPDIR)/test_get_response_cleanup.Po \ ./$(DEPDIR)/test_get_sendfile.Po \ ./$(DEPDIR)/test_get_wait-test_get_wait.Po \ ./$(DEPDIR)/test_get_wait11-test_get_wait.Po \ ./$(DEPDIR)/test_head.Po ./$(DEPDIR)/test_iplimit.Po \ ./$(DEPDIR)/test_large_put.Po ./$(DEPDIR)/test_long_header.Po \ ./$(DEPDIR)/test_parse_cookies.Po ./$(DEPDIR)/test_patch.Po \ ./$(DEPDIR)/test_post.Po ./$(DEPDIR)/test_post_loop.Po \ ./$(DEPDIR)/test_postform.Po \ ./$(DEPDIR)/test_process_arguments.Po \ ./$(DEPDIR)/test_process_headers.Po ./$(DEPDIR)/test_put.Po \ ./$(DEPDIR)/test_put_broken_len.Po \ ./$(DEPDIR)/test_put_chunked.Po \ ./$(DEPDIR)/test_put_header_fold.Po \ ./$(DEPDIR)/test_quiesce-test_quiesce.Po \ ./$(DEPDIR)/test_quiesce_stream-test_quiesce_stream.Po \ ./$(DEPDIR)/test_termination.Po ./$(DEPDIR)/test_timeout.Po \ ./$(DEPDIR)/test_toolarge.Po ./$(DEPDIR)/test_tricky.Po \ ./$(DEPDIR)/test_urlparse.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(perf_get_SOURCES) $(perf_get_concurrent_SOURCES) \ $(perf_get_concurrent11_SOURCES) $(test_add_conn_SOURCES) \ $(test_add_conn_cleanup_SOURCES) \ $(test_add_conn_cleanup_nolisten_SOURCES) \ $(test_add_conn_nolisten_SOURCES) $(test_basicauth_SOURCES) \ $(test_basicauth_oldapi_SOURCES) \ $(test_basicauth_preauth_SOURCES) \ $(test_basicauth_preauth_oldapi_SOURCES) \ $(test_callback_SOURCES) $(test_concurrent_stop_SOURCES) \ $(test_delete_SOURCES) $(test_digestauth_SOURCES) \ $(test_digestauth2_SOURCES) \ $(test_digestauth2_bind_all_SOURCES) \ $(test_digestauth2_bind_uri_SOURCES) \ $(test_digestauth2_oldapi1_SOURCES) \ $(test_digestauth2_oldapi1_bind_all_SOURCES) \ $(test_digestauth2_oldapi1_bind_uri_SOURCES) \ $(test_digestauth2_oldapi1_userdigest_SOURCES) \ $(test_digestauth2_oldapi2_SOURCES) \ $(test_digestauth2_oldapi2_sha256_SOURCES) \ $(test_digestauth2_oldapi2_sha256_userdigest_SOURCES) \ $(test_digestauth2_oldapi2_userdigest_SOURCES) \ $(test_digestauth2_rfc2069_SOURCES) \ $(test_digestauth2_rfc2069_userdigest_SOURCES) \ $(test_digestauth2_sha256_SOURCES) \ $(test_digestauth2_sha256_userdigest_SOURCES) \ $(test_digestauth2_sha256_userhash_SOURCES) \ $(test_digestauth2_sha256_userhash_userdigest_SOURCES) \ $(test_digestauth2_userdigest_SOURCES) \ $(test_digestauth2_userhash_SOURCES) \ $(test_digestauth2_userhash_userdigest_SOURCES) \ $(test_digestauth_concurrent_SOURCES) \ $(test_digestauth_emu_ext_SOURCES) \ $(test_digestauth_emu_ext_oldapi_SOURCES) \ $(test_digestauth_sha256_SOURCES) \ $(test_digestauth_with_arguments_SOURCES) $(test_get_SOURCES) \ $(test_get11_SOURCES) $(test_get_chunked_SOURCES) \ $(test_get_chunked_close_SOURCES) \ $(test_get_chunked_close_empty_SOURCES) \ $(test_get_chunked_close_empty_forced_SOURCES) \ $(test_get_chunked_close_empty_sized_SOURCES) \ $(test_get_chunked_close_forced_SOURCES) \ $(test_get_chunked_close_sized_SOURCES) \ $(test_get_chunked_close_string_SOURCES) \ $(test_get_chunked_close_string_empty_SOURCES) \ $(test_get_chunked_empty_SOURCES) \ $(test_get_chunked_empty_forced_SOURCES) \ $(test_get_chunked_empty_sized_SOURCES) \ $(test_get_chunked_forced_SOURCES) \ $(test_get_chunked_sized_SOURCES) \ $(test_get_chunked_string_SOURCES) \ $(test_get_chunked_string_empty_SOURCES) \ $(test_get_close_SOURCES) $(test_get_close10_SOURCES) \ $(test_get_header_double_fold_SOURCES) \ $(test_get_header_fold_SOURCES) $(test_get_iovec_SOURCES) \ $(test_get_iovec11_SOURCES) $(test_get_keep_alive_SOURCES) \ $(test_get_keep_alive10_SOURCES) \ $(test_get_response_cleanup_SOURCES) \ $(test_get_sendfile_SOURCES) $(test_get_sendfile11_SOURCES) \ $(test_get_wait_SOURCES) $(test_get_wait11_SOURCES) \ $(test_head_SOURCES) $(test_head10_SOURCES) \ $(test_iplimit11_SOURCES) $(test_large_put_SOURCES) \ $(test_large_put11_SOURCES) $(test_large_put_inc11_SOURCES) \ $(test_long_header_SOURCES) $(test_long_header11_SOURCES) \ $(test_parse_cookies_discp_n2_SOURCES) \ $(test_parse_cookies_discp_n3_SOURCES) \ $(test_parse_cookies_discp_p1_SOURCES) \ $(test_parse_cookies_discp_p2_SOURCES) \ $(test_parse_cookies_discp_zero_SOURCES) $(test_patch_SOURCES) \ $(test_patch11_SOURCES) $(test_post_SOURCES) \ $(test_post11_SOURCES) $(test_post_loop_SOURCES) \ $(test_post_loop11_SOURCES) $(test_postform_SOURCES) \ $(test_postform11_SOURCES) $(test_process_arguments_SOURCES) \ $(test_process_headers_SOURCES) $(test_put_SOURCES) \ $(test_put11_SOURCES) $(test_put_broken_len_SOURCES) \ $(test_put_broken_len10_SOURCES) $(test_put_chunked_SOURCES) \ $(test_put_header_double_fold_SOURCES) \ $(test_put_header_double_fold_large_SOURCES) \ $(test_put_header_double_fold_last_SOURCES) \ $(test_put_header_fold_SOURCES) \ $(test_put_header_fold_large_SOURCES) \ $(test_put_header_fold_last_SOURCES) \ $(test_put_large_header_double_fold_SOURCES) \ $(test_put_large_header_fold_SOURCES) $(test_quiesce_SOURCES) \ $(test_quiesce_stream_SOURCES) $(test_termination_SOURCES) \ $(test_timeout_SOURCES) $(test_toolarge_method_SOURCES) \ $(test_toolarge_reply_header_name_SOURCES) \ $(test_toolarge_reply_header_value_SOURCES) \ $(test_toolarge_reply_headers_SOURCES) \ $(test_toolarge_request_header_name_SOURCES) \ $(test_toolarge_request_header_value_SOURCES) \ $(test_toolarge_request_headers_SOURCES) \ $(test_toolarge_url_SOURCES) $(test_tricky_header2_SOURCES) \ $(test_tricky_url_SOURCES) $(test_urlparse_SOURCES) DIST_SOURCES = $(perf_get_SOURCES) $(perf_get_concurrent_SOURCES) \ $(perf_get_concurrent11_SOURCES) $(test_add_conn_SOURCES) \ $(test_add_conn_cleanup_SOURCES) \ $(test_add_conn_cleanup_nolisten_SOURCES) \ $(test_add_conn_nolisten_SOURCES) $(test_basicauth_SOURCES) \ $(test_basicauth_oldapi_SOURCES) \ $(test_basicauth_preauth_SOURCES) \ $(test_basicauth_preauth_oldapi_SOURCES) \ $(test_callback_SOURCES) $(test_concurrent_stop_SOURCES) \ $(test_delete_SOURCES) $(test_digestauth_SOURCES) \ $(test_digestauth2_SOURCES) \ $(test_digestauth2_bind_all_SOURCES) \ $(test_digestauth2_bind_uri_SOURCES) \ $(test_digestauth2_oldapi1_SOURCES) \ $(test_digestauth2_oldapi1_bind_all_SOURCES) \ $(test_digestauth2_oldapi1_bind_uri_SOURCES) \ $(test_digestauth2_oldapi1_userdigest_SOURCES) \ $(test_digestauth2_oldapi2_SOURCES) \ $(test_digestauth2_oldapi2_sha256_SOURCES) \ $(test_digestauth2_oldapi2_sha256_userdigest_SOURCES) \ $(test_digestauth2_oldapi2_userdigest_SOURCES) \ $(test_digestauth2_rfc2069_SOURCES) \ $(test_digestauth2_rfc2069_userdigest_SOURCES) \ $(test_digestauth2_sha256_SOURCES) \ $(test_digestauth2_sha256_userdigest_SOURCES) \ $(test_digestauth2_sha256_userhash_SOURCES) \ $(test_digestauth2_sha256_userhash_userdigest_SOURCES) \ $(test_digestauth2_userdigest_SOURCES) \ $(test_digestauth2_userhash_SOURCES) \ $(test_digestauth2_userhash_userdigest_SOURCES) \ $(test_digestauth_concurrent_SOURCES) \ $(test_digestauth_emu_ext_SOURCES) \ $(test_digestauth_emu_ext_oldapi_SOURCES) \ $(test_digestauth_sha256_SOURCES) \ $(test_digestauth_with_arguments_SOURCES) $(test_get_SOURCES) \ $(test_get11_SOURCES) $(test_get_chunked_SOURCES) \ $(test_get_chunked_close_SOURCES) \ $(test_get_chunked_close_empty_SOURCES) \ $(test_get_chunked_close_empty_forced_SOURCES) \ $(test_get_chunked_close_empty_sized_SOURCES) \ $(test_get_chunked_close_forced_SOURCES) \ $(test_get_chunked_close_sized_SOURCES) \ $(test_get_chunked_close_string_SOURCES) \ $(test_get_chunked_close_string_empty_SOURCES) \ $(test_get_chunked_empty_SOURCES) \ $(test_get_chunked_empty_forced_SOURCES) \ $(test_get_chunked_empty_sized_SOURCES) \ $(test_get_chunked_forced_SOURCES) \ $(test_get_chunked_sized_SOURCES) \ $(test_get_chunked_string_SOURCES) \ $(test_get_chunked_string_empty_SOURCES) \ $(test_get_close_SOURCES) $(test_get_close10_SOURCES) \ $(test_get_header_double_fold_SOURCES) \ $(test_get_header_fold_SOURCES) $(test_get_iovec_SOURCES) \ $(test_get_iovec11_SOURCES) $(test_get_keep_alive_SOURCES) \ $(test_get_keep_alive10_SOURCES) \ $(test_get_response_cleanup_SOURCES) \ $(test_get_sendfile_SOURCES) $(test_get_sendfile11_SOURCES) \ $(test_get_wait_SOURCES) $(test_get_wait11_SOURCES) \ $(test_head_SOURCES) $(test_head10_SOURCES) \ $(test_iplimit11_SOURCES) $(test_large_put_SOURCES) \ $(test_large_put11_SOURCES) $(test_large_put_inc11_SOURCES) \ $(test_long_header_SOURCES) $(test_long_header11_SOURCES) \ $(test_parse_cookies_discp_n2_SOURCES) \ $(test_parse_cookies_discp_n3_SOURCES) \ $(test_parse_cookies_discp_p1_SOURCES) \ $(test_parse_cookies_discp_p2_SOURCES) \ $(test_parse_cookies_discp_zero_SOURCES) $(test_patch_SOURCES) \ $(test_patch11_SOURCES) $(test_post_SOURCES) \ $(test_post11_SOURCES) $(test_post_loop_SOURCES) \ $(test_post_loop11_SOURCES) $(test_postform_SOURCES) \ $(test_postform11_SOURCES) $(test_process_arguments_SOURCES) \ $(test_process_headers_SOURCES) $(test_put_SOURCES) \ $(test_put11_SOURCES) $(test_put_broken_len_SOURCES) \ $(test_put_broken_len10_SOURCES) $(test_put_chunked_SOURCES) \ $(test_put_header_double_fold_SOURCES) \ $(test_put_header_double_fold_large_SOURCES) \ $(test_put_header_double_fold_last_SOURCES) \ $(test_put_header_fold_SOURCES) \ $(test_put_header_fold_large_SOURCES) \ $(test_put_header_fold_last_SOURCES) \ $(test_put_large_header_double_fold_SOURCES) \ $(test_put_large_header_fold_SOURCES) $(test_quiesce_SOURCES) \ $(test_quiesce_stream_SOURCES) $(test_termination_SOURCES) \ $(test_timeout_SOURCES) $(test_toolarge_method_SOURCES) \ $(test_toolarge_reply_header_name_SOURCES) \ $(test_toolarge_reply_header_value_SOURCES) \ $(test_toolarge_reply_headers_SOURCES) \ $(test_toolarge_request_header_name_SOURCES) \ $(test_toolarge_request_header_value_SOURCES) \ $(test_toolarge_request_headers_SOURCES) \ $(test_toolarge_url_SOURCES) $(test_tricky_header2_SOURCES) \ $(test_tricky_url_SOURCES) $(test_urlparse_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ check recheck distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' RECHECK_LOGS = $(TEST_LOGS) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) DIST_SUBDIRS = . https am__DIST_COMMON = $(srcdir)/Makefile.in \ $(top_srcdir)/build-aux/depcomp \ $(top_srcdir)/build-aux/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # This Makefile.am is in the public domain EMPTY_ITEM = SUBDIRS = . $(am__append_2) AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/microhttpd \ -DMHD_CPU_COUNT=$(CPU_COUNT) \ $(CPPFLAGS_ac) $(LIBCURL_CPPFLAGS) AM_CFLAGS = $(CFLAGS_ac) @LIBGCRYPT_CFLAGS@ $(am__append_1) AM_LDFLAGS = $(LDFLAGS_ac) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ @LIBCURL@ THREAD_ONLY_TESTS = test_urlparse test_long_header test_long_header11 \ test_iplimit11 test_termination $(EMPTY_ITEM) $(am__append_3) \ $(am__append_4) $(am__append_5) $(am__append_6) \ $(am__append_7) $(am__append_8) $(am__append_13) \ $(am__append_14) @RUN_LIBCURL_TESTS_TRUE@TESTS = $(check_PROGRAMS) test_concurrent_stop_SOURCES = \ test_concurrent_stop.c test_concurrent_stop_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_concurrent_stop_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_get_SOURCES = \ test_get.c mhd_has_in_name.h mhd_has_param.h test_head_SOURCES = \ test_head.c mhd_has_in_name.h mhd_has_param.h test_head10_SOURCES = \ test_head.c mhd_has_in_name.h mhd_has_param.h test_quiesce_SOURCES = \ test_quiesce.c mhd_has_param.h mhd_has_in_name.h test_quiesce_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_quiesce_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_quiesce_stream_SOURCES = \ test_quiesce_stream.c test_quiesce_stream_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_quiesce_stream_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_callback_SOURCES = \ test_callback.c perf_get_SOURCES = \ perf_get.c \ mhd_has_in_name.h perf_get_concurrent_SOURCES = \ perf_get_concurrent.c \ mhd_has_in_name.h perf_get_concurrent_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) perf_get_concurrent_LDADD = \ $(PTHREAD_LIBS) $(LDADD) perf_get_concurrent11_SOURCES = \ perf_get_concurrent.c \ mhd_has_in_name.h perf_get_concurrent11_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) perf_get_concurrent11_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_basicauth_SOURCES = \ test_basicauth.c test_basicauth_preauth_SOURCES = \ test_basicauth.c test_basicauth_oldapi_SOURCES = \ test_basicauth.c test_basicauth_preauth_oldapi_SOURCES = \ test_basicauth.c test_digestauth_SOURCES = \ test_digestauth.c test_digestauth_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) test_digestauth_sha256_SOURCES = \ test_digestauth_sha256.c test_digestauth_sha256_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) test_digestauth_with_arguments_SOURCES = \ test_digestauth_with_arguments.c test_digestauth_with_arguments_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) test_digestauth_concurrent_SOURCES = \ test_digestauth_concurrent.c test_digestauth_concurrent_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_digestauth_concurrent_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) $(PTHREAD_LIBS) $(LDADD) test_digestauth_emu_ext_SOURCES = \ test_digestauth_emu_ext.c test_digestauth_emu_ext_oldapi_SOURCES = \ test_digestauth_emu_ext.c test_digestauth2_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_rfc2069_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_rfc2069_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi1_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi2_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_userhash_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_sha256_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi2_sha256_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_sha256_userhash_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi1_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi2_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_userhash_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_sha256_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi2_sha256_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_sha256_userhash_userdigest_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_bind_all_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_bind_uri_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi1_bind_all_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_digestauth2_oldapi1_bind_uri_SOURCES = \ test_digestauth2.c mhd_has_param.h mhd_has_in_name.h test_get_iovec_SOURCES = \ test_get_iovec.c mhd_has_in_name.h test_get_sendfile_SOURCES = \ test_get_sendfile.c mhd_has_in_name.h test_get_wait_SOURCES = \ test_get_wait.c \ mhd_has_in_name.h test_get_wait_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_get_wait_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_get_wait11_SOURCES = \ test_get_wait.c \ mhd_has_in_name.h test_get_wait11_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_get_wait11_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_urlparse_SOURCES = \ test_urlparse.c mhd_has_in_name.h test_get_response_cleanup_SOURCES = \ test_get_response_cleanup.c mhd_has_in_name.h test_get_chunked_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_string_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_string_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_empty_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_empty_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_string_empty_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_string_empty_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_sized_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_sized_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_empty_sized_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_empty_sized_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_forced_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_forced_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_empty_forced_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_get_chunked_close_empty_forced_SOURCES = \ test_get_chunked.c mhd_has_in_name.h test_post_SOURCES = \ test_post.c mhd_has_in_name.h test_process_headers_SOURCES = \ test_process_headers.c mhd_has_in_name.h test_parse_cookies_discp_zero_SOURCES = \ test_parse_cookies.c mhd_has_in_name.h mhd_has_param.h test_parse_cookies_discp_p2_SOURCES = \ $(test_parse_cookies_discp_zero_SOURCES) test_parse_cookies_discp_p1_SOURCES = \ $(test_parse_cookies_discp_zero_SOURCES) test_parse_cookies_discp_n2_SOURCES = \ $(test_parse_cookies_discp_zero_SOURCES) test_parse_cookies_discp_n3_SOURCES = \ $(test_parse_cookies_discp_zero_SOURCES) test_process_arguments_SOURCES = \ test_process_arguments.c mhd_has_in_name.h test_postform_SOURCES = \ test_postform.c mhd_has_in_name.h test_postform_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) test_post_loop_SOURCES = \ test_post_loop.c mhd_has_in_name.h test_delete_SOURCES = \ test_delete.c mhd_has_in_name.h test_patch_SOURCES = \ test_patch.c mhd_has_in_name.h test_patch11_SOURCES = \ test_patch.c mhd_has_in_name.h test_put_SOURCES = \ test_put.c mhd_has_in_name.h test_put_chunked_SOURCES = \ test_put_chunked.c test_add_conn_SOURCES = \ test_add_conn.c mhd_has_in_name.h mhd_has_param.h test_add_conn_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_add_conn_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_add_conn_nolisten_SOURCES = \ test_add_conn.c mhd_has_in_name.h mhd_has_param.h test_add_conn_nolisten_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_add_conn_nolisten_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_add_conn_cleanup_SOURCES = \ test_add_conn.c mhd_has_in_name.h mhd_has_param.h test_add_conn_cleanup_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_add_conn_cleanup_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_add_conn_cleanup_nolisten_SOURCES = \ test_add_conn.c mhd_has_in_name.h mhd_has_param.h test_add_conn_cleanup_nolisten_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) test_add_conn_cleanup_nolisten_LDADD = \ $(PTHREAD_LIBS) $(LDADD) test_get11_SOURCES = \ test_get.c mhd_has_in_name.h mhd_has_param.h test_get_iovec11_SOURCES = \ test_get_iovec.c mhd_has_in_name.h test_get_sendfile11_SOURCES = \ test_get_sendfile.c mhd_has_in_name.h test_get_close_SOURCES = \ test_get_close_keep_alive.c mhd_has_in_name.h mhd_has_param.h test_get_close10_SOURCES = \ test_get_close_keep_alive.c mhd_has_in_name.h mhd_has_param.h test_get_keep_alive_SOURCES = \ test_get_close_keep_alive.c mhd_has_in_name.h mhd_has_param.h test_get_keep_alive10_SOURCES = \ test_get_close_keep_alive.c mhd_has_in_name.h mhd_has_param.h test_post11_SOURCES = \ test_post.c mhd_has_in_name.h test_postform11_SOURCES = \ test_postform.c mhd_has_in_name.h test_postform11_LDADD = \ @LIBGCRYPT_LIBS@ $(LDADD) test_post_loop11_SOURCES = \ test_post_loop.c mhd_has_in_name.h test_put11_SOURCES = \ test_put.c mhd_has_in_name.h test_large_put_SOURCES = \ test_large_put.c mhd_has_in_name.h mhd_has_param.h test_large_put11_SOURCES = \ test_large_put.c mhd_has_in_name.h mhd_has_param.h test_large_put_inc11_SOURCES = \ test_large_put.c mhd_has_in_name.h mhd_has_param.h test_long_header_SOURCES = \ test_long_header.c mhd_has_in_name.h test_long_header11_SOURCES = \ test_long_header.c mhd_has_in_name.h test_iplimit11_SOURCES = \ test_iplimit.c mhd_has_in_name.h test_termination_SOURCES = \ test_termination.c test_timeout_SOURCES = \ test_timeout.c mhd_has_in_name.h test_toolarge_method_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_url_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_request_header_name_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_request_header_value_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_request_headers_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_reply_header_name_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_reply_header_value_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_toolarge_reply_headers_SOURCES = \ test_toolarge.c mhd_has_in_name.h mhd_has_param.h test_tricky_url_SOURCES = \ test_tricky.c mhd_has_in_name.h mhd_has_param.h test_tricky_header2_SOURCES = \ test_tricky.c mhd_has_in_name.h mhd_has_param.h test_put_broken_len_SOURCES = \ test_put_broken_len.c mhd_has_in_name.h mhd_has_param.h test_put_broken_len10_SOURCES = $(test_put_broken_len_SOURCES) test_put_header_fold_SOURCES = \ test_put_header_fold.c mhd_has_in_name.h mhd_has_param.h test_put_large_header_fold_SOURCES = $(test_put_header_fold_SOURCES) test_get_header_fold_SOURCES = $(test_put_header_fold_SOURCES) test_put_header_fold_last_SOURCES = $(test_put_header_fold_SOURCES) test_put_header_fold_large_SOURCES = $(test_put_header_fold_SOURCES) test_put_header_double_fold_SOURCES = $(test_put_header_fold_SOURCES) test_put_large_header_double_fold_SOURCES = $(test_put_large_header_fold_SOURCES) test_get_header_double_fold_SOURCES = $(test_put_header_fold_SOURCES) test_put_header_double_fold_last_SOURCES = $(test_put_header_fold_last_SOURCES) test_put_header_double_fold_large_SOURCES = $(test_put_header_fold_large_SOURCES) all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/testcurl/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/testcurl/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list perf_get$(EXEEXT): $(perf_get_OBJECTS) $(perf_get_DEPENDENCIES) $(EXTRA_perf_get_DEPENDENCIES) @rm -f perf_get$(EXEEXT) $(AM_V_CCLD)$(LINK) $(perf_get_OBJECTS) $(perf_get_LDADD) $(LIBS) perf_get_concurrent$(EXEEXT): $(perf_get_concurrent_OBJECTS) $(perf_get_concurrent_DEPENDENCIES) $(EXTRA_perf_get_concurrent_DEPENDENCIES) @rm -f perf_get_concurrent$(EXEEXT) $(AM_V_CCLD)$(perf_get_concurrent_LINK) $(perf_get_concurrent_OBJECTS) $(perf_get_concurrent_LDADD) $(LIBS) perf_get_concurrent11$(EXEEXT): $(perf_get_concurrent11_OBJECTS) $(perf_get_concurrent11_DEPENDENCIES) $(EXTRA_perf_get_concurrent11_DEPENDENCIES) @rm -f perf_get_concurrent11$(EXEEXT) $(AM_V_CCLD)$(perf_get_concurrent11_LINK) $(perf_get_concurrent11_OBJECTS) $(perf_get_concurrent11_LDADD) $(LIBS) test_add_conn$(EXEEXT): $(test_add_conn_OBJECTS) $(test_add_conn_DEPENDENCIES) $(EXTRA_test_add_conn_DEPENDENCIES) @rm -f test_add_conn$(EXEEXT) $(AM_V_CCLD)$(test_add_conn_LINK) $(test_add_conn_OBJECTS) $(test_add_conn_LDADD) $(LIBS) test_add_conn_cleanup$(EXEEXT): $(test_add_conn_cleanup_OBJECTS) $(test_add_conn_cleanup_DEPENDENCIES) $(EXTRA_test_add_conn_cleanup_DEPENDENCIES) @rm -f test_add_conn_cleanup$(EXEEXT) $(AM_V_CCLD)$(test_add_conn_cleanup_LINK) $(test_add_conn_cleanup_OBJECTS) $(test_add_conn_cleanup_LDADD) $(LIBS) test_add_conn_cleanup_nolisten$(EXEEXT): $(test_add_conn_cleanup_nolisten_OBJECTS) $(test_add_conn_cleanup_nolisten_DEPENDENCIES) $(EXTRA_test_add_conn_cleanup_nolisten_DEPENDENCIES) @rm -f test_add_conn_cleanup_nolisten$(EXEEXT) $(AM_V_CCLD)$(test_add_conn_cleanup_nolisten_LINK) $(test_add_conn_cleanup_nolisten_OBJECTS) $(test_add_conn_cleanup_nolisten_LDADD) $(LIBS) test_add_conn_nolisten$(EXEEXT): $(test_add_conn_nolisten_OBJECTS) $(test_add_conn_nolisten_DEPENDENCIES) $(EXTRA_test_add_conn_nolisten_DEPENDENCIES) @rm -f test_add_conn_nolisten$(EXEEXT) $(AM_V_CCLD)$(test_add_conn_nolisten_LINK) $(test_add_conn_nolisten_OBJECTS) $(test_add_conn_nolisten_LDADD) $(LIBS) test_basicauth$(EXEEXT): $(test_basicauth_OBJECTS) $(test_basicauth_DEPENDENCIES) $(EXTRA_test_basicauth_DEPENDENCIES) @rm -f test_basicauth$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_basicauth_OBJECTS) $(test_basicauth_LDADD) $(LIBS) test_basicauth_oldapi$(EXEEXT): $(test_basicauth_oldapi_OBJECTS) $(test_basicauth_oldapi_DEPENDENCIES) $(EXTRA_test_basicauth_oldapi_DEPENDENCIES) @rm -f test_basicauth_oldapi$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_basicauth_oldapi_OBJECTS) $(test_basicauth_oldapi_LDADD) $(LIBS) test_basicauth_preauth$(EXEEXT): $(test_basicauth_preauth_OBJECTS) $(test_basicauth_preauth_DEPENDENCIES) $(EXTRA_test_basicauth_preauth_DEPENDENCIES) @rm -f test_basicauth_preauth$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_basicauth_preauth_OBJECTS) $(test_basicauth_preauth_LDADD) $(LIBS) test_basicauth_preauth_oldapi$(EXEEXT): $(test_basicauth_preauth_oldapi_OBJECTS) $(test_basicauth_preauth_oldapi_DEPENDENCIES) $(EXTRA_test_basicauth_preauth_oldapi_DEPENDENCIES) @rm -f test_basicauth_preauth_oldapi$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_basicauth_preauth_oldapi_OBJECTS) $(test_basicauth_preauth_oldapi_LDADD) $(LIBS) test_callback$(EXEEXT): $(test_callback_OBJECTS) $(test_callback_DEPENDENCIES) $(EXTRA_test_callback_DEPENDENCIES) @rm -f test_callback$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_callback_OBJECTS) $(test_callback_LDADD) $(LIBS) test_concurrent_stop$(EXEEXT): $(test_concurrent_stop_OBJECTS) $(test_concurrent_stop_DEPENDENCIES) $(EXTRA_test_concurrent_stop_DEPENDENCIES) @rm -f test_concurrent_stop$(EXEEXT) $(AM_V_CCLD)$(test_concurrent_stop_LINK) $(test_concurrent_stop_OBJECTS) $(test_concurrent_stop_LDADD) $(LIBS) test_delete$(EXEEXT): $(test_delete_OBJECTS) $(test_delete_DEPENDENCIES) $(EXTRA_test_delete_DEPENDENCIES) @rm -f test_delete$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_delete_OBJECTS) $(test_delete_LDADD) $(LIBS) test_digestauth$(EXEEXT): $(test_digestauth_OBJECTS) $(test_digestauth_DEPENDENCIES) $(EXTRA_test_digestauth_DEPENDENCIES) @rm -f test_digestauth$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth_OBJECTS) $(test_digestauth_LDADD) $(LIBS) test_digestauth2$(EXEEXT): $(test_digestauth2_OBJECTS) $(test_digestauth2_DEPENDENCIES) $(EXTRA_test_digestauth2_DEPENDENCIES) @rm -f test_digestauth2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_OBJECTS) $(test_digestauth2_LDADD) $(LIBS) test_digestauth2_bind_all$(EXEEXT): $(test_digestauth2_bind_all_OBJECTS) $(test_digestauth2_bind_all_DEPENDENCIES) $(EXTRA_test_digestauth2_bind_all_DEPENDENCIES) @rm -f test_digestauth2_bind_all$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_bind_all_OBJECTS) $(test_digestauth2_bind_all_LDADD) $(LIBS) test_digestauth2_bind_uri$(EXEEXT): $(test_digestauth2_bind_uri_OBJECTS) $(test_digestauth2_bind_uri_DEPENDENCIES) $(EXTRA_test_digestauth2_bind_uri_DEPENDENCIES) @rm -f test_digestauth2_bind_uri$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_bind_uri_OBJECTS) $(test_digestauth2_bind_uri_LDADD) $(LIBS) test_digestauth2_oldapi1$(EXEEXT): $(test_digestauth2_oldapi1_OBJECTS) $(test_digestauth2_oldapi1_DEPENDENCIES) $(EXTRA_test_digestauth2_oldapi1_DEPENDENCIES) @rm -f test_digestauth2_oldapi1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_oldapi1_OBJECTS) $(test_digestauth2_oldapi1_LDADD) $(LIBS) test_digestauth2_oldapi1_bind_all$(EXEEXT): $(test_digestauth2_oldapi1_bind_all_OBJECTS) $(test_digestauth2_oldapi1_bind_all_DEPENDENCIES) $(EXTRA_test_digestauth2_oldapi1_bind_all_DEPENDENCIES) @rm -f test_digestauth2_oldapi1_bind_all$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_oldapi1_bind_all_OBJECTS) $(test_digestauth2_oldapi1_bind_all_LDADD) $(LIBS) test_digestauth2_oldapi1_bind_uri$(EXEEXT): $(test_digestauth2_oldapi1_bind_uri_OBJECTS) $(test_digestauth2_oldapi1_bind_uri_DEPENDENCIES) $(EXTRA_test_digestauth2_oldapi1_bind_uri_DEPENDENCIES) @rm -f test_digestauth2_oldapi1_bind_uri$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_oldapi1_bind_uri_OBJECTS) $(test_digestauth2_oldapi1_bind_uri_LDADD) $(LIBS) test_digestauth2_oldapi1_userdigest$(EXEEXT): $(test_digestauth2_oldapi1_userdigest_OBJECTS) $(test_digestauth2_oldapi1_userdigest_DEPENDENCIES) $(EXTRA_test_digestauth2_oldapi1_userdigest_DEPENDENCIES) @rm -f test_digestauth2_oldapi1_userdigest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_oldapi1_userdigest_OBJECTS) $(test_digestauth2_oldapi1_userdigest_LDADD) $(LIBS) test_digestauth2_oldapi2$(EXEEXT): $(test_digestauth2_oldapi2_OBJECTS) $(test_digestauth2_oldapi2_DEPENDENCIES) $(EXTRA_test_digestauth2_oldapi2_DEPENDENCIES) @rm -f test_digestauth2_oldapi2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_oldapi2_OBJECTS) $(test_digestauth2_oldapi2_LDADD) $(LIBS) test_digestauth2_oldapi2_sha256$(EXEEXT): $(test_digestauth2_oldapi2_sha256_OBJECTS) $(test_digestauth2_oldapi2_sha256_DEPENDENCIES) $(EXTRA_test_digestauth2_oldapi2_sha256_DEPENDENCIES) @rm -f test_digestauth2_oldapi2_sha256$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_oldapi2_sha256_OBJECTS) $(test_digestauth2_oldapi2_sha256_LDADD) $(LIBS) test_digestauth2_oldapi2_sha256_userdigest$(EXEEXT): $(test_digestauth2_oldapi2_sha256_userdigest_OBJECTS) $(test_digestauth2_oldapi2_sha256_userdigest_DEPENDENCIES) $(EXTRA_test_digestauth2_oldapi2_sha256_userdigest_DEPENDENCIES) @rm -f test_digestauth2_oldapi2_sha256_userdigest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_oldapi2_sha256_userdigest_OBJECTS) $(test_digestauth2_oldapi2_sha256_userdigest_LDADD) $(LIBS) test_digestauth2_oldapi2_userdigest$(EXEEXT): $(test_digestauth2_oldapi2_userdigest_OBJECTS) $(test_digestauth2_oldapi2_userdigest_DEPENDENCIES) $(EXTRA_test_digestauth2_oldapi2_userdigest_DEPENDENCIES) @rm -f test_digestauth2_oldapi2_userdigest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_oldapi2_userdigest_OBJECTS) $(test_digestauth2_oldapi2_userdigest_LDADD) $(LIBS) test_digestauth2_rfc2069$(EXEEXT): $(test_digestauth2_rfc2069_OBJECTS) $(test_digestauth2_rfc2069_DEPENDENCIES) $(EXTRA_test_digestauth2_rfc2069_DEPENDENCIES) @rm -f test_digestauth2_rfc2069$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_rfc2069_OBJECTS) $(test_digestauth2_rfc2069_LDADD) $(LIBS) test_digestauth2_rfc2069_userdigest$(EXEEXT): $(test_digestauth2_rfc2069_userdigest_OBJECTS) $(test_digestauth2_rfc2069_userdigest_DEPENDENCIES) $(EXTRA_test_digestauth2_rfc2069_userdigest_DEPENDENCIES) @rm -f test_digestauth2_rfc2069_userdigest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_rfc2069_userdigest_OBJECTS) $(test_digestauth2_rfc2069_userdigest_LDADD) $(LIBS) test_digestauth2_sha256$(EXEEXT): $(test_digestauth2_sha256_OBJECTS) $(test_digestauth2_sha256_DEPENDENCIES) $(EXTRA_test_digestauth2_sha256_DEPENDENCIES) @rm -f test_digestauth2_sha256$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_sha256_OBJECTS) $(test_digestauth2_sha256_LDADD) $(LIBS) test_digestauth2_sha256_userdigest$(EXEEXT): $(test_digestauth2_sha256_userdigest_OBJECTS) $(test_digestauth2_sha256_userdigest_DEPENDENCIES) $(EXTRA_test_digestauth2_sha256_userdigest_DEPENDENCIES) @rm -f test_digestauth2_sha256_userdigest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_sha256_userdigest_OBJECTS) $(test_digestauth2_sha256_userdigest_LDADD) $(LIBS) test_digestauth2_sha256_userhash$(EXEEXT): $(test_digestauth2_sha256_userhash_OBJECTS) $(test_digestauth2_sha256_userhash_DEPENDENCIES) $(EXTRA_test_digestauth2_sha256_userhash_DEPENDENCIES) @rm -f test_digestauth2_sha256_userhash$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_sha256_userhash_OBJECTS) $(test_digestauth2_sha256_userhash_LDADD) $(LIBS) test_digestauth2_sha256_userhash_userdigest$(EXEEXT): $(test_digestauth2_sha256_userhash_userdigest_OBJECTS) $(test_digestauth2_sha256_userhash_userdigest_DEPENDENCIES) $(EXTRA_test_digestauth2_sha256_userhash_userdigest_DEPENDENCIES) @rm -f test_digestauth2_sha256_userhash_userdigest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_sha256_userhash_userdigest_OBJECTS) $(test_digestauth2_sha256_userhash_userdigest_LDADD) $(LIBS) test_digestauth2_userdigest$(EXEEXT): $(test_digestauth2_userdigest_OBJECTS) $(test_digestauth2_userdigest_DEPENDENCIES) $(EXTRA_test_digestauth2_userdigest_DEPENDENCIES) @rm -f test_digestauth2_userdigest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_userdigest_OBJECTS) $(test_digestauth2_userdigest_LDADD) $(LIBS) test_digestauth2_userhash$(EXEEXT): $(test_digestauth2_userhash_OBJECTS) $(test_digestauth2_userhash_DEPENDENCIES) $(EXTRA_test_digestauth2_userhash_DEPENDENCIES) @rm -f test_digestauth2_userhash$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_userhash_OBJECTS) $(test_digestauth2_userhash_LDADD) $(LIBS) test_digestauth2_userhash_userdigest$(EXEEXT): $(test_digestauth2_userhash_userdigest_OBJECTS) $(test_digestauth2_userhash_userdigest_DEPENDENCIES) $(EXTRA_test_digestauth2_userhash_userdigest_DEPENDENCIES) @rm -f test_digestauth2_userhash_userdigest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth2_userhash_userdigest_OBJECTS) $(test_digestauth2_userhash_userdigest_LDADD) $(LIBS) test_digestauth_concurrent$(EXEEXT): $(test_digestauth_concurrent_OBJECTS) $(test_digestauth_concurrent_DEPENDENCIES) $(EXTRA_test_digestauth_concurrent_DEPENDENCIES) @rm -f test_digestauth_concurrent$(EXEEXT) $(AM_V_CCLD)$(test_digestauth_concurrent_LINK) $(test_digestauth_concurrent_OBJECTS) $(test_digestauth_concurrent_LDADD) $(LIBS) test_digestauth_emu_ext$(EXEEXT): $(test_digestauth_emu_ext_OBJECTS) $(test_digestauth_emu_ext_DEPENDENCIES) $(EXTRA_test_digestauth_emu_ext_DEPENDENCIES) @rm -f test_digestauth_emu_ext$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth_emu_ext_OBJECTS) $(test_digestauth_emu_ext_LDADD) $(LIBS) test_digestauth_emu_ext_oldapi$(EXEEXT): $(test_digestauth_emu_ext_oldapi_OBJECTS) $(test_digestauth_emu_ext_oldapi_DEPENDENCIES) $(EXTRA_test_digestauth_emu_ext_oldapi_DEPENDENCIES) @rm -f test_digestauth_emu_ext_oldapi$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth_emu_ext_oldapi_OBJECTS) $(test_digestauth_emu_ext_oldapi_LDADD) $(LIBS) test_digestauth_sha256$(EXEEXT): $(test_digestauth_sha256_OBJECTS) $(test_digestauth_sha256_DEPENDENCIES) $(EXTRA_test_digestauth_sha256_DEPENDENCIES) @rm -f test_digestauth_sha256$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth_sha256_OBJECTS) $(test_digestauth_sha256_LDADD) $(LIBS) test_digestauth_with_arguments$(EXEEXT): $(test_digestauth_with_arguments_OBJECTS) $(test_digestauth_with_arguments_DEPENDENCIES) $(EXTRA_test_digestauth_with_arguments_DEPENDENCIES) @rm -f test_digestauth_with_arguments$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_digestauth_with_arguments_OBJECTS) $(test_digestauth_with_arguments_LDADD) $(LIBS) test_get$(EXEEXT): $(test_get_OBJECTS) $(test_get_DEPENDENCIES) $(EXTRA_test_get_DEPENDENCIES) @rm -f test_get$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_OBJECTS) $(test_get_LDADD) $(LIBS) test_get11$(EXEEXT): $(test_get11_OBJECTS) $(test_get11_DEPENDENCIES) $(EXTRA_test_get11_DEPENDENCIES) @rm -f test_get11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get11_OBJECTS) $(test_get11_LDADD) $(LIBS) test_get_chunked$(EXEEXT): $(test_get_chunked_OBJECTS) $(test_get_chunked_DEPENDENCIES) $(EXTRA_test_get_chunked_DEPENDENCIES) @rm -f test_get_chunked$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_OBJECTS) $(test_get_chunked_LDADD) $(LIBS) test_get_chunked_close$(EXEEXT): $(test_get_chunked_close_OBJECTS) $(test_get_chunked_close_DEPENDENCIES) $(EXTRA_test_get_chunked_close_DEPENDENCIES) @rm -f test_get_chunked_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_close_OBJECTS) $(test_get_chunked_close_LDADD) $(LIBS) test_get_chunked_close_empty$(EXEEXT): $(test_get_chunked_close_empty_OBJECTS) $(test_get_chunked_close_empty_DEPENDENCIES) $(EXTRA_test_get_chunked_close_empty_DEPENDENCIES) @rm -f test_get_chunked_close_empty$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_close_empty_OBJECTS) $(test_get_chunked_close_empty_LDADD) $(LIBS) test_get_chunked_close_empty_forced$(EXEEXT): $(test_get_chunked_close_empty_forced_OBJECTS) $(test_get_chunked_close_empty_forced_DEPENDENCIES) $(EXTRA_test_get_chunked_close_empty_forced_DEPENDENCIES) @rm -f test_get_chunked_close_empty_forced$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_close_empty_forced_OBJECTS) $(test_get_chunked_close_empty_forced_LDADD) $(LIBS) test_get_chunked_close_empty_sized$(EXEEXT): $(test_get_chunked_close_empty_sized_OBJECTS) $(test_get_chunked_close_empty_sized_DEPENDENCIES) $(EXTRA_test_get_chunked_close_empty_sized_DEPENDENCIES) @rm -f test_get_chunked_close_empty_sized$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_close_empty_sized_OBJECTS) $(test_get_chunked_close_empty_sized_LDADD) $(LIBS) test_get_chunked_close_forced$(EXEEXT): $(test_get_chunked_close_forced_OBJECTS) $(test_get_chunked_close_forced_DEPENDENCIES) $(EXTRA_test_get_chunked_close_forced_DEPENDENCIES) @rm -f test_get_chunked_close_forced$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_close_forced_OBJECTS) $(test_get_chunked_close_forced_LDADD) $(LIBS) test_get_chunked_close_sized$(EXEEXT): $(test_get_chunked_close_sized_OBJECTS) $(test_get_chunked_close_sized_DEPENDENCIES) $(EXTRA_test_get_chunked_close_sized_DEPENDENCIES) @rm -f test_get_chunked_close_sized$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_close_sized_OBJECTS) $(test_get_chunked_close_sized_LDADD) $(LIBS) test_get_chunked_close_string$(EXEEXT): $(test_get_chunked_close_string_OBJECTS) $(test_get_chunked_close_string_DEPENDENCIES) $(EXTRA_test_get_chunked_close_string_DEPENDENCIES) @rm -f test_get_chunked_close_string$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_close_string_OBJECTS) $(test_get_chunked_close_string_LDADD) $(LIBS) test_get_chunked_close_string_empty$(EXEEXT): $(test_get_chunked_close_string_empty_OBJECTS) $(test_get_chunked_close_string_empty_DEPENDENCIES) $(EXTRA_test_get_chunked_close_string_empty_DEPENDENCIES) @rm -f test_get_chunked_close_string_empty$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_close_string_empty_OBJECTS) $(test_get_chunked_close_string_empty_LDADD) $(LIBS) test_get_chunked_empty$(EXEEXT): $(test_get_chunked_empty_OBJECTS) $(test_get_chunked_empty_DEPENDENCIES) $(EXTRA_test_get_chunked_empty_DEPENDENCIES) @rm -f test_get_chunked_empty$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_empty_OBJECTS) $(test_get_chunked_empty_LDADD) $(LIBS) test_get_chunked_empty_forced$(EXEEXT): $(test_get_chunked_empty_forced_OBJECTS) $(test_get_chunked_empty_forced_DEPENDENCIES) $(EXTRA_test_get_chunked_empty_forced_DEPENDENCIES) @rm -f test_get_chunked_empty_forced$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_empty_forced_OBJECTS) $(test_get_chunked_empty_forced_LDADD) $(LIBS) test_get_chunked_empty_sized$(EXEEXT): $(test_get_chunked_empty_sized_OBJECTS) $(test_get_chunked_empty_sized_DEPENDENCIES) $(EXTRA_test_get_chunked_empty_sized_DEPENDENCIES) @rm -f test_get_chunked_empty_sized$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_empty_sized_OBJECTS) $(test_get_chunked_empty_sized_LDADD) $(LIBS) test_get_chunked_forced$(EXEEXT): $(test_get_chunked_forced_OBJECTS) $(test_get_chunked_forced_DEPENDENCIES) $(EXTRA_test_get_chunked_forced_DEPENDENCIES) @rm -f test_get_chunked_forced$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_forced_OBJECTS) $(test_get_chunked_forced_LDADD) $(LIBS) test_get_chunked_sized$(EXEEXT): $(test_get_chunked_sized_OBJECTS) $(test_get_chunked_sized_DEPENDENCIES) $(EXTRA_test_get_chunked_sized_DEPENDENCIES) @rm -f test_get_chunked_sized$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_sized_OBJECTS) $(test_get_chunked_sized_LDADD) $(LIBS) test_get_chunked_string$(EXEEXT): $(test_get_chunked_string_OBJECTS) $(test_get_chunked_string_DEPENDENCIES) $(EXTRA_test_get_chunked_string_DEPENDENCIES) @rm -f test_get_chunked_string$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_string_OBJECTS) $(test_get_chunked_string_LDADD) $(LIBS) test_get_chunked_string_empty$(EXEEXT): $(test_get_chunked_string_empty_OBJECTS) $(test_get_chunked_string_empty_DEPENDENCIES) $(EXTRA_test_get_chunked_string_empty_DEPENDENCIES) @rm -f test_get_chunked_string_empty$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_string_empty_OBJECTS) $(test_get_chunked_string_empty_LDADD) $(LIBS) test_get_close$(EXEEXT): $(test_get_close_OBJECTS) $(test_get_close_DEPENDENCIES) $(EXTRA_test_get_close_DEPENDENCIES) @rm -f test_get_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_close_OBJECTS) $(test_get_close_LDADD) $(LIBS) test_get_close10$(EXEEXT): $(test_get_close10_OBJECTS) $(test_get_close10_DEPENDENCIES) $(EXTRA_test_get_close10_DEPENDENCIES) @rm -f test_get_close10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_close10_OBJECTS) $(test_get_close10_LDADD) $(LIBS) test_get_header_double_fold$(EXEEXT): $(test_get_header_double_fold_OBJECTS) $(test_get_header_double_fold_DEPENDENCIES) $(EXTRA_test_get_header_double_fold_DEPENDENCIES) @rm -f test_get_header_double_fold$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_header_double_fold_OBJECTS) $(test_get_header_double_fold_LDADD) $(LIBS) test_get_header_fold$(EXEEXT): $(test_get_header_fold_OBJECTS) $(test_get_header_fold_DEPENDENCIES) $(EXTRA_test_get_header_fold_DEPENDENCIES) @rm -f test_get_header_fold$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_header_fold_OBJECTS) $(test_get_header_fold_LDADD) $(LIBS) test_get_iovec$(EXEEXT): $(test_get_iovec_OBJECTS) $(test_get_iovec_DEPENDENCIES) $(EXTRA_test_get_iovec_DEPENDENCIES) @rm -f test_get_iovec$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_iovec_OBJECTS) $(test_get_iovec_LDADD) $(LIBS) test_get_iovec11$(EXEEXT): $(test_get_iovec11_OBJECTS) $(test_get_iovec11_DEPENDENCIES) $(EXTRA_test_get_iovec11_DEPENDENCIES) @rm -f test_get_iovec11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_iovec11_OBJECTS) $(test_get_iovec11_LDADD) $(LIBS) test_get_keep_alive$(EXEEXT): $(test_get_keep_alive_OBJECTS) $(test_get_keep_alive_DEPENDENCIES) $(EXTRA_test_get_keep_alive_DEPENDENCIES) @rm -f test_get_keep_alive$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_keep_alive_OBJECTS) $(test_get_keep_alive_LDADD) $(LIBS) test_get_keep_alive10$(EXEEXT): $(test_get_keep_alive10_OBJECTS) $(test_get_keep_alive10_DEPENDENCIES) $(EXTRA_test_get_keep_alive10_DEPENDENCIES) @rm -f test_get_keep_alive10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_keep_alive10_OBJECTS) $(test_get_keep_alive10_LDADD) $(LIBS) test_get_response_cleanup$(EXEEXT): $(test_get_response_cleanup_OBJECTS) $(test_get_response_cleanup_DEPENDENCIES) $(EXTRA_test_get_response_cleanup_DEPENDENCIES) @rm -f test_get_response_cleanup$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_response_cleanup_OBJECTS) $(test_get_response_cleanup_LDADD) $(LIBS) test_get_sendfile$(EXEEXT): $(test_get_sendfile_OBJECTS) $(test_get_sendfile_DEPENDENCIES) $(EXTRA_test_get_sendfile_DEPENDENCIES) @rm -f test_get_sendfile$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_sendfile_OBJECTS) $(test_get_sendfile_LDADD) $(LIBS) test_get_sendfile11$(EXEEXT): $(test_get_sendfile11_OBJECTS) $(test_get_sendfile11_DEPENDENCIES) $(EXTRA_test_get_sendfile11_DEPENDENCIES) @rm -f test_get_sendfile11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_sendfile11_OBJECTS) $(test_get_sendfile11_LDADD) $(LIBS) test_get_wait$(EXEEXT): $(test_get_wait_OBJECTS) $(test_get_wait_DEPENDENCIES) $(EXTRA_test_get_wait_DEPENDENCIES) @rm -f test_get_wait$(EXEEXT) $(AM_V_CCLD)$(test_get_wait_LINK) $(test_get_wait_OBJECTS) $(test_get_wait_LDADD) $(LIBS) test_get_wait11$(EXEEXT): $(test_get_wait11_OBJECTS) $(test_get_wait11_DEPENDENCIES) $(EXTRA_test_get_wait11_DEPENDENCIES) @rm -f test_get_wait11$(EXEEXT) $(AM_V_CCLD)$(test_get_wait11_LINK) $(test_get_wait11_OBJECTS) $(test_get_wait11_LDADD) $(LIBS) test_head$(EXEEXT): $(test_head_OBJECTS) $(test_head_DEPENDENCIES) $(EXTRA_test_head_DEPENDENCIES) @rm -f test_head$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_head_OBJECTS) $(test_head_LDADD) $(LIBS) test_head10$(EXEEXT): $(test_head10_OBJECTS) $(test_head10_DEPENDENCIES) $(EXTRA_test_head10_DEPENDENCIES) @rm -f test_head10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_head10_OBJECTS) $(test_head10_LDADD) $(LIBS) test_iplimit11$(EXEEXT): $(test_iplimit11_OBJECTS) $(test_iplimit11_DEPENDENCIES) $(EXTRA_test_iplimit11_DEPENDENCIES) @rm -f test_iplimit11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_iplimit11_OBJECTS) $(test_iplimit11_LDADD) $(LIBS) test_large_put$(EXEEXT): $(test_large_put_OBJECTS) $(test_large_put_DEPENDENCIES) $(EXTRA_test_large_put_DEPENDENCIES) @rm -f test_large_put$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_large_put_OBJECTS) $(test_large_put_LDADD) $(LIBS) test_large_put11$(EXEEXT): $(test_large_put11_OBJECTS) $(test_large_put11_DEPENDENCIES) $(EXTRA_test_large_put11_DEPENDENCIES) @rm -f test_large_put11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_large_put11_OBJECTS) $(test_large_put11_LDADD) $(LIBS) test_large_put_inc11$(EXEEXT): $(test_large_put_inc11_OBJECTS) $(test_large_put_inc11_DEPENDENCIES) $(EXTRA_test_large_put_inc11_DEPENDENCIES) @rm -f test_large_put_inc11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_large_put_inc11_OBJECTS) $(test_large_put_inc11_LDADD) $(LIBS) test_long_header$(EXEEXT): $(test_long_header_OBJECTS) $(test_long_header_DEPENDENCIES) $(EXTRA_test_long_header_DEPENDENCIES) @rm -f test_long_header$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_long_header_OBJECTS) $(test_long_header_LDADD) $(LIBS) test_long_header11$(EXEEXT): $(test_long_header11_OBJECTS) $(test_long_header11_DEPENDENCIES) $(EXTRA_test_long_header11_DEPENDENCIES) @rm -f test_long_header11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_long_header11_OBJECTS) $(test_long_header11_LDADD) $(LIBS) test_parse_cookies_discp_n2$(EXEEXT): $(test_parse_cookies_discp_n2_OBJECTS) $(test_parse_cookies_discp_n2_DEPENDENCIES) $(EXTRA_test_parse_cookies_discp_n2_DEPENDENCIES) @rm -f test_parse_cookies_discp_n2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_parse_cookies_discp_n2_OBJECTS) $(test_parse_cookies_discp_n2_LDADD) $(LIBS) test_parse_cookies_discp_n3$(EXEEXT): $(test_parse_cookies_discp_n3_OBJECTS) $(test_parse_cookies_discp_n3_DEPENDENCIES) $(EXTRA_test_parse_cookies_discp_n3_DEPENDENCIES) @rm -f test_parse_cookies_discp_n3$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_parse_cookies_discp_n3_OBJECTS) $(test_parse_cookies_discp_n3_LDADD) $(LIBS) test_parse_cookies_discp_p1$(EXEEXT): $(test_parse_cookies_discp_p1_OBJECTS) $(test_parse_cookies_discp_p1_DEPENDENCIES) $(EXTRA_test_parse_cookies_discp_p1_DEPENDENCIES) @rm -f test_parse_cookies_discp_p1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_parse_cookies_discp_p1_OBJECTS) $(test_parse_cookies_discp_p1_LDADD) $(LIBS) test_parse_cookies_discp_p2$(EXEEXT): $(test_parse_cookies_discp_p2_OBJECTS) $(test_parse_cookies_discp_p2_DEPENDENCIES) $(EXTRA_test_parse_cookies_discp_p2_DEPENDENCIES) @rm -f test_parse_cookies_discp_p2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_parse_cookies_discp_p2_OBJECTS) $(test_parse_cookies_discp_p2_LDADD) $(LIBS) test_parse_cookies_discp_zero$(EXEEXT): $(test_parse_cookies_discp_zero_OBJECTS) $(test_parse_cookies_discp_zero_DEPENDENCIES) $(EXTRA_test_parse_cookies_discp_zero_DEPENDENCIES) @rm -f test_parse_cookies_discp_zero$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_parse_cookies_discp_zero_OBJECTS) $(test_parse_cookies_discp_zero_LDADD) $(LIBS) test_patch$(EXEEXT): $(test_patch_OBJECTS) $(test_patch_DEPENDENCIES) $(EXTRA_test_patch_DEPENDENCIES) @rm -f test_patch$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_patch_OBJECTS) $(test_patch_LDADD) $(LIBS) test_patch11$(EXEEXT): $(test_patch11_OBJECTS) $(test_patch11_DEPENDENCIES) $(EXTRA_test_patch11_DEPENDENCIES) @rm -f test_patch11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_patch11_OBJECTS) $(test_patch11_LDADD) $(LIBS) test_post$(EXEEXT): $(test_post_OBJECTS) $(test_post_DEPENDENCIES) $(EXTRA_test_post_DEPENDENCIES) @rm -f test_post$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_post_OBJECTS) $(test_post_LDADD) $(LIBS) test_post11$(EXEEXT): $(test_post11_OBJECTS) $(test_post11_DEPENDENCIES) $(EXTRA_test_post11_DEPENDENCIES) @rm -f test_post11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_post11_OBJECTS) $(test_post11_LDADD) $(LIBS) test_post_loop$(EXEEXT): $(test_post_loop_OBJECTS) $(test_post_loop_DEPENDENCIES) $(EXTRA_test_post_loop_DEPENDENCIES) @rm -f test_post_loop$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_post_loop_OBJECTS) $(test_post_loop_LDADD) $(LIBS) test_post_loop11$(EXEEXT): $(test_post_loop11_OBJECTS) $(test_post_loop11_DEPENDENCIES) $(EXTRA_test_post_loop11_DEPENDENCIES) @rm -f test_post_loop11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_post_loop11_OBJECTS) $(test_post_loop11_LDADD) $(LIBS) test_postform$(EXEEXT): $(test_postform_OBJECTS) $(test_postform_DEPENDENCIES) $(EXTRA_test_postform_DEPENDENCIES) @rm -f test_postform$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_postform_OBJECTS) $(test_postform_LDADD) $(LIBS) test_postform11$(EXEEXT): $(test_postform11_OBJECTS) $(test_postform11_DEPENDENCIES) $(EXTRA_test_postform11_DEPENDENCIES) @rm -f test_postform11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_postform11_OBJECTS) $(test_postform11_LDADD) $(LIBS) test_process_arguments$(EXEEXT): $(test_process_arguments_OBJECTS) $(test_process_arguments_DEPENDENCIES) $(EXTRA_test_process_arguments_DEPENDENCIES) @rm -f test_process_arguments$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_process_arguments_OBJECTS) $(test_process_arguments_LDADD) $(LIBS) test_process_headers$(EXEEXT): $(test_process_headers_OBJECTS) $(test_process_headers_DEPENDENCIES) $(EXTRA_test_process_headers_DEPENDENCIES) @rm -f test_process_headers$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_process_headers_OBJECTS) $(test_process_headers_LDADD) $(LIBS) test_put$(EXEEXT): $(test_put_OBJECTS) $(test_put_DEPENDENCIES) $(EXTRA_test_put_DEPENDENCIES) @rm -f test_put$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_OBJECTS) $(test_put_LDADD) $(LIBS) test_put11$(EXEEXT): $(test_put11_OBJECTS) $(test_put11_DEPENDENCIES) $(EXTRA_test_put11_DEPENDENCIES) @rm -f test_put11$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put11_OBJECTS) $(test_put11_LDADD) $(LIBS) test_put_broken_len$(EXEEXT): $(test_put_broken_len_OBJECTS) $(test_put_broken_len_DEPENDENCIES) $(EXTRA_test_put_broken_len_DEPENDENCIES) @rm -f test_put_broken_len$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_broken_len_OBJECTS) $(test_put_broken_len_LDADD) $(LIBS) test_put_broken_len10$(EXEEXT): $(test_put_broken_len10_OBJECTS) $(test_put_broken_len10_DEPENDENCIES) $(EXTRA_test_put_broken_len10_DEPENDENCIES) @rm -f test_put_broken_len10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_broken_len10_OBJECTS) $(test_put_broken_len10_LDADD) $(LIBS) test_put_chunked$(EXEEXT): $(test_put_chunked_OBJECTS) $(test_put_chunked_DEPENDENCIES) $(EXTRA_test_put_chunked_DEPENDENCIES) @rm -f test_put_chunked$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_chunked_OBJECTS) $(test_put_chunked_LDADD) $(LIBS) test_put_header_double_fold$(EXEEXT): $(test_put_header_double_fold_OBJECTS) $(test_put_header_double_fold_DEPENDENCIES) $(EXTRA_test_put_header_double_fold_DEPENDENCIES) @rm -f test_put_header_double_fold$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_header_double_fold_OBJECTS) $(test_put_header_double_fold_LDADD) $(LIBS) test_put_header_double_fold_large$(EXEEXT): $(test_put_header_double_fold_large_OBJECTS) $(test_put_header_double_fold_large_DEPENDENCIES) $(EXTRA_test_put_header_double_fold_large_DEPENDENCIES) @rm -f test_put_header_double_fold_large$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_header_double_fold_large_OBJECTS) $(test_put_header_double_fold_large_LDADD) $(LIBS) test_put_header_double_fold_last$(EXEEXT): $(test_put_header_double_fold_last_OBJECTS) $(test_put_header_double_fold_last_DEPENDENCIES) $(EXTRA_test_put_header_double_fold_last_DEPENDENCIES) @rm -f test_put_header_double_fold_last$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_header_double_fold_last_OBJECTS) $(test_put_header_double_fold_last_LDADD) $(LIBS) test_put_header_fold$(EXEEXT): $(test_put_header_fold_OBJECTS) $(test_put_header_fold_DEPENDENCIES) $(EXTRA_test_put_header_fold_DEPENDENCIES) @rm -f test_put_header_fold$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_header_fold_OBJECTS) $(test_put_header_fold_LDADD) $(LIBS) test_put_header_fold_large$(EXEEXT): $(test_put_header_fold_large_OBJECTS) $(test_put_header_fold_large_DEPENDENCIES) $(EXTRA_test_put_header_fold_large_DEPENDENCIES) @rm -f test_put_header_fold_large$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_header_fold_large_OBJECTS) $(test_put_header_fold_large_LDADD) $(LIBS) test_put_header_fold_last$(EXEEXT): $(test_put_header_fold_last_OBJECTS) $(test_put_header_fold_last_DEPENDENCIES) $(EXTRA_test_put_header_fold_last_DEPENDENCIES) @rm -f test_put_header_fold_last$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_header_fold_last_OBJECTS) $(test_put_header_fold_last_LDADD) $(LIBS) test_put_large_header_double_fold$(EXEEXT): $(test_put_large_header_double_fold_OBJECTS) $(test_put_large_header_double_fold_DEPENDENCIES) $(EXTRA_test_put_large_header_double_fold_DEPENDENCIES) @rm -f test_put_large_header_double_fold$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_large_header_double_fold_OBJECTS) $(test_put_large_header_double_fold_LDADD) $(LIBS) test_put_large_header_fold$(EXEEXT): $(test_put_large_header_fold_OBJECTS) $(test_put_large_header_fold_DEPENDENCIES) $(EXTRA_test_put_large_header_fold_DEPENDENCIES) @rm -f test_put_large_header_fold$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_large_header_fold_OBJECTS) $(test_put_large_header_fold_LDADD) $(LIBS) test_quiesce$(EXEEXT): $(test_quiesce_OBJECTS) $(test_quiesce_DEPENDENCIES) $(EXTRA_test_quiesce_DEPENDENCIES) @rm -f test_quiesce$(EXEEXT) $(AM_V_CCLD)$(test_quiesce_LINK) $(test_quiesce_OBJECTS) $(test_quiesce_LDADD) $(LIBS) test_quiesce_stream$(EXEEXT): $(test_quiesce_stream_OBJECTS) $(test_quiesce_stream_DEPENDENCIES) $(EXTRA_test_quiesce_stream_DEPENDENCIES) @rm -f test_quiesce_stream$(EXEEXT) $(AM_V_CCLD)$(test_quiesce_stream_LINK) $(test_quiesce_stream_OBJECTS) $(test_quiesce_stream_LDADD) $(LIBS) test_termination$(EXEEXT): $(test_termination_OBJECTS) $(test_termination_DEPENDENCIES) $(EXTRA_test_termination_DEPENDENCIES) @rm -f test_termination$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_termination_OBJECTS) $(test_termination_LDADD) $(LIBS) test_timeout$(EXEEXT): $(test_timeout_OBJECTS) $(test_timeout_DEPENDENCIES) $(EXTRA_test_timeout_DEPENDENCIES) @rm -f test_timeout$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_timeout_OBJECTS) $(test_timeout_LDADD) $(LIBS) test_toolarge_method$(EXEEXT): $(test_toolarge_method_OBJECTS) $(test_toolarge_method_DEPENDENCIES) $(EXTRA_test_toolarge_method_DEPENDENCIES) @rm -f test_toolarge_method$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_toolarge_method_OBJECTS) $(test_toolarge_method_LDADD) $(LIBS) test_toolarge_reply_header_name$(EXEEXT): $(test_toolarge_reply_header_name_OBJECTS) $(test_toolarge_reply_header_name_DEPENDENCIES) $(EXTRA_test_toolarge_reply_header_name_DEPENDENCIES) @rm -f test_toolarge_reply_header_name$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_toolarge_reply_header_name_OBJECTS) $(test_toolarge_reply_header_name_LDADD) $(LIBS) test_toolarge_reply_header_value$(EXEEXT): $(test_toolarge_reply_header_value_OBJECTS) $(test_toolarge_reply_header_value_DEPENDENCIES) $(EXTRA_test_toolarge_reply_header_value_DEPENDENCIES) @rm -f test_toolarge_reply_header_value$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_toolarge_reply_header_value_OBJECTS) $(test_toolarge_reply_header_value_LDADD) $(LIBS) test_toolarge_reply_headers$(EXEEXT): $(test_toolarge_reply_headers_OBJECTS) $(test_toolarge_reply_headers_DEPENDENCIES) $(EXTRA_test_toolarge_reply_headers_DEPENDENCIES) @rm -f test_toolarge_reply_headers$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_toolarge_reply_headers_OBJECTS) $(test_toolarge_reply_headers_LDADD) $(LIBS) test_toolarge_request_header_name$(EXEEXT): $(test_toolarge_request_header_name_OBJECTS) $(test_toolarge_request_header_name_DEPENDENCIES) $(EXTRA_test_toolarge_request_header_name_DEPENDENCIES) @rm -f test_toolarge_request_header_name$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_toolarge_request_header_name_OBJECTS) $(test_toolarge_request_header_name_LDADD) $(LIBS) test_toolarge_request_header_value$(EXEEXT): $(test_toolarge_request_header_value_OBJECTS) $(test_toolarge_request_header_value_DEPENDENCIES) $(EXTRA_test_toolarge_request_header_value_DEPENDENCIES) @rm -f test_toolarge_request_header_value$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_toolarge_request_header_value_OBJECTS) $(test_toolarge_request_header_value_LDADD) $(LIBS) test_toolarge_request_headers$(EXEEXT): $(test_toolarge_request_headers_OBJECTS) $(test_toolarge_request_headers_DEPENDENCIES) $(EXTRA_test_toolarge_request_headers_DEPENDENCIES) @rm -f test_toolarge_request_headers$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_toolarge_request_headers_OBJECTS) $(test_toolarge_request_headers_LDADD) $(LIBS) test_toolarge_url$(EXEEXT): $(test_toolarge_url_OBJECTS) $(test_toolarge_url_DEPENDENCIES) $(EXTRA_test_toolarge_url_DEPENDENCIES) @rm -f test_toolarge_url$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_toolarge_url_OBJECTS) $(test_toolarge_url_LDADD) $(LIBS) test_tricky_header2$(EXEEXT): $(test_tricky_header2_OBJECTS) $(test_tricky_header2_DEPENDENCIES) $(EXTRA_test_tricky_header2_DEPENDENCIES) @rm -f test_tricky_header2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_tricky_header2_OBJECTS) $(test_tricky_header2_LDADD) $(LIBS) test_tricky_url$(EXEEXT): $(test_tricky_url_OBJECTS) $(test_tricky_url_DEPENDENCIES) $(EXTRA_test_tricky_url_DEPENDENCIES) @rm -f test_tricky_url$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_tricky_url_OBJECTS) $(test_tricky_url_LDADD) $(LIBS) test_urlparse$(EXEEXT): $(test_urlparse_OBJECTS) $(test_urlparse_DEPENDENCIES) $(EXTRA_test_urlparse_DEPENDENCIES) @rm -f test_urlparse$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_urlparse_OBJECTS) $(test_urlparse_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perf_get.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perf_get_concurrent-perf_get_concurrent.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perf_get_concurrent11-perf_get_concurrent.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_add_conn-test_add_conn.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_add_conn_cleanup-test_add_conn.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_add_conn_cleanup_nolisten-test_add_conn.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_add_conn_nolisten-test_add_conn.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_basicauth.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_callback.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_concurrent_stop-test_concurrent_stop.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_delete.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_digestauth.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_digestauth2.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_digestauth_concurrent-test_digestauth_concurrent.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_digestauth_emu_ext.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_digestauth_sha256.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_digestauth_with_arguments.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_get.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_get_chunked.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_get_close_keep_alive.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_get_iovec.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_get_response_cleanup.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_get_sendfile.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_get_wait-test_get_wait.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_get_wait11-test_get_wait.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_head.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_iplimit.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_large_put.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_long_header.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_parse_cookies.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_patch.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_post.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_post_loop.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_postform.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_process_arguments.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_process_headers.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_put.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_put_broken_len.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_put_chunked.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_put_header_fold.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_quiesce-test_quiesce.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_quiesce_stream-test_quiesce_stream.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_termination.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_timeout.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_toolarge.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tricky.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_urlparse.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< perf_get_concurrent-perf_get_concurrent.o: perf_get_concurrent.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(perf_get_concurrent_CFLAGS) $(CFLAGS) -MT perf_get_concurrent-perf_get_concurrent.o -MD -MP -MF $(DEPDIR)/perf_get_concurrent-perf_get_concurrent.Tpo -c -o perf_get_concurrent-perf_get_concurrent.o `test -f 'perf_get_concurrent.c' || echo '$(srcdir)/'`perf_get_concurrent.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/perf_get_concurrent-perf_get_concurrent.Tpo $(DEPDIR)/perf_get_concurrent-perf_get_concurrent.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='perf_get_concurrent.c' object='perf_get_concurrent-perf_get_concurrent.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(perf_get_concurrent_CFLAGS) $(CFLAGS) -c -o perf_get_concurrent-perf_get_concurrent.o `test -f 'perf_get_concurrent.c' || echo '$(srcdir)/'`perf_get_concurrent.c perf_get_concurrent-perf_get_concurrent.obj: perf_get_concurrent.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(perf_get_concurrent_CFLAGS) $(CFLAGS) -MT perf_get_concurrent-perf_get_concurrent.obj -MD -MP -MF $(DEPDIR)/perf_get_concurrent-perf_get_concurrent.Tpo -c -o perf_get_concurrent-perf_get_concurrent.obj `if test -f 'perf_get_concurrent.c'; then $(CYGPATH_W) 'perf_get_concurrent.c'; else $(CYGPATH_W) '$(srcdir)/perf_get_concurrent.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/perf_get_concurrent-perf_get_concurrent.Tpo $(DEPDIR)/perf_get_concurrent-perf_get_concurrent.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='perf_get_concurrent.c' object='perf_get_concurrent-perf_get_concurrent.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(perf_get_concurrent_CFLAGS) $(CFLAGS) -c -o perf_get_concurrent-perf_get_concurrent.obj `if test -f 'perf_get_concurrent.c'; then $(CYGPATH_W) 'perf_get_concurrent.c'; else $(CYGPATH_W) '$(srcdir)/perf_get_concurrent.c'; fi` perf_get_concurrent11-perf_get_concurrent.o: perf_get_concurrent.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(perf_get_concurrent11_CFLAGS) $(CFLAGS) -MT perf_get_concurrent11-perf_get_concurrent.o -MD -MP -MF $(DEPDIR)/perf_get_concurrent11-perf_get_concurrent.Tpo -c -o perf_get_concurrent11-perf_get_concurrent.o `test -f 'perf_get_concurrent.c' || echo '$(srcdir)/'`perf_get_concurrent.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/perf_get_concurrent11-perf_get_concurrent.Tpo $(DEPDIR)/perf_get_concurrent11-perf_get_concurrent.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='perf_get_concurrent.c' object='perf_get_concurrent11-perf_get_concurrent.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(perf_get_concurrent11_CFLAGS) $(CFLAGS) -c -o perf_get_concurrent11-perf_get_concurrent.o `test -f 'perf_get_concurrent.c' || echo '$(srcdir)/'`perf_get_concurrent.c perf_get_concurrent11-perf_get_concurrent.obj: perf_get_concurrent.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(perf_get_concurrent11_CFLAGS) $(CFLAGS) -MT perf_get_concurrent11-perf_get_concurrent.obj -MD -MP -MF $(DEPDIR)/perf_get_concurrent11-perf_get_concurrent.Tpo -c -o perf_get_concurrent11-perf_get_concurrent.obj `if test -f 'perf_get_concurrent.c'; then $(CYGPATH_W) 'perf_get_concurrent.c'; else $(CYGPATH_W) '$(srcdir)/perf_get_concurrent.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/perf_get_concurrent11-perf_get_concurrent.Tpo $(DEPDIR)/perf_get_concurrent11-perf_get_concurrent.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='perf_get_concurrent.c' object='perf_get_concurrent11-perf_get_concurrent.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(perf_get_concurrent11_CFLAGS) $(CFLAGS) -c -o perf_get_concurrent11-perf_get_concurrent.obj `if test -f 'perf_get_concurrent.c'; then $(CYGPATH_W) 'perf_get_concurrent.c'; else $(CYGPATH_W) '$(srcdir)/perf_get_concurrent.c'; fi` test_add_conn-test_add_conn.o: test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_CFLAGS) $(CFLAGS) -MT test_add_conn-test_add_conn.o -MD -MP -MF $(DEPDIR)/test_add_conn-test_add_conn.Tpo -c -o test_add_conn-test_add_conn.o `test -f 'test_add_conn.c' || echo '$(srcdir)/'`test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_add_conn-test_add_conn.Tpo $(DEPDIR)/test_add_conn-test_add_conn.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_add_conn.c' object='test_add_conn-test_add_conn.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_CFLAGS) $(CFLAGS) -c -o test_add_conn-test_add_conn.o `test -f 'test_add_conn.c' || echo '$(srcdir)/'`test_add_conn.c test_add_conn-test_add_conn.obj: test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_CFLAGS) $(CFLAGS) -MT test_add_conn-test_add_conn.obj -MD -MP -MF $(DEPDIR)/test_add_conn-test_add_conn.Tpo -c -o test_add_conn-test_add_conn.obj `if test -f 'test_add_conn.c'; then $(CYGPATH_W) 'test_add_conn.c'; else $(CYGPATH_W) '$(srcdir)/test_add_conn.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_add_conn-test_add_conn.Tpo $(DEPDIR)/test_add_conn-test_add_conn.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_add_conn.c' object='test_add_conn-test_add_conn.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_CFLAGS) $(CFLAGS) -c -o test_add_conn-test_add_conn.obj `if test -f 'test_add_conn.c'; then $(CYGPATH_W) 'test_add_conn.c'; else $(CYGPATH_W) '$(srcdir)/test_add_conn.c'; fi` test_add_conn_cleanup-test_add_conn.o: test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_cleanup_CFLAGS) $(CFLAGS) -MT test_add_conn_cleanup-test_add_conn.o -MD -MP -MF $(DEPDIR)/test_add_conn_cleanup-test_add_conn.Tpo -c -o test_add_conn_cleanup-test_add_conn.o `test -f 'test_add_conn.c' || echo '$(srcdir)/'`test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_add_conn_cleanup-test_add_conn.Tpo $(DEPDIR)/test_add_conn_cleanup-test_add_conn.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_add_conn.c' object='test_add_conn_cleanup-test_add_conn.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_cleanup_CFLAGS) $(CFLAGS) -c -o test_add_conn_cleanup-test_add_conn.o `test -f 'test_add_conn.c' || echo '$(srcdir)/'`test_add_conn.c test_add_conn_cleanup-test_add_conn.obj: test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_cleanup_CFLAGS) $(CFLAGS) -MT test_add_conn_cleanup-test_add_conn.obj -MD -MP -MF $(DEPDIR)/test_add_conn_cleanup-test_add_conn.Tpo -c -o test_add_conn_cleanup-test_add_conn.obj `if test -f 'test_add_conn.c'; then $(CYGPATH_W) 'test_add_conn.c'; else $(CYGPATH_W) '$(srcdir)/test_add_conn.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_add_conn_cleanup-test_add_conn.Tpo $(DEPDIR)/test_add_conn_cleanup-test_add_conn.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_add_conn.c' object='test_add_conn_cleanup-test_add_conn.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_cleanup_CFLAGS) $(CFLAGS) -c -o test_add_conn_cleanup-test_add_conn.obj `if test -f 'test_add_conn.c'; then $(CYGPATH_W) 'test_add_conn.c'; else $(CYGPATH_W) '$(srcdir)/test_add_conn.c'; fi` test_add_conn_cleanup_nolisten-test_add_conn.o: test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_cleanup_nolisten_CFLAGS) $(CFLAGS) -MT test_add_conn_cleanup_nolisten-test_add_conn.o -MD -MP -MF $(DEPDIR)/test_add_conn_cleanup_nolisten-test_add_conn.Tpo -c -o test_add_conn_cleanup_nolisten-test_add_conn.o `test -f 'test_add_conn.c' || echo '$(srcdir)/'`test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_add_conn_cleanup_nolisten-test_add_conn.Tpo $(DEPDIR)/test_add_conn_cleanup_nolisten-test_add_conn.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_add_conn.c' object='test_add_conn_cleanup_nolisten-test_add_conn.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_cleanup_nolisten_CFLAGS) $(CFLAGS) -c -o test_add_conn_cleanup_nolisten-test_add_conn.o `test -f 'test_add_conn.c' || echo '$(srcdir)/'`test_add_conn.c test_add_conn_cleanup_nolisten-test_add_conn.obj: test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_cleanup_nolisten_CFLAGS) $(CFLAGS) -MT test_add_conn_cleanup_nolisten-test_add_conn.obj -MD -MP -MF $(DEPDIR)/test_add_conn_cleanup_nolisten-test_add_conn.Tpo -c -o test_add_conn_cleanup_nolisten-test_add_conn.obj `if test -f 'test_add_conn.c'; then $(CYGPATH_W) 'test_add_conn.c'; else $(CYGPATH_W) '$(srcdir)/test_add_conn.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_add_conn_cleanup_nolisten-test_add_conn.Tpo $(DEPDIR)/test_add_conn_cleanup_nolisten-test_add_conn.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_add_conn.c' object='test_add_conn_cleanup_nolisten-test_add_conn.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_cleanup_nolisten_CFLAGS) $(CFLAGS) -c -o test_add_conn_cleanup_nolisten-test_add_conn.obj `if test -f 'test_add_conn.c'; then $(CYGPATH_W) 'test_add_conn.c'; else $(CYGPATH_W) '$(srcdir)/test_add_conn.c'; fi` test_add_conn_nolisten-test_add_conn.o: test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_nolisten_CFLAGS) $(CFLAGS) -MT test_add_conn_nolisten-test_add_conn.o -MD -MP -MF $(DEPDIR)/test_add_conn_nolisten-test_add_conn.Tpo -c -o test_add_conn_nolisten-test_add_conn.o `test -f 'test_add_conn.c' || echo '$(srcdir)/'`test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_add_conn_nolisten-test_add_conn.Tpo $(DEPDIR)/test_add_conn_nolisten-test_add_conn.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_add_conn.c' object='test_add_conn_nolisten-test_add_conn.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_nolisten_CFLAGS) $(CFLAGS) -c -o test_add_conn_nolisten-test_add_conn.o `test -f 'test_add_conn.c' || echo '$(srcdir)/'`test_add_conn.c test_add_conn_nolisten-test_add_conn.obj: test_add_conn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_nolisten_CFLAGS) $(CFLAGS) -MT test_add_conn_nolisten-test_add_conn.obj -MD -MP -MF $(DEPDIR)/test_add_conn_nolisten-test_add_conn.Tpo -c -o test_add_conn_nolisten-test_add_conn.obj `if test -f 'test_add_conn.c'; then $(CYGPATH_W) 'test_add_conn.c'; else $(CYGPATH_W) '$(srcdir)/test_add_conn.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_add_conn_nolisten-test_add_conn.Tpo $(DEPDIR)/test_add_conn_nolisten-test_add_conn.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_add_conn.c' object='test_add_conn_nolisten-test_add_conn.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_add_conn_nolisten_CFLAGS) $(CFLAGS) -c -o test_add_conn_nolisten-test_add_conn.obj `if test -f 'test_add_conn.c'; then $(CYGPATH_W) 'test_add_conn.c'; else $(CYGPATH_W) '$(srcdir)/test_add_conn.c'; fi` test_concurrent_stop-test_concurrent_stop.o: test_concurrent_stop.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_concurrent_stop_CFLAGS) $(CFLAGS) -MT test_concurrent_stop-test_concurrent_stop.o -MD -MP -MF $(DEPDIR)/test_concurrent_stop-test_concurrent_stop.Tpo -c -o test_concurrent_stop-test_concurrent_stop.o `test -f 'test_concurrent_stop.c' || echo '$(srcdir)/'`test_concurrent_stop.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_concurrent_stop-test_concurrent_stop.Tpo $(DEPDIR)/test_concurrent_stop-test_concurrent_stop.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_concurrent_stop.c' object='test_concurrent_stop-test_concurrent_stop.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_concurrent_stop_CFLAGS) $(CFLAGS) -c -o test_concurrent_stop-test_concurrent_stop.o `test -f 'test_concurrent_stop.c' || echo '$(srcdir)/'`test_concurrent_stop.c test_concurrent_stop-test_concurrent_stop.obj: test_concurrent_stop.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_concurrent_stop_CFLAGS) $(CFLAGS) -MT test_concurrent_stop-test_concurrent_stop.obj -MD -MP -MF $(DEPDIR)/test_concurrent_stop-test_concurrent_stop.Tpo -c -o test_concurrent_stop-test_concurrent_stop.obj `if test -f 'test_concurrent_stop.c'; then $(CYGPATH_W) 'test_concurrent_stop.c'; else $(CYGPATH_W) '$(srcdir)/test_concurrent_stop.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_concurrent_stop-test_concurrent_stop.Tpo $(DEPDIR)/test_concurrent_stop-test_concurrent_stop.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_concurrent_stop.c' object='test_concurrent_stop-test_concurrent_stop.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_concurrent_stop_CFLAGS) $(CFLAGS) -c -o test_concurrent_stop-test_concurrent_stop.obj `if test -f 'test_concurrent_stop.c'; then $(CYGPATH_W) 'test_concurrent_stop.c'; else $(CYGPATH_W) '$(srcdir)/test_concurrent_stop.c'; fi` test_digestauth_concurrent-test_digestauth_concurrent.o: test_digestauth_concurrent.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_digestauth_concurrent_CFLAGS) $(CFLAGS) -MT test_digestauth_concurrent-test_digestauth_concurrent.o -MD -MP -MF $(DEPDIR)/test_digestauth_concurrent-test_digestauth_concurrent.Tpo -c -o test_digestauth_concurrent-test_digestauth_concurrent.o `test -f 'test_digestauth_concurrent.c' || echo '$(srcdir)/'`test_digestauth_concurrent.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_digestauth_concurrent-test_digestauth_concurrent.Tpo $(DEPDIR)/test_digestauth_concurrent-test_digestauth_concurrent.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_digestauth_concurrent.c' object='test_digestauth_concurrent-test_digestauth_concurrent.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_digestauth_concurrent_CFLAGS) $(CFLAGS) -c -o test_digestauth_concurrent-test_digestauth_concurrent.o `test -f 'test_digestauth_concurrent.c' || echo '$(srcdir)/'`test_digestauth_concurrent.c test_digestauth_concurrent-test_digestauth_concurrent.obj: test_digestauth_concurrent.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_digestauth_concurrent_CFLAGS) $(CFLAGS) -MT test_digestauth_concurrent-test_digestauth_concurrent.obj -MD -MP -MF $(DEPDIR)/test_digestauth_concurrent-test_digestauth_concurrent.Tpo -c -o test_digestauth_concurrent-test_digestauth_concurrent.obj `if test -f 'test_digestauth_concurrent.c'; then $(CYGPATH_W) 'test_digestauth_concurrent.c'; else $(CYGPATH_W) '$(srcdir)/test_digestauth_concurrent.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_digestauth_concurrent-test_digestauth_concurrent.Tpo $(DEPDIR)/test_digestauth_concurrent-test_digestauth_concurrent.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_digestauth_concurrent.c' object='test_digestauth_concurrent-test_digestauth_concurrent.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_digestauth_concurrent_CFLAGS) $(CFLAGS) -c -o test_digestauth_concurrent-test_digestauth_concurrent.obj `if test -f 'test_digestauth_concurrent.c'; then $(CYGPATH_W) 'test_digestauth_concurrent.c'; else $(CYGPATH_W) '$(srcdir)/test_digestauth_concurrent.c'; fi` test_get_wait-test_get_wait.o: test_get_wait.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_get_wait_CFLAGS) $(CFLAGS) -MT test_get_wait-test_get_wait.o -MD -MP -MF $(DEPDIR)/test_get_wait-test_get_wait.Tpo -c -o test_get_wait-test_get_wait.o `test -f 'test_get_wait.c' || echo '$(srcdir)/'`test_get_wait.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_get_wait-test_get_wait.Tpo $(DEPDIR)/test_get_wait-test_get_wait.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_get_wait.c' object='test_get_wait-test_get_wait.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_get_wait_CFLAGS) $(CFLAGS) -c -o test_get_wait-test_get_wait.o `test -f 'test_get_wait.c' || echo '$(srcdir)/'`test_get_wait.c test_get_wait-test_get_wait.obj: test_get_wait.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_get_wait_CFLAGS) $(CFLAGS) -MT test_get_wait-test_get_wait.obj -MD -MP -MF $(DEPDIR)/test_get_wait-test_get_wait.Tpo -c -o test_get_wait-test_get_wait.obj `if test -f 'test_get_wait.c'; then $(CYGPATH_W) 'test_get_wait.c'; else $(CYGPATH_W) '$(srcdir)/test_get_wait.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_get_wait-test_get_wait.Tpo $(DEPDIR)/test_get_wait-test_get_wait.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_get_wait.c' object='test_get_wait-test_get_wait.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_get_wait_CFLAGS) $(CFLAGS) -c -o test_get_wait-test_get_wait.obj `if test -f 'test_get_wait.c'; then $(CYGPATH_W) 'test_get_wait.c'; else $(CYGPATH_W) '$(srcdir)/test_get_wait.c'; fi` test_get_wait11-test_get_wait.o: test_get_wait.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_get_wait11_CFLAGS) $(CFLAGS) -MT test_get_wait11-test_get_wait.o -MD -MP -MF $(DEPDIR)/test_get_wait11-test_get_wait.Tpo -c -o test_get_wait11-test_get_wait.o `test -f 'test_get_wait.c' || echo '$(srcdir)/'`test_get_wait.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_get_wait11-test_get_wait.Tpo $(DEPDIR)/test_get_wait11-test_get_wait.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_get_wait.c' object='test_get_wait11-test_get_wait.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_get_wait11_CFLAGS) $(CFLAGS) -c -o test_get_wait11-test_get_wait.o `test -f 'test_get_wait.c' || echo '$(srcdir)/'`test_get_wait.c test_get_wait11-test_get_wait.obj: test_get_wait.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_get_wait11_CFLAGS) $(CFLAGS) -MT test_get_wait11-test_get_wait.obj -MD -MP -MF $(DEPDIR)/test_get_wait11-test_get_wait.Tpo -c -o test_get_wait11-test_get_wait.obj `if test -f 'test_get_wait.c'; then $(CYGPATH_W) 'test_get_wait.c'; else $(CYGPATH_W) '$(srcdir)/test_get_wait.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_get_wait11-test_get_wait.Tpo $(DEPDIR)/test_get_wait11-test_get_wait.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_get_wait.c' object='test_get_wait11-test_get_wait.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_get_wait11_CFLAGS) $(CFLAGS) -c -o test_get_wait11-test_get_wait.obj `if test -f 'test_get_wait.c'; then $(CYGPATH_W) 'test_get_wait.c'; else $(CYGPATH_W) '$(srcdir)/test_get_wait.c'; fi` test_quiesce-test_quiesce.o: test_quiesce.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_quiesce_CFLAGS) $(CFLAGS) -MT test_quiesce-test_quiesce.o -MD -MP -MF $(DEPDIR)/test_quiesce-test_quiesce.Tpo -c -o test_quiesce-test_quiesce.o `test -f 'test_quiesce.c' || echo '$(srcdir)/'`test_quiesce.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_quiesce-test_quiesce.Tpo $(DEPDIR)/test_quiesce-test_quiesce.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_quiesce.c' object='test_quiesce-test_quiesce.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_quiesce_CFLAGS) $(CFLAGS) -c -o test_quiesce-test_quiesce.o `test -f 'test_quiesce.c' || echo '$(srcdir)/'`test_quiesce.c test_quiesce-test_quiesce.obj: test_quiesce.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_quiesce_CFLAGS) $(CFLAGS) -MT test_quiesce-test_quiesce.obj -MD -MP -MF $(DEPDIR)/test_quiesce-test_quiesce.Tpo -c -o test_quiesce-test_quiesce.obj `if test -f 'test_quiesce.c'; then $(CYGPATH_W) 'test_quiesce.c'; else $(CYGPATH_W) '$(srcdir)/test_quiesce.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_quiesce-test_quiesce.Tpo $(DEPDIR)/test_quiesce-test_quiesce.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_quiesce.c' object='test_quiesce-test_quiesce.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_quiesce_CFLAGS) $(CFLAGS) -c -o test_quiesce-test_quiesce.obj `if test -f 'test_quiesce.c'; then $(CYGPATH_W) 'test_quiesce.c'; else $(CYGPATH_W) '$(srcdir)/test_quiesce.c'; fi` test_quiesce_stream-test_quiesce_stream.o: test_quiesce_stream.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_quiesce_stream_CFLAGS) $(CFLAGS) -MT test_quiesce_stream-test_quiesce_stream.o -MD -MP -MF $(DEPDIR)/test_quiesce_stream-test_quiesce_stream.Tpo -c -o test_quiesce_stream-test_quiesce_stream.o `test -f 'test_quiesce_stream.c' || echo '$(srcdir)/'`test_quiesce_stream.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_quiesce_stream-test_quiesce_stream.Tpo $(DEPDIR)/test_quiesce_stream-test_quiesce_stream.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_quiesce_stream.c' object='test_quiesce_stream-test_quiesce_stream.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_quiesce_stream_CFLAGS) $(CFLAGS) -c -o test_quiesce_stream-test_quiesce_stream.o `test -f 'test_quiesce_stream.c' || echo '$(srcdir)/'`test_quiesce_stream.c test_quiesce_stream-test_quiesce_stream.obj: test_quiesce_stream.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_quiesce_stream_CFLAGS) $(CFLAGS) -MT test_quiesce_stream-test_quiesce_stream.obj -MD -MP -MF $(DEPDIR)/test_quiesce_stream-test_quiesce_stream.Tpo -c -o test_quiesce_stream-test_quiesce_stream.obj `if test -f 'test_quiesce_stream.c'; then $(CYGPATH_W) 'test_quiesce_stream.c'; else $(CYGPATH_W) '$(srcdir)/test_quiesce_stream.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_quiesce_stream-test_quiesce_stream.Tpo $(DEPDIR)/test_quiesce_stream-test_quiesce_stream.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_quiesce_stream.c' object='test_quiesce_stream-test_quiesce_stream.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_quiesce_stream_CFLAGS) $(CFLAGS) -c -o test_quiesce_stream-test_quiesce_stream.obj `if test -f 'test_quiesce_stream.c'; then $(CYGPATH_W) 'test_quiesce_stream.c'; else $(CYGPATH_W) '$(srcdir)/test_quiesce_stream.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: $(check_PROGRAMS) @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? test_get.log: test_get$(EXEEXT) @p='test_get$(EXEEXT)'; \ b='test_get'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_head.log: test_head$(EXEEXT) @p='test_head$(EXEEXT)'; \ b='test_head'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_head10.log: test_head10$(EXEEXT) @p='test_head10$(EXEEXT)'; \ b='test_head10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_iovec.log: test_get_iovec$(EXEEXT) @p='test_get_iovec$(EXEEXT)'; \ b='test_get_iovec'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_sendfile.log: test_get_sendfile$(EXEEXT) @p='test_get_sendfile$(EXEEXT)'; \ b='test_get_sendfile'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_close.log: test_get_close$(EXEEXT) @p='test_get_close$(EXEEXT)'; \ b='test_get_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_close10.log: test_get_close10$(EXEEXT) @p='test_get_close10$(EXEEXT)'; \ b='test_get_close10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_keep_alive.log: test_get_keep_alive$(EXEEXT) @p='test_get_keep_alive$(EXEEXT)'; \ b='test_get_keep_alive'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_keep_alive10.log: test_get_keep_alive10$(EXEEXT) @p='test_get_keep_alive10$(EXEEXT)'; \ b='test_get_keep_alive10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_delete.log: test_delete$(EXEEXT) @p='test_delete$(EXEEXT)'; \ b='test_delete'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_patch.log: test_patch$(EXEEXT) @p='test_patch$(EXEEXT)'; \ b='test_patch'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put.log: test_put$(EXEEXT) @p='test_put$(EXEEXT)'; \ b='test_put'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_add_conn.log: test_add_conn$(EXEEXT) @p='test_add_conn$(EXEEXT)'; \ b='test_add_conn'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_add_conn_nolisten.log: test_add_conn_nolisten$(EXEEXT) @p='test_add_conn_nolisten$(EXEEXT)'; \ b='test_add_conn_nolisten'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_process_headers.log: test_process_headers$(EXEEXT) @p='test_process_headers$(EXEEXT)'; \ b='test_process_headers'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_process_arguments.log: test_process_arguments$(EXEEXT) @p='test_process_arguments$(EXEEXT)'; \ b='test_process_arguments'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_toolarge_method.log: test_toolarge_method$(EXEEXT) @p='test_toolarge_method$(EXEEXT)'; \ b='test_toolarge_method'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_toolarge_url.log: test_toolarge_url$(EXEEXT) @p='test_toolarge_url$(EXEEXT)'; \ b='test_toolarge_url'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_toolarge_request_header_name.log: test_toolarge_request_header_name$(EXEEXT) @p='test_toolarge_request_header_name$(EXEEXT)'; \ b='test_toolarge_request_header_name'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_toolarge_request_header_value.log: test_toolarge_request_header_value$(EXEEXT) @p='test_toolarge_request_header_value$(EXEEXT)'; \ b='test_toolarge_request_header_value'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_toolarge_request_headers.log: test_toolarge_request_headers$(EXEEXT) @p='test_toolarge_request_headers$(EXEEXT)'; \ b='test_toolarge_request_headers'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_toolarge_reply_header_name.log: test_toolarge_reply_header_name$(EXEEXT) @p='test_toolarge_reply_header_name$(EXEEXT)'; \ b='test_toolarge_reply_header_name'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_toolarge_reply_header_value.log: test_toolarge_reply_header_value$(EXEEXT) @p='test_toolarge_reply_header_value$(EXEEXT)'; \ b='test_toolarge_reply_header_value'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_toolarge_reply_headers.log: test_toolarge_reply_headers$(EXEEXT) @p='test_toolarge_reply_headers$(EXEEXT)'; \ b='test_toolarge_reply_headers'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_tricky_url.log: test_tricky_url$(EXEEXT) @p='test_tricky_url$(EXEEXT)'; \ b='test_tricky_url'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_tricky_header2.log: test_tricky_header2$(EXEEXT) @p='test_tricky_header2$(EXEEXT)'; \ b='test_tricky_header2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_large_put.log: test_large_put$(EXEEXT) @p='test_large_put$(EXEEXT)'; \ b='test_large_put'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get11.log: test_get11$(EXEEXT) @p='test_get11$(EXEEXT)'; \ b='test_get11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_iovec11.log: test_get_iovec11$(EXEEXT) @p='test_get_iovec11$(EXEEXT)'; \ b='test_get_iovec11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_sendfile11.log: test_get_sendfile11$(EXEEXT) @p='test_get_sendfile11$(EXEEXT)'; \ b='test_get_sendfile11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_patch11.log: test_patch11$(EXEEXT) @p='test_patch11$(EXEEXT)'; \ b='test_patch11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put11.log: test_put11$(EXEEXT) @p='test_put11$(EXEEXT)'; \ b='test_put11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_large_put11.log: test_large_put11$(EXEEXT) @p='test_large_put11$(EXEEXT)'; \ b='test_large_put11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_large_put_inc11.log: test_large_put_inc11$(EXEEXT) @p='test_large_put_inc11$(EXEEXT)'; \ b='test_large_put_inc11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_broken_len10.log: test_put_broken_len10$(EXEEXT) @p='test_put_broken_len10$(EXEEXT)'; \ b='test_put_broken_len10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_broken_len.log: test_put_broken_len$(EXEEXT) @p='test_put_broken_len$(EXEEXT)'; \ b='test_put_broken_len'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked.log: test_get_chunked$(EXEEXT) @p='test_get_chunked$(EXEEXT)'; \ b='test_get_chunked'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_close.log: test_get_chunked_close$(EXEEXT) @p='test_get_chunked_close$(EXEEXT)'; \ b='test_get_chunked_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_string.log: test_get_chunked_string$(EXEEXT) @p='test_get_chunked_string$(EXEEXT)'; \ b='test_get_chunked_string'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_close_string.log: test_get_chunked_close_string$(EXEEXT) @p='test_get_chunked_close_string$(EXEEXT)'; \ b='test_get_chunked_close_string'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_empty.log: test_get_chunked_empty$(EXEEXT) @p='test_get_chunked_empty$(EXEEXT)'; \ b='test_get_chunked_empty'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_close_empty.log: test_get_chunked_close_empty$(EXEEXT) @p='test_get_chunked_close_empty$(EXEEXT)'; \ b='test_get_chunked_close_empty'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_string_empty.log: test_get_chunked_string_empty$(EXEEXT) @p='test_get_chunked_string_empty$(EXEEXT)'; \ b='test_get_chunked_string_empty'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_close_string_empty.log: test_get_chunked_close_string_empty$(EXEEXT) @p='test_get_chunked_close_string_empty$(EXEEXT)'; \ b='test_get_chunked_close_string_empty'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_sized.log: test_get_chunked_sized$(EXEEXT) @p='test_get_chunked_sized$(EXEEXT)'; \ b='test_get_chunked_sized'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_close_sized.log: test_get_chunked_close_sized$(EXEEXT) @p='test_get_chunked_close_sized$(EXEEXT)'; \ b='test_get_chunked_close_sized'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_empty_sized.log: test_get_chunked_empty_sized$(EXEEXT) @p='test_get_chunked_empty_sized$(EXEEXT)'; \ b='test_get_chunked_empty_sized'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_close_empty_sized.log: test_get_chunked_close_empty_sized$(EXEEXT) @p='test_get_chunked_close_empty_sized$(EXEEXT)'; \ b='test_get_chunked_close_empty_sized'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_forced.log: test_get_chunked_forced$(EXEEXT) @p='test_get_chunked_forced$(EXEEXT)'; \ b='test_get_chunked_forced'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_close_forced.log: test_get_chunked_close_forced$(EXEEXT) @p='test_get_chunked_close_forced$(EXEEXT)'; \ b='test_get_chunked_close_forced'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_empty_forced.log: test_get_chunked_empty_forced$(EXEEXT) @p='test_get_chunked_empty_forced$(EXEEXT)'; \ b='test_get_chunked_empty_forced'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_close_empty_forced.log: test_get_chunked_close_empty_forced$(EXEEXT) @p='test_get_chunked_close_empty_forced$(EXEEXT)'; \ b='test_get_chunked_close_empty_forced'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_chunked.log: test_put_chunked$(EXEEXT) @p='test_put_chunked$(EXEEXT)'; \ b='test_put_chunked'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_callback.log: test_callback$(EXEEXT) @p='test_callback$(EXEEXT)'; \ b='test_callback'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_header_fold.log: test_get_header_fold$(EXEEXT) @p='test_get_header_fold$(EXEEXT)'; \ b='test_get_header_fold'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_header_fold.log: test_put_header_fold$(EXEEXT) @p='test_put_header_fold$(EXEEXT)'; \ b='test_put_header_fold'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_large_header_fold.log: test_put_large_header_fold$(EXEEXT) @p='test_put_large_header_fold$(EXEEXT)'; \ b='test_put_large_header_fold'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_header_fold_last.log: test_put_header_fold_last$(EXEEXT) @p='test_put_header_fold_last$(EXEEXT)'; \ b='test_put_header_fold_last'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_header_fold_large.log: test_put_header_fold_large$(EXEEXT) @p='test_put_header_fold_large$(EXEEXT)'; \ b='test_put_header_fold_large'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_header_double_fold.log: test_get_header_double_fold$(EXEEXT) @p='test_get_header_double_fold$(EXEEXT)'; \ b='test_get_header_double_fold'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_header_double_fold.log: test_put_header_double_fold$(EXEEXT) @p='test_put_header_double_fold$(EXEEXT)'; \ b='test_put_header_double_fold'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_large_header_double_fold.log: test_put_large_header_double_fold$(EXEEXT) @p='test_put_large_header_double_fold$(EXEEXT)'; \ b='test_put_large_header_double_fold'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_header_double_fold_last.log: test_put_header_double_fold_last$(EXEEXT) @p='test_put_header_double_fold_last$(EXEEXT)'; \ b='test_put_header_double_fold_last'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_header_double_fold_large.log: test_put_header_double_fold_large$(EXEEXT) @p='test_put_header_double_fold_large$(EXEEXT)'; \ b='test_put_header_double_fold_large'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_parse_cookies_discp_p2.log: test_parse_cookies_discp_p2$(EXEEXT) @p='test_parse_cookies_discp_p2$(EXEEXT)'; \ b='test_parse_cookies_discp_p2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_parse_cookies_discp_p1.log: test_parse_cookies_discp_p1$(EXEEXT) @p='test_parse_cookies_discp_p1$(EXEEXT)'; \ b='test_parse_cookies_discp_p1'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_parse_cookies_discp_zero.log: test_parse_cookies_discp_zero$(EXEEXT) @p='test_parse_cookies_discp_zero$(EXEEXT)'; \ b='test_parse_cookies_discp_zero'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_parse_cookies_discp_n2.log: test_parse_cookies_discp_n2$(EXEEXT) @p='test_parse_cookies_discp_n2$(EXEEXT)'; \ b='test_parse_cookies_discp_n2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_parse_cookies_discp_n3.log: test_parse_cookies_discp_n3$(EXEEXT) @p='test_parse_cookies_discp_n3$(EXEEXT)'; \ b='test_parse_cookies_discp_n3'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) perf_get.log: perf_get$(EXEEXT) @p='perf_get$(EXEEXT)'; \ b='perf_get'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_basicauth.log: test_basicauth$(EXEEXT) @p='test_basicauth$(EXEEXT)'; \ b='test_basicauth'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_basicauth_preauth.log: test_basicauth_preauth$(EXEEXT) @p='test_basicauth_preauth$(EXEEXT)'; \ b='test_basicauth_preauth'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_basicauth_oldapi.log: test_basicauth_oldapi$(EXEEXT) @p='test_basicauth_oldapi$(EXEEXT)'; \ b='test_basicauth_oldapi'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_basicauth_preauth_oldapi.log: test_basicauth_preauth_oldapi$(EXEEXT) @p='test_basicauth_preauth_oldapi$(EXEEXT)'; \ b='test_basicauth_preauth_oldapi'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_post.log: test_post$(EXEEXT) @p='test_post$(EXEEXT)'; \ b='test_post'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_postform.log: test_postform$(EXEEXT) @p='test_postform$(EXEEXT)'; \ b='test_postform'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_post_loop.log: test_post_loop$(EXEEXT) @p='test_post_loop$(EXEEXT)'; \ b='test_post_loop'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_post11.log: test_post11$(EXEEXT) @p='test_post11$(EXEEXT)'; \ b='test_post11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_postform11.log: test_postform11$(EXEEXT) @p='test_postform11$(EXEEXT)'; \ b='test_postform11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_post_loop11.log: test_post_loop11$(EXEEXT) @p='test_post_loop11$(EXEEXT)'; \ b='test_post_loop11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth_emu_ext.log: test_digestauth_emu_ext$(EXEEXT) @p='test_digestauth_emu_ext$(EXEEXT)'; \ b='test_digestauth_emu_ext'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth_emu_ext_oldapi.log: test_digestauth_emu_ext_oldapi$(EXEEXT) @p='test_digestauth_emu_ext_oldapi$(EXEEXT)'; \ b='test_digestauth_emu_ext_oldapi'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2.log: test_digestauth2$(EXEEXT) @p='test_digestauth2$(EXEEXT)'; \ b='test_digestauth2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_rfc2069.log: test_digestauth2_rfc2069$(EXEEXT) @p='test_digestauth2_rfc2069$(EXEEXT)'; \ b='test_digestauth2_rfc2069'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_rfc2069_userdigest.log: test_digestauth2_rfc2069_userdigest$(EXEEXT) @p='test_digestauth2_rfc2069_userdigest$(EXEEXT)'; \ b='test_digestauth2_rfc2069_userdigest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_oldapi1.log: test_digestauth2_oldapi1$(EXEEXT) @p='test_digestauth2_oldapi1$(EXEEXT)'; \ b='test_digestauth2_oldapi1'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_oldapi2.log: test_digestauth2_oldapi2$(EXEEXT) @p='test_digestauth2_oldapi2$(EXEEXT)'; \ b='test_digestauth2_oldapi2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_userhash.log: test_digestauth2_userhash$(EXEEXT) @p='test_digestauth2_userhash$(EXEEXT)'; \ b='test_digestauth2_userhash'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_userdigest.log: test_digestauth2_userdigest$(EXEEXT) @p='test_digestauth2_userdigest$(EXEEXT)'; \ b='test_digestauth2_userdigest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_oldapi1_userdigest.log: test_digestauth2_oldapi1_userdigest$(EXEEXT) @p='test_digestauth2_oldapi1_userdigest$(EXEEXT)'; \ b='test_digestauth2_oldapi1_userdigest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_oldapi2_userdigest.log: test_digestauth2_oldapi2_userdigest$(EXEEXT) @p='test_digestauth2_oldapi2_userdigest$(EXEEXT)'; \ b='test_digestauth2_oldapi2_userdigest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_userhash_userdigest.log: test_digestauth2_userhash_userdigest$(EXEEXT) @p='test_digestauth2_userhash_userdigest$(EXEEXT)'; \ b='test_digestauth2_userhash_userdigest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_bind_all.log: test_digestauth2_bind_all$(EXEEXT) @p='test_digestauth2_bind_all$(EXEEXT)'; \ b='test_digestauth2_bind_all'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_bind_uri.log: test_digestauth2_bind_uri$(EXEEXT) @p='test_digestauth2_bind_uri$(EXEEXT)'; \ b='test_digestauth2_bind_uri'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_oldapi1_bind_all.log: test_digestauth2_oldapi1_bind_all$(EXEEXT) @p='test_digestauth2_oldapi1_bind_all$(EXEEXT)'; \ b='test_digestauth2_oldapi1_bind_all'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_oldapi1_bind_uri.log: test_digestauth2_oldapi1_bind_uri$(EXEEXT) @p='test_digestauth2_oldapi1_bind_uri$(EXEEXT)'; \ b='test_digestauth2_oldapi1_bind_uri'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_sha256.log: test_digestauth2_sha256$(EXEEXT) @p='test_digestauth2_sha256$(EXEEXT)'; \ b='test_digestauth2_sha256'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_sha256_userhash.log: test_digestauth2_sha256_userhash$(EXEEXT) @p='test_digestauth2_sha256_userhash$(EXEEXT)'; \ b='test_digestauth2_sha256_userhash'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_oldapi2_sha256.log: test_digestauth2_oldapi2_sha256$(EXEEXT) @p='test_digestauth2_oldapi2_sha256$(EXEEXT)'; \ b='test_digestauth2_oldapi2_sha256'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_sha256_userdigest.log: test_digestauth2_sha256_userdigest$(EXEEXT) @p='test_digestauth2_sha256_userdigest$(EXEEXT)'; \ b='test_digestauth2_sha256_userdigest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_oldapi2_sha256_userdigest.log: test_digestauth2_oldapi2_sha256_userdigest$(EXEEXT) @p='test_digestauth2_oldapi2_sha256_userdigest$(EXEEXT)'; \ b='test_digestauth2_oldapi2_sha256_userdigest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth2_sha256_userhash_userdigest.log: test_digestauth2_sha256_userhash_userdigest$(EXEEXT) @p='test_digestauth2_sha256_userhash_userdigest$(EXEEXT)'; \ b='test_digestauth2_sha256_userhash_userdigest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_response_cleanup.log: test_get_response_cleanup$(EXEEXT) @p='test_get_response_cleanup$(EXEEXT)'; \ b='test_get_response_cleanup'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_urlparse.log: test_urlparse$(EXEEXT) @p='test_urlparse$(EXEEXT)'; \ b='test_urlparse'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_long_header.log: test_long_header$(EXEEXT) @p='test_long_header$(EXEEXT)'; \ b='test_long_header'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_long_header11.log: test_long_header11$(EXEEXT) @p='test_long_header11$(EXEEXT)'; \ b='test_long_header11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_iplimit11.log: test_iplimit11$(EXEEXT) @p='test_iplimit11$(EXEEXT)'; \ b='test_iplimit11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_termination.log: test_termination$(EXEEXT) @p='test_termination$(EXEEXT)'; \ b='test_termination'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_add_conn_cleanup.log: test_add_conn_cleanup$(EXEEXT) @p='test_add_conn_cleanup$(EXEEXT)'; \ b='test_add_conn_cleanup'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_add_conn_cleanup_nolisten.log: test_add_conn_cleanup_nolisten$(EXEEXT) @p='test_add_conn_cleanup_nolisten$(EXEEXT)'; \ b='test_add_conn_cleanup_nolisten'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_timeout.log: test_timeout$(EXEEXT) @p='test_timeout$(EXEEXT)'; \ b='test_timeout'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) perf_get_concurrent11.log: perf_get_concurrent11$(EXEEXT) @p='perf_get_concurrent11$(EXEEXT)'; \ b='perf_get_concurrent11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_wait.log: test_get_wait$(EXEEXT) @p='test_get_wait$(EXEEXT)'; \ b='test_get_wait'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_wait11.log: test_get_wait11$(EXEEXT) @p='test_get_wait11$(EXEEXT)'; \ b='test_get_wait11'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_concurrent_stop.log: test_concurrent_stop$(EXEEXT) @p='test_concurrent_stop$(EXEEXT)'; \ b='test_concurrent_stop'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_quiesce.log: test_quiesce$(EXEEXT) @p='test_quiesce$(EXEEXT)'; \ b='test_quiesce'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_quiesce_stream.log: test_quiesce_stream$(EXEEXT) @p='test_quiesce_stream$(EXEEXT)'; \ b='test_quiesce_stream'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) perf_get_concurrent.log: perf_get_concurrent$(EXEEXT) @p='perf_get_concurrent$(EXEEXT)'; \ b='perf_get_concurrent'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth.log: test_digestauth$(EXEEXT) @p='test_digestauth$(EXEEXT)'; \ b='test_digestauth'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth_with_arguments.log: test_digestauth_with_arguments$(EXEEXT) @p='test_digestauth_with_arguments$(EXEEXT)'; \ b='test_digestauth_with_arguments'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth_concurrent.log: test_digestauth_concurrent$(EXEEXT) @p='test_digestauth_concurrent$(EXEEXT)'; \ b='test_digestauth_concurrent'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_digestauth_sha256.log: test_digestauth_sha256$(EXEEXT) @p='test_digestauth_sha256$(EXEEXT)'; \ b='test_digestauth_sha256'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-recursive -rm -f ./$(DEPDIR)/perf_get.Po -rm -f ./$(DEPDIR)/perf_get_concurrent-perf_get_concurrent.Po -rm -f ./$(DEPDIR)/perf_get_concurrent11-perf_get_concurrent.Po -rm -f ./$(DEPDIR)/test_add_conn-test_add_conn.Po -rm -f ./$(DEPDIR)/test_add_conn_cleanup-test_add_conn.Po -rm -f ./$(DEPDIR)/test_add_conn_cleanup_nolisten-test_add_conn.Po -rm -f ./$(DEPDIR)/test_add_conn_nolisten-test_add_conn.Po -rm -f ./$(DEPDIR)/test_basicauth.Po -rm -f ./$(DEPDIR)/test_callback.Po -rm -f ./$(DEPDIR)/test_concurrent_stop-test_concurrent_stop.Po -rm -f ./$(DEPDIR)/test_delete.Po -rm -f ./$(DEPDIR)/test_digestauth.Po -rm -f ./$(DEPDIR)/test_digestauth2.Po -rm -f ./$(DEPDIR)/test_digestauth_concurrent-test_digestauth_concurrent.Po -rm -f ./$(DEPDIR)/test_digestauth_emu_ext.Po -rm -f ./$(DEPDIR)/test_digestauth_sha256.Po -rm -f ./$(DEPDIR)/test_digestauth_with_arguments.Po -rm -f ./$(DEPDIR)/test_get.Po -rm -f ./$(DEPDIR)/test_get_chunked.Po -rm -f ./$(DEPDIR)/test_get_close_keep_alive.Po -rm -f ./$(DEPDIR)/test_get_iovec.Po -rm -f ./$(DEPDIR)/test_get_response_cleanup.Po -rm -f ./$(DEPDIR)/test_get_sendfile.Po -rm -f ./$(DEPDIR)/test_get_wait-test_get_wait.Po -rm -f ./$(DEPDIR)/test_get_wait11-test_get_wait.Po -rm -f ./$(DEPDIR)/test_head.Po -rm -f ./$(DEPDIR)/test_iplimit.Po -rm -f ./$(DEPDIR)/test_large_put.Po -rm -f ./$(DEPDIR)/test_long_header.Po -rm -f ./$(DEPDIR)/test_parse_cookies.Po -rm -f ./$(DEPDIR)/test_patch.Po -rm -f ./$(DEPDIR)/test_post.Po -rm -f ./$(DEPDIR)/test_post_loop.Po -rm -f ./$(DEPDIR)/test_postform.Po -rm -f ./$(DEPDIR)/test_process_arguments.Po -rm -f ./$(DEPDIR)/test_process_headers.Po -rm -f ./$(DEPDIR)/test_put.Po -rm -f ./$(DEPDIR)/test_put_broken_len.Po -rm -f ./$(DEPDIR)/test_put_chunked.Po -rm -f ./$(DEPDIR)/test_put_header_fold.Po -rm -f ./$(DEPDIR)/test_quiesce-test_quiesce.Po -rm -f ./$(DEPDIR)/test_quiesce_stream-test_quiesce_stream.Po -rm -f ./$(DEPDIR)/test_termination.Po -rm -f ./$(DEPDIR)/test_timeout.Po -rm -f ./$(DEPDIR)/test_toolarge.Po -rm -f ./$(DEPDIR)/test_tricky.Po -rm -f ./$(DEPDIR)/test_urlparse.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/perf_get.Po -rm -f ./$(DEPDIR)/perf_get_concurrent-perf_get_concurrent.Po -rm -f ./$(DEPDIR)/perf_get_concurrent11-perf_get_concurrent.Po -rm -f ./$(DEPDIR)/test_add_conn-test_add_conn.Po -rm -f ./$(DEPDIR)/test_add_conn_cleanup-test_add_conn.Po -rm -f ./$(DEPDIR)/test_add_conn_cleanup_nolisten-test_add_conn.Po -rm -f ./$(DEPDIR)/test_add_conn_nolisten-test_add_conn.Po -rm -f ./$(DEPDIR)/test_basicauth.Po -rm -f ./$(DEPDIR)/test_callback.Po -rm -f ./$(DEPDIR)/test_concurrent_stop-test_concurrent_stop.Po -rm -f ./$(DEPDIR)/test_delete.Po -rm -f ./$(DEPDIR)/test_digestauth.Po -rm -f ./$(DEPDIR)/test_digestauth2.Po -rm -f ./$(DEPDIR)/test_digestauth_concurrent-test_digestauth_concurrent.Po -rm -f ./$(DEPDIR)/test_digestauth_emu_ext.Po -rm -f ./$(DEPDIR)/test_digestauth_sha256.Po -rm -f ./$(DEPDIR)/test_digestauth_with_arguments.Po -rm -f ./$(DEPDIR)/test_get.Po -rm -f ./$(DEPDIR)/test_get_chunked.Po -rm -f ./$(DEPDIR)/test_get_close_keep_alive.Po -rm -f ./$(DEPDIR)/test_get_iovec.Po -rm -f ./$(DEPDIR)/test_get_response_cleanup.Po -rm -f ./$(DEPDIR)/test_get_sendfile.Po -rm -f ./$(DEPDIR)/test_get_wait-test_get_wait.Po -rm -f ./$(DEPDIR)/test_get_wait11-test_get_wait.Po -rm -f ./$(DEPDIR)/test_head.Po -rm -f ./$(DEPDIR)/test_iplimit.Po -rm -f ./$(DEPDIR)/test_large_put.Po -rm -f ./$(DEPDIR)/test_long_header.Po -rm -f ./$(DEPDIR)/test_parse_cookies.Po -rm -f ./$(DEPDIR)/test_patch.Po -rm -f ./$(DEPDIR)/test_post.Po -rm -f ./$(DEPDIR)/test_post_loop.Po -rm -f ./$(DEPDIR)/test_postform.Po -rm -f ./$(DEPDIR)/test_process_arguments.Po -rm -f ./$(DEPDIR)/test_process_headers.Po -rm -f ./$(DEPDIR)/test_put.Po -rm -f ./$(DEPDIR)/test_put_broken_len.Po -rm -f ./$(DEPDIR)/test_put_chunked.Po -rm -f ./$(DEPDIR)/test_put_header_fold.Po -rm -f ./$(DEPDIR)/test_quiesce-test_quiesce.Po -rm -f ./$(DEPDIR)/test_quiesce_stream-test_quiesce_stream.Po -rm -f ./$(DEPDIR)/test_termination.Po -rm -f ./$(DEPDIR)/test_timeout.Po -rm -f ./$(DEPDIR)/test_toolarge.Po -rm -f ./$(DEPDIR)/test_tricky.Po -rm -f ./$(DEPDIR)/test_urlparse.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) check-am install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--depfiles check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile @HEAVY_TESTS_NOTPARALLEL@ $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/src/testcurl/test_digestauth.c0000644000175000017500000004121714555767064016066 /* This file is part of libmicrohttpd Copyright (C) 2010 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file daemontest_digestauth.c * @brief Testcase for libmicrohttpd Digest Auth * @author Amr Ali * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #if defined(MHD_HTTPS_REQUIRE_GCRYPT) && \ (defined(MHD_SHA256_TLSLIB) || defined(MHD_MD5_TLSLIB)) #define NEED_GCRYP_INIT 1 #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT && (MHD_SHA256_TLSLIB || MHD_MD5_TLSLIB) */ #ifndef WINDOWS #include #include #else #include #endif #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __func__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), \ __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func(NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), \ __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func(NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func(errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func((libcurlcall), _MHD_STRMACRO(libcurlcall), NULL, __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (8); } static void _checkCURLE_OK_func (CURLcode code, const char *curlFunc, const char *funcName, int lineNum) { if (CURLE_OK == code) return; fflush (stdout); if ((NULL != curlFunc) && (0 != curlFunc[0])) fprintf (stderr, "'%s' resulted in '%s'", curlFunc, curl_easy_strerror (code)); else fprintf (stderr, "libcurl function call resulted in '%s'", curl_easy_strerror (code)); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (9); } /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 #define MHD_URI_BASE_PATH "/bar%20foo%20without%20args" #define PAGE \ "libmicrohttpd demoAccess granted" #define DENIED \ "libmicrohttpd demoAccess denied" #define MY_OPAQUE "11733b200778ce33060f31c9af70a870ba96ddd4" struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) mhdErrorExitDesc ("Wrong too large data"); /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; char *username; const char *password = "testpass"; const char *realm = "test@example.com"; enum MHD_Result ret; int ret_i; static int already_called_marker; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ if (&already_called_marker != *req_cls) { /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; } username = MHD_digest_auth_get_username (connection); if ( (username == NULL) || (0 != strcmp (username, "testuser")) ) { response = MHD_create_response_from_buffer_static (strlen (DENIED), DENIED); if (NULL == response) mhdErrorExitDesc ("MHD_create_response_from_buffer failed"); ret = MHD_queue_auth_fail_response2 (connection, realm, MY_OPAQUE, response, MHD_NO, MHD_DIGEST_ALG_MD5); if (MHD_YES != ret) mhdErrorExitDesc ("MHD_queue_auth_fail_response2 failed"); MHD_destroy_response (response); return ret; } ret_i = MHD_digest_auth_check2 (connection, realm, username, password, 300, MHD_DIGEST_ALG_MD5); MHD_free (username); if (ret_i != MHD_YES) { response = MHD_create_response_from_buffer_static (strlen (DENIED), DENIED); if (NULL == response) mhdErrorExitDesc ("MHD_create_response_from_buffer() failed"); ret = MHD_queue_auth_fail_response2 (connection, realm, MY_OPAQUE, response, (MHD_INVALID_NONCE == ret_i) ? MHD_YES : MHD_NO, MHD_DIGEST_ALG_MD5); if (MHD_YES != ret) mhdErrorExitDesc ("MHD_queue_auth_fail_response2() failed"); MHD_destroy_response (response); return ret; } response = MHD_create_response_from_buffer_static (strlen (PAGE), PAGE); if (NULL == response) mhdErrorExitDesc ("MHD_create_response_from_buffer() failed"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); if (MHD_YES != ret) mhdErrorExitDesc ("MHD_queue_auth_fail_response2() failed"); MHD_destroy_response (response); return ret; } static CURL * setupCURL (void *cbc, uint16_t port) { CURL *c; char url[512]; if (1) { int res; /* A workaround for some old libcurl versions, which ignore the specified * port by CURLOPT_PORT when digest authorisation is used. */ res = snprintf (url, (sizeof(url) / sizeof(url[0])), "http://127.0.0.1:%u%s", (unsigned int) port, MHD_URI_BASE_PATH); if ((0 >= res) || ((sizeof(url) / sizeof(url[0])) <= (size_t) res)) externalErrorExitDesc ("Cannot form request URL"); } c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || #if CURL_AT_LEAST_VERSION (7, 85, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http")) || #elif CURL_AT_LEAST_VERSION (7, 19, 4) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) || #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ #if CURL_AT_LEAST_VERSION (7, 45, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) || #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) port))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, url))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_USERPWD, "testuser:testpass"))) libcurlErrorExitDesc ("curl_easy_setopt() authorization options failed"); return c; } static unsigned int testDigestAuth (void) { CURL *c; struct MHD_Daemon *d; struct CBC cbc; char buf[2048]; char rnd[8]; uint16_t port; #ifndef WINDOWS int fd; size_t len; size_t off = 0; #endif /* ! WINDOWS */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1165; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; #ifndef WINDOWS fd = open ("/dev/urandom", O_RDONLY); if (-1 == fd) externalErrorExitDesc ("Failed to open '/dev/urandom'"); while (off < 8) { len = (size_t) read (fd, rnd + off, 8 - off); if (len == (size_t) -1) externalErrorExitDesc ("Failed to read '/dev/urandom'"); off += len; } (void) close (fd); #else { HCRYPTPROV cc; BOOL b; b = CryptAcquireContext (&cc, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); if (b == 0) externalErrorExitDesc ("CryptAcquireContext() failed"); b = CryptGenRandom (cc, 8, (BYTE *) rnd); if (b == 0) externalErrorExitDesc ("CryptGenRandom() failed"); CryptReleaseContext (cc, 0); } #endif d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, MHD_OPTION_NONCE_NC_SIZE, 300, MHD_OPTION_DIGEST_AUTH_DEFAULT_MAX_NC, (uint32_t) 999, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); port = dinfo->port; } c = setupCURL (&cbc, port); checkCURLE_OK (curl_easy_perform (c)); curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen (PAGE)) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) cbc.pos, (int) cbc.pos, cbc.buf, (unsigned) strlen (MHD_URI_BASE_PATH)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != strncmp (PAGE, cbc.buf, strlen (PAGE))) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) cbc.pos, cbc.buf); mhdErrorExitDesc ("Wrong returned data"); } return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ #ifdef NEED_GCRYP_INIT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* GCRYCTL_INITIALIZATION_FINISHED */ #endif /* NEED_GCRYP_INIT */ if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; errorCount += testDigestAuth (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_digestauth_emu_ext.c0000644000175000017500000007002614556013673017603 /* This file is part of libmicrohttpd Copyright (C) 2010 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_digest_emu_ext.c * @brief Testcase for MHD Digest Authorisation client's header parsing * @author Karlson2k (Evgeny Grin) * * libcurl does not support extended notation for username, so this test * "emulates" client request will all valid fields except nonce, cnonce and * response (however syntactically these fields valid as well). */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #ifndef WINDOWS #include #include #else #include #endif #include "mhd_has_param.h" #include "mhd_has_in_name.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __func__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func (NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func (NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func (NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func (errDesc, NULL, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), NULL, \ __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } /* Not actually used in this test */ static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (8); } #if 0 /* Function unused in this test */ static void _checkCURLE_OK_func (CURLcode code, const char *curlFunc, const char *funcName, int lineNum) { if (CURLE_OK == code) return; fflush (stdout); if ((NULL != curlFunc) && (0 != curlFunc[0])) fprintf (stderr, "'%s' resulted in '%s'", curlFunc, curl_easy_strerror (code)); else fprintf (stderr, "libcurl function call resulted in '%s'", curl_easy_strerror (code)); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (9); } #endif /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 10 #define MHD_URI_BASE_PATH "/bar%20foo?key=value" #define REALM "TestRealm" /* "titkos szuperügynök" in UTF-8 */ #define USERNAME "titkos szuper" "\xC3\xBC" "gyn" "\xC3\xB6" "k" /* percent-encoded username */ #define USERNAME_PCTENC "titkos%20szuper%C3%BCgyn%C3%B6k" #define PASSWORD_VALUE "fake pass" #define OPAQUE_VALUE "opaque-content" #define NONCE_EMU "badbadbadbadbadbadbadbadbadbadbadbadbadbadba" #define CNONCE_EMU "utututututututututututututututututututututs=" #define RESPONSE_EMU "badbadbadbadbadbadbadbadbadbadba" #define PAGE \ "libmicrohttpd demo page" \ "Access granted" #define DENIED \ "libmicrohttpd - Access denied" \ "Access denied" struct CBC { char *buf; size_t pos; size_t size; }; /* Global parameters */ static int verbose; static int oldapi; /* Static helper variables */ static struct curl_slist *curl_headers; static void test_global_init (void) { libcurl_errbuf[0] = 0; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) externalErrorExit (); curl_headers = NULL; curl_headers = curl_slist_append (curl_headers, "Authorization: " "Digest username*=UTF-8''" USERNAME_PCTENC ", " "realm=\"" REALM "\", " "nonce=\"" NONCE_EMU "\", " "uri=\"" MHD_URI_BASE_PATH "\", " "cnonce=\"" CNONCE_EMU "\", " "nc=00000001, " "qop=auth, " "response=\"" RESPONSE_EMU "\", " "opaque=\"" OPAQUE_VALUE "\", " "algorithm=MD5"); if (NULL == curl_headers) externalErrorExit (); } static void test_global_cleanup (void) { curl_slist_free_all (curl_headers); curl_headers = NULL; curl_global_cleanup (); } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) mhdErrorExitDesc ("Wrong too large data"); /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; static int already_called_marker; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (&already_called_marker != *req_cls) { /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; } if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) mhdErrorExitDesc ("Unexpected HTTP method"); if (! oldapi) { struct MHD_DigestAuthUsernameInfo *creds; struct MHD_DigestAuthInfo *dinfo; enum MHD_DigestAuthResult check_res; creds = MHD_digest_auth_get_username3 (connection); if (NULL == creds) mhdErrorExitDesc ("MHD_digest_auth_get_username3() returned NULL"); else if (MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED != creds->uname_type) { fprintf (stderr, "Unexpected 'uname_type'.\n" "Expected: %d\tRecieved: %d. ", (int) MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED, (int) creds->uname_type); mhdErrorExitDesc ("Wrong 'uname_type'"); } else if (NULL == creds->username) mhdErrorExitDesc ("'username' is NULL"); else if (creds->username_len != MHD_STATICSTR_LEN_ (USERNAME)) { fprintf (stderr, "'username_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) MHD_STATICSTR_LEN_ (USERNAME), (unsigned) creds->username_len); mhdErrorExitDesc ("Wrong 'username_len'"); } else if (0 != memcmp (creds->username, USERNAME, creds->username_len)) { fprintf (stderr, "'username' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", USERNAME, (int) creds->username_len, creds->username); mhdErrorExitDesc ("Wrong 'username'"); } else if (NULL != creds->userhash_hex) mhdErrorExitDesc ("'userhash_hex' is NOT NULL"); else if (0 != creds->userhash_hex_len) mhdErrorExitDesc ("'userhash_hex' is NOT zero"); else if (NULL != creds->userhash_bin) mhdErrorExitDesc ("'userhash_bin' is NOT NULL"); dinfo = MHD_digest_auth_get_request_info3 (connection); if (NULL == dinfo) mhdErrorExitDesc ("MHD_digest_auth_get_username3() returned NULL"); else if (MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED != dinfo->uname_type) { fprintf (stderr, "Unexpected 'uname_type'.\n" "Expected: %d\tRecieved: %d. ", (int) MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED, (int) creds->uname_type); mhdErrorExitDesc ("Wrong 'uname_type'"); } else if (NULL == dinfo->username) mhdErrorExitDesc ("'username' is NULL"); else if (dinfo->username_len != MHD_STATICSTR_LEN_ (USERNAME)) { fprintf (stderr, "'username_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) MHD_STATICSTR_LEN_ (USERNAME), (unsigned) dinfo->username_len); mhdErrorExitDesc ("Wrong 'username_len'"); } else if (0 != memcmp (dinfo->username, USERNAME, dinfo->username_len)) { fprintf (stderr, "'username' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", USERNAME, (int) dinfo->username_len, dinfo->username); mhdErrorExitDesc ("Wrong 'username'"); } else if (NULL != dinfo->userhash_hex) mhdErrorExitDesc ("'userhash_hex' is NOT NULL"); else if (0 != dinfo->userhash_hex_len) mhdErrorExitDesc ("'userhash_hex' is NOT zero"); else if (NULL != dinfo->userhash_bin) mhdErrorExitDesc ("'userhash_bin' is NOT NULL"); else if (MHD_DIGEST_AUTH_ALGO3_MD5 != dinfo->algo3) { fprintf (stderr, "Unexpected 'algo'.\n" "Expected: %d\tRecieved: %d. ", (int) MHD_DIGEST_AUTH_ALGO3_MD5, (int) dinfo->algo3); mhdErrorExitDesc ("Wrong 'algo'"); } else if (MHD_STATICSTR_LEN_ (CNONCE_EMU) != dinfo->cnonce_len) { fprintf (stderr, "Unexpected 'cnonce_len'.\n" "Expected: %d\tRecieved: %ld. ", (int) MHD_STATICSTR_LEN_ (CNONCE_EMU), (long) dinfo->cnonce_len); mhdErrorExitDesc ("Wrong 'cnonce_len'"); } else if (NULL == dinfo->opaque) mhdErrorExitDesc ("'opaque' is NULL"); else if (dinfo->opaque_len != MHD_STATICSTR_LEN_ (OPAQUE_VALUE)) { fprintf (stderr, "'opaque_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) MHD_STATICSTR_LEN_ (OPAQUE_VALUE), (unsigned) dinfo->opaque_len); mhdErrorExitDesc ("Wrong 'opaque_len'"); } else if (0 != memcmp (dinfo->opaque, OPAQUE_VALUE, dinfo->opaque_len)) { fprintf (stderr, "'opaque' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", OPAQUE_VALUE, (int) dinfo->opaque_len, dinfo->opaque); mhdErrorExitDesc ("Wrong 'opaque'"); } else if (MHD_DIGEST_AUTH_QOP_AUTH != dinfo->qop) { fprintf (stderr, "Unexpected 'qop'.\n" "Expected: %d\tRecieved: %d. ", (int) MHD_DIGEST_AUTH_QOP_AUTH, (int) dinfo->qop); mhdErrorExitDesc ("Wrong 'qop'"); } else if (NULL == dinfo->realm) mhdErrorExitDesc ("'realm' is NULL"); else if (dinfo->realm_len != MHD_STATICSTR_LEN_ (REALM)) { fprintf (stderr, "'realm_len' does not match.\n" "Expected: %u\tRecieved: %u. ", (unsigned) MHD_STATICSTR_LEN_ (REALM), (unsigned) dinfo->realm_len); mhdErrorExitDesc ("Wrong 'realm_len'"); } else if (0 != memcmp (dinfo->realm, REALM, dinfo->realm_len)) { fprintf (stderr, "'realm' does not match.\n" "Expected: '%s'\tRecieved: '%.*s'. ", OPAQUE_VALUE, (int) dinfo->realm_len, dinfo->realm); mhdErrorExitDesc ("Wrong 'realm'"); } MHD_free (creds); MHD_free (dinfo); check_res = MHD_digest_auth_check3 (connection, REALM, USERNAME, PASSWORD_VALUE, 50 * TIMEOUTS_VAL, 0, MHD_DIGEST_AUTH_MULT_QOP_AUTH, MHD_DIGEST_AUTH_MULT_ALGO3_MD5); switch (check_res) { /* Valid results */ case MHD_DAUTH_NONCE_STALE: if (verbose) printf ("Got valid auth check result: MHD_DAUTH_NONCE_STALE.\n"); break; case MHD_DAUTH_NONCE_WRONG: if (verbose) printf ("Got valid auth check result: MHD_DAUTH_NONCE_WRONG.\n"); break; /* Invalid results */ case MHD_DAUTH_OK: mhdErrorExitDesc ("'MHD_digest_auth_check3()' succeed, " \ "but it should not"); break; case MHD_DAUTH_ERROR: externalErrorExitDesc ("General error returned " \ "by 'MHD_digest_auth_check3()'"); break; case MHD_DAUTH_WRONG_USERNAME: mhdErrorExitDesc ("MHD_digest_auth_check3()' returned " \ "MHD_DAUTH_WRONG_USERNAME"); break; case MHD_DAUTH_RESPONSE_WRONG: mhdErrorExitDesc ("MHD_digest_auth_check3()' returned " \ "MHD_DAUTH_RESPONSE_WRONG"); break; case MHD_DAUTH_WRONG_HEADER: case MHD_DAUTH_WRONG_REALM: case MHD_DAUTH_WRONG_URI: case MHD_DAUTH_WRONG_QOP: case MHD_DAUTH_WRONG_ALGO: case MHD_DAUTH_TOO_LARGE: case MHD_DAUTH_NONCE_OTHER_COND: fprintf (stderr, "'MHD_digest_auth_check3()' returned " "unexpected result: %d. ", check_res); mhdErrorExitDesc ("Wrong returned code"); break; default: fprintf (stderr, "'MHD_digest_auth_check3()' returned " "impossible result code: %d. ", check_res); mhdErrorExitDesc ("Impossible returned code"); } response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (DENIED), (const void *) DENIED); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); ret = MHD_queue_auth_fail_response2 (connection, REALM, OPAQUE_VALUE, response, 0, MHD_DIGEST_ALG_MD5); if (MHD_YES != ret) mhdErrorExitDesc ("'MHD_queue_auth_fail_response2()' failed"); } else { char *username; int check_res; username = MHD_digest_auth_get_username (connection); if (NULL == username) mhdErrorExitDesc ("'MHD_digest_auth_get_username()' returned NULL"); else if (0 != strcmp (username, USERNAME)) { fprintf (stderr, "'username' does not match.\n" "Expected: '%s'\tRecieved: '%s'. ", USERNAME, username); mhdErrorExitDesc ("Wrong 'username'"); } MHD_free (username); check_res = MHD_digest_auth_check (connection, REALM, USERNAME, PASSWORD_VALUE, 300); if (MHD_INVALID_NONCE != check_res) { fprintf (stderr, "'MHD_digest_auth_check()' returned unexpected" " result: %d. ", check_res); mhdErrorExitDesc ("Wrong 'MHD_digest_auth_check()' result"); } response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (DENIED), (const void *) DENIED); if (NULL == response) mhdErrorExitDesc ("Response creation failed"); ret = MHD_queue_auth_fail_response (connection, REALM, OPAQUE_VALUE, response, 0); if (MHD_YES != ret) mhdErrorExitDesc ("'MHD_queue_auth_fail_response()' failed"); } MHD_destroy_response (response); return ret; } static CURL * setupCURL (void *cbc, uint16_t port) { CURL *c; char url[512]; if (1) { int res; /* A workaround for some old libcurl versions, which ignore the specified * port by CURLOPT_PORT when authorisation is used. */ res = snprintf (url, (sizeof(url) / sizeof(url[0])), "http://127.0.0.1:%u%s", (unsigned int) port, MHD_URI_BASE_PATH); if ((0 >= res) || ((sizeof(url) / sizeof(url[0])) <= (size_t) res)) externalErrorExitDesc ("Cannot form request URL"); } c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || /* (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) || */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 0L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPHEADER, curl_headers)) || #if CURL_AT_LEAST_VERSION (7, 85, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http")) || #elif CURL_AT_LEAST_VERSION (7, 19, 4) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) || #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ #if CURL_AT_LEAST_VERSION (7, 45, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) || #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) port))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, url))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); return c; } static CURLcode performQueryExternal (struct MHD_Daemon *d, CURL *c) { CURLM *multi; time_t start; struct timeval tv; CURLcode ret; ret = CURLE_FAILED_INIT; /* will be replaced with real result */ multi = NULL; multi = curl_multi_init (); if (multi == NULL) libcurlErrorExitDesc ("curl_multi_init() failed"); if (CURLM_OK != curl_multi_add_handle (multi, c)) libcurlErrorExitDesc ("curl_multi_add_handle() failed"); start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; int running; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL != multi) { curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) libcurlErrorExitDesc ("curl_multi_info_read() failed"); totalMsgs++; if (CURLMSG_DONE == msg->msg) ret = msg->data.result; } while (msgLeft > 0); if (1 != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); externalErrorExit (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); multi = NULL; } else { if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) libcurlErrorExitDesc ("curl_multi_fdset() failed"); } } if (NULL == multi) { /* libcurl has finished, check whether MHD still needs to perform cleanup */ if (0 != MHD_get_timeout64s (d)) break; /* MHD finished as well */ } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); tv.tv_sec = 0; tv.tv_usec = 200000; #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep (200); #endif } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); } return ret; } /** * Check request result * @param curl_code the CURL easy return code * @param pcbc the pointer struct CBC * @return non-zero if success, zero if failed */ static unsigned int check_result (CURLcode curl_code, CURL *c, struct CBC *pcbc) { long code; if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code)) libcurlErrorExit (); if (401 != code) { fprintf (stderr, "Request returned wrong code: %ld.\n", code); return 0; } if (CURLE_OK != curl_code) { fflush (stdout); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n" "libcurl error description: '%s'.\n", curl_easy_strerror (curl_code), libcurl_errbuf); else fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n", curl_easy_strerror (curl_code)); fflush (stderr); return 0; } if (pcbc->pos != strlen (DENIED)) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) pcbc->pos, (int) pcbc->pos, pcbc->buf, (unsigned) strlen (DENIED)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != memcmp (DENIED, pcbc->buf, pcbc->pos)) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) pcbc->pos, pcbc->buf); mhdErrorExitDesc ("Wrong returned data"); } return 1; } static unsigned int testDigestAuthEmu (void) { struct MHD_Daemon *d; uint16_t port; struct CBC cbc; char buf[2048]; CURL *c; int failed = 0; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 4210; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); port = (uint16_t) dinfo->port; } /* First request */ cbc.buf = buf; cbc.size = sizeof (buf); cbc.pos = 0; memset (cbc.buf, 0, cbc.size); c = setupCURL (&cbc, port); if (check_result (performQueryExternal (d, c), c, &cbc)) { if (verbose) printf ("Got expected response.\n"); } else { fprintf (stderr, "Request FAILED.\n"); failed = 1; } curl_easy_cleanup (c); MHD_stop_daemon (d); return failed ? 1 : 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); oldapi = has_in_name (argv[0], "_oldapi"); test_global_init (); errorCount += testDigestAuthEmu (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); test_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_post_loop.c0000644000175000017500000004520114530120375015715 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file daemontest_post_loop.c * @brief Testcase for libmicrohttpd POST operations using URL-encoding * @author Christian Grothoff (inspired by bug report #1296) * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #ifndef WINDOWS #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #define POST_DATA \ "\n\n1\n\n" #ifndef __APPLE__ #define LOOPCOUNT 1000 #else /* __APPLE__ */ /* FIXME: macOS may fail in this test with "unable to connect". Investigate deeper? */ #define LOOPCOUNT 200 #endif /* __APPLE__ */ static int oneone; struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp ("POST", method)) { printf ("METHOD: %s\n", method); return MHD_NO; /* unexpected method */ } if ((*req_cls != NULL) && (0 == *upload_data_size)) { if (*req_cls != &marker) abort (); response = MHD_create_response_from_buffer_static (2, "OK"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); *req_cls = NULL; return ret; } if (strlen (POST_DATA) != *upload_data_size) return MHD_YES; *upload_data_size = 0; *req_cls = ▮ return MHD_YES; } static unsigned int testInternalPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; int i; char url[1024]; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1350; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } for (i = 0; i < LOOPCOUNT; i++) { if (99 == i % 100) fprintf (stderr, "."); c = curl_easy_init (); cbc.pos = 0; buf[0] = '\0'; snprintf (url, sizeof (url), "http://127.0.0.1:%u/hw%d", (unsigned int) port, i); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); curl_easy_setopt (c, CURLOPT_POST, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); if ((buf[0] != 'O') || (buf[1] != 'K')) { MHD_stop_daemon (d); return 4; } } MHD_stop_daemon (d); if (LOOPCOUNT >= 99) fprintf (stderr, "\n"); return 0; } static unsigned int testMultithreadedPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; int i; char url[1024]; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1351; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } for (i = 0; i < LOOPCOUNT; i++) { if (99 == i % 100) fprintf (stderr, "."); c = curl_easy_init (); cbc.pos = 0; buf[0] = '\0'; snprintf (url, sizeof (url), "http://127.0.0.1:%u/hw%d", (unsigned int) port, i); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); curl_easy_setopt (c, CURLOPT_POST, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); if ((buf[0] != 'O') || (buf[1] != 'K')) { MHD_stop_daemon (d); return 64; } } MHD_stop_daemon (d); if (LOOPCOUNT >= 99) fprintf (stderr, "\n"); return 0; } static unsigned int testMultithreadedPoolPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; int i; char url[1024]; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1352; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } for (i = 0; i < LOOPCOUNT; i++) { if (99 == i % 100) fprintf (stderr, "."); c = curl_easy_init (); cbc.pos = 0; buf[0] = '\0'; snprintf (url, sizeof (url), "http://127.0.0.1:%u/hw%d", (unsigned int) port, i); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); curl_easy_setopt (c, CURLOPT_POST, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); if ((buf[0] != 'O') || (buf[1] != 'K')) { MHD_stop_daemon (d); return 64; } } MHD_stop_daemon (d); if (LOOPCOUNT >= 99) fprintf (stderr, "\n"); return 0; } static unsigned int testExternalPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; int i; uint64_t timeout64; long ctimeout; char url[1024]; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1353; if (oneone) port += 10; } multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } multi = curl_multi_init (); if (multi == NULL) { MHD_stop_daemon (d); return 512; } for (i = 0; i < LOOPCOUNT; i++) { if (99 == i % 100) fprintf (stderr, "."); c = curl_easy_init (); cbc.pos = 0; buf[0] = '\0'; snprintf (url, sizeof (url), "http://127.0.0.1:%u/hw%d", (unsigned int) port, i); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); curl_easy_setopt (c, CURLOPT_POST, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform (multi, &running)) ; mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } if (MHD_NO == MHD_get_timeout64 (d, &timeout64)) timeout64 = 100; /* 100ms == INFTY -- CURL bug... */ if ((CURLM_OK == curl_multi_timeout (multi, &ctimeout)) && (ctimeout >= 0) && ((uint64_t) ctimeout < timeout64)) timeout64 = (uint64_t) ctimeout; if (0 == running) timeout64 = 0; /* terminate quickly... */ #if ! defined(_WIN32) || defined(__CYGWIN__) tv.tv_sec = (time_t) (timeout64 / 1000); #else /* Native W32 */ tv.tv_sec = (long) (timeout64 / 1000); #endif /* Native W32 */ tv.tv_usec = (long) (1000 * (timeout64 % 1000)); if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform (multi, &running)) ; if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } break; } MHD_run (d); } if (NULL != c) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); } if ((buf[0] != 'O') || (buf[1] != 'K')) { curl_multi_cleanup (multi); MHD_stop_daemon (d); return 8192; } } curl_multi_cleanup (multi); MHD_stop_daemon (d); if (LOOPCOUNT >= 99) fprintf (stderr, "\n"); return 0; } /** * Time this round was started. */ static unsigned long long start_time; /** * Get the current timestamp * * @return current time in ms */ static unsigned long long now (void) { struct timeval tv; gettimeofday (&tv, NULL); return (((unsigned long long) tv.tv_sec * 1000LL) + ((unsigned long long) tv.tv_usec / 1000LL)); } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { start_time = now (); errorCount += testInternalPost (); fprintf (stderr, oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : "%s: Sequential POSTs (http/1.0) %f/s\n", "internal select", (double) 1000 * LOOPCOUNT / ((double) (now () - start_time) + 1.0)); start_time = now (); errorCount += testMultithreadedPost (); fprintf (stderr, oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : "%s: Sequential POSTs (http/1.0) %f/s\n", "multithreaded post", (double) 1000 * LOOPCOUNT / ((double) (now () - start_time) + 1.0)); start_time = now (); errorCount += testMultithreadedPoolPost (); fprintf (stderr, oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : "%s: Sequential POSTs (http/1.0) %f/s\n", "thread with pool", (double) 1000 * LOOPCOUNT / ((double) (now () - start_time) + 1.0)); } start_time = now (); errorCount += testExternalPost (); fprintf (stderr, oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : "%s: Sequential POSTs (http/1.0) %f/s\n", "external select", (double) 1000 * LOOPCOUNT / ((double) (now () - start_time) + 1.0)); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_process_headers.c0000644000175000017500000003760614530120375017062 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_process_headers.c * @brief Testcase for HTTP header access * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #ifndef WINDOWS #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif static int oneone; struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) { if ((0 == strcmp (key, MHD_HTTP_HEADER_HOST)) && (0 == strncmp (value, "127.0.0.1", strlen ("127.0.0.1"))) && (kind == MHD_HEADER_KIND)) { *((int *) cls) = 1; return MHD_NO; } return MHD_YES; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; const char *hdr; (void) cls; (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; ret = 0; MHD_get_connection_values (connection, MHD_HEADER_KIND, &kv_cb, &ret); if (ret != 1) abort (); hdr = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "NotFound"); if (hdr != NULL) abort (); hdr = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT); if ((hdr == NULL) || (0 != strcmp (hdr, "*/*"))) abort (); hdr = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST); if ((hdr == NULL) || (0 != strncmp (hdr, "127.0.0.1", strlen ("127.0.0.1")))) abort (); MHD_set_connection_value (connection, MHD_HEADER_KIND, "FakeHeader", "NowPresent"); hdr = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "FakeHeader"); if ((hdr == NULL) || (0 != strcmp (hdr, "NowPresent"))) abort (); response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); if (NULL == response) abort (); MHD_add_response_header (response, "MyHeader", "MyValue"); hdr = MHD_get_response_header (response, "MyHeader"); if (0 != strcmp ("MyValue", hdr)) abort (); MHD_add_response_header (response, "MyHeader", "MyValueToo"); if (MHD_YES != MHD_del_response_header (response, "MyHeader", "MyValue")) abort (); hdr = MHD_get_response_header (response, "MyHeader"); if (0 != strcmp ("MyValueToo", hdr)) abort (); if (1 != MHD_get_response_headers (response, NULL, NULL)) abort (); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) abort (); return ret; } static unsigned int testInternalGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1420; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; return 0; } static unsigned int testMultithreadedGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1421; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testMultithreadedPoolGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1422; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testExternalGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1423; if (oneone) port += 10; } multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 8192; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 16384; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalGet (); errorCount += testMultithreadedGet (); errorCount += testMultithreadedPoolGet (); } errorCount += testExternalGet (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/perf_get.c0000644000175000017500000004560114530120375014437 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009, 2011 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file perf_get.c * @brief benchmark simple GET operations (sequential access). * Note that we run libcurl in the same process at the * same time, so the execution time given is the combined * time for both MHD and libcurl; it is quite possible * that more time is spend with libcurl than with MHD, * so the performance scores calculated with this code * should NOT be used to compare with other HTTP servers * (since MHD is actually better); only the relative * scores between MHD versions are meaningful. * Furthermore, this code ONLY tests MHD processing * a single request at a time. This is again * not universally meaningful (i.e. when comparing * multithreaded vs. single-threaded or select/poll). * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #ifndef WINDOWS #include #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif /** * How many rounds of operations do we do for each * test? */ #if MHD_CPU_COUNT > 8 #ifndef _WIN32 #define ROUNDS (1 + (30000 / 12) / MHD_CPU_COUNT) #else /* _WIN32 */ #define ROUNDS (1 + (3000 / 12) / MHD_CPU_COUNT) #endif /* _WIN32 */ #else #define ROUNDS 500 #endif /** * Do we use HTTP 1.1? */ static int oneone; /** * Response to return (re-used). */ static struct MHD_Response *response; /** * Time this round was started. */ static unsigned long long start_time; /** * Get the current timestamp * * @return current time in ms */ static unsigned long long now (void) { struct timeval tv; gettimeofday (&tv, NULL); return (((unsigned long long) tv.tv_sec * 1000LL) + ((unsigned long long) tv.tv_usec / 1000LL)); } /** * Start the timer. */ static void start_timer (void) { start_time = now (); } /** * Stop the timer and report performance * * @param desc description of the threading mode we used */ static void stop (const char *desc) { double rps = ((double) (ROUNDS * 1000)) / ((double) (now () - start_time)); fprintf (stderr, "Sequential GETs using %s: %f %s\n", desc, rps, "requests/s"); } struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; enum MHD_Result ret; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; ret = MHD_queue_response (connection, MHD_HTTP_OK, response); if (ret == MHD_NO) abort (); return ret; } static unsigned int testInternalGet (uint16_t port, uint32_t poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; unsigned int i; char url[64]; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; cbc.buf = buf; cbc.size = 2048; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (url, sizeof (url), "http://127.0.0.1:%u/hello_world", (unsigned int) port); start_timer (); for (i = 0; i < ROUNDS; i++) { cbc.pos = 0; c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); } stop (poll_flag == MHD_USE_AUTO ? "internal thread with 'auto'" : poll_flag == MHD_USE_POLL ? "internal thread with poll()" : poll_flag == MHD_USE_EPOLL ? "internal thread with epoll" : "internal thread with select()"); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; return 0; } static unsigned int testMultithreadedGet (uint16_t port, uint32_t poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; unsigned int i; char url[64]; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; cbc.buf = buf; cbc.size = 2048; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (url, sizeof (url), "http://127.0.0.1:%u/hello_world", (unsigned int) port); start_timer (); for (i = 0; i < ROUNDS; i++) { cbc.pos = 0; c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); } stop ((poll_flag & MHD_USE_AUTO) ? "internal thread with 'auto' and thread per connection" : (poll_flag & MHD_USE_POLL) ? "internal thread with poll() and thread per connection" : (poll_flag & MHD_USE_EPOLL) ? "internal thread with epoll and thread per connection" : "internal thread with select() and thread per connection"); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testMultithreadedPoolGet (uint16_t port, uint32_t poll_flag) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; unsigned int i; char url[64]; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; cbc.buf = buf; cbc.size = 2048; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (url, sizeof (url), "http://127.0.0.1:%u/hello_world", (unsigned int) port); start_timer (); for (i = 0; i < ROUNDS; i++) { cbc.pos = 0; c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); } stop (0 != (poll_flag & MHD_USE_AUTO) ? "internal thread pool with 'auto'" : 0 != (poll_flag & MHD_USE_POLL) ? "internal thread pool with poll()" : 0 != (poll_flag & MHD_USE_EPOLL) ? "internal thread pool with epoll" : "internal thread pool with select()"); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testExternalGet (uint16_t port) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; unsigned int i; char url[64]; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; multi = NULL; cbc.buf = buf; cbc.size = 2048; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (NULL == d) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (url, sizeof (url), "http://127.0.0.1:%u/hello_world", (unsigned int) port); start_timer (); multi = curl_multi_init (); if (multi == NULL) { MHD_stop_daemon (d); return 512; } for (i = 0; i < ROUNDS; i++) { cbc.pos = 0; c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (c != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); c = NULL; break; } /* two possibilities here; as select sets are tiny, this makes virtually no difference in actual runtime right now, even though the number of select calls is virtually cut in half (and 'select' is the most expensive of our system calls according to 'strace') */ if (0) MHD_run (d); else MHD_run_from_select (d, &rs, &ws, &es); } if (NULL != c) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); fprintf (stderr, "Timeout!?\n"); } } stop ("external select"); if (multi != NULL) { curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 8192; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 16384; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; uint16_t port = 1130; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (oneone) port += 15; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; response = MHD_create_response_from_buffer_copy (strlen ("/hello_world"), "/hello_world"); errorCount += testExternalGet (port++); if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalGet (port++, MHD_USE_AUTO); errorCount += testMultithreadedGet (port++, MHD_USE_AUTO); errorCount += testMultithreadedPoolGet (port++, MHD_USE_AUTO); errorCount += testInternalGet (port++, 0); errorCount += testMultithreadedGet (port++, 0); errorCount += testMultithreadedPoolGet (port++, 0); if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { errorCount += testInternalGet (port++, MHD_USE_POLL); errorCount += testMultithreadedGet (port++, MHD_USE_POLL); errorCount += testMultithreadedPoolGet (port++, MHD_USE_POLL); } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { errorCount += testInternalGet (port++, MHD_USE_EPOLL); errorCount += testMultithreadedPoolGet (port++, MHD_USE_EPOLL); } } MHD_destroy_response (response); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return errorCount != 0; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_callback.c0000644000175000017500000001662714530120375015445 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009, 2011 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_callback.c * @brief Testcase for MHD not calling the callback too often * @author Jan Seeger * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include struct callback_closure { unsigned int called; }; static ssize_t called_twice (void *cls, uint64_t pos, char *buf, size_t max) { struct callback_closure *cls2 = cls; (void) pos; /* Unused. Silence compiler warning. */ (void) max; if (cls2->called == 0) { memcpy (buf, "test", 5); cls2->called = 1; return (ssize_t) strlen (buf); } if (cls2->called == 1) { cls2->called = 2; return MHD_CONTENT_READER_END_OF_STREAM; } fprintf (stderr, "Handler called after returning END_OF_STREAM!\n"); abort (); return MHD_CONTENT_READER_END_WITH_ERROR; } static enum MHD_Result callback (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct callback_closure *cbc = calloc (1, sizeof(struct callback_closure)); struct MHD_Response *r; enum MHD_Result ret; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ if (NULL == cbc) return MHD_NO; r = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 1024, &called_twice, cbc, &free); if (NULL == r) { free (cbc); return MHD_NO; } ret = MHD_queue_response (connection, MHD_HTTP_OK, r); MHD_destroy_response (r); return ret; } static size_t discard_buffer (void *ptr, size_t size, size_t nmemb, void *ctx) { (void) ptr; (void) ctx; /* Unused. Silent compiler warning. */ return size * nmemb; } int main (int argc, char **argv) { struct MHD_Daemon *d; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ CURL *c; CURLM *multi; CURLMcode mret; struct CURLMsg *msg; int running; struct timeval tv; int extra; uint16_t port; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1140; d = MHD_start_daemon (MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &callback, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 32; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 48; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &discard_buffer); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 99; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 99; } extra = 10; while ( (c != NULL) || (--extra > 0) ) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&ws); FD_ZERO (&rs); FD_ZERO (&es); curl_multi_perform (multi, &running); if (NULL != multi) { mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 99; } } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } if (NULL != multi) { curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } } MHD_run (d); } MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/testcurl/test_put_header_fold.c0000644000175000017500000011476714530120375017041 /* This file is part of GNU libmicrohttpd Copyright (C) 2010 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file testcurl/test_put_header_fold.c * @brief Testcase for requests with header fold * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #ifndef _WIN32 #include #include #endif #include "internal.h" #include "mhd_has_param.h" #include "mhd_has_in_name.h" /* The next macros are borrowed from memorypool.c Keep them in sync! */ /** * Align to 2x word size (as GNU libc does). */ #define ALIGN_SIZE (2 * sizeof(void*)) /** * Round up 'n' to a multiple of ALIGN_SIZE. */ #define ROUND_TO_ALIGN(n) (((n) + (ALIGN_SIZE - 1)) \ / (ALIGN_SIZE) *(ALIGN_SIZE)) #ifndef MHD_ASAN_POISON_ACTIVE #define _MHD_RED_ZONE_SIZE (0) #else /* MHD_ASAN_POISON_ACTIVE */ #define _MHD_RED_ZONE_SIZE (ALIGN_SIZE) #endif /* MHD_ASAN_POISON_ACTIVE */ #define ROUND_TO_ALIGN_PLUS_RED_ZONE(n) (ROUND_TO_ALIGN(n) + _MHD_RED_ZONE_SIZE) /* The previous macros are borrowed from memorypool.c Keep them in sync! */ #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __func__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func (NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func (NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func (NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func (errDesc, NULL, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), NULL, \ __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (8); } /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 #define TEST_UPLOAD_DATA_SIZE 2048U #define EXPECTED_URI_BASE_PATH "/" #define URL_SCHEME "http:/" "/" #define URL_HOST "127.0.0.1" #define URL_SCHEME_HOST_PATH URL_SCHEME URL_HOST EXPECTED_URI_BASE_PATH #define RP_HEADER1_NAME "First" #define RP_HEADER1_VALUE "1st" #define RP_HEADER1 RP_HEADER1_NAME ": " RP_HEADER1_VALUE #define RP_HEADER1_CRLF RP_HEADER1 "\r\n" #define RP_HEADER2_NAME "Normal" #define RP_HEADER2_VALUE "it's fine" #define RP_HEADER2 RP_HEADER2_NAME ": " RP_HEADER2_VALUE #define RP_HEADER2_CRLF RP_HEADER2 "\r\n" #define HDR_FOLD "\r\n " #define RQ_HEADER1_NAME RP_HEADER1_NAME #define RQ_HEADER1_VALUE RP_HEADER1_VALUE #define RQ_HEADER1 RQ_HEADER1_NAME ": " RQ_HEADER1_VALUE #define RQ_HEADER2_NAME "Folded" #define RQ_HEADER2_VALUE_S "start" #define RQ_HEADER2_VALUE_E "end" #define RQ_HEADER2_VALUE \ RQ_HEADER2_VALUE_S HDR_FOLD RQ_HEADER2_VALUE_E #define RQ_HEADER2_VALUE_DF \ RQ_HEADER2_VALUE_S HDR_FOLD HDR_FOLD RQ_HEADER2_VALUE_E #define RQ_HEADER2 RQ_HEADER2_NAME ": " RQ_HEADER2_VALUE #define RQ_HEADER2_DF RQ_HEADER2_NAME ": " RQ_HEADER2_VALUE_DF #define RQ_HEADER3_NAME RP_HEADER2_NAME #define RQ_HEADER3_VALUE RP_HEADER2_VALUE #define RQ_HEADER3 RQ_HEADER3_NAME ": " RQ_HEADER3_VALUE /** * The number of request headers: 3 custom headers + 2 automatic headers */ #define RQ_NUM_HEADERS (3 + 2) /** * The extra size in the memory pool for pointers to the headers */ #define HEADERS_POINTERS_SIZE \ RQ_NUM_HEADERS * \ ROUND_TO_ALIGN_PLUS_RED_ZONE(sizeof(struct MHD_HTTP_Req_Header)) #define PAGE \ "libmicrohttpd demo page" \ "Success!" /* Global parameters */ static int verbose; static int oneone; /**< If false use HTTP/1.0 for requests*/ static int use_get; static int use_put; static int use_put_large; static int use_double_fold; static int use_hdr_last; /**< If non-zero, folded header is placed last */ static int use_hdr_large; /**< If non-zero, folded header is large */ /* Static data */ static struct curl_slist *libcurl_headers = NULL; static char *put_data = NULL; /** * Initialise headers for libcurl * * @return non-zero if succeed, * zero if failed */ static void libcurl_headers_init (void) { libcurl_headers = curl_slist_append (NULL, RQ_HEADER1); if (NULL == libcurl_headers) libcurlErrorExitDesc ("curl_slist_append() failed"); if (use_hdr_last) { libcurl_headers = curl_slist_append (libcurl_headers, RQ_HEADER3); if (NULL == libcurl_headers) libcurlErrorExitDesc ("curl_slist_append() failed"); } if (! use_hdr_large) { if (! use_double_fold) libcurl_headers = curl_slist_append (libcurl_headers, RQ_HEADER2); else libcurl_headers = curl_slist_append (libcurl_headers, RQ_HEADER2_DF); if (NULL == libcurl_headers) libcurlErrorExitDesc ("curl_slist_append() failed"); } else { char *buf; size_t pos; buf = malloc (TEST_UPLOAD_DATA_SIZE + 1); if (NULL == buf) externalErrorExitDesc ("malloc() failed"); pos = 0; memcpy (buf, RQ_HEADER2_NAME, MHD_STATICSTR_LEN_ (RQ_HEADER2_NAME)); pos += MHD_STATICSTR_LEN_ (RQ_HEADER2_NAME); buf[pos++] = ':'; buf[pos++] = ' '; memcpy (buf + pos, RQ_HEADER2_VALUE_S, MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_S)); pos += MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_S); memcpy (buf + pos, HDR_FOLD, MHD_STATICSTR_LEN_ (HDR_FOLD)); pos += MHD_STATICSTR_LEN_ (HDR_FOLD); if (use_double_fold) { memcpy (buf + pos, HDR_FOLD, MHD_STATICSTR_LEN_ (HDR_FOLD)); pos += MHD_STATICSTR_LEN_ (HDR_FOLD); } memset (buf + pos, 'a', TEST_UPLOAD_DATA_SIZE - pos - MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E) - 1); pos += TEST_UPLOAD_DATA_SIZE - pos - MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E) - 1; buf[pos++] = ' '; memcpy (buf + pos, RQ_HEADER2_VALUE_E, MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E)); pos += MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E); if (TEST_UPLOAD_DATA_SIZE != pos) externalErrorExitDesc ("Position miscalculation"); buf[pos] = 0; libcurl_headers = curl_slist_append (libcurl_headers, buf); if (NULL == libcurl_headers) libcurlErrorExitDesc ("curl_slist_append() failed"); free (buf); } if (! use_hdr_last) { libcurl_headers = curl_slist_append (libcurl_headers, RQ_HEADER3); if (NULL == libcurl_headers) libcurlErrorExitDesc ("curl_slist_append() failed"); } } static void init_put_data (void) { size_t i; put_data = malloc (TEST_UPLOAD_DATA_SIZE + 1); if (NULL == put_data) externalErrorExit (); for (i = 0; i < (TEST_UPLOAD_DATA_SIZE - 1); ++i) { if (0 == (i % 7)) put_data[i] = ' '; else if (0 == (i % 47)) put_data[i] = '\n'; else if (0 == (i % 11)) put_data[i] = (char) ('A' + i % ('Z' - 'A' + 1)); else put_data[i] = (char) ('a' + i % ('z' - 'a' + 1)); } put_data[TEST_UPLOAD_DATA_SIZE - 1] = '\n'; put_data[TEST_UPLOAD_DATA_SIZE] = 0; } static void test_global_init (void) { libcurl_errbuf[0] = 0; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) externalErrorExit (); init_put_data (); libcurl_headers_init (); } static void test_global_cleanup (void) { curl_slist_free_all (libcurl_headers); curl_global_cleanup (); if (NULL != put_data) free (put_data); put_data = NULL; } struct headers_check_result { unsigned int expected_size; int header1_found; int header2_found; unsigned int size_found; unsigned int size_broken_found; }; static size_t lcurl_hdr_callback (char *buffer, size_t size, size_t nitems, void *userdata) { const size_t data_size = size * nitems; struct headers_check_result *check_res = (struct headers_check_result *) userdata; if ((MHD_STATICSTR_LEN_ (RP_HEADER1_CRLF) == data_size) && (0 == memcmp (RP_HEADER1_CRLF, buffer, data_size))) check_res->header1_found++; else if ((MHD_STATICSTR_LEN_ (RP_HEADER2_CRLF) == data_size) && (0 == memcmp (RP_HEADER2_CRLF, buffer, data_size))) check_res->header2_found++; else if ((MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": ") < data_size) && (0 == memcmp (MHD_HTTP_HEADER_CONTENT_LENGTH ": ", buffer, MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": ")))) { char cmpbuf[256]; int res; const unsigned int numbers_pos = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": "); res = snprintf (cmpbuf, sizeof(cmpbuf), "%u", check_res->expected_size); if ((res <= 0) || (res > ((int) (sizeof(cmpbuf) - 1)))) externalErrorExit (); if (data_size - numbers_pos <= 2) { fprintf (stderr, "Broken Content-Length.\n"); check_res->size_broken_found++; } else if ((((size_t) res + 2) != data_size - numbers_pos) || (0 != memcmp (buffer + numbers_pos, cmpbuf, (size_t) res))) { fprintf (stderr, "Wrong Content-Length. " "Expected: %u. " "Received: %.*s.\n", check_res->expected_size, (int) (data_size - numbers_pos - 2), buffer + numbers_pos); check_res->size_broken_found++; } else if (0 != memcmp ("\r\n", buffer + data_size - 2, 2)) { fprintf (stderr, "The Content-Length header is not " "terminated by CRLF.\n"); check_res->size_broken_found++; } else check_res->size_found++; } return data_size; } struct CBC { /* Upload members */ size_t up_pos; size_t up_size; /* Download members */ char *dn_buf; size_t dn_pos; size_t dn_buf_size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->dn_pos + size * nmemb > cbc->dn_buf_size) return 0; /* overflow */ memcpy (&cbc->dn_buf[cbc->dn_pos], ptr, size * nmemb); cbc->dn_pos += size * nmemb; return size * nmemb; } static size_t libcurlUploadDataCB (void *stream, size_t item_size, size_t nitems, void *ctx) { size_t to_fill; struct CBC *cbc = ctx; to_fill = cbc->up_size - cbc->up_pos; if (to_fill > item_size * nitems) to_fill = item_size * nitems; /* Avoid libcurl magic numbers */ #ifdef CURL_READFUNC_PAUSE if (CURL_READFUNC_PAUSE == to_fill) to_fill = (CURL_READFUNC_PAUSE - 2); #endif /* CURL_READFUNC_PAUSE */ #ifdef CURL_READFUNC_ABORT if (CURL_READFUNC_ABORT == to_fill) to_fill = (CURL_READFUNC_ABORT - 1); #endif /* CURL_READFUNC_ABORT */ memcpy (stream, put_data + cbc->up_pos, to_fill); cbc->up_pos += to_fill; return to_fill; } static int libcurl_debug_cb (CURL *handle, curl_infotype type, char *data, size_t size, void *userptr) { static const char excess_mark[] = "Excess found"; static const size_t excess_mark_len = MHD_STATICSTR_LEN_ (excess_mark); (void) handle; (void) userptr; #ifdef _DEBUG switch (type) { case CURLINFO_TEXT: fprintf (stderr, "* %.*s", (int) size, data); break; case CURLINFO_HEADER_IN: fprintf (stderr, "< %.*s", (int) size, data); break; case CURLINFO_HEADER_OUT: fprintf (stderr, "> %.*s", (int) size, data); break; case CURLINFO_DATA_IN: #if 0 fprintf (stderr, "<| %.*s\n", (int) size, data); #endif break; case CURLINFO_DATA_OUT: case CURLINFO_SSL_DATA_IN: case CURLINFO_SSL_DATA_OUT: case CURLINFO_END: default: break; } #endif /* _DEBUG */ if (CURLINFO_TEXT == type) { if ((size >= excess_mark_len) && (0 == memcmp (data, excess_mark, excess_mark_len))) mhdErrorExitDesc ("Extra data has been detected in MHD reply"); } return 0; } static CURL * setupCURL (void *cbc, uint16_t port, struct headers_check_result *hdr_chk_result) { CURL *c; c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HEADERFUNCTION, lcurl_hdr_callback)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HEADERDATA, hdr_chk_result)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 0L)) || #ifdef _DEBUG (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) || #endif /* _DEBUG */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &libcurl_debug_cb)) || #if CURL_AT_LEAST_VERSION (7, 45, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) || #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ #if CURL_AT_LEAST_VERSION (7, 85, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http")) || #elif CURL_AT_LEAST_VERSION (7, 19, 4) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) || #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, URL_SCHEME_HOST_PATH)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) port)))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); if (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPHEADER, libcurl_headers)) libcurlErrorExitDesc ("Failed to set request headers"); if (use_put) { if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_UPLOAD, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_READFUNCTION, libcurlUploadDataCB)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_READDATA, cbc))) libcurlErrorExitDesc ("Failed to configure the PUT upload"); } return c; } struct ahc_cls_type { const char *rq_method; const char *rq_url; unsigned int num_req; /* Position in the upload data, not compatible with parallel requests */ size_t up_pos; size_t expected_upload_size; unsigned int req_check_error; }; static enum MHD_Result ahcCheck (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker; struct MHD_Response *response; enum MHD_Result ret; struct ahc_cls_type *const param = (struct ahc_cls_type *) cls; if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); if (oneone) { if (0 != strcmp (version, MHD_HTTP_VERSION_1_1)) mhdErrorExitDesc ("Unexpected HTTP version"); } else { if (0 != strcmp (version, MHD_HTTP_VERSION_1_0)) mhdErrorExitDesc ("Unexpected HTTP version"); } if (0 != strcmp (url, param->rq_url)) mhdErrorExitDesc ("Unexpected URI"); if (0 != strcmp (param->rq_method, method)) mhdErrorExitDesc ("Unexpected request method"); if (NULL == upload_data_size) mhdErrorExitDesc ("'upload_data_size' pointer is NULL"); if (NULL != upload_data) { size_t report_processed_size; if (0 == *upload_data_size) mhdErrorExitDesc ("'*upload_data_size' value is zero"); report_processed_size = *upload_data_size; /* The next checks are not compatible with parallel requests */ if (*upload_data_size > param->expected_upload_size - param->up_pos) { fprintf (stderr, "Unexpected *upload_data_size value: %lu. " "Already processed data size: %lu. " "Total expected upload size: %lu. " "Expected unprocessed upload size: %lu. " "The upload data cannot be checked.\n", (unsigned long) *upload_data_size, (unsigned long) param->up_pos, (unsigned long) param->expected_upload_size, (unsigned long) (param->expected_upload_size - param->up_pos)); param->req_check_error++; } else { if (0 != memcmp (upload_data, put_data + param->up_pos, *upload_data_size)) { fprintf (stderr, "Wrong upload data.\n" "Expected: '%.*s'\n" "Received: '%.*s'.\n", (int) *upload_data_size, upload_data, (int) *upload_data_size, put_data + param->up_pos); param->req_check_error++; } if (use_put_large && (report_processed_size > param->expected_upload_size / 10)) report_processed_size = param->expected_upload_size / 10; param->up_pos += report_processed_size; } *upload_data_size -= report_processed_size; return MHD_YES; } else { if (0 != *upload_data_size) mhdErrorExitDesc ("'*upload_data_size' value is not zero"); } if (1) { /* Check headers */ const char *value; size_t value_len; unsigned int header_check_error; header_check_error = 0; value = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, RQ_HEADER1_NAME); if (NULL == value) { fprintf (stderr, "Request header '" RQ_HEADER1_NAME "' not found.\n"); header_check_error++; } else { if (0 != strcmp (value, RQ_HEADER1_VALUE)) { fprintf (stderr, "Wrong header '" RQ_HEADER1_NAME "'value. " "Expected: '%s'. Received: '%s'.\n", RQ_HEADER1_VALUE, value); header_check_error++; } } if (MHD_YES != MHD_lookup_connection_value_n (connection, MHD_HEADER_KIND, RQ_HEADER2_NAME, MHD_STATICSTR_LEN_ (RQ_HEADER2_NAME), &value, &value_len)) { fprintf (stderr, "Request header '" RQ_HEADER2_NAME "' not found.\n"); header_check_error++; } else { if (NULL == value) mhdErrorExitDesc ("The 'value' pointer is NULL"); if (strlen (value) != value_len) mhdErrorExitDesc ("The 'value' length does not match strlen(value)"); if (value_len < MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_S) + MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E)) { fprintf (stderr, "The value_len is too short. The value: '%s'.\n", value); header_check_error++; } if (0 != memcmp (value, RQ_HEADER2_VALUE_S, MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_S))) { fprintf (stderr, "The 'value' does not start with '" RQ_HEADER2_VALUE_S "'. The 'value' is '%s'. ", value); header_check_error++; } if (0 != memcmp (value + value_len - MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E), RQ_HEADER2_VALUE_E, MHD_STATICSTR_LEN_ (RQ_HEADER2_VALUE_E))) { fprintf (stderr, "The 'value' does not end with '" RQ_HEADER2_VALUE_E "'. The 'value' is '%s'. ", value); header_check_error++; } } value = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, RQ_HEADER3_NAME); if (NULL == value) { fprintf (stderr, "Request header '" RQ_HEADER3_NAME "' not found.\n"); header_check_error++; } else { if (0 != strcmp (value, RQ_HEADER3_VALUE)) { fprintf (stderr, "Wrong header '" RQ_HEADER3_NAME "'value. " "Expected: '%s'. Received: '%s'.\n", RQ_HEADER3_VALUE, value); header_check_error++; } } param->req_check_error += header_check_error; } if (&marker != *req_cls) { *req_cls = ▮ if (param->num_req) mhdErrorExitDesc ("Got unexpected second request"); param->num_req++; return MHD_YES; } *req_cls = NULL; if (0 != strcmp (url, EXPECTED_URI_BASE_PATH)) { fprintf (stderr, "Unexpected URI: '%s'. ", url); mhdErrorExitDesc ("Unexpected URI found"); } response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE), PAGE); if (NULL == response) mhdErrorExitDesc ("Failed to create response"); if (MHD_YES != MHD_add_response_header (response, RP_HEADER1_NAME, RP_HEADER1_VALUE)) mhdErrorExitDesc ("Cannot add header1"); if (MHD_YES != MHD_add_response_header (response, RP_HEADER2_NAME, RP_HEADER2_VALUE)) mhdErrorExitDesc ("Cannot add header2"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (MHD_YES != ret) mhdErrorExitDesc ("Failed to queue response"); return ret; } static CURLcode performQueryExternal (struct MHD_Daemon *d, CURL *c, CURLM **multi_reuse) { CURLM *multi; time_t start; struct timeval tv; CURLcode ret; int libcurl_finished; ret = CURLE_FAILED_INIT; /* will be replaced with real result */ if (NULL != *multi_reuse) multi = *multi_reuse; else { multi = curl_multi_init (); if (multi == NULL) libcurlErrorExitDesc ("curl_multi_init() failed"); *multi_reuse = multi; } if (CURLM_OK != curl_multi_add_handle (multi, c)) libcurlErrorExitDesc ("curl_multi_add_handle() failed"); libcurl_finished = 0; start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (! libcurl_finished) { int running; curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) libcurlErrorExitDesc ("curl_multi_info_read() failed"); totalMsgs++; if (CURLMSG_DONE == msg->msg) ret = msg->data.result; } while (msgLeft > 0); if (1 != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); externalErrorExit (); } curl_multi_remove_handle (multi, c); libcurl_finished = ! 0; } else { if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) libcurlErrorExitDesc ("curl_multi_fdset() failed"); } } if (libcurl_finished) { /* libcurl has finished, check whether MHD still needs to perform cleanup */ if (0 != MHD_get_timeout64s (d)) break; /* MHD finished as well */ } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); tv.tv_sec = 0; tv.tv_usec = 200000; if (0 == MHD_get_timeout64s (d)) tv.tv_usec = 0; else { long curl_to = -1; curl_multi_timeout (multi, &curl_to); if (0 == curl_to) tv.tv_usec = 0; } #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep ((unsigned long) tv.tv_usec / 1000); #endif } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); } return ret; } /** * Check request result * @param curl_code the CURL easy return code * @param pcbc the pointer struct CBC * @return non-zero if success, zero if failed */ static unsigned int check_result (CURLcode curl_code, CURL *c, long expected_code, struct CBC *pcbc, struct headers_check_result *hdr_res, struct ahc_cls_type *ahc_cls) { long code; unsigned int ret; fflush (stderr); fflush (stdout); if (CURLE_OK != curl_code) { fflush (stdout); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n" "libcurl error description: '%s'.\n", curl_easy_strerror (curl_code), libcurl_errbuf); else fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n", curl_easy_strerror (curl_code)); return 0; } if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code)) libcurlErrorExit (); if (expected_code != code) { fprintf (stderr, "The response has wrong HTTP code: %ld\tExpected: %ld.\n", code, expected_code); return 0; } else if (verbose) printf ("The response has expected HTTP code: %ld\n", expected_code); ret = 1; if (ahc_cls->req_check_error) { fprintf (stderr, "One or more errors have been detected by access " "handler callback.\n"); ret = 0; } if (ahc_cls->expected_upload_size != ahc_cls->up_pos) { fprintf (stderr, "Upload size does not match expected. " "Expected: %lu. " "Received: %lu.\n", (unsigned long) ahc_cls->expected_upload_size, (unsigned long) ahc_cls->up_pos); ret = 0; } if (1 != hdr_res->header1_found) { if (0 == hdr_res->header1_found) fprintf (stderr, "Response header1 was not found.\n"); else fprintf (stderr, "Response header1 was found %d times " "instead of one time only.\n", hdr_res->header1_found); ret = 0; } else if (verbose) printf ("Header1 is present in the response.\n"); if (1 != hdr_res->header2_found) { if (0 == hdr_res->header2_found) fprintf (stderr, "Response header2 was not found.\n"); else fprintf (stderr, "Response header2 was found %d times " "instead of one time only.\n", hdr_res->header2_found); ret = 0; } else if (verbose) printf ("Header2 is present in the response.\n"); if (1 != hdr_res->size_found) { if (0 == hdr_res->size_found) fprintf (stderr, "Correct response 'Content-Length' header " "was not found.\n"); else fprintf (stderr, "Correct response 'Content-Length' header " "was found %u times instead of one time only.\n", hdr_res->size_found); ret = 0; } else if (verbose) printf ("'Content-Length' header with correct value " "is present in the response.\n"); if (0 != hdr_res->size_broken_found) { fprintf (stderr, "Wrong response 'Content-Length' header was found " "%u times.\n", hdr_res->size_broken_found); ret = 0; } if (pcbc->dn_pos != MHD_STATICSTR_LEN_ (PAGE)) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) pcbc->dn_pos, (int) pcbc->dn_pos, pcbc->dn_buf, (unsigned) MHD_STATICSTR_LEN_ (PAGE)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != memcmp (PAGE, pcbc->dn_buf, pcbc->dn_pos)) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) pcbc->dn_pos, pcbc->dn_buf); mhdErrorExitDesc ("Wrong returned data"); } fflush (stderr); fflush (stdout); return ret; } static unsigned int performCheck (void) { struct MHD_Daemon *d; uint16_t port; struct CBC cbc; struct ahc_cls_type ahc_param; struct headers_check_result rp_headers_check; char buf[2048]; CURL *c; CURLM *multi_reuse; int failed = 0; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = UINT16_C (4220); if (! oneone) port += UINT16_C (1); if (use_put) port += UINT16_C (2); if (use_put_large) port += UINT16_C (4); if (use_hdr_last) port += UINT16_C (8); if (use_hdr_large) port += UINT16_C (16); } if (1) { size_t mem_limit; if (use_put_large) mem_limit = (size_t) (TEST_UPLOAD_DATA_SIZE / 2 + HEADERS_POINTERS_SIZE); else mem_limit = (size_t) ((TEST_UPLOAD_DATA_SIZE * 4) / 3 + 2 + HEADERS_POINTERS_SIZE); d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahcCheck, &ahc_param, MHD_OPTION_CONNECTION_MEMORY_LIMIT, mem_limit, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); } if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); port = dinfo->port; } /* First request */ ahc_param.rq_method = use_put ? MHD_HTTP_METHOD_PUT : MHD_HTTP_METHOD_GET; ahc_param.rq_url = EXPECTED_URI_BASE_PATH; ahc_param.expected_upload_size = use_put ? TEST_UPLOAD_DATA_SIZE : 0; ahc_param.req_check_error = 0; ahc_param.num_req = 0; ahc_param.up_pos = 0; rp_headers_check.expected_size = MHD_STATICSTR_LEN_ (PAGE); rp_headers_check.header1_found = 0; rp_headers_check.header2_found = 0; rp_headers_check.size_found = 0; rp_headers_check.size_broken_found = 0; cbc.dn_buf = buf; cbc.dn_buf_size = sizeof (buf); cbc.dn_pos = 0; memset (cbc.dn_buf, 0, cbc.dn_buf_size); cbc.up_size = TEST_UPLOAD_DATA_SIZE; cbc.up_pos = 0; c = setupCURL (&cbc, port, &rp_headers_check); multi_reuse = NULL; /* First request */ if (check_result (performQueryExternal (d, c, &multi_reuse), c, MHD_HTTP_OK, &cbc, &rp_headers_check, &ahc_param)) { fflush (stderr); if (verbose) printf ("Got first expected response.\n"); fflush (stdout); } else { fprintf (stderr, "First request FAILED.\n"); fflush (stderr); failed = 1; } /* Second request */ ahc_param.req_check_error = 0; ahc_param.num_req = 0; ahc_param.up_pos = 0; rp_headers_check.header1_found = 0; rp_headers_check.header2_found = 0; rp_headers_check.size_found = 0; rp_headers_check.size_broken_found = 0; /* Reset buffer position */ cbc.dn_pos = 0; memset (cbc.dn_buf, 0, cbc.dn_buf_size); cbc.up_pos = 0; if (check_result (performQueryExternal (d, c, &multi_reuse), c, MHD_HTTP_OK, &cbc, &rp_headers_check, &ahc_param)) { fflush (stderr); if (verbose) printf ("Got second expected response.\n"); fflush (stdout); } else { fprintf (stderr, "Second request FAILED.\n"); fflush (stderr); failed = 1; } /* Third request */ ahc_param.req_check_error = 0; ahc_param.num_req = 0; ahc_param.up_pos = 0; rp_headers_check.header1_found = 0; rp_headers_check.header2_found = 0; rp_headers_check.size_found = 0; rp_headers_check.size_broken_found = 0; /* Reset buffer position */ cbc.dn_pos = 0; memset (cbc.dn_buf, 0, cbc.dn_buf_size); cbc.up_pos = 0; if (NULL != multi_reuse) curl_multi_cleanup (multi_reuse); multi_reuse = NULL; /* Force new connection */ if (check_result (performQueryExternal (d, c, &multi_reuse), c, MHD_HTTP_OK, &cbc, &rp_headers_check, &ahc_param)) { fflush (stderr); if (verbose) printf ("Got third expected response.\n"); fflush (stdout); } else { fprintf (stderr, "Third request FAILED.\n"); fflush (stderr); failed = 1; } curl_easy_cleanup (c); if (NULL != multi_reuse) curl_multi_cleanup (multi_reuse); MHD_stop_daemon (d); return failed ? 1 : 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; /* Test type and test parameters */ verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); oneone = ! has_in_name (argv[0], "10"); use_get = has_in_name (argv[0], "_get"); use_put = has_in_name (argv[0], "_put"); use_double_fold = has_in_name (argv[0], "_double_fold"); use_put_large = has_in_name (argv[0], "_put_large"); use_hdr_last = has_in_name (argv[0], "_last"); use_hdr_large = has_in_name (argv[0], "_fold_large"); if (1 != ((use_get ? 1 : 0) + (use_put ? 1 : 0))) { fprintf (stderr, "Wrong test name '%s': no or multiple indications " "for the test type.\n", argv[0] ? argv[0] : "(NULL)"); return 99; } test_global_init (); errorCount += performCheck (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); test_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_put_chunked.c0000644000175000017500000003715614522742656016237 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file daemontest_put_chunked.c * @brief Testcase for libmicrohttpd PUT operations with chunked encoding * for the upload data * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #ifndef WINDOWS #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif struct CBC { char *buf; size_t pos; size_t size; }; static size_t putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) { size_t *pos = ptr; size_t wrt; wrt = size * nmemb; if (wrt > 8 - (*pos)) wrt = 8 - (*pos); if (wrt > 4) wrt = 4; /* only send half at first => force multiple chunks! */ memcpy (stream, &("Hello123"[*pos]), wrt); (*pos) += wrt; return wrt; } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { size_t *done = cls; struct MHD_Response *response; enum MHD_Result ret; size_t have; (void) version; (void) req_cls; /* Unused. Silent compiler warning. */ if (0 != strcmp ("PUT", method)) return MHD_NO; /* unexpected method */ if ((*done) < 8) { have = *upload_data_size; if (have + *done > 8) { printf ("Invalid upload data `%8s'!\n", upload_data); return MHD_NO; } if (0 == have) return MHD_YES; if (0 == memcmp (upload_data, &"Hello123"[*done], have)) { *done += have; *upload_data_size = 0; } else { printf ("Invalid upload data `%8s'!\n", upload_data); return MHD_NO; } #if 0 fprintf (stderr, "Not ready for response: %u/%u\n", *done, 8); #endif return MHD_YES; } response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int testInternalPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; size_t done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1440; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); /* by not giving the file size, we force chunking! */ /* curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); */ curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; return 0; } static unsigned int testMultithreadedPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; size_t done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1441; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); /* by not giving the file size, we force chunking! */ /* curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); */ curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testMultithreadedPoolPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; size_t done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1442; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); /* by not giving the file size, we force chunking! */ /* curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); */ curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testExternalPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; size_t pos = 0; size_t done_flag = 0; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1443; multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); /* by not giving the file size, we force chunking! */ /* curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); */ curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 8192; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 16384; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalPut (); errorCount += testMultithreadedPut (); errorCount += testMultithreadedPoolPut (); } errorCount += testExternalPut (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_quiesce_stream.c0000644000175000017500000001513214556023140016710 /* This file is part of libmicrohttpd Copyright (C) 2016 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_quiesce_stream.c * @brief Testcase for libmicrohttpd quiescing * @author Markus Doppelbauer * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include #include #include #include #ifdef HAVE_UNISTD_H #include #elif defined(_WIN32) #include #define sleep(s) (Sleep ((s) * 1000), 0) #endif /* _WIN32 */ static volatile unsigned int request_counter; _MHD_NORETURN static void http_PanicCallback (void *cls, const char *file, unsigned int line, const char *reason) { (void) cls; /* Unused. Silent compiler warning. */ fprintf (stderr, "PANIC: exit process: %s at %s:%u\n", reason, file, line); exit (EXIT_FAILURE); } static void * resume_connection (void *arg) { struct MHD_Connection *connection = arg; /* fprintf (stderr, "Calling resume\n"); */ MHD_resume_connection (connection); return NULL; } static void suspend_connection (struct MHD_Connection *connection) { pthread_t thread_id; int status; /* fprintf (stderr, "Calling suspend\n"); */ MHD_suspend_connection (connection); status = pthread_create (&thread_id, NULL, &resume_connection, connection); if (0 != status) { fprintf (stderr, "Could not create thead\n"); exit (EXIT_FAILURE); } pthread_detach (thread_id); } struct ContentReaderUserdata { size_t bytes_written; struct MHD_Connection *connection; }; static ssize_t http_ContentReaderCallback (void *cls, uint64_t pos, char *buf, size_t max) { static const char alphabet[] = "\nABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; struct ContentReaderUserdata *userdata = cls; (void) pos; (void) max; /* Unused. Silent compiler warning. */ if (userdata->bytes_written >= 1024) { fprintf (stderr, "finish: %u\n", request_counter); return MHD_CONTENT_READER_END_OF_STREAM; } userdata->bytes_written++; buf[0] = alphabet[userdata->bytes_written % (sizeof(alphabet) - 1)]; suspend_connection (userdata->connection); return 1; } static void free_crc_data (void *crc_data) { struct ContentReaderUserdata *userdata = crc_data; free (userdata); } static enum MHD_Result http_AccessHandlerCallback (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { enum MHD_Result ret; struct MHD_Response *response; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ /* Never respond on first call */ if (NULL == *req_cls) { struct ContentReaderUserdata *userdata; fprintf (stderr, "start: %u\n", ++request_counter); userdata = malloc (sizeof(struct ContentReaderUserdata)); if (NULL == userdata) return MHD_NO; userdata->bytes_written = 0; userdata->connection = connection; *req_cls = userdata; return MHD_YES; } /* Second call: create response */ response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 32 * 1024, &http_ContentReaderCallback, *req_cls, &free_crc_data); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); suspend_connection (connection); return ret; } int main (void) { uint16_t port; char command_line[1024]; /* Flags */ unsigned int daemon_flags = MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_AUTO | MHD_ALLOW_SUSPEND_RESUME | MHD_USE_ITC; struct MHD_Daemon *daemon; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1470; /* Panic callback */ MHD_set_panic_func (&http_PanicCallback, NULL); /* Create daemon */ daemon = MHD_start_daemon (daemon_flags, port, NULL, NULL, &http_AccessHandlerCallback, NULL, MHD_OPTION_END); if (NULL == daemon) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (daemon, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (daemon); return 32; } port = dinfo->port; } snprintf (command_line, sizeof (command_line), "curl -s http://127.0.0.1:%u", (unsigned int) port); if (0 != system (command_line)) { MHD_stop_daemon (daemon); return 1; } /* wait for a request */ while (0 == request_counter) (void) sleep (1); fprintf (stderr, "quiesce\n"); MHD_quiesce_daemon (daemon); /* wait a second */ (void) sleep (1); fprintf (stderr, "stopping daemon\n"); MHD_stop_daemon (daemon); return 0; } libmicrohttpd-1.0.1/src/testcurl/test_head.c0000644000175000017500000006242514530120375014607 /* This file is part of GNU libmicrohttpd Copyright (C) 2010 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file testcurl/test_head.c * @brief Testcase for HEAD requests * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #ifndef _WIN32 #include #include #else #include #endif #include "mhd_has_param.h" #include "mhd_has_in_name.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __func__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func (NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func (NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func (NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func (errDesc, NULL, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), NULL, \ __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (8); } /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 #define EXPECTED_URI_BASE_PATH "/" #define EXISTING_URI EXPECTED_URI_BASE_PATH #define EXPECTED_URI_BASE_PATH_MISSING "/wrong_uri" #define URL_SCHEME "http:/" "/" #define URL_HOST "127.0.0.1" #define URL_SCHEME_HOST URL_SCHEME URL_HOST #define HEADER1_NAME "First" #define HEADER1_VALUE "1st" #define HEADER1 HEADER1_NAME ": " HEADER1_VALUE #define HEADER1_CRLF HEADER1 "\r\n" #define HEADER2_NAME "Normal" #define HEADER2_VALUE "it's fine" #define HEADER2 HEADER2_NAME ": " HEADER2_VALUE #define HEADER2_CRLF HEADER2 "\r\n" #define PAGE \ "libmicrohttpd demo page" \ "Success!" #define PAGE_404 \ "404 error" \ "Error 404: The requested URI does not exist" /* Global parameters */ static int verbose; static int oneone; /**< If false use HTTP/1.0 for requests*/ static void test_global_init (void) { libcurl_errbuf[0] = 0; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) externalErrorExit (); } static void test_global_cleanup (void) { curl_global_cleanup (); } struct headers_check_result { unsigned int expected_size; int header1_found; int header2_found; int size_found; }; static size_t lcurl_hdr_callback (char *buffer, size_t size, size_t nitems, void *userdata) { const size_t data_size = size * nitems; struct headers_check_result *check_res = (struct headers_check_result *) userdata; if ((MHD_STATICSTR_LEN_ (HEADER1_CRLF) == data_size) && (0 == memcmp (HEADER1_CRLF, buffer, data_size))) check_res->header1_found++; else if ((MHD_STATICSTR_LEN_ (HEADER2_CRLF) == data_size) && (0 == memcmp (HEADER2_CRLF, buffer, data_size))) check_res->header2_found++; else if ((MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": ") < data_size) && (0 == memcmp (MHD_HTTP_HEADER_CONTENT_LENGTH ": ", buffer, MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": ")))) { char cmpbuf[256]; int res; const unsigned int numbers_pos = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": "); res = snprintf (cmpbuf, sizeof(cmpbuf), "%u", check_res->expected_size); if ((res <= 0) || (res > ((int) (sizeof(cmpbuf) - 1)))) externalErrorExit (); if (data_size - numbers_pos <= 2) mhdErrorExitDesc ("Broken Content-Length"); else if ((((size_t) res + 2) != data_size - numbers_pos) || (0 != memcmp (buffer + numbers_pos, cmpbuf, (size_t) res))) { fprintf (stderr, "Wrong Content-Length.\n" "Expected:\n%u\n" "Received:\n%s", check_res->expected_size, buffer + numbers_pos); mhdErrorExitDesc ("Wrong Content-Length"); } else if (0 != memcmp ("\r\n", buffer + data_size - 2, 2)) { mhdErrorExitDesc ("The Content-Length header is not " \ "terminated by CRLF"); } check_res->size_found++; } return data_size; } struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { (void) ptr; /* Unused, mute compiler warning */ (void) ctx; /* Unused, mute compiler warning */ if ((0 != size) && (0 != nmemb)) libcurlErrorExitDesc ("Received unexpected body data"); return size * nmemb; } struct ahc_cls_type { const char *rq_method; const char *rq_url; }; static enum MHD_Result ahcCheck (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker; struct MHD_Response *response; enum MHD_Result ret; struct ahc_cls_type *const param = (struct ahc_cls_type *) cls; unsigned int http_code; if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); if (oneone) { if (0 != strcmp (version, MHD_HTTP_VERSION_1_1)) mhdErrorExitDesc ("Unexpected HTTP version"); } else { if (0 != strcmp (version, MHD_HTTP_VERSION_1_0)) mhdErrorExitDesc ("Unexpected HTTP version"); } if (0 != strcmp (url, param->rq_url)) mhdErrorExitDesc ("Unexpected URI"); if (NULL != upload_data) mhdErrorExitDesc ("'upload_data' is not NULL"); if (NULL == upload_data_size) mhdErrorExitDesc ("'upload_data_size' pointer is NULL"); if (0 != *upload_data_size) mhdErrorExitDesc ("'*upload_data_size' value is not zero"); if (0 != strcmp (param->rq_method, method)) mhdErrorExitDesc ("Unexpected request method"); if (&marker != *req_cls) { *req_cls = ▮ return MHD_YES; } *req_cls = NULL; if (0 == strcmp (url, EXISTING_URI)) { response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE), PAGE); http_code = MHD_HTTP_OK; } else { response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE_404), PAGE_404); http_code = MHD_HTTP_NOT_FOUND; } if (NULL == response) mhdErrorExitDesc ("Failed to create response"); if (MHD_YES != MHD_add_response_header (response, HEADER1_NAME, HEADER1_VALUE)) mhdErrorExitDesc ("Cannot add header1"); if (MHD_YES != MHD_add_response_header (response, HEADER2_NAME, HEADER2_VALUE)) mhdErrorExitDesc ("Cannot add header2"); ret = MHD_queue_response (connection, http_code, response); MHD_destroy_response (response); if (MHD_YES != ret) mhdErrorExitDesc ("Failed to queue response"); return ret; } /** * Set required URI for the request * @param c the CURL handle to use * @param uri_exist if non-zero use request for "existing" URI */ static void setCURL_rq_path (CURL *c, int uri_exist) { if (uri_exist) { if (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, URL_SCHEME_HOST EXPECTED_URI_BASE_PATH)) libcurlErrorExitDesc ("Cannot set request URL"); } else { if (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, URL_SCHEME_HOST EXPECTED_URI_BASE_PATH_MISSING)) libcurlErrorExitDesc ("Cannot set request URL"); } } static int libcurl_debug_cb (CURL *handle, curl_infotype type, char *data, size_t size, void *userptr) { static const char excess_mark[] = "Excess found"; static const size_t excess_mark_len = MHD_STATICSTR_LEN_ (excess_mark); (void) handle; (void) userptr; #ifdef _DEBUG switch (type) { case CURLINFO_TEXT: fprintf (stderr, "* %.*s", (int) size, data); break; case CURLINFO_HEADER_IN: fprintf (stderr, "< %.*s", (int) size, data); break; case CURLINFO_HEADER_OUT: fprintf (stderr, "> %.*s", (int) size, data); break; case CURLINFO_DATA_IN: #if 0 fprintf (stderr, "<| %.*s\n", (int) size, data); #endif break; case CURLINFO_DATA_OUT: case CURLINFO_SSL_DATA_IN: case CURLINFO_SSL_DATA_OUT: case CURLINFO_END: default: break; } #endif /* _DEBUG */ if (CURLINFO_TEXT == type) { if ((size >= excess_mark_len) && (0 == memcmp (data, excess_mark, excess_mark_len))) mhdErrorExitDesc ("Extra data has been detected in MHD reply"); } return 0; } static CURL * setupCURL (void *cbc, uint16_t port, struct headers_check_result *hdr_chk_result) { CURL *c; c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HEADERFUNCTION, lcurl_hdr_callback)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HEADERDATA, hdr_chk_result)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 0L)) || #ifdef _DEBUG (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) || #endif /* _DEBUG */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &libcurl_debug_cb)) || #if CURL_AT_LEAST_VERSION (7, 85, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http")) || #elif CURL_AT_LEAST_VERSION (7, 19, 4) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) || #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ #if CURL_AT_LEAST_VERSION (7, 45, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) || #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) port)))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); /* When 'CURLOPT_NOBODY' is set, libcurl should use HEAD request. */ if (CURLE_OK != curl_easy_setopt (c, CURLOPT_NOBODY, (long) 1)) libcurlErrorExitDesc ("curl_easy_setopt() failed"); return c; } static CURLcode performQueryExternal (struct MHD_Daemon *d, CURL *c, CURLM **multi_reuse) { CURLM *multi; time_t start; struct timeval tv; CURLcode ret; ret = CURLE_FAILED_INIT; /* will be replaced with real result */ if (NULL != *multi_reuse) multi = *multi_reuse; else { multi = curl_multi_init (); if (multi == NULL) libcurlErrorExitDesc ("curl_multi_init() failed"); *multi_reuse = multi; } if (CURLM_OK != curl_multi_add_handle (multi, c)) libcurlErrorExitDesc ("curl_multi_add_handle() failed"); start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; int running; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL != multi) { curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) libcurlErrorExitDesc ("curl_multi_info_read() failed"); totalMsgs++; if (CURLMSG_DONE == msg->msg) ret = msg->data.result; } while (msgLeft > 0); if (1 != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); externalErrorExit (); } curl_multi_remove_handle (multi, c); multi = NULL; } else { if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) libcurlErrorExitDesc ("curl_multi_fdset() failed"); } } if (NULL == multi) { /* libcurl has finished, check whether MHD still needs to perform cleanup */ if (0 != MHD_get_timeout64s (d)) break; /* MHD finished as well */ } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); tv.tv_sec = 0; tv.tv_usec = 200000; if (0 == MHD_get_timeout64s (d)) tv.tv_usec = 0; else { long curl_to = -1; curl_multi_timeout (multi, &curl_to); if (0 == curl_to) tv.tv_usec = 0; } #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep ((unsigned long) tv.tv_usec / 1000); #endif } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); } return ret; } /** * Check request result * @param curl_code the CURL easy return code * @param pcbc the pointer struct CBC * @return non-zero if success, zero if failed */ static unsigned int check_result (CURLcode curl_code, CURL *c, long expected_code, struct headers_check_result *hdr_res) { long code; unsigned int ret; if (CURLE_OK != curl_code) { fflush (stdout); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n" "libcurl error description: '%s'.\n", curl_easy_strerror (curl_code), libcurl_errbuf); else fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n", curl_easy_strerror (curl_code)); fflush (stderr); return 0; } if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code)) libcurlErrorExit (); if (expected_code != code) { fprintf (stderr, "The response has wrong HTTP code: %ld\tExpected: %ld.\n", code, expected_code); return 0; } else if (verbose) printf ("The response has expected HTTP code: %ld\n", expected_code); ret = 1; if (1 != hdr_res->header1_found) { if (0 == hdr_res->header1_found) fprintf (stderr, "Response header1 was not found.\n"); else fprintf (stderr, "Response header1 was found %d times " "instead of one time only.\n", hdr_res->header1_found); ret = 0; } else if (verbose) printf ("Header1 is present in the response.\n"); if (1 != hdr_res->header2_found) { if (0 == hdr_res->header2_found) fprintf (stderr, "Response header2 was not found.\n"); else fprintf (stderr, "Response header2 was found %d times " "instead of one time only.\n", hdr_res->header2_found); ret = 0; } else if (verbose) printf ("Header2 is present in the response.\n"); if (1 != hdr_res->size_found) { if (0 == hdr_res->size_found) fprintf (stderr, "Response 'Content-Length' header was not found.\n"); else fprintf (stderr, "Response 'Content-Length' header was found %d times " "instead of one time only.\n", hdr_res->size_found); ret = 0; } else if (verbose) printf ("'Content-Length' header with correct value " "is present in the response.\n"); return ret; } static unsigned int testHead (void) { struct MHD_Daemon *d; uint16_t port; struct CBC cbc; struct ahc_cls_type ahc_param; struct headers_check_result rp_headers_check; char buf[2048]; CURL *c; CURLM *multi_reuse; int failed = 0; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 4220 + oneone ? 0 : 1; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahcCheck, &ahc_param, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); port = dinfo->port; } /* First request */ ahc_param.rq_method = MHD_HTTP_METHOD_HEAD; ahc_param.rq_url = EXPECTED_URI_BASE_PATH; rp_headers_check.expected_size = MHD_STATICSTR_LEN_ (PAGE); rp_headers_check.header1_found = 0; rp_headers_check.header2_found = 0; rp_headers_check.size_found = 0; cbc.buf = buf; cbc.size = sizeof (buf); cbc.pos = 0; memset (cbc.buf, 0, cbc.size); c = setupCURL (&cbc, port, &rp_headers_check); setCURL_rq_path (c, 1); multi_reuse = NULL; /* First request */ if (check_result (performQueryExternal (d, c, &multi_reuse), c, MHD_HTTP_OK, &rp_headers_check)) { fflush (stderr); if (verbose) printf ("Got first expected response.\n"); fflush (stdout); } else { fprintf (stderr, "First request FAILED.\n"); fflush (stderr); failed = 1; } /* Second request */ rp_headers_check.expected_size = MHD_STATICSTR_LEN_ (PAGE_404); rp_headers_check.header1_found = 0; rp_headers_check.header2_found = 0; rp_headers_check.size_found = 0; cbc.pos = 0; /* Reset buffer position */ ahc_param.rq_url = EXPECTED_URI_BASE_PATH_MISSING; setCURL_rq_path (c, 0); if (check_result (performQueryExternal (d, c, &multi_reuse), c, MHD_HTTP_NOT_FOUND, &rp_headers_check)) { fflush (stderr); if (verbose) printf ("Got second expected response.\n"); fflush (stdout); } else { fprintf (stderr, "Second request FAILED.\n"); fflush (stderr); failed = 1; } /* Third request */ rp_headers_check.header1_found = 0; rp_headers_check.header2_found = 0; rp_headers_check.size_found = 0; cbc.pos = 0; /* Reset buffer position */ if (NULL != multi_reuse) curl_multi_cleanup (multi_reuse); multi_reuse = NULL; /* Force new connection */ if (check_result (performQueryExternal (d, c, &multi_reuse), c, MHD_HTTP_NOT_FOUND, &rp_headers_check)) { fflush (stderr); if (verbose) printf ("Got third expected response.\n"); fflush (stdout); } else { fprintf (stderr, "Third request FAILED.\n"); fflush (stderr); failed = 1; } curl_easy_cleanup (c); if (NULL != multi_reuse) curl_multi_cleanup (multi_reuse); MHD_stop_daemon (d); return failed ? 1 : 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; /* Test type and test parameters */ verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); oneone = ! has_in_name (argv[0], "10"); test_global_init (); errorCount += testHead (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); test_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_timeout.c0000644000175000017500000002576414441373361015407 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_timeout.c * @brief Testcase for libmicrohttpd PUT operations * @author Matthias Wachs * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ #include "mhd_has_in_name.h" /** * Pause execution for specified number of milliseconds. * @param ms the number of milliseconds to sleep */ static void _MHD_sleep (uint32_t ms) { #if defined(_WIN32) Sleep (ms); #elif defined(HAVE_NANOSLEEP) struct timespec slp = {ms / 1000, (ms % 1000) * 1000000}; struct timespec rmn; int num_retries = 0; while (0 != nanosleep (&slp, &rmn)) { if (num_retries++ > 8) break; slp = rmn; } #elif defined(HAVE_USLEEP) uint64_t us = ms * 1000; do { uint64_t this_sleep; if (999999 < us) this_sleep = 999999; else this_sleep = us; /* Ignore return value as it could be void */ usleep (this_sleep); us -= this_sleep; } while (us > 0); #else fprintf (stderr, "No sleep function available on this system.\n"); #endif } static int oneone; static int withTimeout = 0; static int withoutTimeout = 0; struct CBC { char *buf; size_t pos; size_t size; }; static void termination_cb (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { int *test = cls; (void) connection; (void) req_cls; /* Unused. Silent compiler warning. */ switch (toe) { case MHD_REQUEST_TERMINATED_COMPLETED_OK: if (test == &withoutTimeout) { withoutTimeout = 1; } else { fprintf (stderr, "Connection completed without errors while " "timeout is expected.\n"); } break; case MHD_REQUEST_TERMINATED_WITH_ERROR: fprintf (stderr, "Connection terminated with error.\n"); exit (4); break; case MHD_REQUEST_TERMINATED_READ_ERROR: fprintf (stderr, "Connection terminated with read error.\n"); exit (4); break; case MHD_REQUEST_TERMINATED_TIMEOUT_REACHED: if (test == &withTimeout) { withTimeout = 1; } else { fprintf (stderr, "Connection terminated with timeout while expected " "to be successfully completed.\n"); } break; case MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN: fprintf (stderr, "Connection terminated by daemon shutdown.\n"); exit (4); break; case MHD_REQUEST_TERMINATED_CLIENT_ABORT: fprintf (stderr, "Connection terminated by client.\n"); exit (4); break; } } static size_t putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) { size_t *pos = ptr; size_t wrt; wrt = size * nmemb; if (wrt > 8 - (*pos)) wrt = 8 - (*pos); memcpy (stream, &("Hello123"[*pos]), wrt); (*pos) += wrt; return wrt; } static size_t putBuffer_fail (void *stream, size_t size, size_t nmemb, void *ptr) { (void) stream; (void) size; (void) nmemb; (void) ptr; /* Unused. Silent compiler warning. */ _MHD_sleep (100); /* Avoid busy-waiting */ return 0; } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { int *done = cls; struct MHD_Response *response; enum MHD_Result ret; (void) version; (void) req_cls; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_PUT, method)) return MHD_NO; /* unexpected method */ if ((*done) == 0) { if (*upload_data_size != 8) return MHD_YES; /* not yet ready */ if (0 == memcmp (upload_data, "Hello123", 8)) { *upload_data_size = 0; } else { printf ("Invalid upload data `%8s'!\n", upload_data); return MHD_NO; } *done = 1; return MHD_YES; } response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int testWithoutTimeout (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1500; if (oneone) port += 5; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_CONNECTION_TIMEOUT, 2, MHD_OPTION_NOTIFY_COMPLETED, &termination_cb, &withoutTimeout, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &pos); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); withoutTimeout = 0; if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: '%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (0 == withoutTimeout) { fprintf (stderr, "Request wasn't processed successfully.\n"); return 2; } if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; return 0; } static unsigned int testWithTimeout (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1501; if (oneone) port += 5; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_CONNECTION_TIMEOUT, 2, MHD_OPTION_NOTIFY_COMPLETED, &termination_cb, &withTimeout, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer_fail); curl_easy_setopt (c, CURLOPT_READDATA, &testWithTimeout); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); withTimeout = 0; if (CURLE_OK != (errornum = curl_easy_perform (c))) { curl_easy_cleanup (c); MHD_stop_daemon (d); if (errornum == CURLE_GOT_NOTHING) { if (0 != withTimeout) { /* mhd had the timeout */ return 0; } else { fprintf (stderr, "Timeout wasn't detected.\n"); return 8; } } else /* curl had the timeout first */ return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); return 64; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 16; errorCount += testWithoutTimeout (); errorCount += testWithTimeout (); if (errorCount != 0) fprintf (stderr, "Error during test execution (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_post.c0000644000175000017500000005603314530120375014671 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_post.c * @brief Testcase for libmicrohttpd POST operations using URL-encoding * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #ifndef WINDOWS #include #endif #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #include "mhd_has_in_name.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #define POST_DATA "name=daniel&project=curl" static int oneone; struct CBC { char *buf; size_t pos; size_t size; }; static void completed_cb (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { struct MHD_PostProcessor *pp = *req_cls; (void) cls; (void) connection; (void) toe; /* Unused. Silent compiler warning. */ if (NULL != pp) MHD_destroy_post_processor (pp); *req_cls = NULL; } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } /** * Note that this post_iterator is not perfect * in that it fails to support incremental processing. * (to be fixed in the future) */ static enum MHD_Result post_iterator (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *value, uint64_t off, size_t size) { int *eok = cls; (void) kind; (void) filename; (void) content_type; /* Unused. Silent compiler warning. */ (void) transfer_encoding; (void) off; /* Unused. Silent compiler warning. */ if ((0 == strcmp (key, "name")) && (size == strlen ("daniel")) && (0 == strncmp (value, "daniel", size))) (*eok) |= 1; if ((0 == strcmp (key, "project")) && (size == strlen ("curl")) && (0 == strncmp (value, "curl", size))) (*eok) |= 2; return MHD_YES; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int eok; struct MHD_Response *response; struct MHD_PostProcessor *pp; enum MHD_Result ret; (void) cls; (void) version; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_POST, method)) { fprintf (stderr, "METHOD: %s\n", method); return MHD_NO; /* unexpected method */ } pp = *req_cls; if (pp == NULL) { eok = 0; pp = MHD_create_post_processor (connection, 1024, &post_iterator, &eok); *req_cls = pp; } MHD_post_process (pp, upload_data, *upload_data_size); if ((eok == 3) && (0 == *upload_data_size)) { response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); MHD_destroy_post_processor (pp); *req_cls = NULL; return ret; } *upload_data_size = 0; return MHD_YES; } static unsigned int testInternalPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1370; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); curl_easy_setopt (c, CURLOPT_POST, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; return 0; } static unsigned int testMultithreadedPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1371; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); curl_easy_setopt (c, CURLOPT_POST, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testMultithreadedPoolPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1372; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); curl_easy_setopt (c, CURLOPT_POST, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testExternalPost (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1373; if (oneone) port += 10; } multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_DATA); curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, strlen (POST_DATA)); curl_easy_setopt (c, CURLOPT_POST, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 8192; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 16384; return 0; } static enum MHD_Result ahc_cancel (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp ("POST", method)) { fprintf (stderr, "Unexpected method `%s'\n", method); return MHD_NO; } if (*req_cls == NULL) { static int marker = 1; *req_cls = ▮ /* We don't want the body. Send a 500. */ response = MHD_create_response_empty (MHD_RF_NONE); ret = MHD_queue_response (connection, 500, response); if (ret != MHD_YES) fprintf (stderr, "Failed to queue response\n"); MHD_destroy_response (response); return ret; } else { fprintf (stderr, "In ahc_cancel again. This should not happen.\n"); return MHD_NO; } } struct CRBC { const char *buffer; size_t size; size_t pos; }; static size_t readBuffer (void *p, size_t size, size_t nmemb, void *opaque) { struct CRBC *data = opaque; size_t required = size * nmemb; size_t left = data->size - data->pos; if (required > left) required = left; memcpy (p, data->buffer + data->pos, required); data->pos += required; return required / size; } static size_t slowReadBuffer (void *p, size_t size, size_t nmemb, void *opaque) { (void) sleep (1); return readBuffer (p, size, nmemb, opaque); } #define FLAG_EXPECT_CONTINUE 1 #define FLAG_CHUNKED 2 #define FLAG_FORM_DATA 4 #define FLAG_SLOW_READ 8 #define FLAG_COUNT 16 static unsigned int testMultithreadedPostCancelPart (int flags) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; struct curl_slist *headers = NULL; long response_code; CURLcode cc; unsigned int result = 0; struct CRBC crbc; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1374; if (oneone) port += 10; } /* Don't test features that aren't available with HTTP/1.0 in * HTTP/1.0 mode. */ if (! oneone && (flags & (FLAG_EXPECT_CONTINUE | FLAG_CHUNKED))) return 0; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_cancel, NULL, MHD_OPTION_END); if (d == NULL) return 32768; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } crbc.buffer = "Test content"; crbc.size = strlen (crbc.buffer); crbc.pos = 0; c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, (flags & FLAG_SLOW_READ) ? &slowReadBuffer : &readBuffer); curl_easy_setopt (c, CURLOPT_READDATA, &crbc); curl_easy_setopt (c, CURLOPT_POSTFIELDS, NULL); curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, crbc.size); curl_easy_setopt (c, CURLOPT_POST, 1L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (flags & FLAG_CHUNKED) headers = curl_slist_append (headers, "Transfer-Encoding: chunked"); if (! (flags & FLAG_FORM_DATA)) headers = curl_slist_append (headers, "Content-Type: application/octet-stream"); if (flags & FLAG_EXPECT_CONTINUE) headers = curl_slist_append (headers, "Expect: 100-Continue"); curl_easy_setopt (c, CURLOPT_HTTPHEADER, headers); if (CURLE_HTTP_RETURNED_ERROR != (errornum = curl_easy_perform (c))) { #ifdef _WIN32 curl_version_info_data *curlverd = curl_version_info (CURLVERSION_NOW); if ((0 != (flags & FLAG_SLOW_READ)) && (CURLE_RECV_ERROR == errornum) && ((curlverd == NULL) || (curlverd->ares_num < 0x073100) ) ) { /* libcurl up to version 7.49.0 didn't have workaround for WinSock bug */ fprintf (stderr, "Ignored curl_easy_perform expected failure on W32 with \"slow read\".\n"); result = 0; } else #else /* ! _WIN32 */ if (1) #endif /* ! _WIN32 */ { fprintf (stderr, "flibbet curl_easy_perform didn't fail as expected: `%s' %u\n", curl_easy_strerror (errornum), (unsigned int) errornum); result = 65536; } curl_easy_cleanup (c); MHD_stop_daemon (d); curl_slist_free_all (headers); return result; } if (CURLE_OK != (cc = curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &response_code))) { fprintf (stderr, "curl_easy_getinfo failed: '%s'\n", curl_easy_strerror (cc)); result = 65536; } if (! result && (response_code != 500)) { fprintf (stderr, "Unexpected response code: %ld\n", response_code); result = 131072; } if (! result && (cbc.pos != 0)) result = 262144; curl_easy_cleanup (c); MHD_stop_daemon (d); curl_slist_free_all (headers); return result; } static unsigned int testMultithreadedPostCancel (void) { unsigned int result = 0; int flags; for (flags = 0; flags < FLAG_COUNT; ++flags) result |= testMultithreadedPostCancelPart (flags); return result; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testMultithreadedPostCancel (); errorCount += testInternalPost (); errorCount += testMultithreadedPost (); errorCount += testMultithreadedPoolPost (); } errorCount += testExternalPost (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_process_arguments.c0000644000175000017500000002104414530120375017441 /* This file is part of libmicrohttpd Copyright (C) 2007, 2013 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_process_arguments.c * @brief Testcase for HTTP URI arguments * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #ifndef WINDOWS #include #endif static int oneone; struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; const char *hdr; (void) cls; (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; hdr = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "k"); if ((hdr == NULL) || (0 != strcmp (hdr, "v x"))) abort (); hdr = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "hash"); if ((hdr == NULL) || (0 != strcmp (hdr, "#foo"))) abort (); hdr = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "space"); if ((hdr == NULL) || (0 != strcmp (hdr, "\240bar"))) abort (); if (3 != MHD_get_connection_values (connection, MHD_GET_ARGUMENT_KIND, NULL, NULL)) abort (); response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) abort (); return ret; } static unsigned int testExternalGet (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1410; if (oneone) port += 5; } multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello+world?k=v+x&hash=%23foo&space=%A0bar"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello+world")) return 8192; if (0 != strncmp ("/hello+world", cbc.buf, strlen ("/hello+world"))) return 16384; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; errorCount += testExternalGet (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_parse_cookies.c0000644000175000017500000011401114530120375016521 /* This file is part of GNU libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_parse_cookies.c * @brief Testcase for HTTP cookie parsing * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #ifndef _WIN32 #include #include #endif #include "mhd_has_param.h" #include "mhd_has_in_name.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __func__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func (NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func (NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func (NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func (errDesc, NULL, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), NULL, \ __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (8); } /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 500000 #define EXPECTED_URI_BASE_PATH "/" #define URL_SCHEME "http:/" "/" #define URL_HOST "127.0.0.1" #define URL_SCHEME_HOST URL_SCHEME URL_HOST #define PAGE \ "libmicrohttpd test page" \ "Success!" #define PAGE_ERROR \ "Cookies parsing error" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ struct strct_str_len { const char *str; const size_t len; }; #define STR_LEN_(str) {str, MHD_STATICSTR_LEN_ (str)} #define STR_NULL_ {NULL, 0} struct strct_cookie { struct strct_str_len name; struct strct_str_len value; }; #define COOKIE_(name,value) {STR_LEN_ (name), STR_LEN_ (value)} #define COOKIE_NULL {STR_NULL_, STR_NULL_} struct strct_test_data { unsigned int line_num; const char *header_str; unsigned int num_cookies_strict_p2; unsigned int num_cookies_strict_p1; unsigned int num_cookies_strict_zero; unsigned int num_cookies_strict_n2; unsigned int num_cookies_strict_n3; struct strct_cookie cookies[5]; }; static const struct strct_test_data test_data[] = { { __LINE__, "name1=value1", 1, 1, 1, 1, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1;", 0, 1, 1, 1, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1; ", 0, 1, 1, 1, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "; name1=value1", 0, 0, 1, 1, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, ";name1=value1", 0, 0, 1, 1, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1 ", 1, 1, 1, 1, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1 ;", 0, 0, 1, 1, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1 ; ", 0, 0, 1, 1, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name2=\"value 2\"", 0, 0, 0, 1, 1, { COOKIE_ ("name2", "value 2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1;\tname2=value2", 0, 1, 2, 2, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1; name1=value1", 2, 2, 2, 2, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name1", "value1"), /* The second value is not checked actually */ COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1; name2=value2", 2, 2, 2, 2, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1; name2=value2 ", 2, 2, 2, 2, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1; name2=value2", 0, 1, 2, 2, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1;name2=value2", 0, 1, 2, 2, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1;\tname2=value2", 0, 1, 2, 2, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1 ; name2=value2", 0, 0, 2, 2, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, " name1=value1; name2=value2", 2, 2, 2, 2, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=var1; name2=var2; name3=; " \ "name4=\"var4 with spaces\"; " \ "name5=var_with_=_char", 0, 3, 3, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces"), COOKIE_ ("name5", "var_with_=_char") } }, { __LINE__, "name1=var1;name2=var2;name3=;" \ "name4=\"var4 with spaces\";" \ "name5=var_with_=_char", 0, 1, 3, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces"), COOKIE_ ("name5", "var_with_=_char") } }, { __LINE__, "name1=var1; name2=var2; name3=; " \ "name4=\"var4 with spaces\"; " \ "name5=var_with_=_char\t \t", 0, 1, 3, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces"), COOKIE_ ("name5", "var_with_=_char") } }, { __LINE__, "name1=var1;;name2=var2;;name3=;;" \ "name4=\"var4 with spaces\";;" \ "name5=var_with_=_char;\t \t", 0, 1, 3, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces"), COOKIE_ ("name5", "var_with_=_char") } }, { __LINE__, "name3=; name1=var1; name2=var2; " \ "name5=var_with_=_char;" \ "name4=\"var4 with spaces\"", 0, 4, 4, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name5", "var_with_=_char"), COOKIE_ ("name4", "var4 with spaces") } }, { __LINE__, "name2=var2; name1=var1; " \ "name5=var_with_=_char; name3=; " \ "name4=\"var4 with spaces\";", 0, 4, 4, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name5", "var_with_=_char"), COOKIE_ ("name4", "var4 with spaces") } }, { __LINE__, "name2=var2; name1=var1; " \ "name5=var_with_=_char; " \ "name4=\"var4 with spaces\"; name3=", 0, 3, 3, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name5", "var_with_=_char"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces") } }, { __LINE__, "name2=var2; name1=var1; " \ "name4=\"var4 with spaces\"; " \ "name5=var_with_=_char; name3=;", 0, 2, 2, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces"), COOKIE_ ("name5", "var_with_=_char") } }, { __LINE__, ";;;;;;;;name1=var1; name2=var2; name3=; " \ "name4=\"var4 with spaces\"; " \ "name5=var_with_=_char", 0, 0, 3, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces"), COOKIE_ ("name5", "var_with_=_char") } }, { __LINE__, "name1=var1; name2=var2; name3=; " \ "name4=\"var4 with spaces\"; ; ; ; ; " \ "name5=var_with_=_char", 0, 3, 3, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces"), COOKIE_ ("name5", "var_with_=_char") } }, { __LINE__, "name1=var1; name2=var2; name3=; " \ "name4=\"var4 with spaces\"; " \ "name5=var_with_=_char;;;;;;;;", 0, 3, 3, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces"), COOKIE_ ("name5", "var_with_=_char") } }, { __LINE__, "name1=var1; name2=var2; " \ "name4=\"var4 with spaces\";" \ "name5=var_with_=_char; ; ; ; ; name3=", 0, 2, 2, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name5", "var_with_=_char"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces") } }, { __LINE__, "name5=var_with_=_char ;" \ "name1=var1; name2=var2; name3=; " \ "name4=\"var4 with spaces\" ", 0, 0, 4, 5, 5, { COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name5", "var_with_=_char"), COOKIE_ ("name4", "var4 with spaces") } }, { __LINE__, "name5=var_with_=_char; name4=\"var4 with spaces\";" \ "name1=var1; name2=var2; name3=", 0, 1, 1, 5, 5, { COOKIE_ ("name5", "var_with_=_char"), COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4 with spaces") } }, { __LINE__, "name5=var_with_=_char; name4=\"var4_without_spaces\"; " \ "name1=var1; name2=var2; name3=", 5, 5, 5, 5, 5, { COOKIE_ ("name5", "var_with_=_char"), COOKIE_ ("name1", "var1"), COOKIE_ ("name2", "var2"), COOKIE_ ("name3", ""), COOKIE_ ("name4", "var4_without_spaces") } }, { __LINE__, "name1 = value1", 0, 0, 0, 0, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1\t=\tvalue1", 0, 0, 0, 0, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1\t = \tvalue1", 0, 0, 0, 0, 1, { COOKIE_ ("name1", "value1"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1 = value1; name2 =\tvalue2", 0, 0, 0, 0, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1=value1; name2 =\tvalue2", 0, 1, 1, 1, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "name1 = value1; name2=value2", 0, 0, 0, 0, 2, { COOKIE_ ("name1", "value1"), COOKIE_ ("name2", "value2"), COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, " ", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "\t", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "var=,", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "var=\"\\ \"", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "var=value space", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "var=value\ttab", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "=", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "====", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, ";=", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "var", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "=;", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, "= ;", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } }, { __LINE__, ";= ;", 0, 0, 0, 0, 0, { COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL, COOKIE_NULL } } }; /* Global parameters */ static int verbose; static int oneone; /**< If false use HTTP/1.0 for requests*/ static int use_discp_n3; static int use_discp_n2; static int use_discp_zero; static int use_discp_p1; static int use_discp_p2; static int discp_level; static void test_global_init (void) { libcurl_errbuf[0] = 0; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) externalErrorExit (); } static void test_global_cleanup (void) { curl_global_cleanup (); } struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } struct ahc_cls_type { const char *rq_method; const char *rq_url; const struct strct_test_data *check; }; static enum MHD_Result ahcCheck (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker; struct MHD_Response *response; enum MHD_Result ret; struct ahc_cls_type *const param = (struct ahc_cls_type *) cls; unsigned int expected_num_cookies; unsigned int i; int cookie_failed; if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); if (use_discp_p2) expected_num_cookies = param->check->num_cookies_strict_p2; else if (use_discp_p1) expected_num_cookies = param->check->num_cookies_strict_p1; else if (use_discp_zero) expected_num_cookies = param->check->num_cookies_strict_zero; else if (use_discp_n2) expected_num_cookies = param->check->num_cookies_strict_n2; else if (use_discp_n3) expected_num_cookies = param->check->num_cookies_strict_n3; else externalErrorExit (); if (oneone) { if (0 != strcmp (version, MHD_HTTP_VERSION_1_1)) mhdErrorExitDesc ("Unexpected HTTP version"); } else { if (0 != strcmp (version, MHD_HTTP_VERSION_1_0)) mhdErrorExitDesc ("Unexpected HTTP version"); } if (0 != strcmp (url, param->rq_url)) mhdErrorExitDesc ("Unexpected URI"); if (NULL != upload_data) mhdErrorExitDesc ("'upload_data' is not NULL"); if (NULL == upload_data_size) mhdErrorExitDesc ("'upload_data_size' pointer is NULL"); if (0 != *upload_data_size) mhdErrorExitDesc ("'*upload_data_size' value is not zero"); if (0 != strcmp (param->rq_method, method)) mhdErrorExitDesc ("Unexpected request method"); cookie_failed = 0; for (i = 0; i < expected_num_cookies; ++i) { const char *cookie_val; size_t cookie_val_len; const struct strct_cookie *const cookie_data = param->check->cookies + i; if (NULL == cookie_data->name.str) externalErrorExitDesc ("Broken test data"); if (NULL == cookie_data->value.str) externalErrorExitDesc ("Broken test data"); cookie_val = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, cookie_data->name.str); if (cookie_val == NULL) { fprintf (stderr, "'%s' cookie not found.\n", cookie_data->name.str); cookie_failed = 1; } else if (0 != strcmp (cookie_val, cookie_data->value.str)) { fprintf (stderr, "'%s' cookie decoded incorrectly.\n" "Expected: %s\nGot: %s\n", cookie_data->name.str, cookie_data->value.str, cookie_val); cookie_failed = 1; } else if (MHD_YES != MHD_lookup_connection_value_n (connection, MHD_COOKIE_KIND, cookie_data->name.str, cookie_data->name.len, &cookie_val, &cookie_val_len)) { fprintf (stderr, "'%s' (length %lu) cookie not found.\n", cookie_data->name.str, (unsigned long) cookie_data->name.len); cookie_failed = 1; } else { if (cookie_data->value.len != cookie_val_len) { fprintf (stderr, "'%s' (length %lu) cookie has wrong value length.\n" "Expected: %lu\nGot: %lu\n", cookie_data->name.str, (unsigned long) cookie_data->name.len, (unsigned long) cookie_data->value.len, (unsigned long) cookie_val_len); cookie_failed = 1; } else if (0 != memcmp (cookie_val, cookie_data->value.str, cookie_val_len)) { fprintf (stderr, "'%s' (length %lu) cookie has wrong value.\n" "Expected: %.*s\nGot: %.*s\n", cookie_data->name.str, (unsigned long) cookie_data->name.len, (int) cookie_data->value.len, cookie_data->value.str, (int) cookie_val_len, cookie_val); cookie_failed = 1; } } } if (((int) expected_num_cookies) != MHD_get_connection_values_n (connection, MHD_COOKIE_KIND, NULL, NULL)) { fprintf (stderr, "Wrong total number of cookies.\n" "Expected: %u\nGot: %d\n", expected_num_cookies, MHD_get_connection_values_n (connection, MHD_COOKIE_KIND, NULL, NULL)); cookie_failed = 1; } if (cookie_failed) { response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE_ERROR), PAGE_ERROR); ret = MHD_queue_response (connection, MHD_HTTP_BAD_REQUEST, response); MHD_destroy_response (response); return ret; } if (&marker != *req_cls) { *req_cls = ▮ return MHD_YES; } *req_cls = NULL; response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (PAGE), PAGE); if (NULL == response) mhdErrorExitDesc ("Failed to create response"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (MHD_YES != ret) mhdErrorExitDesc ("Failed to queue response"); return ret; } static int libcurl_debug_cb (CURL *handle, curl_infotype type, char *data, size_t size, void *userptr) { static const char excess_mark[] = "Excess found"; static const size_t excess_mark_len = MHD_STATICSTR_LEN_ (excess_mark); (void) handle; (void) userptr; #ifdef _DEBUG switch (type) { case CURLINFO_TEXT: fprintf (stderr, "* %.*s", (int) size, data); break; case CURLINFO_HEADER_IN: fprintf (stderr, "< %.*s", (int) size, data); break; case CURLINFO_HEADER_OUT: fprintf (stderr, "> %.*s", (int) size, data); break; case CURLINFO_DATA_IN: #if 0 fprintf (stderr, "<| %.*s\n", (int) size, data); #endif break; case CURLINFO_DATA_OUT: case CURLINFO_SSL_DATA_IN: case CURLINFO_SSL_DATA_OUT: case CURLINFO_END: default: break; } #endif /* _DEBUG */ if (CURLINFO_TEXT == type) { if ((size >= excess_mark_len) && (0 == memcmp (data, excess_mark, excess_mark_len))) mhdErrorExitDesc ("Extra data has been detected in MHD reply"); } return 0; } static CURL * setupCURL (void *cbc, uint16_t port) { CURL *c; c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 0L)) || #ifdef _DEBUG (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) || #endif /* _DEBUG */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &libcurl_debug_cb)) || #if CURL_AT_LEAST_VERSION (7, 85, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http")) || #elif CURL_AT_LEAST_VERSION (7, 19, 4) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) || #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ #if CURL_AT_LEAST_VERSION (7, 45, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) || #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) port)))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); if (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, URL_SCHEME_HOST EXPECTED_URI_BASE_PATH)) libcurlErrorExitDesc ("Cannot set request URL"); return c; } static CURLcode performQueryExternal (struct MHD_Daemon *d, CURL *c, CURLM **multi_reuse) { CURLM *multi; time_t start; struct timeval tv; CURLcode ret; ret = CURLE_FAILED_INIT; /* will be replaced with real result */ if (NULL != *multi_reuse) multi = *multi_reuse; else { multi = curl_multi_init (); if (multi == NULL) libcurlErrorExitDesc ("curl_multi_init() failed"); *multi_reuse = multi; } if (CURLM_OK != curl_multi_add_handle (multi, c)) libcurlErrorExitDesc ("curl_multi_add_handle() failed"); start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; int running; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL != multi) { curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) libcurlErrorExitDesc ("curl_multi_info_read() failed"); totalMsgs++; if (CURLMSG_DONE == msg->msg) ret = msg->data.result; } while (msgLeft > 0); if (1 != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); externalErrorExit (); } curl_multi_remove_handle (multi, c); multi = NULL; } else { if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) libcurlErrorExitDesc ("curl_multi_fdset() failed"); } } if (NULL == multi) { /* libcurl has finished, check whether MHD still needs to perform cleanup */ if (0 != MHD_get_timeout64s (d)) break; /* MHD finished as well */ } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); tv.tv_sec = 0; tv.tv_usec = 200000; if (0 == MHD_get_timeout64s (d)) tv.tv_usec = 0; else { long curl_to = -1; curl_multi_timeout (multi, &curl_to); if (0 == curl_to) tv.tv_usec = 0; } #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep ((unsigned long) tv.tv_usec / 1000); #endif } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); } return ret; } /** * Check request result * @param curl_code the CURL easy return code * @param pcbc the pointer struct CBC * @return non-zero if success, zero if failed */ static unsigned int check_result (CURLcode curl_code, CURL *c, long expected_code, struct CBC *pcbc) { long code; if (CURLE_OK != curl_code) { fflush (stdout); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n" "libcurl error description: '%s'.\n", curl_easy_strerror (curl_code), libcurl_errbuf); else fprintf (stderr, "Request failed. " "libcurl error: '%s'.\n", curl_easy_strerror (curl_code)); fflush (stderr); return 0; } if (CURLE_OK != curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code)) libcurlErrorExit (); if (expected_code != code) { fprintf (stderr, "### The response has wrong HTTP code: %ld\t" "Expected: %ld.\n", code, expected_code); return 0; } else if (verbose) printf ("### The response has expected HTTP code: %ld\n", expected_code); if (pcbc->pos != MHD_STATICSTR_LEN_ (PAGE)) { fprintf (stderr, "Got %u bytes ('%.*s'), expected %u bytes. ", (unsigned) pcbc->pos, (int) pcbc->pos, pcbc->buf, (unsigned) MHD_STATICSTR_LEN_ (PAGE)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != memcmp (PAGE, pcbc->buf, pcbc->pos)) { fprintf (stderr, "Got invalid response '%.*s'. ", (int) pcbc->pos, pcbc->buf); mhdErrorExitDesc ("Wrong returned data"); } fflush (stderr); fflush (stdout); return 1; } static unsigned int testExternalPolling (void) { struct MHD_Daemon *d; uint16_t port; struct CBC cbc; struct ahc_cls_type ahc_param; char buf[2048]; CURL *c; CURLM *multi_reuse; size_t i; int failed = 0; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1340 + oneone ? 0 : 6 + (uint16_t) (1 + discp_level); d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahcCheck, &ahc_param, MHD_OPTION_CLIENT_DISCIPLINE_LVL, (int) (discp_level), MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); port = dinfo->port; } ahc_param.rq_method = MHD_HTTP_METHOD_GET; ahc_param.rq_url = EXPECTED_URI_BASE_PATH; cbc.buf = buf; cbc.size = sizeof (buf); memset (cbc.buf, 0, cbc.size); c = setupCURL (&cbc, port); multi_reuse = NULL; for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); ++i) { cbc.pos = 0; ahc_param.check = test_data + i; if (CURLE_OK != curl_easy_setopt (c, CURLOPT_COOKIE, ahc_param.check->header_str)) libcurlErrorExitDesc ("Cannot set request cookies"); if (check_result (performQueryExternal (d, c, &multi_reuse), c, MHD_HTTP_OK, &cbc)) { if (verbose) printf ("### Got expected response for the check at line %u.\n", test_data[i].line_num); fflush (stdout); } else { fprintf (stderr, "### FAILED request for the check at line %u.\n", test_data[i].line_num); fflush (stderr); failed = 1; } } curl_easy_cleanup (c); if (NULL != multi_reuse) curl_multi_cleanup (multi_reuse); MHD_stop_daemon (d); return failed ? 1 : 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; /* Test type and test parameters */ verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); oneone = ! has_in_name (argv[0], "10"); use_discp_n3 = has_in_name (argv[0], "_discp_n3"); use_discp_n2 = has_in_name (argv[0], "_discp_n2"); use_discp_zero = has_in_name (argv[0], "_discp_zero"); use_discp_p1 = has_in_name (argv[0], "_discp_p1"); use_discp_p2 = has_in_name (argv[0], "_discp_p2"); if (1 != ((use_discp_n3 ? 1 : 0) + (use_discp_n2 ? 1 : 0) + (use_discp_zero ? 1 : 0) + (use_discp_p1 ? 1 : 0) + (use_discp_p2 ? 1 : 0))) return 99; if (use_discp_n3) discp_level = -3; else if (use_discp_n2) discp_level = -2; else if (use_discp_zero) discp_level = 0; else if (use_discp_p1) discp_level = 1; else if (use_discp_p2) discp_level = 2; test_global_init (); errorCount += testExternalPolling (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); test_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_get_iovec.c0000644000175000017500000005061414530120375015647 /* This file is part of libmicrohttpd Copyright (C) 2007-2021 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_get_iovec.c * @brief Testcase for libmicrohttpd response from scatter/gather array * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) * @author Lawrence Sebald */ /* * This test is largely derived from the test_get_sendfile.c file, with the * daemon using MHD_create_response_from_iovec instead of working from an fd. */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #include #ifdef HAVE_STDBOOL_H #include #endif #include #include "mhd_sockets.h" #include "mhd_has_in_name.h" #ifndef WINDOWS #include #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #define TESTSTR_IOVLEN 20480 #define TESTSTR_IOVCNT 20 #define TESTSTR_SIZE (TESTSTR_IOVCNT * TESTSTR_IOVLEN) static int oneone; static int readbuf[TESTSTR_SIZE * 2 / sizeof(int)]; struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) _exit (7); /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static void iov_free_callback (void *cls) { free (cls); } struct iovncont_data { void *ptrs[TESTSTR_IOVCNT]; }; static void iovncont_free_callback (void *cls) { struct iovncont_data *data = (struct iovncont_data *) cls; unsigned int i; for (i = 0; i < TESTSTR_IOVCNT; ++i) free (data->ptrs[i]); free (data); } static int check_read_data (const void *ptr, size_t len) { const int *buf; size_t i; if (len % sizeof(int)) return -1; buf = (const int *) ptr; for (i = 0; i < len / sizeof(int); ++i) { if (buf[i] != (int) i) return -1; } return 0; } static enum MHD_Result ahc_cont (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; int *data; struct MHD_IoVec iov[TESTSTR_IOVCNT]; int i; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; /* Create some test data. */ if (NULL == (data = malloc (TESTSTR_SIZE))) return MHD_NO; for (i = 0; i < (int) (TESTSTR_SIZE / sizeof(int)); ++i) { data[i] = i; } for (i = 0; i < TESTSTR_IOVCNT; ++i) { iov[i].iov_base = data + (((size_t) i) * (TESTSTR_SIZE / TESTSTR_IOVCNT / sizeof(int))); iov[i].iov_len = TESTSTR_SIZE / TESTSTR_IOVCNT; } response = MHD_create_response_from_iovec (iov, TESTSTR_IOVCNT, &iov_free_callback, data); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) abort (); return ret; } static enum MHD_Result ahc_ncont (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; struct MHD_IoVec iov[TESTSTR_IOVCNT]; struct iovncont_data *clear_cls; int i, j; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; clear_cls = malloc (sizeof(struct iovncont_data)); if (NULL == clear_cls) abort (); memset (iov, 0, sizeof(struct MHD_IoVec) * TESTSTR_IOVCNT); /* Create some test data. */ for (j = TESTSTR_IOVCNT - 1; j >= 0; --j) { int *data; data = malloc (TESTSTR_IOVLEN); if (NULL == data) abort (); clear_cls->ptrs[j] = (void *) data; for (i = 0; i < (int) (TESTSTR_IOVLEN / sizeof(int)); ++i) { data[i] = i + (j * (int) (TESTSTR_IOVLEN / sizeof(int))); } iov[j].iov_base = (const void *) data; iov[j].iov_len = TESTSTR_IOVLEN; } response = MHD_create_response_from_iovec (iov, TESTSTR_IOVCNT, &iovncont_free_callback, clear_cls); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) abort (); return ret; } static unsigned int testInternalGet (bool contiguous) { struct MHD_Daemon *d; CURL *c; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1200; if (oneone) port += 10; } cbc.buf = (char *) readbuf; cbc.size = sizeof(readbuf); cbc.pos = 0; if (contiguous) { d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_cont, NULL, MHD_OPTION_END); } else { d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_ncont, NULL, MHD_OPTION_END); } if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != TESTSTR_SIZE) return 4; if (0 != check_read_data (cbc.buf, cbc.pos)) return 8; return 0; } static unsigned int testMultithreadedGet (void) { struct MHD_Daemon *d; CURL *c; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1201; if (oneone) port += 10; } cbc.buf = (char *) readbuf; cbc.size = sizeof(readbuf); cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_AUTO, port, NULL, NULL, &ahc_cont, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != TESTSTR_SIZE) return 64; if (0 != check_read_data (cbc.buf, cbc.pos)) return 128; return 0; } static unsigned int testMultithreadedPoolGet (void) { struct MHD_Daemon *d; CURL *c; struct CBC cbc; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1202; if (oneone) port += 10; } cbc.buf = (char *) readbuf; cbc.size = sizeof(readbuf); cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_AUTO, port, NULL, NULL, &ahc_cont, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != TESTSTR_SIZE) return 64; if (0 != check_read_data (cbc.buf, cbc.pos)) return 128; return 0; } static unsigned int testExternalGet (int thread_unsafe) { struct MHD_Daemon *d; CURL *c; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef MHD_WINSOCK_SOCKETS int maxposixs; /* Max socket number unused on W32 */ #else /* MHD_POSIX_SOCKETS */ #define maxposixs maxsock #endif /* MHD_POSIX_SOCKETS */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1203; if (oneone) port += 10; } multi = NULL; cbc.buf = (char *) readbuf; cbc.size = sizeof(readbuf); cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | (thread_unsafe ? MHD_USE_NO_THREAD_SAFETY : 0), port, NULL, NULL, &ahc_cont, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != TESTSTR_SIZE) return 8192; if (0 != check_read_data (cbc.buf, cbc.pos)) return 16384; return 0; } static unsigned int testUnknownPortGet (void) { struct MHD_Daemon *d; const union MHD_DaemonInfo *di; CURL *c; struct CBC cbc; CURLcode errornum; uint16_t port; char buf[2048]; struct sockaddr_in addr; socklen_t addr_len = sizeof(addr); memset (&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = 0; addr.sin_addr.s_addr = INADDR_ANY; cbc.buf = (char *) readbuf; cbc.size = sizeof(readbuf); cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 0, NULL, NULL, &ahc_cont, NULL, MHD_OPTION_SOCK_ADDR, &addr, MHD_OPTION_END); if (d == NULL) return 32768; if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) { di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD); if (di == NULL) return 65536; if (0 != getsockname (di->listen_fd, (struct sockaddr *) &addr, &addr_len)) return 131072; if (addr.sin_family != AF_INET) return 26214; port = ntohs (addr.sin_port); } else { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (buf, sizeof(buf), "http://127.0.0.1:%u/", (unsigned int) port); c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, buf); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 524288; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != TESTSTR_SIZE) return 1048576; if (0 != check_read_data (cbc.buf, cbc.pos)) return 2097152; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalGet (true); errorCount += testInternalGet (false); errorCount += testMultithreadedGet (); errorCount += testMultithreadedPoolGet (); errorCount += testUnknownPortGet (); errorCount += testExternalGet (0); } errorCount += testExternalGet (! 0); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_termination.c0000644000175000017500000001011614441373361016233 /* This file is part of libmicrohttpd Copyright (C) 2009 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file daemontest_termination.c * @brief Testcase for libmicrohttpd tolerating client not closing immediately * @author hollosig * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #include #include #include #include #include #include #include #include #ifndef __MINGW32__ #include #include #endif #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif static enum MHD_Result connection_handler (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int i; struct MHD_Response *response; enum MHD_Result ret; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (*req_cls == NULL) { *req_cls = &i; return MHD_YES; } if (*upload_data_size != 0) { (*upload_data_size) = 0; return MHD_YES; } response = MHD_create_response_from_buffer_static (strlen ("Response"), "Response"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static size_t write_data (void *ptr, size_t size, size_t nmemb, void *stream) { (void) ptr; (void) stream; /* Unused. Silent compiler warning. */ return size * nmemb; } int main (void) { struct MHD_Daemon *daemon; uint16_t port; char url[255]; CURL *curl; CURLcode success; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1490; daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, connection_handler, NULL, MHD_OPTION_END); if (daemon == NULL) { fprintf (stderr, "Daemon cannot be started!"); exit (1); } if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (daemon, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (daemon); return 32; } port = dinfo->port; } curl = curl_easy_init (); /* curl_easy_setopt(curl, CURLOPT_POST, 1L); */ snprintf (url, sizeof (url), "http://127.0.0.1:%u", (unsigned int) port); curl_easy_setopt (curl, CURLOPT_URL, url); curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_data); success = curl_easy_perform (curl); if (success != 0) { fprintf (stderr, "CURL Error"); exit (1); } /* CPU used to go crazy here */ (void) sleep (1); curl_easy_cleanup (curl); MHD_stop_daemon (daemon); return 0; } libmicrohttpd-1.0.1/src/testcurl/test_add_conn.c0000644000175000017500000011116614556023140015450 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009, 2011 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) - large rework, multithreading. libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_add_conn.c * @brief Testcase for libmicrohttpd GET operations * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #include "mhd_has_param.h" #include "mhd_sockets.h" /* only macros used */ #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #ifndef WINDOWS #include #include #endif #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ #ifdef HAVE_PTHREAD_H #include #endif /* HAVE_PTHREAD_H */ #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #if MHD_CPU_COUNT > 32 #undef MHD_CPU_COUNT /* Limit to reasonable value */ #define MHD_CPU_COUNT 32 #endif /* MHD_CPU_COUNT > 32 */ /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 /* Number of requests per daemon in cleanup test, * the number must be more than one as the first connection * will be processed and the rest will stay in the list of unprocessed */ #define CLEANUP_NUM_REQS_PER_DAEMON 6 /* Cleanup test: max number of concurrent daemons depending on maximum number * of open FDs. */ #define CLEANUP_MAX_DAEMONS(max_fds) (unsigned int) \ ( ((max_fds) < 10) ? \ 0 : ( (((max_fds) - 10) / (CLEANUP_NUM_REQS_PER_DAEMON * 5 + 3)) ) ) #define EXPECTED_URI_BASE_PATH "/hello_world" #define EXPECTED_URI_QUERY "a=%26&b=c" #define EXPECTED_URI_FULL_PATH EXPECTED_URI_BASE_PATH "?" EXPECTED_URI_QUERY /* Global parameters */ static int oneone; /**< Use HTTP/1.1 instead of HTTP/1.0 */ static int no_listen; /**< Start MHD daemons without listen socket */ static uint16_t global_port; /**< MHD daemons listen port number */ static int cleanup_test; /**< Test for final cleanup */ static int slow_reply = 0; /**< Slowdown MHD replies */ static int ignore_response_errors = 0; /**< Do not fail test if CURL returns error */ static int response_timeout_val = TIMEOUTS_VAL; static int sys_max_fds; /**< Current system limit for number of open files. */ struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static void * log_cb (void *cls, const char *uri, struct MHD_Connection *con) { (void) cls; (void) con; if (0 != strcmp (uri, EXPECTED_URI_FULL_PATH)) { fprintf (stderr, "Wrong URI: `%s'\n", uri); _exit (22); } return NULL; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; struct MHD_Response *response; enum MHD_Result ret; const char *v; (void) cls; (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silence compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; v = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "a"); if ( (NULL == v) || (0 != strcmp ("&", v)) ) { fprintf (stderr, "Found while looking for 'a=&': 'a=%s'\n", NULL == v ? "NULL" : v); _exit (17); } v = NULL; if (MHD_YES != MHD_lookup_connection_value_n (connection, MHD_GET_ARGUMENT_KIND, "b", 1, &v, NULL)) { fprintf (stderr, "Not found 'b' GET argument.\n"); _exit (18); } if ( (NULL == v) || (0 != strcmp ("c", v)) ) { fprintf (stderr, "Found while looking for 'b=c': 'b=%s'\n", NULL == v ? "NULL" : v); _exit (19); } if (slow_reply) usleep (200000); response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) { fprintf (stderr, "Failed to queue response.\n"); _exit (19); } return ret; } _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); _exit (99); } #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func (NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, NULL, __LINE__) #endif /* Static const value, indicates that result value was not set yet */ static const unsigned int eMarker = 0xCE; static MHD_socket createListeningSocket (uint16_t *pport) { MHD_socket skt; struct sockaddr_in sin; socklen_t sin_len; #ifdef MHD_POSIX_SOCKETS static int on = 1; #endif /* MHD_POSIX_SOCKETS */ skt = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); if (MHD_INVALID_SOCKET == skt) externalErrorExitDesc ("socket() failed"); #ifdef MHD_POSIX_SOCKETS setsockopt (skt, SOL_SOCKET, SO_REUSEADDR, (void *) &on, sizeof (on)); /* Ignore possible error */ #endif /* MHD_POSIX_SOCKETS */ memset (&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons (*pport); sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); if (0 != bind (skt, (struct sockaddr *) &sin, sizeof(sin))) externalErrorExitDesc ("bind() failed"); if (0 != listen (skt, SOMAXCONN)) externalErrorExitDesc ("listen() failed"); if (0 == *pport) { memset (&sin, 0, sizeof(sin)); sin_len = (socklen_t) sizeof(sin); if (0 != getsockname (skt, (struct sockaddr *) &sin, &sin_len)) externalErrorExitDesc ("getsockname() failed"); if (sizeof(sin) < (size_t) sin_len) externalErrorExitDesc ("getsockname() failed"); if (AF_INET != sin.sin_family) externalErrorExitDesc ("getsockname() returned wrong socket family"); *pport = ntohs (sin.sin_port); } return skt; } static MHD_socket acceptTimeLimited (MHD_socket lstn_sk, struct sockaddr *paddr, socklen_t *paddr_len) { fd_set rs; struct timeval timeoutval; MHD_socket accepted; FD_ZERO (&rs); FD_SET (lstn_sk, &rs); timeoutval.tv_sec = TIMEOUTS_VAL; timeoutval.tv_usec = 0; if (1 != select (((int) lstn_sk) + 1, &rs, NULL, NULL, &timeoutval)) externalErrorExitDesc ("select() failed"); accepted = accept (lstn_sk, paddr, paddr_len); if (MHD_INVALID_SOCKET == accepted) externalErrorExitDesc ("accept() failed"); return accepted; } struct addConnParam { struct MHD_Daemon *d; MHD_socket lstn_sk; MHD_socket clent_sk; /* Non-zero indicate error */ volatile unsigned int result; #ifdef HAVE_PTHREAD_H pthread_t addConnThread; #endif /* HAVE_PTHREAD_H */ }; static unsigned int doAcceptAndAddConnInThread (struct addConnParam *p) { struct sockaddr addr; socklen_t addr_len = sizeof(addr); p->clent_sk = acceptTimeLimited (p->lstn_sk, &addr, &addr_len); p->result = (MHD_YES == MHD_add_connection (p->d, p->clent_sk, &addr, addr_len)) ? 0 : 1; if (p->result) fprintf (stderr, "MHD_add_connection() failed, errno=%d.\n", errno); return p->result; } #ifdef HAVE_PTHREAD_H static void * doAcceptAndAddConn (void *param) { struct addConnParam *p = param; (void) doAcceptAndAddConnInThread (p); return (void *) p; } static void startThreadAddConn (struct addConnParam *param) { /* thread must reset this value to zero if succeed */ param->result = eMarker; if (0 != pthread_create (¶m->addConnThread, NULL, &doAcceptAndAddConn, (void *) param)) externalErrorExitDesc ("pthread_create() failed"); } static unsigned int finishThreadAddConn (struct addConnParam *param) { struct addConnParam *result; if (0 != pthread_join (param->addConnThread, (void **) &result)) externalErrorExitDesc ("pthread_join() failed"); if (param != result) abort (); /* Test used in a wrong way */ if (eMarker == param->result) abort (); /* Test used in a wrong way */ return result->result; } #endif /* HAVE_PTHREAD_H */ struct curlQueryParams { /* Destination path for CURL query */ const char *queryPath; /* Destination port for CURL query */ uint16_t queryPort; /* CURL query result error flag */ volatile unsigned int queryError; #ifdef HAVE_PTHREAD_H pthread_t queryThread; #endif /* HAVE_PTHREAD_H */ }; static CURL * curlEasyInitForTest (const char *queryPath, uint16_t port, struct CBC *pcbc) { CURL *c; c = curl_easy_init (); if (NULL == c) { fprintf (stderr, "curl_easy_init() failed.\n"); _exit (99); } if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, queryPath)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, (long) port)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, pcbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, (long) response_timeout_val)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, (long) response_timeout_val)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0))) { fprintf (stderr, "curl_easy_setopt() failed.\n"); _exit (99); } return c; } static unsigned int doCurlQueryInThread (struct curlQueryParams *p) { CURL *c; char buf[2048]; struct CBC cbc; CURLcode errornum; if (NULL == p->queryPath) abort (); if (0 == p->queryPort) abort (); cbc.buf = buf; cbc.size = sizeof(buf); cbc.pos = 0; c = curlEasyInitForTest (p->queryPath, p->queryPort, &cbc); errornum = curl_easy_perform (c); if (ignore_response_errors) { p->queryError = 0; curl_easy_cleanup (c); return p->queryError; } if (CURLE_OK != errornum) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); p->queryError = 2; } else { if (cbc.pos != strlen (EXPECTED_URI_BASE_PATH)) { fprintf (stderr, "curl reports wrong size of MHD reply body data.\n"); p->queryError = 4; } else if (0 != strncmp (EXPECTED_URI_BASE_PATH, cbc.buf, strlen (EXPECTED_URI_BASE_PATH))) { fprintf (stderr, "curl reports wrong MHD reply body data.\n"); p->queryError = 4; } else p->queryError = 0; } curl_easy_cleanup (c); return p->queryError; } #ifdef HAVE_PTHREAD_H static void * doCurlQuery (void *param) { struct curlQueryParams *p = (struct curlQueryParams *) param; (void) doCurlQueryInThread (p); return param; } static void startThreadCurlQuery (struct curlQueryParams *param) { /* thread must reset this value to zero if succeed */ param->queryError = eMarker; if (0 != pthread_create (¶m->queryThread, NULL, &doCurlQuery, (void *) param)) externalErrorExitDesc ("pthread_create() failed"); } static unsigned int finishThreadCurlQuery (struct curlQueryParams *param) { struct curlQueryParams *result; if (0 != pthread_join (param->queryThread, (void **) &result)) externalErrorExitDesc ("pthread_join() failed"); if (param != result) abort (); /* Test used in wrong way */ if (eMarker == param->queryError) abort (); /* Test used in wrong way */ return result->queryError; } /* Perform test queries and shut down MHD daemon */ static unsigned int performTestQueries (struct MHD_Daemon *d, uint16_t d_port) { struct curlQueryParams qParam; struct addConnParam aParam; uint16_t a_port; /* Additional listening socket port */ unsigned int ret = 0; /* Return value */ qParam.queryPath = "http://127.0.0.1" EXPECTED_URI_FULL_PATH; a_port = 0; /* auto-assign */ aParam.d = d; aParam.lstn_sk = createListeningSocket (&a_port); /* Sets a_port */ /* Test of adding connection in the same thread */ qParam.queryError = eMarker; /* to be zeroed in new thread */ qParam.queryPort = a_port; /* Connect to additional socket */ startThreadCurlQuery (&qParam); ret |= doAcceptAndAddConnInThread (&aParam); ret |= finishThreadCurlQuery (&qParam); if (! no_listen) { /* Test of the daemon itself can accept and process new connection. */ ret <<= 3; /* Remember errors for each step */ qParam.queryPort = d_port; /* Connect to the daemon */ ret |= doCurlQueryInThread (&qParam); } /* Test of adding connection in an external thread */ ret <<= 3; /* Remember errors for each step */ aParam.result = eMarker; /* to be zeroed in new thread */ qParam.queryPort = a_port; /* Connect to the daemon */ startThreadAddConn (&aParam); ret |= doCurlQueryInThread (&qParam); ret |= finishThreadAddConn (&aParam); (void) MHD_socket_close_ (aParam.lstn_sk); MHD_stop_daemon (d); return ret; } /* Perform test for cleanup and shutdown MHD daemon */ static unsigned int performTestCleanup (struct MHD_Daemon *d, unsigned int num_queries) { struct curlQueryParams *qParamList; struct addConnParam aParam; MHD_socket lstn_sk; /* Additional listening socket */ MHD_socket *clntSkList; uint16_t a_port; /* Additional listening socket port */ unsigned int i; unsigned int ret = 0; /* Return value */ a_port = 0; /* auto-assign */ if (0 >= num_queries) abort (); /* Test's API violation */ lstn_sk = createListeningSocket (&a_port); /* Sets a_port */ qParamList = malloc (sizeof(struct curlQueryParams) * num_queries); clntSkList = malloc (sizeof(MHD_socket) * num_queries); if ((NULL == qParamList) || (NULL == clntSkList)) externalErrorExitDesc ("malloc failed"); /* Start CURL queries */ for (i = 0; i < num_queries; i++) { qParamList[i].queryPath = "http://127.0.0.1" EXPECTED_URI_FULL_PATH; qParamList[i].queryError = 0; qParamList[i].queryPort = a_port; startThreadCurlQuery (qParamList + i); } /* Accept and add required number of client sockets */ aParam.d = d; aParam.lstn_sk = lstn_sk; for (i = 0; i < num_queries; i++) { aParam.clent_sk = MHD_INVALID_SOCKET; ret |= doAcceptAndAddConnInThread (&aParam); clntSkList[i] = aParam.clent_sk; } /* Stop daemon while some of new connection are not yet * processed because of slow response to the first queries. */ MHD_stop_daemon (d); (void) MHD_socket_close_ (aParam.lstn_sk); /* Check whether all client sockets were closed by MHD. * Closure of socket by MHD indicate valid cleanup performed. */ for (i = 0; i < num_queries; i++) { if (MHD_INVALID_SOCKET != clntSkList[i]) { /* Check whether socket could be closed one more time. */ if (MHD_socket_close_ (clntSkList[i])) { ret |= 2; fprintf (stderr, "Client socket was not closed by MHD during" \ "cleanup process.\n"); } } } /* Wait for CURL threads to complete. */ /* Ignore soft CURL errors as many connection shouldn't get any response. * Hard failures are detected in processing function. */ for (i = 0; i < num_queries; i++) (void) finishThreadCurlQuery (qParamList + i); free (clntSkList); free (qParamList); return ret; } #endif /* HAVE_PTHREAD_H */ enum testMhdThreadsType { testMhdThreadExternal = 0, testMhdThreadInternal = MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPerConnection = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPool }; enum testMhdPollType { testMhdPollBySelect = 0, testMhdPollByPoll = MHD_USE_POLL, testMhdPollByEpoll = MHD_USE_EPOLL, testMhdPollAuto = MHD_USE_AUTO }; /* Get number of threads for thread pool depending * on used poll function and test type. */ static unsigned int testNumThreadsForPool (enum testMhdPollType pollType) { unsigned int numThreads = MHD_CPU_COUNT; if (! cleanup_test) return numThreads; /* No practical limit for non-cleanup test */ if (CLEANUP_MAX_DAEMONS (sys_max_fds) < numThreads) numThreads = CLEANUP_MAX_DAEMONS (sys_max_fds); if ((testMhdPollBySelect == pollType) && (CLEANUP_MAX_DAEMONS (FD_SETSIZE) < numThreads)) numThreads = CLEANUP_MAX_DAEMONS (FD_SETSIZE); if (2 > numThreads) abort (); return (unsigned int) numThreads; } static struct MHD_Daemon * startTestMhdDaemon (enum testMhdThreadsType thrType, enum testMhdPollType pollType, uint16_t *pport) { struct MHD_Daemon *d; const union MHD_DaemonInfo *dinfo; if ( (0 == *pport) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { *pport = 1550; if (oneone) *pport += 1; if (no_listen) *pport += 2; if (cleanup_test) *pport += 4; } switch (thrType) { case testMhdThreadExternal: d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType) | MHD_USE_NO_THREAD_SAFETY | (no_listen ? MHD_USE_NO_LISTEN_SOCKET : 0) | MHD_USE_ERROR_LOG, *pport, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); break; case testMhdThreadInternalPool: d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | ((unsigned int) pollType) | MHD_USE_ITC | (no_listen ? MHD_USE_NO_LISTEN_SOCKET : 0) | MHD_USE_ERROR_LOG, *pport, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, testNumThreadsForPool (pollType), MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_END); break; case testMhdThreadInternal: case testMhdThreadInternalPerConnection: d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType) | MHD_USE_ITC | (no_listen ? MHD_USE_NO_LISTEN_SOCKET : 0) | MHD_USE_ERROR_LOG, *pport, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_END); break; default: abort (); break; } if (NULL == d) { fprintf (stderr, "Failed to start MHD daemon, errno=%d.\n", errno); abort (); } if ((! no_listen) && (0 == *pport)) { dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { fprintf (stderr, "MHD_get_daemon_info() failed.\n"); abort (); } *pport = dinfo->port; } return d; } /* Test runners */ static unsigned int testExternalGet (void) { struct MHD_Daemon *d; CURL *c_d; char buf_d[2048]; struct CBC cbc_d; CURL *c_a; char buf_a[2048]; struct CBC cbc_a; CURLM *multi; time_t start; struct timeval tv; uint16_t d_port = global_port; /* Daemon's port */ uint16_t a_port = 0; /* Additional listening socket port */ struct addConnParam aParam; unsigned int ret = 0; /* Return value of the test */ const int c_no_listen = no_listen; /* Local const value to mute analyzer */ d = startTestMhdDaemon (testMhdThreadExternal, testMhdPollBySelect, &d_port); aParam.d = d; aParam.lstn_sk = createListeningSocket (&a_port); multi = NULL; cbc_d.buf = buf_d; cbc_d.size = sizeof(buf_d); cbc_d.pos = 0; cbc_a.buf = buf_a; cbc_a.size = sizeof(buf_a); cbc_a.pos = 0; if (cleanup_test) abort (); /* Not possible with "external poll" as connections are directly added to the daemon processing in the mode. */ if (! c_no_listen) c_d = curlEasyInitForTest ("http://127.0.0.1" EXPECTED_URI_FULL_PATH, d_port, &cbc_d); else c_d = NULL; /* To mute compiler warning only */ c_a = curlEasyInitForTest ("http://127.0.0.1" EXPECTED_URI_FULL_PATH, a_port, &cbc_a); multi = curl_multi_init (); if (multi == NULL) { fprintf (stderr, "curl_multi_init() failed.\n"); _exit (99); } if (! c_no_listen) { if (CURLM_OK != curl_multi_add_handle (multi, c_d)) { fprintf (stderr, "curl_multi_add_handle() failed.\n"); _exit (99); } } if (CURLM_OK != curl_multi_add_handle (multi, c_a)) { fprintf (stderr, "curl_multi_add_handle() failed.\n"); _exit (99); } start = time (NULL); while (time (NULL) - start <= TIMEOUTS_VAL) { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int maxCurlSk; int running; maxMhdSk = MHD_INVALID_SOCKET; maxCurlSk = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); if (0 == running) { struct CURLMsg *msg; int msgLeft; int totalMsgs = 0; do { msg = curl_multi_info_read (multi, &msgLeft); if (NULL == msg) { fprintf (stderr, "curl_multi_info_read failed, NULL returned.\n"); _exit (99); } totalMsgs++; if (CURLMSG_DONE == msg->msg) { if (CURLE_OK != msg->data.result) { fprintf (stderr, "curl_multi_info_read failed, error: '%s'\n", curl_easy_strerror (msg->data.result)); ret |= 2; } } } while (msgLeft > 0); if ((no_listen ? 1 : 2) != totalMsgs) { fprintf (stderr, "curl_multi_info_read returned wrong " "number of results (%d).\n", totalMsgs); _exit (99); } break; /* All transfers have finished. */ } if (CURLM_OK != curl_multi_fdset (multi, &rs, &ws, &es, &maxCurlSk)) { fprintf (stderr, "curl_multi_fdset() failed.\n"); _exit (99); } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) { ret |= 8; break; } FD_SET (aParam.lstn_sk, &rs); if (maxMhdSk < aParam.lstn_sk) maxMhdSk = aParam.lstn_sk; tv.tv_sec = 0; tv.tv_usec = 1000; #ifdef MHD_POSIX_SOCKETS if (maxMhdSk > maxCurlSk) maxCurlSk = maxMhdSk; #endif /* MHD_POSIX_SOCKETS */ if (-1 == select (maxCurlSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } if (FD_ISSET (aParam.lstn_sk, &rs)) ret |= doAcceptAndAddConnInThread (&aParam); if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) { fprintf (stderr, "MHD_run_from_select() failed.\n"); ret |= 1; break; } } MHD_stop_daemon (d); (void) MHD_socket_close_ (aParam.lstn_sk); if (! c_no_listen) { curl_multi_remove_handle (multi, c_d); curl_easy_cleanup (c_d); if (cbc_d.pos != strlen ("/hello_world")) { fprintf (stderr, "curl reports wrong size of MHD reply body data at line %d.\n", __LINE__); ret |= 4; } if (0 != strncmp ("/hello_world", cbc_d.buf, strlen ("/hello_world"))) { fprintf (stderr, "curl reports wrong MHD reply body data at line %d.\n", __LINE__); ret |= 4; } } curl_multi_remove_handle (multi, c_a); curl_easy_cleanup (c_a); curl_multi_cleanup (multi); if (cbc_a.pos != strlen ("/hello_world")) { fprintf (stderr, "curl reports wrong size of MHD reply body data at line %d.\n", __LINE__); ret |= 4; } if (0 != strncmp ("/hello_world", cbc_a.buf, strlen ("/hello_world"))) { fprintf (stderr, "curl reports wrong MHD reply body data at line %d.\n", __LINE__); ret |= 4; } return ret; } #ifdef HAVE_PTHREAD_H static unsigned int testInternalGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ d = startTestMhdDaemon (testMhdThreadInternal, pollType, &d_port); if (cleanup_test) return performTestCleanup (d, CLEANUP_NUM_REQS_PER_DAEMON); return performTestQueries (d, d_port); } static unsigned int testMultithreadedGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ d = startTestMhdDaemon (testMhdThreadInternalPerConnection, pollType, &d_port); if (cleanup_test) abort (); /* Cannot be tested as main daemon thread cannot be slowed down by slow responses, so it processes all new connections before daemon could be stopped. */ return performTestQueries (d, d_port); } static unsigned int testMultithreadedPoolGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ d = startTestMhdDaemon (testMhdThreadInternalPool, pollType, &d_port); if (cleanup_test) return performTestCleanup (d, CLEANUP_NUM_REQS_PER_DAEMON * testNumThreadsForPool (pollType)); return performTestQueries (d, d_port); } static unsigned int testStopRace (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ uint16_t a_port = 0; /* Additional listening socket port */ struct sockaddr_in sin; MHD_socket fd1; MHD_socket fd2; struct addConnParam aParam; unsigned int ret = 0; /* Return value of the test */ d = startTestMhdDaemon (testMhdThreadInternal, pollType, &d_port); if (! no_listen) { fd1 = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); if (MHD_INVALID_SOCKET == fd1) externalErrorExitDesc ("socket() failed"); memset (&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons (d_port); sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); if (connect (fd1, (struct sockaddr *) (&sin), sizeof(sin)) < 0) externalErrorExitDesc ("socket() failed"); } else fd1 = MHD_INVALID_SOCKET; aParam.d = d; aParam.lstn_sk = createListeningSocket (&a_port); /* Sets a_port */ startThreadAddConn (&aParam); fd2 = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); if (MHD_INVALID_SOCKET == fd2) externalErrorExitDesc ("socket() failed"); memset (&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons (a_port); sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); if (connect (fd2, (struct sockaddr *) (&sin), sizeof(sin)) < 0) externalErrorExitDesc ("socket() failed"); ret |= finishThreadAddConn (&aParam); /* Let the thread get going. */ usleep (500000); MHD_stop_daemon (d); if (MHD_INVALID_SOCKET != fd1) (void) MHD_socket_close_ (fd1); (void) MHD_socket_close_ (aParam.lstn_sk); (void) MHD_socket_close_ (fd2); return ret; } #endif /* HAVE_PTHREAD_H */ int main (int argc, char *const *argv) { unsigned int errorCount = 0; unsigned int test_result = 0; int verbose = 0; if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); /* Whether to test MHD daemons without listening socket. */ no_listen = has_in_name (argv[0], "_nolisten"); /* Whether to test for correct final cleanup instead of * of test of normal processing. */ cleanup_test = has_in_name (argv[0], "_cleanup"); /* There are almost nothing that could be tested externally * for final cleanup. Cleanup test actually just tests that * all added client connections were closed by MHD and * nothing fails or crashes when final cleanup is performed. * Mostly useful when configured with '--enable-asserts. */ slow_reply = cleanup_test; ignore_response_errors = cleanup_test; #ifndef HAVE_PTHREAD_H if (cleanup_test) return 77; /* Cannot run without threads */ #endif /* HAVE_PTHREAD_H */ verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); if (cleanup_test) { #ifndef _WIN32 /* Find system limit for number of open FDs. */ #if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX) sys_max_fds = sysconf (_SC_OPEN_MAX) > 500000 ? 500000 : (int) sysconf (_SC_OPEN_MAX); #else /* ! HAVE_SYSCONF || ! _SC_OPEN_MAX */ sys_max_fds = -1; #endif /* ! HAVE_SYSCONF || ! _SC_OPEN_MAX */ if (0 > sys_max_fds) { #if defined(OPEN_MAX) && (0 < ((OPEN_MAX) +1)) sys_max_fds = OPEN_MAX > 500000 ? 500000 : (int) OPEN_MAX; #else /* ! OPEN_MAX */ sys_max_fds = 256; /* Use reasonable value */ #endif /* ! OPEN_MAX */ if (2 > CLEANUP_MAX_DAEMONS (sys_max_fds)) return 77; /* Multithreaded test cannot be run */ } #else /* _WIN32 */ sys_max_fds = 120; /* W32 has problems with ports exhaust */ #endif /* _WIN32 */ } if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 99; /* Could be set to non-zero value to enforce using specific port * in the test */ global_port = 0; if (! cleanup_test) { test_result = testExternalGet (); if (test_result) fprintf (stderr, "FAILED: testExternalGet () - %u.\n", test_result); else if (verbose) printf ("PASSED: testExternalGet ().\n"); errorCount += test_result; } #ifdef HAVE_PTHREAD_H if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { test_result = testInternalGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedPoolGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (testMhdPollBySelect).\n"); errorCount += test_result; if (! cleanup_test) { test_result = testMultithreadedGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedGet (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testStopRace (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testStopRace (testMhdPollBySelect) - %u.\n", test_result); else if (verbose) printf ("PASSED: testStopRace (testMhdPollBySelect).\n"); errorCount += test_result; } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { test_result = testInternalGet (testMhdPollByPoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByPoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByPoll).\n"); errorCount += test_result; test_result = testMultithreadedPoolGet (testMhdPollByPoll); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (testMhdPollByPoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (testMhdPollByPoll).\n"); errorCount += test_result; if (! cleanup_test) { test_result = testMultithreadedGet (testMhdPollByPoll); if (test_result) fprintf (stderr, "FAILED: testMultithreadedGet (testMhdPollByPoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedGet (testMhdPollByPoll).\n"); errorCount += test_result; test_result = testStopRace (testMhdPollByPoll); if (test_result) fprintf (stderr, "FAILED: testStopRace (testMhdPollByPoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testStopRace (testMhdPollByPoll).\n"); errorCount += test_result; } } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { test_result = testInternalGet (testMhdPollByEpoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByEpoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByEpoll).\n"); errorCount += test_result; test_result = testMultithreadedPoolGet (testMhdPollByEpoll); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (testMhdPollByEpoll) - %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (testMhdPollByEpoll).\n"); errorCount += test_result; } } #endif /* HAVE_PTHREAD_H */ if (0 != errorCount) fprintf (stderr, "Error (code: %u)\n", errorCount); else if (verbose) printf ("All tests passed.\n"); curl_global_cleanup (); return (errorCount == 0) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_digestauth_sha256.c0000644000175000017500000002364614555767064017164 /* This file is part of libmicrohttpd Copyright (C) 2010, 2018 Christian Grothoff Copyright (C) 2019-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file daemontest_digestauth_sha256.c * @brief Testcase for libmicrohttpd Digest Auth with SHA256 * @author Amr Ali * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #if defined(MHD_HTTPS_REQUIRE_GCRYPT) && \ (defined(MHD_SHA256_TLSLIB) || defined(MHD_MD5_TLSLIB)) #define NEED_GCRYP_INIT 1 #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT && (MHD_SHA256_TLSLIB || MHD_MD5_TLSLIB) */ #ifndef WINDOWS #include #include #else #include #endif #define PAGE \ "libmicrohttpd demoAccess granted" #define DENIED \ "libmicrohttpd demoAccess denied" #define MY_OPAQUE "11733b200778ce33060f31c9af70a870ba96ddd4" struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; char *username; const char *password = "testpass"; const char *realm = "test@example.com"; enum MHD_Result ret; int ret_i; static int already_called_marker; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ if (&already_called_marker != *req_cls) { /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; } username = MHD_digest_auth_get_username (connection); if ( (username == NULL) || (0 != strcmp (username, "testuser")) ) { response = MHD_create_response_from_buffer_static (strlen (DENIED), DENIED); ret = MHD_queue_auth_fail_response2 (connection, realm, MY_OPAQUE, response, MHD_NO, MHD_DIGEST_ALG_SHA256); MHD_destroy_response (response); return ret; } ret_i = MHD_digest_auth_check2 (connection, realm, username, password, 300, MHD_DIGEST_ALG_SHA256); MHD_free (username); if (ret_i != MHD_YES) { response = MHD_create_response_from_buffer_static (strlen (DENIED), DENIED); if (NULL == response) return MHD_NO; ret = MHD_queue_auth_fail_response2 (connection, realm, MY_OPAQUE, response, (MHD_INVALID_NONCE == ret_i) ? MHD_YES : MHD_NO, MHD_DIGEST_ALG_SHA256); MHD_destroy_response (response); return ret; } response = MHD_create_response_from_buffer_static (strlen (PAGE), PAGE); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int testDigestAuth (void) { CURL *c; CURLcode errornum; struct MHD_Daemon *d; struct CBC cbc; char buf[2048]; char rnd[8]; uint16_t port; char url[128]; #ifndef WINDOWS int fd; size_t len; size_t off = 0; #endif /* ! WINDOWS */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1167; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; #ifndef WINDOWS fd = open ("/dev/urandom", O_RDONLY); if (-1 == fd) { fprintf (stderr, "Failed to open `%s': %s\n", "/dev/urandom", strerror (errno)); return 1; } while (off < 8) { len = (size_t) read (fd, rnd + off, 8 - off); if (len == (size_t) -1) { fprintf (stderr, "Failed to read `%s': %s\n", "/dev/urandom", strerror (errno)); (void) close (fd); return 1; } off += len; } (void) close (fd); #else { HCRYPTPROV cc; BOOL b; b = CryptAcquireContext (&cc, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); if (b == 0) { fprintf (stderr, "Failed to acquire crypto provider context: %lu\n", GetLastError ()); return 1; } b = CryptGenRandom (cc, 8, (BYTE *) rnd); if (b == 0) { fprintf (stderr, "Failed to generate 8 random bytes: %lu\n", GetLastError ()); } CryptReleaseContext (cc, 0); if (b == 0) return 1; } #endif d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, MHD_OPTION_NONCE_NC_SIZE, 300, MHD_OPTION_DIGEST_AUTH_DEFAULT_MAX_NC, (uint32_t) 999, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } snprintf (url, sizeof (url), "http://127.0.0.1:%u/bar%%20foo?key=value", (unsigned int) port); c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); curl_easy_setopt (c, CURLOPT_USERPWD, "testuser:testpass"); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system!*/ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen (PAGE)) return 4; if (0 != strncmp (PAGE, cbc.buf, strlen (PAGE))) return 8; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; curl_version_info_data *d = curl_version_info (CURLVERSION_NOW); (void) argc; (void) argv; /* Unused. Silent compiler warning. */ #if (LIBCURL_VERSION_MAJOR == 7) && (LIBCURL_VERSION_MINOR == 62) if (1) { fprintf (stderr, "libcurl version 7.62.x has bug in processing" "URI with GET arguments for Digest Auth.\n"); fprintf (stderr, "This test cannot be performed.\n"); exit (77); } #endif /* libcurl version 7.62.x */ #ifdef CURL_VERSION_SSPI if (0 != (d->features & CURL_VERSION_SSPI)) return 77; /* Skip test, W32 SSPI doesn't support sha256 digest */ #endif /* CURL_VERSION_SSPI */ /* curl added SHA256 support in 7.57 = 7.0x39 */ if (d->version_num < 0x073900) return 77; /* skip test, curl is too old */ #ifdef NEED_GCRYP_INIT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* GCRYCTL_INITIALIZATION_FINISHED */ #endif /* NEED_GCRYP_INIT */ if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; errorCount += testDigestAuth (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_long_header.c0000644000175000017500000003462614505047640016164 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff Copyright (C) 2016-2023 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_long_header.c * @brief Testcase for libmicrohttpd handling of very long headers * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #ifndef WINDOWS #include #endif #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ /** * We will set the memory available per connection to * half of this value, so the actual value does not have * to be big at all... */ #define VERY_LONG (1024 * 8) /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 #define EXPECTED_URI_BASE_PATH "/" #define URL_SCHEME "http:/" "/" #define URL_HOST "127.0.0.1" #define URL_SCHEME_HOST_PATH URL_SCHEME URL_HOST EXPECTED_URI_BASE_PATH static int oneone; static uint16_t daemon_port; static char libcurl_err_buf[CURL_ERROR_SIZE]; struct CBC { char *buf; size_t pos; size_t size; }; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { (void) ptr; (void) ctx; /* Unused. Silent compiler warning. */ return size * nmemb; } /* Return non-zero on success, zero on failure */ static int setup_easy_handler_params (CURL *c, struct CBC *pcbc, const char *url, struct curl_slist *header) { libcurl_err_buf[0] = 0; /* Reset error message */ if (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, libcurl_err_buf)) { fprintf (stderr, "Failed to set CURLOPT_ERRORBUFFER option.\n"); return 0; } if (CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) { fprintf (stderr, "Failed to set CURLOPT_NOSIGNAL option.\n"); return 0; } if (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) { fprintf (stderr, "Failed to set CURLOPT_WRITEFUNCTION option.\n"); return 0; } if (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, pcbc)) { fprintf (stderr, "Failed to set CURLOPT_WRITEDATA option.\n"); return 0; } if (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) TIMEOUTS_VAL))) { fprintf (stderr, "Failed to set CURLOPT_CONNECTTIMEOUT option.\n"); return 0; } if (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) TIMEOUTS_VAL))) { fprintf (stderr, "Failed to set CURLOPT_TIMEOUT option.\n"); return 0; } if (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, (oneone) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0)) { fprintf (stderr, "Failed to set CURLOPT_HTTP_VERSION option.\n"); return 0; } if (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 0L)) { fprintf (stderr, "Failed to set CURLOPT_FAILONERROR option.\n"); return 0; } #ifdef _DEBUG if (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) { fprintf (stderr, "Failed to set CURLOPT_VERBOSE option.\n"); return 0; } #endif /* _DEBUG */ #if CURL_AT_LEAST_VERSION (7, 45, 0) if (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) { fprintf (stderr, "Failed to set CURLOPT_DEFAULT_PROTOCOL option.\n"); return 0; } #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ #if CURL_AT_LEAST_VERSION (7, 85, 0) if (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http")) { fprintf (stderr, "Failed to set CURLOPT_PROTOCOLS_STR option.\n"); return 0; } #elif CURL_AT_LEAST_VERSION (7, 19, 4) if (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) { fprintf (stderr, "Failed to set CURLOPT_PROTOCOLS option.\n"); return 0; } #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ if (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, (NULL != url) ? url : URL_SCHEME_HOST_PATH)) { fprintf (stderr, "Failed to set CURLOPT_PROTOCOLS option.\n"); return 0; } if (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) daemon_port))) { fprintf (stderr, "Failed to set CURLOPT_PROTOCOLS option.\n"); return 0; } if (NULL != header) { if (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPHEADER, header)) { fprintf (stderr, "Failed to set CURLOPT_HTTPHEADER option.\n"); return 0; } } return ! 0; } static CURL * setup_easy_handler (struct CBC *pcbc, const char *url, struct curl_slist *header) { CURL *c; c = curl_easy_init (); if (NULL == c) { fprintf (stderr, "curl_easy_init() error.\n"); return NULL; } if (setup_easy_handler_params (c, pcbc, url, header)) { return c; /* Success exit point */ } curl_easy_cleanup (c); return NULL; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; static int marker; (void) cls; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ if (&marker != *req_cls) { *req_cls = ▮ return MHD_YES; } if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static unsigned int testLongUrlGet (size_t buff_size) { struct MHD_Daemon *d; unsigned int ret; ret = 1; /* Error value, shall be reset to zero if succeed */ d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */, daemon_port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) buff_size, MHD_OPTION_END); if (d == NULL) { fprintf (stderr, "MHD_start_daemon() failed.\n"); return 16; } if (0 == daemon_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) fprintf (stderr, "MHD_get_daemon_info(d, MHD_DAEMON_INFO_BIND_PORT) " \ "failed.\n"); else daemon_port = dinfo->port; } if (0 != daemon_port) { char *url_str; url_str = malloc (VERY_LONG); if (NULL == url_str) fprintf (stderr, "malloc (VERY_LONG) failed.\n"); else { CURL *c; char buf[2048]; struct CBC cbc; memset (url_str, 'a', VERY_LONG); url_str[VERY_LONG - 1] = '\0'; memcpy (url_str, URL_SCHEME_HOST_PATH, MHD_STATICSTR_LEN_ (URL_SCHEME_HOST_PATH)); cbc.buf = buf; cbc.size = sizeof (buf); cbc.pos = 0; c = setup_easy_handler (&cbc, url_str, NULL); if (NULL != c) { CURLcode r; r = curl_easy_perform (c); if (CURLE_OK != r) { fprintf (stderr, "curl_easy_perform() failed. Error message: %s\n", curl_easy_strerror (r)); if (0 != libcurl_err_buf[0]) fprintf (stderr, "Detailed error message: %s\n", libcurl_err_buf); } else { long code; r = curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code); if (CURLE_OK != r) { fprintf (stderr, "curl_easy_getinfo() failed. " "Error message: %s\n", curl_easy_strerror (r)); if (0 != libcurl_err_buf[0]) fprintf (stderr, "Detailed error message: %s\n", libcurl_err_buf); } else { if (code != MHD_HTTP_URI_TOO_LONG) { fprintf (stderr, "testLongHeaderGet(%lu) failed. HTTP " "response code is %ld, while it should be %ld.\n", (unsigned long) buff_size, code, (long) MHD_HTTP_URI_TOO_LONG); } else { printf ("testLongHeaderGet(%lu) succeed. HTTP " "response code is %ld, as expected.\n", (unsigned long) buff_size, (long) MHD_HTTP_URI_TOO_LONG); ret = 0; /* Success */ } } } curl_easy_cleanup (c); } free (url_str); } } MHD_stop_daemon (d); return ret; } static unsigned int testLongHeaderGet (size_t buff_size) { struct MHD_Daemon *d; unsigned int ret; ret = 1; /* Error value, shall be reset to zero if succeed */ d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */, daemon_port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) buff_size, MHD_OPTION_END); if (d == NULL) { fprintf (stderr, "MHD_start_daemon() failed.\n"); return 16; } if (0 == daemon_port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) fprintf (stderr, "MHD_get_daemon_info(d, MHD_DAEMON_INFO_BIND_PORT) " \ "failed.\n"); else daemon_port = dinfo->port; } if (0 != daemon_port) { char *header_str; header_str = malloc (VERY_LONG); if (NULL == header_str) fprintf (stderr, "malloc (VERY_LONG) failed.\n"); else { struct curl_slist *header = NULL; memset (header_str, 'a', VERY_LONG); header_str[VERY_LONG - 1] = '\0'; header_str[VERY_LONG / 2] = ':'; header_str[VERY_LONG / 2 + 1] = ' '; header = curl_slist_append (header, header_str); if (NULL == header) fprintf (stderr, "curl_slist_append () failed.\n"); else { CURL *c; char buf[2048]; struct CBC cbc; cbc.buf = buf; cbc.size = sizeof (buf); cbc.pos = 0; c = setup_easy_handler (&cbc, NULL, header); if (NULL != c) { CURLcode r; r = curl_easy_perform (c); if (CURLE_OK != r) { fprintf (stderr, "curl_easy_perform() failed. Error message: %s\n", curl_easy_strerror (r)); if (0 != libcurl_err_buf[0]) fprintf (stderr, "Detailed error message: %s\n", libcurl_err_buf); } else { long code; r = curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &code); if (CURLE_OK != r) { fprintf (stderr, "curl_easy_getinfo() failed. " "Error message: %s\n", curl_easy_strerror (r)); if (0 != libcurl_err_buf[0]) fprintf (stderr, "Detailed error message: %s\n", libcurl_err_buf); } else { if (code != MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE) { fprintf (stderr, "testLongHeaderGet(%lu) failed. HTTP " "response code is %ld, while it should be %ld.\n", (unsigned long) buff_size, code, (long) MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE); } else { printf ("testLongHeaderGet(%lu) succeed. HTTP " "response code is %ld, as expected.\n", (unsigned long) buff_size, (long) MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE); ret = 0; /* Success */ } } } curl_easy_cleanup (c); } curl_slist_free_all (header); } free (header_str); } } MHD_stop_daemon (d); return ret; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) daemon_port = 0; else daemon_port = oneone ? 1336 : 1331; errorCount += testLongUrlGet (VERY_LONG / 2); errorCount += testLongUrlGet (VERY_LONG / 2 + 978); errorCount += testLongHeaderGet (VERY_LONG / 2); errorCount += testLongHeaderGet (VERY_LONG / 2 + 1893); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); else printf ("Test succeed.\n"); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_get_wait.c0000644000175000017500000001472714441373361015521 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009, 2011 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_get_wait.c * @brief Test 'MHD_run_wait()' function. * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif /** * How many rounds of operations do we do for each * test. * Check all three types of requests for HTTP/1.1: * * first request, new connection; * * "middle" request, existing connection with stay-alive; * * final request, no data processed after. */ #define ROUNDS 3 /** * Do we use HTTP 1.1? */ static int oneone; /** * Response to return (re-used). */ static struct MHD_Response *response; /** * Set to 1 if the worker threads are done. */ static volatile int signal_done; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { (void) ptr; (void) ctx; /* Unused. Silent compiler warning. */ return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int ptr; enum MHD_Result ret; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&ptr != *req_cls) { *req_cls = &ptr; return MHD_YES; } *req_cls = NULL; ret = MHD_queue_response (connection, MHD_HTTP_OK, response); if (ret == MHD_NO) abort (); return ret; } static void * thread_gets (void *param) { CURL *c; CURLcode errornum; unsigned int i; char url[64]; uint16_t port = (uint16_t) (intptr_t) param; snprintf (url, sizeof (url), "http://127.0.0.1:%u/hello_world", (unsigned int) port); c = curl_easy_init (); if (NULL == c) _exit (99); curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, NULL); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 15L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); for (i = 0; i < ROUNDS; i++) { if (CURLE_OK != (errornum = curl_easy_perform (c))) { signal_done = 1; fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); abort (); } } curl_easy_cleanup (c); signal_done = 1; return NULL; } static unsigned int testRunWaitGet (uint16_t port, uint32_t poll_flag) { pthread_t get_tid; struct MHD_Daemon *d; const char *const test_desc = ((poll_flag & MHD_USE_AUTO) ? "MHD_USE_AUTO" : (poll_flag & MHD_USE_POLL) ? "MHD_USE_POLL" : (poll_flag & MHD_USE_EPOLL) ? "MHD_USE_EPOLL" : "select()"); if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; printf ("Starting MHD_run_wait() test with MHD in %s polling mode.\n", test_desc); signal_done = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) abort (); if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) abort (); port = dinfo->port; } if (0 != pthread_create (&get_tid, NULL, &thread_gets, (void *) (intptr_t) port)) _exit (99); /* As another thread sets "done" flag after ending of network * activity, it's required to set positive timeout value for MHD_run_wait(). * Alternatively, to use timeout value "-1" here, another thread should start * additional connection to wake MHD after setting "done" flag. */ do { if (MHD_NO == MHD_run_wait (d, 50)) abort (); } while (0 == signal_done); if (0 != pthread_join (get_tid, NULL)) _exit (99); MHD_stop_daemon (d); printf ("Test succeeded.\n"); return 0; } int main (int argc, char *const *argv) { uint16_t port = 1675; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (oneone) port += 5; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; response = MHD_create_response_from_buffer_static (strlen ("/hello_world"), "/hello_world"); testRunWaitGet (port++, 0); if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) testRunWaitGet (port++, MHD_USE_EPOLL); testRunWaitGet (port++, MHD_USE_AUTO); MHD_destroy_response (response); curl_global_cleanup (); return 0; /* Errors produce abort() or _exit() */ } libmicrohttpd-1.0.1/src/testcurl/test_patch.c0000644000175000017500000003223014530120375014774 /* This file is part of libmicrohttpd Copyright (C) 2020 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_patch.c * @brief Testcase for libmicrohttpd PATCH operations * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #include "mhd_has_in_name.h" #ifndef WINDOWS #include #endif #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif static int oneone; struct CBC { char *buf; size_t pos; size_t size; }; static size_t putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) { size_t *pos = ptr; size_t wrt; wrt = size * nmemb; if (wrt > 8 - (*pos)) wrt = 8 - (*pos); memcpy (stream, &("Hello123"[*pos]), wrt); (*pos) += wrt; return wrt; } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) return 0; /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { int *done = cls; struct MHD_Response *response; enum MHD_Result ret; (void) version; (void) req_cls; /* Unused. Silent compiler warning. */ if (0 != strcmp ("PATCH", method)) return MHD_NO; /* unexpected method */ if ((*done) == 0) { if (*upload_data_size != 8) return MHD_YES; /* not yet ready */ if (0 == memcmp (upload_data, "Hello123", 8)) { *upload_data_size = 0; } else { printf ("Invalid upload data `%8s'!\n", upload_data); return MHD_NO; } *done = 1; return MHD_YES; } response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } static CURL * setup_curl (long port, struct CBC *cbc, size_t *pos) { CURL *c; c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_CUSTOMREQUEST, "PATCH"); curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); curl_easy_setopt (c, CURLOPT_PORT, (long) port); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc); curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); curl_easy_setopt (c, CURLOPT_READDATA, pos); curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, (curl_off_t) 8L); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 150L); /* NOTE: use of CONNECTTIMEOUT without also * setting NOSIGNAL results in really weird * crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); return c; } static unsigned int testInternalPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1450; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = setup_curl (port, &cbc, &pos); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 4; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 8; return 0; } static unsigned int testMultithreadedPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1451; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = setup_curl (port, &cbc, &pos); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testMultithreadedPoolPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; size_t pos = 0; int done_flag = 0; CURLcode errornum; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1452; if (oneone) port += 10; } cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = setup_curl (port, &cbc, &pos); if (CURLE_OK != (errornum = curl_easy_perform (c))) { fprintf (stderr, "curl_easy_perform failed: `%s'\n", curl_easy_strerror (errornum)); curl_easy_cleanup (c); MHD_stop_daemon (d); return 32; } curl_easy_cleanup (c); MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 64; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 128; return 0; } static unsigned int testExternalPut (void) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; CURLM *multi; CURLMcode mret; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; int maxposixs; /* Max socket number unused on W32 */ int running; struct CURLMsg *msg; time_t start; struct timeval tv; size_t pos = 0; int done_flag = 0; uint16_t port; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else { port = 1453; if (oneone) port += 10; } multi = NULL; cbc.buf = buf; cbc.size = 2048; cbc.pos = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, port, NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 256; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } c = setup_curl (port, &cbc, &pos); multi = curl_multi_init (); if (multi == NULL) { curl_easy_cleanup (c); MHD_stop_daemon (d); return 512; } mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 1024; } start = time (NULL); while ((time (NULL) - start < 5) && (multi != NULL)) { maxsock = MHD_INVALID_SOCKET; maxposixs = -1; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); if (mret != CURLM_OK) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 2048; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) { curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); MHD_stop_daemon (d); return 4096; } #ifdef MHD_POSIX_SOCKETS if (maxsock > maxposixs) maxposixs = maxsock; #endif /* MHD_POSIX_SOCKETS */ tv.tv_sec = 0; tv.tv_usec = 1000; if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) errno, __LINE__); fflush (stderr); exit (99); } #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) { fprintf (stderr, "Unexpected select() error: %d. Line: %d\n", (int) WSAGetLastError (), __LINE__); fflush (stderr); exit (99); } Sleep (1); #endif } curl_multi_perform (multi, &running); if (0 == running) { int pending; int curl_fine = 0; while (NULL != (msg = curl_multi_info_read (multi, &pending))) { if (msg->msg == CURLMSG_DONE) { if (msg->data.result == CURLE_OK) curl_fine = 1; else { fprintf (stderr, "%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, __LINE__, curl_easy_strerror (msg->data.result)); abort (); } } } if (! curl_fine) { fprintf (stderr, "libcurl haven't returned OK code\n"); abort (); } curl_multi_remove_handle (multi, c); curl_multi_cleanup (multi); curl_easy_cleanup (c); c = NULL; multi = NULL; } MHD_run (d); } if (multi != NULL) { curl_multi_remove_handle (multi, c); curl_easy_cleanup (c); curl_multi_cleanup (multi); } MHD_stop_daemon (d); if (cbc.pos != strlen ("/hello_world")) return 8192; if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) return 16384; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { errorCount += testInternalPut (); errorCount += testMultithreadedPut (); errorCount += testMultithreadedPoolPut (); } errorCount += testExternalPut (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_digestauth_concurrent.c0000644000175000017500000005356214555767064020336 /* This file is part of libmicrohttpd Copyright (C) 2010 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_digestauth_concurrent.c * @brief Testcase for libmicrohttpd concurrent Digest Authorisation * @author Amr Ali * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "platform.h" #include #include #include #include #include #if defined(MHD_HTTPS_REQUIRE_GCRYPT) && \ (defined(MHD_SHA256_TLSLIB) || defined(MHD_MD5_TLSLIB)) #define NEED_GCRYP_INIT 1 #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT && (MHD_SHA256_TLSLIB || MHD_MD5_TLSLIB) */ #include #ifndef WINDOWS #include #include #else #include #endif #include #include "mhd_has_param.h" #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __func__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __func__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __func__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define libcurlErrorExit(ignore) \ _libcurlErrorExit_func (NULL, __FUNCTION__, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), \ __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func (NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, NULL, __LINE__) #define libcurlErrorExit(ignore) _libcurlErrorExit_func (NULL, NULL, __LINE__) #define libcurlErrorExitDesc(errDesc) \ _libcurlErrorExit_func (errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func (NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func (errDesc, NULL, __LINE__) #define checkCURLE_OK(libcurlcall) \ _checkCURLE_OK_func ((libcurlcall), _MHD_STRMACRO (libcurlcall), NULL, \ __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } /* Not actually used in this test */ static char libcurl_errbuf[CURL_ERROR_SIZE] = ""; _MHD_NORETURN static void _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "CURL library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (8); } #if 0 /* Function unused in this test */ static void _checkCURLE_OK_func (CURLcode code, const char *curlFunc, const char *funcName, int lineNum) { if (CURLE_OK == code) return; fflush (stdout); if ((NULL != curlFunc) && (0 != curlFunc[0])) fprintf (stderr, "'%s' resulted in '%s'", curlFunc, curl_easy_strerror (code)); else fprintf (stderr, "libcurl function call resulted in '%s'", curl_easy_strerror (code)); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); if (0 != libcurl_errbuf[0]) fprintf (stderr, "Last libcurl error description: %s\n", libcurl_errbuf); fflush (stderr); exit (9); } #endif /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 #define MHD_URI_BASE_PATH "/bar%20foo?key=value" #define PAGE \ "libmicrohttpd demoAccess granted" #define DENIED \ "libmicrohttpd demoAccess denied" #define MY_OPAQUE "11733b200778ce33060f31c9af70a870ba96ddd4" struct CBC { char *buf; size_t pos; size_t size; }; static int verbose; static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->pos + size * nmemb > cbc->size) mhdErrorExitDesc ("Wrong too large data"); /* overflow */ memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb); cbc->pos += size * nmemb; return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; char *username; const char *password = "testpass"; const char *realm = "test@example.com"; enum MHD_Result ret; enum MHD_DigestAuthResult ret_e; static int already_called_marker; (void) cls; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ if (&already_called_marker != *req_cls) { /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; } username = MHD_digest_auth_get_username (connection); if ( (username == NULL) || (0 != strcmp (username, "testuser")) ) { response = MHD_create_response_from_buffer_static (strlen (DENIED), DENIED); if (NULL == response) mhdErrorExitDesc ("MHD_create_response_from_buffer failed"); ret = MHD_queue_auth_fail_response2 (connection, realm, MY_OPAQUE, response, MHD_NO, MHD_DIGEST_ALG_MD5); if (MHD_YES != ret) mhdErrorExitDesc ("MHD_queue_auth_fail_response2 failed"); MHD_destroy_response (response); return ret; } ret_e = MHD_digest_auth_check3 (connection, realm, username, password, 50 * TIMEOUTS_VAL, 0, MHD_DIGEST_AUTH_MULT_QOP_AUTH, MHD_DIGEST_AUTH_MULT_ALGO3_MD5); MHD_free (username); if (ret_e != MHD_DAUTH_OK) { response = MHD_create_response_from_buffer_static (strlen (DENIED), DENIED); if (NULL == response) mhdErrorExitDesc ("MHD_create_response_from_buffer() failed"); ret = MHD_queue_auth_fail_response2 (connection, realm, MY_OPAQUE, response, (MHD_DAUTH_NONCE_STALE == ret_e) ? MHD_YES : MHD_NO, MHD_DIGEST_ALG_MD5); if (MHD_YES != ret) mhdErrorExitDesc ("MHD_queue_auth_fail_response2() failed"); MHD_destroy_response (response); return ret; } response = MHD_create_response_from_buffer_static (strlen (PAGE), PAGE); if (NULL == response) mhdErrorExitDesc ("MHD_create_response_from_buffer() failed"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); if (MHD_YES != ret) mhdErrorExitDesc ("MHD_queue_auth_fail_response2() failed"); MHD_destroy_response (response); return ret; } static CURL * setupCURL (void *cbc, uint16_t port, char *errbuf) { CURL *c; char url[512]; if (1) { int res; /* A workaround for some old libcurl versions, which ignore the specified * port by CURLOPT_PORT when digest authorisation is used. */ res = snprintf (url, (sizeof(url) / sizeof(url[0])), "http://127.0.0.1:%u%s", (unsigned int) port, MHD_URI_BASE_PATH); if ((0 >= res) || ((sizeof(url) / sizeof(url[0])) <= (size_t) res)) externalErrorExitDesc ("Cannot form request URL"); } c = curl_easy_init (); if (NULL == c) libcurlErrorExitDesc ("curl_easy_init() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_ERRORBUFFER, errbuf)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) TIMEOUTS_VAL))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L)) || #ifdef _DEBUG (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) || #endif /* _DEBUG */ #if CURL_AT_LEAST_VERSION (7, 85, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http")) || #elif CURL_AT_LEAST_VERSION (7, 19, 4) (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) || #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ #if CURL_AT_LEAST_VERSION (7, 45, 0) (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http")) || #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ (CURLE_OK != curl_easy_setopt (c, CURLOPT_PORT, ((long) port))) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_URL, url))) libcurlErrorExitDesc ("curl_easy_setopt() failed"); if ((CURLE_OK != curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST)) || (CURLE_OK != curl_easy_setopt (c, CURLOPT_USERPWD, "testuser:testpass"))) libcurlErrorExitDesc ("curl_easy_setopt() authorization options failed"); return c; } static void getRnd (void *buf, size_t size) { #ifndef WINDOWS int fd; size_t off = 0; fd = open ("/dev/urandom", O_RDONLY); if (-1 == fd) externalErrorExitDesc ("Failed to open '/dev/urandom'"); do { ssize_t res; res = read (fd, ((uint8_t *) buf) + off, size - off); if (0 > res) externalErrorExitDesc ("Failed to read '/dev/urandom'"); off += (size_t) res; } while (off < size); (void) close (fd); #else HCRYPTPROV cc; BOOL b; b = CryptAcquireContext (&cc, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT); if (b == 0) externalErrorExitDesc ("CryptAcquireContext() failed"); b = CryptGenRandom (cc, (DWORD) size, (BYTE *) buf); if (b == 0) externalErrorExitDesc ("CryptGenRandom() failed"); CryptReleaseContext (cc, 0); #endif /* ! WINDOWS */ } struct curlWokerInfo { int workerNumber; struct CBC cbc; pthread_t tid; /** * The libcurl handle to run in thread */ CURL *c; char *libcurl_errbuf; /** * Non-zero if worker is finished */ volatile int finished; /** * The number of successful worker results */ volatile unsigned int success; }; static void * worker_func (void *param) { struct curlWokerInfo *const w = (struct curlWokerInfo *) param; CURLcode req_result; if (NULL == w) externalErrorExit (); req_result = curl_easy_perform (w->c); if (CURLE_OK != req_result) { if (0 != w->libcurl_errbuf[0]) fprintf (stderr, "Worker %d: first request failed. " "libcurl error: '%s'.\n" "libcurl error description: '%s'.\n", w->workerNumber, curl_easy_strerror (req_result), w->libcurl_errbuf); else fprintf (stderr, "Worker %d: first request failed. " "libcurl error: '%s'.\n", w->workerNumber, curl_easy_strerror (req_result)); } else { if (w->cbc.pos != strlen (PAGE)) { fprintf (stderr, "Worker %d: Got %u bytes ('%.*s'), expected %u bytes. ", w->workerNumber, (unsigned) w->cbc.pos, (int) w->cbc.pos, w->cbc.buf, (unsigned) strlen (MHD_URI_BASE_PATH)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != strncmp (PAGE, w->cbc.buf, strlen (PAGE))) { fprintf (stderr, "Worker %d: Got invalid response '%.*s'. ", w->workerNumber, (int) w->cbc.pos, w->cbc.buf); mhdErrorExitDesc ("Wrong returned data"); } if (verbose) printf ("Worker %d: first request successful.\n", w->workerNumber); w->success++; } #ifdef _DEBUG fflush (stderr); fflush (stdout); #endif /* _DEBUG */ /* Second request */ w->cbc.pos = 0; req_result = curl_easy_perform (w->c); if (CURLE_OK != req_result) { if (0 != w->libcurl_errbuf[0]) fprintf (stderr, "Worker %d: second request failed. " "libcurl error: '%s'.\n" "libcurl error description: '%s'.\n", w->workerNumber, curl_easy_strerror (req_result), w->libcurl_errbuf); else fprintf (stderr, "Worker %d: second request failed. " "libcurl error: '%s'.\n", w->workerNumber, curl_easy_strerror (req_result)); } else { if (w->cbc.pos != strlen (PAGE)) { fprintf (stderr, "Worker %d: Got %u bytes ('%.*s'), expected %u bytes. ", w->workerNumber, (unsigned) w->cbc.pos, (int) w->cbc.pos, w->cbc.buf, (unsigned) strlen (MHD_URI_BASE_PATH)); mhdErrorExitDesc ("Wrong returned data length"); } if (0 != strncmp (PAGE, w->cbc.buf, strlen (PAGE))) { fprintf (stderr, "Worker %d: Got invalid response '%.*s'. ", w->workerNumber, (int) w->cbc.pos, w->cbc.buf); mhdErrorExitDesc ("Wrong returned data"); } if (verbose) printf ("Worker %d: second request successful.\n", w->workerNumber); w->success++; } #ifdef _DEBUG fflush (stderr); fflush (stdout); #endif /* _DEBUG */ w->finished = ! 0; return NULL; } #define CLIENT_BUF_SIZE 2048 static unsigned int testDigestAuth (void) { struct MHD_Daemon *d; char rnd[8]; uint16_t port; size_t i; /* Run three workers in parallel so at least two workers would start within * the same monotonic clock second.*/ struct curlWokerInfo workers[3]; unsigned int ret; if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 4200; getRnd (rnd, sizeof(rnd)); d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, MHD_OPTION_NONCE_NC_SIZE, 300, MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) (sizeof(workers) / sizeof(workers[0])), MHD_OPTION_DIGEST_AUTH_DEFAULT_MAX_NC, (uint32_t) 999, MHD_OPTION_END); if (d == NULL) return 1; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); port = dinfo->port; } /* Initialise all workers */ for (i = 0; i < sizeof(workers) / sizeof(workers[0]); i++) { struct curlWokerInfo *const w = workers + i; w->workerNumber = (int) i + 1; /* Use 1-based numbering */ w->cbc.buf = malloc (CLIENT_BUF_SIZE); if (NULL == w->cbc.buf) externalErrorExitDesc ("malloc() failed"); w->cbc.size = CLIENT_BUF_SIZE; w->cbc.pos = 0; w->libcurl_errbuf = malloc (CURL_ERROR_SIZE); if (NULL == w->libcurl_errbuf) externalErrorExitDesc ("malloc() failed"); w->libcurl_errbuf[0] = 0; w->c = setupCURL (&w->cbc, port, w->libcurl_errbuf); w->finished = 0; w->success = 0; } /* Fire already initialised workers */ for (i = 0; i < sizeof(workers) / sizeof(workers[0]); i++) { struct curlWokerInfo *const w = workers + i; if (0 != pthread_create (&w->tid, NULL, &worker_func, w)) externalErrorExitDesc ("pthread_create() failed"); } /* Collect results, cleanup workers */ ret = 0; for (i = 0; i < sizeof(workers) / sizeof(workers[0]); i++) { struct curlWokerInfo *const w = workers + i; if (0 != pthread_join (w->tid, NULL)) externalErrorExitDesc ("pthread_join() failed"); curl_easy_cleanup (w->c); free (w->libcurl_errbuf); free (w->cbc.buf); if (! w->finished) externalErrorExitDesc ("The worker thread did't signal 'finished' state"); ret += 2 - w->success; } MHD_stop_daemon (d); return ret; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ #if (LIBCURL_VERSION_MAJOR == 7) && (LIBCURL_VERSION_MINOR == 62) if (1) { fprintf (stderr, "libcurl version 7.62.x has bug in processing " "URI with GET arguments for Digest Auth.\n"); fprintf (stderr, "This test cannot be performed.\n"); exit (77); } #endif /* libcurl version 7.62.x */ verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); #ifdef NEED_GCRYP_INIT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* GCRYCTL_INITIALIZATION_FINISHED */ #endif /* NEED_GCRYP_INIT */ if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; errorCount += testDigestAuth (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testcurl/test_concurrent_stop.c0000644000175000017500000002325014556705750017144 /* This file is part of libmicrohttpd Copyright (C) 2007, 2009, 2011, 2015, 2016 Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_concurrent_stop.c * @brief test stopping server while concurrent GETs are ongoing * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif /** * How many requests do we do in parallel? */ #if SIZEOF_SIZE_T >= 8 || MHD_CPU_COUNT < 8 # define PAR (MHD_CPU_COUNT * 4) #elif MHD_CPU_COUNT < 16 /* Limit load */ # define PAR (MHD_CPU_COUNT * 2) #else /* Limit load */ # define PAR (MHD_CPU_COUNT * 1) #endif /** * Do we use HTTP 1.1? */ static int oneone; /** * Response to return (re-used). */ static struct MHD_Response *response; /** * Continue generating new requests? */ static volatile int continue_requesting; /** * Continue waiting in watchdog thread? */ static volatile int watchdog_continue; static const char *watchdog_obj; /** * Indicate that client detected error */ static volatile CURLcode client_error; static void * thread_watchdog (void *param) { int seconds_passed; const int timeout_val = (int) (intptr_t) param; seconds_passed = 0; while (watchdog_continue) /* Poor threads sync, but works for testing. */ { if (0 == sleep (1)) /* Poor accuracy, but enough for testing. */ seconds_passed++; if (timeout_val < seconds_passed) { fprintf (stderr, "%s timeout expired.\n", watchdog_obj ? watchdog_obj : "Watchdog"); fflush (stderr); _exit (16); } } return NULL; } static pthread_t watchdog_tid; static void start_watchdog (int timeout, const char *obj_name) { watchdog_continue = 1; watchdog_obj = obj_name; if (0 != pthread_create (&watchdog_tid, NULL, &thread_watchdog, (void *) (intptr_t) timeout)) { fprintf (stderr, "Failed to start watchdog.\n"); _exit (99); } } static void stop_watchdog (void) { watchdog_continue = 0; if (0 != pthread_join (watchdog_tid, NULL)) { fprintf (stderr, "Failed to stop watchdog.\n"); _exit (99); } } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { (void) ptr; (void) ctx; /* Unused. Silent compiler warning. */ return size * nmemb; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker; enum MHD_Result ret; (void) cls; (void) url; (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (MHD_HTTP_METHOD_GET, method)) return MHD_NO; /* unexpected method */ if (&marker != *req_cls) { *req_cls = ▮ return MHD_YES; } *req_cls = NULL; ret = MHD_queue_response (connection, MHD_HTTP_OK, response); if (ret == MHD_NO) abort (); return ret; } static void * thread_gets (void *param) { CURL *c; CURLcode errornum; char *const url = (char *) param; c = NULL; c = curl_easy_init (); if (NULL == c) { fprintf (stderr, "curl_easy_init failed.\n"); _exit (99); } curl_easy_setopt (c, CURLOPT_URL, url); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, NULL); curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); curl_easy_setopt (c, CURLOPT_TIMEOUT, 2L); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 2L); /* NOTE: use of CONNECTTIMEOUT without also setting NOSIGNAL results in really weird crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); while (continue_requesting) { errornum = curl_easy_perform (c); if (CURLE_OK != errornum) { curl_easy_cleanup (c); client_error = errornum; return NULL; } } curl_easy_cleanup (c); return NULL; } static void * do_gets (void *param) { int j; pthread_t par[PAR]; char url[64]; uint16_t port = (uint16_t) (intptr_t) param; snprintf (url, sizeof (url), "http://127.0.0.1:%u/hello_world", (unsigned int) port); for (j = 0; j < PAR; j++) { if (0 != pthread_create (&par[j], NULL, &thread_gets, (void *) url)) { fprintf (stderr, "pthread_create failed.\n"); continue_requesting = 0; for (j--; j >= 0; j--) { pthread_join (par[j], NULL); } _exit (99); } } (void) sleep (1); for (j = 0; j < PAR; j++) { pthread_join (par[j], NULL); } return NULL; } static pthread_t start_gets (uint16_t port) { pthread_t tid; continue_requesting = 1; if (0 != pthread_create (&tid, NULL, &do_gets, (void *) (intptr_t) port)) { fprintf (stderr, "pthread_create failed.\n"); _exit (99); } return tid; } static unsigned int testMultithreadedGet (uint16_t port, uint32_t poll_flag) { struct MHD_Daemon *d; pthread_t p; unsigned int result; result = 0; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } client_error = CURLE_OK; /* clear client error state */ p = start_gets (port); (void) sleep (1); start_watchdog (10, "daemon_stop() in testMultithreadedGet"); if (CURLE_OK != client_error) /* poor sync, but enough for test */ { result = 64; fprintf (stderr, "libcurl reported at least one error: \"%s\"\n", curl_easy_strerror (client_error)); } MHD_stop_daemon (d); stop_watchdog (); continue_requesting = 0; pthread_join (p, NULL); return result; } static unsigned int testMultithreadedPoolGet (uint16_t port, uint32_t poll_flag) { struct MHD_Daemon *d; pthread_t p; unsigned int result; result = 0; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | (enum MHD_FLAG) poll_flag, port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 16; if (0 == port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } port = dinfo->port; } client_error = CURLE_OK; /* clear client error state */ p = start_gets (port); (void) sleep (1); start_watchdog (10, "daemon_stop() in testMultithreadedPoolGet"); if (CURLE_OK != client_error) /* poor sync, but enough for test */ { result = 64; fprintf (stderr, "libcurl reported at least one error: \"%s\"\n", curl_easy_strerror (client_error)); } MHD_stop_daemon (d); stop_watchdog (); continue_requesting = 0; pthread_join (p, NULL); return result; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; uint16_t port; (void) argc; /* Unused. Silent compiler warning. */ (void) argv; /* Unused. Silent compiler warning. */ if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; else port = 1142; /* Do reuse connection, otherwise all available local ports may exhausted. */ oneone = 1; if ((0 != port) && oneone) port += 5; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; response = MHD_create_response_from_buffer_copy (strlen ("/hello_world"), "/hello_world"); errorCount += testMultithreadedGet (port, 0); if (0 != port) port++; errorCount += testMultithreadedPoolGet (port, 0); MHD_destroy_response (response); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testzzuf/0000755000175000017500000000000014566140216012610 5libmicrohttpd-1.0.1/src/testzzuf/mhd_debug_funcs.h0000644000175000017500000000327214445225054016021 /* This file is part of GNU libmicrohttpd Copyright (C) 2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GNU libmicrohttpd. If not, see . */ /** * @file testzzuf/mhd_debug_funcs.h * @brief Declarations of MHD private debug functions * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_DEBUG_FUNCS_H #define MHD_DEBUG_FUNCS_H 1 struct MHD_Daemon; /** * Checks whether MHD can use accept() syscall and * avoid accept4() syscall. * @return non-zero if accept() is possible, * zero if accept4() is always used by MHD */ int MHD_is_avoid_accept4_possible_ (void); /** * Switch MHD daemon to use accept() syscalls for new connections. * @param daemon the daemon to operate */ void MHD_avoid_accept4_ (struct MHD_Daemon *daemon); /** * Checks whether any know sanitizer is enabled for this build. * zzuf does not work together with sanitizers as both are intercepting * standard library calls. * @return non-zero if any sanitizer is enabled, * zero otherwise */ int MHD_are_sanitizers_enabled_ (void); #endif /* MHD_DEBUG_FUNCS_H */ libmicrohttpd-1.0.1/src/testzzuf/Makefile.am0000644000175000017500000000720314566122702014566 # This Makefile.am is in the public domain SUBDIRS = . # ZZUF_SEED can be redefined to use other initial seeds # for extended testing. E.g., # make ZZUF_SEED=1234 check ZZUF_SEED = 0 # Additional flags for zzuf ZZUF_FLAGS = # Additional flags for socat (if socat is used) SOCAT_FLAGS = if FORCE_USE_ZZUF_SOCAT TEST_RUNNER_SCRIPT = zzuf_socat_test_runner.sh else TEST_RUNNER_SCRIPT = zzuf_test_runner.sh endif AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/microhttpd \ -DMHD_CPU_COUNT=$(CPU_COUNT) \ $(CPPFLAGS_ac) $(LIBCURL_CPPFLAGS) AM_CFLAGS = $(CFLAGS_ac) AM_LDFLAGS = $(LDFLAGS_ac) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) \ ZZUF="$(ZZUF)" ; export ZZUF ; \ ZZUF_SEED="$(ZZUF_SEED)" ; export ZZUF_SEED ; \ ZZUF_FLAGS="$(ZZUF_FLAGS)" ; export ZZUF_FLAGS ; \ SOCAT="$(SOCAT)" ; export SOCAT ; \ SOCAT_FLAGS="$(SOCAT_FLAGS)" ; export SOCAT_FLAGS ; if USE_COVERAGE AM_CFLAGS += -fprofile-arcs -ftest-coverage endif LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ @LIBCURL@ $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la check_PROGRAMS = \ test_get \ test_get_chunked \ test_post \ test_post_form \ test_put \ test_put_chunked \ test_put_large \ test_get_long_uri \ test_get_long_header \ test_get_close \ test_get_chunked_close \ test_post_close \ test_post_form_close \ test_put_close \ test_put_chunked_close \ test_put_large_close \ test_get_long_uri_close \ test_get_long_header_close \ test_get10 \ test_get_chunked10 \ test_post10 \ test_post_form10 \ test_put10 \ test_put_large10 \ test_get_long_uri10 \ test_get_long_header10 .NOTPARALLEL: TESTS = $(check_PROGRAMS) dist_check_SCRIPTS = zzuf_test_runner.sh zzuf_socat_test_runner.sh LOG_COMPILER = @SHELL@ "$(srcdir)/$(TEST_RUNNER_SCRIPT)" if VHEAVY_TESTS check_SCRIPTS = warn_vheavy_use .PHONY: warn_vheavy_use endif warn_vheavy_use: @echo "NOTICE" ; \ echo "NOTICE: Full heavy tests are enabled. Each test may take up to several minutes to complete." ; \ echo "NOTICE" tests_common_sources = mhd_debug_funcs.h mhd_debug_funcs.c test_get_SOURCES = \ test_get.c $(tests_common_sources) test_get_chunked_SOURCES = $(test_get_SOURCES) test_post_SOURCES = $(test_get_SOURCES) test_post_form_SOURCES = $(test_get_SOURCES) test_put_SOURCES = $(test_get_SOURCES) test_put_chunked_SOURCES = $(test_get_SOURCES) test_put_large_SOURCES = $(test_get_SOURCES) test_get_long_uri_SOURCES = $(test_get_SOURCES) test_get_long_header_SOURCES = $(test_get_SOURCES) test_get_close_SOURCES = $(test_get_SOURCES) test_get_chunked_close_SOURCES = $(test_get_chunked_SOURCES) test_post_close_SOURCES = $(test_post_SOURCES) test_post_form_close_SOURCES = $(test_post_form_SOURCES) test_put_close_SOURCES = $(test_put_SOURCES) test_put_chunked_close_SOURCES = $(test_put_chunked_SOURCES) test_put_large_close_SOURCES = $(test_put_large_SOURCES) test_get_long_uri_close_SOURCES = $(test_get_long_uri_SOURCES) test_get_long_header_close_SOURCES = $(test_get_long_header_SOURCES) test_get10_SOURCES = $(test_get_SOURCES) test_get_chunked10_SOURCES = $(test_get_chunked_SOURCES) test_post10_SOURCES = $(test_post_SOURCES) test_post_form10_SOURCES = $(test_post_form_SOURCES) test_put10_SOURCES = $(test_put_SOURCES) test_put_large10_SOURCES = $(test_put_large_SOURCES) test_get_long_uri10_SOURCES = $(test_get_long_uri_SOURCES) test_get_long_header10_SOURCES = $(test_get_long_header_SOURCES) libmicrohttpd-1.0.1/src/testzzuf/README0000644000175000017500000000112414417460232013404 Testcases in this directory require zzuf and socat. zzuf is used to randomly mess with the TCP connection between the CURL clients and the MHD server. The goal is to expose problems in MHD's error handling (by introducing random syntax errors). socat is used to listen on port 11081 and forward the randomzied stream to port 11080 where MHD is waiting. As a result, the testcases in this directory do NOT check that whatever CURL returns is what was expected -- random modifications to the TCP stream can have random effects ;-). Testcases "fail" if the code crashes or hangs indefinitely. libmicrohttpd-1.0.1/src/testzzuf/mhd_debug_funcs.c0000644000175000017500000000551214445225054016013 /* This file is part of GNU libmicrohttpd Copyright (C) 2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GNU libmicrohttpd. If not, see . */ /** * @file testzzuf/mhd_debug_funcs.c * @brief Implementations of MHD private debug functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_debug_funcs.h" #include "internal.h" #include "mhd_sockets.h" /** * Checks whether MHD can use accept() syscall and * avoid accept4() syscall. * @return non-zero if accept() is possible, * zero if accept4() is always used by MHD */ int MHD_is_avoid_accept4_possible_ (void) { #if ! defined(USE_ACCEPT4) return ! 0; #else /* ! USE_ACCEPT4 */ return (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_DEBUG_BUILD)) ? ! 0 : 0; #endif /* ! USE_ACCEPT4 */ } /** * Switch MHD daemon to use accept() syscalls for new connections. * @param daemon the daemon to operate */ void MHD_avoid_accept4_ (struct MHD_Daemon *daemon) { (void) daemon; /* Mute compiler warning */ #ifdef USE_ACCEPT4 #ifdef _DEBUG daemon->avoid_accept4 = true; #else /* ! _DEBUG */ abort (); #endif /* ! _DEBUG */ #endif /* USE_ACCEPT4 */ } #ifdef MHD_ASAN_ACTIVE #define MHD_ASAN_ENABLED_ 1 #else /* ! MHD_ASAN_ACTIVE */ #ifdef __SANITIZE_ADDRESS__ #define MHD_ASAN_ENABLED_ 1 #else /* ! __SANITIZE_ADDRESS__ */ #if defined(__has_feature) #if __has_feature(address_sanitizer) #define MHD_ASAN_ENABLED_ 1 #endif /* __has_feature(address_sanitizer) */ #endif /* __has_feature */ #endif /* ! __SANITIZE_ADDRESS__ */ #endif /* ! MHD_ASAN_ACTIVE */ /** * Checks whether any know sanitizer is enabled for this build. * zzuf does not work together with sanitizers as both are intercepting * standard library calls. * @return non-zero if any sanitizer is enabled, * zero otherwise */ int MHD_are_sanitizers_enabled_ (void) { int ret = 0; #ifdef MHD_ASAN_ENABLED_ ++ret; #endif /* ! MHD_ASAN_ENABLED_ */ #if defined(__has_feature) #if __has_feature(thread_sanitizer) ++ret; #endif #if __has_feature(memory_sanitizer) ++ret; #endif #if __has_feature(dataflow_sanitizer) ++ret; #endif #else /* ! defined(__has_feature) */ #ifdef __SANITIZE_THREAD__ ++ret; #endif #endif /* ! defined(__has_feature) */ return ret; } libmicrohttpd-1.0.1/src/testzzuf/test_get.c0000644000175000017500000014351714556026062014526 /* This file is part of libmicrohttpd Copyright (C) 2007, 2008 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file testzzuf/test_get.c * @brief Several testcases for libmicrohttpd with input fuzzing * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #include #include #include #include #include #ifndef WINDOWS #include #endif #include "mhd_debug_funcs.h" #include "test_helpers.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef CURL_VERSION_BITS #define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z)) #endif /* ! CURL_VERSION_BITS */ #ifndef CURL_AT_LEAST_VERSION #define CURL_AT_LEAST_VERSION(x,y,z) \ (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z)) #endif /* ! CURL_AT_LEAST_VERSION */ /** * A larger loop count will run more random tests -- * which would be good, except that it may take too * long for most user's patience. So this small * value is the default. * Can be redefined by CPPFLAGS=-DLOOP_COUNT=123 */ #ifndef LOOP_COUNT #ifndef _MHD_VHEAVY_TESTS #define LOOP_COUNT 10 #else /* ! _MHD_HEAVY_TESTS */ #define LOOP_COUNT 200 #endif /* ! _MHD_HEAVY_TESTS */ #endif /* LOOP_COUNT */ #ifdef _DEBUG /* Uncomment the next line (or use CPPFLAGS) to see all request and response bodies in log */ /* #define TEST_PRINT_BODY */ /* Uncomment the next line (or use CPPFLAGS) to see all request bodies as they are sent by libcurl */ /* #define TEST_PRINT_BODY_RQ 1 */ /* Uncomment the next line (or use CPPFLAGS) to see all request bodies as they are received by libcurl */ /* #define TEST_PRINT_BODY_RP 1 */ #endif /* _DEBUG */ #define MHD_TIMEOUT 2 #define CURL_TIMEOUT 5 /* Global test parameters */ static int oneone; static int dry_run; static int use_get; static int use_get_chunked; static int use_put; static int use_put_large; static int use_put_chunked; static int use_post; static int use_post_form; static int use_long_header; static int use_long_uri; static int use_close; static int run_with_socat; #define TEST_BASE_URI "http:/" "/127.0.0.1/test_uri" #define TEST_BASE_URI_SOCAT "http:/" "/127.0.0.121/test_uri" #define SOCAT_PORT 10121 #define TEST_BASE_PORT 4010 #define EMPTY_PAGE "Empty page." #define EMPTY_PAGE_ALT "Alternative empty page." #define METHOD_NOT_SUPPORTED "HTTP method is not supported." #define POST_DATA_BROKEN "The POST request is ill-formed." #define POST_KEY1 "test" #define POST_VALUE1 "test_post" #define POST_KEY2 "library" #define POST_VALUE2 "GNU libmicrohttpd" #define POST_URLENC_DATA \ POST_KEY1 "=" POST_VALUE1 "&" POST_KEY2 "=" "GNU%20libmicrohttpd" #define PUT_NORMAL_SIZE 11 /* Does not need to be very large as MHD buffer will be made smaller anyway */ #define PUT_LARGE_SIZE (4 * 1024) /* The length of "very long" URI and header strings. MHD uses smaller buffer. */ #define TEST_STRING_VLONG_LEN 8 * 1024 #if ! CURL_AT_LEAST_VERSION (7,56,0) #define TEST_USE_STATIC_POST_DATA 1 static struct curl_httppost *post_first; static struct curl_httppost *post_last; #endif /* ! CURL_AT_LEAST_VERSION(7,56,0) */ static struct curl_slist *libcurl_long_header; /** * Initialise long header for libcurl * * @return non-zero if succeed, * zero if failed */ static int long_header_init (void) { char *buf; buf = malloc (TEST_STRING_VLONG_LEN + 1); if (NULL == buf) { fprintf (stderr, "malloc() failed " "at line %d.\n", (int) __LINE__); return 0; } buf[TEST_STRING_VLONG_LEN] = 0; buf[0] = 'A'; memset (buf + 1, 'a', TEST_STRING_VLONG_LEN / 2 - 2); buf[TEST_STRING_VLONG_LEN / 2 - 1] = ':'; buf[TEST_STRING_VLONG_LEN / 2] = ' '; memset (buf + TEST_STRING_VLONG_LEN / 2 + 1, 'c', TEST_STRING_VLONG_LEN / 2 - 1); libcurl_long_header = curl_slist_append (NULL, buf); free (buf); if (NULL != libcurl_long_header) return ! 0; /* Success exit point */ fprintf (stderr, "curl_slist_append() failed " "at line %d.\n", (int) __LINE__); return 0; /* Failure exit point */ } /** * Globally initialise test environment * @return non-zero if succeed, * zero if failed */ static int test_global_init (void) { libcurl_long_header = NULL; if (CURLE_OK != curl_global_init (CURL_GLOBAL_WIN32)) { fprintf (stderr, "curl_global_init() failed " "at line %d.\n", (int) __LINE__); return 0; } if (long_header_init ()) { #ifndef TEST_USE_STATIC_POST_DATA return 1; /* Success exit point */ #else /* ! TEST_USE_STATIC_POST_DATA */ post_first = NULL; post_last = NULL; if ((CURL_FORMADD_OK != curl_formadd (&post_first, &post_last, CURLFORM_PTRNAME, POST_KEY1, CURLFORM_NAMELENGTH, (long) MHD_STATICSTR_LEN_ (POST_KEY1), CURLFORM_PTRCONTENTS, POST_VALUE1, #if CURL_AT_LEAST_VERSION (7,46,0) CURLFORM_CONTENTLEN, (curl_off_t) MHD_STATICSTR_LEN_ (POST_VALUE1), #else /* ! CURL_AT_LEAST_VERSION(7,46,0) */ CURLFORM_CONTENTSLENGTH, (long) MHD_STATICSTR_LEN_ (POST_VALUE1), #endif /* ! CURL_AT_LEAST_VERSION(7,46,0) */ CURLFORM_END)) || (CURL_FORMADD_OK != curl_formadd (&post_first, &post_last, CURLFORM_PTRNAME, POST_KEY2, CURLFORM_NAMELENGTH, (long) MHD_STATICSTR_LEN_ (POST_KEY2), CURLFORM_PTRCONTENTS, POST_VALUE2, #if CURL_AT_LEAST_VERSION (7,46,0) CURLFORM_CONTENTLEN, (curl_off_t) MHD_STATICSTR_LEN_ (POST_VALUE2), #else /* ! CURL_AT_LEAST_VERSION(7,46,0) */ CURLFORM_CONTENTSLENGTH, (long) MHD_STATICSTR_LEN_ (POST_VALUE2), #endif /* ! CURL_AT_LEAST_VERSION(7,46,0) */ CURLFORM_END))) fprintf (stderr, "curl_formadd() failed " "at line %d.\n", (int) __LINE__); else return 1; /* Success exit point */ if (NULL != post_first) curl_formfree (post_first); curl_slist_free_all (libcurl_long_header); #endif /* ! CURL_AT_LEAST_VERSION(7,56,0) */ } curl_global_cleanup (); return 0; /* Failure exit point */ } /** * Globally de-initialise test environment */ static void test_global_deinit (void) { #ifdef TEST_USE_STATIC_POST_DATA curl_formfree (post_first); #endif /* TEST_USE_STATIC_POST_DATA */ curl_global_cleanup (); if (NULL != libcurl_long_header) curl_slist_free_all (libcurl_long_header); } /** * libcurl callback parameters for uploads, downloads and debug callbacks */ struct CBC { /* Upload members */ size_t up_pos; size_t up_size; /* Download members */ char *dn_buf; size_t dn_pos; size_t dn_buf_size; /* Debug callback members */ unsigned int excess_found; }; static void initCBC (struct CBC *libcurlcbc, char *dn_buf, size_t dn_buf_size) { libcurlcbc->up_pos = 0; if (use_put_large) libcurlcbc->up_size = PUT_LARGE_SIZE; else if (use_put) libcurlcbc->up_size = PUT_NORMAL_SIZE; else libcurlcbc->up_size = 0; libcurlcbc->dn_buf = dn_buf; libcurlcbc->dn_pos = 0; libcurlcbc->dn_buf_size = dn_buf_size; libcurlcbc->excess_found = 0; } static void resetCBC (struct CBC *libcurlcbc) { libcurlcbc->up_pos = 0; libcurlcbc->dn_pos = 0; } static size_t putBuffer (void *stream, size_t item_size, size_t nitems, void *ctx) { size_t to_fill; size_t i; struct CBC *cbc = ctx; to_fill = cbc->up_size - cbc->up_pos; /* Skip overflow check as the return value is valid anyway */ if (use_put_chunked) { /* Send data as several chunks */ if (to_fill > cbc->up_size / 3) to_fill = cbc->up_size / 3; } if (to_fill > item_size * nitems) to_fill = item_size * nitems; /* Avoid libcurl magic numbers */ #ifdef CURL_READFUNC_PAUSE if (CURL_READFUNC_ABORT == to_fill) to_fill -= 2; #endif /* CURL_READFUNC_PAUSE */ #ifdef CURL_READFUNC_ABORT if (CURL_READFUNC_ABORT == to_fill) --to_fill; #endif /* CURL_READFUNC_ABORT */ for (i = 0; i < to_fill; ++i) ((char *) stream)[i] = 'a' + (char) ((cbc->up_pos + i) % (unsigned char) ('z' - 'a' + 1)); cbc->up_pos += to_fill; return to_fill; } static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { struct CBC *cbc = ctx; if (cbc->dn_pos + size * nmemb > cbc->dn_buf_size) return 0; /* overflow */ memcpy (&cbc->dn_buf[cbc->dn_pos], ptr, size * nmemb); cbc->dn_pos += size * nmemb; return size * nmemb; } #define TEST_MAGIC_MARKER0 0xFEE1C0DE #define TEST_MAGIC_MARKER1 (TEST_MAGIC_MARKER0 + 1) #define TEST_MAGIC_MARKER2 (TEST_MAGIC_MARKER0 + 2) struct content_cb_param_strct { unsigned int magic0; /**< Must have TEST_MAGIC_MARKER0 value */ struct MHD_Response *response; /**< The pointer to the response structure */ }; /** * MHD content reader callback that returns * data in chunks. */ static ssize_t content_cb (void *cls, uint64_t pos, char *buf, size_t max) { struct content_cb_param_strct *param = (struct content_cb_param_strct *) cls; size_t fill_size; if ((unsigned int) TEST_MAGIC_MARKER0 != param->magic0) { fprintf (stderr, "Wrong cls pointer " "at line %d.\n", (int) __LINE__); fflush (stderr); abort (); } if (pos >= 128 * 10) { if (MHD_YES != MHD_add_response_footer (param->response, "Footer", "working")) { fprintf (stderr, "MHD_add_response_footer() failed " "at line %d.\n", (int) __LINE__); fflush (stderr); abort (); } return MHD_CONTENT_READER_END_OF_STREAM; } if (128 > max) fill_size = 128; else fill_size = max; memset (buf, 'A' + (char) (unsigned int) (pos / 128), fill_size); return (ssize_t) fill_size; } /** * Deallocate memory for callback cls. */ static void crcf (void *ptr) { free (ptr); } struct req_process_strct { unsigned int magic2; /**< Must have TEST_MAGIC_MARKER2 value */ int is_static; /**< Non-zero if statically allocated, zero if malloc()'ed */ struct MHD_PostProcessor *postprocsr; unsigned int post_data_sum; }; static enum MHD_Result post_iterator (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *value, uint64_t off, size_t size) { struct req_process_strct *param = (struct req_process_strct *) cls; size_t i; (void) filename; (void) content_type; (void) transfer_encoding; (void) off; /* Unused. Mute compiler warnings. */ if (TEST_MAGIC_MARKER2 != param->magic2) { fprintf (stderr, "The 'param->magic2' has wrong value " "at line %d.\n", (int) __LINE__); abort (); } if (MHD_POSTDATA_KIND != kind) { fprintf (stderr, "The 'kind' parameter has wrong value " "at line %d.\n", (int) __LINE__); abort (); } if (NULL != key) param->post_data_sum += (unsigned int) strlen (key); for (i = 0; size > i; ++i) param->post_data_sum += (unsigned int) (unsigned char) value[i]; return MHD_YES; } static void free_req_pr_data (struct req_process_strct *pr_data) { if (NULL == pr_data) return; if (TEST_MAGIC_MARKER2 != pr_data->magic2) { fprintf (stderr, "The 'pr_data->magic2' has wrong value " "at line %d.\n", (int) __LINE__); abort (); } if (pr_data->is_static) { if (NULL != pr_data->postprocsr) { fprintf (stderr, "The 'pr_data->postprocsr' has wrong value " "at line %d.\n", (int) __LINE__); abort (); } return; } if (NULL != pr_data->postprocsr) MHD_destroy_post_processor (pr_data->postprocsr); pr_data->postprocsr = NULL; free (pr_data); } struct ahc_param_strct { unsigned int magic1; /**< Must have TEST_MAGIC_MARKER1 value */ unsigned int err_flag; /**< Non-zero if any error is encountered */ unsigned int num_replies; /**< The number of replies sent for the current request */ }; static enum MHD_Result send_error_response (struct MHD_Connection *connection, struct ahc_param_strct *param, unsigned int status_code, const char *static_text, const size_t static_text_len) { struct MHD_Response *response; response = MHD_create_response_from_buffer_static (static_text_len, static_text); if (NULL != response) { if (MHD_YES == MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "close")) { if (MHD_YES == MHD_queue_response (connection, status_code, response)) { MHD_destroy_response (response); return MHD_YES; /* Success exit point */ } else fprintf (stderr, "MHD_queue_response() failed " "at line %d.\n", (int) __LINE__); } else fprintf (stderr, "MHD_add_response_header() failed " "at line %d.\n", (int) __LINE__); MHD_destroy_response (response); } else fprintf (stderr, "MHD_create_response_from_callback() failed " "at line %d.\n", (int) __LINE__); param->err_flag = 1; return MHD_NO; /* Failure exit point */ } static enum MHD_Result ahc_check (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static struct req_process_strct static_req_pr_data = { TEST_MAGIC_MARKER2, ! 0, NULL, 0 }; struct req_process_strct *req_pr_data; struct ahc_param_strct *param = (struct ahc_param_strct *) cls; struct MHD_Response *response; enum MHD_Result ret; unsigned char data_sum; int is_post_req; if (NULL == cls) { fprintf (stderr, "The 'cls' parameter is NULL " "at line %d.\n", (int) __LINE__); fflush (stderr); abort (); } if ((unsigned int) TEST_MAGIC_MARKER1 != param->magic1) { fprintf (stderr, "The 'param->magic1' has wrong value " "at line %d.\n", (int) __LINE__); fflush (stderr); abort (); } if (NULL == connection) { fprintf (stderr, "The 'connection' parameter is NULL " "at line %d.\n", (int) __LINE__); param->err_flag = 1; return MHD_NO; /* Should not reply */ } if (1) { /* Simple check for 'connection' parameter validity */ const union MHD_ConnectionInfo *conn_info; conn_info = MHD_get_connection_info (connection, MHD_CONNECTION_INFO_CONNECTION_TIMEOUT); if (NULL == conn_info) { fprintf (stderr, "The 'MHD_get_connection_info' has returned NULL " "at line %d.\n", (int) __LINE__); param->err_flag = 1; } else if (MHD_TIMEOUT != conn_info->connection_timeout) { fprintf (stderr, "The 'MHD_get_connection_info' has returned " "unexpected timeout value " "at line %d.\n", (int) __LINE__); param->err_flag = 1; } } if (NULL == url) { fprintf (stderr, "The 'url' parameter is NULL " "at line %d.\n", (int) __LINE__); param->err_flag = 1; } if (NULL == method) { fprintf (stderr, "The 'method' parameter is NULL " "at line %d.\n", (int) __LINE__); param->err_flag = 1; return MHD_NO; /* Should not reply */ } if (NULL == version) { fprintf (stderr, "The 'version' parameter is NULL " "at line %d.\n", (int) __LINE__); param->err_flag = 1; return MHD_NO; /* Should not reply */ } if (NULL == upload_data_size) { fprintf (stderr, "The 'upload_data_size' parameter is NULL " "at line %d.\n", (int) __LINE__); param->err_flag = 1; return MHD_NO; /* Should not reply */ } if ((0 != *upload_data_size) && (NULL == upload_data)) { fprintf (stderr, "The 'upload_data' parameter is NULL " "while '*upload_data_size' is not zero " "at line %d.\n", (int) __LINE__); param->err_flag = 1; return MHD_NO; /* Should not reply */ } if ((NULL != upload_data) && (0 == *upload_data_size)) { fprintf (stderr, "The 'upload_data' parameter is NOT NULL " "while '*upload_data_size' is zero " "at line %d.\n", (int) __LINE__); param->err_flag = 1; return MHD_NO; /* Should not reply */ } if (0 != param->num_replies) { /* Phantom "second" request due to the fuzzing of the input. Refuse. */ return MHD_NO; } is_post_req = (0 == strcmp (method, MHD_HTTP_METHOD_POST)); if ((0 != strcmp (method, MHD_HTTP_METHOD_GET)) && (0 != strcmp (method, MHD_HTTP_METHOD_HEAD)) && (0 != strcmp (method, MHD_HTTP_METHOD_PUT)) && (! is_post_req)) { /* Unsupported method for this callback */ return send_error_response (connection, param, MHD_HTTP_NOT_IMPLEMENTED, METHOD_NOT_SUPPORTED, MHD_STATICSTR_LEN_ (METHOD_NOT_SUPPORTED)); } if (NULL == *req_cls) { if (! is_post_req) { /* Use static memory */ *req_cls = &static_req_pr_data; } else { /* POST request, use PostProcessor */ req_pr_data = (struct req_process_strct *) malloc (sizeof (struct req_process_strct)); if (NULL == req_pr_data) { fprintf (stderr, "malloc() failed " "at line %d.\n", (int) __LINE__); return MHD_NO; } req_pr_data->magic2 = TEST_MAGIC_MARKER2; req_pr_data->is_static = 0; req_pr_data->post_data_sum = 0; req_pr_data->postprocsr = MHD_create_post_processor (connection, 1024, &post_iterator, req_pr_data); if (NULL == req_pr_data->postprocsr) { free (req_pr_data); if (NULL == upload_data) return send_error_response (connection, param, MHD_HTTP_BAD_REQUEST, POST_DATA_BROKEN, MHD_STATICSTR_LEN_ (POST_DATA_BROKEN)); else return MHD_NO; /* Cannot handle request, broken POST */ } *req_cls = req_pr_data; } if (NULL == upload_data) return MHD_YES; } req_pr_data = (struct req_process_strct *) *req_cls; data_sum = 0; if (NULL != upload_data) { if (is_post_req) { if (MHD_YES != MHD_post_process (req_pr_data->postprocsr, upload_data, *upload_data_size)) { free_req_pr_data (req_pr_data); *req_cls = NULL; /* Processing upload body (context), error reply cannot be queued here */ return MHD_NO; } *upload_data_size = 0; /* All data have been processed */ } else { /* Check that all 'upload_data' is addressable */ size_t pos; for (pos = 0; pos < *upload_data_size; ++pos) data_sum = (unsigned char) (data_sum + (unsigned char) upload_data[pos]); if (0 != *upload_data_size) { if (3 >= *upload_data_size) *upload_data_size = 0; /* Consume all incoming data */ else *upload_data_size = data_sum % *upload_data_size; /* Pseudo-random */ } } return MHD_YES; } if (is_post_req) { if (MHD_YES != MHD_destroy_post_processor (req_pr_data->postprocsr)) { free (req_pr_data); *req_cls = NULL; return send_error_response (connection, param, MHD_HTTP_BAD_REQUEST, POST_DATA_BROKEN, MHD_STATICSTR_LEN_ (POST_DATA_BROKEN)); } req_pr_data->postprocsr = NULL; } data_sum += (unsigned char) req_pr_data->post_data_sum; free_req_pr_data (req_pr_data); *req_cls = NULL; ret = MHD_YES; if (use_get_chunked) { struct content_cb_param_strct *cnt_cb_param; cnt_cb_param = malloc (sizeof (struct content_cb_param_strct)); if (NULL == cnt_cb_param) { fprintf (stderr, "malloc() failed " "at line %d.\n", (int) __LINE__); /* External error, do not rise the error flag */ return MHD_NO; } cnt_cb_param->magic0 = (unsigned int) TEST_MAGIC_MARKER0; response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 1024, &content_cb, cnt_cb_param, &crcf); if (NULL == response) { fprintf (stderr, "MHD_create_response_from_callback() failed " "at line %d.\n", (int) __LINE__); free (cnt_cb_param); param->err_flag = 1; ret = MHD_NO; } else cnt_cb_param->response = response; } else if (use_get || use_put || use_post) { /* Randomly choose the response page for the POST requests */ if (0 == data_sum % 2) response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (EMPTY_PAGE), EMPTY_PAGE); else response = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ ( \ EMPTY_PAGE_ALT), EMPTY_PAGE_ALT); if (NULL == response) { fprintf (stderr, "MHD_create_response_from_buffer_static() failed " "at line %d.\n", (int) __LINE__); param->err_flag = 1; ret = MHD_NO; } } else { fprintf (stderr, "Response is not implemented for this test. " "Internal logic is broken. " "At line %d.\n", (int) __LINE__); abort (); } if (NULL != response) { if ((MHD_YES == ret) && (use_close || (! oneone && (0 != strcmp (version, MHD_HTTP_VERSION_1_0))))) { ret = MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "close"); if (MHD_YES != ret) { fprintf (stderr, "MHD_add_response_header() failed " "at line %d.\n", (int) __LINE__); param->err_flag = 1; } } if (MHD_YES == ret) { ret = MHD_queue_response (connection, MHD_HTTP_OK, response); if (MHD_YES != ret) { fprintf (stderr, "MHD_queue_response() failed " "at line %d.\n", (int) __LINE__); param->err_flag = 1; } } else param->num_replies++; MHD_destroy_response (response); } else { fprintf (stderr, "MHD_create_response_from_buffer_static() failed " "at line %d.\n", (int) __LINE__); ret = MHD_NO; } return ret; } static void req_completed_cleanup (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { struct ahc_param_strct *param = (struct ahc_param_strct *) cls; struct req_process_strct *req_pr_data = (struct req_process_strct *) *req_cls; (void) connection; /* Unused. Mute compiler warning. */ if (NULL == param) { fprintf (stderr, "The 'cls' parameter is NULL at line %d.\n", (int) __LINE__); fflush (stderr); abort (); } if ((unsigned int) TEST_MAGIC_MARKER1 != param->magic1) { fprintf (stderr, "The 'param->magic1' has wrong value at line %d.\n", (int) __LINE__); fflush (stderr); abort (); } if (NULL == req_pr_data) return; /* The data have been freed */ if ((unsigned int) TEST_MAGIC_MARKER2 != req_pr_data->magic2) { fprintf (stderr, "The 'req_pr_data->magic2' has wrong value at line %d.\n", (int) __LINE__); fflush (stderr); abort (); } if (MHD_REQUEST_TERMINATED_COMPLETED_OK == toe) { fprintf (stderr, "The request completed successful, but request cls has" "not been cleared. " "At line %d.\n", (int) __LINE__); param->err_flag = 1; } if (req_pr_data->is_static) return; if (NULL != req_pr_data->postprocsr) MHD_destroy_post_processor (req_pr_data->postprocsr); req_pr_data->postprocsr = NULL; free (req_pr_data); *req_cls = NULL; } /* Un-comment the next line (or use CPPFLAGS) to avoid logging of the traffic with debug builds */ /* #define TEST_NO_PRINT_TRAFFIC 1 */ #ifdef _DEBUG #ifdef TEST_PRINT_BODY #ifndef TEST_PRINT_BODY_RQ #define TEST_PRINT_BODY_RQ 1 #endif /* TEST_PRINT_BODY_RQ */ #ifndef TEST_PRINT_BODY_RP #define TEST_PRINT_BODY_RP 1 #endif /* TEST_PRINT_BODY_RP */ #endif /* TEST_PRINT_BODY */ #endif /* _DEBUG */ static int libcurl_debug_cb (CURL *handle, curl_infotype type, char *data, size_t size, void *ctx) { static const char excess_mark[] = "Excess found"; static const size_t excess_mark_len = MHD_STATICSTR_LEN_ (excess_mark); struct CBC *cbc = ctx; (void) handle; #if defined(_DEBUG) && ! defined(TEST_NO_PRINT_TRAFFIC) switch (type) { case CURLINFO_TEXT: fprintf (stderr, "* %.*s", (int) size, data); break; case CURLINFO_HEADER_IN: fprintf (stderr, "< %.*s", (int) size, data); break; case CURLINFO_HEADER_OUT: fprintf (stderr, "> %.*s", (int) size, data); break; case CURLINFO_DATA_IN: #ifdef TEST_PRINT_BODY_RP fprintf (stderr, "<| %.*s\n", (int) size, data); #endif /* TEST_PRINT_BODY_RP */ break; case CURLINFO_DATA_OUT: #ifdef TEST_PRINT_BODY_RQ fprintf (stderr, ">| %.*s\n", (int) size, data); #endif /* TEST_PRINT_BODY_RQ */ break; case CURLINFO_SSL_DATA_IN: case CURLINFO_SSL_DATA_OUT: case CURLINFO_END: default: break; } #endif /* _DEBUG && ! TEST_NO_PRINT_TRAFFIC */ if (use_close || ! oneone) { /* Check for extra data only if every connection is terminated by MHD after one request, otherwise MHD may react on garbage after request data. */ if (CURLINFO_TEXT == type) { if ((size >= excess_mark_len) && (0 == memcmp (data, excess_mark, excess_mark_len))) { fprintf (stderr, "Extra data has been detected in MHD reply " "at line %d.\n", (int) __LINE__); cbc->excess_found++; } } } return 0; } static CURL * setupCURL (struct CBC *cbc, uint16_t port #ifndef TEST_USE_STATIC_POST_DATA , curl_mime **mime #endif /* ! TEST_USE_STATIC_POST_DATA */ ) { CURL *c; CURLcode e; char *buf; const char *uri_to_use; const char *base_uri; #ifndef TEST_USE_STATIC_POST_DATA *mime = NULL; #endif /* ! TEST_USE_STATIC_POST_DATA */ base_uri = run_with_socat ? TEST_BASE_URI_SOCAT : TEST_BASE_URI; if (! use_long_uri) { uri_to_use = base_uri; buf = NULL; } else { size_t pos; size_t base_uri_len; base_uri_len = strlen (base_uri); buf = malloc (TEST_STRING_VLONG_LEN + 1); if (NULL == buf) { fprintf (stderr, "malloc() failed " "at line %d.\n", (int) __LINE__); return NULL; } memcpy (buf, base_uri, base_uri_len); for (pos = base_uri_len; pos < TEST_STRING_VLONG_LEN; ++pos) { if (0 == pos % 9) buf[pos] = '/'; else buf[pos] = 'a' + (char) (unsigned char) (pos % ((unsigned char) ('z' - 'a' + 1))); } buf[TEST_STRING_VLONG_LEN] = 0; uri_to_use = buf; } if (run_with_socat) port = SOCAT_PORT; c = curl_easy_init (); if (NULL == c) { fprintf (stderr, "curl_easy_init() failed " "at line %d.\n", (int) __LINE__); return NULL; } if ((CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_URL, uri_to_use))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_WRITEDATA, cbc))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, ((long) CURL_TIMEOUT)))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_TIMEOUT, ((long) CURL_TIMEOUT)))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_FAILONERROR, 0L))) && #ifdef _DEBUG (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_VERBOSE, 1L))) && #endif /* _DEBUG */ (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION, &libcurl_debug_cb))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_DEBUGDATA, cbc))) && #if CURL_AT_LEAST_VERSION (7, 45, 0) (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_DEFAULT_PROTOCOL, "http"))) && #endif /* CURL_AT_LEAST_VERSION (7, 45, 0) */ #if CURL_AT_LEAST_VERSION (7, 85, 0) (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_PROTOCOLS_STR, "http"))) && #elif CURL_AT_LEAST_VERSION (7, 19, 4) (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP))) && #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */ (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_HTTP_VERSION, oneone ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0))) && #if CURL_AT_LEAST_VERSION (7, 24, 0) (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_INTERFACE, "host!127.0.0.101"))) && #else /* ! CURL_AT_LEAST_VERSION (7, 24, 0) */ (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_INTERFACE, "127.0.0.101"))) && #endif /* ! CURL_AT_LEAST_VERSION (7, 24, 0) */ (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_PORT, ((long) port)))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_HTTPHEADER, use_long_header ? libcurl_long_header : NULL))) ) { if (NULL != buf) { free (buf); buf = NULL; } if (use_put) { if ((CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_READDATA, cbc))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_UPLOAD, (long) 1))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_INFILESIZE_LARGE, use_put_chunked ? ((curl_off_t) -1) : ((curl_off_t) cbc->up_size))))) { return c; /* Success exit point for 'use_put' */ } else fprintf (stderr, "PUT-related curl_easy_setopt() failed at line %d, " "error: %s\n", (int) __LINE__, curl_easy_strerror (e)); } else if (use_post) { if (! use_post_form) { if ((CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_POST, (long) 1))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_POSTFIELDS, POST_URLENC_DATA))) && (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_POSTFIELDSIZE, MHD_STATICSTR_LEN_ (POST_URLENC_DATA))))) { return c; /* Success exit point for 'use_post' */ } else fprintf (stderr, "POST-related curl_easy_setopt() failed at line %d, " "error: %s\n", (int) __LINE__, curl_easy_strerror (e)); } else { #ifndef TEST_USE_STATIC_POST_DATA *mime = curl_mime_init (c); if (NULL != *mime) { curl_mimepart *part; if ((NULL != (part = curl_mime_addpart (*mime))) && (CURLE_OK == curl_mime_name (part, POST_KEY1)) && (CURLE_OK == curl_mime_data (part, POST_VALUE1, MHD_STATICSTR_LEN_ (POST_VALUE1))) && (NULL != (part = curl_mime_addpart (*mime))) && (CURLE_OK == curl_mime_name (part, POST_KEY2)) && (CURLE_OK == curl_mime_data (part, POST_VALUE2, MHD_STATICSTR_LEN_ (POST_VALUE2)))) { if (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_MIMEPOST, *mime))) return c; /* Success exit point for 'use_post' */ else fprintf (stderr, "curl_easy_setopt(c, CURLOPT_MIMEPOST, mime) " "failed at line %d, error: %s\n", (int) __LINE__, curl_easy_strerror (e)); } else fprintf (stderr, "curl_mime_addpart(), curl_mime_name() or " "curl_mime_data() failed.\n"); } else fprintf (stderr, "curl_mime_init() failed.\n"); #else /* TEST_USE_STATIC_POST_DATA */ if (CURLE_OK == (e = curl_easy_setopt (c, CURLOPT_HTTPPOST, post_first))) { return c; /* Success exit point for 'use_post' */ } else fprintf (stderr, "POST form-related curl_easy_setopt() failed, " "error: %s\n", curl_easy_strerror (e)); #endif /* TEST_USE_STATIC_POST_DATA */ } } else return c; /* Success exit point */ } else fprintf (stderr, "curl_easy_setopt() failed at line %d, " "error: %s\n", (int) __LINE__, curl_easy_strerror (e)); curl_easy_cleanup (c); #ifndef TEST_USE_STATIC_POST_DATA if (NULL != *mime) curl_mime_free (*mime); #endif /* ! TEST_USE_STATIC_POST_DATA */ if (NULL != buf) free (buf); return NULL; /* Failure exit point */ } static struct MHD_Daemon * start_daemon_for_test (unsigned int daemon_flags, uint16_t *pport, struct ahc_param_strct *callback_param) { struct MHD_Daemon *d; struct MHD_OptionItem ops[] = { { MHD_OPTION_END, 0, NULL }, { MHD_OPTION_END, 0, NULL }, { MHD_OPTION_END, 0, NULL } }; size_t num_opt; num_opt = 0; callback_param->magic1 = (unsigned int) TEST_MAGIC_MARKER1; callback_param->err_flag = 0; callback_param->num_replies = 0; if (use_put_large) { ops[num_opt].option = MHD_OPTION_CONNECTION_MEMORY_LIMIT; ops[num_opt].value = (intptr_t) (PUT_LARGE_SIZE / 4); ++num_opt; } else if (use_long_header || use_long_uri) { ops[num_opt].option = MHD_OPTION_CONNECTION_MEMORY_LIMIT; ops[num_opt].value = (intptr_t) (TEST_STRING_VLONG_LEN / 2); ++num_opt; } if (0 == (MHD_USE_INTERNAL_POLLING_THREAD & daemon_flags)) { ops[num_opt].option = MHD_OPTION_APP_FD_SETSIZE; ops[num_opt].value = (intptr_t) (FD_SETSIZE); ++num_opt; } d = MHD_start_daemon (daemon_flags /* | MHD_USE_ERROR_LOG */, *pport, NULL, NULL, &ahc_check, callback_param, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) MHD_TIMEOUT, MHD_OPTION_NOTIFY_COMPLETED, &req_completed_cleanup, callback_param, MHD_OPTION_ARRAY, ops, MHD_OPTION_END); if (NULL == d) { fprintf (stderr, "MHD_start_daemon() failed " "at line %d.\n", (int) __LINE__); return NULL; } /* Do not use accept4() as only accept() is intercepted by zzuf */ if (! run_with_socat) MHD_avoid_accept4_ (d); if (0 == *pport) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) { fprintf (stderr, "MHD_get_daemon_info() failed " "at line %d.\n", (int) __LINE__); MHD_stop_daemon (d); return NULL; } *pport = dinfo->port; } return d; } static void print_test_starting (unsigned int daemon_flags) { fflush (stderr); if (0 != (MHD_USE_INTERNAL_POLLING_THREAD & daemon_flags)) { if (0 != (MHD_USE_THREAD_PER_CONNECTION & daemon_flags)) { if (0 != (MHD_USE_POLL & daemon_flags)) printf ("\nStarting test with internal polling by poll() and " "thread-per-connection.\n"); else printf ("\nStarting test with internal polling by select() and " "thread-per-connection.\n"); } else { if (0 != (MHD_USE_POLL & daemon_flags)) printf ("\nStarting test with internal polling by poll().\n"); else if (0 != (MHD_USE_EPOLL & daemon_flags)) printf ("\nStarting test with internal polling by 'epoll'.\n"); else printf ("\nStarting test with internal polling by select().\n"); } } else { if (0 != (MHD_USE_EPOLL & daemon_flags)) printf ("\nStarting test with%s thread safety with external polling " "and internal 'epoll'.\n", ((0 != (MHD_USE_NO_THREAD_SAFETY & daemon_flags)) ? "out" : "")); else printf ("\nStarting test with%s thread safety with external polling.\n", ((0 != (MHD_USE_NO_THREAD_SAFETY & daemon_flags)) ? "out" : "")); } fflush (stdout); } static unsigned int testInternalPolling (uint16_t *pport, unsigned int daemon_flags) { struct MHD_Daemon *d; CURL *c; char buf[2048]; struct CBC cbc; struct ahc_param_strct callback_param; unsigned int ret; #ifndef TEST_USE_STATIC_POST_DATA curl_mime *mime; #endif /* ! TEST_USE_STATIC_POST_DATA */ if (0 == (MHD_USE_INTERNAL_POLLING_THREAD & daemon_flags)) { fprintf (stderr, "Wrong internal flags, the test is broken. " "At line %d.\n", (int) __LINE__); abort (); /* Wrong flags, error in code */ } print_test_starting (daemon_flags); initCBC (&cbc, buf, sizeof(buf)); d = start_daemon_for_test (daemon_flags, pport, &callback_param); if (d == NULL) return 1; ret = 0; c = setupCURL (&cbc, *pport #ifndef TEST_USE_STATIC_POST_DATA , &mime #endif /* ! TEST_USE_STATIC_POST_DATA */ ); if (NULL != c) { int i; for (i = dry_run ? LOOP_COUNT : 0; i < LOOP_COUNT; i++) { fprintf (stderr, "."); callback_param.num_replies = 0; resetCBC (&cbc); /* Run libcurl without checking the result */ curl_easy_perform (c); fflush (stderr); } curl_easy_cleanup (c); #ifndef TEST_USE_STATIC_POST_DATA if (NULL != mime) curl_mime_free (mime); #endif /* ! TEST_USE_STATIC_POST_DATA */ } else ret = 99; /* Not an MHD error */ if ((0 == ret) && callback_param.err_flag) { fprintf (stderr, "One or more errors have been detected by " "access handler callback function. " "At line %d.\n", (int) __LINE__); ret = 1; } else if ((0 == ret) && cbc.excess_found) { fprintf (stderr, "The extra reply data have been detected one " "or more times. " "At line %d.\n", (int) __LINE__); ret = 1; } fprintf (stderr, "\n"); MHD_stop_daemon (d); fflush (stderr); return ret; } static unsigned int testExternalPolling (uint16_t *pport, unsigned int daemon_flags) { struct MHD_Daemon *d; CURLM *multi; char buf[2048]; struct CBC cbc; struct ahc_param_strct callback_param; unsigned int ret; #ifndef TEST_USE_STATIC_POST_DATA curl_mime *mime; #endif /* ! TEST_USE_STATIC_POST_DATA */ if (0 != (MHD_USE_INTERNAL_POLLING_THREAD & daemon_flags)) { fprintf (stderr, "Wrong internal flags, the test is broken. " "At line %d.\n", (int) __LINE__); abort (); /* Wrong flags, error in code */ } print_test_starting (daemon_flags); initCBC (&cbc, buf, sizeof(buf)); d = start_daemon_for_test (daemon_flags, pport, &callback_param); if (d == NULL) return 1; ret = 0; multi = curl_multi_init (); if (multi == NULL) { fprintf (stderr, "curl_multi_init() failed " "at line %d.\n", (int) __LINE__); ret = 99; /* Not an MHD error */ } else { CURL *c; c = setupCURL (&cbc, *pport #ifndef TEST_USE_STATIC_POST_DATA , &mime #endif /* ! TEST_USE_STATIC_POST_DATA */ ); if (NULL == c) ret = 99; /* Not an MHD error */ else { int i; for (i = dry_run ? LOOP_COUNT : 0; (i < LOOP_COUNT) && (0 == ret); i++) { CURLMcode mret; /* The same 'multi' handle will be used in transfers so connection will be reused. The same 'easy' handle is added (and removed later) to (re-)start the same transfer. */ mret = curl_multi_add_handle (multi, c); if (CURLM_OK != mret) { fprintf (stderr, "curl_multi_add_handle() failed at %d, " "error: %s\n", (int) __LINE__, curl_multi_strerror (mret)); ret = 99; /* Not an MHD error */ } else { time_t start; fprintf (stderr, "."); callback_param.num_replies = 0; resetCBC (&cbc); start = time (NULL); do { fd_set rs; fd_set ws; fd_set es; int maxfd_curl; MHD_socket maxfd_mhd; int maxfd; int running; struct timeval tv; maxfd_curl = 0; maxfd_mhd = MHD_INVALID_SOCKET; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); curl_multi_perform (multi, &running); if (0 == running) { int msgs_left; do { (void) curl_multi_info_read (multi, &msgs_left); } while (0 != msgs_left); break; /* The transfer has been finished */ } mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxfd_curl); if (CURLM_OK != mret) { fprintf (stderr, "curl_multi_fdset() failed at line %d, " "error: %s\n", (int) __LINE__, curl_multi_strerror (mret)); ret = 99; /* Not an MHD error */ break; } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxfd_mhd)) { fprintf (stderr, "MHD_get_fdset() failed " "at line %d.\n", (int) __LINE__); ret = 1; break; } #ifndef MHD_WINSOCK_SOCKETS if ((int) maxfd_mhd > maxfd_curl) maxfd = (int) maxfd_mhd; else #endif /* ! MHD_WINSOCK_SOCKETS */ maxfd = maxfd_curl; tv.tv_sec = 0; tv.tv_usec = 100 * 1000; if (0 == MHD_get_timeout64s (d)) tv.tv_usec = 0; else { long curl_to = -1; curl_multi_timeout (multi, &curl_to); if (0 == curl_to) tv.tv_usec = 0; } if (-1 == select (maxfd + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) fprintf (stderr, "Unexpected select() error " "at line %d.\n", (int) __LINE__); #else /* ! MHD_POSIX_SOCKETS */ if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count)) fprintf (stderr, "Unexpected select() error " "at line %d.\n", (int) __LINE__); Sleep ((unsigned long) tv.tv_usec / 1000); #endif /* ! MHD_POSIX_SOCKETS */ } MHD_run (d); } while (time (NULL) - start <= MHD_TIMEOUT); /* Remove 'easy' handle from 'multi' handle to * restart the transfer or to finish. */ curl_multi_remove_handle (multi, c); } } curl_easy_cleanup (c); } curl_multi_cleanup (multi); #ifndef TEST_USE_STATIC_POST_DATA if (NULL != mime) curl_mime_free (mime); #endif /* ! TEST_USE_STATIC_POST_DATA */ } if ((0 == ret) && callback_param.err_flag) { fprintf (stderr, "One or more errors have been detected by " "access handler callback function. " "At line %d.\n", (int) __LINE__); ret = 1; } else if ((0 == ret) && cbc.excess_found) { fprintf (stderr, "The extra reply data have been detected one " "or more times. " "At line %d.\n", (int) __LINE__); ret = 1; } fprintf (stderr, "\n"); MHD_stop_daemon (d); return 0; } static unsigned int run_all_checks (void) { uint16_t port; unsigned int testRes; unsigned int ret = 0; if (! run_with_socat) { if (MHD_are_sanitizers_enabled_ ()) { fprintf (stderr, "Direct run with zzuf does not work with sanitizers. " "At line %d.\n", (int) __LINE__); return 77; } if (! MHD_is_avoid_accept4_possible_ ()) { fprintf (stderr, "Non-debug build of MHD on this platform use accept4() function. " "Direct run with zzuf is not possible. " "At line %d.\n", (int) __LINE__); return 77; } if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) port = 0; /* Use system automatic assignment */ else { port = TEST_BASE_PORT; /* Use predefined port, may break parallel testing of another MHD build */ if (oneone) port += 100; if (use_long_uri) port += 30; else if (use_long_header) port += 35; else if (use_get_chunked) port += 0; else if (use_get) port += 5; else if (use_post_form) port += 10; else if (use_post) port += 15; else if (use_put_large) port += 20; else if (use_put_chunked) port += 25; } } else port = TEST_BASE_PORT; /* Use predefined port, may break parallel testing of another MHD build */ if (! dry_run && (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS))) { testRes = testInternalPolling (&port, MHD_USE_SELECT_INTERNALLY); if ((77 == testRes) || (99 == testRes)) return testRes; ret += testRes; testRes = testInternalPolling (&port, MHD_USE_SELECT_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION); if ((77 == testRes) || (99 == testRes)) return testRes; ret += testRes; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { testRes = testInternalPolling (&port, MHD_USE_POLL_INTERNALLY); if ((77 == testRes) || (99 == testRes)) return testRes; ret += testRes; testRes = testInternalPolling (&port, MHD_USE_POLL_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION); if ((77 == testRes) || (99 == testRes)) return testRes; ret += testRes; } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { testRes = testInternalPolling (&port, MHD_USE_EPOLL_INTERNALLY); if ((77 == testRes) || (99 == testRes)) return testRes; } testRes = testExternalPolling (&port, MHD_NO_FLAG); } testRes = testExternalPolling (&port, MHD_USE_NO_THREAD_SAFETY); if ((77 == testRes) || (99 == testRes)) return testRes; ret += testRes; return ret; } int main (int argc, char *const *argv) { unsigned int res; int use_magic_exit_codes; oneone = ! has_in_name (argv[0], "10"); use_get = has_in_name (argv[0], "_get"); use_get_chunked = has_in_name (argv[0], "_get_chunked"); use_put = has_in_name (argv[0], "_put"); use_put_large = has_in_name (argv[0], "_put_large"); use_put_chunked = has_in_name (argv[0], "_put_chunked"); use_post = has_in_name (argv[0], "_post"); use_post_form = has_in_name (argv[0], "_post_form"); use_long_header = has_in_name (argv[0], "_long_header"); use_long_uri = has_in_name (argv[0], "_long_uri"); use_close = has_in_name (argv[0], "_close"); run_with_socat = has_param (argc, argv, "--with-socat"); dry_run = has_param (argc, argv, "--dry-run") || has_param (argc, argv, "-n"); if (1 != ((use_get ? 1 : 0) + (use_put ? 1 : 0) + (use_post ? 1 : 0))) { fprintf (stderr, "Wrong test name '%s': no or multiple indications " "for the test type.\n", argv[0] ? argv[0] : "(NULL)"); return 99; } use_magic_exit_codes = run_with_socat || dry_run; /* zzuf cannot bypass exit values. Unless 'dry run' is used, do not return errors for external error conditions (like out-of-memory) as they will be reported as test failures. */ if (! test_global_init ()) return use_magic_exit_codes ? 99 : 0; res = run_all_checks (); test_global_deinit (); if (99 == res) return use_magic_exit_codes ? 99 : 0; if (77 == res) return use_magic_exit_codes ? 77 : 0; return (0 == res) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/testzzuf/Makefile.in0000644000175000017500000017746114566140141014612 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # This Makefile.am is in the public domain VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @USE_COVERAGE_TRUE@am__append_1 = -fprofile-arcs -ftest-coverage check_PROGRAMS = test_get$(EXEEXT) test_get_chunked$(EXEEXT) \ test_post$(EXEEXT) test_post_form$(EXEEXT) test_put$(EXEEXT) \ test_put_chunked$(EXEEXT) test_put_large$(EXEEXT) \ test_get_long_uri$(EXEEXT) test_get_long_header$(EXEEXT) \ test_get_close$(EXEEXT) test_get_chunked_close$(EXEEXT) \ test_post_close$(EXEEXT) test_post_form_close$(EXEEXT) \ test_put_close$(EXEEXT) test_put_chunked_close$(EXEEXT) \ test_put_large_close$(EXEEXT) test_get_long_uri_close$(EXEEXT) \ test_get_long_header_close$(EXEEXT) test_get10$(EXEEXT) \ test_get_chunked10$(EXEEXT) test_post10$(EXEEXT) \ test_post_form10$(EXEEXT) test_put10$(EXEEXT) \ test_put_large10$(EXEEXT) test_get_long_uri10$(EXEEXT) \ test_get_long_header10$(EXEEXT) subdir = src/testzzuf ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(dist_check_SCRIPTS) \ $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__objects_1 = mhd_debug_funcs.$(OBJEXT) am_test_get_OBJECTS = test_get.$(OBJEXT) $(am__objects_1) test_get_OBJECTS = $(am_test_get_OBJECTS) test_get_LDADD = $(LDADD) test_get_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am__objects_2 = test_get.$(OBJEXT) $(am__objects_1) am_test_get10_OBJECTS = $(am__objects_2) test_get10_OBJECTS = $(am_test_get10_OBJECTS) test_get10_LDADD = $(LDADD) test_get10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_OBJECTS = $(am__objects_2) test_get_chunked_OBJECTS = $(am_test_get_chunked_OBJECTS) test_get_chunked_LDADD = $(LDADD) test_get_chunked_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am__objects_3 = $(am__objects_2) am_test_get_chunked10_OBJECTS = $(am__objects_3) test_get_chunked10_OBJECTS = $(am_test_get_chunked10_OBJECTS) test_get_chunked10_LDADD = $(LDADD) test_get_chunked10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_chunked_close_OBJECTS = $(am__objects_3) test_get_chunked_close_OBJECTS = $(am_test_get_chunked_close_OBJECTS) test_get_chunked_close_LDADD = $(LDADD) test_get_chunked_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_close_OBJECTS = $(am__objects_2) test_get_close_OBJECTS = $(am_test_get_close_OBJECTS) test_get_close_LDADD = $(LDADD) test_get_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_long_header_OBJECTS = $(am__objects_2) test_get_long_header_OBJECTS = $(am_test_get_long_header_OBJECTS) test_get_long_header_LDADD = $(LDADD) test_get_long_header_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_long_header10_OBJECTS = $(am__objects_3) test_get_long_header10_OBJECTS = $(am_test_get_long_header10_OBJECTS) test_get_long_header10_LDADD = $(LDADD) test_get_long_header10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_long_header_close_OBJECTS = $(am__objects_3) test_get_long_header_close_OBJECTS = \ $(am_test_get_long_header_close_OBJECTS) test_get_long_header_close_LDADD = $(LDADD) test_get_long_header_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_long_uri_OBJECTS = $(am__objects_2) test_get_long_uri_OBJECTS = $(am_test_get_long_uri_OBJECTS) test_get_long_uri_LDADD = $(LDADD) test_get_long_uri_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_long_uri10_OBJECTS = $(am__objects_3) test_get_long_uri10_OBJECTS = $(am_test_get_long_uri10_OBJECTS) test_get_long_uri10_LDADD = $(LDADD) test_get_long_uri10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_get_long_uri_close_OBJECTS = $(am__objects_3) test_get_long_uri_close_OBJECTS = \ $(am_test_get_long_uri_close_OBJECTS) test_get_long_uri_close_LDADD = $(LDADD) test_get_long_uri_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_post_OBJECTS = $(am__objects_2) test_post_OBJECTS = $(am_test_post_OBJECTS) test_post_LDADD = $(LDADD) test_post_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_post10_OBJECTS = $(am__objects_3) test_post10_OBJECTS = $(am_test_post10_OBJECTS) test_post10_LDADD = $(LDADD) test_post10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_post_close_OBJECTS = $(am__objects_3) test_post_close_OBJECTS = $(am_test_post_close_OBJECTS) test_post_close_LDADD = $(LDADD) test_post_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_post_form_OBJECTS = $(am__objects_2) test_post_form_OBJECTS = $(am_test_post_form_OBJECTS) test_post_form_LDADD = $(LDADD) test_post_form_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_post_form10_OBJECTS = $(am__objects_3) test_post_form10_OBJECTS = $(am_test_post_form10_OBJECTS) test_post_form10_LDADD = $(LDADD) test_post_form10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_post_form_close_OBJECTS = $(am__objects_3) test_post_form_close_OBJECTS = $(am_test_post_form_close_OBJECTS) test_post_form_close_LDADD = $(LDADD) test_post_form_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_OBJECTS = $(am__objects_2) test_put_OBJECTS = $(am_test_put_OBJECTS) test_put_LDADD = $(LDADD) test_put_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put10_OBJECTS = $(am__objects_3) test_put10_OBJECTS = $(am_test_put10_OBJECTS) test_put10_LDADD = $(LDADD) test_put10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_chunked_OBJECTS = $(am__objects_2) test_put_chunked_OBJECTS = $(am_test_put_chunked_OBJECTS) test_put_chunked_LDADD = $(LDADD) test_put_chunked_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_chunked_close_OBJECTS = $(am__objects_3) test_put_chunked_close_OBJECTS = $(am_test_put_chunked_close_OBJECTS) test_put_chunked_close_LDADD = $(LDADD) test_put_chunked_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_close_OBJECTS = $(am__objects_3) test_put_close_OBJECTS = $(am_test_put_close_OBJECTS) test_put_close_LDADD = $(LDADD) test_put_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_large_OBJECTS = $(am__objects_2) test_put_large_OBJECTS = $(am_test_put_large_OBJECTS) test_put_large_LDADD = $(LDADD) test_put_large_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_large10_OBJECTS = $(am__objects_3) test_put_large10_OBJECTS = $(am_test_put_large10_OBJECTS) test_put_large10_LDADD = $(LDADD) test_put_large10_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_test_put_large_close_OBJECTS = $(am__objects_3) test_put_large_close_OBJECTS = $(am_test_put_large_close_OBJECTS) test_put_large_close_LDADD = $(LDADD) test_put_large_close_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/mhd_debug_funcs.Po \ ./$(DEPDIR)/test_get.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(test_get_SOURCES) $(test_get10_SOURCES) \ $(test_get_chunked_SOURCES) $(test_get_chunked10_SOURCES) \ $(test_get_chunked_close_SOURCES) $(test_get_close_SOURCES) \ $(test_get_long_header_SOURCES) \ $(test_get_long_header10_SOURCES) \ $(test_get_long_header_close_SOURCES) \ $(test_get_long_uri_SOURCES) $(test_get_long_uri10_SOURCES) \ $(test_get_long_uri_close_SOURCES) $(test_post_SOURCES) \ $(test_post10_SOURCES) $(test_post_close_SOURCES) \ $(test_post_form_SOURCES) $(test_post_form10_SOURCES) \ $(test_post_form_close_SOURCES) $(test_put_SOURCES) \ $(test_put10_SOURCES) $(test_put_chunked_SOURCES) \ $(test_put_chunked_close_SOURCES) $(test_put_close_SOURCES) \ $(test_put_large_SOURCES) $(test_put_large10_SOURCES) \ $(test_put_large_close_SOURCES) DIST_SOURCES = $(test_get_SOURCES) $(test_get10_SOURCES) \ $(test_get_chunked_SOURCES) $(test_get_chunked10_SOURCES) \ $(test_get_chunked_close_SOURCES) $(test_get_close_SOURCES) \ $(test_get_long_header_SOURCES) \ $(test_get_long_header10_SOURCES) \ $(test_get_long_header_close_SOURCES) \ $(test_get_long_uri_SOURCES) $(test_get_long_uri10_SOURCES) \ $(test_get_long_uri_close_SOURCES) $(test_post_SOURCES) \ $(test_post10_SOURCES) $(test_post_close_SOURCES) \ $(test_post_form_SOURCES) $(test_post_form10_SOURCES) \ $(test_post_form_close_SOURCES) $(test_put_SOURCES) \ $(test_put10_SOURCES) $(test_put_chunked_SOURCES) \ $(test_put_chunked_close_SOURCES) $(test_put_close_SOURCES) \ $(test_put_large_SOURCES) $(test_put_large10_SOURCES) \ $(test_put_large_close_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ check recheck distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' RECHECK_LOGS = $(TEST_LOGS) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in \ $(top_srcdir)/build-aux/depcomp \ $(top_srcdir)/build-aux/test-driver README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = . # ZZUF_SEED can be redefined to use other initial seeds # for extended testing. E.g., # make ZZUF_SEED=1234 check ZZUF_SEED = 0 # Additional flags for zzuf ZZUF_FLAGS = # Additional flags for socat (if socat is used) SOCAT_FLAGS = @FORCE_USE_ZZUF_SOCAT_FALSE@TEST_RUNNER_SCRIPT = zzuf_test_runner.sh @FORCE_USE_ZZUF_SOCAT_TRUE@TEST_RUNNER_SCRIPT = zzuf_socat_test_runner.sh AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/microhttpd \ -DMHD_CPU_COUNT=$(CPU_COUNT) \ $(CPPFLAGS_ac) $(LIBCURL_CPPFLAGS) AM_CFLAGS = $(CFLAGS_ac) $(am__append_1) AM_LDFLAGS = $(LDFLAGS_ac) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) \ ZZUF="$(ZZUF)" ; export ZZUF ; \ ZZUF_SEED="$(ZZUF_SEED)" ; export ZZUF_SEED ; \ ZZUF_FLAGS="$(ZZUF_FLAGS)" ; export ZZUF_FLAGS ; \ SOCAT="$(SOCAT)" ; export SOCAT ; \ SOCAT_FLAGS="$(SOCAT_FLAGS)" ; export SOCAT_FLAGS ; LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ @LIBCURL@ TESTS = $(check_PROGRAMS) dist_check_SCRIPTS = zzuf_test_runner.sh zzuf_socat_test_runner.sh LOG_COMPILER = @SHELL@ "$(srcdir)/$(TEST_RUNNER_SCRIPT)" @VHEAVY_TESTS_TRUE@check_SCRIPTS = warn_vheavy_use tests_common_sources = mhd_debug_funcs.h mhd_debug_funcs.c test_get_SOURCES = \ test_get.c $(tests_common_sources) test_get_chunked_SOURCES = $(test_get_SOURCES) test_post_SOURCES = $(test_get_SOURCES) test_post_form_SOURCES = $(test_get_SOURCES) test_put_SOURCES = $(test_get_SOURCES) test_put_chunked_SOURCES = $(test_get_SOURCES) test_put_large_SOURCES = $(test_get_SOURCES) test_get_long_uri_SOURCES = $(test_get_SOURCES) test_get_long_header_SOURCES = $(test_get_SOURCES) test_get_close_SOURCES = $(test_get_SOURCES) test_get_chunked_close_SOURCES = $(test_get_chunked_SOURCES) test_post_close_SOURCES = $(test_post_SOURCES) test_post_form_close_SOURCES = $(test_post_form_SOURCES) test_put_close_SOURCES = $(test_put_SOURCES) test_put_chunked_close_SOURCES = $(test_put_chunked_SOURCES) test_put_large_close_SOURCES = $(test_put_large_SOURCES) test_get_long_uri_close_SOURCES = $(test_get_long_uri_SOURCES) test_get_long_header_close_SOURCES = $(test_get_long_header_SOURCES) test_get10_SOURCES = $(test_get_SOURCES) test_get_chunked10_SOURCES = $(test_get_chunked_SOURCES) test_post10_SOURCES = $(test_post_SOURCES) test_post_form10_SOURCES = $(test_post_form_SOURCES) test_put10_SOURCES = $(test_put_SOURCES) test_put_large10_SOURCES = $(test_put_large_SOURCES) test_get_long_uri10_SOURCES = $(test_get_long_uri_SOURCES) test_get_long_header10_SOURCES = $(test_get_long_header_SOURCES) all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/testzzuf/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/testzzuf/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list test_get$(EXEEXT): $(test_get_OBJECTS) $(test_get_DEPENDENCIES) $(EXTRA_test_get_DEPENDENCIES) @rm -f test_get$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_OBJECTS) $(test_get_LDADD) $(LIBS) test_get10$(EXEEXT): $(test_get10_OBJECTS) $(test_get10_DEPENDENCIES) $(EXTRA_test_get10_DEPENDENCIES) @rm -f test_get10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get10_OBJECTS) $(test_get10_LDADD) $(LIBS) test_get_chunked$(EXEEXT): $(test_get_chunked_OBJECTS) $(test_get_chunked_DEPENDENCIES) $(EXTRA_test_get_chunked_DEPENDENCIES) @rm -f test_get_chunked$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_OBJECTS) $(test_get_chunked_LDADD) $(LIBS) test_get_chunked10$(EXEEXT): $(test_get_chunked10_OBJECTS) $(test_get_chunked10_DEPENDENCIES) $(EXTRA_test_get_chunked10_DEPENDENCIES) @rm -f test_get_chunked10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked10_OBJECTS) $(test_get_chunked10_LDADD) $(LIBS) test_get_chunked_close$(EXEEXT): $(test_get_chunked_close_OBJECTS) $(test_get_chunked_close_DEPENDENCIES) $(EXTRA_test_get_chunked_close_DEPENDENCIES) @rm -f test_get_chunked_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_chunked_close_OBJECTS) $(test_get_chunked_close_LDADD) $(LIBS) test_get_close$(EXEEXT): $(test_get_close_OBJECTS) $(test_get_close_DEPENDENCIES) $(EXTRA_test_get_close_DEPENDENCIES) @rm -f test_get_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_close_OBJECTS) $(test_get_close_LDADD) $(LIBS) test_get_long_header$(EXEEXT): $(test_get_long_header_OBJECTS) $(test_get_long_header_DEPENDENCIES) $(EXTRA_test_get_long_header_DEPENDENCIES) @rm -f test_get_long_header$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_long_header_OBJECTS) $(test_get_long_header_LDADD) $(LIBS) test_get_long_header10$(EXEEXT): $(test_get_long_header10_OBJECTS) $(test_get_long_header10_DEPENDENCIES) $(EXTRA_test_get_long_header10_DEPENDENCIES) @rm -f test_get_long_header10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_long_header10_OBJECTS) $(test_get_long_header10_LDADD) $(LIBS) test_get_long_header_close$(EXEEXT): $(test_get_long_header_close_OBJECTS) $(test_get_long_header_close_DEPENDENCIES) $(EXTRA_test_get_long_header_close_DEPENDENCIES) @rm -f test_get_long_header_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_long_header_close_OBJECTS) $(test_get_long_header_close_LDADD) $(LIBS) test_get_long_uri$(EXEEXT): $(test_get_long_uri_OBJECTS) $(test_get_long_uri_DEPENDENCIES) $(EXTRA_test_get_long_uri_DEPENDENCIES) @rm -f test_get_long_uri$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_long_uri_OBJECTS) $(test_get_long_uri_LDADD) $(LIBS) test_get_long_uri10$(EXEEXT): $(test_get_long_uri10_OBJECTS) $(test_get_long_uri10_DEPENDENCIES) $(EXTRA_test_get_long_uri10_DEPENDENCIES) @rm -f test_get_long_uri10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_long_uri10_OBJECTS) $(test_get_long_uri10_LDADD) $(LIBS) test_get_long_uri_close$(EXEEXT): $(test_get_long_uri_close_OBJECTS) $(test_get_long_uri_close_DEPENDENCIES) $(EXTRA_test_get_long_uri_close_DEPENDENCIES) @rm -f test_get_long_uri_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_get_long_uri_close_OBJECTS) $(test_get_long_uri_close_LDADD) $(LIBS) test_post$(EXEEXT): $(test_post_OBJECTS) $(test_post_DEPENDENCIES) $(EXTRA_test_post_DEPENDENCIES) @rm -f test_post$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_post_OBJECTS) $(test_post_LDADD) $(LIBS) test_post10$(EXEEXT): $(test_post10_OBJECTS) $(test_post10_DEPENDENCIES) $(EXTRA_test_post10_DEPENDENCIES) @rm -f test_post10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_post10_OBJECTS) $(test_post10_LDADD) $(LIBS) test_post_close$(EXEEXT): $(test_post_close_OBJECTS) $(test_post_close_DEPENDENCIES) $(EXTRA_test_post_close_DEPENDENCIES) @rm -f test_post_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_post_close_OBJECTS) $(test_post_close_LDADD) $(LIBS) test_post_form$(EXEEXT): $(test_post_form_OBJECTS) $(test_post_form_DEPENDENCIES) $(EXTRA_test_post_form_DEPENDENCIES) @rm -f test_post_form$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_post_form_OBJECTS) $(test_post_form_LDADD) $(LIBS) test_post_form10$(EXEEXT): $(test_post_form10_OBJECTS) $(test_post_form10_DEPENDENCIES) $(EXTRA_test_post_form10_DEPENDENCIES) @rm -f test_post_form10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_post_form10_OBJECTS) $(test_post_form10_LDADD) $(LIBS) test_post_form_close$(EXEEXT): $(test_post_form_close_OBJECTS) $(test_post_form_close_DEPENDENCIES) $(EXTRA_test_post_form_close_DEPENDENCIES) @rm -f test_post_form_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_post_form_close_OBJECTS) $(test_post_form_close_LDADD) $(LIBS) test_put$(EXEEXT): $(test_put_OBJECTS) $(test_put_DEPENDENCIES) $(EXTRA_test_put_DEPENDENCIES) @rm -f test_put$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_OBJECTS) $(test_put_LDADD) $(LIBS) test_put10$(EXEEXT): $(test_put10_OBJECTS) $(test_put10_DEPENDENCIES) $(EXTRA_test_put10_DEPENDENCIES) @rm -f test_put10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put10_OBJECTS) $(test_put10_LDADD) $(LIBS) test_put_chunked$(EXEEXT): $(test_put_chunked_OBJECTS) $(test_put_chunked_DEPENDENCIES) $(EXTRA_test_put_chunked_DEPENDENCIES) @rm -f test_put_chunked$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_chunked_OBJECTS) $(test_put_chunked_LDADD) $(LIBS) test_put_chunked_close$(EXEEXT): $(test_put_chunked_close_OBJECTS) $(test_put_chunked_close_DEPENDENCIES) $(EXTRA_test_put_chunked_close_DEPENDENCIES) @rm -f test_put_chunked_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_chunked_close_OBJECTS) $(test_put_chunked_close_LDADD) $(LIBS) test_put_close$(EXEEXT): $(test_put_close_OBJECTS) $(test_put_close_DEPENDENCIES) $(EXTRA_test_put_close_DEPENDENCIES) @rm -f test_put_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_close_OBJECTS) $(test_put_close_LDADD) $(LIBS) test_put_large$(EXEEXT): $(test_put_large_OBJECTS) $(test_put_large_DEPENDENCIES) $(EXTRA_test_put_large_DEPENDENCIES) @rm -f test_put_large$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_large_OBJECTS) $(test_put_large_LDADD) $(LIBS) test_put_large10$(EXEEXT): $(test_put_large10_OBJECTS) $(test_put_large10_DEPENDENCIES) $(EXTRA_test_put_large10_DEPENDENCIES) @rm -f test_put_large10$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_large10_OBJECTS) $(test_put_large10_LDADD) $(LIBS) test_put_large_close$(EXEEXT): $(test_put_large_close_OBJECTS) $(test_put_large_close_DEPENDENCIES) $(EXTRA_test_put_large_close_DEPENDENCIES) @rm -f test_put_large_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_put_large_close_OBJECTS) $(test_put_large_close_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mhd_debug_funcs.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_get.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: $(check_PROGRAMS) $(check_SCRIPTS) $(dist_check_SCRIPTS) @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) $(check_SCRIPTS) $(dist_check_SCRIPTS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? test_get.log: test_get$(EXEEXT) @p='test_get$(EXEEXT)'; \ b='test_get'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked.log: test_get_chunked$(EXEEXT) @p='test_get_chunked$(EXEEXT)'; \ b='test_get_chunked'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_post.log: test_post$(EXEEXT) @p='test_post$(EXEEXT)'; \ b='test_post'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_post_form.log: test_post_form$(EXEEXT) @p='test_post_form$(EXEEXT)'; \ b='test_post_form'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put.log: test_put$(EXEEXT) @p='test_put$(EXEEXT)'; \ b='test_put'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_chunked.log: test_put_chunked$(EXEEXT) @p='test_put_chunked$(EXEEXT)'; \ b='test_put_chunked'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_large.log: test_put_large$(EXEEXT) @p='test_put_large$(EXEEXT)'; \ b='test_put_large'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_long_uri.log: test_get_long_uri$(EXEEXT) @p='test_get_long_uri$(EXEEXT)'; \ b='test_get_long_uri'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_long_header.log: test_get_long_header$(EXEEXT) @p='test_get_long_header$(EXEEXT)'; \ b='test_get_long_header'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_close.log: test_get_close$(EXEEXT) @p='test_get_close$(EXEEXT)'; \ b='test_get_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked_close.log: test_get_chunked_close$(EXEEXT) @p='test_get_chunked_close$(EXEEXT)'; \ b='test_get_chunked_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_post_close.log: test_post_close$(EXEEXT) @p='test_post_close$(EXEEXT)'; \ b='test_post_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_post_form_close.log: test_post_form_close$(EXEEXT) @p='test_post_form_close$(EXEEXT)'; \ b='test_post_form_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_close.log: test_put_close$(EXEEXT) @p='test_put_close$(EXEEXT)'; \ b='test_put_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_chunked_close.log: test_put_chunked_close$(EXEEXT) @p='test_put_chunked_close$(EXEEXT)'; \ b='test_put_chunked_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_large_close.log: test_put_large_close$(EXEEXT) @p='test_put_large_close$(EXEEXT)'; \ b='test_put_large_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_long_uri_close.log: test_get_long_uri_close$(EXEEXT) @p='test_get_long_uri_close$(EXEEXT)'; \ b='test_get_long_uri_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_long_header_close.log: test_get_long_header_close$(EXEEXT) @p='test_get_long_header_close$(EXEEXT)'; \ b='test_get_long_header_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get10.log: test_get10$(EXEEXT) @p='test_get10$(EXEEXT)'; \ b='test_get10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_chunked10.log: test_get_chunked10$(EXEEXT) @p='test_get_chunked10$(EXEEXT)'; \ b='test_get_chunked10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_post10.log: test_post10$(EXEEXT) @p='test_post10$(EXEEXT)'; \ b='test_post10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_post_form10.log: test_post_form10$(EXEEXT) @p='test_post_form10$(EXEEXT)'; \ b='test_post_form10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put10.log: test_put10$(EXEEXT) @p='test_put10$(EXEEXT)'; \ b='test_put10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_put_large10.log: test_put_large10$(EXEEXT) @p='test_put_large10$(EXEEXT)'; \ b='test_put_large10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_long_uri10.log: test_get_long_uri10$(EXEEXT) @p='test_get_long_uri10$(EXEEXT)'; \ b='test_get_long_uri10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_get_long_header10.log: test_get_long_header10$(EXEEXT) @p='test_get_long_header10$(EXEEXT)'; \ b='test_get_long_header10'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(check_SCRIPTS) \ $(dist_check_SCRIPTS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-recursive -rm -f ./$(DEPDIR)/mhd_debug_funcs.Po -rm -f ./$(DEPDIR)/test_get.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/mhd_debug_funcs.Po -rm -f ./$(DEPDIR)/test_get.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) check-am install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--depfiles check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la .NOTPARALLEL: @VHEAVY_TESTS_TRUE@.PHONY: warn_vheavy_use warn_vheavy_use: @echo "NOTICE" ; \ echo "NOTICE: Full heavy tests are enabled. Each test may take up to several minutes to complete." ; \ echo "NOTICE" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/src/testzzuf/zzuf_test_runner.sh0000755000175000017500000000466014556026062016524 #!/bin/sh mhd_listen_ip='127.0.0.1' max_runtime_sec='1800' if test "x${ZZUF}" = "xno" ; then echo "zzuf command missing" 1>&2 exit 77 fi if command -v "${ZZUF}" > /dev/null 2>&1 ; then : ; else echo "zzuf command missing" 1>&2 exit 77 fi run_with_socat () { echo "Trying to run the test with socat..." script_dir="" if command -v dirname > /dev/null 2>&1 ; then test_dir=`dirname /` if test "x${test_dir}" = "x/" ; then if dirname "$1" > /dev/null 2>&1 ; then script_dir=`dirname "$1"` if test -n "${script_dir}" ; then # Assume script is not in the root dir script_dir="${script_dir}/" else script_dir="./" fi fi fi fi if test -z "${script_dir}" ; then if echo "$1" | sed 's|[^/]*$||' > /dev/null 2>&1 ; then script_dir=`echo "$1" | sed 's|[^/]*$||'` if test -z "${script_dir}" ; then script_dir="./" fi fi fi if test -z "${script_dir}" ; then echo "Cannot determine script location, will try current directory." 1>&2 script_dir="./" fi $SHELL "${script_dir}zzuf_socat_test_runner.sh" "$@" exit $? } # zzuf cannot pass-through the return value of checked program # so try the direct dry-run first to get possible 77 or 99 codes echo "## Dry-run of the $@..." if "$@" --dry-run ; then echo "# Dry-run succeeded." else res_code=$? echo "Dry-run failed with exit code $res_code." 1>&2 if test $res_code -ne 99; then run_with_socat "$@" fi echo "$@ will not be run with zzuf." 1>&2 exit $res_code fi # fuzz the input only for IP ${mhd_listen_ip}. libcurl uses another IP # in this test therefore libcurl input is not fuzzed. zzuf_all_params="--ratio=0.001:0.4 --autoinc --verbose --signal \ --max-usertime=${max_runtime_sec} --check-exit --network \ --allow=${mhd_listen_ip} --exclude=." if test -n "${ZZUF_SEED}" ; then zzuf_all_params="${zzuf_all_params} --seed=${ZZUF_SEED}" fi if test -n "${ZZUF_FLAGS}" ; then zzuf_all_params="${zzuf_all_params} ${ZZUF_FLAGS}" fi # Uncomment the next line to see more data in logs #zzuf_all_params="${zzuf_all_params} -dd" echo "## Dry-run of the $@ with zzuf..." if "$ZZUF" ${zzuf_all_params} "$@" --dry-run ; then echo "# Dry-run with zzuf succeeded." else res_code=$? echo "$@ cannot be run with zzuf directly." 1>&2 run_with_socat "$@" exit $res_code fi echo "## Real test of $@ with zzuf..." "$ZZUF" ${zzuf_all_params} "$@" exit $? libmicrohttpd-1.0.1/src/testzzuf/zzuf_socat_test_runner.sh0000755000175000017500000000645714556026062017723 #!/bin/sh if set -m ; then : ; else echo "The shell $SHELL does not support background jobs, the test cannot run." 1>&2 exit 77 fi socat_listen_ip='127.0.0.121' socat_listen_port='10121' mhd_listen_port='4010' max_runtime_sec='1800' if test "x${ZZUF}" = "xno" ; then echo "zzuf command missing" 1>&2 exit 77 fi if command -v "${ZZUF}" > /dev/null 2>&1 ; then : ; else echo "zzuf command missing" 1>&2 exit 77 fi if test "x${SOCAT}" = "xno" ; then echo "socat command missing" 1>&2 exit 77 fi if command -v "${SOCAT}" > /dev/null 2>&1 ; then : ; else echo "socat command missing" 1>&2 exit 77 fi socat_test_params="-ls -lu \ -T0.1 -4 \ TCP-LISTEN:${socat_listen_port},bind=${socat_listen_ip},reuseaddr,linger=2,linger2=1,accept-timeout=0.1 \ TCP:127.0.0.1:${mhd_listen_port},reuseaddr" echo "## Trying to run socat to test ports availability..." if "${SOCAT}" ${socat_test_params} ; then echo "Success." else echo "socat test run failed" 1>&2 exit 77 fi # fuzz the input only for IP ${socat_listen_ip}. libcurl uses another IP # in this test therefore libcurl input is not fuzzed. zzuf_all_params="--ratio=0.001:0.4 --autoinc --verbose --signal \ --max-usertime=${max_runtime_sec} --check-exit --network --allow=${socat_listen_ip} --exclude=." if test -n "${ZZUF_SEED}" ; then zzuf_all_params="${zzuf_all_params} --seed=${ZZUF_SEED}" fi if test -n "${ZZUF_FLAGS}" ; then zzuf_all_params="${zzuf_all_params} ${ZZUF_FLAGS}" fi # Uncomment the next line to see more zzuf data in logs #zzuf_all_params="${zzuf_all_params} -dd" socat_options="-ls -lu \ -T3 -4" socat_addr1="TCP-LISTEN:${socat_listen_port},bind=${socat_listen_ip},reuseaddr,nodelay,linger=2,linger2=1,accept-timeout=${max_runtime_sec},fork" socat_addr2="TCP:127.0.0.1:${mhd_listen_port},reuseaddr,connect-timeout=3,nodelay,linger=2,linger2=1" if test -n "${SOCAT_FLAGS}" ; then socat_options="${socat_options} ${SOCAT_FLAGS}" fi # Uncomment the next line to see more socat data in logs #socat_options="${socat_options} -dd -D" # Uncomment the next line to see all traffic in logs #socat_options="${socat_options} -v" stop_zzuf_socat () { trap - EXIT if test -n "$zzuf_pid" ; then echo "The test has been interrupted." 1>&2 test "x$zzuf_pid" = "xstarting" && zzuf_pid=$! # Finish zzuf + socat kill -TERM ${zzuf_pid} -${zzuf_pid} # Finish the test kill -INT %2 2> /dev/null || kill -INT %1 2> /dev/null exit 99 fi } echo "## Starting zzuf with socat to reflect fuzzed traffic..." trap 'stop_zzuf_socat' EXIT zzuf_pid="starting" "${ZZUF}" ${zzuf_all_params} "${SOCAT}" ${socat_options} ${socat_addr1} ${socat_addr2} & if test $? -eq 0 ; then zzuf_pid=$! echo "zzuf with socat has been started." else zzuf_pid='' echo "Failed to start zzuf with socat" 1>&2 exit 99 fi echo "## Starting real test of $@ with traffic fuzzed by zzuf with socat..." "$@" --with-socat test_result=$? trap - EXIT echo "$@ has exited with the return code $test_result" if kill -s 0 -- $$ 2> /dev/null ; then if kill -s 0 -- ${zzuf_pid} -${zzuf_pid} ; then : ; else echo "No running zzuf with socat is detected after the test." 1>&2 echo "Looks like zzuf ended prematurely, at least part of the testing has not been performed." 1>&2 test_result=99 fi fi kill -TERM ${zzuf_pid} -${zzuf_pid} zzuf_pid='' exit $test_result libmicrohttpd-1.0.1/src/microhttpd/0000755000175000017500000000000014566140216013067 5libmicrohttpd-1.0.1/src/microhttpd/internal.h0000644000175000017500000022363514556705750015020 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff Copyright (C) 2014-2023 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/internal.h * @brief MHD internal shared structures * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #ifndef INTERNAL_H #define INTERNAL_H #include "mhd_options.h" #include "platform.h" #include "microhttpd.h" #include "mhd_assert.h" #ifdef HTTPS_SUPPORT #include #if GNUTLS_VERSION_MAJOR >= 3 #include #endif #endif /* HTTPS_SUPPORT */ #ifdef HAVE_STDBOOL_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifndef PRIu64 #define PRIu64 "llu" #endif /* ! PRIu64 */ /* Must be included before other internal headers! */ #include "mhd_panic.h" #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) #include "mhd_threads.h" #endif #include "mhd_locks.h" #include "mhd_sockets.h" #include "mhd_itc_types.h" #include "mhd_str_types.h" #if defined(BAUTH_SUPPORT) || defined(DAUTH_SUPPORT) #include "gen_auth.h" #endif /* BAUTH_SUPPORT || DAUTH_SUPPORT*/ /** * Macro to drop 'const' qualifier from pointer without compiler warning. * To be used *only* to deal with broken external APIs, which require non-const * pointer to unmodifiable data. * Must not be used to transform pointers for MHD needs. */ #define _MHD_DROP_CONST(ptr) ((void *) ((uintptr_t) ((const void *) (ptr)))) /** * @def _MHD_MACRO_NO * "Negative answer"/"false" for use in macros, meaningful for precompiler */ #define _MHD_MACRO_NO 0 /** * @def _MHD_MACRO_YES * "Positive answer"/"true" for use in macros, meaningful for precompiler */ #define _MHD_MACRO_YES 1 /** * Close FD and abort execution if error is detected. * @param fd the FD to close */ #define MHD_fd_close_chk_(fd) do { \ if ( (0 != close ((fd)) && (EBADF == errno)) ) { \ MHD_PANIC (_ ("Failed to close FD.\n")); \ } \ } while (0) /* #define EXTRA_CHECKS _MHD_MACRO_NO * Not used. Behaviour is controlled by _DEBUG/NDEBUG macros. */ #ifndef _MHD_DEBUG_CONNECT /** * Print extra messages when establishing * connections? (only adds non-error messages). */ #define _MHD_DEBUG_CONNECT _MHD_MACRO_NO #endif /* ! _MHD_DEBUG_CONNECT */ #ifndef _MHD_DEBUG_SEND_DATA /** * Should all data send be printed to stderr? */ #define _MHD_DEBUG_SEND_DATA _MHD_MACRO_NO #endif /* ! _MHD_DEBUG_SEND_DATA */ #ifndef _MHD_DEBUG_CLOSE /** * Add extra debug messages with reasons for closing connections * (non-error reasons). */ #define _MHD_DEBUG_CLOSE _MHD_MACRO_NO #endif /* ! _MHD_DEBUG_CLOSE */ #define MHD_MAX(a,b) (((a)<(b)) ? (b) : (a)) #define MHD_MIN(a,b) (((a)<(b)) ? (a) : (b)) /** * Minimum reasonable size by which MHD tries to increment read/write buffers. * We usually begin with half the available pool space for the * IO-buffer, but if absolutely needed we additively grow by the * number of bytes given here (up to -- theoretically -- the full pool * space). * * Currently set to reasonable maximum MSS size. */ #define MHD_BUF_INC_SIZE 1500 #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ /** * Tri-state on/off/unknown */ enum MHD_tristate { _MHD_UNKNOWN = -1, /**< State is not yet checked nor set */ _MHD_OFF = false, /**< State is "off" / "disabled" */ _MHD_NO = false, /**< State is "off" / "disabled" */ _MHD_ON = true, /**< State is "on" / "enabled" */ _MHD_YES = true /**< State is "on" / "enabled" */ } _MHD_FIXED_ENUM; /** * State of the socket with respect to epoll (bitmask). */ enum MHD_EpollState { /** * The socket is not involved with a defined state in epoll() right * now. */ MHD_EPOLL_STATE_UNREADY = 0, /** * epoll() told us that data was ready for reading, and we did * not consume all of it yet. */ MHD_EPOLL_STATE_READ_READY = 1, /** * epoll() told us that space was available for writing, and we did * not consume all of it yet. */ MHD_EPOLL_STATE_WRITE_READY = 2, /** * Is this connection currently in the 'eready' EDLL? */ MHD_EPOLL_STATE_IN_EREADY_EDLL = 4, /** * Is this connection currently in the epoll() set? */ MHD_EPOLL_STATE_IN_EPOLL_SET = 8, /** * Is this connection currently suspended? */ MHD_EPOLL_STATE_SUSPENDED = 16, /** * Is this connection in some error state? */ MHD_EPOLL_STATE_ERROR = 128 } _MHD_FIXED_FLAGS_ENUM; /** * What is this connection waiting for? */ enum MHD_ConnectionEventLoopInfo { /** * We are waiting to be able to read. */ MHD_EVENT_LOOP_INFO_READ = 1 << 0, /** * We are waiting to be able to write. */ MHD_EVENT_LOOP_INFO_WRITE = 1 << 1, /** * We are waiting for the application to provide data. */ MHD_EVENT_LOOP_INFO_PROCESS = 1 << 2, /** * Some data is ready to be processed, but more data could * be read. */ MHD_EVENT_LOOP_INFO_PROCESS_READ = MHD_EVENT_LOOP_INFO_READ | MHD_EVENT_LOOP_INFO_PROCESS, /** * We are finished and are awaiting cleanup. */ MHD_EVENT_LOOP_INFO_CLEANUP = 1 << 3 } _MHD_FIXED_ENUM; /** * Additional test value for enum MHD_FLAG to check only for MHD_ALLOW_SUSPEND_RESUME and * NOT for MHD_USE_ITC. */ #define MHD_TEST_ALLOW_SUSPEND_RESUME 8192 /** * Maximum length of a nonce in digest authentication. 64(SHA-256 Hex) + * 12(Timestamp Hex) + 1(NULL); hence 77 should suffice, but Opera * (already) takes more (see Mantis #1633), so we've increased the * value to support something longer... */ #define MAX_CLIENT_NONCE_LENGTH 129 /** * The maximum size of MHD-generated nonce when printed with hexadecimal chars. * * This is equal to "(32 bytes for SHA-256 (or SHA-512/256) nonce plus 6 bytes * for timestamp) multiplied by two hex chars per byte". * Please keep it in sync with digestauth.c */ #if defined(MHD_SHA256_SUPPORT) || defined(MHD_SHA512_256_SUPPORT) #define MAX_DIGEST_NONCE_LENGTH ((32 + 6) * 2) #else /* !MHD_SHA256_SUPPORT && !MHD_SHA512_256_SUPPORT */ #define MAX_DIGEST_NONCE_LENGTH ((16 + 6) * 2) #endif /* !MHD_SHA256_SUPPORT && !MHD_SHA512_256_SUPPORT */ /** * A structure representing the internal holder of the * nonce-nc map. */ struct MHD_NonceNc { /** * Nonce counter, a value that increases for each subsequent * request for the same nonce. Matches the largest last received * 'nc' value. * This 'nc' value was already used by the client. */ uint32_t nc; /** * Bitmask over the previous 64 nonce counter values (down to to nc-64). * Used to allow out-of-order 'nc'. * If bit in the bitmask is set to one, then this 'nc' value was already used * by the client. */ uint64_t nmask; /** * Nonce value */ char nonce[MAX_DIGEST_NONCE_LENGTH + 1]; }; #ifdef HAVE_MESSAGES /** * fprintf()-like helper function for logging debug * messages. */ void MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...); #endif /** * Header or footer for HTTP response. */ struct MHD_HTTP_Res_Header { /** * Headers are kept in a double-linked list. */ struct MHD_HTTP_Res_Header *next; /** * Headers are kept in a double-linked list. */ struct MHD_HTTP_Res_Header *prev; /** * The name of the header (key), without the colon. */ char *header; /** * The length of the @a header, not including the final zero termination. */ size_t header_size; /** * The value of the header. */ char *value; /** * The length of the @a value, not including the final zero termination. */ size_t value_size; /** * Type of the value. */ enum MHD_ValueKind kind; }; /** * Header, footer, or cookie for HTTP request. */ struct MHD_HTTP_Req_Header { /** * Headers are kept in a double-linked list. */ struct MHD_HTTP_Req_Header *next; /** * Headers are kept in a double-linked list. */ struct MHD_HTTP_Req_Header *prev; /** * The name of the header (key), without the colon. */ const char *header; /** * The length of the @a header, not including the final zero termination. */ size_t header_size; /** * The value of the header. */ const char *value; /** * The length of the @a value, not including the final zero termination. */ size_t value_size; /** * Type of the value. */ enum MHD_ValueKind kind; }; /** * Automatically assigned flags */ enum MHD_ResponseAutoFlags { MHD_RAF_NO_FLAGS = 0, /**< No auto flags */ MHD_RAF_HAS_CONNECTION_HDR = 1 << 0, /**< Has "Connection" header */ MHD_RAF_HAS_CONNECTION_CLOSE = 1 << 1, /**< Has "Connection: close" */ MHD_RAF_HAS_TRANS_ENC_CHUNKED = 1 << 2, /**< Has "Transfer-Encoding: chunked" */ MHD_RAF_HAS_CONTENT_LENGTH = 1 << 3, /**< Has "Content-Length" header */ MHD_RAF_HAS_DATE_HDR = 1 << 4 /**< Has "Date" header */ } _MHD_FIXED_FLAGS_ENUM; #if defined(MHD_WINSOCK_SOCKETS) /** * Internally used I/O vector type for use with winsock. * Binary matches system "WSABUF". */ typedef struct _MHD_W32_iovec { unsigned long iov_len; char *iov_base; } MHD_iovec_; #define MHD_IOV_ELMN_MAX_SIZE ULONG_MAX typedef unsigned long MHD_iov_size_; #elif defined(HAVE_SENDMSG) || defined(HAVE_WRITEV) /** * Internally used I/O vector type for use when writev or sendmsg * is available. Matches system "struct iovec". */ typedef struct iovec MHD_iovec_; #define MHD_IOV_ELMN_MAX_SIZE SIZE_MAX typedef size_t MHD_iov_size_; #else /** * Internally used I/O vector type for use when writev or sendmsg * is not available. */ typedef struct MHD_IoVec MHD_iovec_; #define MHD_IOV_ELMN_MAX_SIZE SIZE_MAX typedef size_t MHD_iov_size_; #endif struct MHD_iovec_track_ { /** * The copy of array of iovec elements. * The copy of elements are updated during sending. * The number of elements is not changed during lifetime. */ MHD_iovec_ *iov; /** * The number of elements in @a iov. * This value is not changed during lifetime. */ size_t cnt; /** * The number of sent elements. * At the same time, it is the index of the next (or current) element * to send. */ size_t sent; }; /** * Representation of a response. */ struct MHD_Response { /** * Head of double-linked list of headers to send for the response. */ struct MHD_HTTP_Res_Header *first_header; /** * Tail of double-linked list of headers to send for the response. */ struct MHD_HTTP_Res_Header *last_header; /** * Buffer pointing to data that we are supposed * to send as a response. */ const char *data; /** * Closure to give to the content reader @e crc * and content reader free callback @e crfc. */ void *crc_cls; /** * How do we get more data? NULL if we are * given all of the data up front. */ MHD_ContentReaderCallback crc; /** * NULL if data must not be freed, otherwise * either user-specified callback or "&free". */ MHD_ContentReaderFreeCallback crfc; #ifdef UPGRADE_SUPPORT /** * Application function to call once we are done sending the headers * of the response; NULL unless this is a response created with * #MHD_create_response_for_upgrade(). */ MHD_UpgradeHandler upgrade_handler; /** * Closure for @e uh. */ void *upgrade_handler_cls; #endif /* UPGRADE_SUPPORT */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) /** * Mutex to synchronize access to @e data, @e size and * @e reference_count. */ MHD_mutex_ mutex; #endif /** * The size of the response body. * Set to #MHD_SIZE_UNKNOWN if size is not known. */ uint64_t total_size; /** * At what offset in the stream is the * beginning of @e data located? */ uint64_t data_start; /** * Offset to start reading from when using @e fd. */ uint64_t fd_off; /** * Number of bytes ready in @e data (buffer may be larger * than what is filled with payload). */ size_t data_size; /** * Size of the writable data buffer @e data. */ size_t data_buffer_size; /** * Reference count for this response. Free once the counter hits * zero. */ unsigned int reference_count; /** * File-descriptor if this response is FD-backed. */ int fd; /** * Flags set for the MHD response. */ enum MHD_ResponseFlags flags; /** * Automatic flags set for the MHD response. */ enum MHD_ResponseAutoFlags flags_auto; /** * If the @e fd is a pipe (no sendfile()). */ bool is_pipe; /** * I/O vector used with MHD_create_response_from_iovec. */ MHD_iovec_ *data_iov; /** * Number of elements in data_iov. */ unsigned int data_iovcnt; }; /** * States in a state machine for a connection. * * The main transitions are any-state to #MHD_CONNECTION_CLOSED, any * state to state+1, #MHD_CONNECTION_FOOTERS_SENT to * #MHD_CONNECTION_INIT. #MHD_CONNECTION_CLOSED is the terminal state * and #MHD_CONNECTION_INIT the initial state. * * Note that transitions for *reading* happen only after the input has * been processed; transitions for *writing* happen after the * respective data has been put into the write buffer (the write does * not have to be completed yet). A transition to * #MHD_CONNECTION_CLOSED or #MHD_CONNECTION_INIT requires the write * to be complete. */ enum MHD_CONNECTION_STATE { /** * Connection just started (no headers received). * Waiting for the line with the request type, URL and version. */ MHD_CONNECTION_INIT = 0, /** * Part of the request line was received. * Wait for complete line. */ MHD_CONNECTION_REQ_LINE_RECEIVING = MHD_CONNECTION_INIT + 1, /** * We got the URL (and request type and version). Wait for a header line. * * A milestone state. No received data is processed in this state. */ MHD_CONNECTION_REQ_LINE_RECEIVED = MHD_CONNECTION_REQ_LINE_RECEIVING + 1, /** * Receiving request headers. Wait for the rest of the headers. */ MHD_CONNECTION_REQ_HEADERS_RECEIVING = MHD_CONNECTION_REQ_LINE_RECEIVED + 1, /** * We got the request headers. Process them. */ MHD_CONNECTION_HEADERS_RECEIVED = MHD_CONNECTION_REQ_HEADERS_RECEIVING + 1, /** * We have processed the request headers. Call application callback. */ MHD_CONNECTION_HEADERS_PROCESSED = MHD_CONNECTION_HEADERS_RECEIVED + 1, /** * We have processed the headers and need to send 100 CONTINUE. */ MHD_CONNECTION_CONTINUE_SENDING = MHD_CONNECTION_HEADERS_PROCESSED + 1, /** * We have sent 100 CONTINUE (or do not need to). Read the message body. */ MHD_CONNECTION_BODY_RECEIVING = MHD_CONNECTION_CONTINUE_SENDING + 1, /** * We got the request body. * * A milestone state. No received data is processed in this state. */ MHD_CONNECTION_BODY_RECEIVED = MHD_CONNECTION_BODY_RECEIVING + 1, /** * We are reading the request footers. */ MHD_CONNECTION_FOOTERS_RECEIVING = MHD_CONNECTION_BODY_RECEIVED + 1, /** * We received the entire footer. * * A milestone state. No received data is processed in this state. */ MHD_CONNECTION_FOOTERS_RECEIVED = MHD_CONNECTION_FOOTERS_RECEIVING + 1, /** * We received the entire request. * Wait for a response to be queued. */ MHD_CONNECTION_FULL_REQ_RECEIVED = MHD_CONNECTION_FOOTERS_RECEIVED + 1, /** * Finished reading of the request and the response is ready. * Switch internal logic from receiving to sending, prepare connection * sending the reply and build the reply header. */ MHD_CONNECTION_START_REPLY = MHD_CONNECTION_FULL_REQ_RECEIVED + 1, /** * We have prepared the response headers in the write buffer. * Send the response headers. */ MHD_CONNECTION_HEADERS_SENDING = MHD_CONNECTION_START_REPLY + 1, /** * We have sent the response headers. Get ready to send the body. */ MHD_CONNECTION_HEADERS_SENT = MHD_CONNECTION_HEADERS_SENDING + 1, /** * We are waiting for the client to provide more * data of a non-chunked body. */ MHD_CONNECTION_NORMAL_BODY_UNREADY = MHD_CONNECTION_HEADERS_SENT + 1, /** * We are ready to send a part of a non-chunked body. Send it. */ MHD_CONNECTION_NORMAL_BODY_READY = MHD_CONNECTION_NORMAL_BODY_UNREADY + 1, /** * We are waiting for the client to provide a chunk of the body. */ MHD_CONNECTION_CHUNKED_BODY_UNREADY = MHD_CONNECTION_NORMAL_BODY_READY + 1, /** * We are ready to send a chunk. */ MHD_CONNECTION_CHUNKED_BODY_READY = MHD_CONNECTION_CHUNKED_BODY_UNREADY + 1, /** * We have sent the chunked response body. Prepare the footers. */ MHD_CONNECTION_CHUNKED_BODY_SENT = MHD_CONNECTION_CHUNKED_BODY_READY + 1, /** * We have prepared the response footer. Send it. */ MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_CHUNKED_BODY_SENT + 1, /** * We have sent the entire reply. * Shutdown connection or restart processing to get a new request. */ MHD_CONNECTION_FULL_REPLY_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1, /** * This connection is to be closed. */ MHD_CONNECTION_CLOSED = MHD_CONNECTION_FULL_REPLY_SENT + 1 #ifdef UPGRADE_SUPPORT , /** * Connection was "upgraded" and socket is now under the * control of the application. */ MHD_CONNECTION_UPGRADE = MHD_CONNECTION_CLOSED + 1 #endif /* UPGRADE_SUPPORT */ } _MHD_FIXED_ENUM; /** * States of TLS transport layer. */ enum MHD_TLS_CONN_STATE { MHD_TLS_CONN_NO_TLS = 0, /**< Not a TLS connection (plain socket). */ MHD_TLS_CONN_INIT, /**< TLS connection is not established yet. */ MHD_TLS_CONN_HANDSHAKING, /**< TLS is in handshake process. */ MHD_TLS_CONN_CONNECTED, /**< TLS is established. */ MHD_TLS_CONN_WR_CLOSING, /**< Closing WR side of TLS layer. */ MHD_TLS_CONN_WR_CLOSED, /**< WR side of TLS layer is closed. */ MHD_TLS_CONN_TLS_CLOSING, /**< TLS session is terminating. */ MHD_TLS_CONN_TLS_CLOSED, /**< TLS session is terminated. */ MHD_TLS_CONN_TLS_FAILED, /**< TLS session failed. */ MHD_TLS_CONN_INVALID_STATE/**< Sentinel. Not a valid value. */ } _MHD_FIXED_ENUM; /** * Should all state transitions be printed to stderr? */ #define DEBUG_STATES _MHD_MACRO_NO #ifdef HAVE_MESSAGES #if DEBUG_STATES const char * MHD_state_to_string (enum MHD_CONNECTION_STATE state); #endif #endif /** * Function to receive plaintext data. * * @param conn the connection struct * @param write_to where to write received data * @param max_bytes maximum number of bytes to receive * @return number of bytes written to @a write_to */ typedef ssize_t (*ReceiveCallback) (struct MHD_Connection *conn, void *write_to, size_t max_bytes); /** * Function to transmit plaintext data. * * @param conn the connection struct * @param read_from where to read data to transmit * @param max_bytes maximum number of bytes to transmit * @return number of bytes transmitted */ typedef ssize_t (*TransmitCallback) (struct MHD_Connection *conn, const void *read_from, size_t max_bytes); /** * Ability to use same connection for next request */ enum MHD_ConnKeepAlive { /** * Connection must be closed after sending response. */ MHD_CONN_MUST_CLOSE = -1, /** * KeelAlive state is not yet determined */ MHD_CONN_KEEPALIVE_UNKOWN = 0, /** * Connection can be used for serving next request */ MHD_CONN_USE_KEEPALIVE = 1, /** * Connection will be upgraded */ MHD_CONN_MUST_UPGRADE = 2 } _MHD_FIXED_ENUM; enum MHD_HTTP_Version { /** * Not a HTTP protocol or HTTP version is invalid. */ MHD_HTTP_VER_INVALID = -1, /** * HTTP version is not yet received from the client. */ MHD_HTTP_VER_UNKNOWN = 0, /** * HTTP version before 1.0, unsupported. */ MHD_HTTP_VER_TOO_OLD = 1, /** * HTTP version 1.0 */ MHD_HTTP_VER_1_0 = 2, /** * HTTP version 1.1 */ MHD_HTTP_VER_1_1 = 3, /** * HTTP version 1.2-1.9, must be used as 1.1 */ MHD_HTTP_VER_1_2__1_9 = 4, /** * HTTP future version. Unsupported. */ MHD_HTTP_VER_FUTURE = 100 } _MHD_FIXED_ENUM; /** * Returns boolean 'true' if HTTP version is supported by MHD */ #define MHD_IS_HTTP_VER_SUPPORTED(ver) (MHD_HTTP_VER_1_0 <= (ver) && \ MHD_HTTP_VER_1_2__1_9 >= (ver)) /** * Protocol should be used as HTTP/1.1 protocol. * * See the last paragraph of * https://datatracker.ietf.org/doc/html/rfc7230#section-2.6 */ #define MHD_IS_HTTP_VER_1_1_COMPAT(ver) (MHD_HTTP_VER_1_1 == (ver) || \ MHD_HTTP_VER_1_2__1_9 == (ver)) /** * The HTTP method. * * Only primary methods (specified in RFC9110) are defined here. */ enum MHD_HTTP_Method { /** * No request string has been received yet */ MHD_HTTP_MTHD_NO_METHOD = 0, /** * HTTP method GET */ MHD_HTTP_MTHD_GET = 1, /** * HTTP method HEAD */ MHD_HTTP_MTHD_HEAD = 2, /** * HTTP method POST */ MHD_HTTP_MTHD_POST = 3, /** * HTTP method PUT */ MHD_HTTP_MTHD_PUT = 4, /** * HTTP method DELETE */ MHD_HTTP_MTHD_DELETE = 5, /** * HTTP method CONNECT */ MHD_HTTP_MTHD_CONNECT = 6, /** * HTTP method OPTIONS */ MHD_HTTP_MTHD_OPTIONS = 7, /** * HTTP method TRACE */ MHD_HTTP_MTHD_TRACE = 8, /** * Other HTTP method. Check the string value. */ MHD_HTTP_MTHD_OTHER = 1000 } _MHD_FIXED_ENUM; /** * The request line processing data */ struct MHD_RequestLineProcessing { /** * The position of the next character to be processed */ size_t proc_pos; /** * The number of empty lines skipped */ unsigned int skipped_empty_lines; /** * The position of the start of the current/last found whitespace block, * zero if not found yet. */ size_t last_ws_start; /** * The position of the next character after the last known whitespace * character in the current/last found whitespace block, * zero if not found yet. */ size_t last_ws_end; /** * The pointer to the request target. * The request URI will be formed based on it. */ char *rq_tgt; /** * The pointer to the first question mark in the @a rq_tgt. */ char *rq_tgt_qmark; /** * The number of whitespace characters in the request URI */ size_t num_ws_in_uri; }; /** * The request header processing data */ struct MHD_HeaderProcessing { /** * The position of the last processed character */ size_t proc_pos; /** * The position of the first whitespace character in current contiguous * whitespace block. * Zero when no whitespace found or found non-whitespace character after * whitespace. * Must be zero, if the current character is not whitespace. */ size_t ws_start; /** * Indicates that end of the header (field) name found. * Must be false until the first colon in line is found. */ bool name_end_found; /** * The length of the header name. * Must be zero until the first colon in line is found. * Name always starts at zero position. */ size_t name_len; /** * The position of the first character of the header value. * Zero when the first character has not been found yet. */ size_t value_start; /** * Line starts with whitespace. * It's meaningful only for the first line, as other lines should be handled * as "folded". */ bool starts_with_ws; }; /** * The union of request line and header processing data */ union MHD_HeadersProcessing { /** * The request line processing data */ struct MHD_RequestLineProcessing rq_line; /** * The request header processing data */ struct MHD_HeaderProcessing hdr; }; /** * The union of text staring point and the size of the text */ union MHD_StartOrSize { /** * The starting point of the text. * Valid when the text is being processed and the end of the text * is not yet determined. */ const char *start; /** * The size of the text. * Valid when the text has been processed and the end of the text * is known. */ size_t size; }; /** * Request-specific values. * * Meaningful for the current request only. */ struct MHD_Request { /** * HTTP version string (i.e. http/1.1). Allocated * in pool. */ const char *version; /** * HTTP protocol version as enum. */ enum MHD_HTTP_Version http_ver; /** * Request method. Should be GET/POST/etc. Allocated in pool. */ const char *method; /** * The request method as enum. */ enum MHD_HTTP_Method http_mthd; /** * Requested URL (everything after "GET" only). Allocated * in pool. */ const char *url; /** * The length of the @a url in characters, not including the terminating zero. */ size_t url_len; /** * The original length of the request target. */ size_t req_target_len; /** * Linked list of parsed headers. */ struct MHD_HTTP_Req_Header *headers_received; /** * Tail of linked list of parsed headers. */ struct MHD_HTTP_Req_Header *headers_received_tail; /** * Number of bytes we had in the HTTP header, set once we * pass #MHD_CONNECTION_HEADERS_RECEIVED. * This includes the request line, all request headers, the header section * terminating empty line, with all CRLF (or LF) characters. */ size_t header_size; /** * The union of the size of all request field lines (headers) and * the starting point of the first request field line (the first header). * Until #MHD_CONNECTION_HEADERS_RECEIVED the @a start member is valid, * staring with #MHD_CONNECTION_HEADERS_RECEIVED the @a size member is valid. * The size includes CRLF (or LR) characters, but does not include * the terminating empty line. */ union MHD_StartOrSize field_lines; /** * How many more bytes of the body do we expect * to read? #MHD_SIZE_UNKNOWN for unknown. */ uint64_t remaining_upload_size; /** * Are we receiving with chunked encoding? * This will be set to #MHD_YES after we parse the headers and * are processing the body with chunks. * After we are done with the body and we are processing the footers; * once the footers are also done, this will be set to #MHD_NO again * (before the final call to the handler). * It is used only for requests, chunked encoding for response is * indicated by @a rp_props. */ bool have_chunked_upload; /** * If we are receiving with chunked encoding, where are we right * now? * Set to 0 if we are waiting to receive the chunk size; * otherwise, this is the size of the current chunk. * A value of zero is also used when we're at the end of the chunks. */ uint64_t current_chunk_size; /** * If we are receiving with chunked encoding, where are we currently * with respect to the current chunk (at what offset / position)? */ uint64_t current_chunk_offset; /** * Indicate that some of the upload payload data (from the currently * processed chunk for chunked uploads) have been processed by the * last call of the connection handler. * If any data have been processed, but some data left in the buffer * for further processing, then MHD will use zero timeout before the * next data processing round. This allow the application handler * process the data by the fixed portions or other way suitable for * application developer. * If no data have been processed, than MHD will wait for more data * to come (as it makes no sense to call the same connection handler * under the same conditions). However this is dangerous as if buffer * is completely used then connection is aborted. Connection * suspension should be used in such case. */ bool some_payload_processed; /** * We allow the main application to associate some pointer with the * HTTP request, which is passed to each #MHD_AccessHandlerCallback * and some other API calls. Here is where we store it. (MHD does * not know or care what it is). */ void *client_context; /** * Did we ever call the "default_handler" on this request? * This flag determines if we have called the #MHD_OPTION_NOTIFY_COMPLETED * handler when the request finishes. */ bool client_aware; #ifdef BAUTH_SUPPORT /** * Basic Authorization parameters. * The result of Basic Authorization header parsing. * Allocated in the connection's pool. */ const struct MHD_RqBAuth *bauth; /** * Set to true if current request headers are checked for Basic Authorization */ bool bauth_tried; #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT /** * Digest Authorization parameters. * The result of Digest Authorization header parsing. * Allocated in the connection's pool. */ const struct MHD_RqDAuth *dauth; /** * Set to true if current request headers are checked for Digest Authorization */ bool dauth_tried; #endif /* DAUTH_SUPPORT */ /** * Number of bare CR characters that were replaced with space characters * in the request line or in the headers (field lines). */ size_t num_cr_sp_replaced; /** * The number of header lines skipped because they have no colon */ size_t skipped_broken_lines; /** * The data of the request line / request headers processing */ union MHD_HeadersProcessing hdrs; }; /** * Reply-specific properties. */ struct MHD_Reply_Properties { #ifdef _DEBUG bool set; /**< Indicates that other members are set and valid */ #endif /* _DEBUG */ bool use_reply_body_headers; /**< Use reply body-specific headers */ bool send_reply_body; /**< Send reply body (can be zero-sized) */ bool chunked; /**< Use chunked encoding for reply */ }; #if defined(_MHD_HAVE_SENDFILE) enum MHD_resp_sender_ { MHD_resp_sender_std = 0, MHD_resp_sender_sendfile }; #endif /* _MHD_HAVE_SENDFILE */ /** * Reply-specific values. * * Meaningful for the current reply only. */ struct MHD_Reply { /** * Response to transmit (initially NULL). */ struct MHD_Response *response; /** * HTTP response code. Only valid if response object * is already set. */ unsigned int responseCode; /** * The "ICY" response. * Reply begins with the SHOUTcast "ICY" line instead of "HTTP". */ bool responseIcy; /** * Current write position in the actual response * (excluding headers, content only; should be 0 * while sending headers). */ uint64_t rsp_write_position; /** * The copy of iov response. * Valid if iovec response is used. * Updated during send. * Members are allocated in the pool. */ struct MHD_iovec_track_ resp_iov; #if defined(_MHD_HAVE_SENDFILE) enum MHD_resp_sender_ resp_sender; #endif /* _MHD_HAVE_SENDFILE */ /** * Reply-specific properties */ struct MHD_Reply_Properties props; }; /** * State kept for each HTTP request. */ struct MHD_Connection { #ifdef EPOLL_SUPPORT /** * Next pointer for the EDLL listing connections that are epoll-ready. */ struct MHD_Connection *nextE; /** * Previous pointer for the EDLL listing connections that are epoll-ready. */ struct MHD_Connection *prevE; #endif /** * Next pointer for the DLL describing our IO state. */ struct MHD_Connection *next; /** * Previous pointer for the DLL describing our IO state. */ struct MHD_Connection *prev; /** * Next pointer for the XDLL organizing connections by timeout. * This DLL can be either the * 'manual_timeout_head/manual_timeout_tail' or the * 'normal_timeout_head/normal_timeout_tail', depending on whether a * custom timeout is set for the connection. */ struct MHD_Connection *nextX; /** * Previous pointer for the XDLL organizing connections by timeout. */ struct MHD_Connection *prevX; /** * Reference to the MHD_Daemon struct. */ struct MHD_Daemon *daemon; /** * Request-specific data */ struct MHD_Request rq; /** * Reply-specific data */ struct MHD_Reply rp; /** * The memory pool is created whenever we first read from the TCP * stream and destroyed at the end of each request (and re-created * for the next request). In the meantime, this pointer is NULL. * The pool is used for all connection-related data except for the * response (which maybe shared between connections) and the IP * address (which persists across individual requests). */ struct MemoryPool *pool; /** * We allow the main application to associate some pointer with the * TCP connection (which may span multiple HTTP requests). Here is * where we store it. (MHD does not know or care what it is). * The location is given to the #MHD_NotifyConnectionCallback and * also accessible via #MHD_CONNECTION_INFO_SOCKET_CONTEXT. */ void *socket_context; /** * Close connection after sending response? * Functions may change value from "Unknown" or "KeepAlive" to "Must close", * but no functions reset value "Must Close" to any other value. */ enum MHD_ConnKeepAlive keepalive; /** * Buffer for reading requests. Allocated in pool. Actually one * byte larger than @e read_buffer_size (if non-NULL) to allow for * 0-termination. */ char *read_buffer; /** * Buffer for writing response (headers only). Allocated * in pool. */ char *write_buffer; /** * Foreign address (of length @e addr_len). MALLOCED (not * in pool!). */ struct sockaddr_storage *addr; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) /** * Thread handle for this connection (if we are using * one thread per connection). */ MHD_thread_handle_ID_ tid; #endif /** * Size of @e read_buffer (in bytes). * This value indicates how many bytes we're willing to read * into the buffer. */ size_t read_buffer_size; /** * Position where we currently append data in @e read_buffer (the * next char after the last valid position). */ size_t read_buffer_offset; /** * Size of @e write_buffer (in bytes). */ size_t write_buffer_size; /** * Offset where we are with sending from @e write_buffer. */ size_t write_buffer_send_offset; /** * Last valid location in write_buffer (where do we * append and up to where is it safe to send?) */ size_t write_buffer_append_offset; /** * Position in the 100 CONTINUE message that * we need to send when receiving http 1.1 requests. */ size_t continue_message_write_offset; /** * Length of the foreign address. */ socklen_t addr_len; /** * Last time this connection had any activity * (reading or writing). */ uint64_t last_activity; /** * After how many milliseconds of inactivity should * this connection time out? * Zero for no timeout. */ uint64_t connection_timeout_ms; /** * Socket for this connection. Set to #MHD_INVALID_SOCKET if * this connection has died (daemon should clean * up in that case). */ MHD_socket socket_fd; /** * true if @e socket_fd is not TCP/IP (a UNIX domain socket, a pipe), * false (TCP/IP) otherwise. */ enum MHD_tristate is_nonip; /** * true if #socket_fd is non-blocking, false otherwise. */ bool sk_nonblck; /** * true if connection socket has set SIGPIPE suppression */ bool sk_spipe_suppress; /** * Tracks TCP_CORK / TCP_NOPUSH of the connection socket. */ enum MHD_tristate sk_corked; /** * Tracks TCP_NODELAY state of the connection socket. */ enum MHD_tristate sk_nodelay; /** * Has this socket been closed for reading (i.e. other side closed * the connection)? If so, we must completely close the connection * once we are done sending our response (and stop trying to read * from this socket). */ bool read_closed; /** * Some error happens during processing the connection therefore this * connection must be closed. * The error may come from the client side (like wrong request format), * from the application side (like data callback returned error), or from * the OS side (like out-of-memory). */ bool stop_with_error; /** * Response queued early, before the request is fully processed, * the client upload is rejected. * The connection cannot be reused for additional requests as the current * request is incompletely read and it is unclear where is the initial * byte of the next request. */ bool discard_request; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) /** * Set to `true` if the thread has been joined. */ bool thread_joined; #endif /** * Are we currently inside the "idle" handler (to avoid recursively * invoking it). */ bool in_idle; /** * Connection is in the cleanup DL-linked list. */ bool in_cleanup; #ifdef EPOLL_SUPPORT /** * What is the state of this socket in relation to epoll? */ enum MHD_EpollState epoll_state; #endif /** * State in the FSM for this connection. */ enum MHD_CONNECTION_STATE state; /** * What is this connection waiting for? */ enum MHD_ConnectionEventLoopInfo event_loop_info; /** * Function used for reading HTTP request stream. */ ReceiveCallback recv_cls; #ifdef UPGRADE_SUPPORT /** * If this connection was upgraded, this points to * the upgrade response details such that the * #thread_main_connection_upgrade()-logic can perform the * bi-directional forwarding. */ struct MHD_UpgradeResponseHandle *urh; #endif /* UPGRADE_SUPPORT */ #ifdef HTTPS_SUPPORT /** * State required for HTTPS/SSL/TLS support. */ gnutls_session_t tls_session; /** * State of connection's TLS layer */ enum MHD_TLS_CONN_STATE tls_state; /** * Could it be that we are ready to read due to TLS buffers * even though the socket is not? */ bool tls_read_ready; #endif /* HTTPS_SUPPORT */ /** * Is the connection suspended? */ bool suspended; /** * Are we currently in the #MHD_AccessHandlerCallback * for this connection (and thus eligible to receive * calls to #MHD_queue_response()?). */ bool in_access_handler; /** * Is the connection wanting to resume? */ volatile bool resuming; /** * Special member to be returned by #MHD_get_connection_info() */ union MHD_ConnectionInfo connection_info_dummy; }; #ifdef UPGRADE_SUPPORT /** * Buffer we use for upgrade response handling in the unlikely * case where the memory pool was so small it had no buffer * capacity left. Note that we don't expect to _ever_ use this * buffer, so it's mostly wasted memory (except that it allows * us to handle a tricky error condition nicely). So no need to * make this one big. Applications that want to perform well * should just pick an adequate size for the memory pools. */ #define RESERVE_EBUF_SIZE 8 /** * Context we pass to epoll() for each of the two sockets * of a `struct MHD_UpgradeResponseHandle`. We need to do * this so we can distinguish the two sockets when epoll() * gives us event notifications. */ struct UpgradeEpollHandle { /** * Reference to the overall response handle this struct is * included within. */ struct MHD_UpgradeResponseHandle *urh; /** * The socket this event is kind-of about. Note that this is NOT * necessarily the socket we are polling on, as for when we read * from TLS, we epoll() on the connection's socket * (`urh->connection->socket_fd`), while this then the application's * socket (where the application will read from). Nevertheless, for * the application to read, we need to first read from TLS, hence * the two are related. * * Similarly, for writing to TLS, this epoll() will be on the * connection's `socket_fd`, and this will merely be the FD which * the application would write to. Hence this struct must always be * interpreted based on which field in `struct * MHD_UpgradeResponseHandle` it is (`app` or `mhd`). */ MHD_socket socket; /** * IO-state of the @e socket (or the connection's `socket_fd`). */ enum MHD_EpollState celi; }; /** * Handle given to the application to manage special * actions relating to MHD responses that "upgrade" * the HTTP protocol (i.e. to WebSockets). */ struct MHD_UpgradeResponseHandle { /** * The connection for which this is an upgrade handle. Note that * because a response may be shared over many connections, this may * not be the only upgrade handle for the response of this connection. */ struct MHD_Connection *connection; #ifdef HTTPS_SUPPORT /** * Kept in a DLL per daemon. */ struct MHD_UpgradeResponseHandle *next; /** * Kept in a DLL per daemon. */ struct MHD_UpgradeResponseHandle *prev; #ifdef EPOLL_SUPPORT /** * Next pointer for the EDLL listing urhs that are epoll-ready. */ struct MHD_UpgradeResponseHandle *nextE; /** * Previous pointer for the EDLL listing urhs that are epoll-ready. */ struct MHD_UpgradeResponseHandle *prevE; /** * Specifies whether urh already in EDLL list of ready connections. */ bool in_eready_list; #endif /** * The buffer for receiving data from TLS to * be passed to the application. Contains @e in_buffer_size * bytes (unless @e in_buffer_size is zero). Do not free! */ char *in_buffer; /** * The buffer for receiving data from the application to * be passed to TLS. Contains @e out_buffer_size * bytes (unless @e out_buffer_size is zero). Do not free! */ char *out_buffer; /** * Size of the @e in_buffer. * Set to 0 if the TLS connection went down for reading or socketpair * went down for writing. */ size_t in_buffer_size; /** * Size of the @e out_buffer. * Set to 0 if the TLS connection went down for writing or socketpair * went down for reading. */ size_t out_buffer_size; /** * Number of bytes actually in use in the @e in_buffer. Can be larger * than @e in_buffer_size if and only if @a in_buffer_size is zero and * we still have bytes that can be forwarded. * Reset to zero if all data was forwarded to socketpair or * if socketpair went down for writing. */ size_t in_buffer_used; /** * Number of bytes actually in use in the @e out_buffer. Can be larger * than @e out_buffer_size if and only if @a out_buffer_size is zero and * we still have bytes that can be forwarded. * Reset to zero if all data was forwarded to TLS connection or * if TLS connection went down for writing. */ size_t out_buffer_used; /** * The socket we gave to the application (r/w). */ struct UpgradeEpollHandle app; /** * If @a app_sock was a socketpair, our end of it, otherwise * #MHD_INVALID_SOCKET; (r/w). */ struct UpgradeEpollHandle mhd; /** * Emergency IO buffer we use in case the memory pool has literally * nothing left. */ char e_buf[RESERVE_EBUF_SIZE]; #endif /* HTTPS_SUPPORT */ /** * Set to true after the application finished with the socket * by #MHD_UPGRADE_ACTION_CLOSE. * * When BOTH @e was_closed (changed by command from application) * AND @e clean_ready (changed internally by MHD) are set to * #MHD_YES, function #MHD_resume_connection() will move this * connection to cleanup list. * @remark This flag could be changed from any thread. */ volatile bool was_closed; /** * Set to true if connection is ready for cleanup. * * In TLS mode functions #MHD_connection_finish_forward_() must * be called before setting this flag to true. * * In thread-per-connection mode, true in this flag means * that connection's thread exited or about to exit and will * not use MHD_Connection::urh data anymore. * * In any mode true in this flag also means that * MHD_Connection::urh data will not be used for socketpair * forwarding and forwarding itself is finished. * * When BOTH @e was_closed (changed by command from application) * AND @e clean_ready (changed internally by MHD) are set to * true, function #MHD_resume_connection() will move this * connection to cleanup list. * @remark This flag could be changed from thread that process * connection's recv(), send() and response. */ volatile bool clean_ready; }; #endif /* UPGRADE_SUPPORT */ /** * Signature of function called to log URI accesses. * * @param cls closure * @param uri uri being accessed * @param con connection handle * @return new closure */ typedef void * (*LogCallback)(void *cls, const char *uri, struct MHD_Connection *con); /** * Signature of function called to unescape URIs. See also * #MHD_http_unescape(). * * @param cls closure * @param conn connection handle * @param uri 0-terminated string to unescape (should be updated) * @return length of the resulting string */ typedef size_t (*UnescapeCallback)(void *cls, struct MHD_Connection *conn, char *uri); /** * State kept for each MHD daemon. All connections are kept in two * doubly-linked lists. The first one reflects the state of the * connection in terms of what operations we are waiting for (read, * write, locally blocked, cleanup) whereas the second is about its * timeout state (default or custom). */ struct MHD_Daemon { /** * Callback function for all requests. */ MHD_AccessHandlerCallback default_handler; /** * Closure argument to default_handler. */ void *default_handler_cls; /** * Daemon's flags (bitfield). * * @remark Keep this member after pointer value to keep it * properly aligned as it will be used as member of union MHD_DaemonInfo. */ enum MHD_FLAG options; /** * Head of doubly-linked list of new, externally added connections. */ struct MHD_Connection *new_connections_head; /** * Tail of doubly-linked list of new, externally added connections. */ struct MHD_Connection *new_connections_tail; /** * Head of doubly-linked list of our current, active connections. */ struct MHD_Connection *connections_head; /** * Tail of doubly-linked list of our current, active connections. */ struct MHD_Connection *connections_tail; /** * Head of doubly-linked list of our current but suspended connections. */ struct MHD_Connection *suspended_connections_head; /** * Tail of doubly-linked list of our current but suspended connections. */ struct MHD_Connection *suspended_connections_tail; /** * Head of doubly-linked list of connections to clean up. */ struct MHD_Connection *cleanup_head; /** * Tail of doubly-linked list of connections to clean up. */ struct MHD_Connection *cleanup_tail; /** * _MHD_YES if the @e listen_fd socket is a UNIX domain socket. */ enum MHD_tristate listen_is_unix; #ifdef EPOLL_SUPPORT /** * Head of EDLL of connections ready for processing (in epoll mode). */ struct MHD_Connection *eready_head; /** * Tail of EDLL of connections ready for processing (in epoll mode) */ struct MHD_Connection *eready_tail; /** * File descriptor associated with our epoll loop. * * @remark Keep this member after pointer value to keep it * properly aligned as it will be used as member of union MHD_DaemonInfo. */ int epoll_fd; /** * true if the @e listen_fd socket is in the 'epoll' set, * false if not. */ bool listen_socket_in_epoll; #ifdef UPGRADE_SUPPORT #ifdef HTTPS_SUPPORT /** * File descriptor associated with the #run_epoll_for_upgrade() loop. * Only available if #MHD_USE_HTTPS_EPOLL_UPGRADE is set. */ int epoll_upgrade_fd; /** * true if @e epoll_upgrade_fd is in the 'epoll' set, * false if not. */ bool upgrade_fd_in_epoll; #endif /* HTTPS_SUPPORT */ /** * Head of EDLL of upgraded connections ready for processing (in epoll mode). */ struct MHD_UpgradeResponseHandle *eready_urh_head; /** * Tail of EDLL of upgraded connections ready for processing (in epoll mode) */ struct MHD_UpgradeResponseHandle *eready_urh_tail; #endif /* UPGRADE_SUPPORT */ #endif /* EPOLL_SUPPORT */ /** * Head of the XDLL of ALL connections with a default ('normal') * timeout, sorted by timeout (earliest at the tail, most recently * used connection at the head). MHD can just look at the tail of * this list to determine the timeout for all of its elements; * whenever there is an event of a connection, the connection is * moved back to the tail of the list. * * All connections by default start in this list; if a custom * timeout that does not match @e connection_timeout_ms is set, they * are moved to the @e manual_timeout_head-XDLL. * Not used in MHD_USE_THREAD_PER_CONNECTION mode as each thread * needs only one connection-specific timeout. */ struct MHD_Connection *normal_timeout_head; /** * Tail of the XDLL of ALL connections with a default timeout, * sorted by timeout (earliest timeout at the tail). * Not used in MHD_USE_THREAD_PER_CONNECTION mode. */ struct MHD_Connection *normal_timeout_tail; /** * Head of the XDLL of ALL connections with a non-default/custom * timeout, unsorted. MHD will do a O(n) scan over this list to * determine the current timeout. * Not used in MHD_USE_THREAD_PER_CONNECTION mode. */ struct MHD_Connection *manual_timeout_head; /** * Tail of the XDLL of ALL connections with a non-default/custom * timeout, unsorted. * Not used in MHD_USE_THREAD_PER_CONNECTION mode. */ struct MHD_Connection *manual_timeout_tail; /** * Function to call to check if we should accept or reject an * incoming request. May be NULL. */ MHD_AcceptPolicyCallback apc; /** * Closure argument to apc. */ void *apc_cls; /** * Function to call when we are done processing * a particular request. May be NULL. */ MHD_RequestCompletedCallback notify_completed; /** * Closure argument to @e notify_completed. */ void *notify_completed_cls; /** * Function to call when we are starting/stopping * a connection. May be NULL. */ MHD_NotifyConnectionCallback notify_connection; /** * Closure argument to @e notify_connection. */ void *notify_connection_cls; /** * Function to call with the full URI at the * beginning of request processing. May be NULL. *

* Returns the initial pointer to internal state * kept by the client for the request. */ LogCallback uri_log_callback; /** * Closure argument to @e uri_log_callback. */ void *uri_log_callback_cls; /** * Function to call when we unescape escape sequences. */ UnescapeCallback unescape_callback; /** * Closure for @e unescape_callback. */ void *unescape_callback_cls; /** * Listen port. * * @remark Keep this member after pointer value to keep it * properly aligned as it will be used as member of union MHD_DaemonInfo. */ uint16_t port; #ifdef HAVE_MESSAGES /** * Function for logging error messages (if we * support error reporting). */ MHD_LogCallback custom_error_log; /** * Closure argument to @e custom_error_log. */ void *custom_error_log_cls; #endif /** * Pointer to master daemon (NULL if this is the master) */ struct MHD_Daemon *master; /** * Listen socket. * * @remark Keep this member after pointer value to keep it * properly aligned as it will be used as member of union MHD_DaemonInfo. */ MHD_socket listen_fd; /** * Listen socket is non-blocking. */ bool listen_nonblk; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) /** * Worker daemons (one per thread) */ struct MHD_Daemon *worker_pool; #endif /** * Table storing number of connections per IP */ void *per_ip_connection_count; /** * Number of active parallel connections. * * @remark Keep this member after pointer value to keep it * properly aligned as it will be used as member of union MHD_DaemonInfo. */ unsigned int connections; /** * Size of the per-connection memory pools. */ size_t pool_size; /** * Increment for growth of the per-connection memory pools. */ size_t pool_increment; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) /** * Size of threads created by MHD. */ size_t thread_stack_size; /** * Number of worker daemons */ unsigned int worker_pool_size; /** * The select thread handle (if we have internal select) */ MHD_thread_handle_ID_ tid; /** * Mutex for per-IP connection counts. */ MHD_mutex_ per_ip_connection_mutex; /** * Mutex for (modifying) access to the "cleanup", "normal_timeout" and * "manual_timeout" DLLs. */ MHD_mutex_ cleanup_connection_mutex; /** * Mutex for any access to the "new connections" DL-list. */ MHD_mutex_ new_connections_mutex; #endif /** * Our #MHD_OPTION_SERVER_INSANITY level, bits indicating * which sanity checks are off. */ enum MHD_DisableSanityCheck insanity_level; /** * Whether to allow/disallow/ignore reuse of listening address. * The semantics is the following: * 0: ignore (user did not ask for neither allow/disallow, use SO_REUSEADDR * except W32) * >0: allow (use SO_REUSEPORT on most platforms, SO_REUSEADDR on Windows) * <0: disallow (mostly no action, SO_EXCLUSIVEADDRUSE on Windows or SO_EXCLBIND * on Solaris) */ int listening_address_reuse; /** * Inter-thread communication channel (also used to unblock * select() in non-threaded code). */ struct MHD_itc_ itc; /** * Are we shutting down? */ volatile bool shutdown; /** * Has this daemon been quiesced via #MHD_quiesce_daemon()? * If so, we should no longer use the @e listen_fd (including * removing it from the @e epoll_fd when possible). */ volatile bool was_quiesced; /** * Did we hit some system or process-wide resource limit while * trying to accept() the last time? If so, we don't accept new * connections until we close an existing one. This effectively * temporarily lowers the "connection_limit" to the current * number of connections. */ bool at_limit; /* * Do we need to process resuming connections? */ volatile bool resuming; /** * Indicate that new connections in @e new_connections_head list * need to be processed. */ volatile bool have_new; /** * 'True' if some data is already waiting to be processed. * If set to 'true' - zero timeout for select()/poll*() * is used. * Should be reset each time before processing connections * and raised by any connection which require additional * immediately processing (application does not provide * data for response, data waiting in TLS buffers etc.) */ bool data_already_pending; /** * Limit on the number of parallel connections. */ unsigned int connection_limit; /** * After how many milliseconds of inactivity should * this connection time out? * Zero for no timeout. */ uint64_t connection_timeout_ms; /** * Maximum number of connections per IP, or 0 for * unlimited. */ unsigned int per_ip_connection_limit; /** * The strictness level for parsing of incoming data. * @see #MHD_OPTION_CLIENT_DISCIPLINE_LVL */ int client_discipline; #ifdef HAS_FD_SETSIZE_OVERRIDABLE /** * The value of FD_SETSIZE used by the daemon. * For external sockets polling this is the value provided by the application * via MHD_OPTION_APP_FD_SETSIZE or current FD_SETSIZE value. * For internal threads modes this is always current FD_SETSIZE value. */ int fdset_size; /** * Indicates whether @a fdset_size value was set by application. * 'false' if default value is used. */ bool fdset_size_set_by_app; #endif /* HAS_FD_SETSIZE_OVERRIDABLE */ /** * True if SIGPIPE is blocked */ bool sigpipe_blocked; #ifdef HTTPS_SUPPORT #ifdef UPGRADE_SUPPORT /** * Head of DLL of upgrade response handles we are processing. * Used for upgraded TLS connections when thread-per-connection * is not used. */ struct MHD_UpgradeResponseHandle *urh_head; /** * Tail of DLL of upgrade response handles we are processing. * Used for upgraded TLS connections when thread-per-connection * is not used. */ struct MHD_UpgradeResponseHandle *urh_tail; #endif /* UPGRADE_SUPPORT */ /** * Desired cipher algorithms. */ gnutls_priority_t priority_cache; /** * What kind of credentials are we offering * for SSL/TLS? */ gnutls_credentials_type_t cred_type; /** * Server x509 credentials */ gnutls_certificate_credentials_t x509_cred; /** * Diffie-Hellman parameters */ gnutls_dh_params_t dh_params; /** * Server PSK credentials */ gnutls_psk_server_credentials_t psk_cred; #if GNUTLS_VERSION_MAJOR >= 3 /** * Function that can be used to obtain the certificate. Needed * for SNI support. See #MHD_OPTION_HTTPS_CERT_CALLBACK. */ gnutls_certificate_retrieve_function2 *cert_callback; /** * Function that can be used to obtain the shared key. */ MHD_PskServerCredentialsCallback cred_callback; /** * Closure for @e cred_callback. */ void *cred_callback_cls; #endif #if GNUTLS_VERSION_NUMBER >= 0x030603 /** * Function that can be used to obtain the certificate. Needed * for OCSP stapling support. See #MHD_OPTION_HTTPS_CERT_CALLBACK2. */ gnutls_certificate_retrieve_function3 *cert_callback2; #endif /** * Pointer to our SSL/TLS key (in ASCII) in memory. */ const char *https_mem_key; /** * Pointer to our SSL/TLS certificate (in ASCII) in memory. */ const char *https_mem_cert; /** * Pointer to 0-terminated HTTPS passphrase in memory. */ const char *https_key_password; /** * Pointer to our SSL/TLS certificate authority (in ASCII) in memory. */ const char *https_mem_trust; /** * Our Diffie-Hellman parameters in memory. */ gnutls_dh_params_t https_mem_dhparams; /** * true if we have initialized @e https_mem_dhparams. */ bool have_dhparams; /** * true if ALPN is disabled. */ bool disable_alpn; #endif /* HTTPS_SUPPORT */ #ifdef DAUTH_SUPPORT /** * Character array of random values. */ const char *digest_auth_random; /** * Size of @a digest_auth_random. */ size_t digest_auth_rand_size; /** * The malloc'ed copy of the @a digest_auth_random. */ void *digest_auth_random_copy; /** * An array that contains the map nonce-nc. */ struct MHD_NonceNc *nnc; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) /** * A rw-lock for synchronizing access to @e nnc. */ MHD_mutex_ nnc_lock; #endif /** * Size of the nonce-nc array. */ unsigned int nonce_nc_size; /** * Nonce bind type. */ unsigned int dauth_bind_type; /** * Default nonce validity length. */ unsigned int dauth_def_nonce_timeout; /** * Default maximum nc (nonce count) value. */ uint32_t dauth_def_max_nc; #endif #ifdef TCP_FASTOPEN /** * The queue size for incoming SYN + DATA packets. */ unsigned int fastopen_queue_size; #endif /** * The size of queue for listen socket. */ unsigned int listen_backlog_size; /* TODO: replace with a single member */ /** * The value to be returned by #MHD_get_daemon_info() */ union MHD_DaemonInfo daemon_info_dummy_listen_fd; #ifdef EPOLL_SUPPORT /** * The value to be returned by #MHD_get_daemon_info() */ union MHD_DaemonInfo daemon_info_dummy_epoll_fd; #endif /* EPOLL_SUPPORT */ /** * The value to be returned by #MHD_get_daemon_info() */ union MHD_DaemonInfo daemon_info_dummy_num_connections; /** * The value to be returned by #MHD_get_daemon_info() */ union MHD_DaemonInfo daemon_info_dummy_flags; /** * The value to be returned by #MHD_get_daemon_info() */ union MHD_DaemonInfo daemon_info_dummy_port; #if defined(_DEBUG) && defined(HAVE_ACCEPT4) /** * If set to 'true', accept() function will be used instead of accept4() even * if accept4() is available. * This is a workaround for zzuf, which does not support sockets created * by accept4() function. * There is no API to change the value of this member, it can be flipped * only by direct access to the struct member. */ bool avoid_accept4; #endif /* _DEBUG */ }; #if defined(HAVE_POLL) && defined(EPOLL_SUPPORT) /** * Checks whether the @a d daemon is using select() */ #define MHD_D_IS_USING_SELECT_(d) \ (0 == (d->options & (MHD_USE_POLL | MHD_USE_EPOLL))) /** * Checks whether the @a d daemon is using poll() */ #define MHD_D_IS_USING_POLL_(d) (0 != ((d)->options & MHD_USE_POLL)) /** * Checks whether the @a d daemon is using epoll */ #define MHD_D_IS_USING_EPOLL_(d) (0 != ((d)->options & MHD_USE_EPOLL)) #elif defined(HAVE_POLL) /** * Checks whether the @a d daemon is using select() */ #define MHD_D_IS_USING_SELECT_(d) (0 == ((d)->options & MHD_USE_POLL)) /** * Checks whether the @a d daemon is using poll() */ #define MHD_D_IS_USING_POLL_(d) (0 != ((d)->options & MHD_USE_POLL)) /** * Checks whether the @a d daemon is using epoll */ #define MHD_D_IS_USING_EPOLL_(d) ((void) (d), 0) #elif defined(EPOLL_SUPPORT) /** * Checks whether the @a d daemon is using select() */ #define MHD_D_IS_USING_SELECT_(d) (0 == ((d)->options & MHD_USE_EPOLL)) /** * Checks whether the @a d daemon is using poll() */ #define MHD_D_IS_USING_POLL_(d) ((void) (d), 0) /** * Checks whether the @a d daemon is using epoll */ #define MHD_D_IS_USING_EPOLL_(d) (0 != ((d)->options & MHD_USE_EPOLL)) #else /* select() only */ /** * Checks whether the @a d daemon is using select() */ #define MHD_D_IS_USING_SELECT_(d) ((void) (d), ! 0) /** * Checks whether the @a d daemon is using poll() */ #define MHD_D_IS_USING_POLL_(d) ((void) (d), 0) /** * Checks whether the @a d daemon is using epoll */ #define MHD_D_IS_USING_EPOLL_(d) ((void) (d), 0) #endif /* select() only */ #if defined(MHD_USE_THREADS) /** * Checks whether the @a d daemon is using internal polling thread */ #define MHD_D_IS_USING_THREADS_(d) \ (0 != (d->options & (MHD_USE_INTERNAL_POLLING_THREAD))) /** * Checks whether the @a d daemon is using thread-per-connection mode */ #define MHD_D_IS_USING_THREAD_PER_CONN_(d) \ (0 != ((d)->options & MHD_USE_THREAD_PER_CONNECTION)) /** * Check whether the @a d daemon has thread-safety enabled. */ #define MHD_D_IS_THREAD_SAFE_(d) \ (0 == ((d)->options & MHD_USE_NO_THREAD_SAFETY)) #else /* ! MHD_USE_THREADS */ /** * Checks whether the @a d daemon is using internal polling thread */ #define MHD_D_IS_USING_THREADS_(d) ((void) d, 0) /** * Checks whether the @a d daemon is using thread-per-connection mode */ #define MHD_D_IS_USING_THREAD_PER_CONN_(d) ((void) d, 0) /** * Check whether the @a d daemon has thread-safety enabled. */ #define MHD_D_IS_THREAD_SAFE_(d) ((void) d, 0) #endif /* ! MHD_USE_THREADS */ #ifdef HAS_FD_SETSIZE_OVERRIDABLE /** * Get FD_SETSIZE used by the daemon @a d */ #define MHD_D_GET_FD_SETSIZE_(d) ((d)->fdset_size) #else /* ! HAS_FD_SETSIZE_OVERRIDABLE */ /** * Get FD_SETSIZE used by the daemon @a d */ #define MHD_D_GET_FD_SETSIZE_(d) (FD_SETSIZE) #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ /** * Check whether socket @a sckt fits fd_sets used by the daemon @a d */ #define MHD_D_DOES_SCKT_FIT_FDSET_(sckt,d) \ MHD_SCKT_FD_FITS_FDSET_SETSIZE_(sckt,NULL,MHD_D_GET_FD_SETSIZE_(d)) #ifdef DAUTH_SUPPORT /** * Parameter of request's Digest Authorization header */ struct MHD_RqDAuthParam { /** * The string with length, NOT zero-terminated */ struct _MHD_str_w_len value; /** * True if string must be "unquoted" before processing. * This member is false if the string is used in DQUOTE marks, but no * backslash-escape is used in the string. */ bool quoted; }; /** * Request client's Digest Authorization header parameters */ struct MHD_RqDAuth { struct MHD_RqDAuthParam nonce; struct MHD_RqDAuthParam opaque; struct MHD_RqDAuthParam response; struct MHD_RqDAuthParam username; struct MHD_RqDAuthParam username_ext; struct MHD_RqDAuthParam realm; struct MHD_RqDAuthParam uri; /* The raw QOP value, used in the 'response' calculation */ struct MHD_RqDAuthParam qop_raw; struct MHD_RqDAuthParam cnonce; struct MHD_RqDAuthParam nc; /* Decoded values are below */ bool userhash; /* True if 'userhash' parameter has value 'true'. */ enum MHD_DigestAuthAlgo3 algo3; enum MHD_DigestAuthQOP qop; }; #endif /* DAUTH_SUPPORT */ /** * Insert an element at the head of a DLL. Assumes that head, tail and * element are structs with prev and next fields. * * @param head pointer to the head of the DLL * @param tail pointer to the tail of the DLL * @param element element to insert */ #define DLL_insert(head,tail,element) do { \ mhd_assert (NULL == (element)->next); \ mhd_assert (NULL == (element)->prev); \ (element)->next = (head); \ (element)->prev = NULL; \ if ((tail) == NULL) { \ (tail) = element; \ } else { \ (head)->prev = element; \ } \ (head) = (element); } while (0) /** * Remove an element from a DLL. Assumes * that head, tail and element are structs * with prev and next fields. * * @param head pointer to the head of the DLL * @param tail pointer to the tail of the DLL * @param element element to remove */ #define DLL_remove(head,tail,element) do { \ mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \ mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \ if ((element)->prev == NULL) { \ (head) = (element)->next; \ } else { \ (element)->prev->next = (element)->next; \ } \ if ((element)->next == NULL) { \ (tail) = (element)->prev; \ } else { \ (element)->next->prev = (element)->prev; \ } \ (element)->next = NULL; \ (element)->prev = NULL; } while (0) /** * Insert an element at the head of a XDLL. Assumes that head, tail and * element are structs with prevX and nextX fields. * * @param head pointer to the head of the XDLL * @param tail pointer to the tail of the XDLL * @param element element to insert */ #define XDLL_insert(head,tail,element) do { \ mhd_assert (NULL == (element)->nextX); \ mhd_assert (NULL == (element)->prevX); \ (element)->nextX = (head); \ (element)->prevX = NULL; \ if (NULL == (tail)) { \ (tail) = element; \ } else { \ (head)->prevX = element; \ } \ (head) = (element); } while (0) /** * Remove an element from a XDLL. Assumes * that head, tail and element are structs * with prevX and nextX fields. * * @param head pointer to the head of the XDLL * @param tail pointer to the tail of the XDLL * @param element element to remove */ #define XDLL_remove(head,tail,element) do { \ mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \ mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \ if (NULL == (element)->prevX) { \ (head) = (element)->nextX; \ } else { \ (element)->prevX->nextX = (element)->nextX; \ } \ if (NULL == (element)->nextX) { \ (tail) = (element)->prevX; \ } else { \ (element)->nextX->prevX = (element)->prevX; \ } \ (element)->nextX = NULL; \ (element)->prevX = NULL; } while (0) /** * Insert an element at the head of a EDLL. Assumes that head, tail and * element are structs with prevE and nextE fields. * * @param head pointer to the head of the EDLL * @param tail pointer to the tail of the EDLL * @param element element to insert */ #define EDLL_insert(head,tail,element) do { \ (element)->nextE = (head); \ (element)->prevE = NULL; \ if ((tail) == NULL) { \ (tail) = element; \ } else { \ (head)->prevE = element; \ } \ (head) = (element); } while (0) /** * Remove an element from a EDLL. Assumes * that head, tail and element are structs * with prevE and nextE fields. * * @param head pointer to the head of the EDLL * @param tail pointer to the tail of the EDLL * @param element element to remove */ #define EDLL_remove(head,tail,element) do { \ if ((element)->prevE == NULL) { \ (head) = (element)->nextE; \ } else { \ (element)->prevE->nextE = (element)->nextE; \ } \ if ((element)->nextE == NULL) { \ (tail) = (element)->prevE; \ } else { \ (element)->nextE->prevE = (element)->prevE; \ } \ (element)->nextE = NULL; \ (element)->prevE = NULL; } while (0) /** * Convert all occurrences of '+' to ' '. * * @param arg string that is modified (in place), must be 0-terminated */ void MHD_unescape_plus (char *arg); /** * Callback invoked when iterating over @a key / @a value * argument pairs during parsing. * * @param cls context of the iteration * @param key 0-terminated key string, never NULL * @param key_size number of bytes in key * @param value 0-terminated binary data, may include binary zeros, may be NULL * @param value_size number of bytes in value * @param kind origin of the key-value pair * @return #MHD_YES on success (continue to iterate) * #MHD_NO to signal failure (and abort iteration) */ typedef enum MHD_Result (*MHD_ArgumentIterator_)(void *cls, const char *key, size_t key_size, const char *value, size_t value_size, enum MHD_ValueKind kind); /** * Parse and unescape the arguments given by the client * as part of the HTTP request URI. * * @param kind header kind to pass to @a cb * @param connection connection to add headers to * @param[in,out] args argument URI string (after "?" in URI), * clobbered in the process! * @param cb function to call on each key-value pair found * @param cls the iterator context * @return #MHD_NO on failure (@a cb returned #MHD_NO), * #MHD_YES for success (parsing succeeded, @a cb always * returned #MHD_YES) */ enum MHD_Result MHD_parse_arguments_ (struct MHD_Connection *connection, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, void *cls); /** * Check whether response header contains particular token. * * Token could be surrounded by spaces and tabs and delimited by comma. * Case-insensitive match used for header names and tokens. * * @param response the response to query * @param key header name * @param key_len the length of @a key, not including optional * terminating null-character. * @param token the token to find * @param token_len the length of @a token, not including optional * terminating null-character. * @return true if token is found in specified header, * false otherwise */ bool MHD_check_response_header_token_ci (const struct MHD_Response *response, const char *key, size_t key_len, const char *token, size_t token_len); /** * Check whether response header contains particular static @a tkn. * * Token could be surrounded by spaces and tabs and delimited by comma. * Case-insensitive match used for header names and tokens. * @param r the response to query * @param k header name * @param tkn the static string of token to find * @return true if token is found in specified header, * false otherwise */ #define MHD_check_response_header_s_token_ci(r,k,tkn) \ MHD_check_response_header_token_ci ((r),(k),MHD_STATICSTR_LEN_ (k), \ (tkn),MHD_STATICSTR_LEN_ (tkn)) /** * Internal version of #MHD_suspend_connection(). * * @remark In thread-per-connection mode: can be called from any thread, * in any other mode: to be called only from thread that process * daemon's select()/poll()/etc. * * @param connection the connection to suspend */ void internal_suspend_connection_ (struct MHD_Connection *connection); /** * Trace up to and return master daemon. If the supplied daemon * is a master, then return the daemon itself. * * @param daemon handle to a daemon * @return master daemon handle */ _MHD_static_inline struct MHD_Daemon * MHD_get_master (struct MHD_Daemon *const daemon) { struct MHD_Daemon *ret; if (NULL != daemon->master) ret = daemon->master; else ret = daemon; mhd_assert (NULL == ret->master); return ret; } #ifdef UPGRADE_SUPPORT /** * Mark upgraded connection as closed by application. * * The @a connection pointer must not be used after call of this function * as it may be freed in other thread immediately. * @param connection the upgraded connection to mark as closed by application */ void MHD_upgraded_connection_mark_app_closed_ (struct MHD_Connection *connection); #endif /* UPGRADE_SUPPORT */ #endif libmicrohttpd-1.0.1/src/microhttpd/test_dauth_userhash.c0000644000175000017500000006050114556705750017234 /* This file is part of libmicrohttpd Copyright (C) 2022 Evgeny Grin (Karlson2) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_dauth_userhash.c * @brief Tests for Digest Auth calculations of userhash * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include #include "microhttpd.h" #include "test_helpers.h" #if defined(MHD_HTTPS_REQUIRE_GCRYPT) && \ (defined(MHD_SHA256_TLSLIB) || defined(MHD_MD5_TLSLIB)) #define NEED_GCRYP_INIT 1 #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT && (MHD_SHA256_TLSLIB || MHD_MD5_TLSLIB) */ static int verbose = 1; /* verbose level (0-1)*/ /* Declarations and data */ struct data_md5 { unsigned int line_num; const char *const username; const char *const realm; const uint8_t hash[MHD_MD5_DIGEST_SIZE]; }; static const struct data_md5 md5_tests[] = { {__LINE__, "u", "r", {0xba, 0x84, 0xbe, 0x20, 0x3f, 0xdf, 0xc7, 0xd3, 0x4e, 0x05, 0x4a, 0x76, 0xd2, 0x85, 0xd0, 0xc9}}, {__LINE__, "testuser", "testrealm", {0xab, 0xae, 0x15, 0x95, 0x24, 0xe5, 0x17, 0xbf, 0x48, 0xf4, 0x4a, 0xab, 0xfe, 0xb9, 0x37, 0x40}}, {__LINE__, "test_user", "TestRealm", /* Values from testcurl/test_digestauth2.c */ {0xc5, 0x3c, 0x60, 0x15, 0x03, 0xff, 0x17, 0x6f, 0x18, 0xf6, 0x23, 0x72, 0x5f, 0xba, 0x42, 0x81}}, {__LINE__, "Mufasa", "myhost@testrealm.com", {0x26, 0x45, 0xae, 0x13, 0xd1, 0xa2, 0xa6, 0x9e, 0xd2, 0x6d, 0xd2, 0x1a, 0xa5, 0x52, 0x86, 0xe3}}, {__LINE__, "Mufasa", "myhost@example.com", {0x4f, 0xc8, 0x64, 0x02, 0xd7, 0x18, 0x5d, 0x7b, 0x38, 0xd4, 0x38, 0xad, 0xd5, 0x5a, 0x35, 0x84}}, {__LINE__, "Mufasa", "http-auth@example.org", {0x42, 0x38, 0xf3, 0xa1, 0x61, 0x67, 0x37, 0x3f, 0xeb, 0xb9, 0xbc, 0x4d, 0x43, 0xdb, 0x9c, 0xc4}}, {__LINE__, "J" "\xC3\xA4" "s" "\xC3\xB8" "n Doe" /* "Jäsøn Doe" */, "api@example.org", {0x2e, 0x06, 0x3f, 0xa2, 0xc5, 0x4d, 0xea, 0x1c, 0x36, 0x80, 0x8b, 0x7a, 0x6e, 0x3b, 0x14, 0xc9}} }; struct data_sha256 { unsigned int line_num; const char *const username; const char *const realm; const uint8_t hash[MHD_SHA256_DIGEST_SIZE]; }; static const struct data_sha256 sha256_tests[] = { {__LINE__, "u", "r", {0x1d, 0x8a, 0x03, 0xa6, 0xe2, 0x1a, 0x4c, 0xe7, 0x75, 0x06, 0x0e, 0xa5, 0x73, 0x60, 0x32, 0x9a, 0xc7, 0x50, 0xde, 0xa5, 0xd8, 0x47, 0x29, 0x7b, 0x42, 0xf0, 0xd4, 0x65, 0x39, 0xaf, 0x8a, 0xb2}}, {__LINE__, "testuser", "testrealm", {0x75, 0xaf, 0x8a, 0x35, 0x00, 0xf7, 0x71, 0xe5, 0x8a, 0x52, 0x09, 0x3a, 0x25, 0xe7, 0x90, 0x5d, 0x6e, 0x42, 0x8a, 0x51, 0x12, 0x85, 0xc1, 0x2e, 0xa1, 0x42, 0x0c, 0x73, 0x07, 0x8d, 0xfd, 0x61}}, {__LINE__, "test_user", "TestRealm", /* Values from testcurl/test_digestauth2.c */ {0x09, 0x0c, 0x7e, 0x06, 0xb7, 0x7d, 0x66, 0x14, 0xcf, 0x5f, 0xe6, 0xca, 0xfa, 0x00, 0x4d, 0x2e, 0x5f, 0x8f, 0xb3, 0x6b, 0xa4, 0x5a, 0x0e, 0x35, 0xea, 0xcb, 0x2e, 0xb7, 0x72, 0x8f, 0x34, 0xde}}, {__LINE__, "Mufasa", "myhost@testrealm.com", {0x92, 0x9f, 0xac, 0x9e, 0x6c, 0x8b, 0x76, 0xcc, 0xab, 0xa9, 0xe0, 0x6f, 0xf6, 0x4d, 0xf2, 0x6f, 0xcb, 0x40, 0x56, 0x4c, 0x19, 0x9c, 0x32, 0xd9, 0xea, 0xd9, 0x12, 0x4b, 0x25, 0x34, 0xe1, 0xf9}}, {__LINE__, "Mufasa", "myhost@example.com", {0x97, 0x06, 0xf0, 0x07, 0x1c, 0xec, 0x05, 0x3f, 0x88, 0x22, 0xb6, 0x63, 0x69, 0xc4, 0xa4, 0x00, 0x39, 0x79, 0xb7, 0xe7, 0x42, 0xb7, 0x4e, 0x42, 0x59, 0x63, 0x57, 0xf4, 0xd3, 0x02, 0xae, 0x16}}, {__LINE__, "Mufasa", "http-auth@example.org", {0xa9, 0x47, 0xaa, 0xd2, 0x05, 0xe8, 0x0e, 0x42, 0x99, 0x58, 0xa3, 0x87, 0x39, 0x49, 0x44, 0xc6, 0xb4, 0x96, 0x30, 0x1e, 0x79, 0xf8, 0x9d, 0x35, 0xa4, 0xcc, 0x23, 0xb6, 0xee, 0x12, 0xb5, 0xb6}}, {__LINE__, "J" "\xC3\xA4" "s" "\xC3\xB8" "n Doe" /* "Jäsøn Doe" */, "api@example.org", {0x5a, 0x1a, 0x8a, 0x47, 0xdf, 0x5c, 0x29, 0x85, 0x51, 0xb9, 0xb4, 0x2b, 0xa9, 0xb0, 0x58, 0x35, 0x17, 0x4a, 0x5b, 0xd7, 0xd5, 0x11, 0xff, 0x7f, 0xe9, 0x19, 0x1d, 0x8e, 0x94, 0x6f, 0xc4, 0xe7}} }; struct data_sha512_256 { unsigned int line_num; const char *const username; const char *const realm; const uint8_t hash[MHD_SHA512_256_DIGEST_SIZE]; }; static const struct data_sha512_256 sha512_256_tests[] = { {__LINE__, "u", "r", {0xc7, 0x38, 0xf2, 0xad, 0x40, 0x1b, 0xc8, 0x7a, 0x71, 0xfe, 0x78, 0x09, 0x60, 0x15, 0xc9, 0x7b, 0x9a, 0x26, 0xd5, 0x5f, 0x15, 0xe9, 0xf5, 0x0a, 0xc3, 0xa6, 0xde, 0x73, 0xdd, 0xcd, 0x3d, 0x08}}, {__LINE__, "testuser", "testrealm", {0x4f, 0x69, 0x1e, 0xe9, 0x50, 0x8a, 0xe4, 0x55, 0x21, 0x32, 0x9e, 0xcf, 0xd4, 0x91, 0xf7, 0xe2, 0x77, 0x4b, 0x6f, 0xb8, 0x60, 0x2c, 0x14, 0x86, 0xad, 0x94, 0x9d, 0x1c, 0x23, 0xd8, 0xa1, 0xf5}}, {__LINE__, "test_user", "TestRealm", /* Values from testcurl/test_digestauth2.c */ {0x62, 0xe1, 0xac, 0x9f, 0x6c, 0xb1, 0xeb, 0x26, 0xaa, 0x75, 0xeb, 0x5d, 0x46, 0xef, 0xcd, 0xc8, 0x9c, 0xcb, 0xa7, 0x81, 0xf0, 0xf9, 0xf7, 0x2f, 0x6a, 0xfd, 0xb9, 0x42, 0x65, 0xd9, 0xa7, 0x9a}}, {__LINE__, "Mufasa", "myhost@testrealm.com", {0xbd, 0x3e, 0xbc, 0x30, 0x10, 0x0b, 0x7c, 0xf1, 0x61, 0x45, 0x6c, 0xfe, 0x64, 0x1c, 0x4c, 0xd2, 0x82, 0xe0, 0x62, 0x6e, 0x2c, 0x5e, 0x09, 0xc2, 0x4c, 0x90, 0xb1, 0x60, 0x8a, 0xec, 0x28, 0x64}}, {__LINE__, "Mufasa", "myhost@example.com", {0xea, 0x4b, 0x59, 0x37, 0xde, 0x2c, 0x4e, 0x9f, 0x16, 0xf9, 0x9c, 0x31, 0x01, 0xb6, 0xdd, 0xf8, 0x8c, 0x85, 0xd7, 0xe8, 0xf1, 0x75, 0x90, 0xd0, 0x63, 0x2a, 0x75, 0x75, 0xe4, 0x80, 0x13, 0x69}}, {__LINE__, "Mufasa", "http-auth@example.org", {0xe2, 0xdf, 0xab, 0xd1, 0xa9, 0x6d, 0xdf, 0x86, 0x77, 0x10, 0xb6, 0x53, 0xb6, 0xe6, 0x85, 0x7d, 0x1f, 0x14, 0x70, 0x86, 0xde, 0x7d, 0x7e, 0xf7, 0x9d, 0xcd, 0x24, 0x98, 0x59, 0x87, 0x25, 0x70}}, {__LINE__, "J" "\xC3\xA4" "s" "\xC3\xB8" "n Doe" /* "Jäsøn Doe" */, "api@example.org", {0x79, 0x32, 0x63, 0xca, 0xab, 0xb7, 0x07, 0xa5, 0x62, 0x11, 0x94, 0x0d, 0x90, 0x41, 0x1e, 0xa4, 0xa5, 0x75, 0xad, 0xec, 0xcb, 0x7e, 0x36, 0x0a, 0xeb, 0x62, 0x4e, 0xd0, 0x6e, 0xce, 0x9b, 0x0b}} }; /* * Helper functions */ /** * Print bin as lower case hex * * @param bin binary data * @param len number of bytes in bin * @param hex pointer to len*2+1 bytes buffer */ static void bin2hex (const uint8_t *bin, size_t len, char *hex) { while (len-- > 0) { unsigned int b1, b2; b1 = (*bin >> 4) & 0xf; *hex++ = (char) ((b1 > 9) ? (b1 + 'a' - 10) : (b1 + '0')); b2 = *bin++ & 0xf; *hex++ = (char) ((b2 > 9) ? (b2 + 'a' - 10) : (b2 + '0')); } *hex = 0; } /* Tests */ static unsigned int check_md5 (const struct data_md5 *const data) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_MD5; uint8_t hash_bin[MHD_MD5_DIGEST_SIZE]; char hash_hex[MHD_MD5_DIGEST_SIZE * 2 + 1]; char expected_hex[MHD_MD5_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userhash"; if (MHD_YES != MHD_digest_auth_calc_userhash (algo3, data->username, data->realm, hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_YES.\n", func_name); } else if (0 != memcmp (hash_bin, data->hash, sizeof(data->hash))) { failed++; bin2hex (hash_bin, sizeof(hash_bin), hash_hex); bin2hex (data->hash, sizeof(data->hash), expected_hex); fprintf (stderr, "FAILED: %s() produced wrong hash. " "Calculated digest %s, expected digest %s.\n", func_name, hash_hex, expected_hex); } func_name = "MHD_digest_auth_calc_userhash_hex"; if (MHD_YES != MHD_digest_auth_calc_userhash_hex (algo3, data->username, data->realm, hash_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_YES.\n", func_name); } else if (sizeof(hash_hex) - 1 != strlen (hash_hex)) { failed++; fprintf (stderr, "FAILED: %s produced hash with wrong length. " "Calculated length %u, expected digest %u.\n", func_name, (unsigned) strlen (hash_hex), (unsigned) (sizeof(hash_hex) - 1)); } else { bin2hex (data->hash, sizeof(data->hash), expected_hex); if (0 != memcmp (hash_hex, expected_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() produced wrong hash. " "Calculated digest %s, expected digest %s.\n", func_name, hash_hex, expected_hex); } } if (failed) { fprintf (stderr, "The check failed for data located at line: %u.\n", data->line_num); fflush (stderr); } else if (verbose) { printf ("PASSED: check for data at line: %u.\n", data->line_num); } return failed ? 1 : 0; } static unsigned int test_md5 (void) { unsigned int num_failed = 0; size_t i; for (i = 0; i < sizeof(md5_tests) / sizeof(md5_tests[0]); i++) num_failed += check_md5 (md5_tests + i); return num_failed; } static unsigned int test_md5_failure (void) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_MD5; uint8_t hash_bin[MHD_MD5_DIGEST_SIZE]; char hash_hex[MHD_MD5_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userhash"; if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, sizeof(hash_bin) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_MD5)) { if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } func_name = "MHD_digest_auth_calc_userhash_hex"; if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, sizeof(hash_hex) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_MD5)) { if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } if (! failed && verbose) { printf ("PASSED: all checks with expected MHD_NO result near line: %u.\n", (unsigned) __LINE__); } return failed ? 1 : 0; } static unsigned int check_sha256 (const struct data_sha256 *const data) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_SHA256; uint8_t hash_bin[MHD_SHA256_DIGEST_SIZE]; char hash_hex[MHD_SHA256_DIGEST_SIZE * 2 + 1]; char expected_hex[MHD_SHA256_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userhash"; if (MHD_YES != MHD_digest_auth_calc_userhash (algo3, data->username, data->realm, hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_YES.\n", func_name); } else if (0 != memcmp (hash_bin, data->hash, sizeof(data->hash))) { failed++; bin2hex (hash_bin, sizeof(hash_bin), hash_hex); bin2hex (data->hash, sizeof(data->hash), expected_hex); fprintf (stderr, "FAILED: %s() produced wrong hash. " "Calculated digest %s, expected digest %s.\n", func_name, hash_hex, expected_hex); } func_name = "MHD_digest_auth_calc_userhash_hex"; if (MHD_YES != MHD_digest_auth_calc_userhash_hex (algo3, data->username, data->realm, hash_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_YES.\n", func_name); } else if (sizeof(hash_hex) - 1 != strlen (hash_hex)) { failed++; fprintf (stderr, "FAILED: %s produced hash with wrong length. " "Calculated length %u, expected digest %u.\n", func_name, (unsigned) strlen (hash_hex), (unsigned) (sizeof(hash_hex) - 1)); } else { bin2hex (data->hash, sizeof(data->hash), expected_hex); if (0 != memcmp (hash_hex, expected_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() produced wrong hash. " "Calculated digest %s, expected digest %s.\n", func_name, hash_hex, expected_hex); } } if (failed) { fprintf (stderr, "The check failed for data located at line: %u.\n", data->line_num); fflush (stderr); } else if (verbose) { printf ("PASSED: check for data at line: %u.\n", data->line_num); } return failed ? 1 : 0; } static unsigned int test_sha256 (void) { unsigned int num_failed = 0; size_t i; for (i = 0; i < sizeof(sha256_tests) / sizeof(sha256_tests[0]); i++) num_failed += check_sha256 (sha256_tests + i); return num_failed; } static unsigned int test_sha256_failure (void) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_SHA256; uint8_t hash_bin[MHD_SHA256_DIGEST_SIZE]; char hash_hex[MHD_SHA256_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userhash"; if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, sizeof(hash_bin) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_SHA256)) { if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } func_name = "MHD_digest_auth_calc_userhash_hex"; if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, sizeof(hash_hex) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_SHA256)) { if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } if (! failed && verbose) { printf ("PASSED: all checks with expected MHD_NO result near line: %u.\n", (unsigned) __LINE__); } return failed ? 1 : 0; } static unsigned int check_sha512_256 (const struct data_sha512_256 *const data) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_SHA512_256; uint8_t hash_bin[MHD_SHA512_256_DIGEST_SIZE]; char hash_hex[MHD_SHA512_256_DIGEST_SIZE * 2 + 1]; char expected_hex[MHD_SHA512_256_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userhash"; if (MHD_YES != MHD_digest_auth_calc_userhash (algo3, data->username, data->realm, hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_YES.\n", func_name); } else if (0 != memcmp (hash_bin, data->hash, sizeof(data->hash))) { failed++; bin2hex (hash_bin, sizeof(hash_bin), hash_hex); bin2hex (data->hash, sizeof(data->hash), expected_hex); fprintf (stderr, "FAILED: %s() produced wrong hash. " "Calculated digest %s, expected digest %s.\n", func_name, hash_hex, expected_hex); } func_name = "MHD_digest_auth_calc_userhash_hex"; if (MHD_YES != MHD_digest_auth_calc_userhash_hex (algo3, data->username, data->realm, hash_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_YES.\n", func_name); } else if (sizeof(hash_hex) - 1 != strlen (hash_hex)) { failed++; fprintf (stderr, "FAILED: %s produced hash with wrong length. " "Calculated length %u, expected digest %u.\n", func_name, (unsigned) strlen (hash_hex), (unsigned) (sizeof(hash_hex) - 1)); } else { bin2hex (data->hash, sizeof(data->hash), expected_hex); if (0 != memcmp (hash_hex, expected_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() produced wrong hash. " "Calculated digest %s, expected digest %s.\n", func_name, hash_hex, expected_hex); } } if (failed) { fprintf (stderr, "The check failed for data located at line: %u.\n", data->line_num); fflush (stderr); } else if (verbose) { printf ("PASSED: check for data at line: %u.\n", data->line_num); } return failed ? 1 : 0; } static unsigned int test_sha512_256 (void) { unsigned int num_failed = 0; size_t i; for (i = 0; i < sizeof(sha512_256_tests) / sizeof(sha512_256_tests[0]); i++) num_failed += check_sha512_256 (sha512_256_tests + i); return num_failed; } static unsigned int test_sha512_256_failure (void) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_SHA512_256; static const enum MHD_FEATURE feature = MHD_FEATURE_DIGEST_AUTH_SHA512_256; uint8_t hash_bin[MHD_SHA512_256_DIGEST_SIZE]; char hash_hex[MHD_SHA512_256_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userhash"; if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, sizeof(hash_bin) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (feature)) { if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } func_name = "MHD_digest_auth_calc_userhash_hex"; if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, sizeof(hash_hex) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (feature)) { if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } if (! failed && verbose) { printf ("PASSED: all checks with expected MHD_NO result near line: %u.\n", (unsigned) __LINE__); } return failed ? 1 : 0; } int main (int argc, char *argv[]) { unsigned int num_failed = 0; (void) has_in_name; /* Mute compiler warning. */ if (has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")) verbose = 0; #ifdef NEED_GCRYP_INIT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* GCRYCTL_INITIALIZATION_FINISHED */ #endif /* NEED_GCRYP_INIT */ if (MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_MD5)) num_failed += test_md5 (); num_failed += test_md5_failure (); if (MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_SHA256)) num_failed += test_sha256 (); num_failed += test_sha256_failure (); if (MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_SHA512_256)) num_failed += test_sha512_256 (); num_failed += test_sha512_256_failure (); return num_failed ? 1 : 0; } libmicrohttpd-1.0.1/src/microhttpd/test_shutdown_select.c0000644000175000017500000002406114504515253017426 /* This file is part of libmicrohttpd Copyright (C) 2016 Karlson2k (Evgeny Grin) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file microhttpd/test_shutdown_select.c * @brief Test whether shutdown socket triggers select()/poll() * @details On some platforms shutting down the socket in one thread * triggers select() or poll() waiting for this socket in * other thread. libmicrohttpd depends on this behavior on * these platforms. This program check whether select() * and poll() (if available) work as expected. * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include "mhd_sockets.h" #include #include #include #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ #if defined(MHD_USE_POSIX_THREADS) #include #endif /* MHD_USE_POSIX_THREADS */ #if defined(MHD_WINSOCK_SOCKETS) #include #include #define sock_errno (WSAGetLastError ()) #elif defined(MHD_POSIX_SOCKETS) #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_ARPA_INET_H #include #endif /* HAVE_ARPA_INET_H */ #ifdef HAVE_SYS_SELECT_H #include #endif /* HAVE_SYS_SELECT_H */ #if defined(HAVE_POLL) && defined(HAVE_POLL_H) #include #endif /* HAVE_POLL && HAVE_POLL_H */ #define sock_errno (errno) #endif /* MHD_POSIX_SOCKETS */ #ifdef HAVE_STDBOOL_H #include #endif /* HAVE_STDBOOL_H */ #include "mhd_threads.h" #ifndef SOMAXCONN #define SOMAXCONN 511 #endif /* ! SOMAXCONN */ #if ! defined(SHUT_RDWR) && defined(SD_BOTH) #define SHUT_RDWR SD_BOTH #endif static bool check_err; static bool has_in_name (const char *prog_name, const char *marker) { size_t name_pos; size_t pos; if (! prog_name || ! marker) return 0; pos = 0; name_pos = 0; while (prog_name[pos]) { if ('/' == prog_name[pos]) name_pos = pos + 1; #if defined(_WIN32) || defined(__CYGWIN__) else if ('\\' == prog_name[pos]) name_pos = pos + 1; #endif /* _WIN32 || __CYGWIN__ */ pos++; } if (name_pos == pos) return true; return strstr (prog_name + name_pos, marker) != NULL; } static MHD_socket start_socket_listen (int domain) { /* Create sockets similarly to daemon.c */ MHD_socket fd; int cloexec_set; struct sockaddr_in sock_addr; socklen_t addrlen; #ifdef MHD_WINSOCK_SOCKETS unsigned long flags = 1; #else /* MHD_POSIX_SOCKETS */ int flags; #endif /* MHD_POSIX_SOCKETS */ #if defined(MHD_POSIX_SOCKETS) && defined(SOCK_CLOEXEC) fd = socket (domain, SOCK_STREAM | SOCK_CLOEXEC, 0); cloexec_set = 1; #elif defined(MHD_WINSOCK_SOCKETS) && defined(WSA_FLAG_NO_HANDLE_INHERIT) fd = WSASocketW (domain, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_NO_HANDLE_INHERIT); cloexec_set = 1; #else /* !SOCK_CLOEXEC */ fd = socket (domain, SOCK_STREAM, 0); cloexec_set = 0; #endif /* !SOCK_CLOEXEC */ if ( (MHD_INVALID_SOCKET == fd) && (cloexec_set) ) { fd = socket (domain, SOCK_STREAM, 0); cloexec_set = 0; } if (MHD_INVALID_SOCKET == fd) { fprintf (stderr, "Can't create socket: %u\n", (unsigned) sock_errno); return MHD_INVALID_SOCKET; } if (! cloexec_set) { #ifdef MHD_WINSOCK_SOCKETS if (! SetHandleInformation ((HANDLE) fd, HANDLE_FLAG_INHERIT, 0)) fprintf (stderr, "Failed to make socket non-inheritable: %u\n", (unsigned int) GetLastError ()); #else /* MHD_POSIX_SOCKETS */ flags = fcntl (fd, F_GETFD); if ( ( (-1 == flags) || ( (flags != (flags | FD_CLOEXEC)) && (0 != fcntl (fd, F_SETFD, flags | FD_CLOEXEC)) ) ) ) fprintf (stderr, "Failed to make socket non-inheritable: %s\n", MHD_socket_last_strerr_ ()); #endif /* MHD_POSIX_SOCKETS */ } memset (&sock_addr, 0, sizeof (struct sockaddr_in)); sock_addr.sin_family = AF_INET; sock_addr.sin_port = htons (0); #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sock_addr.sin_len = sizeof (struct sockaddr_in); #endif addrlen = sizeof (struct sockaddr_in); if (bind (fd, (const struct sockaddr *) &sock_addr, addrlen) < 0) { fprintf (stderr, "Failed to bind socket: %u\n", (unsigned) sock_errno); MHD_socket_close_chk_ (fd); return MHD_INVALID_SOCKET; } #ifdef MHD_WINSOCK_SOCKETS if (0 != ioctlsocket (fd, (int) FIONBIO, &flags)) { fprintf (stderr, "Failed to make socket non-blocking: %u\n", (unsigned) sock_errno); MHD_socket_close_chk_ (fd); return MHD_INVALID_SOCKET; } #else /* MHD_POSIX_SOCKETS */ flags = fcntl (fd, F_GETFL); if ( ( (-1 == flags) || ( (flags != (flags | O_NONBLOCK)) && (0 != fcntl (fd, F_SETFL, flags | O_NONBLOCK)) ) ) ) { fprintf (stderr, "Failed to make socket non-blocking: %s\n", MHD_socket_last_strerr_ ()); MHD_socket_close_chk_ (fd); return MHD_INVALID_SOCKET; } #endif /* MHD_POSIX_SOCKETS */ if (listen (fd, SOMAXCONN) < 0) { fprintf (stderr, "Failed to listen on socket: %u\n", (unsigned) sock_errno); MHD_socket_close_chk_ (fd); return MHD_INVALID_SOCKET; } return fd; } static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ select_thread (void *data) { /* use select() like in daemon.c */ MHD_socket listen_sock = *((MHD_socket *) data); fd_set rs, ws; struct timeval timeout; FD_ZERO (&rs); FD_ZERO (&ws); FD_SET (listen_sock, &rs); timeout.tv_usec = 0; timeout.tv_sec = 7; check_err = (0 > MHD_SYS_select_ (listen_sock + 1, &rs, &ws, NULL, &timeout)); return (MHD_THRD_RTRN_TYPE_) 0; } #ifdef HAVE_POLL static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ poll_thread (void *data) { /* use poll() like in daemon.c */ struct pollfd p[1]; MHD_socket listen_sock = *((MHD_socket *) data); p[0].fd = listen_sock; p[0].events = POLLIN; p[0].revents = 0; check_err = (0 > MHD_sys_poll_ (p, 1, 7000)); return (MHD_THRD_RTRN_TYPE_) 0; } #endif /* HAVE_POLL */ static void local_sleep (unsigned seconds) { #if defined(_WIN32) && ! defined(__CYGWIN__) Sleep (seconds * 1000); #else unsigned seconds_left = seconds; do { seconds_left = sleep (seconds_left); } while (seconds_left > 0); #endif } int main (int argc, char *const *argv) { int i; time_t start_t, end_t; int result = 0; MHD_THRD_RTRN_TYPE_ (MHD_THRD_CALL_SPEC_ * test_func)(void *data); #ifdef MHD_WINSOCK_SOCKETS WORD ver_req; WSADATA wsa_data; int err; #endif /* MHD_WINSOCK_SOCKETS */ bool test_poll; bool must_ignore; (void) argc; /* Unused. Silent compiler warning. */ test_poll = has_in_name (argv[0], "_poll"); must_ignore = has_in_name (argv[0], "_ignore"); if (! test_poll) test_func = &select_thread; else { #ifndef HAVE_POLL return 77; #else /* ! HAVE_POLL */ test_func = &poll_thread; #endif /* ! HAVE_POLL */ } #ifdef MHD_WINSOCK_SOCKETS ver_req = MAKEWORD (2, 2); err = WSAStartup (ver_req, &wsa_data); if ((err != 0) || (MAKEWORD (2, 2) != wsa_data.wVersion)) { printf ("WSAStartup() failed\n"); WSACleanup (); return 99; } #endif /* MHD_WINSOCK_SOCKETS */ /* try several times to ensure that accidental incoming connection * didn't interfere with test results */ for (i = 0; i < 5 && result == 0; i++) { MHD_thread_handle_native_ sel_thrd; /* fprintf(stdout, "Creating, binding and listening socket...\n"); */ MHD_socket listen_socket = start_socket_listen (AF_INET); if (MHD_INVALID_SOCKET == listen_socket) return 99; check_err = true; /* fprintf (stdout, "Starting select() thread...\n"); */ #if defined(MHD_USE_POSIX_THREADS) if (0 != pthread_create (&sel_thrd, NULL, test_func, &listen_socket)) { MHD_socket_close_chk_ (listen_socket); fprintf (stderr, "Can't start thread\n"); return 99; } #elif defined(MHD_USE_W32_THREADS) sel_thrd = (HANDLE) (uintptr_t) _beginthreadex (NULL, 0, test_func, &listen_socket, 0, NULL); if (0 == (sel_thrd)) { MHD_socket_close_chk_ (listen_socket); fprintf (stderr, "Can't start select() thread\n"); return 99; } #else #error No threading lib available #endif /* fprintf (stdout, "Waiting...\n"); */ local_sleep (1); /* make sure that select() is started */ /* fprintf (stdout, "Shutting down socket...\n"); */ start_t = time (NULL); shutdown (listen_socket, SHUT_RDWR); /* fprintf (stdout, "Waiting for thread to finish...\n"); */ if (! MHD_join_thread_ (sel_thrd)) { MHD_socket_close_chk_ (listen_socket); fprintf (stderr, "Can't join select() thread\n"); return 99; } if (check_err) { MHD_socket_close_chk_ (listen_socket); fprintf (stderr, "Error in waiting thread\n"); return 99; } end_t = time (NULL); /* fprintf (stdout, "Thread finished.\n"); */ MHD_socket_close_chk_ (listen_socket); if ((start_t == (time_t) -1) || (end_t == (time_t) -1) ) { MHD_socket_close_chk_ (listen_socket); fprintf (stderr, "Can't get current time\n"); return 99; } if (end_t - start_t > 3) result++; } #ifdef MHD_WINSOCK_SOCKETS WSACleanup (); #endif /* MHD_WINSOCK_SOCKETS */ return must_ignore ? (! result) : (result); } libmicrohttpd-1.0.1/src/microhttpd/test_str_token.c0000644000175000017500000001122514441373361016224 /* This file is part of libmicrohttpd Copyright (C) 2017 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_str_token.c * @brief Unit tests for some mhd_str functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include "mhd_str.h" static int expect_found_n (const char *str, const char *token, size_t token_len) { if (! MHD_str_has_token_caseless_ (str, token, token_len)) { fprintf (stderr, "MHD_str_has_token_caseless_() FAILED:\n\tMHD_str_has_token_caseless_(%s, %s, %lu) return false\n", str, token, (unsigned long) token_len); return 1; } return 0; } #define expect_found(s,t) expect_found_n ((s),(t),MHD_STATICSTR_LEN_ (t)) static int expect_not_found_n (const char *str, const char *token, size_t token_len) { if (MHD_str_has_token_caseless_ (str, token, token_len)) { fprintf (stderr, "MHD_str_has_token_caseless_() FAILED:\n\tMHD_str_has_token_caseless_(%s, %s, %lu) return true\n", str, token, (unsigned long) token_len); return 1; } return 0; } #define expect_not_found(s,t) expect_not_found_n ((s),(t),MHD_STATICSTR_LEN_ ( \ t)) static int check_match (void) { int errcount = 0; errcount += expect_found ("string", "string"); errcount += expect_found ("String", "string"); errcount += expect_found ("string", "String"); errcount += expect_found ("strinG", "String"); errcount += expect_found ("\t strinG", "String"); errcount += expect_found ("strinG\t ", "String"); errcount += expect_found (" \t tOkEn ", "toKEN"); errcount += expect_found ("not token\t, tOkEn ", "toKEN"); errcount += expect_found ("not token,\t tOkEn, more token", "toKEN"); errcount += expect_found ("not token,\t tOkEn\t, more token", "toKEN"); errcount += expect_found (",,,,,,test,,,,", "TESt"); errcount += expect_found (",,,,,\t,test,,,,", "TESt"); errcount += expect_found (",,,,,,test, ,,,", "TESt"); errcount += expect_found (",,,,,, test,,,,", "TESt"); errcount += expect_found (",,,,,, test not,test,,", "TESt"); errcount += expect_found (",,,,,, test not,,test,,", "TESt"); errcount += expect_found (",,,,,, test not ,test,,", "TESt"); errcount += expect_found (",,,,,, test", "TESt"); errcount += expect_found (",,,,,, test ", "TESt"); errcount += expect_found ("no test,,,,,, test ", "TESt"); return errcount; } static int check_not_match (void) { int errcount = 0; errcount += expect_not_found ("strin", "string"); errcount += expect_not_found ("Stringer", "string"); errcount += expect_not_found ("sstring", "String"); errcount += expect_not_found ("string", "Strin"); errcount += expect_not_found ("\t( strinG", "String"); errcount += expect_not_found (")strinG\t ", "String"); errcount += expect_not_found (" \t tOkEn t ", "toKEN"); errcount += expect_not_found ("not token\t, tOkEner ", "toKEN"); errcount += expect_not_found ("not token,\t tOkEns, more token", "toKEN"); errcount += expect_not_found ("not token,\t tOkEns\t, more token", "toKEN"); errcount += expect_not_found (",,,,,,testing,,,,", "TESt"); errcount += expect_not_found (",,,,,\t,test,,,,", "TESting"); errcount += expect_not_found ("tests,,,,,,quest, ,,,", "TESt"); errcount += expect_not_found (",,,,,, testÑ‹,,,,", "TESt"); errcount += expect_not_found (",,,,,, test not,Ñ…test,,", "TESt"); errcount += expect_not_found ("testing,,,,,, test not,,test2,,", "TESt"); errcount += expect_not_found (",testi,,,,, test not ,test,,", "TESting"); errcount += expect_not_found (",,,,,,2 test", "TESt"); errcount += expect_not_found (",,,,,,test test ", "test"); errcount += expect_not_found ("no test,,,,,, test test", "test"); return errcount; } int main (int argc, char *argv[]) { int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errcount += check_match (); errcount += check_not_match (); return errcount == 0 ? 0 : 1; } libmicrohttpd-1.0.1/src/microhttpd/mhd_byteorder.h0000644000175000017500000001357014556705750016026 /* This file is part of libmicrohttpd Copyright (C) 2015-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/mhd_byteorder.h * @brief macro definitions for host byte order * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_BYTEORDER_H #define MHD_BYTEORDER_H #include "mhd_options.h" #include #ifdef HAVE_ENDIAN_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifdef HAVE_MACHINE_ENDIAN_H #include #endif #ifdef HAVE_SYS_ENDIAN_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_BYTEORDER_H #include #endif #ifdef HAVE_SYS_MACHINE_H #include #endif #ifdef HAVE_MACHINE_PARAM_H #include #endif #ifdef HAVE_SYS_ISA_DEFS_H #include #endif #define _MHD_BIG_ENDIAN 1234 #define _MHD_LITTLE_ENDIAN 4321 #define _MHD_PDP_ENDIAN 2143 #if defined(__BYTE_ORDER__) #if defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == \ __ORDER_LITTLE_ENDIAN__ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(__ORDER_PDP_ENDIAN__) && __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ #define _MHD_BYTE_ORDER _MHD_PDP_ENDIAN #endif /* __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ */ #elif defined(__BYTE_ORDER) #if defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(__PDP_ENDIAN) && __BYTE_ORDER == __PDP_ENDIAN #define _MHD_BYTE_ORDER _MHD_PDP_ENDIAN #endif /* __BYTE_ORDER == __PDP_ENDIAN */ #elif defined(BYTE_ORDER) #if defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(LITTLE_ENDIAN) && BYTE_ORDER == LITTLE_ENDIAN #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(PDP_ENDIAN) && BYTE_ORDER == PDP_ENDIAN #define _MHD_BYTE_ORDER _MHD_PDP_ENDIAN #endif /* __BYTE_ORDER == _PDP_ENDIAN */ #elif defined(_BYTE_ORDER) #if defined(_BIG_ENDIAN) && _BYTE_ORDER == _BIG_ENDIAN #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(_LITTLE_ENDIAN) && _BYTE_ORDER == _LITTLE_ENDIAN #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(_PDP_ENDIAN) && _BYTE_ORDER == _PDP_ENDIAN #define _MHD_BYTE_ORDER _MHD_PDP_ENDIAN #endif /* _BYTE_ORDER == _PDP_ENDIAN */ #endif /* _BYTE_ORDER */ #ifndef _MHD_BYTE_ORDER /* Byte order specification didn't detected in system headers */ /* Try some guessing */ #if (defined(__BIG_ENDIAN__) && ! defined(__LITTLE_ENDIAN__)) || \ (defined(_BIG_ENDIAN) && ! defined(_LITTLE_ENDIAN)) /* Seems that we are on big endian platform */ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif (defined(__LITTLE_ENDIAN__) && ! defined(__BIG_ENDIAN__)) || \ (defined(_LITTLE_ENDIAN) && ! defined(_BIG_ENDIAN)) /* Seems that we are on little endian platform */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || \ defined(__x86_64) || \ defined(_M_X64) || defined(_M_AMD64) || defined(i386) || defined(__i386) || \ defined(__i386__) || defined(__i486__) || defined(__i586__) || \ defined(__i686__) || \ defined(_M_IX86) || defined(_X86_) || defined(__THW_INTEL__) /* x86 family is little endian */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \ defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) /* Looks like we are on ARM/MIPS in big endian mode */ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \ defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) /* Looks like we are on ARM/MIPS in little endian mode */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(__m68k__) || defined(M68000) || defined(__hppa__) || \ defined(__hppa) || \ defined(__HPPA__) || defined(__370__) || defined(__THW_370__) || \ defined(__s390__) || defined(__s390x__) || defined(__SYSC_ZARCH__) /* Looks like we are on big endian platform */ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #elif defined(__ia64__) || defined(_IA64) || defined(__IA64__) || \ defined(__ia64) || \ defined(_M_IA64) || defined(__itanium__) || defined(__bfin__) || \ defined(__BFIN__) || defined(bfin) || defined(BFIN) /* Looks like we are on little endian platform */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(_WIN32) /* W32 is always little endian on all platforms */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN #elif defined(WORDS_BIGENDIAN) /* Use byte order detected by configure */ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN #endif /* _WIN32 */ #endif /* !_MHD_BYTE_ORDER */ #ifdef _MHD_BYTE_ORDER /* Some safety checks */ #if defined(WORDS_BIGENDIAN) && _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN #error \ Configure detected big endian byte order but headers specify different byte order #elif ! defined(WORDS_BIGENDIAN) && _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN #error \ Configure did not detect big endian byte order but headers specify big endian byte order #endif /* !WORDS_BIGENDIAN && _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN */ #endif /* _MHD_BYTE_ORDER */ #endif /* !MHD_BYTEORDER_H */ libmicrohttpd-1.0.1/src/microhttpd/mhd_md5_wrap.h0000644000175000017500000000553014441373361015532 /* This file is part of GNU libmicrohttpd Copyright (C) 2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GNU libmicrohttpd. If not, see . */ /** * @file microhttpd/mhd_md5_wrap.h * @brief Simple wrapper for selection of built-in/external MD5 implementation * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_MD5_WRAP_H #define MHD_MD5_WRAP_H 1 #include "mhd_options.h" #ifndef MHD_MD5_SUPPORT #error This file must be used only when MD5 is enabled #endif #ifndef MHD_MD5_TLSLIB #include "md5.h" #else /* MHD_MD5_TLSLIB */ #include "md5_ext.h" #endif /* MHD_MD5_TLSLIB */ #ifndef MD5_DIGEST_SIZE /** * Size of MD5 resulting digest in bytes * This is the final digest size, not intermediate hash. */ #define MD5_DIGEST_SIZE (16) #endif /* ! MD5_DIGEST_SIZE */ #ifndef MD5_DIGEST_STRING_SIZE /** * Size of MD5 digest string in chars including termination NUL. */ #define MD5_DIGEST_STRING_SIZE ((MD5_DIGEST_SIZE) * 2 + 1) #endif /* ! MD5_DIGEST_STRING_SIZE */ #ifndef MHD_MD5_TLSLIB /** * Universal ctx type mapped for chosen implementation */ #define Md5CtxWr Md5Ctx #else /* MHD_MD5_TLSLIB */ /** * Universal ctx type mapped for chosen implementation */ #define Md5CtxWr Md5CtxExt #endif /* MHD_MD5_TLSLIB */ #ifndef MHD_MD5_HAS_INIT_ONE_TIME /** * Setup and prepare ctx for hash calculation */ #define MHD_MD5_init_one_time(ctx) MHD_MD5_init(ctx) #endif /* ! MHD_MD5_HAS_INIT_ONE_TIME */ #ifndef MHD_MD5_HAS_FINISH_RESET /** * Re-use the same ctx for the new hashing after digest calculated */ #define MHD_MD5_reset(ctx) MHD_MD5_init(ctx) /** * Finalise MD5 calculation, return digest, reset hash calculation. */ #define MHD_MD5_finish_reset(ctx,digest) MHD_MD5_finish(ctx,digest), \ MHD_MD5_reset(ctx) #else /* MHD_MD5_HAS_FINISH_RESET */ #define MHD_MD5_reset(ctx) (void)0 #endif /* MHD_MD5_HAS_FINISH_RESET */ #ifndef MHD_MD5_HAS_DEINIT #define MHD_MD5_deinit(ignore) (void)0 #endif /* HAVE_MD5_DEINIT */ /* Sanity checks */ #if ! defined(MHD_MD5_HAS_FINISH_RESET) && ! defined(MHD_MD5_HAS_FINISH) #error Required at least one of MHD_MD5_finish_reset(), MHD_MD5_finish_reset() #endif /* ! MHD_MD5_HAS_FINISH_RESET && ! MHD_MD5_HAS_FINISH */ #endif /* MHD_MD5_WRAP_H */ libmicrohttpd-1.0.1/src/microhttpd/mhd_send.h0000644000175000017500000001244514556705750014760 /* This file is part of libmicrohttpd Copyright (C) 2017-2021 Karlson2k (Evgeny Grin) Copyright (C) 2019 ng0 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file mhd_send.h * @brief Declarations of send() wrappers. * @author ng0 * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_SEND_H #define MHD_SEND_H #include "platform.h" #include "internal.h" #if defined(HAVE_STDBOOL_H) #include #endif /* HAVE_STDBOOL_H */ #include #include "mhd_sockets.h" #include "connection.h" #ifdef HTTPS_SUPPORT #include "connection_https.h" #endif #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV) || \ defined(MHD_WINSOCK_SOCKETS) #define MHD_VECT_SEND 1 #endif /* HAVE_SENDMSG || HAVE_WRITEV || MHD_WINSOCK_SOCKETS */ /** * Initialises static variables */ void MHD_send_init_static_vars_ (void); /** * Send buffer to the client, push data from network buffer if requested * and full buffer is sent. * * @param connection the MHD_Connection structure * @param buffer content of the buffer to send * @param buffer_size the size of the @a buffer (in bytes) * @param push_data set to true to force push the data to the network from * system buffers (usually set for the last piece of data), * set to false to prefer holding incomplete network packets * (more data will be send for the same reply). * @return sum of the number of bytes sent from both buffers or * error code (negative) */ ssize_t MHD_send_data_ (struct MHD_Connection *connection, const char *buffer, size_t buffer_size, bool push_data); /** * Send reply header with optional reply body. * * @param connection the MHD_Connection structure * @param header content of header to send * @param header_size the size of the @a header (in bytes) * @param never_push_hdr set to true to disable internal algorithm * that can push automatically header data * alone to the network * @param body content of the body to send (optional, may be NULL) * @param body_size the size of the @a body (in bytes) * @param complete_response set to true if complete response * is provided by @a header and @a body, * set to false if additional body data * will be sent later * @return sum of the number of bytes sent from both buffers or * error code (negative) */ ssize_t MHD_send_hdr_and_body_ (struct MHD_Connection *connection, const char *header, size_t header_size, bool never_push_hdr, const char *body, size_t body_size, bool complete_response); #if defined(_MHD_HAVE_SENDFILE) /** * Function for sending responses backed by file FD. * * @param connection the MHD connection structure * @return actual number of bytes sent */ ssize_t MHD_send_sendfile_ (struct MHD_Connection *connection); #endif /** * Set required TCP_NODELAY state for connection socket * * The function automatically updates sk_nodelay state. * @param connection the connection to manipulate * @param nodelay_state the requested new state of socket * @return true if succeed, false if failed or not supported * by the current platform / kernel. */ bool MHD_connection_set_nodelay_state_ (struct MHD_Connection *connection, bool nodelay_state); /** * Set required cork state for connection socket * * The function automatically updates sk_corked state. * * @param connection the connection to manipulate * @param cork_state the requested new state of socket * @return true if succeed, false if failed or not supported * by the current platform / kernel. */ bool MHD_connection_set_cork_state_ (struct MHD_Connection *connection, bool cork_state); /** * Function for sending responses backed by a an array of memory buffers. * * @param connection the MHD connection structure * @param r_iov the pointer to iov response structure with tracking * @param push_data set to true to force push the data to the network from * system buffers (usually set for the last piece of data), * set to false to prefer holding incomplete network packets * (more data will be send for the same reply). * @return actual number of bytes sent */ ssize_t MHD_send_iovec_ (struct MHD_Connection *connection, struct MHD_iovec_track_ *const r_iov, bool push_data); #endif /* MHD_SEND_H */ libmicrohttpd-1.0.1/src/microhttpd/test_sha512_256.c0000644000175000017500000007264414441373361015627 /* This file is part of libmicrohttpd Copyright (C) 2019-2022 Evgeny Grin (Karlson2k) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_sha512_256.h * @brief Unit tests for SHA-512/256 functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "sha512_256.h" #include "test_helpers.h" #include #include static int verbose = 0; /* verbose level (0-1)*/ struct str_with_len { const char *const str; const size_t len; }; #define D_STR_W_LEN(s) {(s), (sizeof((s)) / sizeof(char)) - 1} struct data_unit1 { const struct str_with_len str_l; const uint8_t digest[SHA512_256_DIGEST_SIZE]; }; static const struct data_unit1 data_units1[] = { {D_STR_W_LEN ("abc"), {0x53, 0x04, 0x8E, 0x26, 0x81, 0x94, 0x1E, 0xF9, 0x9B, 0x2E, 0x29, 0xB7, 0x6B, 0x4C, 0x7D, 0xAB, 0xE4, 0xC2, 0xD0, 0xC6, 0x34, 0xFC, 0x6D, 0x46, 0xE0, 0xE2, 0xF1, 0x31, 0x07, 0xE7, 0xAF, 0x23}}, {D_STR_W_LEN ("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi" \ "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"), {0x39, 0x28, 0xE1, 0x84, 0xFB, 0x86, 0x90, 0xF8, 0x40, 0xDA, 0x39, 0x88, 0x12, 0x1D, 0x31, 0xBE, 0x65, 0xCB, 0x9D, 0x3E, 0xF8, 0x3E, 0xE6, 0x14, 0x6F, 0xEA, 0xC8, 0x61, 0xE1, 0x9B, 0x56, 0x3A}}, {D_STR_W_LEN (""), /* The empty zero-size input */ {0xc6, 0x72, 0xb8, 0xd1, 0xef, 0x56, 0xed, 0x28, 0xab, 0x87, 0xc3, 0x62, 0x2c, 0x51, 0x14, 0x06, 0x9b, 0xdd, 0x3a, 0xd7, 0xb8, 0xf9, 0x73, 0x74, 0x98, 0xd0, 0xc0, 0x1e, 0xce, 0xf0, 0x96, 0x7a}}, {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."), {0xc8, 0x7c, 0x5a, 0x55, 0x27, 0x77, 0x1b, 0xe7, 0x69, 0x3c, 0x50, 0x79, 0x32, 0xad, 0x7c, 0x79, 0xe9, 0x60, 0xa0, 0x18, 0xb7, 0x78, 0x2b, 0x6f, 0xa9, 0x7b, 0xa3, 0xa0, 0xb5, 0x18, 0x17, 0xa5}}, {D_STR_W_LEN ("Simple string."), {0xde, 0xcb, 0x3c, 0x81, 0x65, 0x4b, 0xa0, 0xf5, 0xf0, 0x45, 0x6b, 0x7e, 0x61, 0xf5, 0x0d, 0xf5, 0x38, 0xa4, 0xfc, 0xb1, 0x8a, 0x95, 0xff, 0x59, 0xbc, 0x04, 0x82, 0xcf, 0x23, 0xb2, 0x32, 0x56}}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"), {0xfc, 0x31, 0x89, 0x44, 0x3f, 0x9c, 0x26, 0x8f, 0x62, 0x6a, 0xea, 0x08, 0xa7, 0x56, 0xab, 0xe7, 0xb7, 0x26, 0xb0, 0x5f, 0x70, 0x1c, 0xb0, 0x82, 0x22, 0x31, 0x2c, 0xcf, 0xd6, 0x71, 0x0a, 0x26, }}, {D_STR_W_LEN ("zyxwvutsrqponMLKJIHGFEDCBA"), {0xd2, 0x6d, 0x24, 0x81, 0xa4, 0xf9, 0x0a, 0x72, 0xd2, 0x7f, 0xc1, 0xac, 0xac, 0xe1, 0xc0, 0x6b, 0x39, 0x94, 0xac, 0x73, 0x50, 0x2e, 0x27, 0x97, 0xa3, 0x65, 0x37, 0x4e, 0xbb, 0x5c, 0x27, 0xe9}}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA" \ "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"), {0xad, 0xe9, 0x5d, 0x55, 0x3b, 0x9e, 0x45, 0x69, 0xdb, 0x53, 0xa4, 0x04, 0x92, 0xe7, 0x87, 0x94, 0xff, 0xc9, 0x98, 0x5f, 0x93, 0x03, 0x86, 0x45, 0xe1, 0x97, 0x17, 0x72, 0x7c, 0xbc, 0x31, 0x15}}, {D_STR_W_LEN ("/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/path?with%20some=parameters"), {0xbc, 0xab, 0xc6, 0x2c, 0x0a, 0x22, 0xd5, 0xcb, 0xac, 0xac, 0xe9, 0x25, 0xcf, 0xce, 0xaa, 0xaf, 0x0e, 0xa1, 0xed, 0x42, 0x46, 0x8a, 0xe2, 0x01, 0xee, 0x2f, 0xdb, 0x39, 0x75, 0x47, 0x73, 0xf1}} }; static const size_t units1_num = sizeof(data_units1) / sizeof(data_units1[0]); struct bin_with_len { const uint8_t bin[512]; const size_t len; }; struct data_unit2 { const struct bin_with_len bin_l; const uint8_t digest[SHA512_256_DIGEST_SIZE]; }; /* Size must be less than 512 bytes! */ static const struct data_unit2 data_units2[] = { { { {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}, 26}, /* a..z ASCII sequence */ {0xfc, 0x31, 0x89, 0x44, 0x3f, 0x9c, 0x26, 0x8f, 0x62, 0x6a, 0xea, 0x08, 0xa7, 0x56, 0xab, 0xe7, 0xb7, 0x26, 0xb0, 0x5f, 0x70, 0x1c, 0xb0, 0x82, 0x22, 0x31, 0x2c, 0xcf, 0xd6, 0x71, 0x0a, 0x26}}, { { {65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65}, 72 }, /* 'A' x 72 times */ {0x36, 0x5d, 0x41, 0x0e, 0x55, 0xd1, 0xfd, 0xe6, 0xc3, 0xb8, 0x68, 0xcc, 0xed, 0xeb, 0xcd, 0x0d, 0x2e, 0x34, 0xb2, 0x5c, 0xdf, 0xe7, 0x79, 0xe2, 0xe9, 0x65, 0x07, 0x33, 0x78, 0x0d, 0x01, 0x89}}, { { {19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73}, 55}, /* 19..73 sequence */ {0xb9, 0xe5, 0x74, 0x11, 0xbf, 0xa2, 0x0e, 0x98, 0xbe, 0x08, 0x69, 0x2e, 0x17, 0x9e, 0xc3, 0xfe, 0x61, 0xe3, 0x7a, 0x80, 0x2e, 0x25, 0x8c, 0xf3, 0x76, 0xda, 0x9f, 0x5f, 0xcd, 0x87, 0x48, 0x0d}}, { { {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69}, 63}, /* 7..69 sequence */ {0x80, 0x15, 0x83, 0xed, 0x7d, 0xef, 0x9f, 0xdf, 0xfb, 0x83, 0x1f, 0xc5, 0x8b, 0x50, 0x37, 0x81, 0x00, 0xc3, 0x4f, 0xfd, 0xfe, 0xc2, 0x9b, 0xaf, 0xfe, 0x15, 0x66, 0xe5, 0x08, 0x42, 0x5e, 0xae}}, { { {38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92}, 55}, /* 38..92 sequence */ {0x76, 0x2f, 0x27, 0x4d, 0xfa, 0xd5, 0xa9, 0x21, 0x4e, 0xe9, 0x56, 0x22, 0x54, 0x38, 0x71, 0x3e, 0xef, 0x14, 0xa9, 0x22, 0x37, 0xf3, 0xb0, 0x50, 0x3d, 0x95, 0x40, 0xb7, 0x08, 0x64, 0xa9, 0xfd}}, { { {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72}, 72}, /* 1..72 sequence */ {0x3f, 0x5c, 0xd3, 0xec, 0x40, 0xc4, 0xb9, 0x78, 0x35, 0x57, 0xc6, 0x4f, 0x3e, 0x46, 0x82, 0xdc, 0xd4, 0x46, 0x11, 0xd0, 0xb3, 0x0a, 0xbb, 0x89, 0xf1, 0x1d, 0x34, 0xb5, 0xf9, 0xd5, 0x10, 0x35}}, { { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}, 256}, /* 0..255 sequence */ {0x08, 0x37, 0xa1, 0x1d, 0x99, 0x4d, 0x5a, 0xa8, 0x60, 0xd0, 0x69, 0x17, 0xa8, 0xa0, 0xf6, 0x3e, 0x31, 0x11, 0xb9, 0x56, 0x33, 0xde, 0xeb, 0x15, 0xee, 0xd9, 0x94, 0x93, 0x76, 0xf3, 0x7d, 0x36, }}, { { {199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139}, 61}, /* 199..139 sequence */ {0xcf, 0x21, 0x4b, 0xb2, 0xdd, 0x40, 0x98, 0xdf, 0x3a, 0xb7, 0x21, 0xb4, 0x69, 0x0e, 0x19, 0x36, 0x24, 0xa9, 0xbe, 0x30, 0xf7, 0xd0, 0x75, 0xb0, 0x39, 0x94, 0x82, 0xda, 0x55, 0x97, 0xe4, 0x79}}, { { {255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, 255}, /* 255..1 sequence */ {0x22, 0x31, 0xf2, 0xa1, 0xb4, 0x89, 0xb2, 0x44, 0xf7, 0x66, 0xa0, 0xb8, 0x31, 0xed, 0xb7, 0x73, 0x8a, 0x34, 0xdc, 0x11, 0xc8, 0x2c, 0xf2, 0xb5, 0x88, 0x60, 0x39, 0x6b, 0x5c, 0x06, 0x70, 0x37}}, { { {41, 35, 190, 132, 225, 108, 214, 174, 82, 144, 73, 241, 241, 187, 233, 235, 179, 166, 219, 60, 135, 12, 62, 153, 36, 94, 13, 28, 6, 183, 71, 222, 179, 18, 77, 200, 67, 187, 139, 166, 31, 3, 90, 125, 9, 56, 37, 31, 93, 212, 203, 252, 150, 245, 69, 59, 19, 13, 137, 10, 28, 219, 174, 50, 32, 154, 80, 238, 64, 120, 54, 253, 18, 73, 50, 246, 158, 125, 73, 220, 173, 79, 20, 242, 68, 64, 102, 208, 107, 196, 48, 183, 50, 59, 161, 34, 246, 34, 145, 157, 225, 139, 31, 218, 176, 202, 153, 2, 185, 114, 157, 73, 44, 128, 126, 197, 153, 213, 233, 128, 178, 234, 201, 204, 83, 191, 103, 214, 191, 20, 214, 126, 45, 220, 142, 102, 131, 239, 87, 73, 97, 255, 105, 143, 97, 205, 209, 30, 157, 156, 22, 114, 114, 230, 29, 240, 132, 79, 74, 119, 2, 215, 232, 57, 44, 83, 203, 201, 18, 30, 51, 116, 158, 12, 244, 213, 212, 159, 212, 164, 89, 126, 53, 207, 50, 34, 244, 204, 207, 211, 144, 45, 72, 211, 143, 117, 230, 217, 29, 42, 229, 192, 247, 43, 120, 129, 135, 68, 14, 95, 80, 0, 212, 97, 141, 190, 123, 5, 21, 7, 59, 51, 130, 31, 24, 112, 146, 218, 100, 84, 206, 177, 133, 62, 105, 21, 248, 70, 106, 4, 150, 115, 14, 217, 22, 47, 103, 104, 212, 247, 74, 74, 208, 87, 104}, 255}, /* pseudo-random data */ {0xb8, 0xdb, 0x2c, 0x2e, 0xf3, 0x12, 0x77, 0x14, 0xf9, 0x34, 0x2d, 0xfa, 0xda, 0x42, 0xbe, 0xfe, 0x67, 0x3a, 0x8a, 0xf6, 0x71, 0x36, 0x00, 0xff, 0x77, 0xa5, 0x83, 0x14, 0x55, 0x2a, 0x05, 0xaf}}, { { {66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66}, 110}, /* 'B' x 110 times */ {0xc8, 0x9e, 0x0d, 0x8f, 0x7b, 0x35, 0xfd, 0x3e, 0xdc, 0x90, 0x87, 0x64, 0x45, 0x94, 0x94, 0x21, 0xb3, 0x8e, 0xb5, 0xc7, 0x54, 0xc8, 0xee, 0xde, 0xfc, 0x77, 0xd6, 0xe3, 0x9f, 0x81, 0x8e, 0x78}}, { { {67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67}, 111}, /* 'C' x 111 times */ {0x86, 0xca, 0x6d, 0x2a, 0x72, 0xe2, 0x8c, 0x17, 0x89, 0x86, 0x89, 0x1b, 0x36, 0xf9, 0x6d, 0xda, 0x8c, 0xd6, 0x30, 0xb2, 0xd3, 0x60, 0x39, 0xfb, 0xc9, 0x04, 0xc5, 0x11, 0xcd, 0x2d, 0xe3, 0x62}}, { { {68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68}, 112}, /* 'D' x 112 times */ {0xdf, 0x9d, 0x4a, 0xcf, 0x81, 0x0d, 0x3a, 0xd4, 0x8e, 0xa4, 0x65, 0x9e, 0x1e, 0x15, 0xe4, 0x15, 0x1b, 0x37, 0xb6, 0xeb, 0x17, 0xab, 0xf6, 0xb1, 0xbc, 0x30, 0x46, 0x34, 0x24, 0x56, 0x1c, 0x06}}, { { {69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69}, 113}, /* 'E' x 113 times */ {0xa5, 0xf1, 0x47, 0x74, 0xf8, 0x2b, 0xed, 0x23, 0xe4, 0x10, 0x59, 0x8f, 0x7e, 0xb1, 0x30, 0xe5, 0x7e, 0xd1, 0x4b, 0xbc, 0x72, 0x58, 0x58, 0x81, 0xbb, 0xa0, 0xa5, 0xb6, 0x15, 0x39, 0x49, 0xa1}}, { { {70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70}, 114}, /* 'F' x 114 times */ {0xe6, 0xa3, 0xc9, 0x63, 0xd5, 0x28, 0x6e, 0x2d, 0xfb, 0x71, 0xdf, 0xd4, 0xff, 0xc2, 0xd4, 0x2b, 0x5d, 0x9b, 0x76, 0x28, 0xd2, 0xcb, 0x15, 0xc8, 0x81, 0x57, 0x14, 0x09, 0xc3, 0x8e, 0x92, 0xce}}, { { {76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76}, 127}, /* 'L' x 127 times */ {0x5d, 0x18, 0xff, 0xd7, 0xbe, 0x23, 0xb2, 0xb2, 0xbd, 0xe3, 0x13, 0x12, 0x1c, 0x16, 0x89, 0x14, 0x4a, 0x42, 0xb4, 0x3f, 0xab, 0xc8, 0x41, 0x14, 0x62, 0x00, 0xb5, 0x53, 0xa7, 0xd6, 0xd5, 0x35}}, { { {77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77}, 128}, /* 'M' x 128 times */ {0x6e, 0xf0, 0xda, 0x81, 0x3d, 0x50, 0x1d, 0x31, 0xf1, 0x4a, 0xf8, 0xd9, 0x7d, 0xd2, 0x13, 0xdd, 0xa4, 0x46, 0x15, 0x0b, 0xb8, 0x5a, 0x8a, 0xc6, 0x1e, 0x3a, 0x1f, 0x21, 0x35, 0xa2, 0xbb, 0x4f}}, { { {78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78}, 129}, /* 'N' x 129 times */ {0xee, 0xce, 0xd5, 0x34, 0xab, 0x14, 0x13, 0x9e, 0x8f, 0x5c, 0xb4, 0xef, 0xac, 0xaf, 0xc5, 0xeb, 0x1d, 0x2f, 0xe3, 0xc5, 0xca, 0x09, 0x29, 0x96, 0xfa, 0x84, 0xff, 0x12, 0x26, 0x6a, 0x50, 0x49}}, { { {97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97}, 238}, /* 'a' x 238 times */ {0xb4, 0x24, 0xe5, 0x7b, 0xa7, 0x37, 0xe3, 0xc4, 0xac, 0x35, 0x21, 0x17, 0x98, 0xec, 0xb9, 0xae, 0x45, 0x13, 0x24, 0xa4, 0x2c, 0x76, 0xae, 0x7d, 0x17, 0x75, 0x27, 0x8a, 0xaa, 0x4a, 0x48, 0x60}}, { { {98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98}, 239}, /* 'b' x 239 times */ {0xcd, 0x93, 0xb8, 0xab, 0x6a, 0x74, 0xbd, 0x34, 0x8c, 0x43, 0x76, 0x0c, 0x2a, 0xd0, 0x6e, 0xd8, 0x76, 0xcf, 0xdf, 0x2a, 0x21, 0x04, 0xfb, 0xf6, 0x16, 0x53, 0x68, 0xf6, 0x10, 0xc3, 0xa1, 0xac}}, { { {99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}, 240}, /* 'c' x 240 times */ {0x5f, 0x60, 0xea, 0x44, 0xb6, 0xc6, 0x9e, 0xfe, 0xfc, 0x0e, 0x6a, 0x0a, 0x99, 0x40, 0x1b, 0x61, 0x43, 0x58, 0xba, 0x4a, 0x0a, 0xee, 0x6b, 0x52, 0x10, 0xdb, 0x32, 0xd9, 0x7f, 0x12, 0xba, 0x70}}, { { {48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48}, 241}, /* '0' x 241 times */ {0x3c, 0xcb, 0xcf, 0x50, 0x79, 0xd5, 0xb6, 0xf5, 0xbf, 0x25, 0x07, 0xfb, 0x4d, 0x1f, 0xa3, 0x77, 0xc3, 0x6f, 0xe8, 0xe3, 0xc4, 0x4b, 0xf8, 0xcd, 0x90, 0x93, 0xf1, 0x3e, 0x08, 0x09, 0xa7, 0x69}} }; static const size_t units2_num = sizeof(data_units2) / sizeof(data_units2[0]); /* * Helper functions */ /** * Print bin as hex * * @param bin binary data * @param len number of bytes in bin * @param hex pointer to len*2+1 bytes buffer */ static void bin2hex (const uint8_t *bin, size_t len, char *hex) { while (len-- > 0) { unsigned int b1, b2; b1 = (*bin >> 4) & 0xf; *hex++ = (char) ((b1 > 9) ? (b1 + 'A' - 10) : (b1 + '0')); b2 = *bin++ & 0xf; *hex++ = (char) ((b2 > 9) ? (b2 + 'A' - 10) : (b2 + '0')); } *hex = 0; } static int check_result (const char *test_name, unsigned int check_num, const uint8_t calculated[SHA512_256_DIGEST_SIZE], const uint8_t expected[SHA512_256_DIGEST_SIZE]) { int failed = memcmp (calculated, expected, SHA512_256_DIGEST_SIZE); check_num++; /* Print 1-based numbers */ if (failed) { char calc_str[SHA512_256_DIGEST_SIZE * 2 + 1]; char expc_str[SHA512_256_DIGEST_SIZE * 2 + 1]; bin2hex (calculated, SHA512_256_DIGEST_SIZE, calc_str); bin2hex (expected, SHA512_256_DIGEST_SIZE, expc_str); fprintf (stderr, "FAILED: %s check %u: calculated digest %s, expected digest %s.\n", test_name, check_num, calc_str, expc_str); fflush (stderr); } else if (verbose) { char calc_str[SHA512_256_DIGEST_SIZE * 2 + 1]; bin2hex (calculated, SHA512_256_DIGEST_SIZE, calc_str); printf ("PASSED: %s check %u: calculated digest %s matches " \ "expected digest.\n", test_name, check_num, calc_str); fflush (stdout); } return failed ? 1 : 0; } /* * Tests */ /* Calculated SHA-512/256 as one pass for whole data */ static int test1_str (void) { int num_failed = 0; unsigned int i; struct Sha512_256Ctx ctx; for (i = 0; i < units1_num; i++) { uint8_t digest[SHA512_256_DIGEST_SIZE]; MHD_SHA512_256_init (&ctx); MHD_SHA512_256_update (&ctx, (const uint8_t *) data_units1[i].str_l.str, data_units1[i].str_l.len); MHD_SHA512_256_finish (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units1[i].digest); } return num_failed; } static int test1_bin (void) { int num_failed = 0; unsigned int i; struct Sha512_256Ctx ctx; for (i = 0; i < units2_num; i++) { uint8_t digest[SHA512_256_DIGEST_SIZE]; MHD_SHA512_256_init (&ctx); MHD_SHA512_256_update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len); MHD_SHA512_256_finish (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units2[i].digest); } return num_failed; } /* Calculated SHA-512/256 as two iterations for whole data */ static int test2_str (void) { int num_failed = 0; unsigned int i; struct Sha512_256Ctx ctx; for (i = 0; i < units1_num; i++) { uint8_t digest[SHA512_256_DIGEST_SIZE]; size_t part_s = data_units1[i].str_l.len / 4; MHD_SHA512_256_init (&ctx); MHD_SHA512_256_update (&ctx, (const uint8_t *) "", 0); MHD_SHA512_256_update (&ctx, (const uint8_t *) data_units1[i].str_l.str, part_s); MHD_SHA512_256_update (&ctx, (const uint8_t *) "", 0); MHD_SHA512_256_update (&ctx, (const uint8_t *) data_units1[i].str_l.str + part_s, data_units1[i].str_l.len - part_s); MHD_SHA512_256_update (&ctx, (const uint8_t *) "", 0); MHD_SHA512_256_finish (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units1[i].digest); } return num_failed; } static int test2_bin (void) { int num_failed = 0; unsigned int i; struct Sha512_256Ctx ctx; for (i = 0; i < units2_num; i++) { uint8_t digest[SHA512_256_DIGEST_SIZE]; size_t part_s = data_units2[i].bin_l.len * 2 / 3; MHD_SHA512_256_init (&ctx); MHD_SHA512_256_update (&ctx, data_units2[i].bin_l.bin, part_s); MHD_SHA512_256_update (&ctx, (const uint8_t *) "", 0); MHD_SHA512_256_update (&ctx, data_units2[i].bin_l.bin + part_s, data_units2[i].bin_l.len - part_s); MHD_SHA512_256_finish (&ctx, digest); num_failed += check_result (__FUNCTION__, i, digest, data_units2[i].digest); } return num_failed; } /* Use data set number 7 as it has the longest sequence */ #define DATA_POS 6 #define MAX_OFFSET 63 static int test_unaligned (void) { int num_failed = 0; unsigned int offset; uint8_t *buf; uint8_t *digest_buf; struct Sha512_256Ctx ctx; const struct data_unit2 *const tdata = data_units2 + DATA_POS; buf = malloc (tdata->bin_l.len + MAX_OFFSET); digest_buf = malloc (SHA512_256_DIGEST_SIZE + MAX_OFFSET); if ((NULL == buf) || (NULL == digest_buf)) exit (99); for (offset = MAX_OFFSET; offset >= 1; --offset) { uint8_t *unaligned_digest; uint8_t *unaligned_buf; unaligned_buf = buf + offset; memcpy (unaligned_buf, tdata->bin_l.bin, tdata->bin_l.len); unaligned_digest = digest_buf + MAX_OFFSET - offset; memset (unaligned_digest, 0, SHA512_256_DIGEST_SIZE); MHD_SHA512_256_init (&ctx); MHD_SHA512_256_update (&ctx, unaligned_buf, tdata->bin_l.len); MHD_SHA512_256_finish (&ctx, unaligned_digest); num_failed += check_result (__FUNCTION__, MAX_OFFSET - offset, unaligned_digest, tdata->digest); } free (digest_buf); free (buf); return num_failed; } int main (int argc, char *argv[]) { int num_failed = 0; (void) has_in_name; /* Mute compiler warning. */ if (has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose")) verbose = 1; num_failed += test1_str (); num_failed += test1_bin (); num_failed += test2_str (); num_failed += test2_bin (); num_failed += test_unaligned (); return num_failed ? 1 : 0; } libmicrohttpd-1.0.1/src/microhttpd/test_str_pct.c0000644000175000017500000011247514441373361015703 /* This file is part of libmicrohttpd Copyright (C) 2022 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_str_pct.c * @brief Unit tests for percent (URL) encoded strings processing * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include "mhd_str.h" #include "mhd_assert.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ static char tmp_bufs[4][4 * 1024]; /* should be enough for testing */ static size_t buf_idx = 0; /* print non-printable chars as char codes */ static char * n_prnt (const char *str, size_t len) { static char *buf; /* should be enough for testing */ static const size_t buf_size = sizeof(tmp_bufs[0]); size_t r_pos = 0; size_t w_pos = 0; if (++buf_idx >= (sizeof(tmp_bufs) / sizeof(tmp_bufs[0]))) buf_idx = 0; buf = tmp_bufs[buf_idx]; while (len > r_pos && w_pos + 1 < buf_size) { const unsigned char c = (unsigned char) str[r_pos]; if ((c == '\\') || (c == '"') ) { if (w_pos + 2 >= buf_size) break; buf[w_pos++] = '\\'; buf[w_pos++] = (char) c; } else if ((c >= 0x20) && (c <= 0x7E) ) buf[w_pos++] = (char) c; else { if (w_pos + 4 >= buf_size) break; if (snprintf (buf + w_pos, buf_size - w_pos, "\\x%02hX", (short unsigned int) c) != 4) break; w_pos += 4; } r_pos++; } if (len != r_pos) { /* not full string is printed */ /* enough space for "..." ? */ if (w_pos + 3 > buf_size) w_pos = buf_size - 4; buf[w_pos++] = '.'; buf[w_pos++] = '.'; buf[w_pos++] = '.'; } buf[w_pos] = 0; return buf; } #define TEST_BIN_MAX_SIZE 1024 /* return zero if succeed, number of failures otherwise */ static unsigned int expect_decoded_n (const char *const encoded, const size_t encoded_len, const char *const decoded, const size_t decoded_size, const unsigned int line_num) { static const char fill_chr = '#'; static char buf[TEST_BIN_MAX_SIZE]; size_t res_size; unsigned int ret; mhd_assert (NULL != encoded); mhd_assert (NULL != decoded); mhd_assert (TEST_BIN_MAX_SIZE > decoded_size + 1); mhd_assert (TEST_BIN_MAX_SIZE > encoded_len + 1); mhd_assert (encoded_len >= decoded_size); ret = 0; /* check MHD_str_pct_decode_strict_n_() with small out buffer */ if (1) { unsigned int check_res = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_strict_n_ (encoded, encoded_len, buf, decoded_size + 1); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_strict_n_ ()' FAILED: " "Wrong returned value:\n"); } else { if (fill_chr != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_strict_n_ ()' FAILED: " "A char written outside the buffer:\n"); } else { memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_strict_n_ (encoded, encoded_len, buf, decoded_size); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_strict_n_ ()' FAILED: " "Wrong returned value:\n"); } } if ((res_size == decoded_size) && (0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size))) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_strict_n_ ()' FAILED: " "Wrong output string:\n"); } } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_strict_n_ (\"%s\", %u, " "->\"%s\", %u) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (buf, res_size), (unsigned) decoded_size, (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_strict_n_ (\"%s\", %u, " "->\"%s\", %u) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (decoded, decoded_size), (unsigned) decoded_size, (unsigned) decoded_size); } } /* check MHD_str_pct_decode_strict_n_() with large out buffer */ if (1) { unsigned int check_res = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_strict_n_ (encoded, encoded_len, buf, encoded_len + 1); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_strict_n_ ()' FAILED: " "Wrong returned value:\n"); } else { if (fill_chr != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_strict_n_ ()' FAILED: " "A char written outside the buffer:\n"); } if ((res_size == decoded_size) && (0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size))) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_strict_n_ ()' FAILED: " "Wrong output string:\n"); } } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_strict_n_ (\"%s\", %u, " "->\"%s\", %u) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (buf, res_size), (unsigned) (encoded_len + 1), (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_strict_n_ (\"%s\", %u, " "->\"%s\", %u) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (decoded, decoded_size), (unsigned) (encoded_len + 1), (unsigned) decoded_size); } } /* check MHD_str_pct_decode_lenient_n_() with small out buffer */ if (1) { unsigned int check_res = 0; bool is_broken = true; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_lenient_n_ (encoded, encoded_len, buf, decoded_size + 1, &is_broken); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong returned value:\n"); } else { if (fill_chr != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "A char written outside the buffer:\n"); } else { is_broken = true; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_lenient_n_ (encoded, encoded_len, buf, decoded_size, &is_broken); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong returned value:\n"); } } if (is_broken) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong 'broken_encoding' result:\n"); } if ((res_size == decoded_size) && (0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size))) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong output string:\n"); } } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_lenient_n_ (\"%s\", %u, " "->\"%s\", %u, ->%s) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (buf, res_size), (unsigned) decoded_size, is_broken ? "true" : "false", (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_lenient_n_ (\"%s\", %u, " "->\"%s\", %u, ->false) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (decoded, decoded_size), (unsigned) decoded_size, (unsigned) decoded_size); } } /* check MHD_str_pct_decode_lenient_n_() with large out buffer */ if (1) { unsigned int check_res = 0; bool is_broken = true; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_lenient_n_ (encoded, encoded_len, buf, encoded_len + 1, &is_broken); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong returned value:\n"); } else { if (fill_chr != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "A char written outside the buffer:\n"); } if (is_broken) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong 'broken_encoding' result:\n"); } if ((res_size == decoded_size) && (0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size))) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong output string:\n"); } } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_lenient_n_ (\"%s\", %u, " "->\"%s\", %u, ->%s) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (buf, res_size), (unsigned) (encoded_len + 1), is_broken ? "true" : "false", (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_lenient_n_ (\"%s\", %u, " "->\"%s\", %u, ->false) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (decoded, decoded_size), (unsigned) (encoded_len + 1), (unsigned) decoded_size); } } if (strlen (encoded) == encoded_len) { /* check MHD_str_pct_decode_in_place_strict_() */ if (1) { unsigned int check_res = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ memcpy (buf, encoded, encoded_len); buf[encoded_len] = 0; res_size = MHD_str_pct_decode_in_place_strict_ (buf); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_strict_ ()' FAILED: " "Wrong returned value:\n"); } else { if (0 != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_strict_ ()' FAILED: " "The result is not zero-terminated:\n"); } if (((res_size + 1) < encoded_len) ? (encoded[res_size + 1] != buf[res_size + 1]) : (fill_chr != buf[res_size + 1])) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_strict_ ()' FAILED: " "A char written outside the buffer:\n"); } if ((res_size == decoded_size) && (0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size))) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_strict_ ()' FAILED: " "Wrong output string:\n"); } } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_in_place_strict_ (\"%s\" " "-> \"%s\") -> %u\n", n_prnt (encoded, encoded_len), n_prnt (buf, res_size), (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_in_place_strict_ (\"%s\" " "-> \"%s\") -> %u\n", n_prnt (encoded, encoded_len), n_prnt (decoded, decoded_size), (unsigned) decoded_size); } } /* check MHD_str_pct_decode_in_place_lenient_() */ if (1) { unsigned int check_res = 0; bool is_broken = true; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ memcpy (buf, encoded, encoded_len); buf[encoded_len] = 0; res_size = MHD_str_pct_decode_in_place_lenient_ (buf, &is_broken); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_lenient_ ()' FAILED: " "Wrong returned value:\n"); } else { if (0 != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_lenient_ ()' FAILED: " "The result is not zero-terminated:\n"); } if (((res_size + 1) < encoded_len) ? (encoded[res_size + 1] != buf[res_size + 1]) : (fill_chr != buf[res_size + 1])) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_lenient_ ()' FAILED: " "A char written outside the buffer:\n"); } if (is_broken) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_lenient_ ()' FAILED: " "Wrong 'broken_encoding' result:\n"); } if ((res_size == decoded_size) && (0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size))) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_lenient_ ()' FAILED: " "Wrong output string:\n"); } } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_in_place_lenient_ (\"%s\" " "-> \"%s\", ->%s) -> %u\n", n_prnt (encoded, encoded_len), n_prnt (buf, res_size), is_broken ? "true" : "false", (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_in_place_lenient_ (\"%s\" " "-> \"%s\", ->false) -> %u\n", n_prnt (encoded, encoded_len), n_prnt (decoded, decoded_size), (unsigned) decoded_size); } } } if (0 != ret) { fprintf (stderr, "The check is at line: %u\n\n", line_num); } return ret; } #define expect_decoded(e,d) \ expect_decoded_n(e,MHD_STATICSTR_LEN_(e),\ d,MHD_STATICSTR_LEN_(d), \ __LINE__) static unsigned int check_decode_str (void) { unsigned int r = 0; /**< The number of errors */ r += expect_decoded ("", ""); /* Base sequences without percent symbol */ r += expect_decoded ("aaa", "aaa"); r += expect_decoded ("bbb", "bbb"); r += expect_decoded ("ccc", "ccc"); r += expect_decoded ("ddd", "ddd"); r += expect_decoded ("lll", "lll"); r += expect_decoded ("mmm", "mmm"); r += expect_decoded ("nnn", "nnn"); r += expect_decoded ("ooo", "ooo"); r += expect_decoded ("www", "www"); r += expect_decoded ("xxx", "xxx"); r += expect_decoded ("yyy", "yyy"); r += expect_decoded ("zzz", "zzz"); r += expect_decoded ("AAA", "AAA"); r += expect_decoded ("GGG", "GGG"); r += expect_decoded ("MMM", "MMM"); r += expect_decoded ("TTT", "TTT"); r += expect_decoded ("ZZZ", "ZZZ"); r += expect_decoded ("012", "012"); r += expect_decoded ("345", "345"); r += expect_decoded ("678", "678"); r += expect_decoded ("901", "901"); r += expect_decoded ("aaaaaa", "aaaaaa"); r += expect_decoded ("bbbbbb", "bbbbbb"); r += expect_decoded ("cccccc", "cccccc"); r += expect_decoded ("dddddd", "dddddd"); r += expect_decoded ("llllll", "llllll"); r += expect_decoded ("mmmmmm", "mmmmmm"); r += expect_decoded ("nnnnnn", "nnnnnn"); r += expect_decoded ("oooooo", "oooooo"); r += expect_decoded ("wwwwww", "wwwwww"); r += expect_decoded ("xxxxxx", "xxxxxx"); r += expect_decoded ("yyyyyy", "yyyyyy"); r += expect_decoded ("zzzzzz", "zzzzzz"); r += expect_decoded ("AAAAAA", "AAAAAA"); r += expect_decoded ("GGGGGG", "GGGGGG"); r += expect_decoded ("MMMMMM", "MMMMMM"); r += expect_decoded ("TTTTTT", "TTTTTT"); r += expect_decoded ("ZZZZZZ", "ZZZZZZ"); r += expect_decoded ("012012", "012012"); r += expect_decoded ("345345", "345345"); r += expect_decoded ("678678", "678678"); r += expect_decoded ("901901", "901901"); r += expect_decoded ("a", "a"); r += expect_decoded ("bc", "bc"); r += expect_decoded ("DEFG", "DEFG"); r += expect_decoded ("123t", "123t"); r += expect_decoded ("12345", "12345"); r += expect_decoded ("TestStr", "TestStr"); r += expect_decoded ("Teststring", "Teststring"); r += expect_decoded ("Teststring.", "Teststring."); r += expect_decoded ("Longerstring", "Longerstring"); r += expect_decoded ("Longerstring.", "Longerstring."); r += expect_decoded ("Longerstring2.", "Longerstring2."); /* Simple percent-encoded strings */ r += expect_decoded ("Test%20string", "Test string"); r += expect_decoded ("Test%3Fstring.", "Test?string."); r += expect_decoded ("100%25", "100%"); r += expect_decoded ("a%2C%20b%3Dc%26e%3Dg", "a, b=c&e=g"); r += expect_decoded ("%20%21%23%24%25%26%27%28%29%2A%2B%2C" "%2F%3A%3B%3D%3F%40%5B%5D%09", " !#$%&'()*+,/:;=?@[]\t"); return r; } #define expect_decoded_arr(e,a) \ expect_decoded_n(e,MHD_STATICSTR_LEN_(e),\ (const char *)a,(sizeof(a)/sizeof(a[0])), \ __LINE__) static unsigned int check_decode_bin (void) { unsigned int r = 0; /**< The number of errors */ if (1) { static const uint8_t bin[256] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; /* The lower case */ r += expect_decoded_arr ("%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e" \ "%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d" \ "%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c" \ "%2d%2e%2f%30%31%32%33%34%35%36%37%38%39%3a%3b" \ "%3c%3d%3e%3f%40%41%42%43%44%45%46%47%48%49%4a" \ "%4b%4c%4d%4e%4f%50%51%52%53%54%55%56%57%58%59" \ "%5a%5b%5c%5d%5e%5f%60%61%62%63%64%65%66%67%68" \ "%69%6a%6b%6c%6d%6e%6f%70%71%72%73%74%75%76%77" \ "%78%79%7a%7b%7c%7d%7e%7f%80%81%82%83%84%85%86" \ "%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95" \ "%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4" \ "%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3" \ "%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2" \ "%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1" \ "%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0" \ "%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef" \ "%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe" \ "%ff", bin); } if (1) { static const uint8_t bin[256] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; /* The upper case */ r += expect_decoded_arr ("%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E" \ "%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D" \ "%1E%1F%20%21%22%23%24%25%26%27%28%29%2A%2B%2C" \ "%2D%2E%2F%30%31%32%33%34%35%36%37%38%39%3A%3B" \ "%3C%3D%3E%3F%40%41%42%43%44%45%46%47%48%49%4A" \ "%4B%4C%4D%4E%4F%50%51%52%53%54%55%56%57%58%59" \ "%5A%5B%5C%5D%5E%5F%60%61%62%63%64%65%66%67%68" \ "%69%6A%6B%6C%6D%6E%6F%70%71%72%73%74%75%76%77" \ "%78%79%7A%7B%7C%7D%7E%7F%80%81%82%83%84%85%86" \ "%87%88%89%8A%8B%8C%8D%8E%8F%90%91%92%93%94%95" \ "%96%97%98%99%9A%9B%9C%9D%9E%9F%A0%A1%A2%A3%A4" \ "%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF%B0%B1%B2%B3" \ "%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF%C0%C1%C2" \ "%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1" \ "%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0" \ "%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF" \ "%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE" \ "%FF", bin); } return r; } /* return zero if succeed, number of failures otherwise */ static unsigned int expect_decoded_bad_n (const char *const encoded, const size_t encoded_len, const char *const decoded, const size_t decoded_size, const unsigned int line_num) { static const char fill_chr = '#'; static char buf[TEST_BIN_MAX_SIZE]; size_t res_size; unsigned int ret; mhd_assert (NULL != encoded); mhd_assert (NULL != decoded); mhd_assert (TEST_BIN_MAX_SIZE > decoded_size + 1); mhd_assert (TEST_BIN_MAX_SIZE > encoded_len + 1); mhd_assert (encoded_len >= decoded_size); ret = 0; /* check MHD_str_pct_decode_strict_n_() with small out buffer */ if (1) { unsigned int check_res = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_strict_n_ (encoded, encoded_len, buf, decoded_size); if (res_size != 0) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_strict_n_ ()' FAILED: " "Wrong returned value:\n"); } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_strict_n_ (\"%s\", %u, " "->\"%s\", %u) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (buf, res_size), (unsigned) decoded_size, (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_strict_n_ (\"%s\", %u, " "->(not defined), %u) -> 0\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, (unsigned) decoded_size); } } /* check MHD_str_pct_decode_strict_n_() with large out buffer */ if (1) { unsigned int check_res = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_strict_n_ (encoded, encoded_len, buf, encoded_len + 1); if (res_size != 0) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_strict_n_ ()' FAILED: " "Wrong returned value:\n"); } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_strict_n_ (\"%s\", %u, " "->\"%s\", %u) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (buf, res_size), (unsigned) (encoded_len + 1), (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_strict_n_ (\"%s\", %u, " "->(not defined), %u) -> 0\n", n_prnt (encoded, encoded_len), (unsigned) (encoded_len + 1), (unsigned) decoded_size); } } /* check MHD_str_pct_decode_lenient_n_() with small out buffer */ if (1) { unsigned int check_res = 0; bool is_broken = false; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_lenient_n_ (encoded, encoded_len, buf, decoded_size + 1, &is_broken); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong returned value:\n"); } else { if (fill_chr != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "A char written outside the buffer:\n"); } else { is_broken = false; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_lenient_n_ (encoded, encoded_len, buf, decoded_size, &is_broken); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong returned value:\n"); } } if (! is_broken) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong 'broken_encoding' result:\n"); } if ((res_size == decoded_size) && (0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size))) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong output string:\n"); } } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_lenient_n_ (\"%s\", %u, " "->\"%s\", %u, ->%s) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (buf, res_size), (unsigned) decoded_size, is_broken ? "true" : "false", (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_lenient_n_ (\"%s\", %u, " "->\"%s\", %u, ->true) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (decoded, decoded_size), (unsigned) decoded_size, (unsigned) decoded_size); } } /* check MHD_str_pct_decode_lenient_n_() with large out buffer */ if (1) { unsigned int check_res = 0; bool is_broken = false; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_str_pct_decode_lenient_n_ (encoded, encoded_len, buf, encoded_len + 1, &is_broken); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong returned value:\n"); } else { if (fill_chr != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "A char written outside the buffer:\n"); } if (! is_broken) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong 'broken_encoding' result:\n"); } if ((res_size == decoded_size) && (0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size))) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_lenient_n_ ()' FAILED: " "Wrong output string:\n"); } } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_lenient_n_ (\"%s\", %u, " "->\"%s\", %u, ->%s) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (buf, res_size), (unsigned) (encoded_len + 1), is_broken ? "true" : "false", (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_lenient_n_ (\"%s\", %u, " "->\"%s\", %u, ->true) -> %u\n", n_prnt (encoded, encoded_len), (unsigned) encoded_len, n_prnt (decoded, decoded_size), (unsigned) (encoded_len + 1), (unsigned) decoded_size); } } if (strlen (encoded) == encoded_len) { /* check MHD_str_pct_decode_in_place_strict_() */ if (1) { unsigned int check_res = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ memcpy (buf, encoded, encoded_len); buf[encoded_len] = 0; res_size = MHD_str_pct_decode_in_place_strict_ (buf); if (res_size != 0) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_strict_ ()' FAILED: " "Wrong returned value:\n"); } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_in_place_strict_ (\"%s\" " "-> \"%s\") -> %u\n", n_prnt (encoded, encoded_len), n_prnt (buf, res_size), (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_in_place_strict_ (\"%s\" " "-> (not defined)) -> 0\n", n_prnt (encoded, encoded_len)); } } /* check MHD_str_pct_decode_in_place_lenient_() */ if (1) { unsigned int check_res = 0; bool is_broken = false; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ memcpy (buf, encoded, encoded_len); buf[encoded_len] = 0; res_size = MHD_str_pct_decode_in_place_lenient_ (buf, &is_broken); if (res_size != decoded_size) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_lenient_ ()' FAILED: " "Wrong returned value:\n"); } else { if (0 != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_lenient_ ()' FAILED: " "The result is not zero-terminated:\n"); } if (((res_size + 1) < encoded_len) ? (encoded[res_size + 1] != buf[res_size + 1]) : (fill_chr != buf[res_size + 1])) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_lenient_ ()' FAILED: " "A char written outside the buffer:\n"); } if (! is_broken) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_lenient_ ()' FAILED: " "Wrong 'broken_encoding' result:\n"); } if ((res_size == decoded_size) && (0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size))) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_in_place_lenient_ ()' FAILED: " "Wrong output string:\n"); } } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_str_pct_decode_in_place_lenient_ (\"%s\" " "-> \"%s\", ->%s) -> %u\n", n_prnt (encoded, encoded_len), n_prnt (buf, res_size), is_broken ? "true" : "false", (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_str_pct_decode_in_place_lenient_ (\"%s\" " "-> \"%s\", ->true) -> %u\n", n_prnt (encoded, encoded_len), n_prnt (decoded, decoded_size), (unsigned) decoded_size); } } } if (0 != ret) { fprintf (stderr, "The check is at line: %u\n\n", line_num); } return ret; } #define expect_decoded_bad(e,d) \ expect_decoded_bad_n(e,MHD_STATICSTR_LEN_(e),\ d,MHD_STATICSTR_LEN_(d), \ __LINE__) static unsigned int check_decode_bad_str (void) { unsigned int r = 0; /**< The number of errors */ r += expect_decoded_bad ("50%/50%", "50%/50%"); r += expect_decoded_bad ("This is 100% incorrect.", "This is 100% incorrect."); r += expect_decoded_bad ("Some %%", "Some %%"); r += expect_decoded_bad ("1 %", "1 %"); r += expect_decoded_bad ("%", "%"); r += expect_decoded_bad ("%a", "%a"); r += expect_decoded_bad ("%0", "%0"); r += expect_decoded_bad ("%0x", "%0x"); r += expect_decoded_bad ("%FX", "%FX"); r += expect_decoded_bad ("Valid%20and%2invalid", "Valid and%2invalid"); return r; } int main (int argc, char *argv[]) { unsigned int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errcount += check_decode_str (); errcount += check_decode_bin (); errcount += check_decode_bad_str (); if (0 == errcount) printf ("All tests have been passed without errors.\n"); return errcount == 0 ? 0 : 1; } libmicrohttpd-1.0.1/src/microhttpd/connection.h0000644000175000017500000001350314556705750015332 /* This file is part of libmicrohttpd Copyright (C) 2007 Daniel Pittman and Christian Grothoff Copyright (C) 2015-2023 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file connection.h * @brief Methods for managing connections * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #ifndef CONNECTION_H #define CONNECTION_H #include "internal.h" /** * Error code similar to EGAIN or EINTR */ #define MHD_ERR_AGAIN_ (-3073) /** * Connection was hard-closed by remote peer. */ #define MHD_ERR_CONNRESET_ (-3074) /** * Connection is not connected anymore due to * network error or any other reason. */ #define MHD_ERR_NOTCONN_ (-3075) /** * "Not enough memory" error code */ #define MHD_ERR_NOMEM_ (-3076) /** * "Bad FD" error code */ #define MHD_ERR_BADF_ (-3077) /** * Error code similar to EINVAL */ #define MHD_ERR_INVAL_ (-3078) /** * Argument values are not supported */ #define MHD_ERR_OPNOTSUPP_ (-3079) /** * Socket is shut down for writing or no longer connected */ #define MHD_ERR_PIPE_ (-3080) /** * General TLS encryption or decryption error */ #define MHD_ERR_TLS_ (-4097) /** * Set callbacks for this connection to those for HTTP. * * @param connection connection to initialize */ void MHD_set_http_callbacks_ (struct MHD_Connection *connection); /** * Set initial internal states for the connection to start reading and * processing incoming data. * @param c the connection to process */ void MHD_connection_set_initial_state_ (struct MHD_Connection *c); /** * This function handles a particular connection when it has been * determined that there is data to be read off a socket. All * implementations (multithreaded, external polling, internal polling) * call this function to handle reads. * * @param connection connection to handle * @param socket_error set to true if socket error was detected */ void MHD_connection_handle_read (struct MHD_Connection *connection, bool socket_error); /** * This function was created to handle writes to sockets when it has * been determined that the socket can be written to. All * implementations (multithreaded, external select, internal select) * call this function * * @param connection connection to handle */ void MHD_connection_handle_write (struct MHD_Connection *connection); /** * This function was created to handle per-connection processing that * has to happen even if the socket cannot be read or written to. * All implementations (multithreaded, external select, internal select) * call this function. * @remark To be called only from thread that process connection's * recv(), send() and response. * * @param connection connection to handle * @return #MHD_YES if we should continue to process the * connection (not dead yet), #MHD_NO if it died */ enum MHD_Result MHD_connection_handle_idle (struct MHD_Connection *connection); /** * Mark connection as "closed". * @remark To be called from any thread. * * @param connection connection to close */ void MHD_connection_mark_closed_ (struct MHD_Connection *connection); /** * Close the given connection and give the * specified termination code to the user. * @remark To be called only from thread that * process connection's recv(), send() and response. * * @param connection connection to close * @param termination_code termination reason to give */ void MHD_connection_close_ (struct MHD_Connection *connection, enum MHD_RequestTerminationCode termination_code); #ifdef HTTPS_SUPPORT /** * Stop TLS forwarding on upgraded connection and * reflect remote disconnect state to socketpair. * @param connection the upgraded connection */ void MHD_connection_finish_forward_ (struct MHD_Connection *connection); #else /* ! HTTPS_SUPPORT */ #define MHD_connection_finish_forward_(conn) (void) conn #endif /* ! HTTPS_SUPPORT */ #ifdef EPOLL_SUPPORT /** * Perform epoll processing, possibly moving the connection back into * the epoll set if needed. * * @param connection connection to process * @return #MHD_YES if we should continue to process the * connection (not dead yet), #MHD_NO if it died */ enum MHD_Result MHD_connection_epoll_update_ (struct MHD_Connection *connection); #endif /** * Update the 'last_activity' field of the connection to the current time * and move the connection to the head of the 'normal_timeout' list if * the timeout for the connection uses the default value. * * @param connection the connection that saw some activity */ void MHD_update_last_activity_ (struct MHD_Connection *connection); /** * Allocate memory from connection's memory pool. * If memory pool doesn't have enough free memory but read or write buffer * have some unused memory, the size of the buffer will be reduced as needed. * @param connection the connection to use * @param size the size of allocated memory area * @return pointer to allocated memory region in the pool or * NULL if no memory is available */ void * MHD_connection_alloc_memory_ (struct MHD_Connection *connection, size_t size); #endif libmicrohttpd-1.0.1/src/microhttpd/sysfdsetsize.c0000644000175000017500000000450014556705750015722 /* This file is part of libmicrohttpd Copyright (C) 2015-2023 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/sysfdsetsize.c * @brief Helper for obtaining FD_SETSIZE system default value * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #ifndef MHD_SYS_FD_SETSIZE_ #include "sysfdsetsize.h" #ifdef FD_SETSIZE /* FD_SETSIZE was defined before system headers. */ /* To get system value of FD_SETSIZE, undefine FD_SETSIZE here. */ #undef FD_SETSIZE #endif /* FD_SETSIZE */ #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS) #include #endif /* OS_VXWORKS */ #ifdef HAVE_SYS_SELECT_H #include #endif /* HAVE_SYS_SELECT_H */ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if defined(_WIN32) && ! defined(__CYGWIN__) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif /* _WIN32 && !__CYGWIN__ */ #ifndef FD_SETSIZE #error FD_SETSIZE must be defined in system headers #endif /* !FD_SETSIZE */ /** * Get system default value of FD_SETSIZE * @return system default value of FD_SETSIZE */ unsigned int get_system_fdsetsize_value (void) { return (unsigned int) FD_SETSIZE; } #endif /* ! MHD_SYS_FD_SETSIZE_ */ libmicrohttpd-1.0.1/src/microhttpd/test_upgrade.c0000644000175000017500000020627214556705750015663 /* This file is part of libmicrohttpd Copyright (C) 2016-2020 Christian Grothoff Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_upgrade.c * @brief Testcase for libmicrohttpd upgrading a connection * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include #include #include #include #include #include #ifndef WINDOWS #include #endif #ifdef HAVE_STDBOOL_H #include #endif /* HAVE_STDBOOL_H */ #include "mhd_sockets.h" #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #include "platform.h" #include "microhttpd.h" #include "test_helpers.h" #ifdef HTTPS_SUPPORT #include #include "../testcurl/https/tls_test_keys.h" #if defined(HAVE_FORK) && defined(HAVE_WAITPID) #include #include #endif /* HAVE_FORK && HAVE_WAITPID */ #endif /* HTTPS_SUPPORT */ #if defined(MHD_POSIX_SOCKETS) # ifdef MHD_WINSOCK_SOCKETS # error Both MHD_POSIX_SOCKETS and MHD_WINSOCK_SOCKETS are defined # endif /* MHD_WINSOCK_SOCKETS */ #elif ! defined(MHD_WINSOCK_SOCKETS) # error Neither MHD_POSIX_SOCKETS nor MHD_WINSOCK_SOCKETS are defined #endif /* MHD_WINSOCK_SOCKETS */ #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); fflush (stderr); exit (8); } static void _testErrorLog_func (const char *errDesc, const char *funcName, int lineNum) { fflush (stdout); if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call resulted in error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); } #ifdef MHD_HAVE_MHD_FUNC_ #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, MHD_FUNC_, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, MHD_FUNC_, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, MHD_FUNC_, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, MHD_FUNC_, __LINE__) #define testErrorLog(ignore) \ _testErrorLog_func(NULL, MHD_FUNC_, __LINE__) #define testErrorLogDesc(errDesc) \ _testErrorLog_func(errDesc, MHD_FUNC_, __LINE__) #else /* ! MHD_HAVE_MHD_FUNC_ */ #define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__) #define testErrorLog(ignore) _testErrorLog_func(NULL, NULL, __LINE__) #define testErrorLogDesc(errDesc) _testErrorLog_func(errDesc, NULL, __LINE__) #endif /* ! MHD_HAVE_MHD_FUNC_ */ /* ** External parameters ** */ static bool use_large; static bool use_vlarge; static bool test_tls; static int verbose = 0; enum tls_tool { TLS_CLI_NO_TOOL = 0, TLS_CLI_GNUTLS, TLS_CLI_OPENSSL, TLS_LIB_GNUTLS }; static enum tls_tool use_tls_tool; /* ** Internal values ** */ /* Could be increased to facilitate debugging */ static int test_timeout = 5; static uint16_t global_port; static const void *rclient_msg; static size_t rclient_msg_size; static const void *app_msg; static size_t app_msg_size; static void *alloc_ptr[2] = {NULL, NULL}; static void fflush_allstd (void) { fflush (stderr); fflush (stdout); } #if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) /** * Fork child that connects via GnuTLS-CLI to our @a port. Allows us to * talk to our port over a socket in @a sp without having to worry * about TLS. * * @param location where the socket is returned * @return -1 on error, otherwise PID of TLS child process */ static pid_t gnutlscli_connect (int *sock, uint16_t port) { pid_t chld; int sp[2]; char destination[30]; if (0 != socketpair (AF_UNIX, SOCK_STREAM, 0, sp)) { testErrorLogDesc ("socketpair() failed"); return (pid_t) -1; } chld = fork (); if (0 != chld) { *sock = sp[1]; MHD_socket_close_chk_ (sp[0]); return chld; } MHD_socket_close_chk_ (sp[1]); (void) close (0); (void) close (1); if (-1 == dup2 (sp[0], 0)) externalErrorExitDesc ("dup2() failed"); if (-1 == dup2 (sp[0], 1)) externalErrorExitDesc ("dup2() failed"); MHD_socket_close_chk_ (sp[0]); if (TLS_CLI_GNUTLS == use_tls_tool) { snprintf (destination, sizeof(destination), "%u", (unsigned int) port); execlp ("gnutls-cli", "gnutls-cli", "--insecure", "-p", destination, "127.0.0.1", (char *) NULL); } else if (TLS_CLI_OPENSSL == use_tls_tool) { snprintf (destination, sizeof(destination), "127.0.0.1:%u", (unsigned int) port); execlp ("openssl", "openssl", "s_client", "-connect", destination, "-verify", "1", (char *) NULL); } _exit (1); } #endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ #if 0 /* Unused code */ /** * Change socket to blocking. * * @param fd the socket to manipulate */ static void make_blocking (MHD_socket fd) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (fd, F_GETFL); if (-1 == flags) externalErrorExitDesc ("fcntl() failed"); if ((flags & ~O_NONBLOCK) != flags) if (-1 == fcntl (fd, F_SETFL, flags & ~O_NONBLOCK)) externalErrorExitDesc ("fcntl() failed"); #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 0; if (0 != ioctlsocket (fd, (int) FIONBIO, &flags)) externalErrorExitDesc ("ioctlsocket() failed"); #endif /* MHD_WINSOCK_SOCKETS */ } #endif /* Unused code */ /** * Change socket to non-blocking. * * @param fd the socket to manipulate */ static void make_nonblocking (MHD_socket fd) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (fd, F_GETFL); if (-1 == flags) externalErrorExitDesc ("fcntl() failed"); if (O_NONBLOCK != (flags & O_NONBLOCK)) if (-1 == fcntl (fd, F_SETFL, flags | O_NONBLOCK)) externalErrorExitDesc ("fcntl() failed"); #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 1; if (0 != ioctlsocket (fd, (int) FIONBIO, &flags)) externalErrorExitDesc ("ioctlsocket() failed"); #endif /* MHD_WINSOCK_SOCKETS */ } /** * Enable TCP_NODELAY on TCP/IP socket. * * @param fd the socket to manipulate */ static void make_nodelay (MHD_socket fd) { #ifdef TCP_NODELAY const MHD_SCKT_OPT_BOOL_ on_val = 1; if (0 == setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, (const void *) &on_val, sizeof (on_val))) return; /* Success exit point */ #ifndef MHD_WINSOCK_SOCKETS fprintf (stderr, "Failed to enable TCP_NODELAY on socket (ignored). " "errno: %d (%s)\n", (int) errno, strerror (errno)); #else /* MHD_WINSOCK_SOCKETS */ fprintf (stderr, "Failed to enable TCP_NODELAY on socket (ignored). " "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); #endif /* TCP_NODELAY */ } /** * Wrapper structure for plain&TLS sockets */ struct wr_socket { /** * Real network socket */ MHD_socket fd; /** * Type of this socket */ enum wr_type { wr_invalid = 0, wr_plain = 1, wr_tls = 2 } t; bool is_nonblocking; bool eof_recieved; #ifdef HTTPS_SUPPORT /** * TLS credentials */ gnutls_certificate_credentials_t tls_crd; /** * TLS session. */ gnutls_session_t tls_s; /** * TLS handshake already succeed? */ bool tls_connected; #endif }; /** * Get underlying real socket. * @return FD of real socket */ #define wr_fd(s) ((s)->fd) #if 0 /* Unused code */ static void wr_make_blocking (struct wr_socket *s) { if (s->is_nonblocking) make_blocking (s->fd); s->is_nonblocking = false; } #endif /* Unused code */ static void wr_make_nonblocking (struct wr_socket *s) { if (! s->is_nonblocking) make_nonblocking (s->fd); s->is_nonblocking = true; } /** * Create wr_socket with plain TCP underlying socket * @return created socket on success, NULL otherwise */ static struct wr_socket * wr_create_plain_sckt (void) { struct wr_socket *s = malloc (sizeof(struct wr_socket)); if (NULL == s) { testErrorLogDesc ("malloc() failed"); return NULL; } s->t = wr_plain; s->eof_recieved = false; s->fd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); s->is_nonblocking = false; if (MHD_INVALID_SOCKET != s->fd) { make_nodelay (s->fd); return s; /* Success */ } testErrorLogDesc ("socket() failed"); free (s); return NULL; } /** * Create wr_socket with TLS TCP underlying socket * @return created socket on success, NULL otherwise */ static struct wr_socket * wr_create_tls_sckt (void) { #ifdef HTTPS_SUPPORT struct wr_socket *s = malloc (sizeof(struct wr_socket)); if (NULL == s) { testErrorLogDesc ("malloc() failed"); return NULL; } s->t = wr_tls; s->eof_recieved = false; s->tls_connected = 0; s->fd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); s->is_nonblocking = false; if (MHD_INVALID_SOCKET != s->fd) { make_nodelay (s->fd); if (GNUTLS_E_SUCCESS == gnutls_init (&(s->tls_s), GNUTLS_CLIENT)) { if (GNUTLS_E_SUCCESS == gnutls_set_default_priority (s->tls_s)) { if (GNUTLS_E_SUCCESS == gnutls_certificate_allocate_credentials (&(s->tls_crd))) { if (GNUTLS_E_SUCCESS == gnutls_credentials_set (s->tls_s, GNUTLS_CRD_CERTIFICATE, s->tls_crd)) { #if (GNUTLS_VERSION_NUMBER + 0 >= 0x030109) && ! defined(_WIN64) gnutls_transport_set_int (s->tls_s, (int) (s->fd)); #else /* GnuTLS before 3.1.9 or Win x64 */ gnutls_transport_set_ptr (s->tls_s, (gnutls_transport_ptr_t) \ (intptr_t) (s->fd)); #endif /* GnuTLS before 3.1.9 or Win x64 */ return s; } else testErrorLogDesc ("gnutls_credentials_set() failed"); gnutls_certificate_free_credentials (s->tls_crd); } else testErrorLogDesc ("gnutls_certificate_allocate_credentials() failed"); } else testErrorLogDesc ("gnutls_set_default_priority() failed"); gnutls_deinit (s->tls_s); } else testErrorLogDesc ("gnutls_init() failed"); (void) MHD_socket_close_ (s->fd); } else testErrorLogDesc ("socket() failed"); free (s); #endif /* HTTPS_SUPPORT */ return NULL; } /** * Create wr_socket with plain TCP underlying socket * from already created TCP socket. * @param plain_sk real TCP socket * @return created socket on success, NULL otherwise */ static struct wr_socket * wr_create_from_plain_sckt (MHD_socket plain_sk) { struct wr_socket *s = malloc (sizeof(struct wr_socket)); if (NULL == s) { testErrorLogDesc ("malloc() failed"); return NULL; } s->t = wr_plain; s->eof_recieved = false; s->fd = plain_sk; s->is_nonblocking = false; /* The actual mode is unknown */ wr_make_nonblocking (s); /* Force set mode to have correct status */ make_nodelay (s->fd); return s; } #if 0 /* Disabled code */ /** * Check whether shutdown of connection was received from remote * @param s socket to check * @return zero if shutdown signal has not been received, * 1 if shutdown signal was already received */ static int wr_is_eof_received (struct wr_socket *s) { return s->eof_recieved ? 1 : 0; } #endif /* Disabled code */ enum wr_wait_for_type { WR_WAIT_FOR_RECV = 0, WR_WAIT_FOR_SEND = 1 }; static bool wr_wait_socket_ready_noabort_ (struct wr_socket *s, int timeout_ms, enum wr_wait_for_type wait_for) { fd_set fds; int sel_res; struct timeval tmo; struct timeval *tmo_ptr; #ifndef MHD_WINSOCK_SOCKETS if (FD_SETSIZE <= s->fd) externalErrorExitDesc ("Too large FD value"); #endif /* ! MHD_WINSOCK_SOCKETS */ FD_ZERO (&fds); FD_SET (s->fd, &fds); if (0 <= timeout_ms) { #if ! defined(_WIN32) || defined(__CYGWIN__) tmo.tv_sec = (time_t) (timeout_ms / 1000); #else /* Native W32 */ tmo.tv_sec = (long) (timeout_ms / 1000); #endif /* Native W32 */ tmo.tv_usec = ((long) (timeout_ms % 1000)) * 1000; tmo_ptr = &tmo; } else tmo_ptr = NULL; /* No timeout */ do { if (WR_WAIT_FOR_RECV == wait_for) sel_res = select (1 + (int) s->fd, &fds, NULL, NULL, tmo_ptr); else sel_res = select (1 + (int) s->fd, NULL, &fds, NULL, tmo_ptr); } while (0 > sel_res && MHD_SCKT_ERR_IS_EINTR_ (MHD_socket_get_error_ ())); if (1 == sel_res) return true; if (0 == sel_res) fprintf (stderr, "Timeout"); else { #ifndef MHD_WINSOCK_SOCKETS fprintf (stderr, "Error %d (%s)", (int) errno, strerror (errno)); #else /* MHD_WINSOCK_SOCKETS */ fprintf (stderr, "Error (WSAGetLastError code: %d)", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ } fprintf (stderr, " waiting for socket to be available for %s.\n", (WR_WAIT_FOR_RECV == wait_for) ? "receiving" : "sending"); return false; } static void wr_wait_socket_ready_ (struct wr_socket *s, int timeout_ms, enum wr_wait_for_type wait_for) { if (wr_wait_socket_ready_noabort_ (s, timeout_ms, wait_for)) return; if (WR_WAIT_FOR_RECV == wait_for) mhdErrorExitDesc ("Client or application failed to receive the data"); else mhdErrorExitDesc ("Client or application failed to send the data"); } /** * Connect socket to specified address. * @param s socket to use * @param addr address to connect * @param length of structure pointed by @a addr * @param timeout_ms the maximum wait time in milliseconds to send the data, * no limit if negative value is used * @return zero on success, -1 otherwise. */ static int wr_connect_tmo (struct wr_socket *s, const struct sockaddr *addr, unsigned int length, int timeout_ms) { if (0 != connect (s->fd, addr, (socklen_t) length)) { int err; bool connect_completed = false; err = MHD_socket_get_error_ (); #if defined(MHD_POSIX_SOCKETS) while (! connect_completed && (EINTR == err)) { connect_completed = (0 == connect (s->fd, addr, (socklen_t) length)); if (! connect_completed) { err = errno; if (EALREADY == err) err = EINPROGRESS; else if (EISCONN == err) connect_completed = true; } } #endif /* MHD_POSIX_SOCKETS */ if (! connect_completed && (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINPROGRESS_) || MHD_SCKT_ERR_IS_EAGAIN_ (err))) /* No modern system uses EAGAIN, except W32 */ connect_completed = wr_wait_socket_ready_noabort_ (s, timeout_ms, WR_WAIT_FOR_SEND); if (! connect_completed) { testErrorLogDesc ("connect() failed"); return -1; } } if (wr_plain == s->t) return 0; #ifdef HTTPS_SUPPORT if (wr_tls == s->t) { /* Do not try handshake here as * it requires processing on MHD side and * when testing with "external" polling, * test will call MHD processing only * after return from wr_connect(). */ s->tls_connected = 0; return 0; } #endif /* HTTPS_SUPPORT */ testErrorLogDesc ("HTTPS socket connect called, but code does not support" \ " HTTPS sockets"); return -1; } /** * Connect socket to specified address. * @param s socket to use * @param addr address to connect * @param length of structure pointed by @a addr * @return zero on success, -1 otherwise. */ static int wr_connect (struct wr_socket *s, const struct sockaddr *addr, unsigned int length) { return wr_connect_tmo (s, addr, length, test_timeout * 1000); } #ifdef HTTPS_SUPPORT /* Only to be called from wr_send() and wr_recv() ! */ static bool wr_handshake_tmo_ (struct wr_socket *s, int timeout_ms) { int res = gnutls_handshake (s->tls_s); while ((GNUTLS_E_AGAIN == res) || (GNUTLS_E_INTERRUPTED == res)) { wr_wait_socket_ready_ (s, timeout_ms, gnutls_record_get_direction (s->tls_s) ? WR_WAIT_FOR_SEND : WR_WAIT_FOR_RECV); res = gnutls_handshake (s->tls_s); } if (GNUTLS_E_SUCCESS == res) s->tls_connected = true; else { fprintf (stderr, "The error returned by gnutls_handshake() is " "'%s' ", gnutls_strerror ((int) res)); #if GNUTLS_VERSION_NUMBER >= 0x020600 fprintf (stderr, "(%s)\n", gnutls_strerror_name ((int) res)); #else /* GNUTLS_VERSION_NUMBER < 0x020600 */ fprintf (stderr, "(%d)\n", (int) res); #endif /* GNUTLS_VERSION_NUMBER < 0x020600 */ testErrorLogDesc ("gnutls_handshake() failed with hard error"); MHD_socket_set_error_ (MHD_SCKT_ECONNABORTED_); /* hard error */ } return s->tls_connected; } #if 0 /* Unused function */ /* Only to be called from wr_send() and wr_recv() ! */ static bool wr_handshake_ (struct wr_socket *s) { return wr_handshake_tmo_ (s, test_timeout * 1000); } #endif /* Unused function */ #endif /* HTTPS_SUPPORT */ /** * Send data to remote by socket. * @param s the socket to use * @param buf the buffer with data to send * @param len the length of data in @a buf * @param timeout_ms the maximum wait time in milliseconds to send the data, * no limit if negative value is used * @return number of bytes were sent if succeed, * -1 if failed. Use #MHD_socket_get_error_() * to get socket error. */ static ssize_t wr_send_tmo (struct wr_socket *s, const void *buf, size_t len, int timeout_ms) { if (wr_plain == s->t) { ssize_t res; while (! 0) { int err; res = MHD_send_ (s->fd, buf, len); if (0 <= res) break; /* Success */ err = MHD_socket_get_error_ (); if (! MHD_SCKT_ERR_IS_EAGAIN_ (err) && ! MHD_SCKT_ERR_IS_EINTR_ (err)) break; /* Failure */ wr_wait_socket_ready_ (s, timeout_ms, WR_WAIT_FOR_SEND); } return res; } #ifdef HTTPS_SUPPORT else if (wr_tls == s->t) { ssize_t ret; if (! s->tls_connected && ! wr_handshake_tmo_ (s, timeout_ms)) return -1; while (1) { ret = gnutls_record_send (s->tls_s, buf, len); if (ret >= 0) return ret; if ((GNUTLS_E_AGAIN != ret) && (GNUTLS_E_INTERRUPTED != ret)) break; wr_wait_socket_ready_ (s, timeout_ms, gnutls_record_get_direction (s->tls_s) ? WR_WAIT_FOR_SEND : WR_WAIT_FOR_RECV); } fprintf (stderr, "The error returned by gnutls_record_send() is " "'%s' ", gnutls_strerror ((int) ret)); #if GNUTLS_VERSION_NUMBER >= 0x020600 fprintf (stderr, "(%s)\n", gnutls_strerror_name ((int) ret)); #else /* GNUTLS_VERSION_NUMBER < 0x020600 */ fprintf (stderr, "(%d)\n", (int) ret); #endif /* GNUTLS_VERSION_NUMBER < 0x020600 */ testErrorLogDesc ("gnutls_record_send() failed with hard error"); MHD_socket_set_error_ (MHD_SCKT_ECONNABORTED_); /* hard error */ return -1; } #endif /* HTTPS_SUPPORT */ testErrorLogDesc ("HTTPS socket send called, but code does not support" \ " HTTPS sockets"); return -1; } /** * Send data to remote by socket. * @param s the socket to use * @param buf the buffer with data to send * @param len the length of data in @a buf * @return number of bytes were sent if succeed, * -1 if failed. Use #MHD_socket_get_error_() * to get socket error. */ static ssize_t wr_send (struct wr_socket *s, const void *buf, size_t len) { return wr_send_tmo (s, buf, len, test_timeout * 1000); } /** * Receive data from remote by socket. * @param s the socket to use * @param buf the buffer to store received data * @param len the length of @a buf * @param timeout_ms the maximum wait time in milliseconds to receive the data, * no limit if negative value is used * @return number of bytes were received if succeed, * -1 if failed. Use #MHD_socket_get_error_() * to get socket error. */ static ssize_t wr_recv_tmo (struct wr_socket *s, void *buf, size_t len, int timeout_ms) { if (wr_plain == s->t) { ssize_t res; while (! 0) { int err; res = MHD_recv_ (s->fd, buf, len); if (0 == res) s->eof_recieved = true; if (0 <= res) break; /* Success */ err = MHD_socket_get_error_ (); if (! MHD_SCKT_ERR_IS_EAGAIN_ (err) && ! MHD_SCKT_ERR_IS_EINTR_ (err)) break; /* Failure */ wr_wait_socket_ready_ (s, timeout_ms, WR_WAIT_FOR_RECV); } return res; } #ifdef HTTPS_SUPPORT if (wr_tls == s->t) { ssize_t ret; if (! s->tls_connected && ! wr_handshake_tmo_ (s, timeout_ms)) return -1; while (1) { ret = gnutls_record_recv (s->tls_s, buf, len); if (0 == ret) s->eof_recieved = true; if (ret >= 0) return ret; if ((GNUTLS_E_AGAIN != ret) && (GNUTLS_E_INTERRUPTED != ret)) break; wr_wait_socket_ready_ (s, timeout_ms, gnutls_record_get_direction (s->tls_s) ? WR_WAIT_FOR_SEND : WR_WAIT_FOR_RECV); } fprintf (stderr, "The error returned by gnutls_record_recv() is " "'%s' ", gnutls_strerror ((int) ret)); #if GNUTLS_VERSION_NUMBER >= 0x020600 fprintf (stderr, "(%s)\n", gnutls_strerror_name ((int) ret)); #else /* GNUTLS_VERSION_NUMBER < 0x020600 */ fprintf (stderr, "(%d)\n", (int) ret); #endif /* GNUTLS_VERSION_NUMBER < 0x020600 */ testErrorLogDesc ("gnutls_record_recv() failed with hard error"); MHD_socket_set_error_ (MHD_SCKT_ECONNABORTED_); /* hard error */ return -1; } #endif /* HTTPS_SUPPORT */ return -1; } /** * Receive data from remote by socket. * @param s the socket to use * @param buf the buffer to store received data * @param len the length of @a buf * @return number of bytes were received if succeed, * -1 if failed. Use #MHD_socket_get_error_() * to get socket error. */ static ssize_t wr_recv (struct wr_socket *s, void *buf, size_t len) { return wr_recv_tmo (s, buf, len, test_timeout * 1000); } /** * Shutdown send/write on the socket. * @param s the socket to shutdown * @param how the type of shutdown: SHUT_WR or SHUT_RDWR * @param timeout_ms the maximum wait time in milliseconds to receive the data, * no limit if negative value is used * @return zero on succeed, -1 otherwise */ static int wr_shutdown_tmo (struct wr_socket *s, int how, int timeout_ms) { switch (how) { case SHUT_WR: /* Valid value */ break; case SHUT_RDWR: /* Valid value */ break; case SHUT_RD: externalErrorExitDesc ("Unsupported 'how' value"); break; default: externalErrorExitDesc ("Invalid 'how' value"); break; } if (wr_plain == s->t) { (void) timeout_ms; /* Unused parameter for plain sockets */ return shutdown (s->fd, how); } #ifdef HTTPS_SUPPORT if (wr_tls == s->t) { ssize_t ret; if (! s->tls_connected && ! wr_handshake_tmo_ (s, timeout_ms)) return -1; while (1) { ret = gnutls_bye (s->tls_s, (SHUT_WR == how) ? GNUTLS_SHUT_WR : GNUTLS_SHUT_RDWR); if (GNUTLS_E_SUCCESS == ret) { #if 0 /* Disabled to test pure behaviour */ if (SHUT_RDWR == how) (void) shutdown (s->fd, how); /* Also shutdown the underlying transport layer */ #endif return 0; } if ((GNUTLS_E_AGAIN != ret) && (GNUTLS_E_INTERRUPTED != ret)) break; wr_wait_socket_ready_ (s, timeout_ms, gnutls_record_get_direction (s->tls_s) ? WR_WAIT_FOR_SEND : WR_WAIT_FOR_RECV); } fprintf (stderr, "The error returned by gnutls_bye() is " "'%s' ", gnutls_strerror ((int) ret)); #if GNUTLS_VERSION_NUMBER >= 0x020600 fprintf (stderr, "(%s)\n", gnutls_strerror_name ((int) ret)); #else /* GNUTLS_VERSION_NUMBER < 0x020600 */ fprintf (stderr, "(%d)\n", (int) ret); #endif /* GNUTLS_VERSION_NUMBER < 0x020600 */ testErrorLogDesc ("gnutls_bye() failed with hard error"); MHD_socket_set_error_ (MHD_SCKT_ECONNABORTED_); /* hard error */ return -1; } #endif /* HTTPS_SUPPORT */ return -1; } /** * Shutdown the socket. * @param s the socket to shutdown * @return zero on succeed, -1 otherwise */ static int wr_shutdown (struct wr_socket *s, int how) { return wr_shutdown_tmo (s, how, test_timeout * 1000); } /** * Close socket and release allocated resourced * @param s the socket to close * @return zero on succeed, -1 otherwise */ static int wr_close (struct wr_socket *s) { int ret = (MHD_socket_close_ (s->fd)) ? 0 : -1; #ifdef HTTPS_SUPPORT if (wr_tls == s->t) { gnutls_deinit (s->tls_s); gnutls_certificate_free_credentials (s->tls_crd); } #endif /* HTTPS_SUPPORT */ free (s); return ret; } /** * Thread we use to run the interaction with the upgraded socket. */ static pthread_t pt; /** * Will be set to the upgraded socket. */ static struct wr_socket *volatile usock; /** * Thread we use to run the interaction with the upgraded socket. */ static pthread_t pt_client; /** * Flag set to true once the client is finished. */ static volatile bool client_done; /** * Flag set to true once the app is finished. */ static volatile bool app_done; static const char * term_reason_str (enum MHD_RequestTerminationCode term_code) { switch ((int) term_code) { case MHD_REQUEST_TERMINATED_COMPLETED_OK: return "COMPLETED_OK"; case MHD_REQUEST_TERMINATED_WITH_ERROR: return "TERMINATED_WITH_ERROR"; case MHD_REQUEST_TERMINATED_TIMEOUT_REACHED: return "TIMEOUT_REACHED"; case MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN: return "DAEMON_SHUTDOWN"; case MHD_REQUEST_TERMINATED_READ_ERROR: return "READ_ERROR"; case MHD_REQUEST_TERMINATED_CLIENT_ABORT: return "CLIENT_ABORT"; case -1: return "(not called)"; default: return "(unknown code)"; } return "(problem)"; /* unreachable */ } /** * Callback used by MHD to notify the application about completed * requests. Frees memory. * * @param cls client-defined closure * @param connection connection handle * @param req_cls value as set by the last call to * the #MHD_AccessHandlerCallback * @param toe reason for request termination */ static void notify_completed_cb (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { (void) cls; (void) connection; /* Unused. Silent compiler warning. */ if (verbose) printf ("notify_completed_cb() has been called with '%s' code.\n", term_reason_str (toe)); if ( (toe != MHD_REQUEST_TERMINATED_COMPLETED_OK) && (toe != MHD_REQUEST_TERMINATED_CLIENT_ABORT) && (toe != MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN) ) mhdErrorExitDesc ("notify_completed_cb() called with wrong code"); if (NULL == req_cls) mhdErrorExitDesc ("'req_cls' parameter is NULL"); if (NULL == *req_cls) mhdErrorExitDesc ("'*req_cls' pointer is NULL"); if (! pthread_equal (**((pthread_t **) req_cls), pthread_self ())) mhdErrorExitDesc ("notify_completed_cb() is called in wrong thread"); free (*req_cls); *req_cls = NULL; } /** * Logging callback. * * @param cls logging closure (NULL) * @param uri access URI * @param connection connection handle * @return #TEST_PTR */ static void * log_cb (void *cls, const char *uri, struct MHD_Connection *connection) { pthread_t *ppth; (void) cls; (void) connection; /* Unused. Silent compiler warning. */ if (NULL == uri) mhdErrorExitDesc ("The 'uri' parameter is NULL"); if (0 != strcmp (uri, "/")) { fprintf (stderr, "Wrong 'uri' value: '%s'. ", uri); mhdErrorExit (); } ppth = malloc (sizeof (pthread_t)); if (NULL == ppth) externalErrorExitDesc ("malloc() failed"); *ppth = pthread_self (); return (void *) ppth; } /** * Function to check that MHD properly notifies about starting * and stopping. * * @param cls client-defined closure * @param connection connection handle * @param socket_context socket-specific pointer where the * client can associate some state specific * to the TCP connection; note that this is * different from the "req_cls" which is per * HTTP request. The client can initialize * during #MHD_CONNECTION_NOTIFY_STARTED and * cleanup during #MHD_CONNECTION_NOTIFY_CLOSED * and access in the meantime using * #MHD_CONNECTION_INFO_SOCKET_CONTEXT. * @param toe reason for connection notification * @see #MHD_OPTION_NOTIFY_CONNECTION * @ingroup request */ static void notify_connection_cb (void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe) { static int started = MHD_NO; (void) cls; (void) connection; /* Unused. Silent compiler warning. */ switch (toe) { case MHD_CONNECTION_NOTIFY_STARTED: if (MHD_NO != started) mhdErrorExitDesc ("The connection has been already started"); started = MHD_YES; *socket_context = &started; break; case MHD_CONNECTION_NOTIFY_CLOSED: if (MHD_YES != started) mhdErrorExitDesc ("The connection has not been started before"); if (&started != *socket_context) mhdErrorExitDesc ("Wrong '*socket_context' value"); *socket_context = NULL; started = MHD_NO; break; } } static void send_all (struct wr_socket *sock, const void *data, size_t data_size) { ssize_t ret; size_t sent; const uint8_t *const buf = (const uint8_t *) data; wr_make_nonblocking (sock); for (sent = 0; sent < data_size; sent += (size_t) ret) { ret = wr_send (sock, buf + sent, data_size - sent); if (0 > ret) { if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()) || MHD_SCKT_ERR_IS_EINTR_ (MHD_socket_get_error_ ())) { ret = 0; continue; } externalErrorExitDesc ("send() failed"); } } } #define send_all_stext(sk,st) send_all(sk,st,MHD_STATICSTR_LEN_(st)) /** * Read character-by-character until we * get 'CRLNCRLN'. */ static void recv_hdr (struct wr_socket *sock) { unsigned int i; char next; char c; ssize_t ret; wr_make_nonblocking (sock); next = '\r'; i = 0; while (i < 4) { ret = wr_recv (sock, &c, 1); if (0 > ret) { if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ())) continue; if (MHD_SCKT_ERR_IS_EINTR_ (MHD_socket_get_error_ ())) continue; externalErrorExitDesc ("recv() failed"); } if (0 == ret) mhdErrorExitDesc ("The server unexpectedly closed connection"); if (c == next) { i++; if (next == '\r') next = '\n'; else next = '\r'; continue; } if (c == '\r') { i = 1; next = '\n'; continue; } i = 0; next = '\r'; } } static void recv_all (struct wr_socket *sock, const void *data, size_t data_size) { uint8_t *buf; ssize_t ret; size_t rcvd; buf = (uint8_t *) malloc (data_size); if (NULL == buf) externalErrorExitDesc ("malloc() failed"); wr_make_nonblocking (sock); for (rcvd = 0; rcvd < data_size; rcvd += (size_t) ret) { ret = wr_recv (sock, buf + rcvd, data_size - rcvd); if (0 > ret) { if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()) || MHD_SCKT_ERR_IS_EINTR_ (MHD_socket_get_error_ ())) { ret = 0; continue; } externalErrorExitDesc ("recv() failed"); } else if (0 == ret) { fprintf (stderr, "Partial only received text. Expected: '%.*s' " "(length: %ud). Got: '%.*s' (length: %ud). ", (int) data_size, (const char *) data, (unsigned int) data_size, (int) rcvd, (const char *) buf, (unsigned int) rcvd); mhdErrorExitDesc ("The server unexpectedly closed connection"); } if ((data_size - rcvd) < (size_t) ret) externalErrorExitDesc ("recv() returned excessive amount of data"); if (0 != memcmp (data, buf, rcvd + (size_t) ret)) { fprintf (stderr, "Wrong received text. Expected: '%.*s'. " "Got: '%.*s'. ", (int) (rcvd + (size_t) ret), (const char *) data, (int) (rcvd + (size_t) ret), (const char *) buf); mhdErrorExit (); } } if (0 != memcmp (data, buf, data_size)) { fprintf (stderr, "Wrong received text. Expected: '%.*s'. " "Got: '%.*s'. ", (int) data_size, (const char *) data, (int) data_size, (const char *) buf); mhdErrorExit (); } free (buf); } #define recv_all_stext(sk,st) recv_all(sk,st,MHD_STATICSTR_LEN_(st)) /** * Shutdown write of the connection to signal end of transmission * for the remote side * @param sock the socket to shutdown */ static void send_eof (struct wr_socket *sock) { if (0 != wr_shutdown (sock, /* ** On Darwin local shutdown of RD cause error ** if remote side shut down WR before. wr_is_eof_received (sock) ? SHUT_RDWR : */ SHUT_WR)) externalErrorExitDesc ("Failed to shutdown connection"); } /** * Receive end of the transmission indication from the remote side * @param sock the socket to use */ static void receive_eof (struct wr_socket *sock) { uint8_t buf[127]; ssize_t ret; size_t rcvd; bool got_eof = false; wr_make_nonblocking (sock); for (rcvd = 0; rcvd < sizeof(buf); rcvd += (size_t) ret) { ret = wr_recv (sock, buf + rcvd, sizeof(buf) - rcvd); if (0 > ret) { if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()) || MHD_SCKT_ERR_IS_EINTR_ (MHD_socket_get_error_ ())) { ret = 0; continue; } externalErrorExitDesc ("recv() failed"); } else if (0 == ret) { got_eof = true; break; } } if (got_eof && (0 == rcvd)) return; /* Success */ if (0 != rcvd) { if (sizeof(buf) == rcvd) { fprintf (stderr, "Received at least %lu extra bytes while " "end-of-file is expected.\n", (unsigned long) sizeof(buf)); mhdErrorExit (); } fprintf (stderr, "Received at %lu extra bytes and then %s" "end-of-file marker.\n", (unsigned long) rcvd, got_eof ? "" : "NO "); mhdErrorExit (); } if (! got_eof) mhdErrorExitDesc ("Failed to receive end-of-file marker."); } /** * Main function for the thread that runs the interaction with * the upgraded socket. * * @param cls the handle for the upgrade */ static void * run_usock (void *cls) { struct MHD_UpgradeResponseHandle *urh = cls; recv_all (usock, rclient_msg, rclient_msg_size); send_all (usock, app_msg, app_msg_size); recv_all_stext (usock, "Finished"); if (! test_tls) { receive_eof (usock); send_eof (usock); } MHD_upgrade_action (urh, MHD_UPGRADE_ACTION_CLOSE); free (usock); usock = NULL; app_done = true; return NULL; } /** * Main function for the thread that runs the client-side of the * interaction with the upgraded socket. * * @param cls the client socket */ static void * run_usock_client (void *cls) { struct wr_socket *sock = cls; send_all_stext (sock, "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: Upgrade\r\n\r\n"); recv_hdr (sock); send_all (sock, rclient_msg, rclient_msg_size); recv_all (sock, app_msg, app_msg_size); send_all_stext (sock, "Finished"); if (! test_tls) { send_eof (sock); receive_eof (sock); } wr_close (sock); client_done = true; return NULL; } /** * Function called after a protocol "upgrade" response was sent * successfully and the socket should now be controlled by some * protocol other than HTTP. * * Any data already received on the socket will be made available in * @e extra_in. This can happen if the application sent extra data * before MHD send the upgrade response. The application should * treat data from @a extra_in as if it had read it from the socket. * * Note that the application must not close() @a sock directly, * but instead use #MHD_upgrade_action() for special operations * on @a sock. * * Except when in 'thread-per-connection' mode, implementations * of this function should never block (as it will still be called * from within the main event loop). * * @param cls closure, whatever was given to #MHD_create_response_for_upgrade(). * @param connection original HTTP connection handle, * giving the function a last chance * to inspect the original HTTP request * @param req_cls last value left in `req_cls` of the `MHD_AccessHandlerCallback` * @param extra_in if we happened to have read bytes after the * HTTP header already (because the client sent * more than the HTTP header of the request before * we sent the upgrade response), * these are the extra bytes already read from @a sock * by MHD. The application should treat these as if * it had read them from @a sock. * @param extra_in_size number of bytes in @a extra_in * @param sock socket to use for bi-directional communication * with the client. For HTTPS, this may not be a socket * that is directly connected to the client and thus certain * operations (TCP-specific setsockopt(), getsockopt(), etc.) * may not work as expected (as the socket could be from a * socketpair() or a TCP-loopback). The application is expected * to perform read()/recv() and write()/send() calls on the socket. * The application may also call shutdown(), but must not call * close() directly. * @param urh argument for #MHD_upgrade_action()s on this @a connection. * Applications must eventually use this callback to (indirectly) * perform the close() action on the @a sock. */ static void upgrade_cb (void *cls, struct MHD_Connection *connection, void *req_cls, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh) { (void) cls; (void) connection; (void) req_cls; (void) extra_in; /* Unused. Silent compiler warning. */ usock = wr_create_from_plain_sckt (sock); wr_make_nonblocking (usock); if (0 != extra_in_size) mhdErrorExitDesc ("'extra_in_size' is not zero"); if (0 != pthread_create (&pt, NULL, &run_usock, urh)) externalErrorExitDesc ("pthread_create() failed"); } /** * A client has requested the given url using the given method * (#MHD_HTTP_METHOD_GET, #MHD_HTTP_METHOD_PUT, * #MHD_HTTP_METHOD_DELETE, #MHD_HTTP_METHOD_POST, etc). The callback * must call MHD callbacks to provide content to give back to the * client and return an HTTP status code (i.e. #MHD_HTTP_OK, * #MHD_HTTP_NOT_FOUND, etc.). * * @param cls argument given together with the function * pointer when the handler was registered with MHD * @param url the requested url * @param method the HTTP method used (#MHD_HTTP_METHOD_GET, * #MHD_HTTP_METHOD_PUT, etc.) * @param version the HTTP version string (i.e. * #MHD_HTTP_VERSION_1_1) * @param upload_data the data being uploaded (excluding HEADERS, * for a POST that fits into memory and that is encoded * with a supported encoding, the POST data will NOT be * given in upload_data and is instead available as * part of #MHD_get_connection_values; very large POST * data *will* be made available incrementally in * @a upload_data) * @param upload_data_size set initially to the size of the * @a upload_data provided; the method must update this * value to the number of bytes NOT processed; * @param req_cls pointer that the callback can set to some * address and that will be preserved by MHD for future * calls for this request; since the access handler may * be called many times (i.e., for a PUT/POST operation * with plenty of upload data) this allows the application * to easily associate some request-specific state. * If necessary, this state can be cleaned up in the * global #MHD_RequestCompletedCallback (which * can be set with the #MHD_OPTION_NOTIFY_COMPLETED). * Initially, `*req_cls` will be NULL. * @return #MHD_YES if the connection was handled successfully, * #MHD_NO if the socket must be closed due to a serious * error while handling the request */ static enum MHD_Result ahc_upgrade (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *resp; (void) cls; (void) url; (void) method; /* Unused. Silent compiler warning. */ (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ if (NULL == req_cls) mhdErrorExitDesc ("'req_cls' is NULL"); if (NULL == *req_cls) mhdErrorExitDesc ("'*req_cls' value is NULL"); if (! pthread_equal (**((pthread_t **) req_cls), pthread_self ())) mhdErrorExitDesc ("ahc_upgrade() is called in wrong thread"); resp = MHD_create_response_for_upgrade (&upgrade_cb, NULL); if (NULL == resp) mhdErrorExitDesc ("MHD_create_response_for_upgrade() failed"); if (MHD_YES != MHD_add_response_header (resp, MHD_HTTP_HEADER_UPGRADE, "Hello World Protocol")) mhdErrorExitDesc ("MHD_add_response_header() failed"); if (MHD_YES != MHD_queue_response (connection, MHD_HTTP_SWITCHING_PROTOCOLS, resp)) mhdErrorExitDesc ("MHD_queue_response() failed"); MHD_destroy_response (resp); return MHD_YES; } /** * Run the MHD external event loop using select or epoll. * * select/epoll modes are used automatically based on daemon's flags. * * @param daemon daemon to run it for */ static void run_mhd_select_loop (struct MHD_Daemon *daemon) { const time_t start_time = time (NULL); const union MHD_DaemonInfo *pdinfo; bool connection_was_accepted; bool connection_has_finished; #ifdef EPOLL_SUPPORT bool use_epoll = false; int ep = -1; pdinfo = MHD_get_daemon_info (daemon, MHD_DAEMON_INFO_FLAGS); if (NULL == pdinfo) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); else use_epoll = (0 != (pdinfo->flags & MHD_USE_EPOLL)); if (use_epoll) { pdinfo = MHD_get_daemon_info (daemon, MHD_DAEMON_INFO_EPOLL_FD); if (NULL == pdinfo) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); ep = pdinfo->listen_fd; if (0 > ep) mhdErrorExitDesc ("Invalid epoll FD value"); } #endif /* EPOLL_SUPPORT */ connection_was_accepted = false; connection_has_finished = false; while (1) { fd_set rs; fd_set ws; fd_set es; MHD_socket max_fd; struct timeval tv; uint64_t to64; bool has_mhd_timeout; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); max_fd = MHD_INVALID_SOCKET; if (time (NULL) - start_time > ((time_t) test_timeout)) mhdErrorExitDesc ("Test timeout"); pdinfo = MHD_get_daemon_info (daemon, MHD_DAEMON_INFO_CURRENT_CONNECTIONS); if (NULL == pdinfo) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); if (0 != pdinfo->num_connections) connection_was_accepted = true; else { if (connection_was_accepted) connection_has_finished = true; } if (connection_has_finished) return; if (MHD_YES != MHD_get_fdset (daemon, &rs, &ws, &es, &max_fd)) mhdErrorExitDesc ("MHD_get_fdset() failed"); #ifdef EPOLL_SUPPORT if (use_epoll) { if (ep != max_fd) mhdErrorExitDesc ("Wrong 'max_fd' value"); if (! FD_ISSET (ep, &rs)) mhdErrorExitDesc ("Epoll FD is NOT set in read fd_set"); } #endif /* EPOLL_SUPPORT */ has_mhd_timeout = (MHD_NO != MHD_get_timeout64 (daemon, &to64)); if (has_mhd_timeout) { #if ! defined(_WIN32) || defined(__CYGWIN__) tv.tv_sec = (time_t) (to64 / 1000); #else /* Native W32 */ tv.tv_sec = (long) (to64 / 1000); #endif /* Native W32 */ tv.tv_usec = (long) (1000 * (to64 % 1000)); } else { #if ! defined(_WIN32) || defined(__CYGWIN__) tv.tv_sec = (time_t) test_timeout; #else /* Native W32 */ tv.tv_sec = (long) test_timeout; #endif /* Native W32 */ tv.tv_usec = 0; } #ifdef MHD_WINSOCK_SOCKETS if ((0 == rs.fd_count) && (0 == ws.fd_count) && (0 != es.fd_count)) Sleep ((DWORD) (tv.tv_sec * 1000 + tv.tv_usec / 1000)); else /* Combined with the next 'if' */ #endif if (1) { int sel_res; sel_res = MHD_SYS_select_ (max_fd + 1, &rs, &ws, &es, &tv); if (0 == sel_res) { if (! has_mhd_timeout) mhdErrorExitDesc ("Timeout waiting for data on sockets"); } else if (0 > sel_res) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) #endif /* MHD_POSIX_SOCKETS */ mhdErrorExitDesc ("Unexpected select() error"); } } MHD_run_from_select (daemon, &rs, &ws, &es); } } #ifdef HAVE_POLL /** * Run the MHD external event loop using select. * * @param daemon daemon to run it for */ _MHD_NORETURN static void run_mhd_poll_loop (struct MHD_Daemon *daemon) { (void) daemon; /* Unused. Silent compiler warning. */ externalErrorExitDesc ("Not implementable with MHD API"); } #endif /* HAVE_POLL */ /** * Run the MHD external event loop using select. * * @param daemon daemon to run it for */ static void run_mhd_loop (struct MHD_Daemon *daemon, unsigned int flags) { if (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) run_mhd_select_loop (daemon); #ifdef HAVE_POLL else if (0 != (flags & MHD_USE_POLL)) run_mhd_poll_loop (daemon); #endif /* HAVE_POLL */ #ifdef EPOLL_SUPPORT else if (0 != (flags & MHD_USE_EPOLL)) run_mhd_select_loop (daemon); #endif else externalErrorExitDesc ("Wrong 'flags' value"); } /** * Test upgrading a connection. * * @param flags which event loop style should be tested * @param pool size of the thread pool, 0 to disable */ static unsigned int test_upgrade (unsigned int flags, unsigned int pool) { struct MHD_Daemon *d = NULL; struct wr_socket *sock; struct sockaddr_in sa; enum MHD_FLAG used_flags; const union MHD_DaemonInfo *dinfo; #if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) pid_t pid = -1; #endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ size_t mem_limit; /* Handle memory limits. Actually makes sense only for TLS */ if (use_vlarge) mem_limit = 64U * 1024U; /* Half of the buffer should be large enough to take more than max TLS packet */ else if (use_large) mem_limit = 4U * 1024; /* Make sure that several iteration required to deliver a single message */ else mem_limit = 0; /* Use default value */ client_done = false; app_done = false; if (! test_tls) d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE | MHD_USE_ITC, global_port, NULL, NULL, &ahc_upgrade, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_NOTIFY_COMPLETED, ¬ify_completed_cb, NULL, MHD_OPTION_NOTIFY_CONNECTION, ¬ify_connection_cb, NULL, MHD_OPTION_THREAD_POOL_SIZE, pool, MHD_OPTION_CONNECTION_TIMEOUT, test_timeout, MHD_OPTION_CONNECTION_MEMORY_LIMIT, mem_limit, MHD_OPTION_END); #ifdef HTTPS_SUPPORT else d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE | MHD_USE_TLS | MHD_USE_ITC, global_port, NULL, NULL, &ahc_upgrade, NULL, MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL, MHD_OPTION_NOTIFY_COMPLETED, ¬ify_completed_cb, NULL, MHD_OPTION_NOTIFY_CONNECTION, ¬ify_connection_cb, NULL, MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_THREAD_POOL_SIZE, pool, MHD_OPTION_CONNECTION_TIMEOUT, test_timeout, MHD_OPTION_CONNECTION_MEMORY_LIMIT, mem_limit, MHD_OPTION_END); #endif /* HTTPS_SUPPORT */ if (NULL == d) mhdErrorExitDesc ("MHD_start_daemon() failed"); dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_FLAGS); if (NULL == dinfo) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); used_flags = dinfo->flags; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ( (NULL == dinfo) || (0 == dinfo->port) ) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); global_port = dinfo->port; /* Re-use the same port for the next checks */ if (! test_tls || (TLS_LIB_GNUTLS == use_tls_tool)) { sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt (); if (NULL == sock) externalErrorExitDesc ("Create socket failed"); wr_make_nonblocking (sock); sa.sin_family = AF_INET; sa.sin_port = htons (dinfo->port); sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); if (0 != wr_connect (sock, (struct sockaddr *) &sa, sizeof (sa))) externalErrorExitDesc ("Connect socket failed"); } else { #if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) MHD_socket tls_fork_sock; uint16_t port; port = dinfo->port; if (-1 == (pid = gnutlscli_connect (&tls_fork_sock, port))) externalErrorExitDesc ("gnutlscli_connect() failed"); sock = wr_create_from_plain_sckt (tls_fork_sock); if (NULL == sock) externalErrorExitDesc ("wr_create_from_plain_sckt() failed"); wr_make_nonblocking (sock); #else /* !HTTPS_SUPPORT || !HAVE_FORK || !HAVE_WAITPID */ externalErrorExitDesc ("Unsupported 'use_tls_tool' value"); #endif /* !HTTPS_SUPPORT || !HAVE_FORK || !HAVE_WAITPID */ } if (0 != pthread_create (&pt_client, NULL, &run_usock_client, sock)) externalErrorExitDesc ("pthread_create() failed"); if (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD) ) run_mhd_loop (d, used_flags); if (0 != pthread_join (pt_client, NULL)) externalErrorExitDesc ("pthread_join() failed"); if (0 != pthread_join (pt, NULL)) externalErrorExitDesc ("pthread_join() failed"); #if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) if (test_tls && (TLS_LIB_GNUTLS != use_tls_tool)) { if ((pid_t) -1 == waitpid (pid, NULL, 0)) externalErrorExitDesc ("waitpid() failed"); } #endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ if (! client_done) externalErrorExitDesc ("The client thread has not signalled " \ "successful finish"); if (! app_done) externalErrorExitDesc ("The application thread has not signalled " \ "successful finish"); MHD_stop_daemon (d); return 0; } enum test_msg_type { test_msg_large_app_data, test_msg_large_rclient_data, test_msg_vlarge_app_data, test_msg_vlarge_rclient_data }; /** * Initialise test message data * @param buf the pointer to the buffer to fill with the test data * @param buf_size the size of the @a buf * @param msg_type the type of the data to fill the @a buf * @return the @a buf pointer */ static void * init_test_msg (void *buf, size_t buf_size, enum test_msg_type msg_type) { size_t i; char *const text_buf = (char *) buf; uint8_t *const bin_buf = (uint8_t *) buf; if (0 == buf_size) return buf; switch (msg_type) { case test_msg_large_app_data: case test_msg_large_rclient_data: /* Simulate text data */ for (i = 0; i < buf_size; ++i) { size_t pos; if (test_msg_large_app_data == msg_type) pos = i + 43; else pos = i + 26; if ((0 == i) || (2 == pos % 100) ) text_buf[i] = (char) (unsigned char) ((test_msg_large_app_data == msg_type) ? ('Z' - pos % ('Z' - 'A' + 1)) : ('A' + pos % ('Z' - 'A' + 1))); else if (0 == pos % 100) text_buf[i] = '.'; else if (1 == pos % 100) text_buf[i] = ' '; else if ((99 != pos % 100) && (2 != pos % 100) && (0 == pos % 5)) text_buf[i] = ' '; else if (test_msg_large_app_data == msg_type) text_buf[i] = (char) (unsigned char) ('z' - pos % ('z' - 'a' + 1)); else text_buf[i] = (char) (unsigned char) ('a' + pos % ('z' - 'a' + 1)); } break; case test_msg_vlarge_app_data: /* Simulate binary data */ for (i = 0; i < buf_size; ++i) { bin_buf[i] = (uint8_t) ((i + 182) & 0xFF); } break; case test_msg_vlarge_rclient_data: /* Simulate binary data */ for (i = 0; i < buf_size; ++i) { bin_buf[i] = (uint8_t) ((111 - i) & 0xFF); } break; default: exit (99); break; } return buf; } /** * Perform initialisation of variables used in all check in this test * @return true if succeed, * false if failed. */ static bool global_test_init (void) { if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) global_port = 0; else { global_port = 1090; if (test_tls) global_port += 1U << 0; if (use_large) global_port += 1U << 1; else if (use_vlarge) global_port += 1U << 2; } if (use_large || use_vlarge) { unsigned int i; size_t alloc_size; alloc_size = use_vlarge ? (64U * 1024U) : (17U * 1024U); for (i = 0; i < (sizeof(alloc_ptr) / sizeof(alloc_ptr[0])); ++i) { alloc_ptr[i] = malloc (alloc_size); if (NULL == alloc_ptr[i]) { for (--i; i < (sizeof(alloc_ptr) / sizeof(alloc_ptr[0])); --i) { free (alloc_ptr[i]); } return false; } } rclient_msg_size = alloc_size; rclient_msg = init_test_msg (alloc_ptr[0], rclient_msg_size, use_vlarge ? test_msg_vlarge_rclient_data : test_msg_large_rclient_data); app_msg_size = alloc_size; app_msg = init_test_msg (alloc_ptr[1], app_msg_size, use_vlarge ? test_msg_vlarge_app_data : test_msg_large_app_data); } else { unsigned int i; for (i = 0; i < (sizeof(alloc_ptr) / sizeof(alloc_ptr[0])); ++i) alloc_ptr[i] = NULL; rclient_msg_size = MHD_STATICSTR_LEN_ ("Hello"); rclient_msg = "Hello"; app_msg_size = MHD_STATICSTR_LEN_ ("World"); app_msg = "World"; } return true; } /** * Perform de-initialisation of variables with memory de-allocation if required. */ static void global_test_deinit (void) { unsigned int i; for (i = ((sizeof(alloc_ptr) / sizeof(alloc_ptr[0])) - 1); i < (sizeof(alloc_ptr) / sizeof(alloc_ptr[0])); --i) { if (NULL != alloc_ptr[i]) free (alloc_ptr[i]); } } int main (int argc, char *const *argv) { unsigned int error_count = 0; unsigned int res; use_vlarge = (0 != has_in_name (argv[0], "_vlarge")); use_large = (! use_vlarge) && (0 != has_in_name (argv[0], "_large")); use_tls_tool = TLS_CLI_NO_TOOL; test_tls = has_in_name (argv[0], "_tls"); verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); if ((((int) ((~((unsigned int) 0U)) >> 1)) / 1000) < test_timeout) { fprintf (stderr, "The test timeout value (%d) is too large.\n" "The test cannot run.\n", test_timeout); fprintf (stderr, "The maximum allowed timeout value is %d.\n", (((int) ((~((unsigned int) 0U)) >> 1)) / 1000)); return 3; } if (test_tls) { use_tls_tool = TLS_LIB_GNUTLS; /* Should be always available as MHD uses it. */ #ifdef HTTPS_SUPPORT if (has_param (argc, argv, "--use-gnutls-cli")) use_tls_tool = TLS_CLI_GNUTLS; else if (has_param (argc, argv, "--use-openssl")) use_tls_tool = TLS_CLI_OPENSSL; else if (has_param (argc, argv, "--use-gnutls-lib")) use_tls_tool = TLS_LIB_GNUTLS; #if defined(HAVE_FORK) && defined(HAVE_WAITPID) else if (0 == system ("gnutls-cli --version 1> /dev/null 2> /dev/null")) use_tls_tool = TLS_CLI_GNUTLS; else if (0 == system ("openssl version 1> /dev/null 2> /dev/null")) use_tls_tool = TLS_CLI_OPENSSL; #endif /* HAVE_FORK && HAVE_WAITPID */ if (verbose) { switch (use_tls_tool) { case TLS_CLI_GNUTLS: printf ("GnuTLS-CLI will be used for testing.\n"); break; case TLS_CLI_OPENSSL: printf ("Command line version of OpenSSL will be used for testing.\n"); break; case TLS_LIB_GNUTLS: printf ("GnuTLS library will be used for testing.\n"); break; case TLS_CLI_NO_TOOL: default: externalErrorExitDesc ("Wrong 'use_tls_tool' value"); } } if ( (TLS_LIB_GNUTLS == use_tls_tool) && (GNUTLS_E_SUCCESS != gnutls_global_init ()) ) externalErrorExitDesc ("gnutls_global_init() failed"); #else /* ! HTTPS_SUPPORT */ fprintf (stderr, "HTTPS support was disabled by configure.\n"); return 77; #endif /* ! HTTPS_SUPPORT */ } if (! global_test_init ()) { #ifdef HTTPS_SUPPORT if (test_tls && (TLS_LIB_GNUTLS == use_tls_tool)) gnutls_global_deinit (); #endif /* HTTPS_SUPPORT */ fprintf (stderr, "Failed to initialise the test.\n"); return 99; } /* run tests */ if (verbose) printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n", test_tls ? "TLS" : "plain"); /* try external select */ res = test_upgrade (0, 0); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with external select, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with external select.\n"); /* Try external auto */ res = test_upgrade (MHD_USE_AUTO, 0); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with external 'auto', return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with external 'auto'.\n"); #ifdef EPOLL_SUPPORT res = test_upgrade (MHD_USE_EPOLL, 0); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with external select with EPOLL, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with external select with EPOLL.\n"); #endif /* Test thread-per-connection */ res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION, 0); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with thread per connection, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with thread per connection.\n"); res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION, 0); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with thread per connection and 'auto', return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with thread per connection and 'auto'.\n"); #ifdef HAVE_POLL res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL, 0); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with thread per connection and poll, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with thread per connection and poll.\n"); #endif /* HAVE_POLL */ /* Test different event loops, with and without thread pool */ res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD, 0); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with internal select, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with internal select.\n"); res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD, 2); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with internal select with thread pool, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with internal select with thread pool.\n"); res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, 0); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with internal 'auto' return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with internal 'auto'.\n"); res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, 2); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with internal 'auto' with thread pool, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with internal 'auto' with thread pool.\n"); #ifdef HAVE_POLL res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD, 0); fflush_allstd (); error_count += res; if (res) fprintf (stderr, "FAILED: Upgrade with internal poll, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with internal poll.\n"); res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD, 2); fflush_allstd (); if (res) fprintf (stderr, "FAILED: Upgrade with internal poll with thread pool, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with internal poll with thread pool.\n"); #endif #ifdef EPOLL_SUPPORT res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, 0); fflush_allstd (); if (res) fprintf (stderr, "FAILED: Upgrade with internal epoll, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with internal epoll.\n"); res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, 2); fflush_allstd (); if (res) fprintf (stderr, "FAILED: Upgrade with internal epoll, return code %u.\n", res); else if (verbose) printf ("PASSED: Upgrade with internal epoll.\n"); #endif /* report result */ if (0 != error_count) fprintf (stderr, "Error (code: %u)\n", error_count); global_test_deinit (); #ifdef HTTPS_SUPPORT if (test_tls && (TLS_LIB_GNUTLS == use_tls_tool)) gnutls_global_deinit (); #endif /* HTTPS_SUPPORT */ return error_count != 0; /* 0 == pass */ } libmicrohttpd-1.0.1/src/microhttpd/mhd_mono_clock.c0000644000175000017500000003447614556705750016155 /* This file is part of libmicrohttpd Copyright (C) 2015-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_mono_clock.h * @brief internal monotonic clock functions implementations * @author Karlson2k (Evgeny Grin) */ #include "mhd_mono_clock.h" #if defined(_WIN32) && ! defined(__CYGWIN__) /* Prefer native clock source over wrappers */ #ifdef HAVE_CLOCK_GETTIME #undef HAVE_CLOCK_GETTIME #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_GETTIMEOFDAY #undef HAVE_GETTIMEOFDAY #endif /* HAVE_GETTIMEOFDAY */ #endif /* _WIN32 && ! __CYGWIN__ */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ #ifdef HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_CLOCK_GET_TIME #include /* for host_get_clock_service(), mach_host_self(), mach_task_self() */ #include /* for clock_get_time() */ #define _MHD_INVALID_CLOCK_SERV ((clock_serv_t) -2) static clock_serv_t mono_clock_service = _MHD_INVALID_CLOCK_SERV; #endif /* HAVE_CLOCK_GET_TIME */ #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN /* Do not include unneeded parts of W32 headers. */ #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #include #endif /* _WIN32 */ #ifndef NULL #define NULL ((void*)0) #endif /* ! NULL */ #ifdef HAVE_CLOCK_GETTIME #ifdef CLOCK_REALTIME #define _MHD_UNWANTED_CLOCK CLOCK_REALTIME #else /* !CLOCK_REALTIME */ #define _MHD_UNWANTED_CLOCK ((clockid_t) -2) #endif /* !CLOCK_REALTIME */ static clockid_t mono_clock_id = _MHD_UNWANTED_CLOCK; #endif /* HAVE_CLOCK_GETTIME */ /* sync clocks; reduce chance of value wrap */ #if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_CLOCK_GET_TIME) || \ defined(HAVE_GETHRTIME) static time_t mono_clock_start; #endif /* HAVE_CLOCK_GETTIME || HAVE_CLOCK_GET_TIME || HAVE_GETHRTIME */ #if defined(HAVE_TIMESPEC_GET) || defined(HAVE_GETTIMEOFDAY) /* The start value shared for timespec_get() and gettimeofday () */ static time_t gettime_start; #endif /* HAVE_TIMESPEC_GET || HAVE_GETTIMEOFDAY */ static time_t sys_clock_start; #ifdef HAVE_GETHRTIME static hrtime_t hrtime_start; #endif /* HAVE_GETHRTIME */ #ifdef _WIN32 #if _WIN32_WINNT >= 0x0600 static uint64_t tick_start; #else /* _WIN32_WINNT < 0x0600 */ static uint64_t perf_freq; static uint64_t perf_start; #endif /* _WIN32_WINNT < 0x0600 */ #endif /* _WIN32 */ /** * Type of monotonic clock source */ enum _MHD_mono_clock_source { /** * No monotonic clock */ _MHD_CLOCK_NO_SOURCE = 0, /** * clock_gettime() with specific clock */ _MHD_CLOCK_GETTIME, /** * clock_get_time() with specific clock service */ _MHD_CLOCK_GET_TIME, /** * gethrtime() / 1000000000 */ _MHD_CLOCK_GETHRTIME, /** * GetTickCount64() / 1000 */ _MHD_CLOCK_GETTICKCOUNT64, /** * QueryPerformanceCounter() / QueryPerformanceFrequency() */ _MHD_CLOCK_PERFCOUNTER }; /** * Initialise monotonic seconds and milliseconds counters. */ void MHD_monotonic_sec_counter_init (void) { #ifdef HAVE_CLOCK_GET_TIME mach_timespec_t cur_time; #endif /* HAVE_CLOCK_GET_TIME */ enum _MHD_mono_clock_source mono_clock_source = _MHD_CLOCK_NO_SOURCE; #ifdef HAVE_CLOCK_GETTIME struct timespec ts; mono_clock_id = _MHD_UNWANTED_CLOCK; #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_CLOCK_GET_TIME mono_clock_service = _MHD_INVALID_CLOCK_SERV; #endif /* HAVE_CLOCK_GET_TIME */ /* just a little syntactic trick to get the various following ifdef's to work out nicely */ if (0) { (void) 0; /* Mute possible compiler warning */ } else #ifdef HAVE_CLOCK_GETTIME #ifdef CLOCK_MONOTONIC_COARSE /* Linux-specific fast value-getting clock */ /* Can be affected by frequency adjustment and don't count time in suspend, */ /* but preferred since it's fast */ if (0 == clock_gettime (CLOCK_MONOTONIC_COARSE, &ts)) { mono_clock_id = CLOCK_MONOTONIC_COARSE; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_MONOTONIC_COARSE */ #ifdef CLOCK_MONOTONIC_FAST /* FreeBSD/DragonFly fast value-getting clock */ /* Can be affected by frequency adjustment, but preferred since it's fast */ if (0 == clock_gettime (CLOCK_MONOTONIC_FAST, &ts)) { mono_clock_id = CLOCK_MONOTONIC_FAST; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_MONOTONIC_COARSE */ #ifdef CLOCK_MONOTONIC_RAW_APPROX /* Darwin-specific clock */ /* Not affected by frequency adjustment, returns clock value cached at * context switch. Can be "milliseconds old", but it's fast. */ if (0 == clock_gettime (CLOCK_MONOTONIC_RAW_APPROX, &ts)) { mono_clock_id = CLOCK_MONOTONIC_RAW_APPROX; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_MONOTONIC_RAW */ #ifdef CLOCK_MONOTONIC_RAW /* Linux and Darwin clock */ /* Not affected by frequency adjustment, * on Linux don't count time in suspend */ if (0 == clock_gettime (CLOCK_MONOTONIC_RAW, &ts)) { mono_clock_id = CLOCK_MONOTONIC_RAW; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_MONOTONIC_RAW */ #ifdef CLOCK_BOOTTIME /* Count time in suspend on Linux so it's real monotonic, */ /* but can be slower value-getting than other clocks */ if (0 == clock_gettime (CLOCK_BOOTTIME, &ts)) { mono_clock_id = CLOCK_BOOTTIME; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_BOOTTIME */ #ifdef CLOCK_MONOTONIC /* Monotonic clock */ /* Widely supported, may be affected by frequency adjustment */ /* On Linux it's not truly monotonic as it doesn't count time in suspend */ if (0 == clock_gettime (CLOCK_MONOTONIC, &ts)) { mono_clock_id = CLOCK_MONOTONIC; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_MONOTONIC */ #ifdef CLOCK_UPTIME /* non-Linux clock */ /* Doesn't count time in suspend */ if (0 == clock_gettime (CLOCK_UPTIME, &ts)) { mono_clock_id = CLOCK_UPTIME; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_BOOTTIME */ #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_CLOCK_GET_TIME /* Darwin-specific monotonic clock */ /* Should be monotonic as clock_set_time function always unconditionally */ /* failed on latest kernels */ if ( (KERN_SUCCESS == host_get_clock_service (mach_host_self (), SYSTEM_CLOCK, &mono_clock_service)) && (KERN_SUCCESS == clock_get_time (mono_clock_service, &cur_time)) ) { mono_clock_start = cur_time.tv_sec; mono_clock_source = _MHD_CLOCK_GET_TIME; } else #endif /* HAVE_CLOCK_GET_TIME */ #ifdef _WIN32 #if _WIN32_WINNT >= 0x0600 /* W32 Vista or later specific monotonic clock */ /* Available since Vista, ~15ms accuracy */ if (1) { tick_start = GetTickCount64 (); mono_clock_source = _MHD_CLOCK_GETTICKCOUNT64; } else #else /* _WIN32_WINNT < 0x0600 */ /* W32 specific monotonic clock */ /* Available on Windows 2000 and later */ if (1) { LARGE_INTEGER freq; LARGE_INTEGER perf_counter; QueryPerformanceFrequency (&freq); /* never fail on XP and later */ QueryPerformanceCounter (&perf_counter); /* never fail on XP and later */ perf_freq = (uint64_t) freq.QuadPart; perf_start = (uint64_t) perf_counter.QuadPart; mono_clock_source = _MHD_CLOCK_PERFCOUNTER; } else #endif /* _WIN32_WINNT < 0x0600 */ #endif /* _WIN32 */ #ifdef HAVE_CLOCK_GETTIME #ifdef CLOCK_HIGHRES /* Solaris-specific monotonic high-resolution clock */ /* Not preferred due to be potentially resource-hungry */ if (0 == clock_gettime (CLOCK_HIGHRES, &ts)) { mono_clock_id = CLOCK_HIGHRES; mono_clock_start = ts.tv_sec; mono_clock_source = _MHD_CLOCK_GETTIME; } else #endif /* CLOCK_HIGHRES */ #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_GETHRTIME /* HP-UX and Solaris monotonic clock */ /* Not preferred due to be potentially resource-hungry */ if (1) { hrtime_start = gethrtime (); mono_clock_source = _MHD_CLOCK_GETHRTIME; } else #endif /* HAVE_GETHRTIME */ { /* no suitable clock source was found */ mono_clock_source = _MHD_CLOCK_NO_SOURCE; } #ifdef HAVE_CLOCK_GET_TIME if ( (_MHD_CLOCK_GET_TIME != mono_clock_source) && (_MHD_INVALID_CLOCK_SERV != mono_clock_service) ) { /* clock service was initialised but clock_get_time failed */ mach_port_deallocate (mach_task_self (), mono_clock_service); mono_clock_service = _MHD_INVALID_CLOCK_SERV; } #else (void) mono_clock_source; /* avoid compiler warning */ #endif /* HAVE_CLOCK_GET_TIME */ #ifdef HAVE_TIMESPEC_GET if (1) { struct timespec tsg; if (TIME_UTC == timespec_get (&tsg, TIME_UTC)) gettime_start = tsg.tv_sec; else gettime_start = 0; } #elif defined(HAVE_GETTIMEOFDAY) if (1) { struct timeval tv; if (0 == gettimeofday (&tv, NULL)) gettime_start = tv.tv_sec; else gettime_start = 0; } #endif /* HAVE_GETTIMEOFDAY */ sys_clock_start = time (NULL); } /** * Deinitialise monotonic seconds and milliseconds counters by freeing * any allocated resources */ void MHD_monotonic_sec_counter_finish (void) { #ifdef HAVE_CLOCK_GET_TIME if (_MHD_INVALID_CLOCK_SERV != mono_clock_service) { mach_port_deallocate (mach_task_self (), mono_clock_service); mono_clock_service = _MHD_INVALID_CLOCK_SERV; } #endif /* HAVE_CLOCK_GET_TIME */ } /** * Monotonic seconds counter. * Tries to be not affected by manually setting the system real time * clock or adjustments by NTP synchronization. * * @return number of seconds from some fixed moment */ time_t MHD_monotonic_sec_counter (void) { #ifdef HAVE_CLOCK_GETTIME struct timespec ts; if ( (_MHD_UNWANTED_CLOCK != mono_clock_id) && (0 == clock_gettime (mono_clock_id, &ts)) ) return ts.tv_sec - mono_clock_start; #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_CLOCK_GET_TIME if (_MHD_INVALID_CLOCK_SERV != mono_clock_service) { mach_timespec_t cur_time; if (KERN_SUCCESS == clock_get_time (mono_clock_service, &cur_time)) return cur_time.tv_sec - mono_clock_start; } #endif /* HAVE_CLOCK_GET_TIME */ #if defined(_WIN32) #if _WIN32_WINNT >= 0x0600 if (1) return (time_t) (((uint64_t) (GetTickCount64 () - tick_start)) / 1000); #else /* _WIN32_WINNT < 0x0600 */ if (0 != perf_freq) { LARGE_INTEGER perf_counter; QueryPerformanceCounter (&perf_counter); /* never fail on XP and later */ return (time_t) (((uint64_t) perf_counter.QuadPart - perf_start) / perf_freq); } #endif /* _WIN32_WINNT < 0x0600 */ #endif /* _WIN32 */ #ifdef HAVE_GETHRTIME if (1) return (time_t) (((uint64_t) (gethrtime () - hrtime_start)) / 1000000000); #endif /* HAVE_GETHRTIME */ return time (NULL) - sys_clock_start; } /** * Monotonic milliseconds counter, useful for timeout calculation. * Tries to be not affected by manually setting the system real time * clock or adjustments by NTP synchronization. * * @return number of microseconds from some fixed moment */ uint64_t MHD_monotonic_msec_counter (void) { #if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_TIMESPEC_GET) struct timespec ts; #endif /* HAVE_CLOCK_GETTIME || HAVE_TIMESPEC_GET */ #ifdef HAVE_CLOCK_GETTIME if ( (_MHD_UNWANTED_CLOCK != mono_clock_id) && (0 == clock_gettime (mono_clock_id, &ts)) ) return (uint64_t) (((uint64_t) (ts.tv_sec - mono_clock_start)) * 1000 + (uint64_t) (ts.tv_nsec / 1000000)); #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_CLOCK_GET_TIME if (_MHD_INVALID_CLOCK_SERV != mono_clock_service) { mach_timespec_t cur_time; if (KERN_SUCCESS == clock_get_time (mono_clock_service, &cur_time)) return (uint64_t) (((uint64_t) (cur_time.tv_sec - mono_clock_start)) * 1000 + (uint64_t) (cur_time.tv_nsec / 1000000)); } #endif /* HAVE_CLOCK_GET_TIME */ #if defined(_WIN32) #if _WIN32_WINNT >= 0x0600 if (1) return (uint64_t) (GetTickCount64 () - tick_start); #else /* _WIN32_WINNT < 0x0600 */ if (0 != perf_freq) { LARGE_INTEGER perf_counter; uint64_t num_ticks; QueryPerformanceCounter (&perf_counter); /* never fail on XP and later */ num_ticks = (uint64_t) (perf_counter.QuadPart - perf_start); return ((num_ticks / perf_freq) * 1000) + ((num_ticks % perf_freq) / (perf_freq / 1000)); } #endif /* _WIN32_WINNT < 0x0600 */ #endif /* _WIN32 */ #ifdef HAVE_GETHRTIME if (1) return ((uint64_t) (gethrtime () - hrtime_start)) / 1000000; #endif /* HAVE_GETHRTIME */ /* Fallbacks, affected by system time change */ #ifdef HAVE_TIMESPEC_GET if (TIME_UTC == timespec_get (&ts, TIME_UTC)) return (uint64_t) (((uint64_t) (ts.tv_sec - gettime_start)) * 1000 + (uint64_t) (ts.tv_nsec / 1000000)); #elif defined(HAVE_GETTIMEOFDAY) if (1) { struct timeval tv; if (0 == gettimeofday (&tv, NULL)) return (uint64_t) (((uint64_t) (tv.tv_sec - gettime_start)) * 1000 + (uint64_t) (tv.tv_usec / 1000)); } #endif /* HAVE_GETTIMEOFDAY */ /* The last resort fallback with very low resolution */ return (uint64_t) (time (NULL) - sys_clock_start) * 1000; } libmicrohttpd-1.0.1/src/microhttpd/test_postprocessor_md.c0000644000175000017500000011311014445225034017612 /* This file is part of libmicrohttpd Copyright (C) 2020 Christian Grothoff Copyright (C) 2020-2023 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_postprocessor_md.c * @brief Testcase for postprocessor, keys with no value * @author Markus Doppelbauer * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include "microhttpd.h" #include "internal.h" #include "postprocessor.h" #if 0 #include "mhd_panic.c" #include "mhd_str.c" #include "internal.c" #endif #define DEBUG 0 /* local replacement for MHD functions */ _MHD_EXTERN enum MHD_Result MHD_lookup_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr) { (void) connection; (void) kind; (void) key; /* Mute compiler warnings */ (void) key_size; *value_ptr = ""; if (NULL != value_size_ptr) *value_size_ptr = 0; return MHD_NO; } #define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0])) static unsigned int found; static enum MHD_Result post_data_iterator (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { (void) cls; (void) kind; (void) filename; /* Mute compiler warnings */ (void) content_type; (void) transfer_encoding; (void) off; /* FIXME: shouldn't be checked? */ #if DEBUG fprintf (stderr, "%s\t%s\n", key, data); #endif if (0 == strcmp (key, "xxxx")) { if ( (4 != size) || (0 != memcmp (data, "xxxx", 4)) ) exit (1); found |= 1; } if (0 == strcmp (key, "yyyy")) { if ( (4 != size) || (0 != memcmp (data, "yyyy", 4)) ) exit (1); found |= 2; } if (0 == strcmp (key, "zzzz")) { if (0 != size) exit (1); found |= 4; } if (0 == strcmp (key, "aaaa")) { if (0 != size) exit (1); found |= 8; } return MHD_YES; } static enum MHD_Result post_data_iterator2 (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { static char seen[16]; (void) cls; (void) kind; (void) filename; /* Mute compiler warnings */ (void) content_type; (void) transfer_encoding; #if DEBUG printf ("%s\t%s@ %" PRIu64 "\n", key, data, off); #endif if (0 == strcmp (key, "text")) { if (off + size > sizeof (seen)) exit (6); memcpy (&seen[off], data, size); if ( (10 == off + size) && (0 == memcmp (seen, "text, text", 10)) ) found |= 1; } return MHD_YES; } static enum MHD_Result post_data_iterator3 (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { (void) cls; (void) kind; (void) filename; /* Mute compiler warnings */ (void) content_type; (void) transfer_encoding; (void) off; /* FIXME: shouldn't be checked? */ #if DEBUG fprintf (stderr, "%s\t%s\n", key, data); #endif if (0 == strcmp (key, "y")) { if ( (1 != size) || (0 != memcmp (data, "y", 1)) ) exit (1); found |= 1; } return MHD_YES; } static enum MHD_Result post_data_iterator4 (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { (void) cls; (void) kind; (void) key; /* Mute compiler warnings */ (void) filename; (void) content_type; (void) transfer_encoding; (void) off; /* FIXME: shouldn't be checked? */ #if DEBUG fprintf (stderr, "%s\t%s\n", key, data); #endif if (NULL != memchr (data, 'M', size)) { found |= 1; } return MHD_YES; } static enum MHD_Result post_data_iterator5 (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { (void) cls; (void) kind; (void) key; /* Mute compiler warnings */ (void) filename; (void) content_type; (void) transfer_encoding; (void) data; (void) off; (void) size; found++; return MHD_YES; } int main (int argc, char *argv[]) { struct MHD_PostProcessor *postprocessor; (void) argc; (void) argv; if (1) { found = 0; postprocessor = malloc (sizeof (struct MHD_PostProcessor) + 0x1000 + 1); if (NULL == postprocessor) return 77; memset (postprocessor, 0, sizeof (struct MHD_PostProcessor) + 0x1000 + 1); postprocessor->ikvi = &post_data_iterator; postprocessor->encoding = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; postprocessor->buffer_size = 0x1000; postprocessor->state = PP_Init; postprocessor->skip_rn = RN_Inactive; if (MHD_YES != MHD_post_process (postprocessor, "xxxx=xxxx", 9)) exit (1); if (MHD_YES != MHD_post_process (postprocessor, "&yyyy=yyyy&zzzz=&aaaa=", 22)) exit (1); if (MHD_YES != MHD_post_process (postprocessor, "", 0)) exit (1); if (MHD_YES != MHD_destroy_post_processor (postprocessor)) exit (3); if (found != 15) exit (2); } if (1) { found = 0; postprocessor = malloc (sizeof (struct MHD_PostProcessor) + 0x1000 + 1); if (NULL == postprocessor) return 77; memset (postprocessor, 0, sizeof (struct MHD_PostProcessor) + 0x1000 + 1); postprocessor->ikvi = post_data_iterator2; postprocessor->encoding = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; postprocessor->buffer_size = 0x1000; postprocessor->state = PP_Init; postprocessor->skip_rn = RN_Inactive; if (MHD_YES != MHD_post_process (postprocessor, "text=text%2", 11)) exit (1); if (MHD_YES != MHD_post_process (postprocessor, "C+text", 6)) exit (1); if (MHD_YES != MHD_post_process (postprocessor, "", 0)) exit (1); if (MHD_YES != MHD_destroy_post_processor (postprocessor)) exit (1); if (found != 1) exit (4); } if (1) { found = 0; postprocessor = malloc (sizeof (struct MHD_PostProcessor) + 0x1000 + 1); if (NULL == postprocessor) return 77; memset (postprocessor, 0, sizeof (struct MHD_PostProcessor) + 0x1000 + 1); postprocessor->ikvi = post_data_iterator3; postprocessor->encoding = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; postprocessor->buffer_size = 0x1000; postprocessor->state = PP_Init; postprocessor->skip_rn = RN_Inactive; { const char *chunk = "x=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxx%2C%2C%2C%2C%2C%2Cxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2Cxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2Cxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxx%2C%2Cxxxxxxxxxxx%2C%2Cxxxxxx" "%2Cxxxx%2C%2Cxxxxx%2Cxxxxxxxxx%2C%2Cxxx%2Cxxxxxxxxxxx_xxxxxxxxxxxxxxx" "%2Cxxxxx%2Cxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxx" "%2Cxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxx%2C%2Cxxxxx%2C%2Cx%2Cxxxxxxxxxxxxxxxxxxxx%2C%2Cxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C" "xxxxxxxx%2Cxxxxxxxxxxxxxxxx%2Cxxxxx%2Cxxxxxxx%2C%2Cxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxx%2C%2Cxx%2C%2Cx%2Cxx%2C%2Cxxxx%2Cxxx" "%2C%2Cx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C" "%2Cxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "x%2C%2C%2C%2C%2C%2C%2Cxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xx%2Cxxxxx%2Cxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxx%2Cxxxxx%2Cxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxxxxxxxxxxx%2C%2Cxxxxx" "xx%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxx%2Cxxxxxxxxxxx" "xxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cx%2Cx%2Cxxxxxxxxxxxxxxxxxxxxxx%2Cxxxx" "xxxxxx%2Cxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxx%2Cxx%2Cx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxx%2Cxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxxxxxxxxx%2" "Cxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxx%2Cxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx%2Cx" "xxxxxxxx%2Cxxxxxx%2Cxxxxxxxxx%2Cxxxxxxx%2Cxxxxx%2Cxxxxxxxxxxxxxxxxxxxx" "%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C" "%2C%2C%2C%2C%2Cxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%" "2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxx%2Cxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C" "%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2" "Cxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxx%2C%2Cxxxxxxxxxxxx%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2" "C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" "2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxx%2Cxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxx%2Cx%2Cxxxxxxxxx" "xxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2Cxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxx%2" "Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2" "C%2C%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxx%2Cx%2C%" "2Cx%2Cxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxx%2Cxxxxxxxxxx%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxx%2Cxxxx%2Cx" "xxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2Cxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxx" "xxx%2Cxxxxxxxxxxxxxxxxxx%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxx%2Cxxxxxxxxxx%2Cxxxxxxxxxxx%2C%2C%2Cxxxxxxxxxxxxxxxxxxxx%2Cx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cx" "xxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxx" "xx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxx" "xxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxx" "xxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C" "%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxx" "xxxxxx%2Cxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxx" "xxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2C" "xxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxx" "xxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx%2" "Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxx%2Cxxxxxxxxxxxx%2Cxxxx" "xxx%2Cxxxxxxxxxxxx%2Cxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxx%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxx%2Cxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxx%2Cx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxx" "xxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx" "xxxxxxxxxxx%2Cxxxxxxxxxx%2Cxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxx%2Cxxxxxxxx" "xxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxx%2Cxxxxxxxx%2Cxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx" "xxxxxxxxx%2Cxxxxx%2Cxxxx%2Cxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cx" "xxxxxxxxxxxxxxx%2Cx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxx%2Cx%2Cxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxx%2Cx%2Cxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" "2Cxxxxx%2Cxx%2Cxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxx%2Cxxxxxx%" "2Cxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxx%2Cxxx" "xx%2Cxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxx%2Cxxxxxxxxxxxx" "xxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%" "2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxx%2Cxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxx%2Cx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxx%2Cxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxx" "x%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxx" "xxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C" "%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxx%2C%2C%2C%2Cxxxxxxx" "xxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%" "2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxx%2C%2C%2Cxxxxxxxxxx%2Cxxx" "xxxx%2Cxxxxxxxxx%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxx%" "2C%2C%2Cxxxxxxxxx%2Cxxxxxxxx%2C" "&y=y&z=z"; if (MHD_YES != MHD_post_process (postprocessor, chunk, strlen (chunk) )) exit (1); } if (MHD_YES != MHD_post_process (postprocessor, "", 0)) exit (1); if (MHD_YES != MHD_destroy_post_processor (postprocessor)) exit (1); if (found != 1) exit (5); } if (1) { unsigned i; const char *chunks[] = { "t=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2Cxxxxx%2C%2Cx%2Cxxxxxxxx" "xxxxxxxxxxxx%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxx%2Cxxxxxxxxxxxxxxxx%2Cxxxxx%" "2Cxxxxxxx%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2Cxx%2C%2Cx%2" "Cxx%2C%2Cxxxx%2Cxxx%2C%2Cx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "x%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2" "Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxx%2C%2C%2C%2Cxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxx%2Cxxxxx%2Cxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxx%2Cxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxxx" "xxxxxxxx%2C%2Cxxxxxxx%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx" "xxxxx%2Cxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cx%2Cx%2Cxxxxxxxxxx" "xxxxxxxxxxxx%2Cxxxxxxxxxx%2Cxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xx%2Cxxxxx%2Cxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxx%2Cxxxx" "xxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx%2C" "xxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C" "%2C%2C%2C%2Cxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxx%2Cxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxx%2Cxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C" "%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxx" "xxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxx%2C%2Cxxxxxxxxxxxx%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2" "C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxx%2Cxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxx%2Cx%2Cxxxxxxxxxxxx" "xxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2Cxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxx%2Cxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2" "C%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxx%2Cxxxxxxxxx", /* one chunk: second line is dropped */ "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C" "xxxxxxxxxxxxxxxx%2Cx%2C%2Cx%2Cxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2Cxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxx%2C%2C%2Cxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxx" "xxxxxxxxxxxxx%2Cxxxx%2Cxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2Cxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2Cx%2C%2C" "%2C%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxx%2Cxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" "2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxx" "xxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "x%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxxx%2C%2C%2C%2C" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxx" "xxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxx%2Cxxxxxxx" "xxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxxxxxxx" "%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxx" "x%2Cxxxxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxx%2Cxxxxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxx" "xx%2Cxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxx%2Cxxxxxx%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxx%2Cxx%2Cxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxx%2Cxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%" "2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxx%2Cxx" "xxxxxxxx%2Cxxxxxxxxx%2Cxxxxxxx%2Cxxxxxxxxxx%2Cxxxxxxxxxxxxxx%2Cxxxxxxx" "xxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxx%2Cxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxx%2Cxxxx" "x%2Cxxxx%2Cxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxx%" "2Cx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxx%2Cx%2Cxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xx%2Cx%2Cxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxx%2Cxx%2Cx" "xxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxx%2Cxxxxxx%2Cxxxxxxxxxxxxxx" "xxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%" "2C%2C%2C%2Cxxxxxxxxxxx%2C%2Cxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxx%2Cxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2" "Cxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxx" "xxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2" "C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxx%2C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%2C%2C%2C%2C%2C%2C%2Cxxxxxxxxxxxxxx%2" "C%2C%2C%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxx%2Cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxZZZZZZZZZZZZZ%2C%2C%2C%2C" "%E2%80%A2MMMMMMMM%2C%2C%2C%2CMMMMMMMMMMMMMMMMMMMM%2CMMMMMMMMMMMMMMMMMM" "MMMMM%2CMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" "MMMMMMMMMMMMMMMMMMMMMMMMMM%2C%2C%2C%2CMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM" "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM%2CMMMMMMMMMMMMMMMMMMMM" "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM%2CMMMMMM" "MMMMMMMMMMMMMMMMMMMMMMMMMMMM" "zz", "", }; postprocessor = malloc (sizeof(struct MHD_PostProcessor) + 131076 + 1); if (NULL == postprocessor) return 77; memset (postprocessor, 0, sizeof (struct MHD_PostProcessor) + 0x1000 + 1); postprocessor->ikvi = post_data_iterator4; postprocessor->encoding = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; postprocessor->buffer_size = 131076; postprocessor->state = PP_Init; postprocessor->skip_rn = RN_Inactive; for (i = 0; i < ARRAY_LENGTH (chunks); ++i) { const char *chunk = chunks[i]; if (MHD_YES != MHD_post_process (postprocessor, chunk, strlen (chunk) )) exit (1); } if (MHD_YES != MHD_destroy_post_processor (postprocessor)) exit (1); if (found != 1) return 6; } if (1) { unsigned i; const char *chunks[] = { "XXXXXXXXXXXX=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&XXXXXX=&XXXXXXXXXXXXXX=X" "XXX+&XXXXXXXXXXXXXXX=XXXXXXXXX&XXXXXXXXXXXXX=XXXX%XX%XXXXXX&XXXXXXXXXX" "X=XXXXXXXXX&XXXXXXXXXXXXX=XXXXXXXXXX&XXXXXXXXXXXXXXX=XX&XXXXXXXXXXXXXX" "X=XXXXXXXXX&XXXXXXXXXXXXX=XXXXXX&XXXXXXXXXXX=XXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "XXXXXXXXXX", "&XXXXXXXX=XXXX", "", }; postprocessor = malloc (sizeof(struct MHD_PostProcessor) + 131076 + 1); found = 0; if (NULL == postprocessor) return 77; memset (postprocessor, 0, sizeof (struct MHD_PostProcessor) + 0x1000 + 1); postprocessor->ikvi = post_data_iterator5; postprocessor->encoding = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; postprocessor->buffer_size = 131076; postprocessor->state = PP_Init; postprocessor->skip_rn = RN_Inactive; for (i = 0; i < ARRAY_LENGTH (chunks); ++i) { const char *chunk = chunks[i]; if (MHD_YES != MHD_post_process (postprocessor, chunk, strlen (chunk) )) exit (1); } if (MHD_YES != MHD_destroy_post_processor (postprocessor)) exit (1); if (found != 12) return 7; } return EXIT_SUCCESS; } libmicrohttpd-1.0.1/src/microhttpd/md5.h0000644000175000017500000000637214441373361013656 /* This file is part of GNU libmicrohttpd Copyright (C) 2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/md5.h * @brief Calculation of MD5 digest * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_MD5_H #define MHD_MD5_H 1 #include "mhd_options.h" #include #ifdef HAVE_STDDEF_H #include /* for size_t */ #endif /* HAVE_STDDEF_H */ /** * Number of bits in single MD5 word. */ #define MD5_WORD_SIZE_BITS 32 /** * Number of bytes in single MD5 word. */ #define MD5_BYTES_IN_WORD (MD5_WORD_SIZE_BITS / 8) /** * Hash is kept internally as four 32-bit words. * This is intermediate hash size, used during computing the final digest. */ #define MD5_HASH_SIZE_WORDS 4 /** * Size of MD5 resulting digest in bytes. * This is the final digest size, not intermediate hash. */ #define MD5_DIGEST_SIZE_WORDS MD5_HASH_SIZE_WORDS /** * Size of MD5 resulting digest in bytes * This is the final digest size, not intermediate hash. */ #define MD5_DIGEST_SIZE (MD5_DIGEST_SIZE_WORDS * MD5_BYTES_IN_WORD) /** * Size of MD5 digest string in chars including termination NUL. */ #define MD5_DIGEST_STRING_SIZE ((MD5_DIGEST_SIZE) * 2 + 1) /** * Size of MD5 single processing block in bits. */ #define MD5_BLOCK_SIZE_BITS 512 /** * Size of MD5 single processing block in bytes. */ #define MD5_BLOCK_SIZE (MD5_BLOCK_SIZE_BITS / 8) /** * Size of MD5 single processing block in words. */ #define MD5_BLOCK_SIZE_WORDS (MD5_BLOCK_SIZE_BITS / MD5_WORD_SIZE_BITS) /** * MD5 calculation context */ struct Md5Ctx { uint32_t H[MD5_HASH_SIZE_WORDS]; /**< Intermediate hash value / digest at end of calculation */ uint32_t buffer[MD5_BLOCK_SIZE_WORDS]; /**< MD5 input data buffer */ uint64_t count; /**< number of bytes, mod 2^64 */ }; /** * Initialise structure for MD5 calculation. * * @param ctx the calculation context */ void MHD_MD5_init (struct Md5Ctx *ctx); /** * MD5 process portion of bytes. * * @param ctx the calculation context * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_MD5_update (struct Md5Ctx *ctx, const uint8_t *data, size_t length); /** * Finalise MD5 calculation, return digest. * * @param ctx the calculation context * @param[out] digest set to the hash, must be #MD5_DIGEST_SIZE bytes */ void MHD_MD5_finish (struct Md5Ctx *ctx, uint8_t digest[MD5_DIGEST_SIZE]); /** * Indicates that function MHD_MD5_finish() (without context reset) is available */ #define MHD_MD5_HAS_FINISH 1 #endif /* MHD_MD5_H */ libmicrohttpd-1.0.1/src/microhttpd/tsearch.h0000644000175000017500000000113614417460232014610 /*- * Written by J.T. Conklin * Public domain. * * $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ */ #ifndef _TSEARCH_H_ #define _TSEARCH_H_ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ void *tdelete (const void *, void **, int (*)(const void *, const void *)); void *tfind (const void *, void * const *, int (*)(const void *, const void *)); void *tsearch (const void *, void **, int (*)(const void *, const void *)); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* !_TSEARCH_H_ */ libmicrohttpd-1.0.1/src/microhttpd/test_postprocessor.c0000644000175000017500000006677114556705750017171 /* This file is part of libmicrohttpd Copyright (C) 2007, 2013, 2019, 2020 Christian Grothoff Copyright (C) 2021 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_postprocessor.c * @brief Testcase for postprocessor * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include "internal.h" #include #include #include #include "mhd_compat.h" #ifndef WINDOWS #include #endif #ifndef MHD_DEBUG_PP #define MHD_DEBUG_PP 0 #endif /* MHD_DEBUG_PP */ struct expResult { const char *key; const char *fname; const char *cnt_type; const char *tr_enc; const char *data; }; /** * Array of values that the value checker "wants". * Each series of checks should be terminated by * five NULL-entries. */ static struct expResult exp_results[] = { #define URL_NOVALUE1_DATA "abc&x=5" #define URL_NOVALUE1_START 0 {"abc", NULL, NULL, NULL, /* NULL */ ""}, /* change after API update */ {"x", NULL, NULL, NULL, "5"}, #define URL_NOVALUE1_END (URL_NOVALUE1_START + 2) #define URL_NOVALUE2_DATA "abc=&x=5" #define URL_NOVALUE2_START URL_NOVALUE1_END {"abc", NULL, NULL, NULL, ""}, {"x", NULL, NULL, NULL, "5"}, #define URL_NOVALUE2_END (URL_NOVALUE2_START + 2) #define URL_NOVALUE3_DATA "xyz=" #define URL_NOVALUE3_START URL_NOVALUE2_END {"xyz", NULL, NULL, NULL, ""}, #define URL_NOVALUE3_END (URL_NOVALUE3_START + 1) #define URL_NOVALUE4_DATA "xyz" #define URL_NOVALUE4_START URL_NOVALUE3_END {"xyz", NULL, NULL, NULL, /* NULL */ ""}, /* change after API update */ #define URL_NOVALUE4_END (URL_NOVALUE4_START + 1) #define URL_DATA "abc=def&x=5" #define URL_START URL_NOVALUE4_END {"abc", NULL, NULL, NULL, "def"}, {"x", NULL, NULL, NULL, "5"}, #define URL_END (URL_START + 2) #define URL_ENC_DATA "space=%20&key%201=&crlf=%0D%0a&mix%09ed=%2001%0d%0A" #define URL_ENC_START URL_END {"space", NULL, NULL, NULL, " "}, {"key 1", NULL, NULL, NULL, ""}, {"crlf", NULL, NULL, NULL, "\r\n"}, {"mix\ted", NULL, NULL, NULL, " 01\r\n"}, #define URL_ENC_END (URL_ENC_START + 4) {NULL, NULL, NULL, NULL, NULL}, #define FORM_DATA \ "--AaB03x\r\ncontent-disposition: form-data; name=\"field1\"\r\n\r\n" \ "Joe Blow\r\n--AaB03x\r\ncontent-disposition: form-data; name=\"pics\";" \ " filename=\"file1.txt\"\r\nContent-Type: text/plain\r\n" \ "Content-Transfer-Encoding: binary\r\n\r\nfiledata\r\n--AaB03x--\r\n" #define FORM_START (URL_ENC_END + 1) {"field1", NULL, NULL, NULL, "Joe Blow"}, {"pics", "file1.txt", "text/plain", "binary", "filedata"}, #define FORM_END (FORM_START + 2) {NULL, NULL, NULL, NULL, NULL}, #define FORM_NESTED_DATA \ "--AaB03x\r\ncontent-disposition: form-data; name=\"field1\"\r\n\r\n" \ "Jane Blow\r\n--AaB03x\r\ncontent-disposition: form-data; name=\"pics\"\r\n" \ "Content-type: multipart/mixed, boundary=BbC04y\r\n\r\n--BbC04y\r\n" \ "Content-disposition: attachment; filename=\"file1.txt\"\r\n" \ "Content-Type: text/plain\r\n\r\nfiledata1\r\n--BbC04y\r\n" \ "Content-disposition: attachment; filename=\"file2.gif\"\r\n" \ "Content-type: image/gif\r\nContent-Transfer-Encoding: binary\r\n\r\n" \ "filedata2\r\n--BbC04y--\r\n--AaB03x--" #define FORM_NESTED_START (FORM_END + 1) {"field1", NULL, NULL, NULL, "Jane Blow"}, {"pics", "file1.txt", "text/plain", NULL, "filedata1"}, {"pics", "file2.gif", "image/gif", "binary", "filedata2"}, #define FORM_NESTED_END (FORM_NESTED_START + 3) {NULL, NULL, NULL, NULL, NULL}, #define URL_EMPTY_VALUE_DATA "key1=value1&key2=&key3=" #define URL_EMPTY_VALUE_START (FORM_NESTED_END + 1) {"key1", NULL, NULL, NULL, "value1"}, {"key2", NULL, NULL, NULL, ""}, {"key3", NULL, NULL, NULL, ""}, #define URL_EMPTY_VALUE_END (URL_EMPTY_VALUE_START + 3) {NULL, NULL, NULL, NULL, NULL} }; static int mismatch (const char *a, const char *b) { if (a == b) return 0; if ((a == NULL) || (b == NULL)) return 1; return 0 != strcmp (a, b); } static int mismatch2 (const char *data, const char *expected, size_t offset, size_t size) { if (data == expected) return 0; if ((data == NULL) || (expected == NULL)) return 1; return 0 != memcmp (data, expected + offset, size); } static enum MHD_Result value_checker (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { unsigned int *idxp = cls; struct expResult *expect = exp_results + *idxp; (void) kind; /* Unused. Silent compiler warning. */ #if MHD_DEBUG_PP fprintf (stderr, "VC: `%s' `%s' `%s' `%s' (+%u)`%.*s' (%d)\n", key ? key : "(NULL)", filename ? filename : "(NULL)", content_type ? content_type : "(NULL)", transfer_encoding ? transfer_encoding : "(NULL)", (unsigned int) off, (int) (data ? size : 6), data ? data : "(NULL)", (int) size); #endif if (*idxp == (unsigned int) -1) exit (99); if ( (0 != off) && (0 == size) ) { if (NULL == expect->data) *idxp += 1; return MHD_YES; } if ((expect->key == NULL) || (0 != strcmp (key, expect->key)) || (mismatch (filename, expect->fname)) || (mismatch (content_type, expect->cnt_type)) || (mismatch (transfer_encoding, expect->tr_enc)) || (strlen (expect->data) < off) || (mismatch2 (data, expect->data, (size_t) off, size))) { *idxp = (unsigned int) -1; fprintf (stderr, "Failed with: `%s' `%s' `%s' `%s' `%.*s'\n", key ? key : "(NULL)", filename ? filename : "(NULL)", content_type ? content_type : "(NULL)", transfer_encoding ? transfer_encoding : "(NULL)", (int) (data ? size : 6), data ? data : "(NULL)"); fprintf (stderr, "Wanted: `%s' `%s' `%s' `%s' `%s'\n", expect->key ? expect->key : "(NULL)", expect->fname ? expect->fname : "(NULL)", expect->cnt_type ? expect->cnt_type : "(NULL)", expect->tr_enc ? expect->tr_enc : "(NULL)", expect->data ? expect->data : "(NULL)"); fprintf (stderr, "Unexpected result: %d/%d/%d/%d/%d/%d\n", (expect->key == NULL), (NULL != expect->key) && (0 != strcmp (key, expect->key)), (mismatch (filename, expect->fname)), (mismatch (content_type, expect->cnt_type)), (mismatch (transfer_encoding, expect->tr_enc)), (strlen (expect->data) < off) || (mismatch2 (data, expect->data, (size_t) off, size))); return MHD_NO; } if ( ( (NULL == expect->data) && (0 == off + size) ) || ( (NULL != expect->data) && (off + size == strlen (expect->data)) ) ) *idxp += 1; return MHD_YES; } static unsigned int test_urlencoding_case (unsigned int want_start, unsigned int want_end, const char *url_data) { size_t step; unsigned int errors = 0; const size_t size = strlen (url_data); for (step = 1; size >= step; ++step) { struct MHD_Connection connection; struct MHD_HTTP_Req_Header header; struct MHD_PostProcessor *pp; unsigned int want_off = want_start; size_t i; memset (&connection, 0, sizeof (struct MHD_Connection)); memset (&header, 0, sizeof (struct MHD_HTTP_Res_Header)); connection.rq.headers_received = &header; header.header = MHD_HTTP_HEADER_CONTENT_TYPE; header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; header.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_TYPE); header.value_size = MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED); header.kind = MHD_HEADER_KIND; pp = MHD_create_post_processor (&connection, 1024, &value_checker, &want_off); if (NULL == pp) { fprintf (stderr, "Failed to create post processor.\n" "Line: %u\n", (unsigned int) __LINE__); exit (50); } for (i = 0; size > i; i += step) { size_t left = size - i; if (MHD_YES != MHD_post_process (pp, &url_data[i], (left > step) ? step : left)) { fprintf (stderr, "Failed to process the data.\n" "i: %u. step: %u.\n" "Line: %u\n", (unsigned) i, (unsigned) step, (unsigned int) __LINE__); exit (49); } } MHD_destroy_post_processor (pp); if (want_off != want_end) { fprintf (stderr, "Test failed in line %u.\tStep: %u.\tData: \"%s\"\n" \ " Got: %u\tExpected: %u\n", (unsigned int) __LINE__, (unsigned int) step, url_data, want_off, want_end); errors++; } } return errors; } static unsigned int test_urlencoding (void) { unsigned int errorCount = 0; errorCount += test_urlencoding_case (URL_START, URL_END, URL_DATA); errorCount += test_urlencoding_case (URL_ENC_START, URL_ENC_END, URL_ENC_DATA); errorCount += test_urlencoding_case (URL_NOVALUE1_START, URL_NOVALUE1_END, URL_NOVALUE1_DATA); errorCount += test_urlencoding_case (URL_NOVALUE2_START, URL_NOVALUE2_END, URL_NOVALUE2_DATA); errorCount += test_urlencoding_case (URL_NOVALUE3_START, URL_NOVALUE3_END, URL_NOVALUE3_DATA); errorCount += test_urlencoding_case (URL_NOVALUE4_START, URL_NOVALUE4_START, /* No advance */ URL_NOVALUE4_DATA); errorCount += test_urlencoding_case (URL_EMPTY_VALUE_START, URL_EMPTY_VALUE_END, URL_EMPTY_VALUE_DATA); errorCount += test_urlencoding_case (URL_START, URL_END, URL_DATA "\n"); errorCount += test_urlencoding_case (URL_ENC_START, URL_ENC_END, URL_ENC_DATA "\n"); errorCount += test_urlencoding_case (URL_NOVALUE1_START, URL_NOVALUE1_END, URL_NOVALUE1_DATA "\n"); errorCount += test_urlencoding_case (URL_NOVALUE2_START, URL_NOVALUE2_END, URL_NOVALUE2_DATA "\n"); errorCount += test_urlencoding_case (URL_NOVALUE3_START, URL_NOVALUE3_END, URL_NOVALUE3_DATA "\n"); errorCount += test_urlencoding_case (URL_NOVALUE4_START, URL_NOVALUE4_END, /* With advance */ URL_NOVALUE4_DATA "\n"); errorCount += test_urlencoding_case (URL_EMPTY_VALUE_START, URL_EMPTY_VALUE_END, URL_EMPTY_VALUE_DATA "\n"); errorCount += test_urlencoding_case (URL_START, URL_END, "&&" URL_DATA); errorCount += test_urlencoding_case (URL_ENC_START, URL_ENC_END, "&&" URL_ENC_DATA); errorCount += test_urlencoding_case (URL_NOVALUE1_START, URL_NOVALUE1_END, "&&" URL_NOVALUE1_DATA); errorCount += test_urlencoding_case (URL_NOVALUE2_START, URL_NOVALUE2_END, "&&" URL_NOVALUE2_DATA); errorCount += test_urlencoding_case (URL_NOVALUE3_START, URL_NOVALUE3_END, "&&" URL_NOVALUE3_DATA); errorCount += test_urlencoding_case (URL_NOVALUE4_START, URL_NOVALUE4_START, /* No advance */ "&&" URL_NOVALUE4_DATA); errorCount += test_urlencoding_case (URL_EMPTY_VALUE_START, URL_EMPTY_VALUE_END, "&&" URL_EMPTY_VALUE_DATA); if (0 != errorCount) fprintf (stderr, "Test failed in line %u with %u errors\n", (unsigned int) __LINE__, errorCount); return errorCount; } static unsigned int test_multipart_garbage (void) { struct MHD_Connection connection; struct MHD_HTTP_Req_Header header; struct MHD_PostProcessor *pp; unsigned int want_off; size_t size = MHD_STATICSTR_LEN_ (FORM_DATA); size_t splitpoint; char xdata[MHD_STATICSTR_LEN_ (FORM_DATA) + 3]; /* fill in evil garbage at the beginning */ xdata[0] = '-'; xdata[1] = 'x'; xdata[2] = '\r'; memcpy (&xdata[3], FORM_DATA, size); size += 3; for (splitpoint = 1; splitpoint < size; splitpoint++) { want_off = FORM_START; memset (&connection, 0, sizeof (struct MHD_Connection)); memset (&header, 0, sizeof (struct MHD_HTTP_Res_Header)); connection.rq.headers_received = &header; header.header = MHD_HTTP_HEADER_CONTENT_TYPE; header.value = MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA ", boundary=AaB03x"; header.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_TYPE); header.value_size = MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA \ ", boundary=AaB03x"); header.kind = MHD_HEADER_KIND; pp = MHD_create_post_processor (&connection, 1024, &value_checker, &want_off); if (NULL == pp) { fprintf (stderr, "Failed to create post processor.\n" "Line: %u\n", (unsigned int) __LINE__); exit (50); } if (MHD_YES != MHD_post_process (pp, xdata, splitpoint)) { fprintf (stderr, "Test failed in line %u at point %d\n", (unsigned int) __LINE__, (int) splitpoint); exit (49); } if (MHD_YES != MHD_post_process (pp, &xdata[splitpoint], size - splitpoint)) { fprintf (stderr, "Test failed in line %u at point %u\n", (unsigned int) __LINE__, (unsigned int) splitpoint); exit (49); } MHD_destroy_post_processor (pp); if (want_off != FORM_END) { fprintf (stderr, "Test failed in line %u at point %u\n", (unsigned int) __LINE__, (unsigned int) splitpoint); return (unsigned int) splitpoint; } } return 0; } static unsigned int test_multipart_splits (void) { struct MHD_Connection connection; struct MHD_HTTP_Req_Header header; struct MHD_PostProcessor *pp; unsigned int want_off; size_t size; size_t splitpoint; size = strlen (FORM_DATA); for (splitpoint = 1; splitpoint < size; splitpoint++) { want_off = FORM_START; memset (&connection, 0, sizeof (struct MHD_Connection)); memset (&header, 0, sizeof (struct MHD_HTTP_Res_Header)); connection.rq.headers_received = &header; header.header = MHD_HTTP_HEADER_CONTENT_TYPE; header.value = MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA ", boundary=AaB03x"; header.header_size = strlen (header.header); header.value_size = strlen (header.value); header.kind = MHD_HEADER_KIND; pp = MHD_create_post_processor (&connection, 1024, &value_checker, &want_off); if (NULL == pp) { fprintf (stderr, "Failed to create post processor.\n" "Line: %u\n", (unsigned int) __LINE__); exit (50); } if (MHD_YES != MHD_post_process (pp, FORM_DATA, splitpoint)) { fprintf (stderr, "Test failed in line %u at point %d\n", (unsigned int) __LINE__, (int) splitpoint); exit (49); } if (MHD_YES != MHD_post_process (pp, &FORM_DATA[splitpoint], size - splitpoint)) { fprintf (stderr, "Test failed in line %u at point %u\n", (unsigned int) __LINE__, (unsigned int) splitpoint); exit (49); } MHD_destroy_post_processor (pp); if (want_off != FORM_END) { fprintf (stderr, "Test failed in line %u at point %u\n", (unsigned int) __LINE__, (unsigned int) splitpoint); return (unsigned int) splitpoint; } } return 0; } static unsigned int test_multipart (void) { struct MHD_Connection connection; struct MHD_HTTP_Req_Header header; struct MHD_PostProcessor *pp; unsigned int want_off = FORM_START; size_t i; size_t delta; size_t size; memset (&connection, 0, sizeof (struct MHD_Connection)); memset (&header, 0, sizeof (struct MHD_HTTP_Res_Header)); connection.rq.headers_received = &header; header.header = MHD_HTTP_HEADER_CONTENT_TYPE; header.value = MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA ", boundary=AaB03x"; header.kind = MHD_HEADER_KIND; header.header_size = strlen (header.header); header.value_size = strlen (header.value); pp = MHD_create_post_processor (&connection, 1024, &value_checker, &want_off); if (NULL == pp) { fprintf (stderr, "Failed to create post processor.\n" "Line: %u\n", (unsigned int) __LINE__); exit (50); } i = 0; size = strlen (FORM_DATA); while (i < size) { delta = 1 + ((size_t) MHD_random_ ()) % (size - i); if (MHD_YES != MHD_post_process (pp, &FORM_DATA[i], delta)) { fprintf (stderr, "Failed to process the data.\n" "i: %u. delta: %u.\n" "Line: %u\n", (unsigned) i, (unsigned) delta, (unsigned int) __LINE__); exit (49); } i += delta; } MHD_destroy_post_processor (pp); if (want_off != FORM_END) { fprintf (stderr, "Test failed in line %u\n", (unsigned int) __LINE__); return 2; } return 0; } static unsigned int test_nested_multipart (void) { struct MHD_Connection connection; struct MHD_HTTP_Req_Header header; struct MHD_PostProcessor *pp; unsigned int want_off = FORM_NESTED_START; size_t i; size_t delta; size_t size; memset (&connection, 0, sizeof (struct MHD_Connection)); memset (&header, 0, sizeof (struct MHD_HTTP_Res_Header)); connection.rq.headers_received = &header; header.header = MHD_HTTP_HEADER_CONTENT_TYPE; header.value = MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA ", boundary=AaB03x"; header.kind = MHD_HEADER_KIND; header.header_size = strlen (header.header); header.value_size = strlen (header.value); pp = MHD_create_post_processor (&connection, 1024, &value_checker, &want_off); if (NULL == pp) { fprintf (stderr, "Failed to create post processor.\n" "Line: %u\n", (unsigned int) __LINE__); exit (50); } i = 0; size = strlen (FORM_NESTED_DATA); while (i < size) { delta = 1 + ((size_t) MHD_random_ ()) % (size - i); if (MHD_YES != MHD_post_process (pp, &FORM_NESTED_DATA[i], delta)) { fprintf (stderr, "Failed to process the data.\n" "i: %u. delta: %u.\n" "Line: %u\n", (unsigned) i, (unsigned) delta, (unsigned int) __LINE__); exit (49); } i += delta; } MHD_destroy_post_processor (pp); if (want_off != FORM_NESTED_END) { fprintf (stderr, "Test failed in line %u\n", (unsigned int) __LINE__); return 4; } return 0; } static enum MHD_Result value_checker2 (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { (void) cls; (void) kind; (void) key; /* Mute compiler warnings */ (void) filename; (void) content_type; (void) transfer_encoding; (void) data; (void) off; (void) size; return MHD_YES; } static unsigned int test_overflow (void) { struct MHD_Connection connection; struct MHD_HTTP_Req_Header header; struct MHD_PostProcessor *pp; size_t i; size_t j; size_t delta; char *buf; memset (&connection, 0, sizeof (struct MHD_Connection)); memset (&header, 0, sizeof (struct MHD_HTTP_Res_Header)); connection.rq.headers_received = &header; header.header = MHD_HTTP_HEADER_CONTENT_TYPE; header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; header.header_size = strlen (header.header); header.value_size = strlen (header.value); header.kind = MHD_HEADER_KIND; for (i = 128; i < 1024 * 1024; i += 1024) { pp = MHD_create_post_processor (&connection, 1024, &value_checker2, NULL); if (NULL == pp) { fprintf (stderr, "Failed to create post processor.\n" "Line: %u\n", (unsigned int) __LINE__); exit (50); } buf = malloc (i); if (NULL == buf) return 1; memset (buf, 'A', i); buf[i / 2] = '='; delta = 1 + (((size_t) MHD_random_ ()) % (i - 1)); j = 0; while (j < i) { if (j + delta > i) delta = i - j; if (MHD_NO == MHD_post_process (pp, &buf[j], delta)) break; j += delta; } free (buf); MHD_destroy_post_processor (pp); } return 0; } static unsigned int test_empty_key (void) { const char form_data[] = "=abcdef"; size_t step; const size_t size = MHD_STATICSTR_LEN_ (form_data); for (step = 1; size >= step; ++step) { size_t i; struct MHD_Connection connection; struct MHD_HTTP_Req_Header header; struct MHD_PostProcessor *pp; memset (&connection, 0, sizeof (struct MHD_Connection)); memset (&header, 0, sizeof (struct MHD_HTTP_Res_Header)); connection.rq.headers_received = &header; connection.rq.headers_received_tail = &header; header.header = MHD_HTTP_HEADER_CONTENT_TYPE; header.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_TYPE); header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; header.value_size = MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED); header.kind = MHD_HEADER_KIND; pp = MHD_create_post_processor (&connection, 1024, &value_checker2, NULL); if (NULL == pp) { fprintf (stderr, "Failed to create post processor.\n" "Line: %u\n", (unsigned int) __LINE__); exit (50); } for (i = 0; size > i; i += step) { if (MHD_NO != MHD_post_process (pp, form_data + i, (step > size - i) ? (size - i) : step)) { fprintf (stderr, "Succeed to process the broken data.\n" "i: %u. step: %u.\n" "Line: %u\n", (unsigned) i, (unsigned) step, (unsigned int) __LINE__); exit (49); } } MHD_destroy_post_processor (pp); } return 0; } static unsigned int test_double_value (void) { const char form_data[] = URL_DATA "=abcdef"; size_t step; const size_t size = MHD_STATICSTR_LEN_ (form_data); const size_t safe_size = MHD_STATICSTR_LEN_ (URL_DATA); for (step = 1; size >= step; ++step) { size_t i; struct MHD_Connection connection; struct MHD_HTTP_Req_Header header; struct MHD_PostProcessor *pp; unsigned int results_off = URL_START; unsigned int results_final = results_off + 1; /* First value is correct */ memset (&connection, 0, sizeof (struct MHD_Connection)); memset (&header, 0, sizeof (struct MHD_HTTP_Res_Header)); connection.rq.headers_received = &header; connection.rq.headers_received_tail = &header; header.header = MHD_HTTP_HEADER_CONTENT_TYPE; header.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_TYPE); header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; header.value_size = MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED); header.kind = MHD_HEADER_KIND; pp = MHD_create_post_processor (&connection, 1024, &value_checker, &results_off); if (NULL == pp) { fprintf (stderr, "Failed to create post processor.\n" "Line: %u\n", (unsigned int) __LINE__); exit (50); } for (i = 0; size > i; i += step) { if (MHD_NO != MHD_post_process (pp, form_data + i, (step > size - i) ? (size - i) : step)) { if (safe_size == i + step) results_final = URL_END; if (safe_size < i + step) { fprintf (stderr, "Succeed to process the broken data.\n" "i: %u. step: %u.\n" "Line: %u\n", (unsigned) i, (unsigned) step, (unsigned int) __LINE__); exit (49); } } else { if (safe_size >= i + step) { fprintf (stderr, "Failed to process the data.\n" "i: %u. step: %u.\n" "Line: %u\n", (unsigned) i, (unsigned) step, (unsigned int) __LINE__); exit (49); } } } MHD_destroy_post_processor (pp); if (results_final != results_off) { fprintf (stderr, "Test failed in line %u.\tStep:%u\n Got: %u\tExpected: %u\n", (unsigned int) __LINE__, (unsigned int) step, results_off, results_final); return 1; } } return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errorCount += test_multipart_splits (); errorCount += test_multipart_garbage (); errorCount += test_urlencoding (); errorCount += test_multipart (); errorCount += test_nested_multipart (); errorCount += test_empty_key (); errorCount += test_double_value (); errorCount += test_overflow (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); return (errorCount == 0) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/microhttpd/mhd_sha256_wrap.h0000644000175000017500000000600714441373361016055 /* This file is part of GNU libmicrohttpd Copyright (C) 2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GNU libmicrohttpd. If not, see . */ /** * @file microhttpd/mhd_sha256_wrap.h * @brief Simple wrapper for selection of built-in/external SHA-256 * implementation * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_SHA256_WRAP_H #define MHD_SHA256_WRAP_H 1 #include "mhd_options.h" #include "mhd_options.h" #ifndef MHD_SHA256_SUPPORT #error This file must be used only when SHA-256 is enabled #endif #ifndef MHD_SHA256_TLSLIB #include "sha256.h" #else /* MHD_SHA256_TLSLIB */ #include "sha256_ext.h" #endif /* MHD_SHA256_TLSLIB */ #ifndef SHA256_DIGEST_SIZE /** * Size of SHA-256 resulting digest in bytes * This is the final digest size, not intermediate hash. */ #define SHA256_DIGEST_SIZE (32) #endif /* ! SHA256_DIGEST_SIZE */ #ifndef SHA256_DIGEST_STRING_SIZE /** * Size of MD5 digest string in chars including termination NUL. */ #define SHA256_DIGEST_STRING_SIZE ((SHA256_DIGEST_SIZE) * 2 + 1) #endif /* ! SHA256_DIGEST_STRING_SIZE */ #ifndef MHD_SHA256_TLSLIB /** * Universal ctx type mapped for chosen implementation */ #define Sha256CtxWr Sha256Ctx #else /* MHD_SHA256_TLSLIB */ /** * Universal ctx type mapped for chosen implementation */ #define Sha256CtxWr Sha256CtxExt #endif /* MHD_SHA256_TLSLIB */ #ifndef MHD_SHA256_HAS_INIT_ONE_TIME /** * Setup and prepare ctx for hash calculation */ #define MHD_SHA256_init_one_time(ctx) MHD_SHA256_init(ctx) #endif /* ! MHD_SHA256_HAS_INIT_ONE_TIME */ #ifndef MHD_SHA256_HAS_FINISH_RESET /** * Re-use the same ctx for the new hashing after digest calculated */ #define MHD_SHA256_reset(ctx) MHD_SHA256_init(ctx) /** * Finalise MD5 calculation, return digest, reset hash calculation. */ #define MHD_SHA256_finish_reset(ctx,digest) MHD_SHA256_finish(ctx,digest), \ MHD_SHA256_reset(ctx) #else /* MHD_SHA256_HAS_FINISH_RESET */ #define MHD_SHA256_reset(ctx) (void)0 #endif /* MHD_SHA256_HAS_FINISH_RESET */ #ifndef MHD_SHA256_HAS_DEINIT #define MHD_SHA256_deinit(ignore) (void)0 #endif /* HAVE_SHA256_DEINIT */ /* Sanity checks */ #if ! defined(MHD_SHA256_HAS_FINISH_RESET) && ! defined(MHD_SHA256_HAS_FINISH) #error Required MHD_SHA256_finish_reset() or MHD_SHA256_finish_reset() #endif /* ! MHD_SHA256_HAS_FINISH_RESET && ! MHD_SHA256_HAS_FINISH */ #endif /* MHD_SHA256_WRAP_H */ libmicrohttpd-1.0.1/src/microhttpd/mhd_panic.c0000644000175000017500000000577214441373361015111 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_panic.h * @brief MHD_panic() function and helpers * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "mhd_panic.h" #include "platform.h" #include "microhttpd.h" /** * Handler for fatal errors. */ MHD_PanicCallback mhd_panic = (MHD_PanicCallback) NULL; /** * Closure argument for #mhd_panic. */ void *mhd_panic_cls = NULL; /** * Default implementation of the panic function, * prints an error message and aborts. * * @param cls unused * @param file name of the file with the problem * @param line line number with the problem * @param reason error message with details */ _MHD_NORETURN static void mhd_panic_std (void *cls, const char *file, unsigned int line, const char *reason) { (void) cls; /* Mute compiler warning. */ #ifdef HAVE_MESSAGES fprintf (stderr, _ ("Fatal error in GNU libmicrohttpd %s:%u: %s\n"), file, line, reason); #else /* ! HAVE_MESSAGES */ (void) file; /* Mute compiler warning. */ (void) line; /* Mute compiler warning. */ (void) reason; /* Mute compiler warning. */ #endif abort (); } /** * Sets the global error handler to a different implementation. * * @a cb will only be called in the case of typically fatal, serious internal * consistency issues or serious system failures like failed lock of mutex. * * These issues should only arise in the case of serious memory corruption or * similar problems with the architecture, there is no safe way to continue * even for closing of the application. * * The default implementation that is used if no panic function is set simply * prints an error message and calls `abort()`. * Alternative implementations might call `exit()` or other similar functions. * * @param cb new error handler or NULL to use default handler * @param cls passed to @a cb * @ingroup logging */ _MHD_EXTERN void MHD_set_panic_func (MHD_PanicCallback cb, void *cls) { if ((MHD_PanicCallback) NULL != cb) mhd_panic = cb; else mhd_panic = &mhd_panic_std; mhd_panic_cls = cls; } libmicrohttpd-1.0.1/src/microhttpd/mhd_send.c0000644000175000017500000015225414556705750014756 /* This file is part of libmicrohttpd Copyright (C) 2017-2023 Karlson2k (Evgeny Grin), Full re-write of buffering and pushing, many bugs fixes, optimisations, sendfile() porting Copyright (C) 2019 ng0 , Initial version of send() wrappers This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_send.c * @brief Implementation of send() wrappers and helper functions. * @author Karlson2k (Evgeny Grin) * @author ng0 (N. Gillmann) * @author Christian Grothoff */ /* Worth considering for future improvements and additions: * NetBSD has no sendfile or sendfile64. The way to work * with this seems to be to mmap the file and write(2) as * large a chunk as possible to the socket. Alternatively, * use madvise(..., MADV_SEQUENTIAL). */ #include "mhd_send.h" #ifdef MHD_LINUX_SOLARIS_SENDFILE #include #endif /* MHD_LINUX_SOLARIS_SENDFILE */ #if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_DARWIN_SENDFILE) #include #include #include #endif /* HAVE_FREEBSD_SENDFILE || HAVE_DARWIN_SENDFILE */ #ifdef HAVE_SYS_PARAM_H /* For FreeBSD version identification */ #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYSCONF #include #endif /* HAVE_SYSCONF */ #include "mhd_assert.h" #include "mhd_limits.h" #ifdef MHD_VECT_SEND #if (! defined(HAVE_SENDMSG) || ! defined(MSG_NOSIGNAL)) && \ defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) && \ defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) #define _MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED 1 #endif /* (!HAVE_SENDMSG || !MSG_NOSIGNAL) && MHD_SEND_SPIPE_SUPPRESS_POSSIBLE && MHD_SEND_SPIPE_SUPPRESS_NEEDED */ #endif /* MHD_VECT_SEND */ /** * sendfile() chuck size */ #define MHD_SENFILE_CHUNK_ (0x20000) /** * sendfile() chuck size for thread-per-connection */ #define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000) #ifdef HAVE_FREEBSD_SENDFILE #ifdef SF_FLAGS /** * FreeBSD sendfile() flags */ static int freebsd_sendfile_flags_; /** * FreeBSD sendfile() flags for thread-per-connection */ static int freebsd_sendfile_flags_thd_p_c_; /** * Initialises variables for FreeBSD's sendfile() */ static void freebsd_sendfile_init_ (void) { long sys_page_size = sysconf (_SC_PAGESIZE); if (0 >= sys_page_size) { /* Failed to get page size. */ freebsd_sendfile_flags_ = SF_NODISKIO; freebsd_sendfile_flags_thd_p_c_ = SF_NODISKIO; } else { freebsd_sendfile_flags_ = SF_FLAGS ((uint16_t) ((MHD_SENFILE_CHUNK_ + sys_page_size - 1) / sys_page_size), SF_NODISKIO); freebsd_sendfile_flags_thd_p_c_ = SF_FLAGS ((uint16_t) ((MHD_SENFILE_CHUNK_THR_P_C_ + sys_page_size - 1) / sys_page_size), SF_NODISKIO); } } #endif /* SF_FLAGS */ #endif /* HAVE_FREEBSD_SENDFILE */ #if defined(HAVE_SYSCONF) && defined(_SC_IOV_MAX) /** * Current IOV_MAX system value */ static unsigned long mhd_iov_max_ = 0; static void iov_max_init_ (void) { long res = sysconf (_SC_IOV_MAX); if (res >= 0) mhd_iov_max_ = (unsigned long) res; else { #if defined(IOV_MAX) mhd_iov_max_ = IOV_MAX; #else /* ! IOV_MAX */ mhd_iov_max_ = 8; /* Should be the safe limit */ #endif /* ! IOV_MAX */ } } /** * IOV_MAX (run-time) value */ #define _MHD_IOV_MAX mhd_iov_max_ #elif defined(IOV_MAX) /** * IOV_MAX (static) value */ #define _MHD_IOV_MAX IOV_MAX #endif /* HAVE_SYSCONF && _SC_IOV_MAX */ /** * Initialises static variables */ void MHD_send_init_static_vars_ (void) { #ifdef HAVE_FREEBSD_SENDFILE /* FreeBSD 11 and later allow to specify read-ahead size * and handles SF_NODISKIO differently. * SF_FLAGS defined only on FreeBSD 11 and later. */ #ifdef SF_FLAGS freebsd_sendfile_init_ (); #endif /* SF_FLAGS */ #endif /* HAVE_FREEBSD_SENDFILE */ #if defined(HAVE_SYSCONF) && defined(_SC_IOV_MAX) iov_max_init_ (); #endif /* HAVE_SYSCONF && _SC_IOV_MAX */ } bool MHD_connection_set_nodelay_state_ (struct MHD_Connection *connection, bool nodelay_state) { #ifdef TCP_NODELAY const MHD_SCKT_OPT_BOOL_ off_val = 0; const MHD_SCKT_OPT_BOOL_ on_val = 1; int err_code; if (_MHD_YES == connection->is_nonip) return false; if (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, (const void *) (nodelay_state ? &on_val : &off_val), sizeof (off_val))) { connection->sk_nodelay = nodelay_state; return true; } err_code = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_EINVAL_) || MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_ENOPROTOOPT_) || MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_ENOTSOCK_)) { if (_MHD_UNKNOWN == connection->is_nonip) connection->is_nonip = _MHD_YES; #ifdef HAVE_MESSAGES else { MHD_DLOG (connection->daemon, _ ("Setting %s option to %s state failed " "for TCP/IP socket %d: %s\n"), "TCP_NODELAY", nodelay_state ? _ ("ON") : _ ("OFF"), (int) connection->socket_fd, MHD_socket_strerr_ (err_code)); } #endif /* HAVE_MESSAGES */ } #ifdef HAVE_MESSAGES else { MHD_DLOG (connection->daemon, _ ("Setting %s option to %s state failed: %s\n"), "TCP_NODELAY", nodelay_state ? _ ("ON") : _ ("OFF"), MHD_socket_strerr_ (err_code)); } #endif /* HAVE_MESSAGES */ #else /* ! TCP_NODELAY */ (void) connection; (void) nodelay_state; /* Mute compiler warnings */ #endif /* ! TCP_NODELAY */ return false; } /** * Set required cork state for connection socket * * The function automatically updates sk_corked state. * * @param connection the connection to manipulate * @param cork_state the requested new state of socket * @return true if succeed, false if failed or not supported * by the current platform / kernel. */ bool MHD_connection_set_cork_state_ (struct MHD_Connection *connection, bool cork_state) { #if defined(MHD_TCP_CORK_NOPUSH) const MHD_SCKT_OPT_BOOL_ off_val = 0; const MHD_SCKT_OPT_BOOL_ on_val = 1; int err_code; if (_MHD_YES == connection->is_nonip) return false; if (0 == setsockopt (connection->socket_fd, IPPROTO_TCP, MHD_TCP_CORK_NOPUSH, (const void *) (cork_state ? &on_val : &off_val), sizeof (off_val))) { connection->sk_corked = cork_state; return true; } err_code = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_EINVAL_) || MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_ENOPROTOOPT_) || MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_ENOTSOCK_)) { if (_MHD_UNKNOWN == connection->is_nonip) connection->is_nonip = _MHD_YES; #ifdef HAVE_MESSAGES else { MHD_DLOG (connection->daemon, _ ("Setting %s option to %s state failed " "for TCP/IP socket %d: %s\n"), #ifdef TCP_CORK "TCP_CORK", #else /* ! TCP_CORK */ "TCP_NOPUSH", #endif /* ! TCP_CORK */ cork_state ? _ ("ON") : _ ("OFF"), (int) connection->socket_fd, MHD_socket_strerr_ (err_code)); } #endif /* HAVE_MESSAGES */ } #ifdef HAVE_MESSAGES else { MHD_DLOG (connection->daemon, _ ("Setting %s option to %s state failed: %s\n"), #ifdef TCP_CORK "TCP_CORK", #else /* ! TCP_CORK */ "TCP_NOPUSH", #endif /* ! TCP_CORK */ cork_state ? _ ("ON") : _ ("OFF"), MHD_socket_strerr_ (err_code)); } #endif /* HAVE_MESSAGES */ #else /* ! MHD_TCP_CORK_NOPUSH */ (void) connection; (void) cork_state; /* Mute compiler warnings. */ #endif /* ! MHD_TCP_CORK_NOPUSH */ return false; } /** * Handle pre-send setsockopt calls. * * @param connection the MHD_Connection structure * @param plain_send set to true if plain send() or sendmsg() will be called, * set to false if TLS socket send(), sendfile() or * writev() will be called. * @param push_data whether to push data to the network from buffers after * the next call of send function. */ static void pre_send_setopt (struct MHD_Connection *connection, bool plain_send, bool push_data) { /* Try to buffer data if not sending the final piece. * Final piece is indicated by push_data == true. */ const bool buffer_data = (! push_data); if (_MHD_YES == connection->is_nonip) return; /* The goal is to minimise the total number of additional sys-calls * before and after send(). * The following tricky (over-)complicated algorithm typically use zero, * one or two additional sys-calls (depending on OS) for each response. */ if (buffer_data) { /* Need to buffer data if possible. */ #ifdef MHD_USE_MSG_MORE if (plain_send) return; /* Data is buffered by send() with MSG_MORE flag. * No need to check or change anything. */ #else /* ! MHD_USE_MSG_MORE */ (void) plain_send; /* Mute compiler warning. */ #endif /* ! MHD_USE_MSG_MORE */ #ifdef MHD_TCP_CORK_NOPUSH if (_MHD_ON == connection->sk_corked) return; /* The connection was already corked. */ if (MHD_connection_set_cork_state_ (connection, true)) return; /* The connection has been corked. */ /* Failed to cork the connection. * Really unlikely to happen on TCP connections. */ #endif /* MHD_TCP_CORK_NOPUSH */ if (_MHD_OFF == connection->sk_nodelay) return; /* TCP_NODELAY was not set for the socket. * Nagle's algorithm will buffer some data. */ /* Try to reset TCP_NODELAY state for the socket. * Ignore possible error as no other options exist to * buffer data. */ MHD_connection_set_nodelay_state_ (connection, false); /* TCP_NODELAY has been (hopefully) reset for the socket. * Nagle's algorithm will buffer some data. */ return; } /* Need to push data after send() */ /* If additional sys-call is required prefer to make it after the send() * as the next send() may consume only part of the prepared data and * more send() calls will be used. */ #ifdef MHD_TCP_CORK_NOPUSH #ifdef _MHD_CORK_RESET_PUSH_DATA #ifdef _MHD_CORK_RESET_PUSH_DATA_ALWAYS /* Data can be pushed immediately by uncorking socket regardless of * cork state before. */ /* This is typical for Linux, no other kernel with * such behavior are known so far. */ /* No need to check the current state of TCP_CORK / TCP_NOPUSH * as reset of cork will push the data anyway. */ return; /* Data may be pushed by resetting of * TCP_CORK / TCP_NOPUSH after send() */ #else /* ! _MHD_CORK_RESET_PUSH_DATA_ALWAYS */ /* Reset of TCP_CORK / TCP_NOPUSH will push the data * only if socket is corked. */ #ifdef _MHD_NODELAY_SET_PUSH_DATA_ALWAYS /* Data can be pushed immediately by setting TCP_NODELAY regardless * of TCP_NODDELAY or corking state before. */ /* Dead code currently, no known kernels with such behavior. */ return; /* Data may be pushed by setting of TCP_NODELAY after send(). No need to make extra sys-calls before send().*/ #else /* ! _MHD_NODELAY_SET_PUSH_DATA_ALWAYS */ #ifdef _MHD_NODELAY_SET_PUSH_DATA /* Setting of TCP_NODELAY will push the data only if * both TCP_NODELAY and TCP_CORK / TCP_NOPUSH were not set. */ /* Data can be pushed immediately by uncorking socket if * socket was corked before or by setting TCP_NODELAY if * socket was not corked and TCP_NODELAY was not set before. */ /* Dead code currently as Linux is the only kernel that push * data by setting of TCP_NODELAY and Linux push data always. */ #else /* ! _MHD_NODELAY_SET_PUSH_DATA */ /* Data can be pushed immediately by uncorking socket or * can be pushed by send() on uncorked socket if * TCP_NODELAY was set *before*. */ /* This is typical FreeBSD behavior. */ #endif /* ! _MHD_NODELAY_SET_PUSH_DATA */ if (_MHD_ON == connection->sk_corked) return; /* Socket is corked. Data can be pushed by resetting of * TCP_CORK / TCP_NOPUSH after send() */ else if (_MHD_OFF == connection->sk_corked) { /* The socket is not corked. */ if (_MHD_ON == connection->sk_nodelay) return; /* TCP_NODELAY was already set, * data will be pushed automatically by the next send() */ #ifdef _MHD_NODELAY_SET_PUSH_DATA else if (_MHD_UNKNOWN == connection->sk_nodelay) { /* Setting TCP_NODELAY may push data. * Cork socket here and uncork after send(). */ if (MHD_connection_set_cork_state_ (connection, true)) return; /* The connection has been corked. * Data can be pushed by resetting of * TCP_CORK / TCP_NOPUSH after send() */ else { /* The socket cannot be corked. * Really unlikely to happen on TCP connections */ /* Have to set TCP_NODELAY. * If TCP_NODELAY real system state was OFF then * already buffered data may be pushed here, but this is unlikely * to happen as it is only a backup solution when corking has failed. * Ignore possible error here as no other options exist to * push data. */ MHD_connection_set_nodelay_state_ (connection, true); /* TCP_NODELAY has been (hopefully) set for the socket. * The data will be pushed by the next send(). */ return; } } #endif /* _MHD_NODELAY_SET_PUSH_DATA */ else { #ifdef _MHD_NODELAY_SET_PUSH_DATA /* TCP_NODELAY was switched off and * the socket is not corked. */ #else /* ! _MHD_NODELAY_SET_PUSH_DATA */ /* Socket is not corked and TCP_NODELAY was not set or unknown. */ #endif /* ! _MHD_NODELAY_SET_PUSH_DATA */ /* At least one additional sys-call is required. */ /* Setting TCP_NODELAY is optimal here as data will be pushed * automatically by the next send() and no additional * sys-call are needed after the send(). */ if (MHD_connection_set_nodelay_state_ (connection, true)) return; else { /* Failed to set TCP_NODELAY for the socket. * Really unlikely to happen on TCP connections. */ /* Cork the socket here and make additional sys-call * to uncork the socket after send(). */ /* Ignore possible error here as no other options exist to * push data. */ MHD_connection_set_cork_state_ (connection, true); /* The connection has been (hopefully) corked. * Data can be pushed by resetting of TCP_CORK / TCP_NOPUSH * after send() */ return; } } } /* Corked state is unknown. Need to make sys-call here otherwise * data may not be pushed. */ if (MHD_connection_set_cork_state_ (connection, true)) return; /* The connection has been corked. * Data can be pushed by resetting of * TCP_CORK / TCP_NOPUSH after send() */ /* The socket cannot be corked. * Really unlikely to happen on TCP connections */ if (_MHD_ON == connection->sk_nodelay) return; /* TCP_NODELAY was already set, * data will be pushed by the next send() */ /* Have to set TCP_NODELAY. */ #ifdef _MHD_NODELAY_SET_PUSH_DATA /* If TCP_NODELAY state was unknown (external connection) then * already buffered data may be pushed here, but this is unlikely * to happen as it is only a backup solution when corking has failed. */ #endif /* _MHD_NODELAY_SET_PUSH_DATA */ /* Ignore possible error here as no other options exist to * push data. */ MHD_connection_set_nodelay_state_ (connection, true); /* TCP_NODELAY has been (hopefully) set for the socket. * The data will be pushed by the next send(). */ return; #endif /* ! _MHD_NODELAY_SET_PUSH_DATA_ALWAYS */ #endif /* ! _MHD_CORK_RESET_PUSH_DATA_ALWAYS */ #else /* ! _MHD_CORK_RESET_PUSH_DATA */ /* Neither uncorking the socket or setting TCP_NODELAY * push the data immediately. */ /* The only way to push the data is to use send() on uncorked * socket with TCP_NODELAY switched on . */ /* This is a typical *BSD (except FreeBSD) and Darwin behavior. */ /* Uncork socket if socket wasn't uncorked. */ if (_MHD_OFF != connection->sk_corked) MHD_connection_set_cork_state_ (connection, false); /* Set TCP_NODELAY if it wasn't set. */ if (_MHD_ON != connection->sk_nodelay) MHD_connection_set_nodelay_state_ (connection, true); return; #endif /* ! _MHD_CORK_RESET_PUSH_DATA */ #else /* ! MHD_TCP_CORK_NOPUSH */ /* Buffering of data is controlled only by * Nagel's algorithm. */ /* Set TCP_NODELAY if it wasn't set. */ if (_MHD_ON != connection->sk_nodelay) MHD_connection_set_nodelay_state_ (connection, true); #endif /* ! MHD_TCP_CORK_NOPUSH */ } #ifndef _MHD_CORK_RESET_PUSH_DATA_ALWAYS /** * Send zero-sized data * * This function use send of zero-sized data to kick data from the socket * buffers to the network. The socket must not be corked and must have * TCP_NODELAY switched on. * Used only as last resort option, when other options are failed due to * some errors. * Should not be called on typical data processing. * @return true if succeed, false if failed */ static bool zero_send_ (struct MHD_Connection *connection) { int dummy; if (_MHD_YES == connection->is_nonip) return false; mhd_assert (_MHD_OFF == connection->sk_corked); mhd_assert (_MHD_ON == connection->sk_nodelay); dummy = 0; /* Mute compiler and analyzer warnings */ if (0 == MHD_send_ (connection->socket_fd, &dummy, 0)) return true; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Zero-send failed: %s\n"), MHD_socket_last_strerr_ () ); #endif /* HAVE_MESSAGES */ return false; } #endif /* ! _MHD_CORK_RESET_PUSH_DATA_ALWAYS */ /** * Handle post-send setsockopt calls. * * @param connection the MHD_Connection structure * @param plain_send_next set to true if plain send() or sendmsg() will be * called next, * set to false if TLS socket send(), sendfile() or * writev() will be called next. * @param push_data whether to push data to the network from buffers */ static void post_send_setopt (struct MHD_Connection *connection, bool plain_send_next, bool push_data) { /* Try to buffer data if not sending the final piece. * Final piece is indicated by push_data == true. */ const bool buffer_data = (! push_data); if (_MHD_YES == connection->is_nonip) return; if (buffer_data) return; /* Nothing to do after send(). */ #ifndef MHD_USE_MSG_MORE (void) plain_send_next; /* Mute compiler warning */ #endif /* ! MHD_USE_MSG_MORE */ /* Need to push data. */ #ifdef MHD_TCP_CORK_NOPUSH #ifdef _MHD_CORK_RESET_PUSH_DATA_ALWAYS #ifdef _MHD_NODELAY_SET_PUSH_DATA_ALWAYS #ifdef MHD_USE_MSG_MORE if (_MHD_OFF == connection->sk_corked) { if (_MHD_ON == connection->sk_nodelay) return; /* Data was already pushed by send(). */ } /* This is Linux kernel. There are options: * * Push the data by setting of TCP_NODELAY (without change * of the cork on the socket), * * Push the data by resetting of TCP_CORK. * The optimal choice depends on the next final send functions * used on the same socket. If TCP_NODELAY wasn't set then push * data by setting TCP_NODELAY (TCP_NODELAY will not be removed * and is needed to push the data by send() without MSG_MORE). * If send()/sendmsg() will be used next than push data by * resetting of TCP_CORK so next send without MSG_MORE will push * data to the network (without additional sys-call to push data). * If next final send function will not support MSG_MORE (like * sendfile() or TLS-connection) than push data by setting * TCP_NODELAY so socket will remain corked (no additional * sys-call before next send()). */ if ((_MHD_ON != connection->sk_nodelay) || (! plain_send_next)) { if (MHD_connection_set_nodelay_state_ (connection, true)) return; /* Data has been pushed by TCP_NODELAY. */ /* Failed to set TCP_NODELAY for the socket. * Really unlikely to happen on TCP connections. */ if (MHD_connection_set_cork_state_ (connection, false)) return; /* Data has been pushed by uncorking the socket. */ /* Failed to uncork the socket. * Really unlikely to happen on TCP connections. */ /* The socket cannot be uncorked, no way to push data */ } else { if (MHD_connection_set_cork_state_ (connection, false)) return; /* Data has been pushed by uncorking the socket. */ /* Failed to uncork the socket. * Really unlikely to happen on TCP connections. */ if (MHD_connection_set_nodelay_state_ (connection, true)) return; /* Data has been pushed by TCP_NODELAY. */ /* Failed to set TCP_NODELAY for the socket. * Really unlikely to happen on TCP connections. */ /* The socket cannot be uncorked, no way to push data */ } #else /* ! MHD_USE_MSG_MORE */ /* Use setting of TCP_NODELAY here to avoid sys-call * for corking the socket during sending of the next response. */ if (MHD_connection_set_nodelay_state_ (connection, true)) return; /* Data was pushed by TCP_NODELAY. */ /* Failed to set TCP_NODELAY for the socket. * Really unlikely to happen on TCP connections. */ if (MHD_connection_set_cork_state_ (connection, false)) return; /* Data was pushed by uncorking the socket. */ /* Failed to uncork the socket. * Really unlikely to happen on TCP connections. */ /* The socket remains corked, no way to push data */ #endif /* ! MHD_USE_MSG_MORE */ #else /* ! _MHD_NODELAY_SET_PUSH_DATA_ALWAYS */ if (MHD_connection_set_cork_state_ (connection, false)) return; /* Data was pushed by uncorking the socket. */ /* Failed to uncork the socket. * Really unlikely to happen on TCP connections. */ return; /* Socket remains corked, no way to push data */ #endif /* ! _MHD_NODELAY_SET_PUSH_DATA_ALWAYS */ #else /* ! _MHD_CORK_RESET_PUSH_DATA_ALWAYS */ /* This is a typical *BSD or Darwin kernel. */ if (_MHD_OFF == connection->sk_corked) { if (_MHD_ON == connection->sk_nodelay) return; /* Data was already pushed by send(). */ /* Unlikely to reach this code. * TCP_NODELAY should be turned on before send(). */ if (MHD_connection_set_nodelay_state_ (connection, true)) { /* TCP_NODELAY has been set on uncorked socket. * Use zero-send to push the data. */ if (zero_send_ (connection)) return; /* The data has been pushed by zero-send. */ } /* Failed to push the data by all means. */ /* There is nothing left to try. */ } else { #ifdef _MHD_CORK_RESET_PUSH_DATA enum MHD_tristate old_cork_state = connection->sk_corked; #endif /* _MHD_CORK_RESET_PUSH_DATA */ /* The socket is corked or cork state is unknown. */ if (MHD_connection_set_cork_state_ (connection, false)) { #ifdef _MHD_CORK_RESET_PUSH_DATA /* FreeBSD kernel */ if (_MHD_OFF == old_cork_state) return; /* Data has been pushed by uncorking the socket. */ #endif /* _MHD_CORK_RESET_PUSH_DATA */ /* Unlikely to reach this code. * The data should be pushed by uncorking (FreeBSD) or * the socket should be uncorked before send(). */ if ((_MHD_ON == connection->sk_nodelay) || (MHD_connection_set_nodelay_state_ (connection, true))) { /* TCP_NODELAY is turned ON on uncorked socket. * Use zero-send to push the data. */ if (zero_send_ (connection)) return; /* The data has been pushed by zero-send. */ } } /* The socket remains corked. Data cannot be pushed. */ } #endif /* ! _MHD_CORK_RESET_PUSH_DATA_ALWAYS */ #else /* ! MHD_TCP_CORK_NOPUSH */ /* Corking is not supported. Buffering is controlled * by TCP_NODELAY only. */ mhd_assert (_MHD_ON != connection->sk_corked); if (_MHD_ON == connection->sk_nodelay) return; /* Data was already pushed by send(). */ /* Unlikely to reach this code. * TCP_NODELAY should be turned on before send(). */ if (MHD_connection_set_nodelay_state_ (connection, true)) { /* TCP_NODELAY has been set. * Use zero-send to push the data. */ if (zero_send_ (connection)) return; /* The data has been pushed by zero-send. */ } /* Failed to push the data. */ #endif /* ! MHD_TCP_CORK_NOPUSH */ #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Failed to push the data from buffers to the network. " "Client may experience some delay " "(usually in range 200ms - 5 sec).\n")); #endif /* HAVE_MESSAGES */ return; } ssize_t MHD_send_data_ (struct MHD_Connection *connection, const char *buffer, size_t buffer_size, bool push_data) { MHD_socket s = connection->socket_fd; ssize_t ret; #ifdef HTTPS_SUPPORT const bool tls_conn = (connection->daemon->options & MHD_USE_TLS); #else /* ! HTTPS_SUPPORT */ const bool tls_conn = false; #endif /* ! HTTPS_SUPPORT */ if ( (MHD_INVALID_SOCKET == s) || (MHD_CONNECTION_CLOSED == connection->state) ) { return MHD_ERR_NOTCONN_; } if (buffer_size > SSIZE_MAX) { buffer_size = SSIZE_MAX; /* Max return value */ push_data = false; /* Incomplete send */ } if (tls_conn) { #ifdef HTTPS_SUPPORT pre_send_setopt (connection, (! tls_conn), push_data); ret = gnutls_record_send (connection->tls_session, buffer, buffer_size); if (GNUTLS_E_AGAIN == ret) { #ifdef EPOLL_SUPPORT connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); #endif return MHD_ERR_AGAIN_; } if (GNUTLS_E_INTERRUPTED == ret) return MHD_ERR_AGAIN_; if ( (GNUTLS_E_ENCRYPTION_FAILED == ret) || (GNUTLS_E_INVALID_SESSION == ret) || (GNUTLS_E_COMPRESSION_FAILED == ret) || (GNUTLS_E_EXPIRED == ret) || (GNUTLS_E_HASH_FAILED == ret) ) return MHD_ERR_TLS_; if ( (GNUTLS_E_PUSH_ERROR == ret) || (GNUTLS_E_INTERNAL_ERROR == ret) || (GNUTLS_E_CRYPTODEV_IOCTL_ERROR == ret) || (GNUTLS_E_CRYPTODEV_DEVICE_ERROR == ret) ) return MHD_ERR_PIPE_; #if defined(GNUTLS_E_PREMATURE_TERMINATION) if (GNUTLS_E_PREMATURE_TERMINATION == ret) return MHD_ERR_CONNRESET_; #elif defined(GNUTLS_E_UNEXPECTED_PACKET_LENGTH) if (GNUTLS_E_UNEXPECTED_PACKET_LENGTH == ret) return MHD_ERR_CONNRESET_; #endif /* GNUTLS_E_UNEXPECTED_PACKET_LENGTH */ if (GNUTLS_E_MEMORY_ERROR == ret) return MHD_ERR_NOMEM_; if (ret < 0) { /* Treat any other error as hard error. */ return MHD_ERR_NOTCONN_; } #ifdef EPOLL_SUPPORT /* Unlike non-TLS connections, do not reset "write-ready" if * sent amount smaller than provided amount, as TLS * connections may break data into smaller parts for sending. */ #endif /* EPOLL_SUPPORT */ #else /* ! HTTPS_SUPPORT */ ret = MHD_ERR_NOTCONN_; #endif /* ! HTTPS_SUPPORT */ } else { /* plaintext transmission */ if (buffer_size > MHD_SCKT_SEND_MAX_SIZE_) { buffer_size = MHD_SCKT_SEND_MAX_SIZE_; /* send() return value limit */ push_data = false; /* Incomplete send */ } pre_send_setopt (connection, (! tls_conn), push_data); #ifdef MHD_USE_MSG_MORE ret = MHD_send4_ (s, buffer, buffer_size, push_data ? 0 : MSG_MORE); #else ret = MHD_send4_ (s, buffer, buffer_size, 0); #endif if (0 > ret) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) { #ifdef EPOLL_SUPPORT /* EAGAIN, no longer write-ready */ connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); #endif /* EPOLL_SUPPORT */ return MHD_ERR_AGAIN_; } if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_ERR_AGAIN_; if (MHD_SCKT_ERR_IS_REMOTE_DISCNN_ (err)) return MHD_ERR_CONNRESET_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EPIPE_)) return MHD_ERR_PIPE_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EOPNOTSUPP_)) return MHD_ERR_OPNOTSUPP_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ENOTCONN_)) return MHD_ERR_NOTCONN_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINVAL_)) return MHD_ERR_INVAL_; if (MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err)) return MHD_ERR_NOMEM_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EBADF_)) return MHD_ERR_BADF_; /* Treat any other error as a hard error. */ return MHD_ERR_NOTCONN_; } #ifdef EPOLL_SUPPORT else if (buffer_size > (size_t) ret) connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); #endif /* EPOLL_SUPPORT */ } /* If there is a need to push the data from network buffers * call post_send_setopt(). */ /* If TLS connection is used then next final send() will be * without MSG_MORE support. If non-TLS connection is used * it's unknown whether sendfile() will be used or not so * assume that next call will be the same, like this call. */ if ( (push_data) && (buffer_size == (size_t) ret) ) post_send_setopt (connection, (! tls_conn), push_data); return ret; } ssize_t MHD_send_hdr_and_body_ (struct MHD_Connection *connection, const char *header, size_t header_size, bool never_push_hdr, const char *body, size_t body_size, bool complete_response) { ssize_t ret; bool push_hdr; bool push_body; MHD_socket s = connection->socket_fd; #ifndef _WIN32 #define _MHD_SEND_VEC_MAX MHD_SCKT_SEND_MAX_SIZE_ #else /* ! _WIN32 */ #define _MHD_SEND_VEC_MAX UINT32_MAX #endif /* ! _WIN32 */ #ifdef MHD_VECT_SEND #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV) struct iovec vector[2]; #ifdef HAVE_SENDMSG struct msghdr msg; #endif /* HAVE_SENDMSG */ #endif /* HAVE_SENDMSG || HAVE_WRITEV */ #ifdef _WIN32 WSABUF vector[2]; DWORD vec_sent; #endif /* _WIN32 */ bool no_vec; /* Is vector-send() disallowed? */ no_vec = false; #ifdef HTTPS_SUPPORT no_vec = no_vec || (connection->daemon->options & MHD_USE_TLS); #endif /* HTTPS_SUPPORT */ #if (! defined(HAVE_SENDMSG) || ! defined(MSG_NOSIGNAL) ) && \ defined(MHD_SEND_SPIPE_SEND_SUPPRESS_POSSIBLE) && \ defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) no_vec = no_vec || (! connection->daemon->sigpipe_blocked && ! connection->sk_spipe_suppress); #endif /* (!HAVE_SENDMSG || ! MSG_NOSIGNAL) && MHD_SEND_SPIPE_SEND_SUPPRESS_POSSIBLE && MHD_SEND_SPIPE_SUPPRESS_NEEDED */ #endif /* MHD_VECT_SEND */ mhd_assert ( (NULL != body) || (0 == body_size) ); if ( (MHD_INVALID_SOCKET == s) || (MHD_CONNECTION_CLOSED == connection->state) ) { return MHD_ERR_NOTCONN_; } push_body = complete_response; if (! never_push_hdr) { if (! complete_response) push_hdr = true; /* Push the header as the client may react * on header alone while the body data is * being prepared. */ else { if (1400 > (header_size + body_size)) push_hdr = false; /* Do not push the header as complete * reply is already ready and the whole * reply most probably will fit into * the single IP packet. */ else push_hdr = true; /* Push header alone so client may react * on it while reply body is being delivered. */ } } else push_hdr = false; if (complete_response && (0 == body_size)) push_hdr = true; /* The header alone is equal to the whole response. */ if ( #ifdef MHD_VECT_SEND (no_vec) || (0 == body_size) || ((size_t) SSIZE_MAX <= header_size) || ((size_t) _MHD_SEND_VEC_MAX < header_size) #ifdef _WIN32 || ((size_t) UINT_MAX < header_size) #endif /* _WIN32 */ #else /* ! MHD_VECT_SEND */ true #endif /* ! MHD_VECT_SEND */ ) { ret = MHD_send_data_ (connection, header, header_size, push_hdr); if ( (header_size == (size_t) ret) && ((size_t) SSIZE_MAX > header_size) && (0 != body_size) && (connection->sk_nonblck) ) { ssize_t ret2; /* The header has been sent completely. * Try to send the reply body without waiting for * the next round. */ /* Make sure that sum of ret + ret2 will not exceed SSIZE_MAX as * function needs to return positive value if succeed. */ if ( (((size_t) SSIZE_MAX) - ((size_t) ret)) < body_size) { body_size = (((size_t) SSIZE_MAX) - ((size_t) ret)); complete_response = false; push_body = complete_response; } ret2 = MHD_send_data_ (connection, body, body_size, push_body); if (0 < ret2) return ret + ret2; /* Total data sent */ if (MHD_ERR_AGAIN_ == ret2) return ret; return ret2; /* Error code */ } return ret; } #ifdef MHD_VECT_SEND if ( ((size_t) SSIZE_MAX <= body_size) || ((size_t) SSIZE_MAX < (header_size + body_size)) ) { /* Return value limit */ body_size = SSIZE_MAX - header_size; complete_response = false; push_body = complete_response; } #if (SSIZE_MAX != _MHD_SEND_VEC_MAX) || (_MHD_SEND_VEC_MAX + 0 == 0) if (((size_t) _MHD_SEND_VEC_MAX <= body_size) || ((size_t) _MHD_SEND_VEC_MAX < (header_size + body_size))) { /* Send total amount limit */ body_size = _MHD_SEND_VEC_MAX - header_size; complete_response = false; push_body = complete_response; } #endif /* SSIZE_MAX != _MHD_SEND_VEC_MAX */ pre_send_setopt (connection, #ifdef HAVE_SENDMSG true, #else /* ! HAVE_SENDMSG */ false, #endif /* ! HAVE_SENDMSG */ push_hdr || push_body); #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV) vector[0].iov_base = _MHD_DROP_CONST (header); vector[0].iov_len = header_size; vector[1].iov_base = _MHD_DROP_CONST (body); vector[1].iov_len = body_size; #if defined(HAVE_SENDMSG) memset (&msg, 0, sizeof(msg)); msg.msg_iov = vector; msg.msg_iovlen = 2; ret = sendmsg (s, &msg, MSG_NOSIGNAL_OR_ZERO); #elif defined(HAVE_WRITEV) ret = writev (s, vector, 2); #endif /* HAVE_WRITEV */ #endif /* HAVE_SENDMSG || HAVE_WRITEV */ #ifdef _WIN32 if ((size_t) UINT_MAX < body_size) { /* Send item size limit */ body_size = UINT_MAX; complete_response = false; push_body = complete_response; } vector[0].buf = (char *) _MHD_DROP_CONST (header); vector[0].len = (unsigned long) header_size; vector[1].buf = (char *) _MHD_DROP_CONST (body); vector[1].len = (unsigned long) body_size; ret = WSASend (s, vector, 2, &vec_sent, 0, NULL, NULL); if (0 == ret) ret = (ssize_t) vec_sent; else ret = -1; #endif /* _WIN32 */ if (0 > ret) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) { #ifdef EPOLL_SUPPORT /* EAGAIN, no longer write-ready */ connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); #endif /* EPOLL_SUPPORT */ return MHD_ERR_AGAIN_; } if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_ERR_AGAIN_; if (MHD_SCKT_ERR_IS_REMOTE_DISCNN_ (err)) return MHD_ERR_CONNRESET_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EPIPE_)) return MHD_ERR_PIPE_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EOPNOTSUPP_)) return MHD_ERR_OPNOTSUPP_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ENOTCONN_)) return MHD_ERR_NOTCONN_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINVAL_)) return MHD_ERR_INVAL_; if (MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err)) return MHD_ERR_NOMEM_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EBADF_)) return MHD_ERR_BADF_; /* Treat any other error as a hard error. */ return MHD_ERR_NOTCONN_; } #ifdef EPOLL_SUPPORT else if ((header_size + body_size) > (size_t) ret) connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); #endif /* EPOLL_SUPPORT */ /* If there is a need to push the data from network buffers * call post_send_setopt(). */ if ( (push_body) && ((header_size + body_size) == (size_t) ret) ) { /* Complete reply has been sent. */ /* If TLS connection is used then next final send() will be * without MSG_MORE support. If non-TLS connection is used * it's unknown whether next 'send' will be plain send() / sendmsg() or * sendfile() will be used so assume that next final send() will be * the same, like for this response. */ post_send_setopt (connection, #ifdef HAVE_SENDMSG true, #else /* ! HAVE_SENDMSG */ false, #endif /* ! HAVE_SENDMSG */ true); } else if ( (push_hdr) && (header_size <= (size_t) ret)) { /* The header has been sent completely and there is a * need to push the header data. */ /* Luckily the type of send function will be used next is known. */ post_send_setopt (connection, #if defined(_MHD_HAVE_SENDFILE) MHD_resp_sender_std == connection->rp.resp_sender, #else /* ! _MHD_HAVE_SENDFILE */ true, #endif /* ! _MHD_HAVE_SENDFILE */ true); } return ret; #else /* ! MHD_VECT_SEND */ mhd_assert (false); return MHD_ERR_CONNRESET_; /* Unreachable. Mute warnings. */ #endif /* ! MHD_VECT_SEND */ } #if defined(_MHD_HAVE_SENDFILE) ssize_t MHD_send_sendfile_ (struct MHD_Connection *connection) { ssize_t ret; const int file_fd = connection->rp.response->fd; uint64_t left; uint64_t offsetu64; #ifndef HAVE_SENDFILE64 const uint64_t max_off_t = (uint64_t) OFF_T_MAX; #else /* HAVE_SENDFILE64 */ const uint64_t max_off_t = (uint64_t) OFF64_T_MAX; #endif /* HAVE_SENDFILE64 */ #ifdef MHD_LINUX_SOLARIS_SENDFILE #ifndef HAVE_SENDFILE64 off_t offset; #else /* HAVE_SENDFILE64 */ off64_t offset; #endif /* HAVE_SENDFILE64 */ #endif /* MHD_LINUX_SOLARIS_SENDFILE */ #ifdef HAVE_FREEBSD_SENDFILE off_t sent_bytes; int flags = 0; #endif #ifdef HAVE_DARWIN_SENDFILE off_t len; #endif /* HAVE_DARWIN_SENDFILE */ const bool used_thr_p_c = MHD_D_IS_USING_THREAD_PER_CONN_ (connection->daemon); const size_t chunk_size = used_thr_p_c ? MHD_SENFILE_CHUNK_THR_P_C_ : MHD_SENFILE_CHUNK_; size_t send_size = 0; bool push_data; mhd_assert (MHD_resp_sender_sendfile == connection->rp.resp_sender); mhd_assert (0 == (connection->daemon->options & MHD_USE_TLS)); offsetu64 = connection->rp.rsp_write_position + connection->rp.response->fd_off; if (max_off_t < offsetu64) { /* Retry to send with standard 'send()'. */ connection->rp.resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; } left = connection->rp.response->total_size - connection->rp.rsp_write_position; if ( (uint64_t) SSIZE_MAX < left) left = SSIZE_MAX; /* Do not allow system to stick sending on single fast connection: * use 128KiB chunks (2MiB for thread-per-connection). */ if (chunk_size < left) { send_size = chunk_size; push_data = false; /* No need to push data, there is more to send. */ } else { send_size = (size_t) left; push_data = true; /* Final piece of data, need to push to the network. */ } pre_send_setopt (connection, false, push_data); #ifdef MHD_LINUX_SOLARIS_SENDFILE #ifndef HAVE_SENDFILE64 offset = (off_t) offsetu64; ret = sendfile (connection->socket_fd, file_fd, &offset, send_size); #else /* HAVE_SENDFILE64 */ offset = (off64_t) offsetu64; ret = sendfile64 (connection->socket_fd, file_fd, &offset, send_size); #endif /* HAVE_SENDFILE64 */ if (0 > ret) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) { #ifdef EPOLL_SUPPORT /* EAGAIN --- no longer write-ready */ connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); #endif /* EPOLL_SUPPORT */ return MHD_ERR_AGAIN_; } if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_ERR_AGAIN_; #ifdef HAVE_LINUX_SENDFILE if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EBADF_)) return MHD_ERR_BADF_; /* sendfile() failed with EINVAL if mmap()-like operations are not supported for FD or other 'unusual' errors occurred, so we should try to fall back to 'SEND'; see also this thread for info on odd libc/Linux behavior with sendfile: http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */ connection->rp.resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; #else /* HAVE_SOLARIS_SENDFILE */ if ( (EAFNOSUPPORT == err) || (EINVAL == err) || (EOPNOTSUPP == err) ) { /* Retry with standard file reader. */ connection->rp.resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; } if ( (ENOTCONN == err) || (EPIPE == err) ) { return MHD_ERR_CONNRESET_; } return MHD_ERR_BADF_; /* Fail hard */ #endif /* HAVE_SOLARIS_SENDFILE */ } #ifdef EPOLL_SUPPORT else if (send_size > (size_t) ret) connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); #endif /* EPOLL_SUPPORT */ #elif defined(HAVE_FREEBSD_SENDFILE) #ifdef SF_FLAGS flags = used_thr_p_c ? freebsd_sendfile_flags_thd_p_c_ : freebsd_sendfile_flags_; #endif /* SF_FLAGS */ if (0 != sendfile (file_fd, connection->socket_fd, (off_t) offsetu64, send_size, NULL, &sent_bytes, flags)) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err) || MHD_SCKT_ERR_IS_EINTR_ (err) || (EBUSY == err) ) { mhd_assert (SSIZE_MAX >= sent_bytes); if (0 != sent_bytes) return (ssize_t) sent_bytes; return MHD_ERR_AGAIN_; } /* Some unrecoverable error. Possibly file FD is not suitable * for sendfile(). Retry with standard send(). */ connection->rp.resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; } mhd_assert (0 < sent_bytes); mhd_assert (SSIZE_MAX >= sent_bytes); ret = (ssize_t) sent_bytes; #elif defined(HAVE_DARWIN_SENDFILE) len = (off_t) send_size; /* chunk always fit */ if (0 != sendfile (file_fd, connection->socket_fd, (off_t) offsetu64, &len, NULL, 0)) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err) || MHD_SCKT_ERR_IS_EINTR_ (err)) { mhd_assert (0 <= len); mhd_assert (SSIZE_MAX >= len); mhd_assert (send_size >= (size_t) len); if (0 != len) return (ssize_t) len; return MHD_ERR_AGAIN_; } if ((ENOTCONN == err) || (EPIPE == err) ) return MHD_ERR_CONNRESET_; if ((ENOTSUP == err) || (EOPNOTSUPP == err) ) { /* This file FD is not suitable for sendfile(). * Retry with standard send(). */ connection->rp.resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; } return MHD_ERR_BADF_; /* Return hard error. */ } mhd_assert (0 <= len); mhd_assert (SSIZE_MAX >= len); mhd_assert (send_size >= (size_t) len); ret = (ssize_t) len; #endif /* HAVE_FREEBSD_SENDFILE */ /* If there is a need to push the data from network buffers * call post_send_setopt(). */ /* It's unknown whether sendfile() will be used in the next * response so assume that next response will be the same. */ if ( (push_data) && (send_size == (size_t) ret) ) post_send_setopt (connection, false, push_data); return ret; } #endif /* _MHD_HAVE_SENDFILE */ #if defined(MHD_VECT_SEND) /** * Function sends iov data by system sendmsg or writev function. * * Connection must be in non-TLS (non-HTTPS) mode. * * @param connection the MHD connection structure * @param r_iov the pointer to iov data structure with tracking * @param push_data set to true to force push the data to the network from * system buffers (usually set for the last piece of data), * set to false to prefer holding incomplete network packets * (more data will be send for the same reply). * @return actual number of bytes sent */ static ssize_t send_iov_nontls (struct MHD_Connection *connection, struct MHD_iovec_track_ *const r_iov, bool push_data) { ssize_t res; size_t items_to_send; #ifdef HAVE_SENDMSG struct msghdr msg; #elif defined(MHD_WINSOCK_SOCKETS) DWORD bytes_sent; DWORD cnt_w; #endif /* MHD_WINSOCK_SOCKETS */ mhd_assert (0 == (connection->daemon->options & MHD_USE_TLS)); if ( (MHD_INVALID_SOCKET == connection->socket_fd) || (MHD_CONNECTION_CLOSED == connection->state) ) { return MHD_ERR_NOTCONN_; } items_to_send = r_iov->cnt - r_iov->sent; #ifdef _MHD_IOV_MAX if (_MHD_IOV_MAX < items_to_send) { mhd_assert (0 < _MHD_IOV_MAX); if (0 == _MHD_IOV_MAX) return MHD_ERR_NOTCONN_; /* Should never happen */ items_to_send = _MHD_IOV_MAX; push_data = false; /* Incomplete response */ } #endif /* _MHD_IOV_MAX */ #ifdef HAVE_SENDMSG memset (&msg, 0, sizeof(struct msghdr)); msg.msg_iov = r_iov->iov + r_iov->sent; msg.msg_iovlen = items_to_send; pre_send_setopt (connection, true, push_data); #ifdef MHD_USE_MSG_MORE res = sendmsg (connection->socket_fd, &msg, MSG_NOSIGNAL_OR_ZERO | (push_data ? 0 : MSG_MORE)); #else /* ! MHD_USE_MSG_MORE */ res = sendmsg (connection->socket_fd, &msg, MSG_NOSIGNAL_OR_ZERO); #endif /* ! MHD_USE_MSG_MORE */ #elif defined(HAVE_WRITEV) pre_send_setopt (connection, true, push_data); res = writev (connection->socket_fd, r_iov->iov + r_iov->sent, items_to_send); #elif defined(MHD_WINSOCK_SOCKETS) #ifdef _WIN64 if (items_to_send > UINT32_MAX) { cnt_w = UINT32_MAX; push_data = false; /* Incomplete response */ } else cnt_w = (DWORD) items_to_send; #else /* ! _WIN64 */ cnt_w = (DWORD) items_to_send; #endif /* ! _WIN64 */ pre_send_setopt (connection, true, push_data); if (0 == WSASend (connection->socket_fd, (LPWSABUF) (r_iov->iov + r_iov->sent), cnt_w, &bytes_sent, 0, NULL, NULL)) res = (ssize_t) bytes_sent; else res = -1; #else /* !HAVE_SENDMSG && !HAVE_WRITEV && !MHD_WINSOCK_SOCKETS */ #error No vector-send function available #endif if (0 > res) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) { #ifdef EPOLL_SUPPORT /* EAGAIN --- no longer write-ready */ connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); #endif /* EPOLL_SUPPORT */ return MHD_ERR_AGAIN_; } if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_ERR_AGAIN_; if (MHD_SCKT_ERR_IS_REMOTE_DISCNN_ (err)) return MHD_ERR_CONNRESET_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EPIPE_)) return MHD_ERR_PIPE_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EOPNOTSUPP_)) return MHD_ERR_OPNOTSUPP_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ENOTCONN_)) return MHD_ERR_NOTCONN_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINVAL_)) return MHD_ERR_INVAL_; if (MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err)) return MHD_ERR_NOMEM_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EBADF_)) return MHD_ERR_BADF_; /* Treat any other error as a hard error. */ return MHD_ERR_NOTCONN_; } /* Some data has been sent */ if (1) { size_t track_sent = (size_t) res; /* Adjust the internal tracking information for the iovec to * take this last send into account. */ while ((0 != track_sent) && (r_iov->iov[r_iov->sent].iov_len <= track_sent)) { track_sent -= r_iov->iov[r_iov->sent].iov_len; r_iov->sent++; /* The iov element has been completely sent */ mhd_assert ((r_iov->cnt > r_iov->sent) || (0 == track_sent)); } if (r_iov->cnt == r_iov->sent) post_send_setopt (connection, true, push_data); else { #ifdef EPOLL_SUPPORT connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); #endif /* EPOLL_SUPPORT */ if (0 != track_sent) { mhd_assert (r_iov->cnt > r_iov->sent); /* The last iov element has been partially sent */ r_iov->iov[r_iov->sent].iov_base = (void *) ((uint8_t *) r_iov->iov[r_iov->sent].iov_base + track_sent); r_iov->iov[r_iov->sent].iov_len -= (MHD_iov_size_) track_sent; } } } return res; } #endif /* MHD_VECT_SEND */ #if ! defined(MHD_VECT_SEND) || defined(HTTPS_SUPPORT) || \ defined(_MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED) /** * Function sends iov data by sending buffers one-by-one by standard * data send function. * * Connection could be in HTTPS or non-HTTPS mode. * * @param connection the MHD connection structure * @param r_iov the pointer to iov data structure with tracking * @param push_data set to true to force push the data to the network from * system buffers (usually set for the last piece of data), * set to false to prefer holding incomplete network packets * (more data will be send for the same reply). * @return actual number of bytes sent */ static ssize_t send_iov_emu (struct MHD_Connection *connection, struct MHD_iovec_track_ *const r_iov, bool push_data) { const bool non_blk = connection->sk_nonblck; size_t total_sent; ssize_t res; mhd_assert (NULL != r_iov->iov); total_sent = 0; do { if ((size_t) SSIZE_MAX - total_sent < r_iov->iov[r_iov->sent].iov_len) return (ssize_t) total_sent; /* return value would overflow */ res = MHD_send_data_ (connection, r_iov->iov[r_iov->sent].iov_base, r_iov->iov[r_iov->sent].iov_len, push_data && (r_iov->cnt == r_iov->sent + 1)); if (0 > res) { /* Result is an error */ if (0 == total_sent) return res; /* Nothing was sent, return result as is */ if (MHD_ERR_AGAIN_ == res) return (ssize_t) total_sent; /* Return the amount of the sent data */ return res; /* Any kind of a hard error */ } total_sent += (size_t) res; if (r_iov->iov[r_iov->sent].iov_len != (size_t) res) { const size_t sent = (size_t) res; /* Incomplete buffer has been sent. * Adjust buffer of the last element. */ r_iov->iov[r_iov->sent].iov_base = (void *) ((uint8_t *) r_iov->iov[r_iov->sent].iov_base + sent); r_iov->iov[r_iov->sent].iov_len -= (MHD_iov_size_) sent; return (ssize_t) total_sent; } /* The iov element has been completely sent */ r_iov->sent++; } while ((r_iov->cnt > r_iov->sent) && (non_blk)); return (ssize_t) total_sent; } #endif /* !MHD_VECT_SEND || HTTPS_SUPPORT || _MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED */ ssize_t MHD_send_iovec_ (struct MHD_Connection *connection, struct MHD_iovec_track_ *const r_iov, bool push_data) { #ifdef MHD_VECT_SEND #if defined(HTTPS_SUPPORT) || \ defined(_MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED) bool use_iov_send = true; #endif /* HTTPS_SUPPORT || _MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED */ #endif /* MHD_VECT_SEND */ mhd_assert (NULL != connection->rp.resp_iov.iov); mhd_assert (NULL != connection->rp.response->data_iov); mhd_assert (connection->rp.resp_iov.cnt > connection->rp.resp_iov.sent); #ifdef MHD_VECT_SEND #if defined(HTTPS_SUPPORT) || \ defined(_MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED) #ifdef HTTPS_SUPPORT use_iov_send = use_iov_send && (0 == (connection->daemon->options & MHD_USE_TLS)); #endif /* HTTPS_SUPPORT */ #ifdef _MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED use_iov_send = use_iov_send && (connection->daemon->sigpipe_blocked || connection->sk_spipe_suppress); #endif /* _MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED */ if (use_iov_send) #endif /* HTTPS_SUPPORT || _MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED */ return send_iov_nontls (connection, r_iov, push_data); #endif /* MHD_VECT_SEND */ #if ! defined(MHD_VECT_SEND) || defined(HTTPS_SUPPORT) || \ defined(_MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED) return send_iov_emu (connection, r_iov, push_data); #endif /* !MHD_VECT_SEND || HTTPS_SUPPORT || _MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED */ } libmicrohttpd-1.0.1/src/microhttpd/mhd_str_types.h0000644000175000017500000000321214441373361016043 /* This file is part of libmicrohttpd Copyright (C) 2015-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_str_types.h * @brief Header for string manipulating helpers types * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_STR_TYPES_H #define MHD_STR_TYPES_H 1 #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ /** * Constant string with length */ struct _MHD_cstr_w_len { const char *const str; const size_t len; }; /** * String with length */ struct _MHD_str_w_len { const char *str; size_t len; }; /** * Modifiable string with length */ struct _MHD_mstr_w_len { char *str; size_t len; }; /** * Static string initialiser for struct _MHD_str_w_len */ #define _MHD_S_STR_W_LEN(str) { str, MHD_STATICSTR_LEN_(str) } #endif /* MHD_STR_TYPES_H */ libmicrohttpd-1.0.1/src/microhttpd/test_response_entries.c0000644000175000017500000006354614441373361017620 /* This file is part of libmicrohttpd Copyright (C) 2021 Karlson2k (Evgeny Grin) This test_response_entries.c file is in the public domain */ /** * @file test_response_entries.c * @brief Test adding and removing response headers * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "platform.h" #include #include static int expect_str (const char *actual, const char *expected) { if (expected == actual) return ! 0; if (NULL == actual) { fprintf (stderr, "FAILED: result: NULL\n" \ " expected: \"%s\"\n", expected); return 0; } if (NULL == expected) { fprintf (stderr, "FAILED: result: \"%s\"\n" \ " expected: NULL\n", actual); return 0; } if (0 != strcmp (actual, expected)) { fprintf (stderr, "FAILED: result: \"%s\"\n" \ " expected: \"%s\"\n", actual, expected); return 0; } return ! 0; } int main (int argc, char *const *argv) { struct MHD_Response *r; (void) argc; (void) argv; /* Unused. Silence compiler warning. */ r = MHD_create_response_empty (MHD_RF_NONE); if (NULL == r) { fprintf (stderr, "Cannot create a response.\n"); return 1; } /* ** Test basic header functions ** */ /* Add first header */ if (MHD_YES != MHD_add_response_header (r, "Header-Type-A", "value-a1")) { fprintf (stderr, "Cannot add header A1.\n"); MHD_destroy_response (r); return 2; } if (! expect_str (MHD_get_response_header (r, "Header-Type-A"), "value-a1")) { MHD_destroy_response (r); return 2; } /* Add second header with the same name */ if (MHD_YES != MHD_add_response_header (r, "Header-Type-A", "value-a2")) { fprintf (stderr, "Cannot add header A2.\n"); MHD_destroy_response (r); return 2; } /* Value of the first header must be returned */ if (! expect_str (MHD_get_response_header (r, "Header-Type-A"), "value-a1")) { MHD_destroy_response (r); return 2; } /* Remove the first header */ if (MHD_YES != MHD_del_response_header (r, "Header-Type-A", "value-a1")) { fprintf (stderr, "Cannot remove header A1.\n"); MHD_destroy_response (r); return 2; } /* Value of the ex-second header must be returned */ if (! expect_str (MHD_get_response_header (r, "Header-Type-A"), "value-a2")) { MHD_destroy_response (r); return 2; } if (MHD_YES != MHD_add_response_header (r, "Header-Type-A", "value-a3")) { fprintf (stderr, "Cannot add header A2.\n"); MHD_destroy_response (r); return 2; } /* Value of the ex-second header must be returned */ if (! expect_str (MHD_get_response_header (r, "Header-Type-A"), "value-a2")) { MHD_destroy_response (r); return 2; } /* Remove the last header */ if (MHD_YES != MHD_del_response_header (r, "Header-Type-A", "value-a3")) { fprintf (stderr, "Cannot add header A2.\n"); MHD_destroy_response (r); return 2; } if (! expect_str (MHD_get_response_header (r, "Header-Type-A"), "value-a2")) { MHD_destroy_response (r); return 2; } if (! expect_str (MHD_get_response_header (r, "Header-Type-B"), NULL)) { MHD_destroy_response (r); return 2; } if (MHD_NO != MHD_del_response_header (r, "Header-Type-C", "value-a3")) { fprintf (stderr, "Removed non-existing header.\n"); MHD_destroy_response (r); return 2; } if (MHD_NO != MHD_del_response_header (r, "Header-Type-A", "value-c")) { fprintf (stderr, "Removed non-existing header value.\n"); MHD_destroy_response (r); return 2; } /* ** Test "Connection:" header ** */ if (MHD_YES != MHD_add_response_header (r, "Connection", "a,b,c,d,e")) { fprintf (stderr, "Cannot add \"Connection\" header with simple values.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "a, b, c, d, e")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "e,b,c,d,a")) { fprintf (stderr, "Cannot remove \"Connection\" header with simple values.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "i,k,l,m,n,o,p,close")) { fprintf (stderr, "Cannot add \"Connection\" header with simple values and \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, i, k, l, m, n, o, p")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "i,k,l,m,n,o,p,close")) { fprintf (stderr, "Cannot remove \"Connection\" header with simple values and \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "1,2,3,4,5,6,7,close")) { fprintf (stderr, "Cannot add \"Connection\" header with simple values and \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, 1, 2, 3, 4, 5, 6, 7")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "8,9,close")) { fprintf (stderr, "Cannot add second \"Connection\" header with simple values and \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, 1, 2, 3, 4, 5, 6, 7, 8, 9")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "1,3,5,7,9")) { fprintf (stderr, "Cannot remove part of \"Connection\" header with simple values.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, 2, 4, 6, 8")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "10,12")) { fprintf (stderr, "Cannot add third \"Connection\" header with simple values.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, 2, 4, 6, 8, 10, 12")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "12 ,10 ,8 ,close")) { fprintf (stderr, "Cannot remove part of \"Connection\" header with simple values and \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "2, 4, 6")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\" only.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, 2, 4, 6")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "4 ,5,6,7 8,")) { fprintf (stderr, "Cannot remove part of \"Connection\" header with simple values and non-existing tokens.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, 2")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\" only.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, 2")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "close, 10, 12, 22, nothing")) { fprintf (stderr, "Cannot remove part of \"Connection\" header with \"close\" and non-existing tokens.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "2")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "2")) { fprintf (stderr, "Cannot remove part of \"Connection\" header with simple values and non-existing tokens.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot remove \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close,other-token")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, other-token")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close, new-token")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, other-token, new-token")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "close, new-token")) { fprintf (stderr, "Cannot remove tokens from \"Connection\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "other-token")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "other-token")) { fprintf (stderr, "Cannot remove tokens from \"Connection\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close, one-long-token")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, one-long-token")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, one-long-token")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "one-long-token,close")) { fprintf (stderr, "Cannot remove tokens from \"Connection\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close, additional-token")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, additional-token")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "additional-token,close")) { fprintf (stderr, "Cannot remove tokens from \"Connection\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "token-1,token-2")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "token-1, token-2")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "token-3")) { fprintf (stderr, "Cannot add \"Connection\" header.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "token-1, token-2, token-3")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, token-1, token-2, token-3")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, token-1, token-2, token-3")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close, token-4")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, token-1, token-2, token-3, token-4")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot remove tokens from \"Connection\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "token-1, token-2, token-3, token-4")) { MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close, token-5")) { fprintf (stderr, "Cannot add \"Connection\" header with \"close\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, token-1, token-2, token-3, token-4, token-5")) { MHD_destroy_response (r); return 3; } if (MHD_NO != MHD_del_response_header (r, "Connection", "non-existing, token-9")) { fprintf (stderr, "Non-existing tokens successfully removed from \"Connection\" header.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, token-1, token-2, token-3, token-4, token-5")) { MHD_destroy_response (r); return 3; } if (MHD_NO != MHD_add_response_header (r, "Connection", ",,,,,,,,,,,, ,\t\t\t, , , ")) { fprintf (stderr, "Empty token was added successfully to \"Connection\" header.\n"); MHD_destroy_response (r); return 3; } if (MHD_YES != MHD_del_response_header (r, "Connection", "close, token-1, token-2, token-3, token-4, token-5")) { fprintf (stderr, "Cannot remove tokens from \"Connection\".\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 3; } if (MHD_NO != MHD_add_response_header (r, "Connection", ",,,,,,,,,,,, ,\t\t\t, , , ")) { fprintf (stderr, "Empty token was added successfully to \"Connection\" header.\n"); MHD_destroy_response (r); return 3; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 3; } if (MHD_NO != MHD_add_response_header (r, "Connection", "keep-Alive")) { fprintf (stderr, "Successfully added \"Connection\" header with \"keep-Alive\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_add_response_header (r, "Connection", "keep-Alive, Close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"keep-Alive, Close\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close")) { MHD_destroy_response (r); return 4; } if (MHD_NO != MHD_add_response_header (r, "Connection", "keep-Alive")) { fprintf (stderr, "Successfully added \"Connection\" header with \"keep-Alive\".\n"); MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_add_response_header (r, "Connection", "keep-Alive, Close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"keep-Alive, Close\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close")) { MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_add_response_header (r, "Connection", "close, additional-token")) { fprintf (stderr, "Cannot add \"Connection\" header with " "\"close, additional-token\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, additional-token")) { MHD_destroy_response (r); return 4; } if (MHD_NO != MHD_add_response_header (r, "Connection", "keep-Alive")) { fprintf (stderr, "Successfully added \"Connection\" header with \"keep-Alive\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, additional-token")) { MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_del_response_header (r, "Connection", "additional-token,close")) { fprintf (stderr, "Cannot remove tokens from \"Connection\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_add_response_header (r, "Connection", "Keep-aLive, token-1")) { fprintf (stderr, "Cannot add \"Connection\" header with \"Keep-aLive, token-1\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), "token-1")) { MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_add_response_header (r, "Connection", "Keep-aLive, token-2")) { fprintf (stderr, "Cannot add \"Connection\" header with \"Keep-aLive, token-2\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), "token-1, token-2")) { MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_add_response_header (r, "Connection", "Keep-aLive, token-3, close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"Keep-aLive, token-3, close\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, token-1, token-2, token-3")) { MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_del_response_header (r, "Connection", "close")) { fprintf (stderr, "Cannot remove \"close\" tokens from \"Connection\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), "token-1, token-2, token-3")) { MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_add_response_header (r, "Connection", "Keep-aLive, close")) { fprintf (stderr, "Cannot add \"Connection\" header with \"Keep-aLive, token-3, close\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), "close, token-1, token-2, token-3")) { MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_del_response_header (r, "Connection", "close, token-1, Keep-Alive, token-2, token-3")) { fprintf (stderr, "Cannot remove \"close\" tokens from \"Connection\".\n"); MHD_destroy_response (r); return 4; } if (! expect_str (MHD_get_response_header (r, "Connection"), NULL)) { MHD_destroy_response (r); return 4; } if (MHD_YES != MHD_add_response_header (r, "Date", "Wed, 01 Apr 2015 00:00:00 GMT")) { fprintf (stderr, "Cannot add \"Date\" header with \"Wed, 01 Apr 2015 00:00:00 GMT\".\n"); MHD_destroy_response (r); return 5; } if (! expect_str (MHD_get_response_header (r, "Date"), "Wed, 01 Apr 2015 00:00:00 GMT")) { MHD_destroy_response (r); return 5; } if (MHD_YES != MHD_add_response_header (r, "Date", "Thu, 01 Apr 2021 00:00:00 GMT")) { fprintf (stderr, "Cannot add \"Date\" header with \"Thu, 01 Apr 2021 00:00:00 GMT\".\n"); MHD_destroy_response (r); return 5; } if (! expect_str (MHD_get_response_header (r, "Date"), "Thu, 01 Apr 2021 00:00:00 GMT")) { MHD_destroy_response (r); return 5; } if (MHD_YES != MHD_del_response_header (r, "Date", "Thu, 01 Apr 2021 00:00:00 GMT")) { fprintf (stderr, "Cannot remove \"Date\" header.\n"); MHD_destroy_response (r); return 5; } if (! expect_str (MHD_get_response_header (r, "Date"), NULL)) { MHD_destroy_response (r); return 5; } if (MHD_YES != MHD_add_response_header (r, MHD_HTTP_HEADER_TRANSFER_ENCODING, "chunked")) { fprintf (stderr, "Cannot add \"" MHD_HTTP_HEADER_TRANSFER_ENCODING \ "\" header with \"chunked\".\n"); MHD_destroy_response (r); return 6; } if (! expect_str (MHD_get_response_header (r, MHD_HTTP_HEADER_TRANSFER_ENCODING), "chunked")) { MHD_destroy_response (r); return 6; } if (MHD_YES != MHD_add_response_header (r, MHD_HTTP_HEADER_TRANSFER_ENCODING, "chunked")) { fprintf (stderr, "Cannot add \"" MHD_HTTP_HEADER_TRANSFER_ENCODING \ "\" second header with \"chunked\".\n"); MHD_destroy_response (r); return 6; } if (! expect_str (MHD_get_response_header (r, MHD_HTTP_HEADER_TRANSFER_ENCODING), "chunked")) { MHD_destroy_response (r); return 6; } if (MHD_NO != MHD_add_response_header (r, MHD_HTTP_HEADER_TRANSFER_ENCODING, "identity")) { fprintf (stderr, "Successfully added \"" MHD_HTTP_HEADER_TRANSFER_ENCODING \ "\" header with \"identity\".\n"); MHD_destroy_response (r); return 6; } if (! expect_str (MHD_get_response_header (r, MHD_HTTP_HEADER_TRANSFER_ENCODING), "chunked")) { MHD_destroy_response (r); return 6; } if (MHD_YES != MHD_del_response_header (r, MHD_HTTP_HEADER_TRANSFER_ENCODING, "chunked")) { fprintf (stderr, "Cannot remove \"" MHD_HTTP_HEADER_TRANSFER_ENCODING \ "\" header.\n"); MHD_destroy_response (r); return 6; } if (! expect_str (MHD_get_response_header (r, MHD_HTTP_HEADER_TRANSFER_ENCODING), NULL)) { MHD_destroy_response (r); return 6; } MHD_destroy_response (r); printf ("All tests has been successfully passed.\n"); return 0; } libmicrohttpd-1.0.1/src/microhttpd/test_str_tokens_remove.c0000644000175000017500000003311014441373361017761 /* This file is part of libmicrohttpd Copyright (C) 2017-2021 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_str_token.c * @brief Unit tests for MHD_str_remove_tokens_caseless_() function * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include "mhd_str.h" #include "mhd_assert.h" static int expect_result_n (const char *str, size_t str_len, const char *tokens, size_t tokens_len, const char *expected, size_t expected_len, const bool expected_removed) { char buf_in[1024]; char buf_tokens[256]; bool res; size_t result_len; mhd_assert (sizeof(buf_in) > str_len + 2); mhd_assert (sizeof(buf_tokens) > tokens_len + 2); memset (buf_tokens, '#', sizeof(buf_tokens)); memcpy (buf_tokens, tokens, tokens_len); /* Copy without zero-termination */ memset (buf_in, '$', sizeof(buf_in)); memcpy (buf_in, str, str_len); /* Copy without zero-termination */ result_len = str_len; res = MHD_str_remove_tokens_caseless_ (buf_in, &result_len, buf_tokens, tokens_len); if ( (expected_removed != res) || (expected_len != result_len) || ((0 != result_len) && (0 != memcmp (expected, buf_in, result_len))) || ('$' != buf_in[str_len])) { fprintf (stderr, "MHD_str_remove_tokens_caseless_() FAILED:\n" "\tRESULT: " "\tMHD_str_remove_token_caseless_(\"%s\"->\"%.*s\", &(%lu->%lu)," " \"%.*s\", %lu) returned %s\n", str, (int) result_len, buf_in, (unsigned long) str_len, (unsigned long) result_len, (int) tokens_len, buf_tokens, (unsigned long) tokens_len, res ? "true" : "false"); fprintf (stderr, "\tEXPECTED: " "\tMHD_str_remove_token_caseless_(\"%s\"->\"%s\", &(%lu->%lu)," " \"%.*s\", %lu) returned %s\n", str, expected, (unsigned long) str_len, (unsigned long) expected_len, (int) tokens_len, buf_tokens, (unsigned long) tokens_len, expected_removed ? "true" : "false"); return 1; } return 0; } #define expect_result(s,t,e,found) \ expect_result_n ((s),MHD_STATICSTR_LEN_ (s), \ (t),MHD_STATICSTR_LEN_ (t), \ (e),MHD_STATICSTR_LEN_ (e), found) static int check_result (void) { int errcount = 0; errcount += expect_result ("string", "string", "", true); errcount += expect_result ("String", "string", "", true); errcount += expect_result ("string", "String", "", true); errcount += expect_result ("strinG", "String", "", true); errcount += expect_result ("strinG", "String\t", "", true); errcount += expect_result ("strinG", "\tString", "", true); errcount += expect_result ("tOkEn", " \t toKEN ", "", true); errcount += expect_result ("not-token, tOkEn", "token", "not-token", true); errcount += expect_result ("not-token1, tOkEn1, token", "token1", "not-token1, token", true); errcount += expect_result ("token, tOkEn1", "token1", "token", true); errcount += expect_result ("not-token, tOkEn", " \t toKEN", "not-token", true); errcount += expect_result ("not-token, tOkEn, more-token", "toKEN\t", "not-token, more-token", true); errcount += expect_result ("not-token, tOkEn, more-token", "\t toKEN,,,,,", "not-token, more-token", true); errcount += expect_result ("a, b, c, d", ",,,,,a", "b, c, d", true); errcount += expect_result ("a, b, c, d", "a,,,,,,", "b, c, d", true); errcount += expect_result ("a, b, c, d", ",,,,a,,,,,,", "b, c, d", true); errcount += expect_result ("a, b, c, d", "\t \t,,,,a,, , ,,,\t", "b, c, d", true); errcount += expect_result ("a, b, c, d", "b, c, d", "a", true); errcount += expect_result ("a, b, c, d", "a, b, c, d", "", true); errcount += expect_result ("a, b, c, d", "d, c, b, a", "", true); errcount += expect_result ("a, b, c, d", "b, d, a, c", "", true); errcount += expect_result ("a, b, c, d, e", "b, d, a, c", "e", true); errcount += expect_result ("e, a, b, c, d", "b, d, a, c", "e", true); errcount += expect_result ("e, a, b, c, d, e", "b, d, a, c", "e, e", true); errcount += expect_result ("a, b, c, d", "b,c,d", "a", true); errcount += expect_result ("a, b, c, d", "a,b,c,d", "", true); errcount += expect_result ("a, b, c, d", "d,c,b,a", "", true); errcount += expect_result ("a, b, c, d", "b,d,a,c", "", true); errcount += expect_result ("a, b, c, d, e", "b,d,a,c", "e", true); errcount += expect_result ("e, a, b, c, d", "b,d,a,c", "e", true); errcount += expect_result ("e, a, b, c, d, e", "b,d,a,c", "e, e", true); errcount += expect_result ("a, b, c, d", "d,,,,,,,,,c,b,a", "", true); errcount += expect_result ("a, b, c, d", "b,d,a,c,,,,,,,,,,", "", true); errcount += expect_result ("a, b, c, d, e", ",,,,\t,,,,b,d,a,c,\t", "e", true); errcount += expect_result ("e, a, b, c, d", "b,d,a,c", "e", true); errcount += expect_result ("token, a, b, c, d", "token", "a, b, c, d", true); errcount += expect_result ("token1, a, b, c, d", "token1", "a, b, c, d", true); errcount += expect_result ("token12, a, b, c, d", "token12", "a, b, c, d", true); errcount += expect_result ("token123, a, b, c, d", "token123", "a, b, c, d", true); errcount += expect_result ("token1234, a, b, c, d", "token1234", "a, b, c, d", true); errcount += expect_result ("token12345, a, b, c, d", "token12345", "a, b, c, d", true); errcount += expect_result ("token123456, a, b, c, d", "token123456", "a, b, c, d", true); errcount += expect_result ("token1234567, a, b, c, d", "token1234567", "a, b, c, d", true); errcount += expect_result ("token12345678, a, b, c, d", "token12345678", "a, b, c, d", true); errcount += expect_result ("", "a", "", false); errcount += expect_result ("", "", "", false); errcount += expect_result ("a, b, c, d", "bb, dd, aa, cc", "a, b, c, d", false); errcount += expect_result ("a, b, c, d, e", "bb, dd, aa, cc", "a, b, c, d, e", false); errcount += expect_result ("e, a, b, c, d", "bb, dd, aa, cc", "e, a, b, c, d", false); errcount += expect_result ("e, a, b, c, d, e", "bb, dd, aa, cc", "e, a, b, c, d, e", false); errcount += expect_result ("aa, bb, cc, dd", "b, d, a, c", "aa, bb, cc, dd", false); errcount += expect_result ("aa, bb, cc, dd, ee", "b, d, a, c", "aa, bb, cc, dd, ee", false); errcount += expect_result ("ee, aa, bb, cc, dd", "b, d, a, c", "ee, aa, bb, cc, dd", false); errcount += expect_result ("ee, aa, bb, cc, dd, ee", "b, d, a, c", "ee, aa, bb, cc, dd, ee", false); errcount += expect_result ("TESt", ",,,,,,test,,,,", "", true); errcount += expect_result ("TESt", ",,,,,\t,test,,,,", "", true); errcount += expect_result ("TESt", ",,,,,,test, ,,,", "", true); errcount += expect_result ("TESt", ",,,,,, test,,,,", "", true); errcount += expect_result ("TESt", ",,,,,, test-not,test,,", "", true); errcount += expect_result ("TESt", ",,,,,, test-not,,test,,", "", true); errcount += expect_result ("TESt", ",,,,,, test-not ,test,,", "", true); errcount += expect_result ("TESt", ",,,,,, test", "", true); errcount += expect_result ("TESt", ",,,,,, test ", "", true); errcount += expect_result ("TESt", "no-test,,,,,, test ", "", true); errcount += expect_result ("the-token, a, the-token, b, the-token, " \ "the-token, c, the-token", "the-token", "a, b, c", true); errcount += expect_result ("aa, the-token, bb, the-token, cc, the-token, " \ "the-token, dd, the-token", "the-token", "aa, bb, cc, dd", true); errcount += expect_result ("the-token, a, the-token, b, the-token, " \ "the-token, c, the-token, e", "the-token", "a, b, c, e", true); errcount += expect_result ("aa, the-token, bb, the-token, cc, the-token, " \ "the-token, dd, the-token, ee", "the-token", "aa, bb, cc, dd, ee", true); errcount += expect_result ("the-token, the-token, the-token, " \ "the-token, the-token", "the-token", "", true); errcount += expect_result ("the-token, a, the-token, the-token, b, " \ "the-token, c, the-token, a", "c,a,b", "the-token, the-token, the-token, the-token, the-token", true); errcount += expect_result ("the-token, xx, the-token, the-token, zz, " \ "the-token, yy, the-token, ww", "ww,zz,yy", "the-token, xx, the-token, the-token, the-token, the-token", true); errcount += expect_result ("the-token, a, the-token, the-token, b, " \ "the-token, c, the-token, a", " c,\t a,b,,,", "the-token, the-token, the-token, the-token, the-token", true); errcount += expect_result ("the-token, xx, the-token, the-token, zz, " \ "the-token, yy, the-token, ww", ",,,,ww,\t zz, yy", "the-token, xx, the-token, the-token, the-token, the-token", true); errcount += expect_result ("the-token, a, the-token, the-token, b, " \ "the-token, c, the-token, a", ",,,,c,\t a,b", "the-token, the-token, the-token, the-token, the-token", true); errcount += expect_result ("the-token, xx, the-token, the-token, zz, " \ "the-token, yy, the-token, ww", " ww,\t zz,yy,,,,", "the-token, xx, the-token, the-token, the-token, the-token", true); errcount += expect_result ("close, 2", "close", "2", true); errcount += expect_result ("close, 22", "close", "22", true); errcount += expect_result ("close, nothing", "close", "nothing", true); errcount += expect_result ("close, 2", "2", "close", true); errcount += expect_result ("close", "close", "", true); errcount += expect_result ("close, nothing", "close, token", "nothing", true); errcount += expect_result ("close, nothing", "nothing, token", "close", true); errcount += expect_result ("close, 2", "close, 10, 12, 22, nothing", "2", true); errcount += expect_result ("strin", "string", "strin", false); errcount += expect_result ("Stringer", "string", "Stringer", false); errcount += expect_result ("sstring", "String", "sstring", false); errcount += expect_result ("string", "Strin", "string", false); errcount += expect_result ("String", "\t(-strinG", "String", false); errcount += expect_result ("String", ")strinG\t ", "String", false); errcount += expect_result ("not-token, tOkEner", "toKEN", "not-token, tOkEner", false); errcount += expect_result ("not-token, tOkEns, more-token", "toKEN", "not-token, tOkEns, more-token", false); errcount += expect_result ("tests, quest", "TESt", "tests, quest", false); errcount += expect_result ("testÑ‹", "TESt", "testÑ‹", false); errcount += expect_result ("test-not, Ñ…test", "TESt", "test-not, Ñ…test", false); errcount += expect_result ("testing, test not, test2", "TESt", "testing, test not, test2", false); errcount += expect_result ("", ",,,,,,,,,,,,,,,,,,,the-token", "", false); errcount += expect_result ("a1, b1, c1, d1, e1, f1, g1", "", "a1, b1, c1, d1, e1, f1, g1", false); return errcount; } int main (int argc, char *argv[]) { int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errcount += check_result (); if (0 == errcount) printf ("All tests were passed without errors.\n"); return errcount == 0 ? 0 : 1; } libmicrohttpd-1.0.1/src/microhttpd/test_daemon.c0000644000175000017500000001366414530120375015462 /* This file is part of libmicrohttpd Copyright (C) 2007, 2017 Christian Grothoff Copyright (C) 2014--2023 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_daemon.c * @brief Testcase for libmicrohttpd starts and stops * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include #include #include #ifndef WINDOWS #include #endif static unsigned int testStartError (void) { struct MHD_Daemon *d; d = MHD_start_daemon (MHD_USE_ERROR_LOG, 0, NULL, NULL, NULL, NULL); if (NULL != d) { MHD_stop_daemon (d); fprintf (stderr, "Succeeded to start without MHD_AccessHandlerCallback?\n"); return 1; } return 0; } static enum MHD_Result apc_nothing (void *cls, const struct sockaddr *addr, socklen_t addrlen) { (void) cls; (void) addr; (void) addrlen; /* Unused. Silent compiler warning. */ return MHD_NO; } static enum MHD_Result apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen) { (void) cls; (void) addr; (void) addrlen; /* Unused. Silent compiler warning. */ return MHD_YES; } static enum MHD_Result ahc_nothing (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { (void) cls; (void) connection; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ return MHD_NO; } static unsigned int testStartStop (void) { struct MHD_Daemon *d; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 0, &apc_nothing, NULL, &ahc_nothing, NULL, MHD_OPTION_END); if (NULL == d) { fprintf (stderr, "Failed to start daemon on port %u\n", (unsigned int) 0); exit (3); } MHD_stop_daemon (d); return 0; } static unsigned int testExternalRun (int use_no_thread_safe) { struct MHD_Daemon *d; fd_set rs; MHD_socket maxfd; int i; d = MHD_start_daemon (MHD_USE_ERROR_LOG | (use_no_thread_safe ? MHD_USE_NO_THREAD_SAFETY : 0), 0, &apc_all, NULL, &ahc_nothing, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (NULL == d) { fprintf (stderr, "Failed to start daemon on port %u\n", (unsigned int) 0); exit (3); } for (i = 0; i < 15; ++i) { maxfd = 0; FD_ZERO (&rs); if (MHD_YES != MHD_get_fdset (d, &rs, &rs, &rs, &maxfd)) { MHD_stop_daemon (d); fprintf (stderr, "Failed in MHD_get_fdset().\n"); return 256; } if (MHD_NO == MHD_run (d)) { MHD_stop_daemon (d); fprintf (stderr, "Failed in MHD_run().\n"); return 8; } } MHD_stop_daemon (d); return 0; } static unsigned int testThread (void) { struct MHD_Daemon *d; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_INTERNAL_POLLING_THREAD, 0, &apc_all, NULL, &ahc_nothing, NULL, MHD_OPTION_END); if (NULL == d) { fprintf (stderr, "Failed to start daemon on port %u.\n", (unsigned int) 0); exit (3); } if (MHD_run (d) != MHD_NO) { fprintf (stderr, "Failed in MHD_run().\n"); return 32; } MHD_stop_daemon (d); return 0; } static unsigned int testMultithread (void) { struct MHD_Daemon *d; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION, 0, &apc_all, NULL, &ahc_nothing, NULL, MHD_OPTION_END); if (NULL == d) { fprintf (stderr, "Failed to start daemon on port %u\n", (unsigned int) 0); exit (3); } if (MHD_run (d) != MHD_NO) { fprintf (stderr, "Failed in MHD_run().\n"); return 128; } MHD_stop_daemon (d); return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; int has_threads_support; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ has_threads_support = (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_THREADS)); errorCount += testStartError (); if (has_threads_support) errorCount += testStartStop (); if (has_threads_support) errorCount += testExternalRun (0); errorCount += testExternalRun (! 0); if (has_threads_support) { errorCount += testThread (); errorCount += testMultithread (); } if (0 != errorCount) fprintf (stderr, "Error (code: %u)\n", errorCount); return 0 != errorCount; /* 0 == pass */ } libmicrohttpd-1.0.1/src/microhttpd/memorypool.h0000644000175000017500000001433114556705750015375 /* This file is part of libmicrohttpd Copyright (C) 2007--2024 Daniel Pittman and Christian Grothoff Copyright (C) 2016--2024 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file memorypool.h * @brief memory pool; mostly used for efficient (de)allocation * for each connection and bounding memory use for each * request * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #ifndef MEMORYPOOL_H #define MEMORYPOOL_H #include "mhd_options.h" #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #ifdef HAVE_STDBOOL_H #include #endif /** * Opaque handle for a memory pool. * Pools are not reentrant and must not be used * by multiple threads. */ struct MemoryPool; /** * Initialize values for memory pools */ void MHD_init_mem_pools_ (void); /** * Create a memory pool. * * @param max maximum size of the pool * @return NULL on error */ struct MemoryPool * MHD_pool_create (size_t max); /** * Destroy a memory pool. * * @param pool memory pool to destroy */ void MHD_pool_destroy (struct MemoryPool *pool); /** * Allocate size bytes from the pool. * * @param pool memory pool to use for the operation * @param size number of bytes to allocate * @param from_end allocate from end of pool (set to 'true'); * use this for small, persistent allocations that * will never be reallocated * @return NULL if the pool cannot support size more * bytes */ void * MHD_pool_allocate (struct MemoryPool *pool, size_t size, bool from_end); /** * Checks whether allocated block is re-sizable in-place. * If block is not re-sizable in-place, it still could be shrunk, but freed * memory will not be re-used until reset of the pool. * @param pool the memory pool to use * @param block the pointer to the allocated block to check * @param block_size the size of the allocated @a block * @return true if block can be resized in-place in the optimal way, * false otherwise */ bool MHD_pool_is_resizable_inplace (struct MemoryPool *pool, void *block, size_t block_size); /** * Try to allocate @a size bytes memory area from the @a pool. * * If allocation fails, @a required_bytes is updated with size required to be * freed in the @a pool from rellocatable area to allocate requested number * of bytes. * Allocated memory area is always not rellocatable ("from end"). * * @param pool memory pool to use for the operation * @param size the size of memory in bytes to allocate * @param[out] required_bytes the pointer to variable to be updated with * the size of the required additional free * memory area, set to 0 if function succeeds. * Cannot be NULL. * @return the pointer to allocated memory area if succeed, * NULL if the pool doesn't have enough space, required_bytes is updated * with amount of space needed to be freed in rellocatable area or * set to SIZE_MAX if requested size is too large for the pool. */ void * MHD_pool_try_alloc (struct MemoryPool *pool, size_t size, size_t *required_bytes); /** * Reallocate a block of memory obtained from the pool. * This is particularly efficient when growing or * shrinking the block that was last (re)allocated. * If the given block is not the most recently * (re)allocated block, the memory of the previous * allocation may be not released until the pool is * destroyed or reset. * * @param pool memory pool to use for the operation * @param old the existing block * @param old_size the size of the existing block * @param new_size the new size of the block * @return new address of the block, or * NULL if the pool cannot support @a new_size * bytes (old continues to be valid for @a old_size) */ void * MHD_pool_reallocate (struct MemoryPool *pool, void *old, size_t old_size, size_t new_size); /** * Check how much memory is left in the @a pool * * @param pool pool to check * @return number of bytes still available in @a pool */ size_t MHD_pool_get_free (struct MemoryPool *pool); /** * Deallocate a block of memory obtained from the pool. * * If the given block is not the most recently * (re)allocated block, the memory of the this block * allocation may be not released until the pool is * destroyed or reset. * * @param pool memory pool to use for the operation * @param block the allocated block, the NULL is tolerated * @param block_size the size of the allocated block */ void MHD_pool_deallocate (struct MemoryPool *pool, void *block, size_t block_size); /** * Clear all entries from the memory pool except * for @a keep of the given @a copy_bytes. The pointer * returned should be a buffer of @a new_size where * the first @a copy_bytes are from @a keep. * * @param pool memory pool to use for the operation * @param keep pointer to the entry to keep (maybe NULL) * @param copy_bytes how many bytes need to be kept at this address * @param new_size how many bytes should the allocation we return have? * (should be larger or equal to @a copy_bytes) * @return addr new address of @a keep (if it had to change) */ void * MHD_pool_reset (struct MemoryPool *pool, void *keep, size_t copy_bytes, size_t new_size); #endif libmicrohttpd-1.0.1/src/microhttpd/sysfdsetsize.h0000644000175000017500000000276114556705750015736 /* This file is part of libmicrohttpd Copyright (C) 2015-2023 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/sysfdsetsize.h * @brief Helper for obtaining FD_SETSIZE system default value * @author Karlson2k (Evgeny Grin) */ #ifndef SYSFDSETSIZE_H #define SYSFDSETSIZE_H 1 #include "mhd_options.h" #ifndef MHD_SYS_FD_SETSIZE_ /** * Get system default value of FD_SETSIZE * @return system default value of FD_SETSIZE */ unsigned int get_system_fdsetsize_value (void); #else /* MHD_SYS_FD_SETSIZE_ */ /** * Get system default value of FD_SETSIZE * @return system default value of FD_SETSIZE */ _MHD_static_inline unsigned int get_system_fdsetsize_value (void) { return (unsigned int) MHD_SYS_FD_SETSIZE_; } #endif /* MHD_SYS_FD_SETSIZE_ */ #endif /* !SYSFDSETSIZE_H */ libmicrohttpd-1.0.1/src/microhttpd/test_str_bin_hex.c0000644000175000017500000003517714441373361016534 /* This file is part of libmicrohttpd Copyright (C) 2022 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_str_bin_hex.c * @brief Unit tests for hex strings <-> binary data processing * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include "mhd_str.h" #include "mhd_assert.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ static char tmp_bufs[4][4 * 1024]; /* should be enough for testing */ static size_t buf_idx = 0; /* print non-printable chars as char codes */ static char * n_prnt (const char *str, size_t len) { static char *buf; /* should be enough for testing */ static const size_t buf_size = sizeof(tmp_bufs[0]); size_t r_pos = 0; size_t w_pos = 0; if (++buf_idx >= (sizeof(tmp_bufs) / sizeof(tmp_bufs[0]))) buf_idx = 0; buf = tmp_bufs[buf_idx]; while (len > r_pos && w_pos + 1 < buf_size) { const unsigned char c = (unsigned char) str[r_pos]; if ((c == '\\') || (c == '"') ) { if (w_pos + 2 >= buf_size) break; buf[w_pos++] = '\\'; buf[w_pos++] = (char) c; } else if ((c >= 0x20) && (c <= 0x7E) ) buf[w_pos++] = (char) c; else { if (w_pos + 4 >= buf_size) break; if (snprintf (buf + w_pos, buf_size - w_pos, "\\x%02hX", (short unsigned int) c) != 4) break; w_pos += 4; } r_pos++; } if (len != r_pos) { /* not full string is printed */ /* enough space for "..." ? */ if (w_pos + 3 > buf_size) w_pos = buf_size - 4; buf[w_pos++] = '.'; buf[w_pos++] = '.'; buf[w_pos++] = '.'; } buf[w_pos] = 0; return buf; } #define TEST_BIN_MAX_SIZE (2 * 1024) /* return zero if succeed, number of failures otherwise */ static unsigned int expect_decoded_n (const char *const hex, const size_t hex_len, const uint8_t *const bin, const size_t bin_size, const unsigned int line_num) { static const char fill_chr = '#'; static char buf[TEST_BIN_MAX_SIZE]; size_t res_size; unsigned int ret; mhd_assert (NULL != hex); mhd_assert (NULL != bin); mhd_assert (TEST_BIN_MAX_SIZE > bin_size + 1); mhd_assert (TEST_BIN_MAX_SIZE > hex_len + 1); mhd_assert (hex_len >= bin_size); mhd_assert (1 >= hex_len || hex_len > bin_size); ret = 0; /* check MHD_hex_to_bin() */ if (1) { unsigned int check_res = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_hex_to_bin (hex, hex_len, buf); if (res_size != bin_size) { check_res = 1; fprintf (stderr, "'MHD_hex_to_bin ()' FAILED: " "Wrong returned value:\n"); } else { if ((0 != bin_size) && (0 != memcmp (buf, bin, bin_size))) { check_res = 1; fprintf (stderr, "'MHD_hex_to_bin ()' FAILED: " "Wrong output data:\n"); } } if (fill_chr != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_str_pct_decode_strict_n_ ()' FAILED: " "A char written outside the buffer:\n"); } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_hex_to_bin (\"%s\", %u, " "->\"%s\") -> %u\n", n_prnt (hex, hex_len), (unsigned) hex_len, n_prnt (buf, res_size), (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_hex_to_bin (\"%s\", %u, " "->\"%s\") -> %u\n", n_prnt (hex, hex_len), (unsigned) hex_len, n_prnt ((const char *) bin, bin_size), (unsigned) bin_size); } } /* check MHD_bin_to_hex() */ if (0 == hex_len % 2) { unsigned int check_res = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_bin_to_hex_z (bin, bin_size, buf); if (res_size != hex_len) { check_res = 1; fprintf (stderr, "'MHD_bin_to_hex ()' FAILED: " "Wrong returned value:\n"); } else { if ((0 != hex_len) && (! MHD_str_equal_caseless_bin_n_ (buf, hex, hex_len))) { check_res = 1; fprintf (stderr, "'MHD_bin_to_hex ()' FAILED: " "Wrong output string:\n"); } } if (fill_chr != buf[res_size + 1]) { check_res = 1; fprintf (stderr, "'MHD_bin_to_hex ()' FAILED: " "A char written outside the buffer:\n"); } if (0 != buf[res_size]) { check_res = 1; fprintf (stderr, "'MHD_bin_to_hex ()' FAILED: " "The result is not zero-terminated:\n"); } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_bin_to_hex (\"%s\", %u, " "->\"%s\") -> %u\n", n_prnt ((const char *) bin, bin_size), (unsigned) bin_size, n_prnt (buf, res_size), (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_bin_to_hex (\"%s\", %u, " "->(lower case)\"%s\") -> %u\n", n_prnt ((const char *) bin, bin_size), (unsigned) bin_size, n_prnt (hex, hex_len), (unsigned) bin_size); } } if (0 != ret) { fprintf (stderr, "The check is at line: %u\n\n", line_num); } return ret; } #define expect_decoded_arr(h,a) \ expect_decoded_n(h,MHD_STATICSTR_LEN_(h),\ a,(sizeof(a)/sizeof(a[0])), \ __LINE__) static unsigned int check_decode_bin (void) { unsigned int r = 0; /**< The number of errors */ if (1) { static const uint8_t bin[256] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; /* The lower case */ r += expect_decoded_arr ("000102030405060708090a0b0c0d0e" \ "0f101112131415161718191a1b1c1d" \ "1e1f202122232425262728292a2b2c" \ "2d2e2f303132333435363738393a3b" \ "3c3d3e3f404142434445464748494a" \ "4b4c4d4e4f50515253545556575859" \ "5a5b5c5d5e5f606162636465666768" \ "696a6b6c6d6e6f7071727374757677" \ "78797a7b7c7d7e7f80818283848586" \ "8788898a8b8c8d8e8f909192939495" \ "969798999a9b9c9d9e9fa0a1a2a3a4" \ "a5a6a7a8a9aaabacadaeafb0b1b2b3" \ "b4b5b6b7b8b9babbbcbdbebfc0c1c2" \ "c3c4c5c6c7c8c9cacbcccdcecfd0d1" \ "d2d3d4d5d6d7d8d9dadbdcdddedfe0" \ "e1e2e3e4e5e6e7e8e9eaebecedeeef" \ "f0f1f2f3f4f5f6f7f8f9fafbfcfdfe" \ "ff", bin); } if (1) { static const uint8_t bin[256] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; /* The upper case */ r += expect_decoded_arr ("000102030405060708090A0B0C0D0E" \ "0F101112131415161718191A1B1C1D" \ "1E1F202122232425262728292A2B2C" \ "2D2E2F303132333435363738393A3B" \ "3C3D3E3F404142434445464748494A" \ "4B4C4D4E4F50515253545556575859" \ "5A5B5C5D5E5F606162636465666768" \ "696A6B6C6D6E6F7071727374757677" \ "78797A7B7C7D7E7F80818283848586" \ "8788898A8B8C8D8E8F909192939495" \ "969798999A9B9C9D9E9FA0A1A2A3A4" \ "A5A6A7A8A9AAABACADAEAFB0B1B2B3" \ "B4B5B6B7B8B9BABBBCBDBEBFC0C1C2" \ "C3C4C5C6C7C8C9CACBCCCDCECFD0D1" \ "D2D3D4D5D6D7D8D9DADBDCDDDEDFE0" \ "E1E2E3E4E5E6E7E8E9EAEBECEDEEEF" \ "F0F1F2F3F4F5F6F7F8F9FAFBFCFDFE" \ "FF", bin); } if (1) { static const uint8_t bin[3] = {0x1, 0x2, 0x3}; r += expect_decoded_arr ("010203", bin); } if (1) { static const uint8_t bin[3] = {0x1, 0x2, 0x3}; r += expect_decoded_arr ("10203", bin); } if (1) { static const uint8_t bin[1] = {0x1}; r += expect_decoded_arr ("01", bin); } if (1) { static const uint8_t bin[1] = {0x1}; r += expect_decoded_arr ("1", bin); } return r; } /* return zero if succeed, number of failures otherwise */ static unsigned int expect_failed_n (const char *const hex, const size_t hex_len, const unsigned int line_num) { static const char fill_chr = '#'; static char buf[TEST_BIN_MAX_SIZE]; size_t res_size; unsigned int ret; mhd_assert (NULL != hex); mhd_assert (TEST_BIN_MAX_SIZE > hex_len + 1); ret = 0; /* check MHD_hex_to_bin() */ if (1) { unsigned int check_res = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_hex_to_bin (hex, hex_len, buf); if (res_size != 0) { check_res = 1; fprintf (stderr, "'MHD_hex_to_bin ()' FAILED: " "Wrong returned value:\n"); } if (0 != check_res) { ret++; fprintf (stderr, "\tRESULT : MHD_hex_to_bin (\"%s\", %u, " "->\"%s\") -> %u\n", n_prnt (hex, hex_len), (unsigned) hex_len, n_prnt (buf, res_size), (unsigned) res_size); fprintf (stderr, "\tEXPECTED: MHD_hex_to_bin (\"%s\", %u, " "->(not defined)) -> 0\n", n_prnt (hex, hex_len), (unsigned) hex_len); } } if (0 != ret) { fprintf (stderr, "The check is at line: %u\n\n", line_num); } return ret; } #define expect_failed(h) \ expect_failed_n(h,MHD_STATICSTR_LEN_(h), \ __LINE__) static unsigned int check_broken_str (void) { unsigned int r = 0; /**< The number of errors */ r += expect_failed ("abcx"); r += expect_failed ("X"); r += expect_failed ("!"); r += expect_failed ("01z"); r += expect_failed ("0z"); r += expect_failed ("00z"); r += expect_failed ("000Y"); return r; } int main (int argc, char *argv[]) { unsigned int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errcount += check_decode_bin (); errcount += check_broken_str (); if (0 == errcount) printf ("All tests have been passed without errors.\n"); return errcount == 0 ? 0 : 1; } libmicrohttpd-1.0.1/src/microhttpd/Makefile.am0000644000175000017500000004507614566122702015057 # This Makefile.am is in the public domain AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ $(CPPFLAGS_ac) AM_CFLAGS = $(CFLAGS_ac) $(HIDDEN_VISIBILITY_CFLAGS) AM_LDFLAGS = $(LDFLAGS_ac) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) lib_LTLIBRARIES = \ libmicrohttpd.la noinst_DATA = MOSTLYCLEANFILES = AM_V_LIB = $(am__v_LIB_@AM_V@) am__v_LIB_ = $(am__v_LIB_@AM_DEFAULT_V@) am__v_LIB_0 = @echo " LIB " $@; am__v_LIB_1 = if W32_SHARED_LIB_EXP AM_V_DLLTOOL = $(am__v_DLLTOOL_@AM_V@) am__v_DLLTOOL_ = $(am__v_DLLTOOL_@AM_DEFAULT_V@) am__v_DLLTOOL_0 = @echo " DLLTOOL " $@; am__v_DLLTOOL_1 = W32_MHD_LIB_LDFLAGS = -Wl,--output-def,$(lt_cv_objdir)/libmicrohttpd.def -XCClinker -static-libgcc noinst_DATA += $(lt_cv_objdir)/libmicrohttpd.lib $(lt_cv_objdir)/libmicrohttpd.def MOSTLYCLEANFILES += $(lt_cv_objdir)/libmicrohttpd.lib $(lt_cv_objdir)/libmicrohttpd.def $(lt_cv_objdir)/libmicrohttpd.exp $(lt_cv_objdir)/libmicrohttpd.def: libmicrohttpd.la $(AM_V_at)test -f $@ && touch $@ || \ ( rm -f libmicrohttpd.la ; $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la && touch $@ ) if USE_EXPORT_FILE noinst_DATA += $(lt_cv_objdir)/libmicrohttpd.exp $(lt_cv_objdir)/libmicrohttpd.exp: $(lt_cv_objdir)/libmicrohttpd.lib $(AM_V_at)test -f $@ && touch $@ || \ ( rm -f $(lt_cv_objdir)/libmicrohttpd.lib ; $(MAKE) $(AM_MAKEFLAGS) $(lt_cv_objdir)/libmicrohttpd.lib && touch $@ ) endif if USE_MS_LIB_TOOL $(lt_cv_objdir)/libmicrohttpd.lib: $(lt_cv_objdir)/libmicrohttpd.def libmicrohttpd.la $(libmicrohttpd_la_OBJECTS) $(AM_V_LIB) cd "$(lt_cv_objdir)" && dll_name=`$(SED) -n -e "s/^dlname='\(.*\)'/\1/p" libmicrohttpd.la` && test -n "$$dll_name" && \ $(MS_LIB_TOOL) -nologo -def:libmicrohttpd.def -name:$$dll_name -out:libmicrohttpd.lib $(libmicrohttpd_la_OBJECTS:.lo=.o) -ignore:4221 else if USE_EXPORT_FILE $(lt_cv_objdir)/libmicrohttpd.lib: $(lt_cv_objdir)/libmicrohttpd.def libmicrohttpd.la $(libmicrohttpd_la_OBJECTS) $(AM_V_DLLTOOL) cd "$(lt_cv_objdir)" && dll_name=`$(SED) -n -e "s/^dlname='\(.*\)'/\1/p" libmicrohttpd.la` && test -n "$$dll_name" && \ $(DLLTOOL) -d libmicrohttpd.def -D $$dll_name -l libmicrohttpd.lib $(libmicrohttpd_la_OBJECTS:.lo=.o) -e ./libmicrohttpd.exp else $(lt_cv_objdir)/libmicrohttpd.lib: $(lt_cv_objdir)/libmicrohttpd.def libmicrohttpd.la $(AM_V_DLLTOOL) cd "$(lt_cv_objdir)" && dll_name=`$(SED) -n -e "s/^dlname='\(.*\)'/\1/p" libmicrohttpd.la` && test -n "$$dll_name" && \ $(DLLTOOL) -d libmicrohttpd.def -D $$dll_name -l libmicrohttpd.lib endif endif else W32_MHD_LIB_LDFLAGS = endif if W32_STATIC_LIB noinst_DATA += $(lt_cv_objdir)/libmicrohttpd-static.lib MOSTLYCLEANFILES += $(lt_cv_objdir)/libmicrohttpd-static.lib $(lt_cv_objdir)/libmicrohttpd-static.lib: libmicrohttpd.la $(libmicrohttpd_la_OBJECTS) if USE_MS_LIB_TOOL $(AM_V_LIB) $(MS_LIB_TOOL) -nologo -out:$@ $(libmicrohttpd_la_OBJECTS:.lo=.o) else $(AM_V_at)cp $(lt_cv_objdir)/libmicrohttpd.a $@ endif endif libmicrohttpd_la_SOURCES = \ connection.c connection.h \ reason_phrase.c \ daemon.c \ internal.c internal.h \ memorypool.c memorypool.h \ mhd_mono_clock.c mhd_mono_clock.h \ mhd_limits.h \ sysfdsetsize.h \ mhd_str.c mhd_str.h mhd_str_types.h\ mhd_send.h mhd_send.c \ mhd_assert.h \ mhd_sockets.c mhd_sockets.h \ mhd_itc.c mhd_itc.h mhd_itc_types.h \ mhd_compat.c mhd_compat.h \ mhd_panic.c mhd_panic.h \ response.c response.h if USE_POSIX_THREADS libmicrohttpd_la_SOURCES += \ mhd_threads.c mhd_threads.h \ mhd_locks.h endif if USE_W32_THREADS libmicrohttpd_la_SOURCES += \ mhd_threads.c mhd_threads.h \ mhd_locks.h endif if NEED_SYS_FD_SET_SIZE_VALUE libmicrohttpd_la_SOURCES += \ sysfdsetsize.c endif libmicrohttpd_la_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) \ -DBUILDING_MHD_LIB=1 libmicrohttpd_la_CFLAGS = \ $(AM_CFLAGS) $(MHD_LIB_CFLAGS) $(MHD_TLS_LIB_CFLAGS) libmicrohttpd_la_LDFLAGS = \ $(AM_LDFLAGS) $(MHD_LIB_LDFLAGS) $(MHD_TLS_LIB_LDFLAGS) \ $(W32_MHD_LIB_LDFLAGS) \ -export-dynamic -no-undefined \ -version-info @LIB_VERSION_CURRENT@:@LIB_VERSION_REVISION@:@LIB_VERSION_AGE@ libmicrohttpd_la_LIBADD = \ $(MHD_LIBDEPS) $(MHD_TLS_LIBDEPS) if HAVE_W32 MHD_DLL_RES_SRC = microhttpd_dll_res.rc MHD_DLL_RES_LO = libmicrohttpd_la-$(MHD_DLL_RES_SRC:.rc=.lo) EXTRA_libmicrohttpd_la_DEPENDENCIES = $(MHD_DLL_RES_LO) libmicrohttpd_la_LIBADD += $(MHD_DLL_RES_LO) AM_V_RC = $(am__v_RC_$(V)) am__v_RC_ = $(am__v_RC_$(AM_DEFAULT_VERBOSITY)) am__v_RC_0 = @echo " RC " $@; am__v_RC_1 = # General rule is not required, but keep it just in case .rc.lo: $(AM_V_RC) $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $< -o $@ # To add dll resource only to .dll file and exclude it form static # lib, a little trick was used. Allow libtool to create file.lo, # file.o and .libs/file.lo, .libs/file.o files, then overwrite file.o # by empty object generated from empty c-file. Later libtool will # use .libs/file.o for shared lib and empty file.o for static lib. # This implementation is based on trick found in liblzma. # Note: windres does not understand '-isystem' flag, so all # possible '-isystem' flags are replaced by simple '-I' flags. $(MHD_DLL_RES_LO): $(MHD_DLL_RES_SRC) $(AM_V_RC) RC_CPP_FLAGS=" $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) " && \ $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $${RC_CPP_FLAGS// -isystem / -I} $< -o $@ && \ echo > $@-empty.c && $(CC) $(DEFS) $(AM_CFLAGS) $(CFLAGS) -c $@-empty.c -o $(@:.lo=.o) && rm -f $@-empty.c endif if USE_COVERAGE AM_CFLAGS += --coverage endif if !MHD_USE_SYS_TSEARCH libmicrohttpd_la_SOURCES += \ tsearch.c tsearch.h endif if HAVE_POSTPROCESSOR libmicrohttpd_la_SOURCES += \ postprocessor.c postprocessor.h endif if HAVE_ANYAUTH libmicrohttpd_la_SOURCES += \ gen_auth.c gen_auth.h endif if ENABLE_DAUTH libmicrohttpd_la_SOURCES += \ digestauth.c digestauth.h \ mhd_bithelpers.h mhd_byteorder.h mhd_align.h if ENABLE_MD5 libmicrohttpd_la_SOURCES += \ mhd_md5_wrap.h if ! ENABLE_MD5_EXT libmicrohttpd_la_SOURCES += \ md5.c md5.h else libmicrohttpd_la_SOURCES += \ md5_ext.c md5_ext.h endif endif if ENABLE_SHA256 libmicrohttpd_la_SOURCES += \ mhd_sha256_wrap.h if ! ENABLE_SHA256_EXT libmicrohttpd_la_SOURCES += \ sha256.c sha256.h else libmicrohttpd_la_SOURCES += \ sha256_ext.c sha256_ext.h endif endif if ENABLE_SHA512_256 libmicrohttpd_la_SOURCES += \ sha512_256.c sha512_256.h endif endif if ENABLE_BAUTH libmicrohttpd_la_SOURCES += \ basicauth.c basicauth.h endif if ENABLE_HTTPS libmicrohttpd_la_SOURCES += \ connection_https.c connection_https.h endif check_PROGRAMS = \ test_str_compare \ test_str_to_value \ test_str_from_value \ test_str_token \ test_str_token_remove \ test_str_tokens_remove \ test_str_pct \ test_str_bin_hex \ test_http_reasons \ test_sha1 \ test_start_stop \ test_daemon \ test_response_entries \ test_postprocessor_md \ test_client_put_shutdown \ test_client_put_close \ test_client_put_hard_close \ test_client_put_steps_shutdown \ test_client_put_steps_close \ test_client_put_steps_hard_close \ test_client_put_chunked_shutdown \ test_client_put_chunked_close \ test_client_put_chunked_hard_close \ test_client_put_chunked_steps_shutdown \ test_client_put_chunked_steps_close \ test_client_put_chunked_steps_hard_close \ test_options \ test_mhd_version \ test_set_panic if ENABLE_MD5 check_PROGRAMS += \ test_md5 endif if ENABLE_SHA256 check_PROGRAMS += \ test_sha256 endif if ENABLE_SHA512_256 check_PROGRAMS += \ test_sha512_256 endif if HAVE_POSIX_THREADS if ENABLE_UPGRADE if USE_THREADS check_PROGRAMS += test_upgrade test_upgrade_large test_upgrade_vlarge if ENABLE_HTTPS if USE_UPGRADE_TLS_TESTS check_PROGRAMS += test_upgrade_tls test_upgrade_large_tls test_upgrade_vlarge_tls endif endif endif endif endif if HAVE_POSTPROCESSOR check_PROGRAMS += \ test_postprocessor \ test_postprocessor_large \ test_postprocessor_amp endif # Do not test trigger of select by shutdown of listen socket # on Cygwin as this ability is deliberately ignored on Cygwin # to improve compatibility with core OS. if !CYGWIN_TARGET if HAVE_POSIX_THREADS if HAVE_LISTEN_SHUTDOWN check_PROGRAMS += \ test_shutdown_select \ test_shutdown_poll else check_PROGRAMS += \ test_shutdown_select_ignore \ test_shutdown_poll_ignore endif endif endif if HAVE_ANYAUTH if HAVE_MESSAGES check_PROGRAMS += \ test_auth_parse endif endif if ENABLE_DAUTH check_PROGRAMS += \ test_str_quote \ test_dauth_userdigest \ test_dauth_userhash endif if ENABLE_BAUTH check_PROGRAMS += \ test_str_base64 endif if HEAVY_TESTS if TESTS_STRESS_OS check_PROGRAMS += \ test_client_put_hard_close_stress_os \ test_client_put_steps_hard_close_stress_os \ test_client_put_chunked_steps_hard_close_stress_os endif endif TESTS = $(check_PROGRAMS) update-po-POTFILES.in: $(top_srcdir)/po/POTFILES.in $(top_srcdir)/po/POTFILES.in: $(srcdir)/Makefile.am @echo "Creating $@" @echo src/include/microhttpd.h > "$@" && \ for src in $(am__libmicrohttpd_la_SOURCES_DIST) ; do \ echo "$(subdir)/$$src" >> "$@" ; \ done test_start_stop_SOURCES = \ test_start_stop.c test_start_stop_LDADD = \ libmicrohttpd.la test_daemon_SOURCES = \ test_daemon.c test_daemon_LDADD = \ $(builddir)/libmicrohttpd.la test_response_entries_SOURCES = \ test_response_entries.c test_response_entries_LDADD = \ libmicrohttpd.la test_upgrade_SOURCES = \ test_upgrade.c test_helpers.h mhd_sockets.h test_upgrade_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_upgrade_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(MHD_TLS_LIB_CFLAGS) test_upgrade_LDFLAGS = \ $(MHD_TLS_LIB_LDFLAGS) test_upgrade_LDADD = \ $(builddir)/libmicrohttpd.la \ $(MHD_TLS_LIBDEPS) \ $(PTHREAD_LIBS) test_upgrade_large_SOURCES = \ $(test_upgrade_SOURCES) test_upgrade_large_CPPFLAGS = \ $(test_upgrade_CPPFLAGS) test_upgrade_large_CFLAGS = \ $(test_upgrade_CFLAGS) test_upgrade_large_LDFLAGS = \ $(test_upgrade_LDFLAGS) test_upgrade_large_LDADD = \ $(test_upgrade_LDADD) test_upgrade_vlarge_SOURCES = \ $(test_upgrade_SOURCES) test_upgrade_vlarge_CPPFLAGS = \ $(test_upgrade_CPPFLAGS) test_upgrade_vlarge_CFLAGS = \ $(test_upgrade_CFLAGS) test_upgrade_vlarge_LDFLAGS = \ $(test_upgrade_LDFLAGS) test_upgrade_vlarge_LDADD = \ $(test_upgrade_LDADD) test_upgrade_tls_SOURCES = \ $(test_upgrade_SOURCES) test_upgrade_tls_CPPFLAGS = \ $(test_upgrade_CPPFLAGS) test_upgrade_tls_CFLAGS = \ $(test_upgrade_CFLAGS) test_upgrade_tls_LDFLAGS = \ $(test_upgrade_LDFLAGS) test_upgrade_tls_LDADD = \ $(test_upgrade_LDADD) test_upgrade_large_tls_SOURCES = \ $(test_upgrade_SOURCES) test_upgrade_large_tls_CPPFLAGS = \ $(test_upgrade_CPPFLAGS) test_upgrade_large_tls_CFLAGS = \ $(test_upgrade_CFLAGS) test_upgrade_large_tls_LDFLAGS = \ $(test_upgrade_LDFLAGS) test_upgrade_large_tls_LDADD = \ $(test_upgrade_LDADD) test_upgrade_vlarge_tls_SOURCES = \ $(test_upgrade_SOURCES) test_upgrade_vlarge_tls_CPPFLAGS = \ $(test_upgrade_CPPFLAGS) test_upgrade_vlarge_tls_CFLAGS = \ $(test_upgrade_CFLAGS) test_upgrade_vlarge_tls_LDFLAGS = \ $(test_upgrade_LDFLAGS) test_upgrade_vlarge_tls_LDADD = \ $(test_upgrade_LDADD) test_postprocessor_SOURCES = \ test_postprocessor.c test_postprocessor_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_postprocessor_CFLAGS = \ $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS) test_postprocessor_LDADD = \ $(builddir)/libmicrohttpd.la test_postprocessor_amp_SOURCES = \ test_postprocessor_amp.c test_postprocessor_amp_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_postprocessor_amp_CFLAGS = \ $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS) test_postprocessor_amp_LDADD = \ $(builddir)/libmicrohttpd.la test_postprocessor_large_SOURCES = \ test_postprocessor_large.c test_postprocessor_large_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_postprocessor_large_CFLAGS = \ $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS) test_postprocessor_large_LDADD = \ $(builddir)/libmicrohttpd.la test_postprocessor_md_SOURCES = \ test_postprocessor_md.c postprocessor.h postprocessor.c \ internal.h internal.c mhd_str.h mhd_str.c \ mhd_panic.h mhd_panic.c test_postprocessor_md_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_shutdown_select_SOURCES = \ test_shutdown_select.c test_shutdown_select_CFLAGS = $(AM_CFLAGS) test_shutdown_select_LDADD = $(LDADD) if USE_POSIX_THREADS test_shutdown_select_CFLAGS += \ $(PTHREAD_CFLAGS) test_shutdown_select_LDADD += \ $(PTHREAD_LIBS) endif test_shutdown_poll_SOURCES = \ test_shutdown_select.c mhd_threads.h test_shutdown_poll_CFLAGS = $(AM_CFLAGS) test_shutdown_poll_LDADD = $(LDADD) if USE_POSIX_THREADS test_shutdown_poll_CFLAGS += \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_shutdown_poll_LDADD += \ $(PTHREAD_LIBS) endif test_shutdown_select_ignore_SOURCES = \ test_shutdown_select.c test_shutdown_select_ignore_CFLAGS = $(AM_CFLAGS) test_shutdown_select_ignore_LDADD = $(LDADD) if USE_POSIX_THREADS test_shutdown_select_ignore_CFLAGS += \ $(PTHREAD_CFLAGS) test_shutdown_select_ignore_LDADD += \ $(PTHREAD_LIBS) endif test_shutdown_poll_ignore_SOURCES = \ test_shutdown_select.c mhd_threads.h test_shutdown_poll_ignore_CFLAGS = $(AM_CFLAGS) test_shutdown_poll_ignore_LDADD = $(LDADD) if USE_POSIX_THREADS test_shutdown_poll_ignore_CFLAGS += \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) test_shutdown_poll_ignore_LDADD += \ $(PTHREAD_LIBS) endif test_str_compare_SOURCES = \ test_str.c test_helpers.h mhd_str.c mhd_str.h test_str_to_value_SOURCES = \ test_str.c test_helpers.h mhd_str.c mhd_str.h test_str_from_value_SOURCES = \ test_str.c test_helpers.h mhd_str.c mhd_str.h test_str_token_SOURCES = \ test_str_token.c mhd_str.c mhd_str.h test_str_token_remove_SOURCES = \ test_str_token_remove.c mhd_str.c mhd_str.h mhd_assert.h ../include/mhd_options.h test_str_tokens_remove_SOURCES = \ test_str_tokens_remove.c mhd_str.c mhd_str.h mhd_assert.h ../include/mhd_options.h test_http_reasons_SOURCES = \ test_http_reasons.c \ reason_phrase.c mhd_str.c mhd_str.h test_md5_SOURCES = \ test_md5.c test_helpers.h mhd_md5_wrap.h ../include/mhd_options.h if ! ENABLE_MD5_EXT test_md5_SOURCES += \ md5.c md5.h mhd_bithelpers.h mhd_byteorder.h mhd_align.h test_md5_CPPFLAGS = $(AM_CPPFLAGS) test_md5_CFLAGS = $(AM_CFLAGS) test_md5_LDFLAGS = $(AM_LDFLAGS) test_md5_LDADD = $(LDADD) else test_md5_SOURCES += \ md5_ext.c md5_ext.h test_md5_CPPFLAGS = $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_md5_CFLAGS = $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS) test_md5_LDFLAGS = $(AM_LDFLAGS) $(MHD_TLS_LIB_LDFLAGS) test_md5_LDADD = $(MHD_TLS_LIBDEPS) $(LDADD) endif test_sha256_SOURCES = \ test_sha256.c test_helpers.h mhd_sha256_wrap.h ../include/mhd_options.h if ! ENABLE_SHA256_EXT test_sha256_SOURCES += \ sha256.c sha256.h mhd_bithelpers.h mhd_byteorder.h mhd_align.h test_sha256_CPPFLAGS = $(AM_CPPFLAGS) test_sha256_CFLAGS = $(AM_CFLAGS) test_sha256_LDFLAGS = $(AM_LDFLAGS) test_sha256_LDADD = $(LDADD) else test_sha256_SOURCES += \ sha256_ext.c sha256_ext.h test_sha256_CPPFLAGS = $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_sha256_CFLAGS = $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS) test_sha256_LDFLAGS = $(AM_LDFLAGS) $(MHD_TLS_LIB_LDFLAGS) test_sha256_LDADD = $(MHD_TLS_LIBDEPS) $(LDADD) endif test_sha512_256_SOURCES = \ test_sha512_256.c test_helpers.h \ sha512_256.c sha512_256.h mhd_bithelpers.h mhd_byteorder.h mhd_align.h test_sha1_SOURCES = \ test_sha1.c test_helpers.h \ sha1.c sha1.h mhd_bithelpers.h mhd_byteorder.h mhd_align.h test_auth_parse_SOURCES = \ test_auth_parse.c gen_auth.c gen_auth.h mhd_str.h mhd_str.c mhd_assert.h test_auth_parse_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_str_quote_SOURCES = \ test_str_quote.c mhd_str.h mhd_str.c mhd_assert.h test_str_base64_SOURCES = \ test_str_base64.c mhd_str.h mhd_str.c mhd_assert.h test_str_pct_SOURCES = \ test_str_pct.c mhd_str.h mhd_str.c mhd_assert.h test_str_bin_hex_SOURCES = \ test_str_bin_hex.c mhd_str.h mhd_str.c mhd_assert.h test_options_SOURCES = \ test_options.c test_options_LDADD = \ $(builddir)/libmicrohttpd.la test_client_put_shutdown_SOURCES = \ test_client_put_stop.c test_client_put_shutdown_LDADD = \ libmicrohttpd.la test_client_put_close_SOURCES = \ test_client_put_stop.c test_client_put_close_LDADD = \ libmicrohttpd.la test_client_put_hard_close_SOURCES = \ test_client_put_stop.c test_client_put_hard_close_LDADD = \ libmicrohttpd.la test_client_put_hard_close_stress_os_SOURCES = \ $(test_client_put_hard_close_SOURCES) test_client_put_hard_close_stress_os_LDADD = \ $(test_client_put_hard_close_LDADD) test_client_put_steps_shutdown_SOURCES = \ test_client_put_stop.c test_client_put_steps_shutdown_LDADD = \ libmicrohttpd.la test_client_put_steps_close_SOURCES = \ test_client_put_stop.c test_client_put_steps_close_LDADD = \ libmicrohttpd.la test_client_put_steps_hard_close_SOURCES = \ test_client_put_stop.c test_client_put_steps_hard_close_LDADD = \ libmicrohttpd.la test_client_put_steps_hard_close_stress_os_SOURCES = \ $(test_client_put_steps_hard_close_SOURCES) test_client_put_steps_hard_close_stress_os_LDADD = \ $(test_client_put_steps_hard_close_LDADD) test_client_put_chunked_shutdown_SOURCES = \ test_client_put_stop.c test_client_put_chunked_shutdown_LDADD = \ libmicrohttpd.la test_client_put_chunked_close_SOURCES = \ test_client_put_stop.c test_client_put_chunked_close_LDADD = \ libmicrohttpd.la test_client_put_chunked_hard_close_SOURCES = \ test_client_put_stop.c test_client_put_chunked_hard_close_LDADD = \ libmicrohttpd.la test_client_put_chunked_steps_shutdown_SOURCES = \ test_client_put_stop.c test_client_put_chunked_steps_shutdown_LDADD = \ libmicrohttpd.la test_client_put_chunked_steps_close_SOURCES = \ test_client_put_stop.c test_client_put_chunked_steps_close_LDADD = \ libmicrohttpd.la test_client_put_chunked_steps_hard_close_SOURCES = \ test_client_put_stop.c test_client_put_chunked_steps_hard_close_LDADD = \ libmicrohttpd.la test_client_put_chunked_steps_hard_close_stress_os_SOURCES = \ $(test_client_put_chunked_steps_hard_close_SOURCES) test_client_put_chunked_steps_hard_close_stress_os_LDADD = \ $(test_client_put_chunked_steps_hard_close_LDADD) test_set_panic_SOURCES = \ test_set_panic.c test_set_panic_LDADD = \ libmicrohttpd.la test_dauth_userdigest_SOURCES = \ test_dauth_userdigest.c test_dauth_userdigest_LDADD = \ libmicrohttpd.la test_dauth_userhash_SOURCES = \ test_dauth_userhash.c test_dauth_userhash_LDADD = \ libmicrohttpd.la test_mhd_version_SOURCES = \ test_mhd_version.c test_mhd_version_LDADD = \ libmicrohttpd.la .PHONY: update-po-POTFILES.in libmicrohttpd-1.0.1/src/microhttpd/md5_ext.h0000644000175000017500000000552214556705750014542 /* This file is part of GNU libmicrohttpd Copyright (C) 2022-2024 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GNU libmicrohttpd. If not, see . */ /** * @file microhttpd/md5_ext.h * @brief Wrapper declarations for MD5 calculation performed by TLS library * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_MD5_EXT_H #define MHD_MD5_EXT_H 1 #include "mhd_options.h" #include #ifdef HAVE_STDDEF_H #include /* for size_t */ #endif /* HAVE_STDDEF_H */ /** * Size of MD5 resulting digest in bytes * This is the final digest size, not intermediate hash. */ #define MD5_DIGEST_SIZE (16) /* Actual declaration is in GnuTLS lib header */ struct hash_hd_st; /** * Indicates that struct Md5CtxExt has 'ext_error' */ #define MHD_MD5_HAS_EXT_ERROR 1 /** * MD5 calculation context */ struct Md5CtxExt { struct hash_hd_st *handle; /**< Hash calculation handle */ int ext_error; /**< Non-zero if external error occurs during init or hashing */ }; /** * Indicates that MHD_MD5_init_one_time() function is present. */ #define MHD_MD5_HAS_INIT_ONE_TIME 1 /** * Initialise structure for MD5 calculation, allocate resources. * * This function must not be called more than one time for @a ctx. * * @param ctx the calculation context */ void MHD_MD5_init_one_time (struct Md5CtxExt *ctx); /** * MD5 process portion of bytes. * * @param ctx the calculation context * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_MD5_update (struct Md5CtxExt *ctx, const uint8_t *data, size_t length); /** * Indicates that MHD_MD5_finish_reset() function is available */ #define MHD_MD5_HAS_FINISH_RESET 1 /** * Finalise MD5 calculation, return digest, reset hash calculation. * * @param ctx the calculation context * @param[out] digest set to the hash, must be #MD5_DIGEST_SIZE bytes */ void MHD_MD5_finish_reset (struct Md5CtxExt *ctx, uint8_t digest[MD5_DIGEST_SIZE]); /** * Indicates that MHD_MD5_deinit() function is present */ #define MHD_MD5_HAS_DEINIT 1 /** * Free allocated resources. * * @param ctx the calculation context */ void MHD_MD5_deinit (struct Md5CtxExt *ctx); #endif /* MHD_MD5_EXT_H */ libmicrohttpd-1.0.1/src/microhttpd/sha1.c0000644000175000017500000003757714556705750014043 /* This file is part of libmicrohttpd Copyright (C) 2019-2022 Karlson2k (Evgeny Grin) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/sha1.c * @brief Calculation of SHA-1 digest as defined in FIPS PUB 180-4 (2015) * @author Karlson2k (Evgeny Grin) */ #include "sha1.h" #include #ifdef HAVE_MEMORY_H #include #endif /* HAVE_MEMORY_H */ #include "mhd_bithelpers.h" #include "mhd_assert.h" /** * Initialise structure for SHA-1 calculation. * * @param ctx_ must be a `struct sha1_ctx *` */ void MHD_SHA1_init (void *ctx_) { struct sha1_ctx *const ctx = ctx_; /* Initial hash values, see FIPS PUB 180-4 paragraph 5.3.1 */ /* Just some "magic" numbers defined by standard */ ctx->H[0] = UINT32_C (0x67452301); ctx->H[1] = UINT32_C (0xefcdab89); ctx->H[2] = UINT32_C (0x98badcfe); ctx->H[3] = UINT32_C (0x10325476); ctx->H[4] = UINT32_C (0xc3d2e1f0); /* Initialise number of bytes. */ ctx->count = 0; } /** * Base of SHA-1 transformation. * Gets full 512 bits / 64 bytes block of data and updates hash values; * @param H hash values * @param data data, must be exactly 64 bytes long */ static void sha1_transform (uint32_t H[_SHA1_DIGEST_LENGTH], const uint8_t data[SHA1_BLOCK_SIZE]) { /* Working variables, see FIPS PUB 180-4 paragraph 6.1.3 */ uint32_t a = H[0]; uint32_t b = H[1]; uint32_t c = H[2]; uint32_t d = H[3]; uint32_t e = H[4]; /* Data buffer, used as cyclic buffer. See FIPS PUB 180-4 paragraphs 5.2.1, 6.1.3 */ uint32_t W[16]; /* 'Ch' and 'Maj' macro functions are defined with widely-used optimization. See FIPS PUB 180-4 formulae 4.1. */ #define Ch(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) ) #define Maj(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) /* Unoptimized (original) versions: */ /* #define Ch(x,y,z) ( ( (x) & (y) ) ^ ( ~(x) & (z) ) ) */ /* #define Maj(x,y,z) ( ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) ) */ #define Par(x,y,z) ( (x) ^ (y) ^ (z) ) /* Single step of SHA-1 computation, see FIPS PUB 180-4 paragraph 6.1.3 step 3. * Note: instead of reassigning all working variables on each step, variables are rotated for each step: SHA1STEP32 (a, b, c, d, e, func, K00, W[0]); SHA1STEP32 (e, a, b, c, d, func, K00, W[1]); so current 'vC' will be used as 'vD' on the next step, current 'vE' will be used as 'vA' on the next step. * Note: 'wt' must be used exactly one time in this macro as it change other data as well every time when used. */ #define SHA1STEP32(vA,vB,vC,vD,vE,ft,kt,wt) do { \ (vE) += _MHD_ROTL32 ((vA), 5) + ft ((vB), (vC), (vD)) + (kt) + (wt); \ (vB) = _MHD_ROTL32 ((vB), 30); } while (0) /* Get value of W(t) from input data buffer, See FIPS PUB 180-4 paragraph 6.1.3. Input data must be read in big-endian bytes order, see FIPS PUB 180-4 paragraph 3.1.2. */ /* Use cast to (void*) to mute compiler alignment warning, * data was already aligned in previous step */ #define GET_W_FROM_DATA(buf,t) \ _MHD_GET_32BIT_BE ((const void *)(((const uint8_t*) (buf)) + \ (t) * SHA1_BYTES_IN_WORD)) #ifndef _MHD_GET_32BIT_BE_UNALIGNED if (0 != (((uintptr_t) data) % _MHD_UINT32_ALIGN)) { /* Copy the unaligned input data to the aligned buffer */ memcpy (W, data, SHA1_BLOCK_SIZE); /* The W[] buffer itself will be used as the source of the data, * but data will be reloaded in correct bytes order during * the next steps */ data = (uint8_t *) W; } #endif /* _MHD_GET_32BIT_BE_UNALIGNED */ /* SHA-1 values of Kt for t=0..19, see FIPS PUB 180-4 paragraph 4.2.1. */ #define K00 UINT32_C(0x5a827999) /* SHA-1 values of Kt for t=20..39, see FIPS PUB 180-4 paragraph 4.2.1.*/ #define K20 UINT32_C(0x6ed9eba1) /* SHA-1 values of Kt for t=40..59, see FIPS PUB 180-4 paragraph 4.2.1.*/ #define K40 UINT32_C(0x8f1bbcdc) /* SHA-1 values of Kt for t=60..79, see FIPS PUB 180-4 paragraph 4.2.1.*/ #define K60 UINT32_C(0xca62c1d6) /* During first 16 steps, before making any calculations on each step, the W element is read from input data buffer as big-endian value and stored in array of W elements. */ /* Note: instead of using K constants as array, all K values are specified individually for each step. */ SHA1STEP32 (a, b, c, d, e, Ch, K00, W[0] = GET_W_FROM_DATA (data, 0)); SHA1STEP32 (e, a, b, c, d, Ch, K00, W[1] = GET_W_FROM_DATA (data, 1)); SHA1STEP32 (d, e, a, b, c, Ch, K00, W[2] = GET_W_FROM_DATA (data, 2)); SHA1STEP32 (c, d, e, a, b, Ch, K00, W[3] = GET_W_FROM_DATA (data, 3)); SHA1STEP32 (b, c, d, e, a, Ch, K00, W[4] = GET_W_FROM_DATA (data, 4)); SHA1STEP32 (a, b, c, d, e, Ch, K00, W[5] = GET_W_FROM_DATA (data, 5)); SHA1STEP32 (e, a, b, c, d, Ch, K00, W[6] = GET_W_FROM_DATA (data, 6)); SHA1STEP32 (d, e, a, b, c, Ch, K00, W[7] = GET_W_FROM_DATA (data, 7)); SHA1STEP32 (c, d, e, a, b, Ch, K00, W[8] = GET_W_FROM_DATA (data, 8)); SHA1STEP32 (b, c, d, e, a, Ch, K00, W[9] = GET_W_FROM_DATA (data, 9)); SHA1STEP32 (a, b, c, d, e, Ch, K00, W[10] = GET_W_FROM_DATA (data, 10)); SHA1STEP32 (e, a, b, c, d, Ch, K00, W[11] = GET_W_FROM_DATA (data, 11)); SHA1STEP32 (d, e, a, b, c, Ch, K00, W[12] = GET_W_FROM_DATA (data, 12)); SHA1STEP32 (c, d, e, a, b, Ch, K00, W[13] = GET_W_FROM_DATA (data, 13)); SHA1STEP32 (b, c, d, e, a, Ch, K00, W[14] = GET_W_FROM_DATA (data, 14)); SHA1STEP32 (a, b, c, d, e, Ch, K00, W[15] = GET_W_FROM_DATA (data, 15)); /* 'W' generation and assignment for 16 <= t <= 79. See FIPS PUB 180-4 paragraph 6.1.3. As only last 16 'W' are used in calculations, it is possible to use 16 elements array of W as cyclic buffer. */ #define Wgen(w,t) _MHD_ROTL32((w)[(t + 13) & 0xf] ^ (w)[(t + 8) & 0xf] \ ^ (w)[(t + 2) & 0xf] ^ (w)[t & 0xf], 1) /* During last 60 steps, before making any calculations on each step, W element is generated from W elements of cyclic buffer and generated value stored back in cyclic buffer. */ /* Note: instead of using K constants as array, all K values are specified individually for each step, see FIPS PUB 180-4 paragraph 4.2.1. */ SHA1STEP32 (e, a, b, c, d, Ch, K00, W[16 & 0xf] = Wgen (W, 16)); SHA1STEP32 (d, e, a, b, c, Ch, K00, W[17 & 0xf] = Wgen (W, 17)); SHA1STEP32 (c, d, e, a, b, Ch, K00, W[18 & 0xf] = Wgen (W, 18)); SHA1STEP32 (b, c, d, e, a, Ch, K00, W[19 & 0xf] = Wgen (W, 19)); SHA1STEP32 (a, b, c, d, e, Par, K20, W[20 & 0xf] = Wgen (W, 20)); SHA1STEP32 (e, a, b, c, d, Par, K20, W[21 & 0xf] = Wgen (W, 21)); SHA1STEP32 (d, e, a, b, c, Par, K20, W[22 & 0xf] = Wgen (W, 22)); SHA1STEP32 (c, d, e, a, b, Par, K20, W[23 & 0xf] = Wgen (W, 23)); SHA1STEP32 (b, c, d, e, a, Par, K20, W[24 & 0xf] = Wgen (W, 24)); SHA1STEP32 (a, b, c, d, e, Par, K20, W[25 & 0xf] = Wgen (W, 25)); SHA1STEP32 (e, a, b, c, d, Par, K20, W[26 & 0xf] = Wgen (W, 26)); SHA1STEP32 (d, e, a, b, c, Par, K20, W[27 & 0xf] = Wgen (W, 27)); SHA1STEP32 (c, d, e, a, b, Par, K20, W[28 & 0xf] = Wgen (W, 28)); SHA1STEP32 (b, c, d, e, a, Par, K20, W[29 & 0xf] = Wgen (W, 29)); SHA1STEP32 (a, b, c, d, e, Par, K20, W[30 & 0xf] = Wgen (W, 30)); SHA1STEP32 (e, a, b, c, d, Par, K20, W[31 & 0xf] = Wgen (W, 31)); SHA1STEP32 (d, e, a, b, c, Par, K20, W[32 & 0xf] = Wgen (W, 32)); SHA1STEP32 (c, d, e, a, b, Par, K20, W[33 & 0xf] = Wgen (W, 33)); SHA1STEP32 (b, c, d, e, a, Par, K20, W[34 & 0xf] = Wgen (W, 34)); SHA1STEP32 (a, b, c, d, e, Par, K20, W[35 & 0xf] = Wgen (W, 35)); SHA1STEP32 (e, a, b, c, d, Par, K20, W[36 & 0xf] = Wgen (W, 36)); SHA1STEP32 (d, e, a, b, c, Par, K20, W[37 & 0xf] = Wgen (W, 37)); SHA1STEP32 (c, d, e, a, b, Par, K20, W[38 & 0xf] = Wgen (W, 38)); SHA1STEP32 (b, c, d, e, a, Par, K20, W[39 & 0xf] = Wgen (W, 39)); SHA1STEP32 (a, b, c, d, e, Maj, K40, W[40 & 0xf] = Wgen (W, 40)); SHA1STEP32 (e, a, b, c, d, Maj, K40, W[41 & 0xf] = Wgen (W, 41)); SHA1STEP32 (d, e, a, b, c, Maj, K40, W[42 & 0xf] = Wgen (W, 42)); SHA1STEP32 (c, d, e, a, b, Maj, K40, W[43 & 0xf] = Wgen (W, 43)); SHA1STEP32 (b, c, d, e, a, Maj, K40, W[44 & 0xf] = Wgen (W, 44)); SHA1STEP32 (a, b, c, d, e, Maj, K40, W[45 & 0xf] = Wgen (W, 45)); SHA1STEP32 (e, a, b, c, d, Maj, K40, W[46 & 0xf] = Wgen (W, 46)); SHA1STEP32 (d, e, a, b, c, Maj, K40, W[47 & 0xf] = Wgen (W, 47)); SHA1STEP32 (c, d, e, a, b, Maj, K40, W[48 & 0xf] = Wgen (W, 48)); SHA1STEP32 (b, c, d, e, a, Maj, K40, W[49 & 0xf] = Wgen (W, 49)); SHA1STEP32 (a, b, c, d, e, Maj, K40, W[50 & 0xf] = Wgen (W, 50)); SHA1STEP32 (e, a, b, c, d, Maj, K40, W[51 & 0xf] = Wgen (W, 51)); SHA1STEP32 (d, e, a, b, c, Maj, K40, W[52 & 0xf] = Wgen (W, 52)); SHA1STEP32 (c, d, e, a, b, Maj, K40, W[53 & 0xf] = Wgen (W, 53)); SHA1STEP32 (b, c, d, e, a, Maj, K40, W[54 & 0xf] = Wgen (W, 54)); SHA1STEP32 (a, b, c, d, e, Maj, K40, W[55 & 0xf] = Wgen (W, 55)); SHA1STEP32 (e, a, b, c, d, Maj, K40, W[56 & 0xf] = Wgen (W, 56)); SHA1STEP32 (d, e, a, b, c, Maj, K40, W[57 & 0xf] = Wgen (W, 57)); SHA1STEP32 (c, d, e, a, b, Maj, K40, W[58 & 0xf] = Wgen (W, 58)); SHA1STEP32 (b, c, d, e, a, Maj, K40, W[59 & 0xf] = Wgen (W, 59)); SHA1STEP32 (a, b, c, d, e, Par, K60, W[60 & 0xf] = Wgen (W, 60)); SHA1STEP32 (e, a, b, c, d, Par, K60, W[61 & 0xf] = Wgen (W, 61)); SHA1STEP32 (d, e, a, b, c, Par, K60, W[62 & 0xf] = Wgen (W, 62)); SHA1STEP32 (c, d, e, a, b, Par, K60, W[63 & 0xf] = Wgen (W, 63)); SHA1STEP32 (b, c, d, e, a, Par, K60, W[64 & 0xf] = Wgen (W, 64)); SHA1STEP32 (a, b, c, d, e, Par, K60, W[65 & 0xf] = Wgen (W, 65)); SHA1STEP32 (e, a, b, c, d, Par, K60, W[66 & 0xf] = Wgen (W, 66)); SHA1STEP32 (d, e, a, b, c, Par, K60, W[67 & 0xf] = Wgen (W, 67)); SHA1STEP32 (c, d, e, a, b, Par, K60, W[68 & 0xf] = Wgen (W, 68)); SHA1STEP32 (b, c, d, e, a, Par, K60, W[69 & 0xf] = Wgen (W, 69)); SHA1STEP32 (a, b, c, d, e, Par, K60, W[70 & 0xf] = Wgen (W, 70)); SHA1STEP32 (e, a, b, c, d, Par, K60, W[71 & 0xf] = Wgen (W, 71)); SHA1STEP32 (d, e, a, b, c, Par, K60, W[72 & 0xf] = Wgen (W, 72)); SHA1STEP32 (c, d, e, a, b, Par, K60, W[73 & 0xf] = Wgen (W, 73)); SHA1STEP32 (b, c, d, e, a, Par, K60, W[74 & 0xf] = Wgen (W, 74)); SHA1STEP32 (a, b, c, d, e, Par, K60, W[75 & 0xf] = Wgen (W, 75)); SHA1STEP32 (e, a, b, c, d, Par, K60, W[76 & 0xf] = Wgen (W, 76)); SHA1STEP32 (d, e, a, b, c, Par, K60, W[77 & 0xf] = Wgen (W, 77)); SHA1STEP32 (c, d, e, a, b, Par, K60, W[78 & 0xf] = Wgen (W, 78)); SHA1STEP32 (b, c, d, e, a, Par, K60, W[79 & 0xf] = Wgen (W, 79)); /* Compute intermediate hash. See FIPS PUB 180-4 paragraph 6.1.3 step 4. */ H[0] += a; H[1] += b; H[2] += c; H[3] += d; H[4] += e; } /** * Process portion of bytes. * * @param ctx_ must be a `struct sha1_ctx *` * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_SHA1_update (void *ctx_, const uint8_t *data, size_t length) { struct sha1_ctx *const ctx = ctx_; unsigned bytes_have; /**< Number of bytes in buffer */ mhd_assert ((data != NULL) || (length == 0)); if (0 == length) return; /* Do nothing */ /* Note: (count & (SHA1_BLOCK_SIZE-1)) equal (count % SHA1_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned) (ctx->count & (SHA1_BLOCK_SIZE - 1)); ctx->count += length; if (0 != bytes_have) { unsigned bytes_left = SHA1_BLOCK_SIZE - bytes_have; if (length >= bytes_left) { /* Combine new data with the data in the buffer and process the full block. */ memcpy (ctx->buffer + bytes_have, data, bytes_left); data += bytes_left; length -= bytes_left; sha1_transform (ctx->H, ctx->buffer); bytes_have = 0; } } while (SHA1_BLOCK_SIZE <= length) { /* Process any full blocks of new data directly, without copying to the buffer. */ sha1_transform (ctx->H, data); data += SHA1_BLOCK_SIZE; length -= SHA1_BLOCK_SIZE; } if (0 != length) { /* Copy incomplete block of new data (if any) to the buffer. */ memcpy (ctx->buffer + bytes_have, data, length); } } /** * Size of "length" padding addition in bytes. * See FIPS PUB 180-4 paragraph 5.1.1. */ #define SHA1_SIZE_OF_LEN_ADD (64 / 8) /** * Finalise SHA-1 calculation, return digest. * * @param ctx_ must be a `struct sha1_ctx *` * @param[out] digest set to the hash, must be #SHA1_DIGEST_SIZE bytes */ void MHD_SHA1_finish (void *ctx_, uint8_t digest[SHA1_DIGEST_SIZE]) { struct sha1_ctx *const ctx = ctx_; uint64_t num_bits; /**< Number of processed bits */ unsigned bytes_have; /**< Number of bytes in buffer */ num_bits = ctx->count << 3; /* Note: (count & (SHA1_BLOCK_SIZE-1)) equals (count % SHA1_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned) (ctx->count & (SHA1_BLOCK_SIZE - 1)); /* Input data must be padded with bit "1" and with length of data in bits. See FIPS PUB 180-4 paragraph 5.1.1. */ /* Data is always processed in form of bytes (not by individual bits), therefore position of first padding bit in byte is always predefined (0x80). */ /* Buffer always have space at least for one byte (as full buffers are processed immediately). */ ctx->buffer[bytes_have++] = 0x80; if (SHA1_BLOCK_SIZE - bytes_have < SHA1_SIZE_OF_LEN_ADD) { /* No space in current block to put total length of message. Pad current block with zeros and process it. */ if (SHA1_BLOCK_SIZE > bytes_have) memset (ctx->buffer + bytes_have, 0, SHA1_BLOCK_SIZE - bytes_have); /* Process full block. */ sha1_transform (ctx->H, ctx->buffer); /* Start new block. */ bytes_have = 0; } /* Pad the rest of the buffer with zeros. */ memset (ctx->buffer + bytes_have, 0, SHA1_BLOCK_SIZE - SHA1_SIZE_OF_LEN_ADD - bytes_have); /* Put the number of bits in the processed message as a big-endian value. */ _MHD_PUT_64BIT_BE_SAFE (ctx->buffer + SHA1_BLOCK_SIZE - SHA1_SIZE_OF_LEN_ADD, num_bits); /* Process the full final block. */ sha1_transform (ctx->H, ctx->buffer); /* Put final hash/digest in BE mode */ #ifndef _MHD_PUT_32BIT_BE_UNALIGNED if (0 != ((uintptr_t) digest) % _MHD_UINT32_ALIGN) { uint32_t alig_dgst[_SHA1_DIGEST_LENGTH]; _MHD_PUT_32BIT_BE (alig_dgst + 0, ctx->H[0]); _MHD_PUT_32BIT_BE (alig_dgst + 1, ctx->H[1]); _MHD_PUT_32BIT_BE (alig_dgst + 2, ctx->H[2]); _MHD_PUT_32BIT_BE (alig_dgst + 3, ctx->H[3]); _MHD_PUT_32BIT_BE (alig_dgst + 4, ctx->H[4]); /* Copy result to unaligned destination address */ memcpy (digest, alig_dgst, SHA1_DIGEST_SIZE); } else #else /* _MHD_PUT_32BIT_BE_UNALIGNED */ if (1) #endif /* _MHD_PUT_32BIT_BE_UNALIGNED */ { /* Use cast to (void*) here to mute compiler alignment warnings. * Compilers are not smart enough to see that alignment has been checked. */ _MHD_PUT_32BIT_BE ((void *) (digest + 0 * SHA1_BYTES_IN_WORD), ctx->H[0]); _MHD_PUT_32BIT_BE ((void *) (digest + 1 * SHA1_BYTES_IN_WORD), ctx->H[1]); _MHD_PUT_32BIT_BE ((void *) (digest + 2 * SHA1_BYTES_IN_WORD), ctx->H[2]); _MHD_PUT_32BIT_BE ((void *) (digest + 3 * SHA1_BYTES_IN_WORD), ctx->H[3]); _MHD_PUT_32BIT_BE ((void *) (digest + 4 * SHA1_BYTES_IN_WORD), ctx->H[4]); } /* Erase potentially sensitive data. */ memset (ctx, 0, sizeof(struct sha1_ctx)); } libmicrohttpd-1.0.1/src/microhttpd/mhd_str.h0000644000175000017500000007403314556705750014640 /* This file is part of libmicrohttpd Copyright (C) 2015-2023 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_str.h * @brief Header for string manipulating helpers * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_STR_H #define MHD_STR_H 1 #include "mhd_options.h" #include #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_STDBOOL_H #include #endif /* HAVE_STDBOOL_H */ #include "mhd_str_types.h" #if defined(_MSC_FULL_VER) && ! defined(_SSIZE_T_DEFINED) #define _SSIZE_T_DEFINED typedef intptr_t ssize_t; #endif /* !_SSIZE_T_DEFINED */ #ifdef MHD_FAVOR_SMALL_CODE #include "mhd_limits.h" #endif /* MHD_FAVOR_SMALL_CODE */ /* * Block of functions/macros that use US-ASCII charset as required by HTTP * standards. Not affected by current locale settings. */ #ifndef MHD_FAVOR_SMALL_CODE /** * Check two strings for equality, ignoring case of US-ASCII letters. * * @param str1 first string to compare * @param str2 second string to compare * @return non-zero if two strings are equal, zero otherwise. */ int MHD_str_equal_caseless_ (const char *str1, const char *str2); #else /* MHD_FAVOR_SMALL_CODE */ /* Reuse MHD_str_equal_caseless_n_() to reduce size */ #define MHD_str_equal_caseless_(s1,s2) MHD_str_equal_caseless_n_ ((s1),(s2), \ SIZE_MAX) #endif /* MHD_FAVOR_SMALL_CODE */ /** * Check two string for equality, ignoring case of US-ASCII letters and * checking not more than @a maxlen characters. * Compares up to first terminating null character, but not more than * first @a maxlen characters. * @param str1 first string to compare * @param str2 second string to compare * @param maxlen maximum number of characters to compare * @return non-zero if two strings are equal, zero otherwise. */ int MHD_str_equal_caseless_n_ (const char *const str1, const char *const str2, size_t maxlen); /** * Check two string for equality, ignoring case of US-ASCII letters and * checking not more than @a len bytes. * Compares not more first than @a len bytes, including binary zero characters. * Comparison stops at first unmatched byte. * @param str1 first string to compare * @param str2 second string to compare * @param len number of characters to compare * @return non-zero if @a len bytes are equal, zero otherwise. */ bool MHD_str_equal_caseless_bin_n_ (const char *const str1, const char *const str2, size_t len); /** * Check whether string is equal statically allocated another string, * ignoring case of US-ASCII letters and checking not more than @a len bytes. * * If strings have different sizes (lengths) then macro returns boolean false * without checking the content. * * Compares not more first than @a len bytes, including binary zero characters. * Comparison stops at first unmatched byte. * @param a the statically allocated string to compare * @param s the string to compare * @param len number of characters to compare * @return non-zero if @a len bytes are equal, zero otherwise. */ #define MHD_str_equal_caseless_s_bin_n_(a,s,l) \ ((MHD_STATICSTR_LEN_(a) == (l)) \ && MHD_str_equal_caseless_bin_n_(a,s,l)) /** * Check whether @a str has case-insensitive @a token. * Token could be surrounded by spaces and tabs and delimited by comma. * Match succeed if substring between start, end (of string) or comma * contains only case-insensitive token and optional spaces and tabs. * @warning token must not contain null-characters except optional * terminating null-character. * @param str the string to check * @param token the token to find * @param token_len length of token, not including optional terminating * null-character. * @return non-zero if two strings are equal, zero otherwise. */ bool MHD_str_has_token_caseless_ (const char *str, const char *const token, size_t token_len); /** * Check whether @a str has case-insensitive static @a tkn. * Token could be surrounded by spaces and tabs and delimited by comma. * Match succeed if substring between start, end of string or comma * contains only case-insensitive token and optional spaces and tabs. * @warning tkn must be static string * @param str the string to check * @param tkn the static string of token to find * @return non-zero if two strings are equal, zero otherwise. */ #define MHD_str_has_s_token_caseless_(str,tkn) \ MHD_str_has_token_caseless_ ((str),(tkn),MHD_STATICSTR_LEN_ (tkn)) /** * Remove case-insensitive @a token from the @a str and put result * to the output @a buf. * * Tokens in @a str could be surrounded by spaces and tabs and delimited by * comma. The token match succeed if substring between start, end (of string) * or comma contains only case-insensitive token and optional spaces and tabs. * The quoted strings and comments are not supported by this function. * * The output string is normalised: empty tokens and repeated whitespaces * are removed, no whitespaces before commas, exactly one space is used after * each comma. * * @param str the string to process * @param str_len the length of the @a str, not including optional * terminating null-character. * @param token the token to find * @param token_len the length of @a token, not including optional * terminating null-character. * @param[out] buf the output buffer, not null-terminated. * @param[in,out] buf_size pointer to the size variable, at input it * is the size of allocated buffer, at output * it is the size of the resulting string (can * be up to 50% larger than input) or negative value * if there is not enough space for the result * @return 'true' if token has been removed, * 'false' otherwise. */ bool MHD_str_remove_token_caseless_ (const char *str, size_t str_len, const char *const token, const size_t token_len, char *buf, ssize_t *buf_size); /** * Perform in-place case-insensitive removal of @a tokens from the @a str. * * Token could be surrounded by spaces and tabs and delimited by comma. * The token match succeed if substring between start, end (of the string), or * comma contains only case-insensitive token and optional spaces and tabs. * The quoted strings and comments are not supported by this function. * * The input string must be normalised: empty tokens and repeated whitespaces * are removed, no whitespaces before commas, exactly one space is used after * each comma. The string is updated in-place. * * Behavior is undefined is the input string in not normalised. * * @param[in,out] str the string to update * @param[in,out] str_len the length of the @a str, not including optional * terminating null-character, not null-terminated * @param tokens the token to find * @param tokens_len the length of @a tokens, not including optional * terminating null-character. * @return 'true' if any token has been removed, * 'false' otherwise. */ bool MHD_str_remove_tokens_caseless_ (char *str, size_t *str_len, const char *const tokens, const size_t tokens_len); #ifndef MHD_FAVOR_SMALL_CODE /* Use individual function for each case to improve speed */ /** * Convert decimal US-ASCII digits in string to number in uint64_t. * Conversion stopped at first non-digit character. * * @param str string to convert * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_str_to_uint64_ (const char *str, uint64_t *out_val); /** * Convert not more then @a maxlen decimal US-ASCII digits in string to * number in uint64_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * * @param str string to convert * @param maxlen maximum number of characters to process * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_str_to_uint64_n_ (const char *str, size_t maxlen, uint64_t *out_val); /** * Convert hexadecimal US-ASCII digits in string to number in uint32_t. * Conversion stopped at first non-digit character. * * @param str string to convert * @param[out] out_val pointer to uint32_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint32_t or @a out_val is NULL */ size_t MHD_strx_to_uint32_ (const char *str, uint32_t *out_val); /** * Convert not more then @a maxlen hexadecimal US-ASCII digits in string * to number in uint32_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * * @param str string to convert * @param maxlen maximum number of characters to process * @param[out] out_val pointer to uint32_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint32_t or @a out_val is NULL */ size_t MHD_strx_to_uint32_n_ (const char *str, size_t maxlen, uint32_t *out_val); /** * Convert hexadecimal US-ASCII digits in string to number in uint64_t. * Conversion stopped at first non-digit character. * * @param str string to convert * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_strx_to_uint64_ (const char *str, uint64_t *out_val); /** * Convert not more then @a maxlen hexadecimal US-ASCII digits in string * to number in uint64_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * * @param str string to convert * @param maxlen maximum number of characters to process * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_strx_to_uint64_n_ (const char *str, size_t maxlen, uint64_t *out_val); #else /* MHD_FAVOR_SMALL_CODE */ /* Use one universal function and macros to reduce size */ /** * Generic function for converting not more then @a maxlen * hexadecimal or decimal US-ASCII digits in string to number. * Conversion stopped at first non-digit character or after @a maxlen * digits. * To be used only within macro. * * @param str the string to convert * @param maxlen the maximum number of characters to process * @param out_val the pointer to variable to store result of conversion * @param val_size the size of variable pointed by @a out_val, in bytes, 4 or 8 * @param max_val the maximum decoded number * @param base the numeric base, 10 or 16 * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then @a max_val, @a val_size is not 4/8 or @a out_val is NULL */ size_t MHD_str_to_uvalue_n_ (const char *str, size_t maxlen, void *out_val, size_t val_size, uint64_t max_val, unsigned int base); #define MHD_str_to_uint64_(s,ov) MHD_str_to_uvalue_n_ ((s),SIZE_MAX,(ov), \ sizeof(uint64_t), \ UINT64_MAX,10) #define MHD_str_to_uint64_n_(s,ml,ov) MHD_str_to_uvalue_n_ ((s),(ml),(ov), \ sizeof(uint64_t), \ UINT64_MAX,10) #define MHD_strx_to_sizet_(s,ov) MHD_str_to_uvalue_n_ ((s),SIZE_MAX,(ov), \ sizeof(size_t),SIZE_MAX, \ 16) #define MHD_strx_to_sizet_n_(s,ml,ov) MHD_str_to_uvalue_n_ ((s),(ml),(ov), \ sizeof(size_t), \ SIZE_MAX,16) #define MHD_strx_to_uint32_(s,ov) MHD_str_to_uvalue_n_ ((s),SIZE_MAX,(ov), \ sizeof(uint32_t), \ UINT32_MAX,16) #define MHD_strx_to_uint32_n_(s,ml,ov) MHD_str_to_uvalue_n_ ((s),(ml),(ov), \ sizeof(uint32_t), \ UINT32_MAX,16) #define MHD_strx_to_uint64_(s,ov) MHD_str_to_uvalue_n_ ((s),SIZE_MAX,(ov), \ sizeof(uint64_t), \ UINT64_MAX,16) #define MHD_strx_to_uint64_n_(s,ml,ov) MHD_str_to_uvalue_n_ ((s),(ml),(ov), \ sizeof(uint64_t), \ UINT64_MAX,16) #endif /* MHD_FAVOR_SMALL_CODE */ /** * Convert uint32_t value to hexdecimal US-ASCII string. * @note: result is NOT zero-terminated. * @param val the value to convert * @param buf the buffer to result to * @param buf_size size of the @a buffer * @return number of characters has been put to the @a buf, * zero if buffer is too small (buffer may be modified). */ size_t MHD_uint32_to_strx (uint32_t val, char *buf, size_t buf_size); #ifndef MHD_FAVOR_SMALL_CODE /** * Convert uint16_t value to decimal US-ASCII string. * @note: result is NOT zero-terminated. * @param val the value to convert * @param buf the buffer to result to * @param buf_size size of the @a buffer * @return number of characters has been put to the @a buf, * zero if buffer is too small (buffer may be modified). */ size_t MHD_uint16_to_str (uint16_t val, char *buf, size_t buf_size); #else /* MHD_FAVOR_SMALL_CODE */ #define MHD_uint16_to_str(v,b,s) MHD_uint64_to_str(v,b,s) #endif /* MHD_FAVOR_SMALL_CODE */ /** * Convert uint64_t value to decimal US-ASCII string. * @note: result is NOT zero-terminated. * @param val the value to convert * @param buf the buffer to result to * @param buf_size size of the @a buffer * @return number of characters has been put to the @a buf, * zero if buffer is too small (buffer may be modified). */ size_t MHD_uint64_to_str (uint64_t val, char *buf, size_t buf_size); /** * Convert uint16_t value to decimal US-ASCII string padded with * zeros on the left side. * * @note: result is NOT zero-terminated. * @param val the value to convert * @param min_digits the minimal number of digits to print, * output padded with zeros on the left side, * 'zero' value is interpreted as 'one', * valid values are 3, 2, 1, 0 * @param buf the buffer to result to * @param buf_size size of the @a buffer * @return number of characters has been put to the @a buf, * zero if buffer is too small (buffer may be modified). */ size_t MHD_uint8_to_str_pad (uint8_t val, uint8_t min_digits, char *buf, size_t buf_size); /** * Convert @a size bytes from input binary data to lower case * hexadecimal digits. * Result is NOT zero-terminated * @param bin the pointer to the binary data to convert * @param size the size in bytes of the binary data to convert * @param[out] hex the output buffer, should be at least 2 * @a size * @return The number of characters written to the output buffer. */ size_t MHD_bin_to_hex (const void *bin, size_t size, char *hex); /** * Convert @a size bytes from input binary data to lower case * hexadecimal digits, zero-terminate the result. * @param bin the pointer to the binary data to convert * @param size the size in bytes of the binary data to convert * @param[out] hex the output buffer, should be at least 2 * @a size + 1 * @return The number of characters written to the output buffer, * not including terminating zero. */ size_t MHD_bin_to_hex_z (const void *bin, size_t size, char *hex); /** * Convert hexadecimal digits to binary data. * * The input decoded byte-by-byte (each byte is two hexadecimal digits). * If length is an odd number, extra leading zero is assumed. * * @param hex the input string with hexadecimal digits * @param len the length of the input string * @param[out] bin the output buffer, must be at least len/2 bytes long (or * len/2 + 1 if @a len is not even number) * @return the number of bytes written to the output buffer, * zero if found any character which is not hexadecimal digits */ size_t MHD_hex_to_bin (const char *hex, size_t len, void *bin); /** * Decode string with percent-encoded characters as defined by * RFC 3986 #section-2.1. * * This function decode string by converting percent-encoded characters to * their decoded versions and copying all other characters without extra * processing. * * @param pct_encoded the input string to be decoded * @param pct_encoded_len the length of the @a pct_encoded * @param[out] decoded the output buffer, NOT zero-terminated, can point * to the same buffer as @a pct_encoded * @param buf_size the size of the output buffer * @return the number of characters written to the output buffer or * zero if any percent-encoded characters is broken ('%' followed * by less than two hexadecimal digits) or output buffer is too * small to hold the result */ size_t MHD_str_pct_decode_strict_n_ (const char *pct_encoded, size_t pct_encoded_len, char *decoded, size_t buf_size); /** * Decode string with percent-encoded characters as defined by * RFC 3986 #section-2.1. * * This function decode string by converting percent-encoded characters to * their decoded versions and copying all other characters without extra * processing. * * Any invalid percent-encoding sequences ('%' symbol not followed by two * valid hexadecimal digits) are copied to the output string without decoding. * * @param pct_encoded the input string to be decoded * @param pct_encoded_len the length of the @a pct_encoded * @param[out] decoded the output buffer, NOT zero-terminated, can point * to the same buffer as @a pct_encoded * @param buf_size the size of the output buffer * @param[out] broken_encoding will be set to true if any '%' symbol is not * followed by two valid hexadecimal digits, * optional, can be NULL * @return the number of characters written to the output buffer or * zero if output buffer is too small to hold the result */ size_t MHD_str_pct_decode_lenient_n_ (const char *pct_encoded, size_t pct_encoded_len, char *decoded, size_t buf_size, bool *broken_encoding); /** * Decode string in-place with percent-encoded characters as defined by * RFC 3986 #section-2.1. * * This function decode string by converting percent-encoded characters to * their decoded versions and copying back all other characters without extra * processing. * * @param[in,out] str the string to be updated in-place, must be zero-terminated * on input, the output is zero-terminated; the string is * truncated to zero length if broken encoding is found * @return the number of character in decoded string */ size_t MHD_str_pct_decode_in_place_strict_ (char *str); /** * Decode string in-place with percent-encoded characters as defined by * RFC 3986 #section-2.1. * * This function decode string by converting percent-encoded characters to * their decoded versions and copying back all other characters without extra * processing. * * Any invalid percent-encoding sequences ('%' symbol not followed by two * valid hexadecimal digits) are copied to the output string without decoding. * * @param[in,out] str the string to be updated in-place, must be zero-terminated * on input, the output is zero-terminated * @param[out] broken_encoding will be set to true if any '%' symbol is not * followed by two valid hexadecimal digits, * optional, can be NULL * @return the number of character in decoded string */ size_t MHD_str_pct_decode_in_place_lenient_ (char *str, bool *broken_encoding); #ifdef DAUTH_SUPPORT /** * Check two strings for equality, "unquoting" the first string from quoted * form as specified by RFC7230#section-3.2.6 and RFC7694#quoted.strings. * * Null-termination for input strings is not required, binary zeros compared * like other characters. * * @param quoted the quoted string to compare, must NOT include leading and * closing DQUOTE chars, does not need to be zero-terminated * @param quoted_len the length in chars of the @a quoted string * @param unquoted the unquoted string to compare, does not need to be * zero-terminated * @param unquoted_len the length in chars of the @a unquoted string * @return zero if quoted form is broken (no character after the last escaping * backslash), zero if strings are not equal after unquoting of the * first string, * non-zero if two strings are equal after unquoting of the * first string. */ bool MHD_str_equal_quoted_bin_n (const char *quoted, size_t quoted_len, const char *unquoted, size_t unquoted_len); /** * Check whether the string after "unquoting" equals static string. * * Null-termination for input string is not required, binary zeros compared * like other characters. * * @param q the quoted string to compare, must NOT include leading and * closing DQUOTE chars, does not need to be zero-terminated * @param l the length in chars of the @a q string * @param u the unquoted static string to compare * @return zero if quoted form is broken (no character after the last escaping * backslash), zero if strings are not equal after unquoting of the * first string, * non-zero if two strings are equal after unquoting of the * first string. */ #define MHD_str_equal_quoted_s_bin_n(q,l,u) \ MHD_str_equal_quoted_bin_n(q,l,u,MHD_STATICSTR_LEN_(u)) /** * Check two strings for equality, "unquoting" the first string from quoted * form as specified by RFC7230#section-3.2.6 and RFC7694#quoted.strings and * ignoring case of US-ASCII letters. * * Null-termination for input strings is not required, binary zeros compared * like other characters. * * @param quoted the quoted string to compare, must NOT include leading and * closing DQUOTE chars, does not need to be zero-terminated * @param quoted_len the length in chars of the @a quoted string * @param unquoted the unquoted string to compare, does not need to be * zero-terminated * @param unquoted_len the length in chars of the @a unquoted string * @return zero if quoted form is broken (no character after the last escaping * backslash), zero if strings are not equal after unquoting of the * first string, * non-zero if two strings are caseless equal after unquoting of the * first string. */ bool MHD_str_equal_caseless_quoted_bin_n (const char *quoted, size_t quoted_len, const char *unquoted, size_t unquoted_len); /** * Check whether the string after "unquoting" equals static string, ignoring * case of US-ASCII letters. * * Null-termination for input string is not required, binary zeros compared * like other characters. * * @param q the quoted string to compare, must NOT include leading and * closing DQUOTE chars, does not need to be zero-terminated * @param l the length in chars of the @a q string * @param u the unquoted static string to compare * @return zero if quoted form is broken (no character after the last escaping * backslash), zero if strings are not equal after unquoting of the * first string, * non-zero if two strings are caseless equal after unquoting of the * first string. */ #define MHD_str_equal_caseless_quoted_s_bin_n(q,l,u) \ MHD_str_equal_caseless_quoted_bin_n(q,l,u,MHD_STATICSTR_LEN_(u)) /** * Convert string from quoted to unquoted form as specified by * RFC7230#section-3.2.6 and RFC7694#quoted.strings. * * @param quoted the quoted string, must NOT include leading and closing * DQUOTE chars, does not need to be zero-terminated * @param quoted_len the length in chars of the @a quoted string * @param[out] result the pointer to the buffer to put the result, must * be at least @a size character long. May be modified even * if @a quoted is invalid sequence. The result is NOT * zero-terminated. * @return The number of characters written to the output buffer, * zero if last backslash is not followed by any character (or * @a quoted_len is zero). */ size_t MHD_str_unquote (const char *quoted, size_t quoted_len, char *result); #endif /* DAUTH_SUPPORT */ #if defined(DAUTH_SUPPORT) || defined(BAUTH_SUPPORT) /** * Convert string from unquoted to quoted form as specified by * RFC7230#section-3.2.6 and RFC7694#quoted.strings. * * @param unquoted the unquoted string, does not need to be zero-terminated * @param unquoted_len the length in chars of the @a unquoted string * @param[out] result the pointer to the buffer to put the result. May be * modified even if function failed due to insufficient * space. The result is NOT zero-terminated and does not * have opening and closing DQUOTE chars. * @param buf_size the size of the allocated memory for @a result * @return The number of copied characters, can be up to two times more than * @a unquoted_len, zero if @a unquoted_len is zero or if quoted * string is larger than @a buf_size. */ size_t MHD_str_quote (const char *unquoted, size_t unquoted_len, char *result, size_t buf_size); #endif /* DAUTH_SUPPORT || BAUTH_SUPPORT */ #ifdef BAUTH_SUPPORT /** * Returns the maximum possible size of the Base64 decoded data. * The real recoded size could be up to two bytes smaller. * @param enc_size the size of encoded data, in characters * @return the maximum possible size of the decoded data, in bytes, if * @a enc_size is valid (properly padded), * undefined value smaller then @a enc_size if @a enc_size is not valid */ #define MHD_base64_max_dec_size_(enc_size) (((enc_size) / 4) * 3) /** * Convert Base64 encoded string to binary data. * @param base64 the input string with Base64 encoded data, could be NOT zero * terminated * @param base64_len the number of characters to decode in @a base64 string, * valid number must be a multiple of four * @param[out] bin the pointer to the output buffer, the buffer may be altered * even if decoding failed * @param bin_size the size of the @a bin buffer in bytes, if the size is * at least @a base64_len / 4 * 3 then result will always * fit, regardless of the amount of the padding characters * @return 0 if @a base64_len is zero, or input string has wrong data (not * valid Base64 sequence), or @a bin_size is too small; * non-zero number of bytes written to the @a bin, the number must be * (base64_len / 4 * 3 - 2), (base64_len / 4 * 3 - 1) or * (base64_len / 4 * 3), depending on the number of padding characters. */ size_t MHD_base64_to_bin_n (const char *base64, size_t base64_len, void *bin, size_t bin_size); #endif /* BAUTH_SUPPORT */ #endif /* MHD_STR_H */ libmicrohttpd-1.0.1/src/microhttpd/sha512_256.h0000644000175000017500000000711114441373361014560 /* This file is part of GNU libmicrohttpd Copyright (C) 2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/sha512_256.h * @brief Calculation of SHA-512/256 digest * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_SHA512_256_H #define MHD_SHA512_256_H 1 #include "mhd_options.h" #include #ifdef HAVE_STDDEF_H #include /* for size_t */ #endif /* HAVE_STDDEF_H */ /** * Number of bits in single SHA-512/256 word. */ #define SHA512_256_WORD_SIZE_BITS 64 /** * Number of bytes in single SHA-512/256 word. */ #define SHA512_256_BYTES_IN_WORD (SHA512_256_WORD_SIZE_BITS / 8) /** * Hash is kept internally as 8 64-bit words. * This is intermediate hash size, used during computing the final digest. */ #define SHA512_256_HASH_SIZE_WORDS 8 /** * Size of SHA-512/256 resulting digest in bytes. * This is the final digest size, not intermediate hash. */ #define SHA512_256_DIGEST_SIZE_WORDS (SHA512_256_HASH_SIZE_WORDS / 2) /** * Size of SHA-512/256 resulting digest in bytes * This is the final digest size, not intermediate hash. */ #define SHA512_256_DIGEST_SIZE \ (SHA512_256_DIGEST_SIZE_WORDS * SHA512_256_BYTES_IN_WORD) /** * Size of SHA-512/256 digest string in chars including termination NUL. */ #define SHA512_256_DIGEST_STRING_SIZE ((SHA512_256_DIGEST_SIZE) * 2 + 1) /** * Size of SHA-512/256 single processing block in bits. */ #define SHA512_256_BLOCK_SIZE_BITS 1024 /** * Size of SHA-512/256 single processing block in bytes. */ #define SHA512_256_BLOCK_SIZE (SHA512_256_BLOCK_SIZE_BITS / 8) /** * Size of SHA-512/256 single processing block in words. */ #define SHA512_256_BLOCK_SIZE_WORDS \ (SHA512_256_BLOCK_SIZE_BITS / SHA512_256_WORD_SIZE_BITS) /** * SHA-512/256 calculation context */ struct Sha512_256Ctx { uint64_t H[SHA512_256_HASH_SIZE_WORDS]; /**< Intermediate hash value */ uint64_t buffer[SHA512_256_BLOCK_SIZE_WORDS]; /**< SHA512_256 input data buffer */ /** * The number of bytes, lower part */ uint64_t count; /** * The number of bits, high part. * Unlike lower part, this counts the number of bits, not bytes. */ uint64_t count_bits_hi; }; /** * Initialise structure for SHA-512/256 calculation. * * @param ctx the calculation context */ void MHD_SHA512_256_init (struct Sha512_256Ctx *ctx); /** * Process portion of bytes. * * @param ctx the calculation context * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_SHA512_256_update (struct Sha512_256Ctx *ctx, const uint8_t *data, size_t length); /** * Finalise SHA-512/256 calculation, return digest. * * @param ctx the calculation context * @param[out] digest set to the hash, must be #SHA512_256_DIGEST_SIZE bytes */ void MHD_SHA512_256_finish (struct Sha512_256Ctx *ctx, uint8_t digest[SHA512_256_DIGEST_SIZE]); #endif /* MHD_SHA512_256_H */ libmicrohttpd-1.0.1/src/microhttpd/test_sha256.c0000644000175000017500000004775314445225034015240 /* This file is part of libmicrohttpd Copyright (C) 2019-2023 Evgeny Grin (Karlson2k) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_sha256.h * @brief Unit tests for SHA-256 functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "mhd_sha256_wrap.h" #include "test_helpers.h" #include #include #if defined(MHD_SHA256_TLSLIB) && defined(MHD_HTTPS_REQUIRE_GCRYPT) #define NEED_GCRYP_INIT 1 #include #endif /* MHD_SHA256_TLSLIB && MHD_HTTPS_REQUIRE_GCRYPT */ static int verbose = 0; /* verbose level (0-1)*/ struct str_with_len { const char *const str; const size_t len; }; #define D_STR_W_LEN(s) {(s), (sizeof((s)) / sizeof(char)) - 1} struct data_unit1 { const struct str_with_len str_l; const uint8_t digest[SHA256_DIGEST_SIZE]; }; static const struct data_unit1 data_units1[] = { {D_STR_W_LEN ("abc"), {0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}}, {D_STR_W_LEN ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"), {0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39, 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1}}, {D_STR_W_LEN (""), {0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}}, {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."), {0x2f, 0xad, 0x7a, 0xff, 0x7d, 0xfe, 0xcd, 0x78, 0xe4, 0xa6, 0xf3, 0x85, 0x97, 0x9d, 0xdc, 0x39, 0x55, 0x24, 0x35, 0x4a, 0x00, 0x6f, 0x42, 0x72, 0x41, 0xc1, 0x52, 0xa7, 0x01, 0x0b, 0x2c, 0x41}}, {D_STR_W_LEN ("Simple string."), {0x01, 0x73, 0x17, 0xc4, 0x0a, 0x9a, 0x0e, 0x81, 0xb3, 0xa4, 0xb1, 0x8e, 0xe9, 0xd6, 0xc2, 0xdf, 0xfa, 0x7d, 0x53, 0x4e, 0xa1, 0xda, 0xb2, 0x5a, 0x75, 0xbb, 0x2c, 0x30, 0x2f, 0x5f, 0x7a, 0xf4}}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"), {0x71, 0xc4, 0x80, 0xdf, 0x93, 0xd6, 0xae, 0x2f, 0x1e, 0xfa, 0xd1, 0x44, 0x7c, 0x66, 0xc9, 0x52, 0x5e, 0x31, 0x62, 0x18, 0xcf, 0x51, 0xfc, 0x8d, 0x9e, 0xd8, 0x32, 0xf2, 0xda, 0xf1, 0x8b, 0x73}}, {D_STR_W_LEN ("zyxwvutsrqponMLKJIHGFEDCBA"), {0xce, 0x7d, 0xde, 0xb6, 0x1f, 0x7c, 0x1d, 0x83, 0x7c, 0x60, 0xd8, 0x36, 0x73, 0x82, 0xac, 0x92, 0xca, 0x37, 0xfd, 0x72, 0x8b, 0x0c, 0xd1, 0x6c, 0x55, 0xd5, 0x88, 0x98, 0x24, 0xfa, 0x16, 0xf2}}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA" \ "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"), {0x27, 0xd1, 0xe8, 0xbc, 0x6a, 0x79, 0x16, 0x83, 0x61, 0x73, 0xa9, 0xa8, 0x9b, 0xaf, 0xaf, 0xcf, 0x47, 0x4d, 0x09, 0xef, 0x6d, 0x50, 0x35, 0x12, 0x25, 0x72, 0xd8, 0x68, 0xdc, 0x1f, 0xd2, 0xf4}}, {D_STR_W_LEN ("/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/path?with%20some=parameters"), {0x73, 0x85, 0xc5, 0xb9, 0x8f, 0xaf, 0x7d, 0x5e, 0xad, 0xd8, 0x0b, 0x8e, 0x12, 0xdb, 0x28, 0x60, 0xc7, 0xc7, 0x55, 0x05, 0x2f, 0x7c, 0x6f, 0xfa, 0xd1, 0xe3, 0xe1, 0x7b, 0x04, 0xd4, 0xb0, 0x21}} }; static const size_t units1_num = sizeof(data_units1) / sizeof(data_units1[0]); struct bin_with_len { const uint8_t bin[512]; const size_t len; }; struct data_unit2 { const struct bin_with_len bin_l; const uint8_t digest[SHA256_DIGEST_SIZE]; }; /* Size must be less than 512 bytes! */ static const struct data_unit2 data_units2[] = { { { {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}, 26}, /* a..z ASCII sequence */ {0x71, 0xc4, 0x80, 0xdf, 0x93, 0xd6, 0xae, 0x2f, 0x1e, 0xfa, 0xd1, 0x44, 0x7c, 0x66, 0xc9, 0x52, 0x5e, 0x31, 0x62, 0x18, 0xcf, 0x51, 0xfc, 0x8d, 0x9e, 0xd8, 0x32, 0xf2, 0xda, 0xf1, 0x8b, 0x73}}, { { {65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65}, 72 },/* 'A' x 72 times */ {0x6a, 0x6d, 0x69, 0x1a, 0xc9, 0xba, 0x70, 0x95, 0x50, 0x46, 0x75, 0x7c, 0xd6, 0x85, 0xb6, 0x25, 0x77, 0x73, 0xff, 0x3a, 0xd9, 0x3f, 0x43, 0xd4, 0xd4, 0x81, 0x2c, 0x5b, 0x10, 0x6f, 0x4b, 0x5b}}, { { {19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73}, 55}, /* 19..73 sequence */ {0x06, 0xe4, 0xb3, 0x9e, 0xf1, 0xfb, 0x6c, 0xcf, 0xd7, 0x3f, 0x50, 0x9e, 0xf4, 0x16, 0x17, 0xd4, 0x63, 0x7c, 0x39, 0x1e, 0xa8, 0x0f, 0xa9, 0x88, 0x03, 0x44, 0x98, 0x0e, 0x95, 0x81, 0xf0, 0x2a}}, { { {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69}, 63}, /* 7..69 sequence */ {0x4a, 0xd3, 0xc6, 0x87, 0x1f, 0xd1, 0xc5, 0xe2, 0x3e, 0x52, 0xdc, 0x22, 0xd1, 0x10, 0xd2, 0x05, 0x15, 0x23, 0xcd, 0x15, 0xac, 0x24, 0x88, 0x26, 0x02, 0x00, 0x70, 0x78, 0x9f, 0x17, 0xf8, 0xd9}}, { { {38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92}, 55}, /* 38..92 sequence */ {0xe6, 0x03, 0x0f, 0xc9, 0x0d, 0xca, 0x0c, 0x26, 0x41, 0xcf, 0x43, 0x27, 0xec, 0xd6, 0x28, 0x2a, 0x98, 0x24, 0x55, 0xd3, 0x5a, 0xed, 0x8b, 0x32, 0x19, 0x78, 0xeb, 0x83, 0x1d, 0x19, 0x92, 0x79}}, { { {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72}, 72},/* 1..72 sequence */ {0x87, 0xa2, 0xfa, 0x2e, 0xec, 0x53, 0x05, 0x3c, 0xb1, 0xee, 0x07, 0xd7, 0x59, 0x70, 0xf6, 0x50, 0xcd, 0x9d, 0xc5, 0x8b, 0xdc, 0xb8, 0x65, 0x30, 0x4f, 0x70, 0x82, 0x9e, 0xbd, 0xe2, 0x7d, 0xac}}, { { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}, 256}, /* 0..255 sequence */ {0x40, 0xaf, 0xf2, 0xe9, 0xd2, 0xd8, 0x92, 0x2e, 0x47, 0xaf, 0xd4, 0x64, 0x8e, 0x69, 0x67, 0x49, 0x71, 0x58, 0x78, 0x5f, 0xbd, 0x1d, 0xa8, 0x70, 0xe7, 0x11, 0x02, 0x66, 0xbf, 0x94, 0x48, 0x80}}, { { {199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139}, 61}, /* 199..139 sequence */ {0x85, 0xf8, 0xa2, 0x83, 0xd6, 0x3c, 0x76, 0x8e, 0xea, 0x8f, 0x1c, 0x57, 0x2d, 0x85, 0xb6, 0xff, 0xd8, 0x33, 0x57, 0x62, 0x1d, 0x37, 0xae, 0x0e, 0xfc, 0x22, 0xd3, 0xd5, 0x8f, 0x53, 0x21, 0xb7}}, { { {255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, 255}, /* 255..1 sequence */ {0x61, 0x86, 0x96, 0xab, 0x3e, 0xaa, 0x0e, 0x64, 0xb2, 0xf7, 0x2d, 0x75, 0x47, 0x5a, 0x14, 0x97, 0xa3, 0x3d, 0x59, 0xa4, 0x08, 0xd9, 0x9e, 0x73, 0xf2, 0x78, 0x00, 0x5b, 0x4b, 0x55, 0xca, 0x43}}, { { {41, 35, 190, 132, 225, 108, 214, 174, 82, 144, 73, 241, 241, 187, 233, 235, 179, 166, 219, 60, 135, 12, 62, 153, 36, 94, 13, 28, 6, 183, 71, 222, 179, 18, 77, 200, 67, 187, 139, 166, 31, 3, 90, 125, 9, 56, 37, 31, 93, 212, 203, 252, 150, 245, 69, 59, 19, 13, 137, 10, 28, 219, 174, 50, 32, 154, 80, 238, 64, 120, 54, 253, 18, 73, 50, 246, 158, 125, 73, 220, 173, 79, 20, 242, 68, 64, 102, 208, 107, 196, 48, 183, 50, 59, 161, 34, 246, 34, 145, 157, 225, 139, 31, 218, 176, 202, 153, 2, 185, 114, 157, 73, 44, 128, 126, 197, 153, 213, 233, 128, 178, 234, 201, 204, 83, 191, 103, 214, 191, 20, 214, 126, 45, 220, 142, 102, 131, 239, 87, 73, 97, 255, 105, 143, 97, 205, 209, 30, 157, 156, 22, 114, 114, 230, 29, 240, 132, 79, 74, 119, 2, 215, 232, 57, 44, 83, 203, 201, 18, 30, 51, 116, 158, 12, 244, 213, 212, 159, 212, 164, 89, 126, 53, 207, 50, 34, 244, 204, 207, 211, 144, 45, 72, 211, 143, 117, 230, 217, 29, 42, 229, 192, 247, 43, 120, 129, 135, 68, 14, 95, 80, 0, 212, 97, 141, 190, 123, 5, 21, 7, 59, 51, 130, 31, 24, 112, 146, 218, 100, 84, 206, 177, 133, 62, 105, 21, 248, 70, 106, 4, 150, 115, 14, 217, 22, 47, 103, 104, 212, 247, 74, 74, 208, 87, 104}, 255}, /* pseudo-random data */ {0x08, 0x7f, 0x86, 0xac, 0xe2, 0x2e, 0x28, 0x56, 0x74, 0x53, 0x4f, 0xc0, 0xfb, 0xb8, 0x79, 0x57, 0xc5, 0xc8, 0xd1, 0xb7, 0x47, 0xb7, 0xd9, 0xea, 0x97, 0xa8, 0x67, 0xe9, 0x26, 0x93, 0xee, 0xa3}} }; static const size_t units2_num = sizeof(data_units2) / sizeof(data_units2[0]); /* * Helper functions */ /** * Print bin as hex * * @param bin binary data * @param len number of bytes in bin * @param hex pointer to len*2+1 bytes buffer */ static void bin2hex (const uint8_t *bin, size_t len, char *hex) { while (len-- > 0) { unsigned int b1, b2; b1 = (*bin >> 4) & 0xf; *hex++ = (char) ((b1 > 9) ? (b1 + 'A' - 10) : (b1 + '0')); b2 = *bin++ & 0xf; *hex++ = (char) ((b2 > 9) ? (b2 + 'A' - 10) : (b2 + '0')); } *hex = 0; } static int check_result (const char *test_name, unsigned int check_num, const uint8_t calculated[SHA256_DIGEST_SIZE], const uint8_t expected[SHA256_DIGEST_SIZE]) { int failed = memcmp (calculated, expected, SHA256_DIGEST_SIZE); check_num++; /* Print 1-based numbers */ if (failed) { char calc_str[SHA256_DIGEST_STRING_SIZE]; char expc_str[SHA256_DIGEST_STRING_SIZE]; bin2hex (calculated, SHA256_DIGEST_SIZE, calc_str); bin2hex (expected, SHA256_DIGEST_SIZE, expc_str); fprintf (stderr, "FAILED: %s check %u: calculated digest %s, expected digest %s.\n", test_name, check_num, calc_str, expc_str); fflush (stderr); } else if (verbose) { char calc_str[SHA256_DIGEST_STRING_SIZE]; bin2hex (calculated, SHA256_DIGEST_SIZE, calc_str); printf ("PASSED: %s check %u: calculated digest %s " "matches expected digest.\n", test_name, check_num, calc_str); fflush (stdout); } return failed ? 1 : 0; } /* * Tests */ /* Calculated SHA-256 as one pass for whole data */ static int test1_str (void) { int num_failed = 0; unsigned int i; struct Sha256CtxWr ctx; MHD_SHA256_init_one_time (&ctx); for (i = 0; i < units1_num; i++) { uint8_t digest[SHA256_DIGEST_SIZE]; MHD_SHA256_update (&ctx, (const uint8_t *) data_units1[i].str_l.str, data_units1[i].str_l.len); MHD_SHA256_finish_reset (&ctx, digest); #ifdef MHD_SHA256_HAS_EXT_ERROR if (0 != ctx.ext_error) { fprintf (stderr, "External hashing error: %d.\n", ctx.ext_error); exit (99); } #endif /* MHD_SHA256_HAS_EXT_ERROR */ num_failed += check_result (MHD_FUNC_, i, digest, data_units1[i].digest); } MHD_SHA256_deinit (&ctx); return num_failed; } static int test1_bin (void) { int num_failed = 0; unsigned int i; struct Sha256CtxWr ctx; MHD_SHA256_init_one_time (&ctx); for (i = 0; i < units2_num; i++) { uint8_t digest[SHA256_DIGEST_SIZE]; MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len); MHD_SHA256_finish_reset (&ctx, digest); #ifdef MHD_SHA256_HAS_EXT_ERROR if (0 != ctx.ext_error) { fprintf (stderr, "External hashing error: %d.\n", ctx.ext_error); exit (99); } #endif /* MHD_SHA256_HAS_EXT_ERROR */ num_failed += check_result (MHD_FUNC_, i, digest, data_units2[i].digest); } MHD_SHA256_deinit (&ctx); return num_failed; } /* Calculated SHA-256 as two iterations for whole data */ static int test2_str (void) { int num_failed = 0; unsigned int i; struct Sha256CtxWr ctx; MHD_SHA256_init_one_time (&ctx); for (i = 0; i < units1_num; i++) { uint8_t digest[SHA256_DIGEST_SIZE]; size_t part_s = data_units1[i].str_l.len / 4; MHD_SHA256_update (&ctx, (const uint8_t *) "", 0); MHD_SHA256_update (&ctx, (const uint8_t *) data_units1[i].str_l.str, part_s); MHD_SHA256_update (&ctx, (const uint8_t *) "", 0); MHD_SHA256_update (&ctx, (const uint8_t *) data_units1[i].str_l.str + part_s, data_units1[i].str_l.len - part_s); MHD_SHA256_update (&ctx, (const uint8_t *) "", 0); MHD_SHA256_finish_reset (&ctx, digest); #ifdef MHD_SHA256_HAS_EXT_ERROR if (0 != ctx.ext_error) { fprintf (stderr, "External hashing error: %d.\n", ctx.ext_error); exit (99); } #endif /* MHD_SHA256_HAS_EXT_ERROR */ num_failed += check_result (MHD_FUNC_, i, digest, data_units1[i].digest); } MHD_SHA256_deinit (&ctx); return num_failed; } static int test2_bin (void) { int num_failed = 0; unsigned int i; struct Sha256CtxWr ctx; MHD_SHA256_init_one_time (&ctx); for (i = 0; i < units2_num; i++) { uint8_t digest[SHA256_DIGEST_SIZE]; size_t part_s = data_units2[i].bin_l.len * 2 / 3; MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin, part_s); MHD_SHA256_update (&ctx, (const uint8_t *) "", 0); MHD_SHA256_update (&ctx, data_units2[i].bin_l.bin + part_s, data_units2[i].bin_l.len - part_s); MHD_SHA256_finish_reset (&ctx, digest); #ifdef MHD_SHA256_HAS_EXT_ERROR if (0 != ctx.ext_error) { fprintf (stderr, "External hashing error: %d.\n", ctx.ext_error); exit (99); } #endif /* MHD_SHA256_HAS_EXT_ERROR */ num_failed += check_result (MHD_FUNC_, i, digest, data_units2[i].digest); } MHD_SHA256_deinit (&ctx); return num_failed; } /* Use data set number 7 as it has the longest sequence */ #define DATA_POS 6 #define MAX_OFFSET 31 static int test_unaligned (void) { int num_failed = 0; unsigned int offset; uint8_t *buf; uint8_t *digest_buf; struct Sha256CtxWr ctx; const struct data_unit2 *const tdata = data_units2 + DATA_POS; MHD_SHA256_init_one_time (&ctx); buf = malloc (tdata->bin_l.len + MAX_OFFSET); digest_buf = malloc (SHA256_DIGEST_SIZE + MAX_OFFSET); if ((NULL == buf) || (NULL == digest_buf)) exit (99); for (offset = MAX_OFFSET; offset >= 1; --offset) { uint8_t *unaligned_digest; uint8_t *unaligned_buf; unaligned_buf = buf + offset; memcpy (unaligned_buf, tdata->bin_l.bin, tdata->bin_l.len); unaligned_digest = digest_buf + MAX_OFFSET - offset; memset (unaligned_digest, 0, SHA256_DIGEST_SIZE); MHD_SHA256_update (&ctx, unaligned_buf, tdata->bin_l.len); MHD_SHA256_finish_reset (&ctx, unaligned_digest); #ifdef MHD_SHA256_HAS_EXT_ERROR if (0 != ctx.ext_error) { fprintf (stderr, "External hashing error: %d.\n", ctx.ext_error); exit (99); } #endif /* MHD_SHA256_HAS_EXT_ERROR */ num_failed += check_result (MHD_FUNC_, MAX_OFFSET - offset, unaligned_digest, tdata->digest); } free (digest_buf); free (buf); MHD_SHA256_deinit (&ctx); return num_failed; } int main (int argc, char *argv[]) { int num_failed = 0; (void) has_in_name; /* Mute compiler warning. */ if (has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose")) verbose = 1; #ifdef NEED_GCRYP_INIT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* GCRYCTL_INITIALIZATION_FINISHED */ #endif /* NEED_GCRYP_INIT */ num_failed += test1_str (); num_failed += test1_bin (); num_failed += test2_str (); num_failed += test2_bin (); num_failed += test_unaligned (); return num_failed ? 1 : 0; } libmicrohttpd-1.0.1/src/microhttpd/test_http_reasons.c0000644000175000017500000001161114417460232016721 /* This file is part of libmicrohttpd Copyright (C) 2017-2021 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_http_reasons.c * @brief Unit tests for MHD_get_reason_phrase_for() function * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include "microhttpd.h" #include "mhd_str.h" static const char *const r_unknown = "unknown"; /* Return zero when no error is detected */ static int expect_result (unsigned int code, const char *expected) { const char *const reason = MHD_get_reason_phrase_for (code); const size_t len = MHD_get_reason_phrase_len_for (code); size_t exp_len; if (! MHD_str_equal_caseless_ (reason, expected)) { fprintf (stderr, "Incorrect reason returned for code %u:\n Returned: \"%s\" \tExpected: \"%s\"\n", code, reason, expected); return 1; } if (r_unknown == expected) exp_len = 0; else exp_len = strlen (expected); if (exp_len != len) { fprintf (stderr, "Incorrect reason length returned for code %u:\n Returned: \"%u\" \tExpected: \"%u\"\n", code, (unsigned) len, (unsigned) exp_len); return 1; } return 0; } static int expect_absent (unsigned int code) { return expect_result (code, r_unknown); } static int test_absent_codes (void) { int errcount = 0; errcount += expect_absent (0); errcount += expect_absent (1); errcount += expect_absent (50); errcount += expect_absent (99); errcount += expect_absent (600); errcount += expect_absent (601); errcount += expect_absent (900); errcount += expect_absent (10000); return errcount; } static int test_1xx (void) { int errcount = 0; errcount += expect_result (MHD_HTTP_CONTINUE, "continue"); errcount += expect_result (MHD_HTTP_PROCESSING, "processing"); errcount += expect_absent (110); errcount += expect_absent (190); return errcount; } static int test_2xx (void) { int errcount = 0; errcount += expect_result (MHD_HTTP_OK, "ok"); errcount += expect_result (MHD_HTTP_ALREADY_REPORTED, "already reported"); errcount += expect_absent (217); errcount += expect_result (MHD_HTTP_IM_USED, "im used"); errcount += expect_absent (230); errcount += expect_absent (295); return errcount; } static int test_3xx (void) { int errcount = 0; errcount += expect_result (MHD_HTTP_MULTIPLE_CHOICES, "multiple choices"); errcount += expect_result (MHD_HTTP_SEE_OTHER, "see other"); errcount += expect_result (MHD_HTTP_PERMANENT_REDIRECT, "permanent redirect"); errcount += expect_absent (311); errcount += expect_absent (399); return errcount; } static int test_4xx (void) { int errcount = 0; errcount += expect_result (MHD_HTTP_BAD_REQUEST, "bad request"); errcount += expect_result (MHD_HTTP_NOT_FOUND, "not found"); errcount += expect_result (MHD_HTTP_URI_TOO_LONG, "uri too long"); errcount += expect_result (MHD_HTTP_EXPECTATION_FAILED, "expectation failed"); errcount += expect_result (MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, "request header fields too large"); errcount += expect_absent (441); errcount += expect_result (MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, "unavailable for legal reasons"); errcount += expect_absent (470); errcount += expect_absent (493); return errcount; } static int test_5xx (void) { int errcount = 0; errcount += expect_result (MHD_HTTP_INTERNAL_SERVER_ERROR, "internal server error"); errcount += expect_result (MHD_HTTP_BAD_GATEWAY, "bad gateway"); errcount += expect_result (MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED, "http version not supported"); errcount += expect_result (MHD_HTTP_NETWORK_AUTHENTICATION_REQUIRED, "network authentication required"); errcount += expect_absent (520); errcount += expect_absent (597); return errcount; } int main (int argc, char *argv[]) { int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errcount += test_absent_codes (); errcount += test_1xx (); errcount += test_2xx (); errcount += test_3xx (); errcount += test_4xx (); errcount += test_5xx (); return errcount == 0 ? 0 : 1; } libmicrohttpd-1.0.1/src/microhttpd/test_str_quote.c0000644000175000017500000007504414441373361016252 /* This file is part of libmicrohttpd Copyright (C) 2022 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_str_quote.c * @brief Unit tests for quoted strings processing * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include "mhd_str.h" #include "mhd_assert.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #define TEST_STR_MAX_LEN 1024 /* return zero if succeed, non-zero otherwise */ static unsigned int expect_result_unquote_n (const char *const quoted, const size_t quoted_len, const char *const unquoted, const size_t unquoted_len, const unsigned int line_num) { static char buf[TEST_STR_MAX_LEN]; size_t res_len; unsigned int ret1; unsigned int ret2; unsigned int ret3; unsigned int ret4; mhd_assert (NULL != quoted); mhd_assert (NULL != unquoted); mhd_assert (TEST_STR_MAX_LEN > quoted_len); mhd_assert (quoted_len >= unquoted_len); /* First check: MHD_str_unquote () */ ret1 = 0; memset (buf, '#', sizeof(buf)); /* Fill buffer with character unused in the check */ res_len = MHD_str_unquote (quoted, quoted_len, buf); if (res_len != unquoted_len) { ret1 = 1; fprintf (stderr, "'MHD_str_unquote ()' FAILED: Wrong result size:\n"); } else if ((0 != unquoted_len) && (0 != memcmp (buf, unquoted, unquoted_len))) { ret1 = 1; fprintf (stderr, "'MHD_str_unquote ()' FAILED: Wrong result string:\n"); } if (0 != ret1) { /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_unquote('%.*s', %u, ->'%.*s') -> %u\n" "\tEXPECTED: MHD_str_unquote('%.*s', %u, ->'%.*s') -> %u\n", (int) quoted_len, quoted, (unsigned) quoted_len, (int) res_len, buf, (unsigned) res_len, (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); } /* Second check: MHD_str_equal_quoted_bin_n () */ ret2 = 0; if (! MHD_str_equal_quoted_bin_n (quoted, quoted_len, unquoted, unquoted_len)) { fprintf (stderr, "'MHD_str_equal_quoted_bin_n ()' FAILED: Wrong result:\n"); /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_equal_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> true\n" "\tEXPECTED: MHD_str_equal_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> false\n", (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); ret2 = 1; } /* Third check: MHD_str_equal_caseless_quoted_bin_n () */ ret3 = 0; if (! MHD_str_equal_caseless_quoted_bin_n (quoted, quoted_len, unquoted, unquoted_len)) { fprintf (stderr, "'MHD_str_equal_caseless_quoted_bin_n ()' FAILED: Wrong result:\n"); /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_equal_caseless_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> true\n" "\tEXPECTED: MHD_str_equal_caseless_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> false\n", (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); ret3 = 1; } /* Fourth check: MHD_str_unquote () */ ret4 = 0; memset (buf, '#', sizeof(buf)); /* Fill buffer with character unused in the check */ res_len = MHD_str_quote (unquoted, unquoted_len, buf, quoted_len); if (res_len != quoted_len) { ret4 = 1; fprintf (stderr, "'MHD_str_quote ()' FAILED: Wrong result size:\n"); } else if ((0 != quoted_len) && (0 != memcmp (buf, quoted, quoted_len))) { ret4 = 1; fprintf (stderr, "'MHD_str_quote ()' FAILED: Wrong result string:\n"); } if (0 != ret4) { /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_quote('%.*s', %u, ->'%.*s', %u) -> %u\n" "\tEXPECTED: MHD_str_quote('%.*s', %u, ->'%.*s', %u) -> %u\n", (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) res_len, buf, (unsigned) quoted_len, (unsigned) res_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) quoted_len, quoted, (unsigned) quoted_len, (unsigned) unquoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); } return ret1 + ret2 + ret3 + ret4; } #define expect_result_unquote(q,u) \ expect_result_unquote_n(q,MHD_STATICSTR_LEN_(q),\ u,MHD_STATICSTR_LEN_(u),__LINE__) static unsigned int check_match (void) { unsigned int r = 0; /**< The number of errors */ r += expect_result_unquote ("", ""); r += expect_result_unquote ("a", "a"); r += expect_result_unquote ("abc", "abc"); r += expect_result_unquote ("abcdef", "abcdef"); r += expect_result_unquote ("a\0" "bc", "a\0" "bc"); r += expect_result_unquote ("abc\\\"", "abc\""); r += expect_result_unquote ("\\\"", "\""); r += expect_result_unquote ("\\\"abc", "\"abc"); r += expect_result_unquote ("abc\\\\", "abc\\"); r += expect_result_unquote ("\\\\", "\\"); r += expect_result_unquote ("\\\\abc", "\\abc"); r += expect_result_unquote ("123\\\\\\\\\\\\\\\\", "123\\\\\\\\"); r += expect_result_unquote ("\\\\\\\\\\\\\\\\", "\\\\\\\\"); r += expect_result_unquote ("\\\\\\\\\\\\\\\\123", "\\\\\\\\123"); r += expect_result_unquote ("\\\\\\\"\\\\\\\"\\\\\\\"\\\\\\\"\\\\\\\"" \ "\\\\\\\"\\\\\\\"\\\\\\\"\\\\\\\"\\\\\\\"", \ "\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\""); return r; } /* return zero if succeed, non-zero otherwise */ static unsigned int expect_result_quote_failed_n (const char *const unquoted, const size_t unquoted_len, const size_t buf_size, const unsigned int line_num) { static char buf[TEST_STR_MAX_LEN]; size_t res_len; unsigned int ret4; mhd_assert (TEST_STR_MAX_LEN > buf_size); /* The check: MHD_str_unquote () */ ret4 = 0; memset (buf, '#', sizeof(buf)); /* Fill buffer with character unused in the check */ res_len = MHD_str_quote (unquoted, unquoted_len, buf, buf_size); if (0 != res_len) { ret4 = 1; fprintf (stderr, "'MHD_str_quote ()' FAILED: Wrong result size:\n"); } if (0 != ret4) { /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_quote('%.*s', %u, ->'%.*s', %u) -> %u\n" "\tEXPECTED: MHD_str_quote('%.*s', %u, (not checked), %u) -> 0\n", (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) res_len, buf, (unsigned) buf_size, (unsigned) res_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len, (unsigned) buf_size); fprintf (stderr, "The check is at line: %u\n\n", line_num); } return ret4; } #define expect_result_quote_failed(q,s) \ expect_result_quote_failed_n(q,MHD_STATICSTR_LEN_(q),\ s,__LINE__) static unsigned int check_quote_failed (void) { unsigned int r = 0; /**< The number of errors */ r += expect_result_quote_failed ("a", 0); r += expect_result_quote_failed ("aa", 1); r += expect_result_quote_failed ("abc\\", 4); r += expect_result_quote_failed ("abc\"", 4); r += expect_result_quote_failed ("abc\"\"\"\"", 6); r += expect_result_quote_failed ("abc\"\"\"\"", 7); r += expect_result_quote_failed ("abc\"\"\"\"", 8); r += expect_result_quote_failed ("abc\"\"\"\"", 9); r += expect_result_quote_failed ("abc\"\"\"\"", 10); r += expect_result_quote_failed ("abc\\\\\\\\", 9); r += expect_result_quote_failed ("abc\\\\\\\\", 10); r += expect_result_quote_failed ("abc\"\"\"\"", 9); r += expect_result_quote_failed ("abc\"\"\"\"", 10); r += expect_result_quote_failed ("abc\"\\\"\\", 9); r += expect_result_quote_failed ("abc\\\"\\\"", 10); r += expect_result_quote_failed ("\"\"\"\"abc", 6); r += expect_result_quote_failed ("\"\"\"\"abc", 7); r += expect_result_quote_failed ("\"\"\"\"abc", 8); r += expect_result_quote_failed ("\"\"\"\"abc", 9); r += expect_result_quote_failed ("\"\"\"\"abc", 10); r += expect_result_quote_failed ("\\\\\\\\abc", 9); r += expect_result_quote_failed ("\\\\\\\\abc", 10); r += expect_result_quote_failed ("\"\"\"\"abc", 9); r += expect_result_quote_failed ("\"\"\"\"abc", 10); r += expect_result_quote_failed ("\"\\\"\\abc", 9); r += expect_result_quote_failed ("\\\"\\\"abc", 10); return r; } /* return zero if succeed, one otherwise */ static unsigned int expect_match_caseless_n (const char *const quoted, const size_t quoted_len, const char *const unquoted, const size_t unquoted_len, const unsigned int line_num) { unsigned int ret3; mhd_assert (NULL != quoted); mhd_assert (NULL != unquoted); mhd_assert (TEST_STR_MAX_LEN > quoted_len); /* The check: MHD_str_equal_caseless_quoted_bin_n () */ ret3 = 0; if (! MHD_str_equal_caseless_quoted_bin_n (quoted, quoted_len, unquoted, unquoted_len)) { fprintf (stderr, "'MHD_str_equal_caseless_quoted_bin_n ()' FAILED: Wrong result:\n"); /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_equal_caseless_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> true\n" "\tEXPECTED: MHD_str_equal_caseless_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> false\n", (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); ret3 = 1; } return ret3; } #define expect_match_caseless(q,u) \ expect_match_caseless_n(q,MHD_STATICSTR_LEN_(q),\ u,MHD_STATICSTR_LEN_(u),__LINE__) static unsigned int check_match_caseless (void) { unsigned int r = 0; /**< The number of errors */ r += expect_match_caseless ("a", "A"); r += expect_match_caseless ("abC", "aBc"); r += expect_match_caseless ("AbCdeF", "aBCdEF"); r += expect_match_caseless ("a\0" "Bc", "a\0" "bC"); r += expect_match_caseless ("Abc\\\"", "abC\""); r += expect_match_caseless ("\\\"", "\""); r += expect_match_caseless ("\\\"aBc", "\"abc"); r += expect_match_caseless ("abc\\\\", "ABC\\"); r += expect_match_caseless ("\\\\", "\\"); r += expect_match_caseless ("\\\\ABC", "\\abc"); r += expect_match_caseless ("\\\\ZYX", "\\ZYX"); r += expect_match_caseless ("abc", "ABC"); r += expect_match_caseless ("ABCabc", "abcABC"); r += expect_match_caseless ("abcXYZ", "ABCxyz"); r += expect_match_caseless ("AbCdEfABCabc", "ABcdEFabcABC"); r += expect_match_caseless ("a\\\\bc", "A\\BC"); r += expect_match_caseless ("ABCa\\\\bc", "abcA\\BC"); r += expect_match_caseless ("abcXYZ\\\\", "ABCxyz\\"); r += expect_match_caseless ("\\\\AbCdEfABCabc", "\\ABcdEFabcABC"); return r; } /* return zero if succeed, one otherwise */ static unsigned int expect_result_invalid_n (const char *const quoted, const size_t quoted_len, const unsigned int line_num) { static char buf[TEST_STR_MAX_LEN]; size_t res_len; unsigned int ret1; mhd_assert (NULL != quoted); mhd_assert (TEST_STR_MAX_LEN > quoted_len); /* The check: MHD_str_unquote () */ ret1 = 0; memset (buf, '#', sizeof(buf)); /* Fill buffer with character unused in the check */ res_len = MHD_str_unquote (quoted, quoted_len, buf); if (res_len != 0) { ret1 = 1; fprintf (stderr, "'MHD_str_unquote ()' FAILED: Wrong result size:\n"); } if (0 != ret1) { /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_unquote('%.*s', %u, (not checked)) -> %u\n" "\tEXPECTED: MHD_str_unquote('%.*s', %u, (not checked)) -> 0\n", (int) quoted_len, quoted, (unsigned) quoted_len, (unsigned) res_len, (int) quoted_len, quoted, (unsigned) quoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); } return ret1; } #define expect_result_invalid(q) \ expect_result_invalid_n(q,MHD_STATICSTR_LEN_(q),__LINE__) static unsigned int check_invalid (void) { unsigned int r = 0; /**< The number of errors */ r += expect_result_invalid ("\\"); r += expect_result_invalid ("\\\\\\"); r += expect_result_invalid ("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"); r += expect_result_invalid ("xyz\\"); r += expect_result_invalid ("\\\"\\"); r += expect_result_invalid ("\\\"\\\"\\\"\\"); return r; } /* return zero if succeed, non-zero otherwise */ static unsigned int expect_result_unmatch_n (const char *const quoted, const size_t quoted_len, const char *const unquoted, const size_t unquoted_len, const unsigned int line_num) { unsigned int ret2; unsigned int ret3; mhd_assert (NULL != quoted); mhd_assert (NULL != unquoted); /* The check: MHD_str_equal_quoted_bin_n () */ ret2 = 0; if (MHD_str_equal_quoted_bin_n (quoted, quoted_len, unquoted, unquoted_len)) { fprintf (stderr, "'MHD_str_equal_quoted_bin_n ()' FAILED: Wrong result:\n"); /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_equal_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> true\n" "\tEXPECTED: MHD_str_equal_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> false\n", (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); ret2 = 1; } /* The check: MHD_str_equal_quoted_bin_n () */ ret3 = 0; if (MHD_str_equal_caseless_quoted_bin_n (quoted, quoted_len, unquoted, unquoted_len)) { fprintf (stderr, "'MHD_str_equal_caseless_quoted_bin_n ()' FAILED: Wrong result:\n"); /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_equal_caseless_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> true\n" "\tEXPECTED: MHD_str_equal_caseless_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> false\n", (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); ret3 = 1; } return ret2 + ret3; } #define expect_result_unmatch(q,u) \ expect_result_unmatch_n(q,MHD_STATICSTR_LEN_(q),\ u,MHD_STATICSTR_LEN_(u),__LINE__) static unsigned int check_unmatch (void) { unsigned int r = 0; /**< The number of errors */ /* Matched sequence except invalid backslash at the end */ r += expect_result_unmatch ("\\", ""); r += expect_result_unmatch ("a\\", "a"); r += expect_result_unmatch ("abc\\", "abc"); r += expect_result_unmatch ("a\0" "bc\\", "a\0" "bc"); r += expect_result_unmatch ("abc\\\"\\", "abc\""); r += expect_result_unmatch ("\\\"\\", "\""); r += expect_result_unmatch ("\\\"abc\\", "\"abc"); r += expect_result_unmatch ("abc\\\\\\", "abc\\"); r += expect_result_unmatch ("\\\\\\", "\\"); r += expect_result_unmatch ("\\\\abc\\", "\\abc"); r += expect_result_unmatch ("123\\\\\\\\\\\\\\\\\\", "123\\\\\\\\"); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\\\", "\\\\\\\\"); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\123\\", "\\\\\\\\123"); /* Invalid backslash at the end and empty string */ r += expect_result_unmatch ("\\", ""); r += expect_result_unmatch ("a\\", ""); r += expect_result_unmatch ("abc\\", ""); r += expect_result_unmatch ("a\0" "bc\\", ""); r += expect_result_unmatch ("abc\\\"\\", ""); r += expect_result_unmatch ("\\\"\\", ""); r += expect_result_unmatch ("\\\"abc\\", ""); r += expect_result_unmatch ("abc\\\\\\", ""); r += expect_result_unmatch ("\\\\\\", ""); r += expect_result_unmatch ("\\\\abc\\", ""); r += expect_result_unmatch ("123\\\\\\\\\\\\\\\\\\", ""); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\\\", ""); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\123\\", ""); /* Difference at binary zero */ r += expect_result_unmatch ("\0", ""); r += expect_result_unmatch ("", "\0"); r += expect_result_unmatch ("a\0", "a"); r += expect_result_unmatch ("a", "a\0"); r += expect_result_unmatch ("abc\0", "abc"); r += expect_result_unmatch ("abc", "abc\0"); r += expect_result_unmatch ("a\0" "bc\0", "a\0" "bc"); r += expect_result_unmatch ("a\0" "bc", "a\0" "bc\0"); r += expect_result_unmatch ("abc\\\"\0", "abc\""); r += expect_result_unmatch ("abc\\\"", "abc\"\0"); r += expect_result_unmatch ("\\\"\0", "\""); r += expect_result_unmatch ("\\\"", "\"\0"); r += expect_result_unmatch ("\\\"abc\0", "\"abc"); r += expect_result_unmatch ("\\\"abc", "\"abc\0"); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\\0", "\\\\\\\\"); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\", "\\\\\\\\\0"); r += expect_result_unmatch ("\\\\\\\\\\\\\0" "\\\\", "\\\\\\\\"); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\", "\\\\\\\0" "\\"); r += expect_result_unmatch ("\0" "abc", "abc"); r += expect_result_unmatch ("abc", "\0" "abc"); r += expect_result_unmatch ("\0" "abc", "0abc"); r += expect_result_unmatch ("0abc", "\0" "abc"); r += expect_result_unmatch ("xyz", "xy" "\0" "z"); r += expect_result_unmatch ("xy" "\0" "z", "xyz"); /* Difference after binary zero */ r += expect_result_unmatch ("abc\0" "1", "abc\0" "2"); r += expect_result_unmatch ("a\0" "bcx", "a\0" "bcy"); r += expect_result_unmatch ("\0" "abc\\\"2", "\0" "abc\"1"); r += expect_result_unmatch ("\0" "abc1\\\"", "\0" "abc2\""); r += expect_result_unmatch ("\0" "\\\"c", "\0" "\"d"); r += expect_result_unmatch ("\\\"ab" "\0" "1c", "\"ab" "\0" "2c"); r += expect_result_unmatch ("a\0" "bcdef2", "a\0" "bcdef1"); r += expect_result_unmatch ("a\0" "bc2def", "a\0" "bc1def"); r += expect_result_unmatch ("a\0" "1bcdef", "a\0" "2bcdef"); r += expect_result_unmatch ("abcde\0" "f2", "abcde\0" "f1"); r += expect_result_unmatch ("123\\\\\\\\\\\\\0" "\\\\1", "123\\\\\\\0" "\\2"); r += expect_result_unmatch ("\\\\\\\\\\\\\0" "1\\\\", "\\\\\\" "2\\"); /* One side is empty */ r += expect_result_unmatch ("abc", ""); r += expect_result_unmatch ("", "abc"); r += expect_result_unmatch ("1234567890", ""); r += expect_result_unmatch ("", "1234567890"); r += expect_result_unmatch ("abc\\\"", ""); r += expect_result_unmatch ("", "abc\""); r += expect_result_unmatch ("\\\"", ""); r += expect_result_unmatch ("", "\""); r += expect_result_unmatch ("\\\"abc", ""); r += expect_result_unmatch ("", "\"abc"); r += expect_result_unmatch ("abc\\\\", ""); r += expect_result_unmatch ("", "abc\\"); r += expect_result_unmatch ("\\\\", ""); r += expect_result_unmatch ("", "\\"); r += expect_result_unmatch ("\\\\abc", ""); r += expect_result_unmatch ("", "\\abc"); r += expect_result_unmatch ("123\\\\\\\\\\\\\\\\", ""); r += expect_result_unmatch ("", "123\\\\\\\\"); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\", ""); r += expect_result_unmatch ("", "\\\\\\\\"); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\123", ""); r += expect_result_unmatch ("", "\\\\\\\\123"); /* Various unmatched strings */ r += expect_result_unmatch ("a", "x"); r += expect_result_unmatch ("abc", "abcabc"); r += expect_result_unmatch ("abc", "abcabcabc"); r += expect_result_unmatch ("abc", "abcabcabcabc"); r += expect_result_unmatch ("ABCABC", "ABC"); r += expect_result_unmatch ("ABCABCABC", "ABC"); r += expect_result_unmatch ("ABCABCABCABC", "ABC"); r += expect_result_unmatch ("123\\\\\\\\\\\\\\\\\\\\", "123\\\\\\\\"); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\\\\\", "\\\\\\\\"); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\123\\\\", "\\\\\\\\123"); r += expect_result_unmatch ("\\\\\\\\\\\\\\\\", "\\\\\\\\\\"); return r; } /* return zero if succeed, one otherwise */ static unsigned int expect_result_case_unmatch_n (const char *const quoted, const size_t quoted_len, const char *const unquoted, const size_t unquoted_len, const unsigned int line_num) { unsigned int ret2; mhd_assert (NULL != quoted); mhd_assert (NULL != unquoted); /* THe check: MHD_str_equal_quoted_bin_n () */ ret2 = 0; if (MHD_str_equal_quoted_bin_n (quoted, quoted_len, unquoted, unquoted_len)) { fprintf (stderr, "'MHD_str_equal_quoted_bin_n ()' FAILED: Wrong result:\n"); /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_equal_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> true\n" "\tEXPECTED: MHD_str_equal_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> false\n", (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); ret2 = 1; } return ret2; } #define expect_result_case_unmatch(q,u) \ expect_result_case_unmatch_n(q,MHD_STATICSTR_LEN_(q),\ u,MHD_STATICSTR_LEN_(u),__LINE__) static unsigned int check_unmatch_case (void) { unsigned int r = 0; /**< The number of errors */ r += expect_result_case_unmatch ("a", "A"); r += expect_result_case_unmatch ("abC", "aBc"); r += expect_result_case_unmatch ("AbCdeF", "aBCdEF"); r += expect_result_case_unmatch ("a\0" "Bc", "a\0" "bC"); r += expect_result_case_unmatch ("Abc\\\"", "abC\""); r += expect_result_case_unmatch ("\\\"aBc", "\"abc"); r += expect_result_case_unmatch ("abc\\\\", "ABC\\"); r += expect_result_case_unmatch ("\\\\ABC", "\\abc"); r += expect_result_case_unmatch ("\\\\ZYX", "\\ZYx"); r += expect_result_case_unmatch ("abc", "ABC"); r += expect_result_case_unmatch ("ABCabc", "abcABC"); r += expect_result_case_unmatch ("abcXYZ", "ABCxyz"); r += expect_result_case_unmatch ("AbCdEfABCabc", "ABcdEFabcABC"); r += expect_result_case_unmatch ("a\\\\bc", "A\\BC"); r += expect_result_case_unmatch ("ABCa\\\\bc", "abcA\\BC"); r += expect_result_case_unmatch ("abcXYZ\\\\", "ABCxyz\\"); r += expect_result_case_unmatch ("\\\\AbCdEfABCabc", "\\ABcdEFabcABC"); return r; } /* return zero if succeed, one otherwise */ static unsigned int expect_result_caseless_unmatch_n (const char *const quoted, const size_t quoted_len, const char *const unquoted, const size_t unquoted_len, const unsigned int line_num) { unsigned int ret2; unsigned int ret3; mhd_assert (NULL != quoted); mhd_assert (NULL != unquoted); /* The check: MHD_str_equal_quoted_bin_n () */ ret2 = 0; if (MHD_str_equal_quoted_bin_n (quoted, quoted_len, unquoted, unquoted_len)) { fprintf (stderr, "'MHD_str_equal_quoted_bin_n ()' FAILED: Wrong result:\n"); /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_equal_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> true\n" "\tEXPECTED: MHD_str_equal_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> false\n", (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); ret2 = 1; } /* The check: MHD_str_equal_quoted_bin_n () */ ret3 = 0; if (MHD_str_equal_caseless_quoted_bin_n (quoted, quoted_len, unquoted, unquoted_len)) { fprintf (stderr, "'MHD_str_equal_caseless_quoted_bin_n ()' FAILED: Wrong result:\n"); /* This does NOT print part of the string after binary zero */ fprintf (stderr, "\tRESULT : MHD_str_equal_caseless_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> true\n" "\tEXPECTED: MHD_str_equal_caseless_quoted_bin_n('%.*s', %u, " "'%.*s', %u) -> false\n", (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len, (int) quoted_len, quoted, (unsigned) quoted_len, (int) unquoted_len, unquoted, (unsigned) unquoted_len); fprintf (stderr, "The check is at line: %u\n\n", line_num); ret3 = 1; } return ret2 + ret3; } #define expect_result_caseless_unmatch(q,u) \ expect_result_caseless_unmatch_n(q,MHD_STATICSTR_LEN_(q),\ u,MHD_STATICSTR_LEN_(u),__LINE__) static unsigned int check_unmatch_caseless (void) { unsigned int r = 0; /**< The number of errors */ /* Matched sequence except invalid backslash at the end */ r += expect_result_caseless_unmatch ("a\\", "A"); r += expect_result_caseless_unmatch ("abC\\", "abc"); r += expect_result_caseless_unmatch ("a\0" "Bc\\", "a\0" "bc"); r += expect_result_caseless_unmatch ("abc\\\"\\", "ABC\""); r += expect_result_caseless_unmatch ("\\\"\\", "\""); r += expect_result_caseless_unmatch ("\\\"ABC\\", "\"abc"); r += expect_result_caseless_unmatch ("Abc\\\\\\", "abC\\"); r += expect_result_caseless_unmatch ("\\\\\\", "\\"); r += expect_result_caseless_unmatch ("\\\\aBc\\", "\\abC"); /* Difference at binary zero */ r += expect_result_caseless_unmatch ("a\0", "A"); r += expect_result_caseless_unmatch ("A", "a\0"); r += expect_result_caseless_unmatch ("abC\0", "abc"); r += expect_result_caseless_unmatch ("abc", "ABc\0"); r += expect_result_caseless_unmatch ("a\0" "bC\0", "a\0" "bc"); r += expect_result_caseless_unmatch ("a\0" "bc", "A\0" "bc\0"); r += expect_result_caseless_unmatch ("ABC\\\"\0", "abc\""); r += expect_result_caseless_unmatch ("abc\\\"", "ABC\"\0"); r += expect_result_caseless_unmatch ("\\\"aBc\0", "\"abc"); r += expect_result_caseless_unmatch ("\\\"Abc", "\"abc\0"); r += expect_result_caseless_unmatch ("\\\\\\\\\\\\\\\\\0", "\\\\\\\\"); r += expect_result_caseless_unmatch ("\\\\\\\\\\\\\\\\", "\\\\\\\\\0"); r += expect_result_caseless_unmatch ("\\\\\\\\\\\\\0" "\\\\", "\\\\\\\\"); r += expect_result_caseless_unmatch ("\\\\\\\\\\\\\\\\", "\\\\\\\0" "\\"); r += expect_result_caseless_unmatch ("\0" "aBc", "abc"); r += expect_result_caseless_unmatch ("abc", "\0" "abC"); r += expect_result_caseless_unmatch ("\0" "abc", "0abc"); r += expect_result_caseless_unmatch ("0abc", "\0" "aBc"); r += expect_result_caseless_unmatch ("xyZ", "xy" "\0" "z"); r += expect_result_caseless_unmatch ("Xy" "\0" "z", "xyz"); /* Difference after binary zero */ r += expect_result_caseless_unmatch ("abc\0" "1", "aBC\0" "2"); r += expect_result_caseless_unmatch ("a\0" "bcX", "a\0" "bcy"); r += expect_result_caseless_unmatch ("\0" "abc\\\"2", "\0" "Abc\"1"); r += expect_result_caseless_unmatch ("\0" "Abc1\\\"", "\0" "abc2\""); r += expect_result_caseless_unmatch ("\0" "\\\"c", "\0" "\"d"); r += expect_result_caseless_unmatch ("\\\"ab" "\0" "1C", "\"ab" "\0" "2C"); r += expect_result_caseless_unmatch ("a\0" "BCDef2", "a\0" "bcdef1"); r += expect_result_caseless_unmatch ("a\0" "bc2def", "a\0" "BC1def"); r += expect_result_caseless_unmatch ("a\0" "1bcdeF", "a\0" "2bcdef"); r += expect_result_caseless_unmatch ("abcde\0" "f2", "ABCDE\0" "f1"); r += expect_result_caseless_unmatch ("\\\"ab" "\0" "XC", "\"ab" "\0" "yC"); r += expect_result_caseless_unmatch ("a\0" "BCDefY", "a\0" "bcdefx"); r += expect_result_caseless_unmatch ("a\0" "bczdef", "a\0" "BCXdef"); r += expect_result_caseless_unmatch ("a\0" "YbcdeF", "a\0" "zbcdef"); r += expect_result_caseless_unmatch ("abcde\0" "fy", "ABCDE\0" "fX"); return r; } int main (int argc, char *argv[]) { unsigned int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errcount += check_match (); errcount += check_quote_failed (); errcount += check_match_caseless (); errcount += check_invalid (); errcount += check_unmatch (); errcount += check_unmatch_case (); errcount += check_unmatch_caseless (); if (0 == errcount) printf ("All tests were passed without errors.\n"); return errcount == 0 ? 0 : 1; } libmicrohttpd-1.0.1/src/microhttpd/mhd_itc_types.h0000644000175000017500000000455214556705750016032 /* This file is part of libmicrohttpd Copyright (C) 2016-2020 Karlson2k (Evgeny Grin), Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_itc_types.h * @brief Types for platform-independent inter-thread communication * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff * * Provides basic types for inter-thread communication. * Designed to be included by other headers. */ #ifndef MHD_ITC_TYPES_H #define MHD_ITC_TYPES_H 1 #include "mhd_options.h" /* Force socketpair on native W32 */ #if defined(_WIN32) && ! defined(__CYGWIN__) && ! defined(_MHD_ITC_SOCKETPAIR) #error _MHD_ITC_SOCKETPAIR is not defined on naitive W32 platform #endif /* _WIN32 && !__CYGWIN__ && !_MHD_ITC_SOCKETPAIR */ #if defined(_MHD_ITC_EVENTFD) /* **************** Optimized GNU/Linux ITC implementation by eventfd ********** */ /** * Data type for a MHD ITC. */ struct MHD_itc_ { int fd; }; /** * Static initialiser for struct MHD_itc_ */ #define MHD_ITC_STATIC_INIT_INVALID { -1 } #elif defined(_MHD_ITC_PIPE) /* **************** Standard UNIX ITC implementation by pipe ********** */ /** * Data type for a MHD ITC. */ struct MHD_itc_ { int fd[2]; }; /** * Static initialiser for struct MHD_itc_ */ #define MHD_ITC_STATIC_INIT_INVALID { { -1, -1 } } #elif defined(_MHD_ITC_SOCKETPAIR) /* **************** ITC implementation by socket pair ********** */ #include "mhd_sockets.h" /** * Data type for a MHD ITC. */ struct MHD_itc_ { MHD_socket sk[2]; }; /** * Static initialiser for struct MHD_itc_ */ #define MHD_ITC_STATIC_INIT_INVALID \ { { MHD_INVALID_SOCKET, MHD_INVALID_SOCKET } } #endif /* _MHD_ITC_SOCKETPAIR */ #endif /* ! MHD_ITC_TYPES_H */ libmicrohttpd-1.0.1/src/microhttpd/tsearch.c0000644000175000017500000000671114417460232014607 /* * Tree search generalized from Knuth (6.2.2) Algorithm T just like * the AT&T man page says. * * The node_t structure is for internal use only, lint doesn't grok it. * * Written by reading the System V Interface Definition, not the code. * * Totally public domain. */ #include "mhd_options.h" #include "tsearch.h" #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ typedef struct node { const void *key; struct node *llink, *rlink; } node_t; /* $NetBSD: tsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */ /* find or insert datum into search tree */ void * tsearch (const void *vkey, void **vrootp, int (*compar)(const void *, const void *)) { node_t *q; node_t **rootp = (node_t **) vrootp; if (rootp == NULL) return NULL; while (*rootp != NULL) /* Knuth's T1: */ { int r; if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */ return *rootp; /* we found it! */ rootp = (r < 0) ? &(*rootp)->llink : /* T3: follow left branch */ &(*rootp)->rlink; /* T4: follow right branch */ } q = malloc (sizeof(node_t)); /* T5: key not found */ if (q != NULL) /* make new node */ { *rootp = q; /* link new node to old */ q->key = vkey; /* initialize new node */ q->llink = q->rlink = NULL; } return q; } /* $NetBSD: tfind.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */ /* find a node by key "vkey" in tree "vrootp", or return 0 */ void * tfind (const void *vkey, void * const *vrootp, int (*compar)(const void *, const void *)) { node_t * const *rootp = (node_t * const *) vrootp; if (rootp == NULL) return NULL; while (*rootp != NULL) /* T1: */ { int r; if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */ return *rootp; /* key found */ rootp = (r < 0) ? &(*rootp)->llink : /* T3: follow left branch */ &(*rootp)->rlink; /* T4: follow right branch */ } return NULL; } /* $NetBSD: tdelete.c,v 1.8 2016/01/20 20:47:41 christos Exp $ */ /* find a node with key "vkey" in tree "vrootp" */ void * tdelete (const void *vkey, void **vrootp, int (*compar)(const void *, const void *)) { node_t **rootp = (node_t **) vrootp; node_t *p, *q, *r; int cmp; if ((rootp == NULL) || ((p = *rootp) == NULL) ) return NULL; while ((cmp = (*compar)(vkey, (*rootp)->key)) != 0) { p = *rootp; rootp = (cmp < 0) ? &(*rootp)->llink : /* follow llink branch */ &(*rootp)->rlink; /* follow rlink branch */ if (*rootp == NULL) return NULL; /* key not found */ } r = (*rootp)->rlink; /* D1: */ if ((q = (*rootp)->llink) == NULL) /* Left NULL? */ q = r; else if (r != NULL) /* Right link is NULL? */ { if (r->llink == NULL) /* D2: Find successor */ { r->llink = q; q = r; } else /* D3: Find NULL link */ { for (q = r->llink; q->llink != NULL; q = r->llink) r = q; r->llink = q->rlink; q->llink = (*rootp)->llink; q->rlink = (*rootp)->rlink; } } free (*rootp); /* D4: Free node */ *rootp = q; /* link parent to new node */ return p; } /* end of tsearch.c */ libmicrohttpd-1.0.1/src/microhttpd/sha256.c0000644000175000017500000006026314556705750014203 /* This file is part of libmicrohttpd Copyright (C) 2019-2023 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/sha256.c * @brief Calculation of SHA-256 digest as defined in FIPS PUB 180-4 (2015) * @author Karlson2k (Evgeny Grin) */ #include "sha256.h" #include #ifdef HAVE_MEMORY_H #include #endif /* HAVE_MEMORY_H */ #include "mhd_bithelpers.h" #include "mhd_assert.h" /** * Initialise structure for SHA256 calculation. * * @param ctx must be a `struct Sha256Ctx *` */ void MHD_SHA256_init (struct Sha256Ctx *ctx) { /* Initial hash values, see FIPS PUB 180-4 paragraph 5.3.3 */ /* First thirty-two bits of the fractional parts of the square * roots of the first eight prime numbers: 2, 3, 5, 7, 11, 13, * 17, 19." */ ctx->H[0] = UINT32_C (0x6a09e667); ctx->H[1] = UINT32_C (0xbb67ae85); ctx->H[2] = UINT32_C (0x3c6ef372); ctx->H[3] = UINT32_C (0xa54ff53a); ctx->H[4] = UINT32_C (0x510e527f); ctx->H[5] = UINT32_C (0x9b05688c); ctx->H[6] = UINT32_C (0x1f83d9ab); ctx->H[7] = UINT32_C (0x5be0cd19); /* Initialise number of bytes. */ ctx->count = 0; } MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ /** * Base of SHA-256 transformation. * Gets full 64 bytes block of data and updates hash values; * @param H hash values * @param data data, must be exactly 64 bytes long */ static void sha256_transform (uint32_t H[SHA256_DIGEST_SIZE_WORDS], const void *data) { /* Working variables, see FIPS PUB 180-4 paragraph 6.2. */ uint32_t a = H[0]; uint32_t b = H[1]; uint32_t c = H[2]; uint32_t d = H[3]; uint32_t e = H[4]; uint32_t f = H[5]; uint32_t g = H[6]; uint32_t h = H[7]; /* Data buffer, used as cyclic buffer. See FIPS PUB 180-4 paragraphs 5.2.1, 6.2. */ uint32_t W[16]; #ifndef _MHD_GET_32BIT_BE_UNALIGNED if (0 != (((uintptr_t) data) % _MHD_UINT32_ALIGN)) { /* Copy the unaligned input data to the aligned buffer */ memcpy (W, data, SHA256_BLOCK_SIZE); /* The W[] buffer itself will be used as the source of the data, * but data will be reloaded in correct bytes order during * the next steps */ data = (const void *) W; } #endif /* _MHD_GET_32BIT_BE_UNALIGNED */ /* 'Ch' and 'Maj' macro functions are defined with widely-used optimization. See FIPS PUB 180-4 formulae 4.2, 4.3. */ #define Ch(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) ) #define Maj(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) /* Unoptimized (original) versions: */ /* #define Ch(x,y,z) ( ( (x) & (y) ) ^ ( ~(x) & (z) ) ) */ /* #define Maj(x,y,z) ( ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) ) */ /* Four 'Sigma' macro functions. See FIPS PUB 180-4 formulae 4.4, 4.5, 4.6, 4.7. */ #define SIG0(x) (_MHD_ROTR32 ((x), 2) ^ _MHD_ROTR32 ((x), 13) ^ \ _MHD_ROTR32 ((x), 22) ) #define SIG1(x) (_MHD_ROTR32 ((x), 6) ^ _MHD_ROTR32 ((x), 11) ^ \ _MHD_ROTR32 ((x), 25) ) #define sig0(x) (_MHD_ROTR32 ((x), 7) ^ _MHD_ROTR32 ((x), 18) ^ \ ((x) >> 3) ) #define sig1(x) (_MHD_ROTR32 ((x), 17) ^ _MHD_ROTR32 ((x),19) ^ \ ((x) >> 10) ) /* One step of SHA-256 computation, see FIPS PUB 180-4 paragraph 6.2.2 step 3. * Note: this macro updates working variables in-place, without rotation. * Note: first (vH += SIG1(vE) + Ch(vE,vF,vG) + kt + wt) equals T1 in FIPS PUB 180-4 paragraph 6.2.2 step 3. second (vH += SIG0(vA) + Maj(vE,vF,vC) equals T1 + T2 in FIPS PUB 180-4 paragraph 6.2.2 step 3. * Note: 'wt' must be used exactly one time in this macro as it change other data as well every time when used. */ #define SHA2STEP32(vA,vB,vC,vD,vE,vF,vG,vH,kt,wt) do { \ (vD) += ((vH) += SIG1 ((vE)) + Ch ((vE),(vF),(vG)) + (kt) + (wt)); \ (vH) += SIG0 ((vA)) + Maj ((vA),(vB),(vC)); } while (0) /* Get value of W(t) from input data buffer, See FIPS PUB 180-4 paragraph 6.2. Input data must be read in big-endian bytes order, see FIPS PUB 180-4 paragraph 3.1.2. */ /* Use cast to (const void*) to mute compiler alignment warning, * data was already aligned in previous step */ #define GET_W_FROM_DATA(buf,t) \ _MHD_GET_32BIT_BE ((const void*)(((const uint8_t*) (buf)) + \ (t) * SHA256_BYTES_IN_WORD)) /* 'W' generation and assignment for 16 <= t <= 63. See FIPS PUB 180-4 paragraph 6.2.2. As only last 16 'W' are used in calculations, it is possible to use 16 elements array of W as cyclic buffer. * Note: ((t-16)&0xf) have same value as (t&0xf) */ #define Wgen(w,t) ( (w)[(t - 16) & 0xf] + sig1 ((w)[((t) - 2) & 0xf]) \ + (w)[((t) - 7) & 0xf] + sig0 ((w)[((t) - 15) & 0xf]) ) #ifndef MHD_FAVOR_SMALL_CODE /* Note: instead of using K constants as array, all K values are specified individually for each step, see FIPS PUB 180-4 paragraph 4.2.2 for K values. */ /* Note: instead of reassigning all working variables on each step, variables are rotated for each step: SHA2STEP32(a, b, c, d, e, f, g, h, K[0], data[0]); SHA2STEP32(h, a, b, c, d, e, f, g, K[1], data[1]); so current 'vD' will be used as 'vE' on next step, current 'vH' will be used as 'vA' on next step. */ #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN if ((const void *) W == data) { /* The input data is already in the cyclic data buffer W[] in correct bytes order. */ SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x428a2f98), W[0]); SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x71374491), W[1]); SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0xb5c0fbcf), W[2]); SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0xe9b5dba5), W[3]); SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x3956c25b), W[4]); SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x59f111f1), W[5]); SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x923f82a4), W[6]); SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0xab1c5ed5), W[7]); SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0xd807aa98), W[8]); SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x12835b01), W[9]); SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x243185be), W[10]); SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x550c7dc3), W[11]); SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x72be5d74), W[12]); SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x80deb1fe), W[13]); SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x9bdc06a7), W[14]); SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0xc19bf174), W[15]); } else /* Combined with the next 'if' */ #endif /* _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN */ if (1) { /* During first 16 steps, before making any calculations on each step, the W element is read from input data buffer as big-endian value and stored in array of W elements. */ SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x428a2f98), W[0] = \ GET_W_FROM_DATA (data, 0)); SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x71374491), W[1] = \ GET_W_FROM_DATA (data, 1)); SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0xb5c0fbcf), W[2] = \ GET_W_FROM_DATA (data, 2)); SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0xe9b5dba5), W[3] = \ GET_W_FROM_DATA (data, 3)); SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x3956c25b), W[4] = \ GET_W_FROM_DATA (data, 4)); SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x59f111f1), W[5] = \ GET_W_FROM_DATA (data, 5)); SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x923f82a4), W[6] = \ GET_W_FROM_DATA (data, 6)); SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0xab1c5ed5), W[7] = \ GET_W_FROM_DATA (data, 7)); SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0xd807aa98), W[8] = \ GET_W_FROM_DATA (data, 8)); SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x12835b01), W[9] = \ GET_W_FROM_DATA (data, 9)); SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x243185be), W[10] = \ GET_W_FROM_DATA (data, 10)); SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x550c7dc3), W[11] = \ GET_W_FROM_DATA (data, 11)); SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x72be5d74), W[12] = \ GET_W_FROM_DATA (data, 12)); SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x80deb1fe), W[13] = \ GET_W_FROM_DATA (data, 13)); SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x9bdc06a7), W[14] = \ GET_W_FROM_DATA (data, 14)); SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0xc19bf174), W[15] = \ GET_W_FROM_DATA (data, 15)); } /* During last 48 steps, before making any calculations on each step, current W element is generated from other W elements of the cyclic buffer and the generated value is stored back in the cyclic buffer. */ /* Note: instead of using K constants as array, all K values are specified individually for each step, see FIPS PUB 180-4 paragraph 4.2.2 for K values. */ SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0xe49b69c1), W[16 & 0xf] = \ Wgen (W,16)); SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0xefbe4786), W[17 & 0xf] = \ Wgen (W,17)); SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x0fc19dc6), W[18 & 0xf] = \ Wgen (W,18)); SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x240ca1cc), W[19 & 0xf] = \ Wgen (W,19)); SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x2de92c6f), W[20 & 0xf] = \ Wgen (W,20)); SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x4a7484aa), W[21 & 0xf] = \ Wgen (W,21)); SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x5cb0a9dc), W[22 & 0xf] = \ Wgen (W,22)); SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0x76f988da), W[23 & 0xf] = \ Wgen (W,23)); SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x983e5152), W[24 & 0xf] = \ Wgen (W,24)); SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0xa831c66d), W[25 & 0xf] = \ Wgen (W,25)); SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0xb00327c8), W[26 & 0xf] = \ Wgen (W,26)); SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0xbf597fc7), W[27 & 0xf] = \ Wgen (W,27)); SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0xc6e00bf3), W[28 & 0xf] = \ Wgen (W,28)); SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0xd5a79147), W[29 & 0xf] = \ Wgen (W,29)); SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x06ca6351), W[30 & 0xf] = \ Wgen (W,30)); SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0x14292967), W[31 & 0xf] = \ Wgen (W,31)); SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x27b70a85), W[32 & 0xf] = \ Wgen (W,32)); SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x2e1b2138), W[33 & 0xf] = \ Wgen (W,33)); SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x4d2c6dfc), W[34 & 0xf] = \ Wgen (W,34)); SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x53380d13), W[35 & 0xf] = \ Wgen (W,35)); SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x650a7354), W[36 & 0xf] = \ Wgen (W,36)); SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x766a0abb), W[37 & 0xf] = \ Wgen (W,37)); SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x81c2c92e), W[38 & 0xf] = \ Wgen (W,38)); SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0x92722c85), W[39 & 0xf] = \ Wgen (W,39)); SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0xa2bfe8a1), W[40 & 0xf] = \ Wgen (W,40)); SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0xa81a664b), W[41 & 0xf] = \ Wgen (W,41)); SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0xc24b8b70), W[42 & 0xf] = \ Wgen (W,42)); SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0xc76c51a3), W[43 & 0xf] = \ Wgen (W,43)); SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0xd192e819), W[44 & 0xf] = \ Wgen (W,44)); SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0xd6990624), W[45 & 0xf] = \ Wgen (W,45)); SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0xf40e3585), W[46 & 0xf] = \ Wgen (W,46)); SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0x106aa070), W[47 & 0xf] = \ Wgen (W,47)); SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x19a4c116), W[48 & 0xf] = \ Wgen (W,48)); SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x1e376c08), W[49 & 0xf] = \ Wgen (W,49)); SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x2748774c), W[50 & 0xf] = \ Wgen (W,50)); SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x34b0bcb5), W[51 & 0xf] = \ Wgen (W,51)); SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x391c0cb3), W[52 & 0xf] = \ Wgen (W,52)); SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0x4ed8aa4a), W[53 & 0xf] = \ Wgen (W,53)); SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0x5b9cca4f), W[54 & 0xf] = \ Wgen (W,54)); SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0x682e6ff3), W[55 & 0xf] = \ Wgen (W,55)); SHA2STEP32 (a, b, c, d, e, f, g, h, UINT32_C (0x748f82ee), W[56 & 0xf] = \ Wgen (W,56)); SHA2STEP32 (h, a, b, c, d, e, f, g, UINT32_C (0x78a5636f), W[57 & 0xf] = \ Wgen (W,57)); SHA2STEP32 (g, h, a, b, c, d, e, f, UINT32_C (0x84c87814), W[58 & 0xf] = \ Wgen (W,58)); SHA2STEP32 (f, g, h, a, b, c, d, e, UINT32_C (0x8cc70208), W[59 & 0xf] = \ Wgen (W,59)); SHA2STEP32 (e, f, g, h, a, b, c, d, UINT32_C (0x90befffa), W[60 & 0xf] = \ Wgen (W,60)); SHA2STEP32 (d, e, f, g, h, a, b, c, UINT32_C (0xa4506ceb), W[61 & 0xf] = \ Wgen (W,61)); SHA2STEP32 (c, d, e, f, g, h, a, b, UINT32_C (0xbef9a3f7), W[62 & 0xf] = \ Wgen (W,62)); SHA2STEP32 (b, c, d, e, f, g, h, a, UINT32_C (0xc67178f2), W[63 & 0xf] = \ Wgen (W,63)); #else /* ! MHD_FAVOR_SMALL_CODE */ if (1) { unsigned int t; /* K constants array. See FIPS PUB 180-4 paragraph 4.2.2 for K values. */ static const uint32_t K[80] = { UINT32_C (0x428a2f98), UINT32_C (0x71374491), UINT32_C (0xb5c0fbcf), UINT32_C (0xe9b5dba5), UINT32_C (0x3956c25b), UINT32_C (0x59f111f1), UINT32_C (0x923f82a4), UINT32_C (0xab1c5ed5), UINT32_C (0xd807aa98), UINT32_C (0x12835b01), UINT32_C (0x243185be), UINT32_C (0x550c7dc3), UINT32_C (0x72be5d74), UINT32_C (0x80deb1fe), UINT32_C (0x9bdc06a7), UINT32_C (0xc19bf174), UINT32_C (0xe49b69c1), UINT32_C (0xefbe4786), UINT32_C (0x0fc19dc6), UINT32_C (0x240ca1cc), UINT32_C (0x2de92c6f), UINT32_C (0x4a7484aa), UINT32_C (0x5cb0a9dc), UINT32_C (0x76f988da), UINT32_C (0x983e5152), UINT32_C (0xa831c66d), UINT32_C (0xb00327c8), UINT32_C (0xbf597fc7), UINT32_C (0xc6e00bf3), UINT32_C (0xd5a79147), UINT32_C (0x06ca6351), UINT32_C (0x14292967), UINT32_C (0x27b70a85), UINT32_C (0x2e1b2138), UINT32_C (0x4d2c6dfc), UINT32_C (0x53380d13), UINT32_C (0x650a7354), UINT32_C (0x766a0abb), UINT32_C (0x81c2c92e), UINT32_C (0x92722c85), UINT32_C (0xa2bfe8a1), UINT32_C (0xa81a664b), UINT32_C (0xc24b8b70), UINT32_C (0xc76c51a3), UINT32_C (0xd192e819), UINT32_C (0xd6990624), UINT32_C (0xf40e3585), UINT32_C (0x106aa070), UINT32_C (0x19a4c116), UINT32_C (0x1e376c08), UINT32_C (0x2748774c), UINT32_C (0x34b0bcb5), UINT32_C (0x391c0cb3), UINT32_C (0x4ed8aa4a), UINT32_C (0x5b9cca4f), UINT32_C (0x682e6ff3), UINT32_C (0x748f82ee), UINT32_C (0x78a5636f), UINT32_C (0x84c87814), UINT32_C (0x8cc70208), UINT32_C (0x90befffa), UINT32_C (0xa4506ceb), UINT32_C (0xbef9a3f7), UINT32_C (0xc67178f2) }; /* One step of SHA-256 computation with working variables rotation, see FIPS PUB 180-4 paragraph 6.2.2 step 3. * Note: this version of macro reassign all working variable on each step. */ #define SHA2STEP32RV(vA,vB,vC,vD,vE,vF,vG,vH,kt,wt) do { \ uint32_t tmp_h_ = (vH); \ SHA2STEP32((vA),(vB),(vC),(vD),(vE),(vF),(vG),tmp_h_,(kt),(wt)); \ (vH) = (vG); \ (vG) = (vF); \ (vF) = (vE); \ (vE) = (vD); \ (vD) = (vC); \ (vC) = (vB); \ (vB) = (vA); \ (vA) = tmp_h_; } while (0) /* During first 16 steps, before making any calculations on each step, the W element is read from input data buffer as big-endian value and stored in array of W elements. */ for (t = 0; t < 16; ++t) { SHA2STEP32RV (a, b, c, d, e, f, g, h, K[t], \ W[t] = GET_W_FROM_DATA (data, t)); } /* During last 48 steps, before making any calculations on each step, current W element is generated from other W elements of the cyclic buffer and the generated value is stored back in the cyclic buffer. */ for (t = 16; t < 64; ++t) { SHA2STEP32RV (a, b, c, d, e, f, g, h, K[t], W[t & 15] = Wgen (W,t)); } } #endif /* ! MHD_FAVOR_SMALL_CODE */ /* Compute intermediate hash. See FIPS PUB 180-4 paragraph 6.2.2 step 4. */ H[0] += a; H[1] += b; H[2] += c; H[3] += d; H[4] += e; H[5] += f; H[6] += g; H[7] += h; } /** * Process portion of bytes. * * @param ctx_ must be a `struct Sha256Ctx *` * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_SHA256_update (struct Sha256Ctx *ctx, const uint8_t *data, size_t length) { unsigned bytes_have; /**< Number of bytes in buffer */ mhd_assert ((data != NULL) || (length == 0)); #ifndef MHD_FAVOR_SMALL_CODE if (0 == length) return; /* Shortcut, do nothing */ #endif /* MHD_FAVOR_SMALL_CODE */ /* Note: (count & (SHA256_BLOCK_SIZE-1)) equals (count % SHA256_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned) (ctx->count & (SHA256_BLOCK_SIZE - 1)); ctx->count += length; if (0 != bytes_have) { unsigned bytes_left = SHA256_BLOCK_SIZE - bytes_have; if (length >= bytes_left) { /* Combine new data with data in the buffer and process full block. */ memcpy (((uint8_t *) ctx->buffer) + bytes_have, data, bytes_left); data += bytes_left; length -= bytes_left; sha256_transform (ctx->H, ctx->buffer); bytes_have = 0; } } while (SHA256_BLOCK_SIZE <= length) { /* Process any full blocks of new data directly, without copying to the buffer. */ sha256_transform (ctx->H, data); data += SHA256_BLOCK_SIZE; length -= SHA256_BLOCK_SIZE; } if (0 != length) { /* Copy incomplete block of new data (if any) to the buffer. */ memcpy (((uint8_t *) ctx->buffer) + bytes_have, data, length); } } /** * Size of "length" padding addition in bytes. * See FIPS PUB 180-4 paragraph 5.1.1. */ #define SHA256_SIZE_OF_LEN_ADD (64 / 8) /** * Finalise SHA256 calculation, return digest. * * @param ctx_ must be a `struct Sha256Ctx *` * @param[out] digest set to the hash, must be #SHA256_DIGEST_SIZE bytes */ void MHD_SHA256_finish (struct Sha256Ctx *ctx, uint8_t digest[SHA256_DIGEST_SIZE]) { uint64_t num_bits; /**< Number of processed bits */ unsigned bytes_have; /**< Number of bytes in buffer */ num_bits = ctx->count << 3; /* Note: (count & (SHA256_BLOCK_SIZE-1)) equal (count % SHA256_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned) (ctx->count & (SHA256_BLOCK_SIZE - 1)); /* Input data must be padded with a single bit "1", then with zeros and the finally the length of data in bits must be added as the final bytes of the last block. See FIPS PUB 180-4 paragraph 5.1.1. */ /* Data is always processed in form of bytes (not by individual bits), therefore position of first padding bit in byte is always predefined (0x80). */ /* Buffer always have space at least for one byte (as full buffers are processed immediately). */ ((uint8_t *) ctx->buffer)[bytes_have++] = 0x80; if (SHA256_BLOCK_SIZE - bytes_have < SHA256_SIZE_OF_LEN_ADD) { /* No space in current block to put total length of message. Pad current block with zeros and process it. */ if (bytes_have < SHA256_BLOCK_SIZE) memset (((uint8_t *) ctx->buffer) + bytes_have, 0, SHA256_BLOCK_SIZE - bytes_have); /* Process full block. */ sha256_transform (ctx->H, ctx->buffer); /* Start new block. */ bytes_have = 0; } /* Pad the rest of the buffer with zeros. */ memset (((uint8_t *) ctx->buffer) + bytes_have, 0, SHA256_BLOCK_SIZE - SHA256_SIZE_OF_LEN_ADD - bytes_have); /* Put the number of bits in processed message as big-endian value. */ _MHD_PUT_64BIT_BE_SAFE (ctx->buffer + SHA256_BLOCK_SIZE_WORDS - 2, num_bits); /* Process full final block. */ sha256_transform (ctx->H, ctx->buffer); /* Put final hash/digest in BE mode */ #ifndef _MHD_PUT_32BIT_BE_UNALIGNED if (1 #ifndef MHD_FAVOR_SMALL_CODE && (0 != ((uintptr_t) digest) % _MHD_UINT32_ALIGN) #endif /* MHD_FAVOR_SMALL_CODE */ ) { /* If storing of the final result requires aligned address and the destination address is not aligned or compact code is used, store the final digest in aligned temporary buffer first, then copy it to the destination. */ uint32_t alig_dgst[SHA256_DIGEST_SIZE_WORDS]; _MHD_PUT_32BIT_BE (alig_dgst + 0, ctx->H[0]); _MHD_PUT_32BIT_BE (alig_dgst + 1, ctx->H[1]); _MHD_PUT_32BIT_BE (alig_dgst + 2, ctx->H[2]); _MHD_PUT_32BIT_BE (alig_dgst + 3, ctx->H[3]); _MHD_PUT_32BIT_BE (alig_dgst + 4, ctx->H[4]); _MHD_PUT_32BIT_BE (alig_dgst + 5, ctx->H[5]); _MHD_PUT_32BIT_BE (alig_dgst + 6, ctx->H[6]); _MHD_PUT_32BIT_BE (alig_dgst + 7, ctx->H[7]); /* Copy result to unaligned destination address */ memcpy (digest, alig_dgst, SHA256_DIGEST_SIZE); } #ifndef MHD_FAVOR_SMALL_CODE else /* Combined with the next 'if' */ #endif /* MHD_FAVOR_SMALL_CODE */ #endif /* ! _MHD_PUT_32BIT_BE_UNALIGNED */ #if ! defined(MHD_FAVOR_SMALL_CODE) || defined(_MHD_PUT_32BIT_BE_UNALIGNED) if (1) { /* Use cast to (void*) here to mute compiler alignment warnings. * Compilers are not smart enough to see that alignment has been checked. */ _MHD_PUT_32BIT_BE ((void *) (digest + 0 * SHA256_BYTES_IN_WORD), ctx->H[0]); _MHD_PUT_32BIT_BE ((void *) (digest + 1 * SHA256_BYTES_IN_WORD), ctx->H[1]); _MHD_PUT_32BIT_BE ((void *) (digest + 2 * SHA256_BYTES_IN_WORD), ctx->H[2]); _MHD_PUT_32BIT_BE ((void *) (digest + 3 * SHA256_BYTES_IN_WORD), ctx->H[3]); _MHD_PUT_32BIT_BE ((void *) (digest + 4 * SHA256_BYTES_IN_WORD), ctx->H[4]); _MHD_PUT_32BIT_BE ((void *) (digest + 5 * SHA256_BYTES_IN_WORD), ctx->H[5]); _MHD_PUT_32BIT_BE ((void *) (digest + 6 * SHA256_BYTES_IN_WORD), ctx->H[6]); _MHD_PUT_32BIT_BE ((void *) (digest + 7 * SHA256_BYTES_IN_WORD), ctx->H[7]); } #endif /* ! MHD_FAVOR_SMALL_CODE || _MHD_PUT_32BIT_BE_UNALIGNED */ /* Erase potentially sensitive data. */ memset (ctx, 0, sizeof(struct Sha256Ctx)); } MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ libmicrohttpd-1.0.1/src/microhttpd/reason_phrase.c0000644000175000017500000002352614556705750016025 /* This file is part of libmicrohttpd Copyright (C) 2007, 2011, 2017, 2019 Christian Grothoff Copyright (C) 2017-2023 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file reason_phrase.c * @brief Tables of the string response phrases * @author Elliot Glaysher * @author Christian Grothoff (minor code clean up) * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include "microhttpd.h" #include "mhd_str.h" #ifndef NULL #define NULL ((void*) 0) #endif static const struct _MHD_cstr_w_len invalid_hundred[] = { { NULL, 0 } }; static const struct _MHD_cstr_w_len one_hundred[] = { /* 100 */ _MHD_S_STR_W_LEN ("Continue"), /* RFC9110, Section 15.2.1 */ /* 101 */ _MHD_S_STR_W_LEN ("Switching Protocols"), /* RFC9110, Section 15.2.2 */ /* 102 */ _MHD_S_STR_W_LEN ("Processing"), /* RFC2518 */ /* 103 */ _MHD_S_STR_W_LEN ("Early Hints") /* RFC8297 */ }; static const struct _MHD_cstr_w_len two_hundred[] = { /* 200 */ _MHD_S_STR_W_LEN ("OK"), /* RFC9110, Section 15.3.1 */ /* 201 */ _MHD_S_STR_W_LEN ("Created"), /* RFC9110, Section 15.3.2 */ /* 202 */ _MHD_S_STR_W_LEN ("Accepted"), /* RFC9110, Section 15.3.3 */ /* 203 */ _MHD_S_STR_W_LEN ("Non-Authoritative Information"), /* RFC9110, Section 15.3.4 */ /* 204 */ _MHD_S_STR_W_LEN ("No Content"), /* RFC9110, Section 15.3.5 */ /* 205 */ _MHD_S_STR_W_LEN ("Reset Content"), /* RFC9110, Section 15.3.6 */ /* 206 */ _MHD_S_STR_W_LEN ("Partial Content"), /* RFC9110, Section 15.3.7 */ /* 207 */ _MHD_S_STR_W_LEN ("Multi-Status"), /* RFC4918 */ /* 208 */ _MHD_S_STR_W_LEN ("Already Reported"), /* RFC5842 */ /* 209 */ {"Unknown", 0}, /* Not used */ /* 210 */ {"Unknown", 0}, /* Not used */ /* 211 */ {"Unknown", 0}, /* Not used */ /* 212 */ {"Unknown", 0}, /* Not used */ /* 213 */ {"Unknown", 0}, /* Not used */ /* 214 */ {"Unknown", 0}, /* Not used */ /* 215 */ {"Unknown", 0}, /* Not used */ /* 216 */ {"Unknown", 0}, /* Not used */ /* 217 */ {"Unknown", 0}, /* Not used */ /* 218 */ {"Unknown", 0}, /* Not used */ /* 219 */ {"Unknown", 0}, /* Not used */ /* 220 */ {"Unknown", 0}, /* Not used */ /* 221 */ {"Unknown", 0}, /* Not used */ /* 222 */ {"Unknown", 0}, /* Not used */ /* 223 */ {"Unknown", 0}, /* Not used */ /* 224 */ {"Unknown", 0}, /* Not used */ /* 225 */ {"Unknown", 0}, /* Not used */ /* 226 */ _MHD_S_STR_W_LEN ("IM Used") /* RFC3229 */ }; static const struct _MHD_cstr_w_len three_hundred[] = { /* 300 */ _MHD_S_STR_W_LEN ("Multiple Choices"), /* RFC9110, Section 15.4.1 */ /* 301 */ _MHD_S_STR_W_LEN ("Moved Permanently"), /* RFC9110, Section 15.4.2 */ /* 302 */ _MHD_S_STR_W_LEN ("Found"), /* RFC9110, Section 15.4.3 */ /* 303 */ _MHD_S_STR_W_LEN ("See Other"), /* RFC9110, Section 15.4.4 */ /* 304 */ _MHD_S_STR_W_LEN ("Not Modified"), /* RFC9110, Section 15.4.5 */ /* 305 */ _MHD_S_STR_W_LEN ("Use Proxy"), /* RFC9110, Section 15.4.6 */ /* 306 */ _MHD_S_STR_W_LEN ("Switch Proxy"), /* Not used! RFC9110, Section 15.4.7 */ /* 307 */ _MHD_S_STR_W_LEN ("Temporary Redirect"), /* RFC9110, Section 15.4.8 */ /* 308 */ _MHD_S_STR_W_LEN ("Permanent Redirect") /* RFC9110, Section 15.4.9 */ }; static const struct _MHD_cstr_w_len four_hundred[] = { /* 400 */ _MHD_S_STR_W_LEN ("Bad Request"), /* RFC9110, Section 15.5.1 */ /* 401 */ _MHD_S_STR_W_LEN ("Unauthorized"), /* RFC9110, Section 15.5.2 */ /* 402 */ _MHD_S_STR_W_LEN ("Payment Required"), /* RFC9110, Section 15.5.3 */ /* 403 */ _MHD_S_STR_W_LEN ("Forbidden"), /* RFC9110, Section 15.5.4 */ /* 404 */ _MHD_S_STR_W_LEN ("Not Found"), /* RFC9110, Section 15.5.5 */ /* 405 */ _MHD_S_STR_W_LEN ("Method Not Allowed"), /* RFC9110, Section 15.5.6 */ /* 406 */ _MHD_S_STR_W_LEN ("Not Acceptable"), /* RFC9110, Section 15.5.7 */ /* 407 */ _MHD_S_STR_W_LEN ("Proxy Authentication Required"), /* RFC9110, Section 15.5.8 */ /* 408 */ _MHD_S_STR_W_LEN ("Request Timeout"), /* RFC9110, Section 15.5.9 */ /* 409 */ _MHD_S_STR_W_LEN ("Conflict"), /* RFC9110, Section 15.5.10 */ /* 410 */ _MHD_S_STR_W_LEN ("Gone"), /* RFC9110, Section 15.5.11 */ /* 411 */ _MHD_S_STR_W_LEN ("Length Required"), /* RFC9110, Section 15.5.12 */ /* 412 */ _MHD_S_STR_W_LEN ("Precondition Failed"), /* RFC9110, Section 15.5.13 */ /* 413 */ _MHD_S_STR_W_LEN ("Content Too Large"), /* RFC9110, Section 15.5.14 */ /* 414 */ _MHD_S_STR_W_LEN ("URI Too Long"), /* RFC9110, Section 15.5.15 */ /* 415 */ _MHD_S_STR_W_LEN ("Unsupported Media Type"), /* RFC9110, Section 15.5.16 */ /* 416 */ _MHD_S_STR_W_LEN ("Range Not Satisfiable"), /* RFC9110, Section 15.5.17 */ /* 417 */ _MHD_S_STR_W_LEN ("Expectation Failed"), /* RFC9110, Section 15.5.18 */ /* 418 */ {"Unknown", 0}, /* Not used */ /* 419 */ {"Unknown", 0}, /* Not used */ /* 420 */ {"Unknown", 0}, /* Not used */ /* 421 */ _MHD_S_STR_W_LEN ("Misdirected Request"), /* RFC9110, Section 15.5.20 */ /* 422 */ _MHD_S_STR_W_LEN ("Unprocessable Content"), /* RFC9110, Section 15.5.21 */ /* 423 */ _MHD_S_STR_W_LEN ("Locked"), /* RFC4918 */ /* 424 */ _MHD_S_STR_W_LEN ("Failed Dependency"), /* RFC4918 */ /* 425 */ _MHD_S_STR_W_LEN ("Too Early"), /* RFC8470 */ /* 426 */ _MHD_S_STR_W_LEN ("Upgrade Required"), /* RFC9110, Section 15.5.22 */ /* 427 */ {"Unknown", 0}, /* Not used */ /* 428 */ _MHD_S_STR_W_LEN ("Precondition Required"), /* RFC6585 */ /* 429 */ _MHD_S_STR_W_LEN ("Too Many Requests"), /* RFC6585 */ /* 430 */ {"Unknown", 0}, /* Not used */ /* 431 */ _MHD_S_STR_W_LEN ("Request Header Fields Too Large"), /* RFC6585 */ /* 432 */ {"Unknown", 0}, /* Not used */ /* 433 */ {"Unknown", 0}, /* Not used */ /* 434 */ {"Unknown", 0}, /* Not used */ /* 435 */ {"Unknown", 0}, /* Not used */ /* 436 */ {"Unknown", 0}, /* Not used */ /* 437 */ {"Unknown", 0}, /* Not used */ /* 438 */ {"Unknown", 0}, /* Not used */ /* 439 */ {"Unknown", 0}, /* Not used */ /* 440 */ {"Unknown", 0}, /* Not used */ /* 441 */ {"Unknown", 0}, /* Not used */ /* 442 */ {"Unknown", 0}, /* Not used */ /* 443 */ {"Unknown", 0}, /* Not used */ /* 444 */ {"Unknown", 0}, /* Not used */ /* 445 */ {"Unknown", 0}, /* Not used */ /* 446 */ {"Unknown", 0}, /* Not used */ /* 447 */ {"Unknown", 0}, /* Not used */ /* 448 */ {"Unknown", 0}, /* Not used */ /* 449 */ _MHD_S_STR_W_LEN ("Reply With"), /* MS IIS extension */ /* 450 */ _MHD_S_STR_W_LEN ("Blocked by Windows Parental Controls"), /* MS extension */ /* 451 */ _MHD_S_STR_W_LEN ("Unavailable For Legal Reasons") /* RFC7725 */ }; static const struct _MHD_cstr_w_len five_hundred[] = { /* 500 */ _MHD_S_STR_W_LEN ("Internal Server Error"), /* RFC9110, Section 15.6.1 */ /* 501 */ _MHD_S_STR_W_LEN ("Not Implemented"), /* RFC9110, Section 15.6.2 */ /* 502 */ _MHD_S_STR_W_LEN ("Bad Gateway"), /* RFC9110, Section 15.6.3 */ /* 503 */ _MHD_S_STR_W_LEN ("Service Unavailable"), /* RFC9110, Section 15.6.4 */ /* 504 */ _MHD_S_STR_W_LEN ("Gateway Timeout"), /* RFC9110, Section 15.6.5 */ /* 505 */ _MHD_S_STR_W_LEN ("HTTP Version Not Supported"), /* RFC9110, Section 15.6.6 */ /* 506 */ _MHD_S_STR_W_LEN ("Variant Also Negotiates"), /* RFC2295 */ /* 507 */ _MHD_S_STR_W_LEN ("Insufficient Storage"), /* RFC4918 */ /* 508 */ _MHD_S_STR_W_LEN ("Loop Detected"), /* RFC5842 */ /* 509 */ _MHD_S_STR_W_LEN ("Bandwidth Limit Exceeded"), /* Apache extension */ /* 510 */ _MHD_S_STR_W_LEN ("Not Extended"), /* (OBSOLETED) RFC2774; status-change-http-experiments-to-historic */ /* 511 */ _MHD_S_STR_W_LEN ("Network Authentication Required") /* RFC6585 */ }; struct MHD_Reason_Block { size_t max; const struct _MHD_cstr_w_len *const data; }; #define BLOCK(m) { (sizeof(m) / sizeof(m[0])), m } static const struct MHD_Reason_Block reasons[] = { BLOCK (invalid_hundred), BLOCK (one_hundred), BLOCK (two_hundred), BLOCK (three_hundred), BLOCK (four_hundred), BLOCK (five_hundred), }; _MHD_EXTERN const char * MHD_get_reason_phrase_for (unsigned int code) { if ( (code >= 100) && (code < 600) && (reasons[code / 100].max > (code % 100)) ) return reasons[code / 100].data[code % 100].str; return "Unknown"; } _MHD_EXTERN size_t MHD_get_reason_phrase_len_for (unsigned int code) { if ( (code >= 100) && (code < 600) && (reasons[code / 100].max > (code % 100)) ) return reasons[code / 100].data[code % 100].len; return 0; } libmicrohttpd-1.0.1/src/microhttpd/gen_auth.h0000644000175000017500000000511714441373361014757 /* This file is part of libmicrohttpd Copyright (C) 2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/gen_auth.h * @brief Declarations for HTTP authorisation general functions * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_GET_AUTH_H #define MHD_GET_AUTH_H 1 #include "mhd_options.h" #ifdef HAVE_STDBOOL_H #include #endif /* HAVE_STDBOOL_H */ struct MHD_Connection; /* Forward declaration to avoid include of the large headers */ #ifdef BAUTH_SUPPORT /* Forward declaration to avoid additional headers inclusion */ struct MHD_RqBAuth; /** * Return request's Basic Authorisation parameters. * * Function return result of parsing of the request's "Authorization" header or * returns cached parsing result if the header was already parsed for * the current request. * @param connection the connection to process * @return the pointer to structure with Authentication parameters, * NULL if no memory in memory pool, if called too early (before * header has been received) or if no valid Basic Authorisation header * found. */ const struct MHD_RqBAuth * MHD_get_rq_bauth_params_ (struct MHD_Connection *connection); #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT /* Forward declaration to avoid additional headers inclusion */ struct MHD_RqDAuth; /** * Return request's Digest Authorisation parameters. * * Function return result of parsing of the request's "Authorization" header or * returns cached parsing result if the header was already parsed for * the current request. * @param connection the connection to process * @return the pointer to structure with Authentication parameters, * NULL if no memory in memory pool, if called too early (before * header has been received) or if no valid Basic Authorisation header * found. */ const struct MHD_RqDAuth * MHD_get_rq_dauth_params_ (struct MHD_Connection *connection); #endif /* DAUTH_SUPPORT */ #endif /* MHD_GET_AUTH_H */ libmicrohttpd-1.0.1/src/microhttpd/mhd_threads.c0000644000175000017500000002751114556705750015454 /* This file is part of libmicrohttpd Copyright (C) 2016-2023 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_threads.c * @brief Implementation for thread functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_threads.h" #ifdef MHD_USE_W32_THREADS #include "mhd_limits.h" #include #endif #ifdef MHD_USE_THREAD_NAME_ #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #ifdef HAVE_PTHREAD_NP_H #include #endif /* HAVE_PTHREAD_NP_H */ #endif /* MHD_USE_THREAD_NAME_ */ #include #include "mhd_assert.h" #ifndef MHD_USE_THREAD_NAME_ #define MHD_set_thread_name_(t, n) (void) #define MHD_set_cur_thread_name_(n) (void) #else /* MHD_USE_THREAD_NAME_ */ #if defined(MHD_USE_POSIX_THREADS) #if defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || \ defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) # define MHD_USE_THREAD_ATTR_SETNAME 1 #endif /* HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD || \ HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI */ #if defined(HAVE_PTHREAD_SETNAME_NP_GNU) || \ defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) \ || defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) /** * Set thread name * * @param thread_id ID of thread * @param thread_name name to set * @return non-zero on success, zero otherwise */ static int MHD_set_thread_name_ (const MHD_thread_ID_native_ thread_id, const char *thread_name) { if (NULL == thread_name) return 0; #if defined(HAVE_PTHREAD_SETNAME_NP_GNU) return ! pthread_setname_np (thread_id, thread_name); #elif defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) /* FreeBSD and OpenBSD use different function name and void return type */ pthread_set_name_np (thread_id, thread_name); return ! 0; #elif defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) /* NetBSD use 3 arguments: second argument is string in printf-like format, * third argument is a single argument for printf(); * OSF1 use 3 arguments too, but last one always must be zero (NULL). * MHD doesn't use '%' in thread names, so both form are used in same way. */ return ! pthread_setname_np (thread_id, thread_name, 0); #endif /* HAVE_PTHREAD_SETNAME_NP_NETBSD */ } #ifndef __QNXNTO__ /** * Set current thread name * @param n name to set * @return non-zero on success, zero otherwise */ #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_ (pthread_self (),(n)) #else /* __QNXNTO__ */ /* Special case for QNX Neutrino - using zero for thread ID sets name faster. */ #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_ (0,(n)) #endif /* __QNXNTO__ */ #elif defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) /** * Set current thread name * @param n name to set * @return non-zero on success, zero otherwise */ #define MHD_set_cur_thread_name_(n) (! (pthread_setname_np ((n)))) #endif /* HAVE_PTHREAD_SETNAME_NP_DARWIN */ #elif defined(MHD_USE_W32_THREADS) #ifndef _MSC_FULL_VER /* Thread name available only for VC-compiler */ #else /* _MSC_FULL_VER */ /** * Set thread name * * @param thread_id ID of thread, -1 for current thread * @param thread_name name to set * @return non-zero on success, zero otherwise */ static int MHD_set_thread_name_ (const MHD_thread_ID_native_ thread_id, const char *thread_name) { static const DWORD VC_SETNAME_EXC = 0x406D1388; #pragma pack(push,8) struct thread_info_struct { DWORD type; /* Must be 0x1000. */ LPCSTR name; /* Pointer to name (in user address space). */ DWORD ID; /* Thread ID (-1 = caller thread). */ DWORD flags; /* Reserved for future use, must be zero. */ } thread_info; #pragma pack(pop) if (NULL == thread_name) return 0; thread_info.type = 0x1000; thread_info.name = thread_name; thread_info.ID = thread_id; thread_info.flags = 0; __try { /* This exception is intercepted by debugger */ RaiseException (VC_SETNAME_EXC, 0, sizeof (thread_info) / sizeof(ULONG_PTR), (ULONG_PTR *) &thread_info); } __except (EXCEPTION_EXECUTE_HANDLER) {} return ! 0; } /** * Set current thread name * @param n name to set * @return non-zero on success, zero otherwise */ #define MHD_set_cur_thread_name_(n) \ MHD_set_thread_name_ ((MHD_thread_ID_native_) -1,(n)) #endif /* _MSC_FULL_VER */ #endif /* MHD_USE_W32_THREADS */ #endif /* MHD_USE_THREAD_NAME_ */ /** * Create a thread and set the attributes according to our options. * * If thread is created, thread handle must be freed by MHD_join_thread_(). * * @param handle_id handle to initialise * @param stack_size size of stack for new thread, 0 for default * @param start_routine main function of thread * @param arg argument for start_routine * @return non-zero on success; zero otherwise (with errno set) */ int MHD_create_thread_ (MHD_thread_handle_ID_ *handle_id, size_t stack_size, MHD_THREAD_START_ROUTINE_ start_routine, void *arg) { #if defined(MHD_USE_POSIX_THREADS) int res; #if defined(MHD_thread_handle_ID_get_native_handle_ptr_) pthread_t *const new_tid_ptr = MHD_thread_handle_ID_get_native_handle_ptr_ (handle_id); #else /* ! MHD_thread_handle_ID_get_native_handle_ptr_ */ pthread_t new_tid; pthread_t *const new_tid_ptr = &new_tid; #endif /* ! MHD_thread_handle_ID_get_native_handle_ptr_ */ mhd_assert (! MHD_thread_handle_ID_is_valid_handle_ (*handle_id)); if (0 != stack_size) { pthread_attr_t attr; res = pthread_attr_init (&attr); if (0 == res) { res = pthread_attr_setstacksize (&attr, stack_size); if (0 == res) res = pthread_create (new_tid_ptr, &attr, start_routine, arg); pthread_attr_destroy (&attr); } } else res = pthread_create (new_tid_ptr, NULL, start_routine, arg); if (0 != res) { errno = res; MHD_thread_handle_ID_set_invalid_ (handle_id); } #if ! defined(MHD_thread_handle_ID_get_native_handle_ptr_) else MHD_thread_handle_ID_set_native_handle_ (handle_id, new_tid); #endif /* ! MHD_thread_handle_ID_set_current_thread_ID_ */ return ! res; #elif defined(MHD_USE_W32_THREADS) uintptr_t thr_handle; #if SIZEOF_SIZE_T != SIZEOF_UNSIGNED_INT mhd_assert (! MHD_thread_handle_ID_is_valid_handle_ (*handle_id)); if (stack_size > UINT_MAX) { errno = EINVAL; return 0; } #endif /* SIZEOF_SIZE_T != SIZEOF_UNSIGNED_INT */ thr_handle = (uintptr_t) _beginthreadex (NULL, (unsigned int) stack_size, start_routine, arg, 0, NULL); if ((MHD_thread_handle_native_) 0 == (MHD_thread_handle_native_) thr_handle) return 0; MHD_thread_handle_ID_set_native_handle_ (handle_id, \ (MHD_thread_handle_native_) \ thr_handle); return ! 0; #endif } #ifdef MHD_USE_THREAD_NAME_ #ifndef MHD_USE_THREAD_ATTR_SETNAME struct MHD_named_helper_param_ { /** * Real thread start routine */ MHD_THREAD_START_ROUTINE_ start_routine; /** * Argument for thread start routine */ void *arg; /** * Name for thread */ const char *name; }; static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ named_thread_starter (void *data) { struct MHD_named_helper_param_ *const param = (struct MHD_named_helper_param_ *) data; void *arg; MHD_THREAD_START_ROUTINE_ thr_func; if (NULL == data) return (MHD_THRD_RTRN_TYPE_) 0; MHD_set_cur_thread_name_ (param->name); arg = param->arg; thr_func = param->start_routine; free (data); return thr_func (arg); } #endif /* ! MHD_USE_THREAD_ATTR_SETNAME */ /** * Create a named thread and set the attributes according to our options. * * @param handle_id handle to initialise * @param thread_name name for new thread * @param stack_size size of stack for new thread, 0 for default * @param start_routine main function of thread * @param arg argument for start_routine * @return non-zero on success; zero otherwise (with errno set) */ int MHD_create_named_thread_ (MHD_thread_handle_ID_ *handle_id, const char *thread_name, size_t stack_size, MHD_THREAD_START_ROUTINE_ start_routine, void *arg) { #if defined(MHD_USE_THREAD_ATTR_SETNAME) int res; pthread_attr_t attr; #if defined(MHD_thread_handle_ID_get_native_handle_ptr_) pthread_t *const new_tid_ptr = MHD_thread_handle_ID_get_native_handle_ptr_ (handle_id); #else /* ! MHD_thread_handle_ID_get_native_handle_ptr_ */ pthread_t new_tid; pthread_t *const new_tid_ptr = &new_tid; #endif /* ! MHD_thread_handle_ID_get_native_handle_ptr_ */ res = pthread_attr_init (&attr); if (0 == res) { #if defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) /* NetBSD uses 3 arguments: second argument is string in printf-like format, * third argument is single argument for printf; * OSF1 uses 3 arguments too, but last one always must be zero (NULL). * MHD doesn't use '%' in thread names, so both forms are used in same way. */ res = pthread_attr_setname_np (&attr, thread_name, 0); #elif defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) res = pthread_attr_setname_np (&attr, thread_name); #else #error No pthread_attr_setname_np() function. #endif if ((res == 0) && (0 != stack_size) ) res = pthread_attr_setstacksize (&attr, stack_size); if (0 == res) res = pthread_create (new_tid_ptr, &attr, start_routine, arg); pthread_attr_destroy (&attr); } if (0 != res) { errno = res; MHD_thread_handle_ID_set_invalid_ (handle_id); } #if ! defined(MHD_thread_handle_ID_get_native_handle_ptr_) else MHD_thread_handle_ID_set_native_handle_ (handle_id, new_tid); #endif /* ! MHD_thread_handle_ID_set_current_thread_ID_ */ return ! res; #else /* ! MHD_USE_THREAD_ATTR_SETNAME */ struct MHD_named_helper_param_ *param; if (NULL == thread_name) { errno = EINVAL; return 0; } param = malloc (sizeof (struct MHD_named_helper_param_)); if (NULL == param) return 0; param->start_routine = start_routine; param->arg = arg; param->name = thread_name; /* Set thread name in thread itself to avoid problems with * threads which terminated before name is set in other thread. */ if (! MHD_create_thread_ (handle_id, stack_size, &named_thread_starter, (void *) param)) { int err_num; err_num = errno; free (param); errno = err_num; return 0; } return ! 0; #endif /* ! MHD_USE_THREAD_ATTR_SETNAME */ } #endif /* MHD_USE_THREAD_NAME_ */ libmicrohttpd-1.0.1/src/microhttpd/mhd_sockets.h0000644000175000017500000007701214556705750015503 /* This file is part of libmicrohttpd Copyright (C) 2014-2023 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_sockets.c * @brief Header for platform-independent sockets abstraction * @author Karlson2k (Evgeny Grin) * * Provides basic abstraction for sockets. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid * variable modification in function parameters. */ #ifndef MHD_SOCKETS_H #define MHD_SOCKETS_H 1 #include "mhd_options.h" #include #ifdef HAVE_STDBOOL_H #include #endif /* HAVE_STDBOOL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #if defined(_MSC_FULL_VER) && ! defined(_SSIZE_T_DEFINED) # include # define _SSIZE_T_DEFINED typedef intptr_t ssize_t; #endif /* !_SSIZE_T_DEFINED */ #if ! defined(MHD_POSIX_SOCKETS) && ! defined(MHD_WINSOCK_SOCKETS) # if ! defined(_WIN32) || defined(__CYGWIN__) # define MHD_POSIX_SOCKETS 1 # else /* defined(_WIN32) && !defined(__CYGWIN__) */ # define MHD_WINSOCK_SOCKETS 1 # endif /* defined(_WIN32) && !defined(__CYGWIN__) */ #endif /* !MHD_POSIX_SOCKETS && !MHD_WINSOCK_SOCKETS */ /* * MHD require headers that define socket type, socket basic functions * (socket(), accept(), listen(), bind(), send(), recv(), select()), socket * parameters like SOCK_CLOEXEC, SOCK_NONBLOCK, additional socket functions * (poll(), epoll(), accept4()), struct timeval and other types, required * for socket function. */ #if defined(MHD_POSIX_SOCKETS) # ifdef HAVE_SYS_TYPES_H # include /* required on old platforms */ # endif # ifdef HAVE_SYS_TIME_H # include # endif # ifdef HAVE_TIME_H # include # endif # ifdef HAVE_STRING_H # include /* for strerror() */ # endif # ifdef HAVE_SYS_SOCKET_H # include # endif # if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS) # include /* required for FD_SET (bzero() function) */ # ifdef HAVE_SOCKLIB_H # include # endif /* HAVE_SOCKLIB_H */ # ifdef HAVE_INETLIB_H # include # endif /* HAVE_INETLIB_H */ # endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */ # ifdef HAVE_NETINET_IN_H # include # endif /* HAVE_NETINET_IN_H */ # ifdef HAVE_ARPA_INET_H # include # endif # ifdef HAVE_NET_IF_H # include # endif # ifdef HAVE_NETDB_H # include # endif # ifdef HAVE_SYS_SELECT_H # include # endif # ifdef EPOLL_SUPPORT # include # endif # ifdef HAVE_NETINET_TCP_H /* for TCP_FASTOPEN and TCP_CORK */ # include # endif #elif defined(MHD_WINSOCK_SOCKETS) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif /* !WIN32_LEAN_AND_MEAN */ # include # include #endif /* MHD_WINSOCK_SOCKETS */ #if defined(HAVE_POLL_H) && defined(HAVE_POLL) # include #endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include /* For __FreeBSD_version */ #endif /* __FreeBSD__ */ #include "mhd_limits.h" #ifdef _MHD_FD_SETSIZE_IS_DEFAULT # define _MHD_SYS_DEFAULT_FD_SETSIZE FD_SETSIZE #else /* ! _MHD_FD_SETSIZE_IS_DEFAULT */ # ifndef MHD_SYS_FD_SETSIZE_ # include "sysfdsetsize.h" # define _MHD_SYS_DEFAULT_FD_SETSIZE get_system_fdsetsize_value () # else /* MHD_SYS_FD_SETSIZE_ */ # define _MHD_SYS_DEFAULT_FD_SETSIZE MHD_SYS_FD_SETSIZE_ # endif /* MHD_SYS_FD_SETSIZE_ */ #endif /* ! _MHD_FD_SETSIZE_IS_DEFAULT */ #ifndef MHD_PANIC # include # include /* Simple implementation of MHD_PANIC, to be used outside lib */ # define MHD_PANIC(msg) \ do { fprintf (stderr, \ "Abnormal termination at %d line in file %s: %s\n", \ (int) __LINE__, __FILE__, msg); abort (); \ } while (0) #endif /* ! MHD_PANIC */ #ifndef MHD_SOCKET_DEFINED /** * MHD_socket is type for socket FDs */ # if defined(MHD_POSIX_SOCKETS) typedef int MHD_socket; # define MHD_INVALID_SOCKET (-1) # elif defined(MHD_WINSOCK_SOCKETS) typedef SOCKET MHD_socket; # define MHD_INVALID_SOCKET (INVALID_SOCKET) # endif /* MHD_WINSOCK_SOCKETS */ # define MHD_SOCKET_DEFINED 1 #endif /* ! MHD_SOCKET_DEFINED */ #ifdef SOCK_CLOEXEC # define SOCK_CLOEXEC_OR_ZERO SOCK_CLOEXEC #else /* ! SOCK_CLOEXEC */ # define SOCK_CLOEXEC_OR_ZERO 0 #endif /* ! SOCK_CLOEXEC */ #ifdef HAVE_SOCK_NONBLOCK # define SOCK_NONBLOCK_OR_ZERO SOCK_NONBLOCK #else /* ! HAVE_SOCK_NONBLOCK */ # define SOCK_NONBLOCK_OR_ZERO 0 #endif /* ! HAVE_SOCK_NONBLOCK */ #ifdef SOCK_NOSIGPIPE # define SOCK_NOSIGPIPE_OR_ZERO SOCK_NOSIGPIPE #else /* ! HAVE_SOCK_NONBLOCK */ # define SOCK_NOSIGPIPE_OR_ZERO 0 #endif /* ! HAVE_SOCK_NONBLOCK */ #ifdef MSG_NOSIGNAL # define MSG_NOSIGNAL_OR_ZERO MSG_NOSIGNAL #else /* ! MSG_NOSIGNAL */ # define MSG_NOSIGNAL_OR_ZERO 0 #endif /* ! MSG_NOSIGNAL */ #if ! defined(SHUT_WR) && defined(SD_SEND) # define SHUT_WR SD_SEND #endif #if ! defined(SHUT_RD) && defined(SD_RECEIVE) # define SHUT_RD SD_RECEIVE #endif #if ! defined(SHUT_RDWR) && defined(SD_BOTH) # define SHUT_RDWR SD_BOTH #endif #if defined(HAVE_ACCEPT4) && (defined(HAVE_SOCK_NONBLOCK) || \ defined(SOCK_CLOEXEC) || defined(SOCK_NOSIGPIPE)) # define USE_ACCEPT4 1 #endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ defined(__OpenBSD__) || defined(__NetBSD__) || \ defined(MHD_WINSOCK_SOCKETS) || defined(__MACH__) || defined(__sun) || \ defined(SOMEBSD) /* Most of OSes inherit nonblocking setting from the listen socket */ #define MHD_ACCEPT_INHERIT_NONBLOCK 1 #endif #if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC) # define USE_EPOLL_CREATE1 1 #endif /* HAVE_EPOLL_CREATE1 && EPOLL_CLOEXEC */ #ifdef TCP_FASTOPEN /** * Default TCP fastopen queue size. */ #define MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT 10 #endif #if defined(TCP_CORK) /** * Value of TCP_CORK or TCP_NOPUSH */ #define MHD_TCP_CORK_NOPUSH TCP_CORK #elif defined(TCP_NOPUSH) /** * Value of TCP_CORK or TCP_NOPUSH */ #define MHD_TCP_CORK_NOPUSH TCP_NOPUSH #endif /* TCP_NOPUSH */ #ifdef MHD_TCP_CORK_NOPUSH #ifdef __linux__ /** * Indicate that reset of TCP_CORK / TCP_NOPUSH push data to the network */ #define _MHD_CORK_RESET_PUSH_DATA 1 /** * Indicate that reset of TCP_CORK / TCP_NOPUSH push data to the network * even if TCP_CORK/TCP_NOPUSH was in switched off state. */ #define _MHD_CORK_RESET_PUSH_DATA_ALWAYS 1 #endif /* __linux__ */ #if (defined(__FreeBSD__) && \ ((__FreeBSD__ + 0) >= 5 || (__FreeBSD_version + 0) >= 450000)) || \ (defined(__FreeBSD_kernel_version) && \ (__FreeBSD_kernel_version + 0) >= 450000) /* FreeBSD pushes data to the network with reset of TCP_NOPUSH * starting from version 4.5. */ /** * Indicate that reset of TCP_CORK / TCP_NOPUSH push data to the network */ #define _MHD_CORK_RESET_PUSH_DATA 1 #endif /* __FreeBSD_version >= 450000 */ #ifdef __OpenBSD__ /* OpenBSD took implementation from FreeBSD */ /** * Indicate that reset of TCP_CORK / TCP_NOPUSH push data to the network */ #define _MHD_CORK_RESET_PUSH_DATA 1 #endif /* __OpenBSD__ */ #endif /* MHD_TCP_CORK_NOPUSH */ #ifdef __linux__ /** * Indicate that set of TCP_NODELAY push data to the network */ #define _MHD_NODELAY_SET_PUSH_DATA 1 /** * Indicate that set of TCP_NODELAY push data to the network even * if TCP_DELAY was already set and regardless of TCP_CORK / TCP_NOPUSH state */ #define _MHD_NODELAY_SET_PUSH_DATA_ALWAYS 1 #endif /* __linux__ */ #ifdef MSG_MORE #ifdef __linux__ /* MSG_MORE signal kernel to buffer outbond data and works like * TCP_CORK per call without actually setting TCP_CORK value. * It's known to work on Linux. Add more OSes if they are compatible. */ /** * Indicate MSG_MORE is usable for buffered send(). */ #define MHD_USE_MSG_MORE 1 #endif /* __linux__ */ #endif /* MSG_MORE */ /** * MHD_SCKT_OPT_BOOL_ is type for bool parameters for setsockopt()/getsockopt() */ #ifdef MHD_POSIX_SOCKETS typedef int MHD_SCKT_OPT_BOOL_; #else /* MHD_WINSOCK_SOCKETS */ typedef BOOL MHD_SCKT_OPT_BOOL_; #endif /* MHD_WINSOCK_SOCKETS */ /** * MHD_SCKT_SEND_SIZE_ is type used to specify size for send and recv * functions */ #if ! defined(MHD_WINSOCK_SOCKETS) typedef size_t MHD_SCKT_SEND_SIZE_; #else typedef int MHD_SCKT_SEND_SIZE_; #endif /** * MHD_SCKT_SEND_MAX_SIZE_ is maximum send()/recv() size value. */ #if ! defined(MHD_WINSOCK_SOCKETS) # define MHD_SCKT_SEND_MAX_SIZE_ SSIZE_MAX #else # define MHD_SCKT_SEND_MAX_SIZE_ INT_MAX #endif /** * MHD_socket_close_(fd) close any FDs (non-W32) / close only socket * FDs (W32). Note that on HP-UNIX, this function may leak the FD if * errno is set to EINTR. Do not use HP-UNIX. * * @param fd descriptor to close * @return boolean true on success (error codes like EINTR and EIO are * counted as success, only EBADF counts as an error!), * boolean false otherwise. */ #if ! defined(MHD_WINSOCK_SOCKETS) # define MHD_socket_close_(fd) ((0 == close ((fd))) || (EBADF != errno)) #else # define MHD_socket_close_(fd) (0 == closesocket ((fd))) #endif /** * MHD_socket_close_chk_(fd) close socket and abort execution * if error is detected. * @param fd socket to close */ #define MHD_socket_close_chk_(fd) do { \ if (! MHD_socket_close_ (fd)) \ MHD_PANIC (_ ("Close socket failed.\n")); \ } while (0) /** * MHD_send4_ is a wrapper for system's send() * @param s the socket to use * @param b the buffer with data to send * @param l the length of data in @a b * @param f the additional flags * @return ssize_t type value */ #define MHD_send4_(s,b,l,f) \ ((ssize_t) send ((s),(const void*) (b),(MHD_SCKT_SEND_SIZE_) (l), \ ((MSG_NOSIGNAL_OR_ZERO) | (f)))) /** * MHD_send_ is a simple wrapper for system's send() * @param s the socket to use * @param b the buffer with data to send * @param l the length of data in @a b * @return ssize_t type value */ #define MHD_send_(s,b,l) MHD_send4_((s),(b),(l), 0) /** * MHD_recv_ is wrapper for system's recv() * @param s the socket to use * @param b the buffer for data to receive * @param l the length of @a b * @return ssize_t type value */ #define MHD_recv_(s,b,l) \ ((ssize_t) recv ((s),(void*) (b),(MHD_SCKT_SEND_SIZE_) (l), 0)) /** * Check whether FD can be added to fd_set with specified FD_SETSIZE. * @param fd the fd to check * @param pset the pointer to fd_set to check or NULL to check * whether FD can be used with fd_sets. * @param setsize the value of FD_SETSIZE. * @return boolean true if FD can be added to fd_set, * boolean false otherwise. */ #if defined(MHD_POSIX_SOCKETS) # define MHD_SCKT_FD_FITS_FDSET_SETSIZE_(fd,pset,setsize) \ ((fd) < ((MHD_socket) (setsize))) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_SCKT_FD_FITS_FDSET_SETSIZE_(fd,pset,setsize) \ ( ((void*) (pset)== (void*) 0) || \ (((fd_set*) (pset))->fd_count < ((unsigned) setsize)) || \ (FD_ISSET ((fd), (pset))) ) #endif /** * Check whether FD can be added to fd_set with current FD_SETSIZE. * @param fd the fd to check * @param pset the pointer to fd_set to check or NULL to check * whether FD can be used with fd_sets. * @return boolean true if FD can be added to fd_set, * boolean false otherwise. */ #define MHD_SCKT_FD_FITS_FDSET_(fd,pset) \ MHD_SCKT_FD_FITS_FDSET_SETSIZE_ ((fd), (pset), FD_SETSIZE) /** * Add FD to fd_set with specified FD_SETSIZE. * @param fd the fd to add * @param pset the valid pointer to fd_set. * @param setsize the value of FD_SETSIZE. * @note To work on W32 with value of FD_SETSIZE different from currently defined value, * system definition of FD_SET() is not used. */ #if defined(MHD_POSIX_SOCKETS) # define MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_(fd,pset,setsize) \ FD_SET ((fd), (pset)) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_(fd,pset,setsize) \ do { \ u_int _i_ = 0; \ fd_set*const _s_ = (fd_set*) (pset); \ while ((_i_ < _s_->fd_count) && ((fd) != _s_->fd_array [_i_])) {++_i_;} \ if ((_i_ == _s_->fd_count)) {_s_->fd_array [_s_->fd_count ++] = (fd);} \ } while (0) #endif /* MHD_SYS_select_ is wrapper macro for system select() function */ #if ! defined(MHD_WINSOCK_SOCKETS) # define MHD_SYS_select_(n,r,w,e,t) select ((n),(r),(w),(e),(t)) #else # define MHD_SYS_select_(n,r,w,e,t) \ ( ( (((void*) (r) == (void*) 0) || ((fd_set*) (r))->fd_count == 0) && \ (((void*) (w) == (void*) 0) || ((fd_set*) (w))->fd_count == 0) && \ (((void*) (e) == (void*) 0) || ((fd_set*) (e))->fd_count == 0) ) ? \ ( ((void*) (t) == (void*) 0) ? 0 : \ (Sleep ((DWORD)((struct timeval*) (t))->tv_sec * 1000 \ + (DWORD)((struct timeval*) (t))->tv_usec / 1000), 0) ) : \ (select ((int) 0,(r),(w),(e),(t))) ) #endif #if defined(HAVE_POLL) /* MHD_sys_poll_ is wrapper macro for system poll() function */ # if ! defined(MHD_WINSOCK_SOCKETS) # define MHD_sys_poll_ poll # else /* MHD_WINSOCK_SOCKETS */ # define MHD_sys_poll_ WSAPoll # endif /* MHD_WINSOCK_SOCKETS */ # ifdef POLLPRI # define MHD_POLLPRI_OR_ZERO POLLPRI # else /* ! POLLPRI */ # define MHD_POLLPRI_OR_ZERO 0 # endif /* ! POLLPRI */ # ifdef POLLRDBAND # define MHD_POLLRDBAND_OR_ZERO POLLRDBAND # else /* ! POLLRDBAND */ # define MHD_POLLRDBAND_OR_ZERO 0 # endif /* ! POLLRDBAND */ # ifdef POLLNVAL # define MHD_POLLNVAL_OR_ZERO POLLNVAL # else /* ! POLLNVAL */ # define MHD_POLLNVAL_OR_ZERO 0 # endif /* ! POLLNVAL */ /* MHD_POLL_EVENTS_ERR_DISC is 'events' mask for errors and disconnect. * Note: Out-of-band data is treated as error. */ # if defined(_WIN32) && ! defined(__CYGWIN__) # define MHD_POLL_EVENTS_ERR_DISC POLLRDBAND # elif defined(__linux__) # define MHD_POLL_EVENTS_ERR_DISC POLLPRI # else /* ! __linux__ */ # define MHD_POLL_EVENTS_ERR_DISC \ (MHD_POLLPRI_OR_ZERO | MHD_POLLRDBAND_OR_ZERO) # endif /* ! __linux__ */ /* MHD_POLL_REVENTS_ERR_DISC is 'revents' mask for errors and disconnect. * Note: Out-of-band data is treated as error. */ # define MHD_POLL_REVENTS_ERR_DISC \ (MHD_POLLPRI_OR_ZERO | MHD_POLLRDBAND_OR_ZERO | MHD_POLLNVAL_OR_ZERO \ | POLLERR | POLLHUP) /* MHD_POLL_REVENTS_ERRROR is 'revents' mask for errors. * Note: Out-of-band data is treated as error. */ # define MHD_POLL_REVENTS_ERRROR \ (MHD_POLLPRI_OR_ZERO | MHD_POLLRDBAND_OR_ZERO | MHD_POLLNVAL_OR_ZERO \ | POLLERR) #endif /* HAVE_POLL */ #define MHD_SCKT_MISSING_ERR_CODE_ 31450 #if defined(MHD_POSIX_SOCKETS) # if defined(EAGAIN) # define MHD_SCKT_EAGAIN_ EAGAIN # elif defined(EWOULDBLOCK) # define MHD_SCKT_EAGAIN_ EWOULDBLOCK # else /* !EAGAIN && !EWOULDBLOCK */ # define MHD_SCKT_EAGAIN_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* !EAGAIN && !EWOULDBLOCK */ # if defined(EWOULDBLOCK) # define MHD_SCKT_EWOULDBLOCK_ EWOULDBLOCK # elif defined(EAGAIN) # define MHD_SCKT_EWOULDBLOCK_ EAGAIN # else /* !EWOULDBLOCK && !EAGAIN */ # define MHD_SCKT_EWOULDBLOCK_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* !EWOULDBLOCK && !EAGAIN */ # ifdef EINTR # define MHD_SCKT_EINTR_ EINTR # else /* ! EINTR */ # define MHD_SCKT_EINTR_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EINTR */ # ifdef ECONNRESET # define MHD_SCKT_ECONNRESET_ ECONNRESET # else /* ! ECONNRESET */ # define MHD_SCKT_ECONNRESET_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ECONNRESET */ # ifdef ECONNABORTED # define MHD_SCKT_ECONNABORTED_ ECONNABORTED # else /* ! ECONNABORTED */ # define MHD_SCKT_ECONNABORTED_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ECONNABORTED */ # ifdef ENOTCONN # define MHD_SCKT_ENOTCONN_ ENOTCONN # else /* ! ENOTCONN */ # define MHD_SCKT_ENOTCONN_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOTCONN */ # ifdef EMFILE # define MHD_SCKT_EMFILE_ EMFILE # else /* ! EMFILE */ # define MHD_SCKT_EMFILE_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EMFILE */ # ifdef ENFILE # define MHD_SCKT_ENFILE_ ENFILE # else /* ! ENFILE */ # define MHD_SCKT_ENFILE_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENFILE */ # ifdef ENOMEM # define MHD_SCKT_ENOMEM_ ENOMEM # else /* ! ENOMEM */ # define MHD_SCKT_ENOMEM_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOMEM */ # ifdef ENOBUFS # define MHD_SCKT_ENOBUFS_ ENOBUFS # else /* ! ENOBUFS */ # define MHD_SCKT_ENOBUFS_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOBUFS */ # ifdef EBADF # define MHD_SCKT_EBADF_ EBADF # else /* ! EBADF */ # define MHD_SCKT_EBADF_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EBADF */ # ifdef ENOTSOCK # define MHD_SCKT_ENOTSOCK_ ENOTSOCK # else /* ! ENOTSOCK */ # define MHD_SCKT_ENOTSOCK_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOTSOCK */ # ifdef EINVAL # define MHD_SCKT_EINVAL_ EINVAL # else /* ! EINVAL */ # define MHD_SCKT_EINVAL_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EINVAL */ # ifdef EPIPE # define MHD_SCKT_EPIPE_ EPIPE # else /* ! EPIPE */ # define MHD_SCKT_EPIPE_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EPIPE */ # ifdef EFAULT # define MHD_SCKT_EFAUL_ EFAULT # else /* ! EFAULT */ # define MHD_SCKT_EFAUL_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EFAULT */ # ifdef ENOSYS # define MHD_SCKT_ENOSYS_ ENOSYS # else /* ! ENOSYS */ # define MHD_SCKT_ENOSYS_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOSYS */ # ifdef ENOPROTOOPT # define MHD_SCKT_ENOPROTOOPT_ ENOPROTOOPT # else /* ! ENOPROTOOPT */ # define MHD_SCKT_ENOPROTOOPT_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOPROTOOPT */ # ifdef ENOTSUP # define MHD_SCKT_ENOTSUP_ ENOTSUP # else /* ! ENOTSUP */ # define MHD_SCKT_ENOTSUP_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENOTSUP */ # ifdef EOPNOTSUPP # define MHD_SCKT_EOPNOTSUPP_ EOPNOTSUPP # else /* ! EOPNOTSUPP */ # define MHD_SCKT_EOPNOTSUPP_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EOPNOTSUPP */ # ifdef EACCES # define MHD_SCKT_EACCESS_ EACCES # else /* ! EACCES */ # define MHD_SCKT_EACCESS_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EACCES */ # ifdef ENETDOWN # define MHD_SCKT_ENETDOWN_ ENETDOWN # else /* ! ENETDOWN */ # define MHD_SCKT_ENETDOWN_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! ENETDOWN */ # ifdef EALREADY # define MHD_SCKT_EALREADY_ EALREADY # else /* ! EALREADY */ # define MHD_SCKT_EALREADY_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EALREADY */ # ifdef EINPROGRESS # define MHD_SCKT_EINPROGRESS_ EINPROGRESS # else /* ! EINPROGRESS */ # define MHD_SCKT_EINPROGRESS_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EINPROGRESS */ # ifdef EISCONN # define MHD_SCKT_EISCONN_ EISCONN # else /* ! EISCONN */ # define MHD_SCKT_EISCONN_ MHD_SCKT_MISSING_ERR_CODE_ # endif /* ! EISCONN */ #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_SCKT_EAGAIN_ WSAEWOULDBLOCK # define MHD_SCKT_EWOULDBLOCK_ WSAEWOULDBLOCK # define MHD_SCKT_EINTR_ WSAEINTR # define MHD_SCKT_ECONNRESET_ WSAECONNRESET # define MHD_SCKT_ECONNABORTED_ WSAECONNABORTED # define MHD_SCKT_ENOTCONN_ WSAENOTCONN # define MHD_SCKT_EMFILE_ WSAEMFILE # define MHD_SCKT_ENFILE_ MHD_SCKT_MISSING_ERR_CODE_ # define MHD_SCKT_ENOMEM_ MHD_SCKT_MISSING_ERR_CODE_ # define MHD_SCKT_ENOBUFS_ WSAENOBUFS # define MHD_SCKT_EBADF_ WSAEBADF # define MHD_SCKT_ENOTSOCK_ WSAENOTSOCK # define MHD_SCKT_EINVAL_ WSAEINVAL # define MHD_SCKT_EPIPE_ WSAESHUTDOWN # define MHD_SCKT_EFAUL_ WSAEFAULT # define MHD_SCKT_ENOSYS_ MHD_SCKT_MISSING_ERR_CODE_ # define MHD_SCKT_ENOPROTOOPT_ WSAENOPROTOOPT # define MHD_SCKT_ENOTSUP_ MHD_SCKT_MISSING_ERR_CODE_ # define MHD_SCKT_EOPNOTSUPP_ WSAEOPNOTSUPP # define MHD_SCKT_EACCESS_ WSAEACCES # define MHD_SCKT_ENETDOWN_ WSAENETDOWN # define MHD_SCKT_EALREADY_ WSAEALREADY # define MHD_SCKT_EINPROGRESS_ WSAEINPROGRESS # define MHD_SCKT_EISCONN_ WSAEISCONN #endif /** * MHD_socket_error_ return system native error code for last socket error. * @return system error code for last socket error. */ #if defined(MHD_POSIX_SOCKETS) # define MHD_socket_get_error_() (errno) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_socket_get_error_() WSAGetLastError () #endif #ifdef MHD_WINSOCK_SOCKETS /* POSIX-W32 sockets compatibility functions */ /** * Return pointer to string description of specified WinSock error * @param err the WinSock error code. * @return pointer to string description of specified WinSock error. */ const char *MHD_W32_strerror_winsock_ (int err); #endif /* MHD_WINSOCK_SOCKETS */ /* MHD_socket_last_strerr_ is description string of specified socket error code */ #if defined(MHD_POSIX_SOCKETS) # define MHD_socket_strerr_(err) strerror ((err)) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_socket_strerr_(err) MHD_W32_strerror_winsock_ ((err)) #endif /* MHD_socket_last_strerr_ is description string of last errno (non-W32) / * description string of last socket error (W32) */ #define MHD_socket_last_strerr_() MHD_socket_strerr_ (MHD_socket_get_error_ ()) /** * MHD_socket_fset_error_() set socket system native error code. */ #if defined(MHD_POSIX_SOCKETS) # define MHD_socket_fset_error_(err) (errno = (err)) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_socket_fset_error_(err) (WSASetLastError ((err))) #endif /** * MHD_socket_try_set_error_() set socket system native error code if * specified code is defined on system. * @return non-zero if specified @a err code is defined on system * and error was set; * zero if specified @a err code is not defined on system * and error was not set. */ #define MHD_socket_try_set_error_(err) \ ( (MHD_SCKT_MISSING_ERR_CODE_ != (err)) ? \ (MHD_socket_fset_error_ ((err)), ! 0) : 0) /** * MHD_socket_set_error_() set socket system native error code to * specified code or replacement code if specified code is not * defined on system. */ #if defined(MHD_POSIX_SOCKETS) # if defined(ENOSYS) # define MHD_socket_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ == (err)) ? \ (errno = ENOSYS) : (errno = (err)) ) # elif defined(EOPNOTSUPP) # define MHD_socket_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ == (err)) ? \ (errno = EOPNOTSUPP) : (errno = \ (err)) ) # elif defined(EFAULT) # define MHD_socket_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ == (err)) ? \ (errno = EFAULT) : (errno = (err)) ) # elif defined(EINVAL) # define MHD_socket_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ == (err)) ? \ (errno = EINVAL) : (errno = (err)) ) # else /* !EOPNOTSUPP && !EFAULT && !EINVAL */ # warning \ No suitable replacement for missing socket error code is found. Edit this file and add replacement code which is defined on system. # define MHD_socket_set_error_(err) (errno = (err)) # endif /* !EOPNOTSUPP && !EFAULT && !EINVAL*/ #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_socket_set_error_(err) ( (MHD_SCKT_MISSING_ERR_CODE_ == (err)) ? \ (WSASetLastError ((WSAEOPNOTSUPP))) : \ (WSASetLastError ((err))) ) #endif /** * Check whether given socket error is equal to specified system * native MHD_SCKT_E*_ code. * If platform don't have specific error code, result is * always boolean false. * @return boolean true if @a code is real error code and * @a err equals to MHD_SCKT_E*_ @a code; * boolean false otherwise */ #define MHD_SCKT_ERR_IS_(err,code) \ ( (MHD_SCKT_MISSING_ERR_CODE_ != (code)) && ((code) == (err)) ) /** * Check whether last socket error is equal to specified system * native MHD_SCKT_E*_ code. * If platform don't have specific error code, result is * always boolean false. * @return boolean true if @a code is real error code and * last socket error equals to MHD_SCKT_E*_ @a code; * boolean false otherwise */ #define MHD_SCKT_LAST_ERR_IS_(code) \ MHD_SCKT_ERR_IS_ (MHD_socket_get_error_ (), (code)) /* Specific error code checks */ /** * Check whether given socket error is equal to system's * socket error codes for EINTR. * @return boolean true if @a err is equal to sockets' EINTR code; * boolean false otherwise. */ #define MHD_SCKT_ERR_IS_EINTR_(err) MHD_SCKT_ERR_IS_ ((err),MHD_SCKT_EINTR_) /** * Check whether given socket error is equal to system's * socket error codes for EAGAIN or EWOULDBLOCK. * @return boolean true if @a err is equal to sockets' EAGAIN or EWOULDBLOCK codes; * boolean false otherwise. */ #if MHD_SCKT_EAGAIN_ == MHD_SCKT_EWOULDBLOCK_ # define MHD_SCKT_ERR_IS_EAGAIN_(err) MHD_SCKT_ERR_IS_ ((err),MHD_SCKT_EAGAIN_) #else /* MHD_SCKT_EAGAIN_ != MHD_SCKT_EWOULDBLOCK_ */ # define MHD_SCKT_ERR_IS_EAGAIN_(err) \ ( MHD_SCKT_ERR_IS_ ((err), MHD_SCKT_EAGAIN_) || \ MHD_SCKT_ERR_IS_ ((err), MHD_SCKT_EWOULDBLOCK_) ) #endif /* MHD_SCKT_EAGAIN_ != MHD_SCKT_EWOULDBLOCK_ */ /** * Check whether given socket error is any kind of "low resource" error. * @return boolean true if @a err is any kind of "low resource" error, * boolean false otherwise. */ #define MHD_SCKT_ERR_IS_LOW_RESOURCES_(err) \ ( MHD_SCKT_ERR_IS_ ((err), MHD_SCKT_EMFILE_) || \ MHD_SCKT_ERR_IS_ ((err), MHD_SCKT_ENFILE_) || \ MHD_SCKT_ERR_IS_ ((err), MHD_SCKT_ENOMEM_) || \ MHD_SCKT_ERR_IS_ ((err), MHD_SCKT_ENOBUFS_) ) /** * Check whether is given socket error is type of "incoming connection * was disconnected before 'accept()' is called". * @return boolean true is @a err match described socket error code, * boolean false otherwise. */ #if defined(MHD_POSIX_SOCKETS) # define MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_(err) \ MHD_SCKT_ERR_IS_ ((err), MHD_SCKT_ECONNABORTED_) #elif defined(MHD_WINSOCK_SOCKETS) # define MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_(err) \ MHD_SCKT_ERR_IS_ ((err), MHD_SCKT_ECONNRESET_) #endif /** * Check whether is given socket error is type of "connection was terminated * by remote side". * @return boolean true is @a err match described socket error code, * boolean false otherwise. */ #define MHD_SCKT_ERR_IS_REMOTE_DISCNN_(err) \ ( MHD_SCKT_ERR_IS_ ((err), MHD_SCKT_ECONNRESET_) || \ MHD_SCKT_ERR_IS_ ((err), MHD_SCKT_ECONNABORTED_) ) /* Specific error code set */ /** * Set socket's error code to ENOMEM or equivalent if ENOMEM is not * available on platform. */ #if MHD_SCKT_MISSING_ERR_CODE_ != MHD_SCKT_ENOMEM_ # define MHD_socket_set_error_to_ENOMEM() \ MHD_socket_set_error_ (MHD_SCKT_ENOMEM_) #elif MHD_SCKT_MISSING_ERR_CODE_ != MHD_SCKT_ENOBUFS_ # define MHD_socket_set_error_to_ENOMEM() \ MHD_socket_set_error_ (MHD_SCKT_ENOBUFS_) #else # warning \ No suitable replacement for ENOMEM error codes is found. Edit this file and add replacement code which is defined on system. # define MHD_socket_set_error_to_ENOMEM() MHD_socket_set_error_ ( \ MHD_SCKT_ENOMEM_) #endif /* Socket functions */ #if defined(AF_LOCAL) # define MHD_SCKT_LOCAL AF_LOCAL #elif defined(AF_UNIX) # define MHD_SCKT_LOCAL AF_UNIX #endif /* AF_UNIX */ #if defined(MHD_POSIX_SOCKETS) && defined(MHD_SCKT_LOCAL) # define MHD_socket_pair_(fdarr) \ (! socketpair (MHD_SCKT_LOCAL, SOCK_STREAM, 0, (fdarr))) # if defined(HAVE_SOCK_NONBLOCK) # define MHD_socket_pair_nblk_(fdarr) \ (! socketpair (MHD_SCKT_LOCAL, SOCK_STREAM | SOCK_NONBLOCK, 0, (fdarr))) # endif /* HAVE_SOCK_NONBLOCK*/ #elif defined(MHD_WINSOCK_SOCKETS) /** * Create pair of mutually connected TCP/IP sockets on loopback address * @param sockets_pair array to receive resulted sockets * @param non_blk if set to non-zero value, sockets created in non-blocking mode * otherwise sockets will be in blocking mode * @return non-zero if succeeded, zero otherwise */ int MHD_W32_socket_pair_ (SOCKET sockets_pair[2], int non_blk); # define MHD_socket_pair_(fdarr) MHD_W32_socket_pair_ ((fdarr), 0) # define MHD_socket_pair_nblk_(fdarr) MHD_W32_socket_pair_ ((fdarr), 1) #endif /** * Add @a fd to the @a set. If @a fd is * greater than @a max_fd, set @a max_fd to @a fd. * * @param fd file descriptor to add to the @a set * @param set set to modify * @param max_fd maximum value to potentially update * @param fd_setsize value of FD_SETSIZE * @return non-zero if succeeded, zero otherwise */ int MHD_add_to_fd_set_ (MHD_socket fd, fd_set *set, MHD_socket *max_fd, int fd_setsize); /** * Change socket options to be non-blocking. * * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise */ int MHD_socket_nonblocking_ (MHD_socket sock); /** * Disable Nagle's algorithm on @a sock. This is what we do by default for * all TCP sockets in MHD, unless the platform does not support the MSG_MORE * or MSG_CORK or MSG_NOPUSH options. * * @param sock socket to manipulate * @param on value to use * @return 0 on success */ int MHD_socket_set_nodelay_ (MHD_socket sock, bool on); /** * Change socket options to be non-inheritable. * * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise * @warning Does not set socket error on W32. */ int MHD_socket_noninheritable_ (MHD_socket sock); #if defined(SOL_SOCKET) && defined(SO_NOSIGPIPE) static const int _MHD_socket_int_one = 1; /** * Change socket options to no signal on remote disconnect. * * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise */ #define MHD_socket_nosignal_(sock) \ (! setsockopt ((sock),SOL_SOCKET,SO_NOSIGPIPE,&_MHD_socket_int_one, \ sizeof(_MHD_socket_int_one))) #endif /* SOL_SOCKET && SO_NOSIGPIPE */ #if defined(MHD_socket_nosignal_) || defined(MSG_NOSIGNAL) /** * Indicate that SIGPIPE can be suppressed by MHD for normal send() by flags * or socket options. * If this macro is undefined, MHD cannot suppress SIGPIPE for socket functions * so sendfile() or writev() calls are avoided in application threads. */ #define MHD_SEND_SPIPE_SUPPRESS_POSSIBLE 1 #endif /* MHD_WINSOCK_SOCKETS || MHD_socket_nosignal_ || MSG_NOSIGNAL */ #if ! defined(MHD_WINSOCK_SOCKETS) /** * Indicate that suppression of SIGPIPE is required. */ #define MHD_SEND_SPIPE_SUPPRESS_NEEDED 1 #endif /** * Create a listen socket, with noninheritable flag if possible. * * @param pf protocol family to use * @return created socket or MHD_INVALID_SOCKET in case of errors */ MHD_socket MHD_socket_create_listen_ (int pf); #endif /* ! MHD_SOCKETS_H */ libmicrohttpd-1.0.1/src/microhttpd/test_helpers.h0000644000175000017500000000545414441373361015672 /* This file is part of libmicrohttpd Copyright (C) 2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_helpers.h * @brief Static functions and macros helpers for testsuite. * @author Karlson2k (Evgeny Grin) */ #include /** * Check whether program name contains specific @a marker string. * Only last component in pathname is checked for marker presence, * all leading directories names (if any) are ignored. Directories * separators are handled correctly on both non-W32 and W32 * platforms. * @param prog_name program name, may include path * @param marker marker to look for. * @return zero if any parameter is NULL or empty string or * @a prog_name ends with slash or @a marker is not found in * program name, non-zero if @a maker is found in program * name. */ static int has_in_name (const char *prog_name, const char *marker) { size_t name_pos; size_t pos; if (! prog_name || ! marker || ! prog_name[0] || ! marker[0]) return 0; pos = 0; name_pos = 0; while (prog_name[pos]) { if ('/' == prog_name[pos]) name_pos = pos + 1; #if defined(_WIN32) || defined(__CYGWIN__) else if ('\\' == prog_name[pos]) name_pos = pos + 1; #endif /* _WIN32 || __CYGWIN__ */ pos++; } if (name_pos == pos) return 0; return strstr (prog_name + name_pos, marker) != (char *) 0; } /** * Check whether one of strings in array is equal to @a param. * String @a argv[0] is ignored. * @param argc number of strings in @a argv, as passed to main function * @param argv array of strings, as passed to main function * @param param parameter to look for. * @return zero if @a argv is NULL, @a param is NULL or empty string, * @a argc is less then 2 or @a param is not found in @a argv, * non-zero if one of strings in @a argv is equal to @a param. */ static int has_param (int argc, char *const argv[], const char *param) { int i; if (! argv || ! param || ! param[0]) return 0; for (i = 1; i < argc; i++) { if (argv[i] && (strcmp (argv[i], param) == 0) ) return ! 0; } return 0; } libmicrohttpd-1.0.1/src/microhttpd/mhd_align.h0000644000175000017500000000570514556705750015122 /* This file is part of libmicrohttpd Copyright (C) 2021-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/mhd_align.h * @brief types alignment macros * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_ALIGN_H #define MHD_ALIGN_H 1 #include "mhd_options.h" #include #ifdef HAVE_STDDEF_H #include #endif #ifdef HAVE_C_ALIGNOF #ifdef HAVE_STDALIGN_H #include #endif /* HAVE_STDALIGN_H */ #define _MHD_ALIGNOF(type) alignof(type) #endif /* HAVE_C_ALIGNOF */ #ifndef _MHD_ALIGNOF #if defined(_MSC_VER) && ! defined(__clang__) && _MSC_VER >= 1700 #define _MHD_ALIGNOF(type) __alignof(type) #endif /* _MSC_VER >= 1700 */ #endif /* !_MHD_ALIGNOF */ #ifdef _MHD_ALIGNOF #if (defined(__GNUC__) && __GNUC__ < 4 && __GNUC_MINOR__ < 9 && \ ! defined(__clang__)) || \ (defined(__clang__) && __clang_major__ < 8) || \ (defined(__clang__) && __clang_major__ < 11 && \ defined(__apple_build_version__)) /* GCC before 4.9 and clang before 8.0 have incorrect implementation of 'alignof()' which returns preferred alignment instead of minimal required alignment */ #define _MHD_ALIGNOF_UNRELIABLE 1 #endif #if defined(_MSC_VER) && ! defined(__clang__) && _MSC_VER < 1900 /* MSVC has the same problem as old GCC versions: '__alignof()' may return "preferred" alignment instead of "required". */ #define _MHD_ALIGNOF_UNRELIABLE 1 #endif /* _MSC_VER < 1900 */ #endif /* _MHD_ALIGNOF */ #ifdef offsetof #define _MHD_OFFSETOF(strct, membr) offsetof(strct, membr) #else /* ! offsetof */ #define _MHD_OFFSETOF(strct, membr) (size_t)(((char*)&(((strct*)0)->membr)) - \ ((char*)((strct*)0))) #endif /* ! offsetof */ /* Provide a limited set of alignment macros */ /* The set could be extended as needed */ #if defined(_MHD_ALIGNOF) && ! defined(_MHD_ALIGNOF_UNRELIABLE) #define _MHD_UINT32_ALIGN _MHD_ALIGNOF(uint32_t) #define _MHD_UINT64_ALIGN _MHD_ALIGNOF(uint64_t) #else /* ! _MHD_ALIGNOF */ struct _mhd_dummy_uint32_offset_test { char dummy; uint32_t ui32; }; #define _MHD_UINT32_ALIGN \ _MHD_OFFSETOF(struct _mhd_dummy_uint32_offset_test, ui32) struct _mhd_dummy_uint64_offset_test { char dummy; uint64_t ui64; }; #define _MHD_UINT64_ALIGN \ _MHD_OFFSETOF(struct _mhd_dummy_uint64_offset_test, ui64) #endif /* ! _MHD_ALIGNOF */ #endif /* ! MHD_ALIGN_H */ libmicrohttpd-1.0.1/src/microhttpd/sha256_ext.h0000644000175000017500000000567014441373361015061 /* This file is part of GNU libmicrohttpd Copyright (C) 2022 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GNU libmicrohttpd. If not, see . */ /** * @file microhttpd/sha256_ext.h * @brief Wrapper declarations for SHA-256 calculation performed by TLS library * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_SHA256_EXT_H #define MHD_SHA256_EXT_H 1 #include "mhd_options.h" #include #ifdef HAVE_STDDEF_H #include /* for size_t */ #endif /* HAVE_STDDEF_H */ /** * Size of SHA-256 resulting digest in bytes * This is the final digest size, not intermediate hash. */ #define SHA256_DIGEST_SIZE (32) /* Actual declaration is in GnuTLS lib header */ struct hash_hd_st; /** * Indicates that struct Sha256CtxExt has 'ext_error' */ #define MHD_SHA256_HAS_EXT_ERROR 1 /** * SHA-256 calculation context */ struct Sha256CtxExt { struct hash_hd_st *handle; /**< Hash calculation handle */ int ext_error; /**< Non-zero if external error occurs during init or hashing */ }; /** * Indicates that MHD_SHA256_init_one_time() function is present. */ #define MHD_SHA256_HAS_INIT_ONE_TIME 1 /** * Initialise structure for SHA-256 calculation, allocate resources. * * This function must not be called more than one time for @a ctx. * * @param ctx the calculation context */ void MHD_SHA256_init_one_time (struct Sha256CtxExt *ctx); /** * SHA-256 process portion of bytes. * * @param ctx the calculation context * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_SHA256_update (struct Sha256CtxExt *ctx, const uint8_t *data, size_t length); /** * Indicates that MHD_SHA256_finish_reset() function is available */ #define MHD_SHA256_HAS_FINISH_RESET 1 /** * Finalise SHA-256 calculation, return digest, reset hash calculation. * * @param ctx the calculation context * @param[out] digest set to the hash, must be #SHA256_DIGEST_SIZE bytes */ void MHD_SHA256_finish_reset (struct Sha256CtxExt *ctx, uint8_t digest[SHA256_DIGEST_SIZE]); /** * Indicates that MHD_SHA256_deinit() function is present */ #define MHD_SHA256_HAS_DEINIT 1 /** * Free allocated resources. * * @param ctx the calculation context */ void MHD_SHA256_deinit (struct Sha256CtxExt *ctx); #endif /* MHD_SHA256_EXT_H */ libmicrohttpd-1.0.1/src/microhttpd/Makefile.in0000644000175000017500000067173314566140141015072 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # This Makefile.am is in the public domain VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @W32_SHARED_LIB_EXP_TRUE@am__append_1 = $(lt_cv_objdir)/libmicrohttpd.lib $(lt_cv_objdir)/libmicrohttpd.def @W32_SHARED_LIB_EXP_TRUE@am__append_2 = $(lt_cv_objdir)/libmicrohttpd.lib $(lt_cv_objdir)/libmicrohttpd.def $(lt_cv_objdir)/libmicrohttpd.exp @USE_EXPORT_FILE_TRUE@@W32_SHARED_LIB_EXP_TRUE@am__append_3 = $(lt_cv_objdir)/libmicrohttpd.exp @W32_STATIC_LIB_TRUE@am__append_4 = $(lt_cv_objdir)/libmicrohttpd-static.lib @W32_STATIC_LIB_TRUE@am__append_5 = $(lt_cv_objdir)/libmicrohttpd-static.lib @USE_POSIX_THREADS_TRUE@am__append_6 = \ @USE_POSIX_THREADS_TRUE@ mhd_threads.c mhd_threads.h \ @USE_POSIX_THREADS_TRUE@ mhd_locks.h @USE_W32_THREADS_TRUE@am__append_7 = \ @USE_W32_THREADS_TRUE@ mhd_threads.c mhd_threads.h \ @USE_W32_THREADS_TRUE@ mhd_locks.h @NEED_SYS_FD_SET_SIZE_VALUE_TRUE@am__append_8 = \ @NEED_SYS_FD_SET_SIZE_VALUE_TRUE@ sysfdsetsize.c @HAVE_W32_TRUE@am__append_9 = $(MHD_DLL_RES_LO) @USE_COVERAGE_TRUE@am__append_10 = --coverage @MHD_USE_SYS_TSEARCH_FALSE@am__append_11 = \ @MHD_USE_SYS_TSEARCH_FALSE@ tsearch.c tsearch.h @HAVE_POSTPROCESSOR_TRUE@am__append_12 = \ @HAVE_POSTPROCESSOR_TRUE@ postprocessor.c postprocessor.h @HAVE_ANYAUTH_TRUE@am__append_13 = \ @HAVE_ANYAUTH_TRUE@ gen_auth.c gen_auth.h @ENABLE_DAUTH_TRUE@am__append_14 = \ @ENABLE_DAUTH_TRUE@ digestauth.c digestauth.h \ @ENABLE_DAUTH_TRUE@ mhd_bithelpers.h mhd_byteorder.h mhd_align.h @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@am__append_15 = \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_TRUE@ mhd_md5_wrap.h @ENABLE_DAUTH_TRUE@@ENABLE_MD5_EXT_FALSE@@ENABLE_MD5_TRUE@am__append_16 = \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_EXT_FALSE@@ENABLE_MD5_TRUE@ md5.c md5.h @ENABLE_DAUTH_TRUE@@ENABLE_MD5_EXT_TRUE@@ENABLE_MD5_TRUE@am__append_17 = \ @ENABLE_DAUTH_TRUE@@ENABLE_MD5_EXT_TRUE@@ENABLE_MD5_TRUE@ md5_ext.c md5_ext.h @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@am__append_18 = \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_TRUE@ mhd_sha256_wrap.h @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_EXT_FALSE@@ENABLE_SHA256_TRUE@am__append_19 = \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_EXT_FALSE@@ENABLE_SHA256_TRUE@ sha256.c sha256.h @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_EXT_TRUE@@ENABLE_SHA256_TRUE@am__append_20 = \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_EXT_TRUE@@ENABLE_SHA256_TRUE@ sha256_ext.c sha256_ext.h @ENABLE_DAUTH_TRUE@@ENABLE_SHA512_256_TRUE@am__append_21 = \ @ENABLE_DAUTH_TRUE@@ENABLE_SHA512_256_TRUE@ sha512_256.c sha512_256.h @ENABLE_BAUTH_TRUE@am__append_22 = \ @ENABLE_BAUTH_TRUE@ basicauth.c basicauth.h @ENABLE_HTTPS_TRUE@am__append_23 = \ @ENABLE_HTTPS_TRUE@ connection_https.c connection_https.h check_PROGRAMS = test_str_compare$(EXEEXT) test_str_to_value$(EXEEXT) \ test_str_from_value$(EXEEXT) test_str_token$(EXEEXT) \ test_str_token_remove$(EXEEXT) test_str_tokens_remove$(EXEEXT) \ test_str_pct$(EXEEXT) test_str_bin_hex$(EXEEXT) \ test_http_reasons$(EXEEXT) test_sha1$(EXEEXT) \ test_start_stop$(EXEEXT) test_daemon$(EXEEXT) \ test_response_entries$(EXEEXT) test_postprocessor_md$(EXEEXT) \ test_client_put_shutdown$(EXEEXT) \ test_client_put_close$(EXEEXT) \ test_client_put_hard_close$(EXEEXT) \ test_client_put_steps_shutdown$(EXEEXT) \ test_client_put_steps_close$(EXEEXT) \ test_client_put_steps_hard_close$(EXEEXT) \ test_client_put_chunked_shutdown$(EXEEXT) \ test_client_put_chunked_close$(EXEEXT) \ test_client_put_chunked_hard_close$(EXEEXT) \ test_client_put_chunked_steps_shutdown$(EXEEXT) \ test_client_put_chunked_steps_close$(EXEEXT) \ test_client_put_chunked_steps_hard_close$(EXEEXT) \ test_options$(EXEEXT) test_mhd_version$(EXEEXT) \ test_set_panic$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) \ $(am__EXEEXT_3) $(am__EXEEXT_4) $(am__EXEEXT_5) \ $(am__EXEEXT_6) $(am__EXEEXT_7) $(am__EXEEXT_8) \ $(am__EXEEXT_9) $(am__EXEEXT_10) $(am__EXEEXT_11) \ $(am__EXEEXT_12) @ENABLE_MD5_TRUE@am__append_24 = \ @ENABLE_MD5_TRUE@ test_md5 @ENABLE_SHA256_TRUE@am__append_25 = \ @ENABLE_SHA256_TRUE@ test_sha256 @ENABLE_SHA512_256_TRUE@am__append_26 = \ @ENABLE_SHA512_256_TRUE@ test_sha512_256 @ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@@USE_THREADS_TRUE@am__append_27 = test_upgrade test_upgrade_large test_upgrade_vlarge @ENABLE_HTTPS_TRUE@@ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@@USE_THREADS_TRUE@@USE_UPGRADE_TLS_TESTS_TRUE@am__append_28 = test_upgrade_tls test_upgrade_large_tls test_upgrade_vlarge_tls @HAVE_POSTPROCESSOR_TRUE@am__append_29 = \ @HAVE_POSTPROCESSOR_TRUE@ test_postprocessor \ @HAVE_POSTPROCESSOR_TRUE@ test_postprocessor_large \ @HAVE_POSTPROCESSOR_TRUE@ test_postprocessor_amp # Do not test trigger of select by shutdown of listen socket # on Cygwin as this ability is deliberately ignored on Cygwin # to improve compatibility with core OS. @CYGWIN_TARGET_FALSE@@HAVE_LISTEN_SHUTDOWN_TRUE@@HAVE_POSIX_THREADS_TRUE@am__append_30 = \ @CYGWIN_TARGET_FALSE@@HAVE_LISTEN_SHUTDOWN_TRUE@@HAVE_POSIX_THREADS_TRUE@ test_shutdown_select \ @CYGWIN_TARGET_FALSE@@HAVE_LISTEN_SHUTDOWN_TRUE@@HAVE_POSIX_THREADS_TRUE@ test_shutdown_poll @CYGWIN_TARGET_FALSE@@HAVE_LISTEN_SHUTDOWN_FALSE@@HAVE_POSIX_THREADS_TRUE@am__append_31 = \ @CYGWIN_TARGET_FALSE@@HAVE_LISTEN_SHUTDOWN_FALSE@@HAVE_POSIX_THREADS_TRUE@ test_shutdown_select_ignore \ @CYGWIN_TARGET_FALSE@@HAVE_LISTEN_SHUTDOWN_FALSE@@HAVE_POSIX_THREADS_TRUE@ test_shutdown_poll_ignore @HAVE_ANYAUTH_TRUE@@HAVE_MESSAGES_TRUE@am__append_32 = \ @HAVE_ANYAUTH_TRUE@@HAVE_MESSAGES_TRUE@ test_auth_parse @ENABLE_DAUTH_TRUE@am__append_33 = \ @ENABLE_DAUTH_TRUE@ test_str_quote \ @ENABLE_DAUTH_TRUE@ test_dauth_userdigest \ @ENABLE_DAUTH_TRUE@ test_dauth_userhash @ENABLE_BAUTH_TRUE@am__append_34 = \ @ENABLE_BAUTH_TRUE@ test_str_base64 @HEAVY_TESTS_TRUE@@TESTS_STRESS_OS_TRUE@am__append_35 = \ @HEAVY_TESTS_TRUE@@TESTS_STRESS_OS_TRUE@ test_client_put_hard_close_stress_os \ @HEAVY_TESTS_TRUE@@TESTS_STRESS_OS_TRUE@ test_client_put_steps_hard_close_stress_os \ @HEAVY_TESTS_TRUE@@TESTS_STRESS_OS_TRUE@ test_client_put_chunked_steps_hard_close_stress_os @USE_POSIX_THREADS_TRUE@am__append_36 = \ @USE_POSIX_THREADS_TRUE@ $(PTHREAD_CFLAGS) @USE_POSIX_THREADS_TRUE@am__append_37 = \ @USE_POSIX_THREADS_TRUE@ $(PTHREAD_LIBS) @USE_POSIX_THREADS_TRUE@am__append_38 = \ @USE_POSIX_THREADS_TRUE@ $(AM_CFLAGS) $(PTHREAD_CFLAGS) @USE_POSIX_THREADS_TRUE@am__append_39 = \ @USE_POSIX_THREADS_TRUE@ $(PTHREAD_LIBS) @USE_POSIX_THREADS_TRUE@am__append_40 = \ @USE_POSIX_THREADS_TRUE@ $(PTHREAD_CFLAGS) @USE_POSIX_THREADS_TRUE@am__append_41 = \ @USE_POSIX_THREADS_TRUE@ $(PTHREAD_LIBS) @USE_POSIX_THREADS_TRUE@am__append_42 = \ @USE_POSIX_THREADS_TRUE@ $(AM_CFLAGS) $(PTHREAD_CFLAGS) @USE_POSIX_THREADS_TRUE@am__append_43 = \ @USE_POSIX_THREADS_TRUE@ $(PTHREAD_LIBS) @ENABLE_MD5_EXT_FALSE@am__append_44 = \ @ENABLE_MD5_EXT_FALSE@ md5.c md5.h mhd_bithelpers.h mhd_byteorder.h mhd_align.h @ENABLE_MD5_EXT_TRUE@am__append_45 = \ @ENABLE_MD5_EXT_TRUE@ md5_ext.c md5_ext.h @ENABLE_SHA256_EXT_FALSE@am__append_46 = \ @ENABLE_SHA256_EXT_FALSE@ sha256.c sha256.h mhd_bithelpers.h mhd_byteorder.h mhd_align.h @ENABLE_SHA256_EXT_TRUE@am__append_47 = \ @ENABLE_SHA256_EXT_TRUE@ sha256_ext.c sha256_ext.h subdir = src/microhttpd ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = microhttpd_dll_res.rc CONFIG_CLEAN_VPATH_FILES = @ENABLE_MD5_TRUE@am__EXEEXT_1 = test_md5$(EXEEXT) @ENABLE_SHA256_TRUE@am__EXEEXT_2 = test_sha256$(EXEEXT) @ENABLE_SHA512_256_TRUE@am__EXEEXT_3 = test_sha512_256$(EXEEXT) @ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@@USE_THREADS_TRUE@am__EXEEXT_4 = test_upgrade$(EXEEXT) \ @ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@@USE_THREADS_TRUE@ test_upgrade_large$(EXEEXT) \ @ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@@USE_THREADS_TRUE@ test_upgrade_vlarge$(EXEEXT) @ENABLE_HTTPS_TRUE@@ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@@USE_THREADS_TRUE@@USE_UPGRADE_TLS_TESTS_TRUE@am__EXEEXT_5 = test_upgrade_tls$(EXEEXT) \ @ENABLE_HTTPS_TRUE@@ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@@USE_THREADS_TRUE@@USE_UPGRADE_TLS_TESTS_TRUE@ test_upgrade_large_tls$(EXEEXT) \ @ENABLE_HTTPS_TRUE@@ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@@USE_THREADS_TRUE@@USE_UPGRADE_TLS_TESTS_TRUE@ test_upgrade_vlarge_tls$(EXEEXT) @HAVE_POSTPROCESSOR_TRUE@am__EXEEXT_6 = test_postprocessor$(EXEEXT) \ @HAVE_POSTPROCESSOR_TRUE@ test_postprocessor_large$(EXEEXT) \ @HAVE_POSTPROCESSOR_TRUE@ test_postprocessor_amp$(EXEEXT) @CYGWIN_TARGET_FALSE@@HAVE_LISTEN_SHUTDOWN_TRUE@@HAVE_POSIX_THREADS_TRUE@am__EXEEXT_7 = test_shutdown_select$(EXEEXT) \ @CYGWIN_TARGET_FALSE@@HAVE_LISTEN_SHUTDOWN_TRUE@@HAVE_POSIX_THREADS_TRUE@ test_shutdown_poll$(EXEEXT) @CYGWIN_TARGET_FALSE@@HAVE_LISTEN_SHUTDOWN_FALSE@@HAVE_POSIX_THREADS_TRUE@am__EXEEXT_8 = test_shutdown_select_ignore$(EXEEXT) \ @CYGWIN_TARGET_FALSE@@HAVE_LISTEN_SHUTDOWN_FALSE@@HAVE_POSIX_THREADS_TRUE@ test_shutdown_poll_ignore$(EXEEXT) @HAVE_ANYAUTH_TRUE@@HAVE_MESSAGES_TRUE@am__EXEEXT_9 = test_auth_parse$(EXEEXT) @ENABLE_DAUTH_TRUE@am__EXEEXT_10 = test_str_quote$(EXEEXT) \ @ENABLE_DAUTH_TRUE@ test_dauth_userdigest$(EXEEXT) \ @ENABLE_DAUTH_TRUE@ test_dauth_userhash$(EXEEXT) @ENABLE_BAUTH_TRUE@am__EXEEXT_11 = test_str_base64$(EXEEXT) @HEAVY_TESTS_TRUE@@TESTS_STRESS_OS_TRUE@am__EXEEXT_12 = test_client_put_hard_close_stress_os$(EXEEXT) \ @HEAVY_TESTS_TRUE@@TESTS_STRESS_OS_TRUE@ test_client_put_steps_hard_close_stress_os$(EXEEXT) \ @HEAVY_TESTS_TRUE@@TESTS_STRESS_OS_TRUE@ test_client_put_chunked_steps_hard_close_stress_os$(EXEEXT) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = libmicrohttpd_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__append_9) am__libmicrohttpd_la_SOURCES_DIST = connection.c connection.h \ reason_phrase.c daemon.c internal.c internal.h memorypool.c \ memorypool.h mhd_mono_clock.c mhd_mono_clock.h mhd_limits.h \ sysfdsetsize.h mhd_str.c mhd_str.h mhd_str_types.h mhd_send.h \ mhd_send.c mhd_assert.h mhd_sockets.c mhd_sockets.h mhd_itc.c \ mhd_itc.h mhd_itc_types.h mhd_compat.c mhd_compat.h \ mhd_panic.c mhd_panic.h response.c response.h mhd_threads.c \ mhd_threads.h mhd_locks.h sysfdsetsize.c tsearch.c tsearch.h \ postprocessor.c postprocessor.h gen_auth.c gen_auth.h \ digestauth.c digestauth.h mhd_bithelpers.h mhd_byteorder.h \ mhd_align.h mhd_md5_wrap.h md5.c md5.h md5_ext.c md5_ext.h \ mhd_sha256_wrap.h sha256.c sha256.h sha256_ext.c sha256_ext.h \ sha512_256.c sha512_256.h basicauth.c basicauth.h \ connection_https.c connection_https.h @USE_POSIX_THREADS_TRUE@am__objects_1 = \ @USE_POSIX_THREADS_TRUE@ libmicrohttpd_la-mhd_threads.lo @USE_W32_THREADS_TRUE@am__objects_2 = libmicrohttpd_la-mhd_threads.lo @NEED_SYS_FD_SET_SIZE_VALUE_TRUE@am__objects_3 = libmicrohttpd_la-sysfdsetsize.lo @MHD_USE_SYS_TSEARCH_FALSE@am__objects_4 = \ @MHD_USE_SYS_TSEARCH_FALSE@ libmicrohttpd_la-tsearch.lo @HAVE_POSTPROCESSOR_TRUE@am__objects_5 = \ @HAVE_POSTPROCESSOR_TRUE@ libmicrohttpd_la-postprocessor.lo @HAVE_ANYAUTH_TRUE@am__objects_6 = libmicrohttpd_la-gen_auth.lo @ENABLE_DAUTH_TRUE@am__objects_7 = libmicrohttpd_la-digestauth.lo am__objects_8 = @ENABLE_DAUTH_TRUE@@ENABLE_MD5_EXT_FALSE@@ENABLE_MD5_TRUE@am__objects_9 = libmicrohttpd_la-md5.lo @ENABLE_DAUTH_TRUE@@ENABLE_MD5_EXT_TRUE@@ENABLE_MD5_TRUE@am__objects_10 = libmicrohttpd_la-md5_ext.lo @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_EXT_FALSE@@ENABLE_SHA256_TRUE@am__objects_11 = libmicrohttpd_la-sha256.lo @ENABLE_DAUTH_TRUE@@ENABLE_SHA256_EXT_TRUE@@ENABLE_SHA256_TRUE@am__objects_12 = libmicrohttpd_la-sha256_ext.lo @ENABLE_DAUTH_TRUE@@ENABLE_SHA512_256_TRUE@am__objects_13 = libmicrohttpd_la-sha512_256.lo @ENABLE_BAUTH_TRUE@am__objects_14 = libmicrohttpd_la-basicauth.lo @ENABLE_HTTPS_TRUE@am__objects_15 = \ @ENABLE_HTTPS_TRUE@ libmicrohttpd_la-connection_https.lo am_libmicrohttpd_la_OBJECTS = libmicrohttpd_la-connection.lo \ libmicrohttpd_la-reason_phrase.lo libmicrohttpd_la-daemon.lo \ libmicrohttpd_la-internal.lo libmicrohttpd_la-memorypool.lo \ libmicrohttpd_la-mhd_mono_clock.lo libmicrohttpd_la-mhd_str.lo \ libmicrohttpd_la-mhd_send.lo libmicrohttpd_la-mhd_sockets.lo \ libmicrohttpd_la-mhd_itc.lo libmicrohttpd_la-mhd_compat.lo \ libmicrohttpd_la-mhd_panic.lo libmicrohttpd_la-response.lo \ $(am__objects_1) $(am__objects_2) $(am__objects_3) \ $(am__objects_4) $(am__objects_5) $(am__objects_6) \ $(am__objects_7) $(am__objects_8) $(am__objects_9) \ $(am__objects_10) $(am__objects_8) $(am__objects_11) \ $(am__objects_12) $(am__objects_13) $(am__objects_14) \ $(am__objects_15) libmicrohttpd_la_OBJECTS = $(am_libmicrohttpd_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libmicrohttpd_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(libmicrohttpd_la_CFLAGS) $(CFLAGS) \ $(libmicrohttpd_la_LDFLAGS) $(LDFLAGS) -o $@ am_test_auth_parse_OBJECTS = \ test_auth_parse-test_auth_parse.$(OBJEXT) \ test_auth_parse-gen_auth.$(OBJEXT) \ test_auth_parse-mhd_str.$(OBJEXT) test_auth_parse_OBJECTS = $(am_test_auth_parse_OBJECTS) test_auth_parse_LDADD = $(LDADD) am_test_client_put_chunked_close_OBJECTS = \ test_client_put_stop.$(OBJEXT) test_client_put_chunked_close_OBJECTS = \ $(am_test_client_put_chunked_close_OBJECTS) test_client_put_chunked_close_DEPENDENCIES = libmicrohttpd.la am_test_client_put_chunked_hard_close_OBJECTS = \ test_client_put_stop.$(OBJEXT) test_client_put_chunked_hard_close_OBJECTS = \ $(am_test_client_put_chunked_hard_close_OBJECTS) test_client_put_chunked_hard_close_DEPENDENCIES = libmicrohttpd.la am_test_client_put_chunked_shutdown_OBJECTS = \ test_client_put_stop.$(OBJEXT) test_client_put_chunked_shutdown_OBJECTS = \ $(am_test_client_put_chunked_shutdown_OBJECTS) test_client_put_chunked_shutdown_DEPENDENCIES = libmicrohttpd.la am_test_client_put_chunked_steps_close_OBJECTS = \ test_client_put_stop.$(OBJEXT) test_client_put_chunked_steps_close_OBJECTS = \ $(am_test_client_put_chunked_steps_close_OBJECTS) test_client_put_chunked_steps_close_DEPENDENCIES = libmicrohttpd.la am_test_client_put_chunked_steps_hard_close_OBJECTS = \ test_client_put_stop.$(OBJEXT) test_client_put_chunked_steps_hard_close_OBJECTS = \ $(am_test_client_put_chunked_steps_hard_close_OBJECTS) test_client_put_chunked_steps_hard_close_DEPENDENCIES = \ libmicrohttpd.la am__objects_16 = test_client_put_stop.$(OBJEXT) am_test_client_put_chunked_steps_hard_close_stress_os_OBJECTS = \ $(am__objects_16) test_client_put_chunked_steps_hard_close_stress_os_OBJECTS = $(am_test_client_put_chunked_steps_hard_close_stress_os_OBJECTS) test_client_put_chunked_steps_hard_close_stress_os_DEPENDENCIES = \ $(test_client_put_chunked_steps_hard_close_LDADD) am_test_client_put_chunked_steps_shutdown_OBJECTS = \ test_client_put_stop.$(OBJEXT) test_client_put_chunked_steps_shutdown_OBJECTS = \ $(am_test_client_put_chunked_steps_shutdown_OBJECTS) test_client_put_chunked_steps_shutdown_DEPENDENCIES = \ libmicrohttpd.la am_test_client_put_close_OBJECTS = test_client_put_stop.$(OBJEXT) test_client_put_close_OBJECTS = $(am_test_client_put_close_OBJECTS) test_client_put_close_DEPENDENCIES = libmicrohttpd.la am_test_client_put_hard_close_OBJECTS = \ test_client_put_stop.$(OBJEXT) test_client_put_hard_close_OBJECTS = \ $(am_test_client_put_hard_close_OBJECTS) test_client_put_hard_close_DEPENDENCIES = libmicrohttpd.la am_test_client_put_hard_close_stress_os_OBJECTS = $(am__objects_16) test_client_put_hard_close_stress_os_OBJECTS = \ $(am_test_client_put_hard_close_stress_os_OBJECTS) test_client_put_hard_close_stress_os_DEPENDENCIES = \ $(test_client_put_hard_close_LDADD) am_test_client_put_shutdown_OBJECTS = test_client_put_stop.$(OBJEXT) test_client_put_shutdown_OBJECTS = \ $(am_test_client_put_shutdown_OBJECTS) test_client_put_shutdown_DEPENDENCIES = libmicrohttpd.la am_test_client_put_steps_close_OBJECTS = \ test_client_put_stop.$(OBJEXT) test_client_put_steps_close_OBJECTS = \ $(am_test_client_put_steps_close_OBJECTS) test_client_put_steps_close_DEPENDENCIES = libmicrohttpd.la am_test_client_put_steps_hard_close_OBJECTS = \ test_client_put_stop.$(OBJEXT) test_client_put_steps_hard_close_OBJECTS = \ $(am_test_client_put_steps_hard_close_OBJECTS) test_client_put_steps_hard_close_DEPENDENCIES = libmicrohttpd.la am_test_client_put_steps_hard_close_stress_os_OBJECTS = \ $(am__objects_16) test_client_put_steps_hard_close_stress_os_OBJECTS = \ $(am_test_client_put_steps_hard_close_stress_os_OBJECTS) test_client_put_steps_hard_close_stress_os_DEPENDENCIES = \ $(test_client_put_steps_hard_close_LDADD) am_test_client_put_steps_shutdown_OBJECTS = \ test_client_put_stop.$(OBJEXT) test_client_put_steps_shutdown_OBJECTS = \ $(am_test_client_put_steps_shutdown_OBJECTS) test_client_put_steps_shutdown_DEPENDENCIES = libmicrohttpd.la am_test_daemon_OBJECTS = test_daemon.$(OBJEXT) test_daemon_OBJECTS = $(am_test_daemon_OBJECTS) test_daemon_DEPENDENCIES = $(builddir)/libmicrohttpd.la am_test_dauth_userdigest_OBJECTS = test_dauth_userdigest.$(OBJEXT) test_dauth_userdigest_OBJECTS = $(am_test_dauth_userdigest_OBJECTS) test_dauth_userdigest_DEPENDENCIES = libmicrohttpd.la am_test_dauth_userhash_OBJECTS = test_dauth_userhash.$(OBJEXT) test_dauth_userhash_OBJECTS = $(am_test_dauth_userhash_OBJECTS) test_dauth_userhash_DEPENDENCIES = libmicrohttpd.la am_test_http_reasons_OBJECTS = test_http_reasons.$(OBJEXT) \ reason_phrase.$(OBJEXT) mhd_str.$(OBJEXT) test_http_reasons_OBJECTS = $(am_test_http_reasons_OBJECTS) test_http_reasons_LDADD = $(LDADD) am__test_md5_SOURCES_DIST = test_md5.c test_helpers.h mhd_md5_wrap.h \ ../include/mhd_options.h md5.c md5.h mhd_bithelpers.h \ mhd_byteorder.h mhd_align.h md5_ext.c md5_ext.h @ENABLE_MD5_EXT_FALSE@am__objects_17 = test_md5-md5.$(OBJEXT) @ENABLE_MD5_EXT_TRUE@am__objects_18 = test_md5-md5_ext.$(OBJEXT) am_test_md5_OBJECTS = test_md5-test_md5.$(OBJEXT) $(am__objects_17) \ $(am__objects_18) test_md5_OBJECTS = $(am_test_md5_OBJECTS) @ENABLE_MD5_EXT_TRUE@test_md5_DEPENDENCIES = $(am__DEPENDENCIES_1) test_md5_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_md5_CFLAGS) \ $(CFLAGS) $(test_md5_LDFLAGS) $(LDFLAGS) -o $@ am_test_mhd_version_OBJECTS = test_mhd_version.$(OBJEXT) test_mhd_version_OBJECTS = $(am_test_mhd_version_OBJECTS) test_mhd_version_DEPENDENCIES = libmicrohttpd.la am_test_options_OBJECTS = test_options.$(OBJEXT) test_options_OBJECTS = $(am_test_options_OBJECTS) test_options_DEPENDENCIES = $(builddir)/libmicrohttpd.la am_test_postprocessor_OBJECTS = \ test_postprocessor-test_postprocessor.$(OBJEXT) test_postprocessor_OBJECTS = $(am_test_postprocessor_OBJECTS) test_postprocessor_DEPENDENCIES = $(builddir)/libmicrohttpd.la test_postprocessor_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_postprocessor_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_postprocessor_amp_OBJECTS = \ test_postprocessor_amp-test_postprocessor_amp.$(OBJEXT) test_postprocessor_amp_OBJECTS = $(am_test_postprocessor_amp_OBJECTS) test_postprocessor_amp_DEPENDENCIES = $(builddir)/libmicrohttpd.la test_postprocessor_amp_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_postprocessor_amp_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_postprocessor_large_OBJECTS = \ test_postprocessor_large-test_postprocessor_large.$(OBJEXT) test_postprocessor_large_OBJECTS = \ $(am_test_postprocessor_large_OBJECTS) test_postprocessor_large_DEPENDENCIES = $(builddir)/libmicrohttpd.la test_postprocessor_large_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_postprocessor_large_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_postprocessor_md_OBJECTS = \ test_postprocessor_md-test_postprocessor_md.$(OBJEXT) \ test_postprocessor_md-postprocessor.$(OBJEXT) \ test_postprocessor_md-internal.$(OBJEXT) \ test_postprocessor_md-mhd_str.$(OBJEXT) \ test_postprocessor_md-mhd_panic.$(OBJEXT) test_postprocessor_md_OBJECTS = $(am_test_postprocessor_md_OBJECTS) test_postprocessor_md_LDADD = $(LDADD) am_test_response_entries_OBJECTS = test_response_entries.$(OBJEXT) test_response_entries_OBJECTS = $(am_test_response_entries_OBJECTS) test_response_entries_DEPENDENCIES = libmicrohttpd.la am_test_set_panic_OBJECTS = test_set_panic.$(OBJEXT) test_set_panic_OBJECTS = $(am_test_set_panic_OBJECTS) test_set_panic_DEPENDENCIES = libmicrohttpd.la am_test_sha1_OBJECTS = test_sha1.$(OBJEXT) sha1.$(OBJEXT) test_sha1_OBJECTS = $(am_test_sha1_OBJECTS) test_sha1_LDADD = $(LDADD) am__test_sha256_SOURCES_DIST = test_sha256.c test_helpers.h \ mhd_sha256_wrap.h ../include/mhd_options.h sha256.c sha256.h \ mhd_bithelpers.h mhd_byteorder.h mhd_align.h sha256_ext.c \ sha256_ext.h @ENABLE_SHA256_EXT_FALSE@am__objects_19 = \ @ENABLE_SHA256_EXT_FALSE@ test_sha256-sha256.$(OBJEXT) @ENABLE_SHA256_EXT_TRUE@am__objects_20 = \ @ENABLE_SHA256_EXT_TRUE@ test_sha256-sha256_ext.$(OBJEXT) am_test_sha256_OBJECTS = test_sha256-test_sha256.$(OBJEXT) \ $(am__objects_19) $(am__objects_20) test_sha256_OBJECTS = $(am_test_sha256_OBJECTS) @ENABLE_SHA256_EXT_TRUE@test_sha256_DEPENDENCIES = \ @ENABLE_SHA256_EXT_TRUE@ $(am__DEPENDENCIES_1) test_sha256_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_sha256_CFLAGS) \ $(CFLAGS) $(test_sha256_LDFLAGS) $(LDFLAGS) -o $@ am_test_sha512_256_OBJECTS = test_sha512_256.$(OBJEXT) \ sha512_256.$(OBJEXT) test_sha512_256_OBJECTS = $(am_test_sha512_256_OBJECTS) test_sha512_256_LDADD = $(LDADD) am_test_shutdown_poll_OBJECTS = \ test_shutdown_poll-test_shutdown_select.$(OBJEXT) test_shutdown_poll_OBJECTS = $(am_test_shutdown_poll_OBJECTS) @USE_POSIX_THREADS_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) test_shutdown_poll_DEPENDENCIES = $(am__DEPENDENCIES_2) test_shutdown_poll_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_shutdown_poll_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_shutdown_poll_ignore_OBJECTS = \ test_shutdown_poll_ignore-test_shutdown_select.$(OBJEXT) test_shutdown_poll_ignore_OBJECTS = \ $(am_test_shutdown_poll_ignore_OBJECTS) test_shutdown_poll_ignore_DEPENDENCIES = $(am__DEPENDENCIES_2) test_shutdown_poll_ignore_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_shutdown_poll_ignore_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_shutdown_select_OBJECTS = \ test_shutdown_select-test_shutdown_select.$(OBJEXT) test_shutdown_select_OBJECTS = $(am_test_shutdown_select_OBJECTS) test_shutdown_select_DEPENDENCIES = $(am__DEPENDENCIES_2) test_shutdown_select_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_shutdown_select_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_shutdown_select_ignore_OBJECTS = \ test_shutdown_select_ignore-test_shutdown_select.$(OBJEXT) test_shutdown_select_ignore_OBJECTS = \ $(am_test_shutdown_select_ignore_OBJECTS) test_shutdown_select_ignore_DEPENDENCIES = $(am__DEPENDENCIES_2) test_shutdown_select_ignore_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_shutdown_select_ignore_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ am_test_start_stop_OBJECTS = test_start_stop.$(OBJEXT) test_start_stop_OBJECTS = $(am_test_start_stop_OBJECTS) test_start_stop_DEPENDENCIES = libmicrohttpd.la am_test_str_base64_OBJECTS = test_str_base64.$(OBJEXT) \ mhd_str.$(OBJEXT) test_str_base64_OBJECTS = $(am_test_str_base64_OBJECTS) test_str_base64_LDADD = $(LDADD) am_test_str_bin_hex_OBJECTS = test_str_bin_hex.$(OBJEXT) \ mhd_str.$(OBJEXT) test_str_bin_hex_OBJECTS = $(am_test_str_bin_hex_OBJECTS) test_str_bin_hex_LDADD = $(LDADD) am_test_str_compare_OBJECTS = test_str.$(OBJEXT) mhd_str.$(OBJEXT) test_str_compare_OBJECTS = $(am_test_str_compare_OBJECTS) test_str_compare_LDADD = $(LDADD) am_test_str_from_value_OBJECTS = test_str.$(OBJEXT) mhd_str.$(OBJEXT) test_str_from_value_OBJECTS = $(am_test_str_from_value_OBJECTS) test_str_from_value_LDADD = $(LDADD) am_test_str_pct_OBJECTS = test_str_pct.$(OBJEXT) mhd_str.$(OBJEXT) test_str_pct_OBJECTS = $(am_test_str_pct_OBJECTS) test_str_pct_LDADD = $(LDADD) am_test_str_quote_OBJECTS = test_str_quote.$(OBJEXT) mhd_str.$(OBJEXT) test_str_quote_OBJECTS = $(am_test_str_quote_OBJECTS) test_str_quote_LDADD = $(LDADD) am_test_str_to_value_OBJECTS = test_str.$(OBJEXT) mhd_str.$(OBJEXT) test_str_to_value_OBJECTS = $(am_test_str_to_value_OBJECTS) test_str_to_value_LDADD = $(LDADD) am_test_str_token_OBJECTS = test_str_token.$(OBJEXT) mhd_str.$(OBJEXT) test_str_token_OBJECTS = $(am_test_str_token_OBJECTS) test_str_token_LDADD = $(LDADD) am_test_str_token_remove_OBJECTS = test_str_token_remove.$(OBJEXT) \ mhd_str.$(OBJEXT) test_str_token_remove_OBJECTS = $(am_test_str_token_remove_OBJECTS) test_str_token_remove_LDADD = $(LDADD) am_test_str_tokens_remove_OBJECTS = test_str_tokens_remove.$(OBJEXT) \ mhd_str.$(OBJEXT) test_str_tokens_remove_OBJECTS = $(am_test_str_tokens_remove_OBJECTS) test_str_tokens_remove_LDADD = $(LDADD) am_test_upgrade_OBJECTS = test_upgrade-test_upgrade.$(OBJEXT) test_upgrade_OBJECTS = $(am_test_upgrade_OBJECTS) test_upgrade_DEPENDENCIES = $(builddir)/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) test_upgrade_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_upgrade_CFLAGS) \ $(CFLAGS) $(test_upgrade_LDFLAGS) $(LDFLAGS) -o $@ am__objects_21 = test_upgrade_large-test_upgrade.$(OBJEXT) am_test_upgrade_large_OBJECTS = $(am__objects_21) test_upgrade_large_OBJECTS = $(am_test_upgrade_large_OBJECTS) am__DEPENDENCIES_3 = $(builddir)/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) test_upgrade_large_DEPENDENCIES = $(am__DEPENDENCIES_3) test_upgrade_large_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_upgrade_large_CFLAGS) $(CFLAGS) \ $(test_upgrade_large_LDFLAGS) $(LDFLAGS) -o $@ am__objects_22 = test_upgrade_large_tls-test_upgrade.$(OBJEXT) am_test_upgrade_large_tls_OBJECTS = $(am__objects_22) test_upgrade_large_tls_OBJECTS = $(am_test_upgrade_large_tls_OBJECTS) test_upgrade_large_tls_DEPENDENCIES = $(am__DEPENDENCIES_3) test_upgrade_large_tls_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_upgrade_large_tls_CFLAGS) $(CFLAGS) \ $(test_upgrade_large_tls_LDFLAGS) $(LDFLAGS) -o $@ am__objects_23 = test_upgrade_tls-test_upgrade.$(OBJEXT) am_test_upgrade_tls_OBJECTS = $(am__objects_23) test_upgrade_tls_OBJECTS = $(am_test_upgrade_tls_OBJECTS) test_upgrade_tls_DEPENDENCIES = $(am__DEPENDENCIES_3) test_upgrade_tls_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_upgrade_tls_CFLAGS) $(CFLAGS) \ $(test_upgrade_tls_LDFLAGS) $(LDFLAGS) -o $@ am__objects_24 = test_upgrade_vlarge-test_upgrade.$(OBJEXT) am_test_upgrade_vlarge_OBJECTS = $(am__objects_24) test_upgrade_vlarge_OBJECTS = $(am_test_upgrade_vlarge_OBJECTS) test_upgrade_vlarge_DEPENDENCIES = $(am__DEPENDENCIES_3) test_upgrade_vlarge_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_upgrade_vlarge_CFLAGS) $(CFLAGS) \ $(test_upgrade_vlarge_LDFLAGS) $(LDFLAGS) -o $@ am__objects_25 = test_upgrade_vlarge_tls-test_upgrade.$(OBJEXT) am_test_upgrade_vlarge_tls_OBJECTS = $(am__objects_25) test_upgrade_vlarge_tls_OBJECTS = \ $(am_test_upgrade_vlarge_tls_OBJECTS) test_upgrade_vlarge_tls_DEPENDENCIES = $(am__DEPENDENCIES_3) test_upgrade_vlarge_tls_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_upgrade_vlarge_tls_CFLAGS) $(CFLAGS) \ $(test_upgrade_vlarge_tls_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/libmicrohttpd_la-basicauth.Plo \ ./$(DEPDIR)/libmicrohttpd_la-connection.Plo \ ./$(DEPDIR)/libmicrohttpd_la-connection_https.Plo \ ./$(DEPDIR)/libmicrohttpd_la-daemon.Plo \ ./$(DEPDIR)/libmicrohttpd_la-digestauth.Plo \ ./$(DEPDIR)/libmicrohttpd_la-gen_auth.Plo \ ./$(DEPDIR)/libmicrohttpd_la-internal.Plo \ ./$(DEPDIR)/libmicrohttpd_la-md5.Plo \ ./$(DEPDIR)/libmicrohttpd_la-md5_ext.Plo \ ./$(DEPDIR)/libmicrohttpd_la-memorypool.Plo \ ./$(DEPDIR)/libmicrohttpd_la-mhd_compat.Plo \ ./$(DEPDIR)/libmicrohttpd_la-mhd_itc.Plo \ ./$(DEPDIR)/libmicrohttpd_la-mhd_mono_clock.Plo \ ./$(DEPDIR)/libmicrohttpd_la-mhd_panic.Plo \ ./$(DEPDIR)/libmicrohttpd_la-mhd_send.Plo \ ./$(DEPDIR)/libmicrohttpd_la-mhd_sockets.Plo \ ./$(DEPDIR)/libmicrohttpd_la-mhd_str.Plo \ ./$(DEPDIR)/libmicrohttpd_la-mhd_threads.Plo \ ./$(DEPDIR)/libmicrohttpd_la-postprocessor.Plo \ ./$(DEPDIR)/libmicrohttpd_la-reason_phrase.Plo \ ./$(DEPDIR)/libmicrohttpd_la-response.Plo \ ./$(DEPDIR)/libmicrohttpd_la-sha256.Plo \ ./$(DEPDIR)/libmicrohttpd_la-sha256_ext.Plo \ ./$(DEPDIR)/libmicrohttpd_la-sha512_256.Plo \ ./$(DEPDIR)/libmicrohttpd_la-sysfdsetsize.Plo \ ./$(DEPDIR)/libmicrohttpd_la-tsearch.Plo \ ./$(DEPDIR)/mhd_str.Po ./$(DEPDIR)/reason_phrase.Po \ ./$(DEPDIR)/sha1.Po ./$(DEPDIR)/sha512_256.Po \ ./$(DEPDIR)/test_auth_parse-gen_auth.Po \ ./$(DEPDIR)/test_auth_parse-mhd_str.Po \ ./$(DEPDIR)/test_auth_parse-test_auth_parse.Po \ ./$(DEPDIR)/test_client_put_stop.Po ./$(DEPDIR)/test_daemon.Po \ ./$(DEPDIR)/test_dauth_userdigest.Po \ ./$(DEPDIR)/test_dauth_userhash.Po \ ./$(DEPDIR)/test_http_reasons.Po ./$(DEPDIR)/test_md5-md5.Po \ ./$(DEPDIR)/test_md5-md5_ext.Po \ ./$(DEPDIR)/test_md5-test_md5.Po \ ./$(DEPDIR)/test_mhd_version.Po ./$(DEPDIR)/test_options.Po \ ./$(DEPDIR)/test_postprocessor-test_postprocessor.Po \ ./$(DEPDIR)/test_postprocessor_amp-test_postprocessor_amp.Po \ ./$(DEPDIR)/test_postprocessor_large-test_postprocessor_large.Po \ ./$(DEPDIR)/test_postprocessor_md-internal.Po \ ./$(DEPDIR)/test_postprocessor_md-mhd_panic.Po \ ./$(DEPDIR)/test_postprocessor_md-mhd_str.Po \ ./$(DEPDIR)/test_postprocessor_md-postprocessor.Po \ ./$(DEPDIR)/test_postprocessor_md-test_postprocessor_md.Po \ ./$(DEPDIR)/test_response_entries.Po \ ./$(DEPDIR)/test_set_panic.Po ./$(DEPDIR)/test_sha1.Po \ ./$(DEPDIR)/test_sha256-sha256.Po \ ./$(DEPDIR)/test_sha256-sha256_ext.Po \ ./$(DEPDIR)/test_sha256-test_sha256.Po \ ./$(DEPDIR)/test_sha512_256.Po \ ./$(DEPDIR)/test_shutdown_poll-test_shutdown_select.Po \ ./$(DEPDIR)/test_shutdown_poll_ignore-test_shutdown_select.Po \ ./$(DEPDIR)/test_shutdown_select-test_shutdown_select.Po \ ./$(DEPDIR)/test_shutdown_select_ignore-test_shutdown_select.Po \ ./$(DEPDIR)/test_start_stop.Po ./$(DEPDIR)/test_str.Po \ ./$(DEPDIR)/test_str_base64.Po ./$(DEPDIR)/test_str_bin_hex.Po \ ./$(DEPDIR)/test_str_pct.Po ./$(DEPDIR)/test_str_quote.Po \ ./$(DEPDIR)/test_str_token.Po \ ./$(DEPDIR)/test_str_token_remove.Po \ ./$(DEPDIR)/test_str_tokens_remove.Po \ ./$(DEPDIR)/test_upgrade-test_upgrade.Po \ ./$(DEPDIR)/test_upgrade_large-test_upgrade.Po \ ./$(DEPDIR)/test_upgrade_large_tls-test_upgrade.Po \ ./$(DEPDIR)/test_upgrade_tls-test_upgrade.Po \ ./$(DEPDIR)/test_upgrade_vlarge-test_upgrade.Po \ ./$(DEPDIR)/test_upgrade_vlarge_tls-test_upgrade.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libmicrohttpd_la_SOURCES) $(test_auth_parse_SOURCES) \ $(test_client_put_chunked_close_SOURCES) \ $(test_client_put_chunked_hard_close_SOURCES) \ $(test_client_put_chunked_shutdown_SOURCES) \ $(test_client_put_chunked_steps_close_SOURCES) \ $(test_client_put_chunked_steps_hard_close_SOURCES) \ $(test_client_put_chunked_steps_hard_close_stress_os_SOURCES) \ $(test_client_put_chunked_steps_shutdown_SOURCES) \ $(test_client_put_close_SOURCES) \ $(test_client_put_hard_close_SOURCES) \ $(test_client_put_hard_close_stress_os_SOURCES) \ $(test_client_put_shutdown_SOURCES) \ $(test_client_put_steps_close_SOURCES) \ $(test_client_put_steps_hard_close_SOURCES) \ $(test_client_put_steps_hard_close_stress_os_SOURCES) \ $(test_client_put_steps_shutdown_SOURCES) \ $(test_daemon_SOURCES) $(test_dauth_userdigest_SOURCES) \ $(test_dauth_userhash_SOURCES) $(test_http_reasons_SOURCES) \ $(test_md5_SOURCES) $(test_mhd_version_SOURCES) \ $(test_options_SOURCES) $(test_postprocessor_SOURCES) \ $(test_postprocessor_amp_SOURCES) \ $(test_postprocessor_large_SOURCES) \ $(test_postprocessor_md_SOURCES) \ $(test_response_entries_SOURCES) $(test_set_panic_SOURCES) \ $(test_sha1_SOURCES) $(test_sha256_SOURCES) \ $(test_sha512_256_SOURCES) $(test_shutdown_poll_SOURCES) \ $(test_shutdown_poll_ignore_SOURCES) \ $(test_shutdown_select_SOURCES) \ $(test_shutdown_select_ignore_SOURCES) \ $(test_start_stop_SOURCES) $(test_str_base64_SOURCES) \ $(test_str_bin_hex_SOURCES) $(test_str_compare_SOURCES) \ $(test_str_from_value_SOURCES) $(test_str_pct_SOURCES) \ $(test_str_quote_SOURCES) $(test_str_to_value_SOURCES) \ $(test_str_token_SOURCES) $(test_str_token_remove_SOURCES) \ $(test_str_tokens_remove_SOURCES) $(test_upgrade_SOURCES) \ $(test_upgrade_large_SOURCES) \ $(test_upgrade_large_tls_SOURCES) $(test_upgrade_tls_SOURCES) \ $(test_upgrade_vlarge_SOURCES) \ $(test_upgrade_vlarge_tls_SOURCES) DIST_SOURCES = $(am__libmicrohttpd_la_SOURCES_DIST) \ $(test_auth_parse_SOURCES) \ $(test_client_put_chunked_close_SOURCES) \ $(test_client_put_chunked_hard_close_SOURCES) \ $(test_client_put_chunked_shutdown_SOURCES) \ $(test_client_put_chunked_steps_close_SOURCES) \ $(test_client_put_chunked_steps_hard_close_SOURCES) \ $(test_client_put_chunked_steps_hard_close_stress_os_SOURCES) \ $(test_client_put_chunked_steps_shutdown_SOURCES) \ $(test_client_put_close_SOURCES) \ $(test_client_put_hard_close_SOURCES) \ $(test_client_put_hard_close_stress_os_SOURCES) \ $(test_client_put_shutdown_SOURCES) \ $(test_client_put_steps_close_SOURCES) \ $(test_client_put_steps_hard_close_SOURCES) \ $(test_client_put_steps_hard_close_stress_os_SOURCES) \ $(test_client_put_steps_shutdown_SOURCES) \ $(test_daemon_SOURCES) $(test_dauth_userdigest_SOURCES) \ $(test_dauth_userhash_SOURCES) $(test_http_reasons_SOURCES) \ $(am__test_md5_SOURCES_DIST) $(test_mhd_version_SOURCES) \ $(test_options_SOURCES) $(test_postprocessor_SOURCES) \ $(test_postprocessor_amp_SOURCES) \ $(test_postprocessor_large_SOURCES) \ $(test_postprocessor_md_SOURCES) \ $(test_response_entries_SOURCES) $(test_set_panic_SOURCES) \ $(test_sha1_SOURCES) $(am__test_sha256_SOURCES_DIST) \ $(test_sha512_256_SOURCES) $(test_shutdown_poll_SOURCES) \ $(test_shutdown_poll_ignore_SOURCES) \ $(test_shutdown_select_SOURCES) \ $(test_shutdown_select_ignore_SOURCES) \ $(test_start_stop_SOURCES) $(test_str_base64_SOURCES) \ $(test_str_bin_hex_SOURCES) $(test_str_compare_SOURCES) \ $(test_str_from_value_SOURCES) $(test_str_pct_SOURCES) \ $(test_str_quote_SOURCES) $(test_str_to_value_SOURCES) \ $(test_str_token_SOURCES) $(test_str_token_remove_SOURCES) \ $(test_str_tokens_remove_SOURCES) $(test_upgrade_SOURCES) \ $(test_upgrade_large_SOURCES) \ $(test_upgrade_large_tls_SOURCES) $(test_upgrade_tls_SOURCES) \ $(test_upgrade_vlarge_SOURCES) \ $(test_upgrade_vlarge_tls_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac DATA = $(noinst_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__DIST_COMMON = $(srcdir)/Makefile.in \ $(srcdir)/microhttpd_dll_res.rc.in \ $(top_srcdir)/build-aux/depcomp \ $(top_srcdir)/build-aux/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ $(CPPFLAGS_ac) AM_CFLAGS = $(CFLAGS_ac) $(HIDDEN_VISIBILITY_CFLAGS) $(am__append_10) AM_LDFLAGS = $(LDFLAGS_ac) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) lib_LTLIBRARIES = \ libmicrohttpd.la noinst_DATA = $(am__append_1) $(am__append_3) $(am__append_4) MOSTLYCLEANFILES = $(am__append_2) $(am__append_5) AM_V_LIB = $(am__v_LIB_@AM_V@) am__v_LIB_ = $(am__v_LIB_@AM_DEFAULT_V@) am__v_LIB_0 = @echo " LIB " $@; am__v_LIB_1 = @W32_SHARED_LIB_EXP_TRUE@AM_V_DLLTOOL = $(am__v_DLLTOOL_@AM_V@) @W32_SHARED_LIB_EXP_TRUE@am__v_DLLTOOL_ = $(am__v_DLLTOOL_@AM_DEFAULT_V@) @W32_SHARED_LIB_EXP_TRUE@am__v_DLLTOOL_0 = @echo " DLLTOOL " $@; @W32_SHARED_LIB_EXP_TRUE@am__v_DLLTOOL_1 = @W32_SHARED_LIB_EXP_FALSE@W32_MHD_LIB_LDFLAGS = @W32_SHARED_LIB_EXP_TRUE@W32_MHD_LIB_LDFLAGS = -Wl,--output-def,$(lt_cv_objdir)/libmicrohttpd.def -XCClinker -static-libgcc libmicrohttpd_la_SOURCES = connection.c connection.h reason_phrase.c \ daemon.c internal.c internal.h memorypool.c memorypool.h \ mhd_mono_clock.c mhd_mono_clock.h mhd_limits.h sysfdsetsize.h \ mhd_str.c mhd_str.h mhd_str_types.h mhd_send.h mhd_send.c \ mhd_assert.h mhd_sockets.c mhd_sockets.h mhd_itc.c mhd_itc.h \ mhd_itc_types.h mhd_compat.c mhd_compat.h mhd_panic.c \ mhd_panic.h response.c response.h $(am__append_6) \ $(am__append_7) $(am__append_8) $(am__append_11) \ $(am__append_12) $(am__append_13) $(am__append_14) \ $(am__append_15) $(am__append_16) $(am__append_17) \ $(am__append_18) $(am__append_19) $(am__append_20) \ $(am__append_21) $(am__append_22) $(am__append_23) libmicrohttpd_la_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) \ -DBUILDING_MHD_LIB=1 libmicrohttpd_la_CFLAGS = \ $(AM_CFLAGS) $(MHD_LIB_CFLAGS) $(MHD_TLS_LIB_CFLAGS) libmicrohttpd_la_LDFLAGS = \ $(AM_LDFLAGS) $(MHD_LIB_LDFLAGS) $(MHD_TLS_LIB_LDFLAGS) \ $(W32_MHD_LIB_LDFLAGS) \ -export-dynamic -no-undefined \ -version-info @LIB_VERSION_CURRENT@:@LIB_VERSION_REVISION@:@LIB_VERSION_AGE@ libmicrohttpd_la_LIBADD = $(MHD_LIBDEPS) $(MHD_TLS_LIBDEPS) \ $(am__append_9) @HAVE_W32_TRUE@MHD_DLL_RES_SRC = microhttpd_dll_res.rc @HAVE_W32_TRUE@MHD_DLL_RES_LO = libmicrohttpd_la-$(MHD_DLL_RES_SRC:.rc=.lo) @HAVE_W32_TRUE@EXTRA_libmicrohttpd_la_DEPENDENCIES = $(MHD_DLL_RES_LO) @HAVE_W32_TRUE@AM_V_RC = $(am__v_RC_$(V)) @HAVE_W32_TRUE@am__v_RC_ = $(am__v_RC_$(AM_DEFAULT_VERBOSITY)) @HAVE_W32_TRUE@am__v_RC_0 = @echo " RC " $@; @HAVE_W32_TRUE@am__v_RC_1 = TESTS = $(check_PROGRAMS) test_start_stop_SOURCES = \ test_start_stop.c test_start_stop_LDADD = \ libmicrohttpd.la test_daemon_SOURCES = \ test_daemon.c test_daemon_LDADD = \ $(builddir)/libmicrohttpd.la test_response_entries_SOURCES = \ test_response_entries.c test_response_entries_LDADD = \ libmicrohttpd.la test_upgrade_SOURCES = \ test_upgrade.c test_helpers.h mhd_sockets.h test_upgrade_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_upgrade_CFLAGS = \ $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(MHD_TLS_LIB_CFLAGS) test_upgrade_LDFLAGS = \ $(MHD_TLS_LIB_LDFLAGS) test_upgrade_LDADD = \ $(builddir)/libmicrohttpd.la \ $(MHD_TLS_LIBDEPS) \ $(PTHREAD_LIBS) test_upgrade_large_SOURCES = \ $(test_upgrade_SOURCES) test_upgrade_large_CPPFLAGS = \ $(test_upgrade_CPPFLAGS) test_upgrade_large_CFLAGS = \ $(test_upgrade_CFLAGS) test_upgrade_large_LDFLAGS = \ $(test_upgrade_LDFLAGS) test_upgrade_large_LDADD = \ $(test_upgrade_LDADD) test_upgrade_vlarge_SOURCES = \ $(test_upgrade_SOURCES) test_upgrade_vlarge_CPPFLAGS = \ $(test_upgrade_CPPFLAGS) test_upgrade_vlarge_CFLAGS = \ $(test_upgrade_CFLAGS) test_upgrade_vlarge_LDFLAGS = \ $(test_upgrade_LDFLAGS) test_upgrade_vlarge_LDADD = \ $(test_upgrade_LDADD) test_upgrade_tls_SOURCES = \ $(test_upgrade_SOURCES) test_upgrade_tls_CPPFLAGS = \ $(test_upgrade_CPPFLAGS) test_upgrade_tls_CFLAGS = \ $(test_upgrade_CFLAGS) test_upgrade_tls_LDFLAGS = \ $(test_upgrade_LDFLAGS) test_upgrade_tls_LDADD = \ $(test_upgrade_LDADD) test_upgrade_large_tls_SOURCES = \ $(test_upgrade_SOURCES) test_upgrade_large_tls_CPPFLAGS = \ $(test_upgrade_CPPFLAGS) test_upgrade_large_tls_CFLAGS = \ $(test_upgrade_CFLAGS) test_upgrade_large_tls_LDFLAGS = \ $(test_upgrade_LDFLAGS) test_upgrade_large_tls_LDADD = \ $(test_upgrade_LDADD) test_upgrade_vlarge_tls_SOURCES = \ $(test_upgrade_SOURCES) test_upgrade_vlarge_tls_CPPFLAGS = \ $(test_upgrade_CPPFLAGS) test_upgrade_vlarge_tls_CFLAGS = \ $(test_upgrade_CFLAGS) test_upgrade_vlarge_tls_LDFLAGS = \ $(test_upgrade_LDFLAGS) test_upgrade_vlarge_tls_LDADD = \ $(test_upgrade_LDADD) test_postprocessor_SOURCES = \ test_postprocessor.c test_postprocessor_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_postprocessor_CFLAGS = \ $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS) test_postprocessor_LDADD = \ $(builddir)/libmicrohttpd.la test_postprocessor_amp_SOURCES = \ test_postprocessor_amp.c test_postprocessor_amp_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_postprocessor_amp_CFLAGS = \ $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS) test_postprocessor_amp_LDADD = \ $(builddir)/libmicrohttpd.la test_postprocessor_large_SOURCES = \ test_postprocessor_large.c test_postprocessor_large_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_postprocessor_large_CFLAGS = \ $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS) test_postprocessor_large_LDADD = \ $(builddir)/libmicrohttpd.la test_postprocessor_md_SOURCES = \ test_postprocessor_md.c postprocessor.h postprocessor.c \ internal.h internal.c mhd_str.h mhd_str.c \ mhd_panic.h mhd_panic.c test_postprocessor_md_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_shutdown_select_SOURCES = \ test_shutdown_select.c test_shutdown_select_CFLAGS = $(AM_CFLAGS) $(am__append_36) test_shutdown_select_LDADD = $(LDADD) $(am__append_37) test_shutdown_poll_SOURCES = \ test_shutdown_select.c mhd_threads.h test_shutdown_poll_CFLAGS = $(AM_CFLAGS) $(am__append_38) test_shutdown_poll_LDADD = $(LDADD) $(am__append_39) test_shutdown_select_ignore_SOURCES = \ test_shutdown_select.c test_shutdown_select_ignore_CFLAGS = $(AM_CFLAGS) $(am__append_40) test_shutdown_select_ignore_LDADD = $(LDADD) $(am__append_41) test_shutdown_poll_ignore_SOURCES = \ test_shutdown_select.c mhd_threads.h test_shutdown_poll_ignore_CFLAGS = $(AM_CFLAGS) $(am__append_42) test_shutdown_poll_ignore_LDADD = $(LDADD) $(am__append_43) test_str_compare_SOURCES = \ test_str.c test_helpers.h mhd_str.c mhd_str.h test_str_to_value_SOURCES = \ test_str.c test_helpers.h mhd_str.c mhd_str.h test_str_from_value_SOURCES = \ test_str.c test_helpers.h mhd_str.c mhd_str.h test_str_token_SOURCES = \ test_str_token.c mhd_str.c mhd_str.h test_str_token_remove_SOURCES = \ test_str_token_remove.c mhd_str.c mhd_str.h mhd_assert.h ../include/mhd_options.h test_str_tokens_remove_SOURCES = \ test_str_tokens_remove.c mhd_str.c mhd_str.h mhd_assert.h ../include/mhd_options.h test_http_reasons_SOURCES = \ test_http_reasons.c \ reason_phrase.c mhd_str.c mhd_str.h test_md5_SOURCES = test_md5.c test_helpers.h mhd_md5_wrap.h \ ../include/mhd_options.h $(am__append_44) $(am__append_45) @ENABLE_MD5_EXT_FALSE@test_md5_CPPFLAGS = $(AM_CPPFLAGS) @ENABLE_MD5_EXT_TRUE@test_md5_CPPFLAGS = $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) @ENABLE_MD5_EXT_FALSE@test_md5_CFLAGS = $(AM_CFLAGS) @ENABLE_MD5_EXT_TRUE@test_md5_CFLAGS = $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS) @ENABLE_MD5_EXT_FALSE@test_md5_LDFLAGS = $(AM_LDFLAGS) @ENABLE_MD5_EXT_TRUE@test_md5_LDFLAGS = $(AM_LDFLAGS) $(MHD_TLS_LIB_LDFLAGS) @ENABLE_MD5_EXT_FALSE@test_md5_LDADD = $(LDADD) @ENABLE_MD5_EXT_TRUE@test_md5_LDADD = $(MHD_TLS_LIBDEPS) $(LDADD) test_sha256_SOURCES = test_sha256.c test_helpers.h mhd_sha256_wrap.h \ ../include/mhd_options.h $(am__append_46) $(am__append_47) @ENABLE_SHA256_EXT_FALSE@test_sha256_CPPFLAGS = $(AM_CPPFLAGS) @ENABLE_SHA256_EXT_TRUE@test_sha256_CPPFLAGS = $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) @ENABLE_SHA256_EXT_FALSE@test_sha256_CFLAGS = $(AM_CFLAGS) @ENABLE_SHA256_EXT_TRUE@test_sha256_CFLAGS = $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS) @ENABLE_SHA256_EXT_FALSE@test_sha256_LDFLAGS = $(AM_LDFLAGS) @ENABLE_SHA256_EXT_TRUE@test_sha256_LDFLAGS = $(AM_LDFLAGS) $(MHD_TLS_LIB_LDFLAGS) @ENABLE_SHA256_EXT_FALSE@test_sha256_LDADD = $(LDADD) @ENABLE_SHA256_EXT_TRUE@test_sha256_LDADD = $(MHD_TLS_LIBDEPS) $(LDADD) test_sha512_256_SOURCES = \ test_sha512_256.c test_helpers.h \ sha512_256.c sha512_256.h mhd_bithelpers.h mhd_byteorder.h mhd_align.h test_sha1_SOURCES = \ test_sha1.c test_helpers.h \ sha1.c sha1.h mhd_bithelpers.h mhd_byteorder.h mhd_align.h test_auth_parse_SOURCES = \ test_auth_parse.c gen_auth.c gen_auth.h mhd_str.h mhd_str.c mhd_assert.h test_auth_parse_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) test_str_quote_SOURCES = \ test_str_quote.c mhd_str.h mhd_str.c mhd_assert.h test_str_base64_SOURCES = \ test_str_base64.c mhd_str.h mhd_str.c mhd_assert.h test_str_pct_SOURCES = \ test_str_pct.c mhd_str.h mhd_str.c mhd_assert.h test_str_bin_hex_SOURCES = \ test_str_bin_hex.c mhd_str.h mhd_str.c mhd_assert.h test_options_SOURCES = \ test_options.c test_options_LDADD = \ $(builddir)/libmicrohttpd.la test_client_put_shutdown_SOURCES = \ test_client_put_stop.c test_client_put_shutdown_LDADD = \ libmicrohttpd.la test_client_put_close_SOURCES = \ test_client_put_stop.c test_client_put_close_LDADD = \ libmicrohttpd.la test_client_put_hard_close_SOURCES = \ test_client_put_stop.c test_client_put_hard_close_LDADD = \ libmicrohttpd.la test_client_put_hard_close_stress_os_SOURCES = \ $(test_client_put_hard_close_SOURCES) test_client_put_hard_close_stress_os_LDADD = \ $(test_client_put_hard_close_LDADD) test_client_put_steps_shutdown_SOURCES = \ test_client_put_stop.c test_client_put_steps_shutdown_LDADD = \ libmicrohttpd.la test_client_put_steps_close_SOURCES = \ test_client_put_stop.c test_client_put_steps_close_LDADD = \ libmicrohttpd.la test_client_put_steps_hard_close_SOURCES = \ test_client_put_stop.c test_client_put_steps_hard_close_LDADD = \ libmicrohttpd.la test_client_put_steps_hard_close_stress_os_SOURCES = \ $(test_client_put_steps_hard_close_SOURCES) test_client_put_steps_hard_close_stress_os_LDADD = \ $(test_client_put_steps_hard_close_LDADD) test_client_put_chunked_shutdown_SOURCES = \ test_client_put_stop.c test_client_put_chunked_shutdown_LDADD = \ libmicrohttpd.la test_client_put_chunked_close_SOURCES = \ test_client_put_stop.c test_client_put_chunked_close_LDADD = \ libmicrohttpd.la test_client_put_chunked_hard_close_SOURCES = \ test_client_put_stop.c test_client_put_chunked_hard_close_LDADD = \ libmicrohttpd.la test_client_put_chunked_steps_shutdown_SOURCES = \ test_client_put_stop.c test_client_put_chunked_steps_shutdown_LDADD = \ libmicrohttpd.la test_client_put_chunked_steps_close_SOURCES = \ test_client_put_stop.c test_client_put_chunked_steps_close_LDADD = \ libmicrohttpd.la test_client_put_chunked_steps_hard_close_SOURCES = \ test_client_put_stop.c test_client_put_chunked_steps_hard_close_LDADD = \ libmicrohttpd.la test_client_put_chunked_steps_hard_close_stress_os_SOURCES = \ $(test_client_put_chunked_steps_hard_close_SOURCES) test_client_put_chunked_steps_hard_close_stress_os_LDADD = \ $(test_client_put_chunked_steps_hard_close_LDADD) test_set_panic_SOURCES = \ test_set_panic.c test_set_panic_LDADD = \ libmicrohttpd.la test_dauth_userdigest_SOURCES = \ test_dauth_userdigest.c test_dauth_userdigest_LDADD = \ libmicrohttpd.la test_dauth_userhash_SOURCES = \ test_dauth_userhash.c test_dauth_userhash_LDADD = \ libmicrohttpd.la test_mhd_version_SOURCES = \ test_mhd_version.c test_mhd_version_LDADD = \ libmicrohttpd.la all: all-am .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .rc .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/microhttpd/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/microhttpd/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): microhttpd_dll_res.rc: $(top_builddir)/config.status $(srcdir)/microhttpd_dll_res.rc.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libmicrohttpd.la: $(libmicrohttpd_la_OBJECTS) $(libmicrohttpd_la_DEPENDENCIES) $(EXTRA_libmicrohttpd_la_DEPENDENCIES) $(AM_V_CCLD)$(libmicrohttpd_la_LINK) -rpath $(libdir) $(libmicrohttpd_la_OBJECTS) $(libmicrohttpd_la_LIBADD) $(LIBS) test_auth_parse$(EXEEXT): $(test_auth_parse_OBJECTS) $(test_auth_parse_DEPENDENCIES) $(EXTRA_test_auth_parse_DEPENDENCIES) @rm -f test_auth_parse$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_auth_parse_OBJECTS) $(test_auth_parse_LDADD) $(LIBS) test_client_put_chunked_close$(EXEEXT): $(test_client_put_chunked_close_OBJECTS) $(test_client_put_chunked_close_DEPENDENCIES) $(EXTRA_test_client_put_chunked_close_DEPENDENCIES) @rm -f test_client_put_chunked_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_chunked_close_OBJECTS) $(test_client_put_chunked_close_LDADD) $(LIBS) test_client_put_chunked_hard_close$(EXEEXT): $(test_client_put_chunked_hard_close_OBJECTS) $(test_client_put_chunked_hard_close_DEPENDENCIES) $(EXTRA_test_client_put_chunked_hard_close_DEPENDENCIES) @rm -f test_client_put_chunked_hard_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_chunked_hard_close_OBJECTS) $(test_client_put_chunked_hard_close_LDADD) $(LIBS) test_client_put_chunked_shutdown$(EXEEXT): $(test_client_put_chunked_shutdown_OBJECTS) $(test_client_put_chunked_shutdown_DEPENDENCIES) $(EXTRA_test_client_put_chunked_shutdown_DEPENDENCIES) @rm -f test_client_put_chunked_shutdown$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_chunked_shutdown_OBJECTS) $(test_client_put_chunked_shutdown_LDADD) $(LIBS) test_client_put_chunked_steps_close$(EXEEXT): $(test_client_put_chunked_steps_close_OBJECTS) $(test_client_put_chunked_steps_close_DEPENDENCIES) $(EXTRA_test_client_put_chunked_steps_close_DEPENDENCIES) @rm -f test_client_put_chunked_steps_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_chunked_steps_close_OBJECTS) $(test_client_put_chunked_steps_close_LDADD) $(LIBS) test_client_put_chunked_steps_hard_close$(EXEEXT): $(test_client_put_chunked_steps_hard_close_OBJECTS) $(test_client_put_chunked_steps_hard_close_DEPENDENCIES) $(EXTRA_test_client_put_chunked_steps_hard_close_DEPENDENCIES) @rm -f test_client_put_chunked_steps_hard_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_chunked_steps_hard_close_OBJECTS) $(test_client_put_chunked_steps_hard_close_LDADD) $(LIBS) test_client_put_chunked_steps_hard_close_stress_os$(EXEEXT): $(test_client_put_chunked_steps_hard_close_stress_os_OBJECTS) $(test_client_put_chunked_steps_hard_close_stress_os_DEPENDENCIES) $(EXTRA_test_client_put_chunked_steps_hard_close_stress_os_DEPENDENCIES) @rm -f test_client_put_chunked_steps_hard_close_stress_os$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_chunked_steps_hard_close_stress_os_OBJECTS) $(test_client_put_chunked_steps_hard_close_stress_os_LDADD) $(LIBS) test_client_put_chunked_steps_shutdown$(EXEEXT): $(test_client_put_chunked_steps_shutdown_OBJECTS) $(test_client_put_chunked_steps_shutdown_DEPENDENCIES) $(EXTRA_test_client_put_chunked_steps_shutdown_DEPENDENCIES) @rm -f test_client_put_chunked_steps_shutdown$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_chunked_steps_shutdown_OBJECTS) $(test_client_put_chunked_steps_shutdown_LDADD) $(LIBS) test_client_put_close$(EXEEXT): $(test_client_put_close_OBJECTS) $(test_client_put_close_DEPENDENCIES) $(EXTRA_test_client_put_close_DEPENDENCIES) @rm -f test_client_put_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_close_OBJECTS) $(test_client_put_close_LDADD) $(LIBS) test_client_put_hard_close$(EXEEXT): $(test_client_put_hard_close_OBJECTS) $(test_client_put_hard_close_DEPENDENCIES) $(EXTRA_test_client_put_hard_close_DEPENDENCIES) @rm -f test_client_put_hard_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_hard_close_OBJECTS) $(test_client_put_hard_close_LDADD) $(LIBS) test_client_put_hard_close_stress_os$(EXEEXT): $(test_client_put_hard_close_stress_os_OBJECTS) $(test_client_put_hard_close_stress_os_DEPENDENCIES) $(EXTRA_test_client_put_hard_close_stress_os_DEPENDENCIES) @rm -f test_client_put_hard_close_stress_os$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_hard_close_stress_os_OBJECTS) $(test_client_put_hard_close_stress_os_LDADD) $(LIBS) test_client_put_shutdown$(EXEEXT): $(test_client_put_shutdown_OBJECTS) $(test_client_put_shutdown_DEPENDENCIES) $(EXTRA_test_client_put_shutdown_DEPENDENCIES) @rm -f test_client_put_shutdown$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_shutdown_OBJECTS) $(test_client_put_shutdown_LDADD) $(LIBS) test_client_put_steps_close$(EXEEXT): $(test_client_put_steps_close_OBJECTS) $(test_client_put_steps_close_DEPENDENCIES) $(EXTRA_test_client_put_steps_close_DEPENDENCIES) @rm -f test_client_put_steps_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_steps_close_OBJECTS) $(test_client_put_steps_close_LDADD) $(LIBS) test_client_put_steps_hard_close$(EXEEXT): $(test_client_put_steps_hard_close_OBJECTS) $(test_client_put_steps_hard_close_DEPENDENCIES) $(EXTRA_test_client_put_steps_hard_close_DEPENDENCIES) @rm -f test_client_put_steps_hard_close$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_steps_hard_close_OBJECTS) $(test_client_put_steps_hard_close_LDADD) $(LIBS) test_client_put_steps_hard_close_stress_os$(EXEEXT): $(test_client_put_steps_hard_close_stress_os_OBJECTS) $(test_client_put_steps_hard_close_stress_os_DEPENDENCIES) $(EXTRA_test_client_put_steps_hard_close_stress_os_DEPENDENCIES) @rm -f test_client_put_steps_hard_close_stress_os$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_steps_hard_close_stress_os_OBJECTS) $(test_client_put_steps_hard_close_stress_os_LDADD) $(LIBS) test_client_put_steps_shutdown$(EXEEXT): $(test_client_put_steps_shutdown_OBJECTS) $(test_client_put_steps_shutdown_DEPENDENCIES) $(EXTRA_test_client_put_steps_shutdown_DEPENDENCIES) @rm -f test_client_put_steps_shutdown$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_client_put_steps_shutdown_OBJECTS) $(test_client_put_steps_shutdown_LDADD) $(LIBS) test_daemon$(EXEEXT): $(test_daemon_OBJECTS) $(test_daemon_DEPENDENCIES) $(EXTRA_test_daemon_DEPENDENCIES) @rm -f test_daemon$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_daemon_OBJECTS) $(test_daemon_LDADD) $(LIBS) test_dauth_userdigest$(EXEEXT): $(test_dauth_userdigest_OBJECTS) $(test_dauth_userdigest_DEPENDENCIES) $(EXTRA_test_dauth_userdigest_DEPENDENCIES) @rm -f test_dauth_userdigest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_dauth_userdigest_OBJECTS) $(test_dauth_userdigest_LDADD) $(LIBS) test_dauth_userhash$(EXEEXT): $(test_dauth_userhash_OBJECTS) $(test_dauth_userhash_DEPENDENCIES) $(EXTRA_test_dauth_userhash_DEPENDENCIES) @rm -f test_dauth_userhash$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_dauth_userhash_OBJECTS) $(test_dauth_userhash_LDADD) $(LIBS) test_http_reasons$(EXEEXT): $(test_http_reasons_OBJECTS) $(test_http_reasons_DEPENDENCIES) $(EXTRA_test_http_reasons_DEPENDENCIES) @rm -f test_http_reasons$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_http_reasons_OBJECTS) $(test_http_reasons_LDADD) $(LIBS) test_md5$(EXEEXT): $(test_md5_OBJECTS) $(test_md5_DEPENDENCIES) $(EXTRA_test_md5_DEPENDENCIES) @rm -f test_md5$(EXEEXT) $(AM_V_CCLD)$(test_md5_LINK) $(test_md5_OBJECTS) $(test_md5_LDADD) $(LIBS) test_mhd_version$(EXEEXT): $(test_mhd_version_OBJECTS) $(test_mhd_version_DEPENDENCIES) $(EXTRA_test_mhd_version_DEPENDENCIES) @rm -f test_mhd_version$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_mhd_version_OBJECTS) $(test_mhd_version_LDADD) $(LIBS) test_options$(EXEEXT): $(test_options_OBJECTS) $(test_options_DEPENDENCIES) $(EXTRA_test_options_DEPENDENCIES) @rm -f test_options$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_options_OBJECTS) $(test_options_LDADD) $(LIBS) test_postprocessor$(EXEEXT): $(test_postprocessor_OBJECTS) $(test_postprocessor_DEPENDENCIES) $(EXTRA_test_postprocessor_DEPENDENCIES) @rm -f test_postprocessor$(EXEEXT) $(AM_V_CCLD)$(test_postprocessor_LINK) $(test_postprocessor_OBJECTS) $(test_postprocessor_LDADD) $(LIBS) test_postprocessor_amp$(EXEEXT): $(test_postprocessor_amp_OBJECTS) $(test_postprocessor_amp_DEPENDENCIES) $(EXTRA_test_postprocessor_amp_DEPENDENCIES) @rm -f test_postprocessor_amp$(EXEEXT) $(AM_V_CCLD)$(test_postprocessor_amp_LINK) $(test_postprocessor_amp_OBJECTS) $(test_postprocessor_amp_LDADD) $(LIBS) test_postprocessor_large$(EXEEXT): $(test_postprocessor_large_OBJECTS) $(test_postprocessor_large_DEPENDENCIES) $(EXTRA_test_postprocessor_large_DEPENDENCIES) @rm -f test_postprocessor_large$(EXEEXT) $(AM_V_CCLD)$(test_postprocessor_large_LINK) $(test_postprocessor_large_OBJECTS) $(test_postprocessor_large_LDADD) $(LIBS) test_postprocessor_md$(EXEEXT): $(test_postprocessor_md_OBJECTS) $(test_postprocessor_md_DEPENDENCIES) $(EXTRA_test_postprocessor_md_DEPENDENCIES) @rm -f test_postprocessor_md$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_postprocessor_md_OBJECTS) $(test_postprocessor_md_LDADD) $(LIBS) test_response_entries$(EXEEXT): $(test_response_entries_OBJECTS) $(test_response_entries_DEPENDENCIES) $(EXTRA_test_response_entries_DEPENDENCIES) @rm -f test_response_entries$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_response_entries_OBJECTS) $(test_response_entries_LDADD) $(LIBS) test_set_panic$(EXEEXT): $(test_set_panic_OBJECTS) $(test_set_panic_DEPENDENCIES) $(EXTRA_test_set_panic_DEPENDENCIES) @rm -f test_set_panic$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_set_panic_OBJECTS) $(test_set_panic_LDADD) $(LIBS) test_sha1$(EXEEXT): $(test_sha1_OBJECTS) $(test_sha1_DEPENDENCIES) $(EXTRA_test_sha1_DEPENDENCIES) @rm -f test_sha1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_sha1_OBJECTS) $(test_sha1_LDADD) $(LIBS) test_sha256$(EXEEXT): $(test_sha256_OBJECTS) $(test_sha256_DEPENDENCIES) $(EXTRA_test_sha256_DEPENDENCIES) @rm -f test_sha256$(EXEEXT) $(AM_V_CCLD)$(test_sha256_LINK) $(test_sha256_OBJECTS) $(test_sha256_LDADD) $(LIBS) test_sha512_256$(EXEEXT): $(test_sha512_256_OBJECTS) $(test_sha512_256_DEPENDENCIES) $(EXTRA_test_sha512_256_DEPENDENCIES) @rm -f test_sha512_256$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_sha512_256_OBJECTS) $(test_sha512_256_LDADD) $(LIBS) test_shutdown_poll$(EXEEXT): $(test_shutdown_poll_OBJECTS) $(test_shutdown_poll_DEPENDENCIES) $(EXTRA_test_shutdown_poll_DEPENDENCIES) @rm -f test_shutdown_poll$(EXEEXT) $(AM_V_CCLD)$(test_shutdown_poll_LINK) $(test_shutdown_poll_OBJECTS) $(test_shutdown_poll_LDADD) $(LIBS) test_shutdown_poll_ignore$(EXEEXT): $(test_shutdown_poll_ignore_OBJECTS) $(test_shutdown_poll_ignore_DEPENDENCIES) $(EXTRA_test_shutdown_poll_ignore_DEPENDENCIES) @rm -f test_shutdown_poll_ignore$(EXEEXT) $(AM_V_CCLD)$(test_shutdown_poll_ignore_LINK) $(test_shutdown_poll_ignore_OBJECTS) $(test_shutdown_poll_ignore_LDADD) $(LIBS) test_shutdown_select$(EXEEXT): $(test_shutdown_select_OBJECTS) $(test_shutdown_select_DEPENDENCIES) $(EXTRA_test_shutdown_select_DEPENDENCIES) @rm -f test_shutdown_select$(EXEEXT) $(AM_V_CCLD)$(test_shutdown_select_LINK) $(test_shutdown_select_OBJECTS) $(test_shutdown_select_LDADD) $(LIBS) test_shutdown_select_ignore$(EXEEXT): $(test_shutdown_select_ignore_OBJECTS) $(test_shutdown_select_ignore_DEPENDENCIES) $(EXTRA_test_shutdown_select_ignore_DEPENDENCIES) @rm -f test_shutdown_select_ignore$(EXEEXT) $(AM_V_CCLD)$(test_shutdown_select_ignore_LINK) $(test_shutdown_select_ignore_OBJECTS) $(test_shutdown_select_ignore_LDADD) $(LIBS) test_start_stop$(EXEEXT): $(test_start_stop_OBJECTS) $(test_start_stop_DEPENDENCIES) $(EXTRA_test_start_stop_DEPENDENCIES) @rm -f test_start_stop$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_start_stop_OBJECTS) $(test_start_stop_LDADD) $(LIBS) test_str_base64$(EXEEXT): $(test_str_base64_OBJECTS) $(test_str_base64_DEPENDENCIES) $(EXTRA_test_str_base64_DEPENDENCIES) @rm -f test_str_base64$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_str_base64_OBJECTS) $(test_str_base64_LDADD) $(LIBS) test_str_bin_hex$(EXEEXT): $(test_str_bin_hex_OBJECTS) $(test_str_bin_hex_DEPENDENCIES) $(EXTRA_test_str_bin_hex_DEPENDENCIES) @rm -f test_str_bin_hex$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_str_bin_hex_OBJECTS) $(test_str_bin_hex_LDADD) $(LIBS) test_str_compare$(EXEEXT): $(test_str_compare_OBJECTS) $(test_str_compare_DEPENDENCIES) $(EXTRA_test_str_compare_DEPENDENCIES) @rm -f test_str_compare$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_str_compare_OBJECTS) $(test_str_compare_LDADD) $(LIBS) test_str_from_value$(EXEEXT): $(test_str_from_value_OBJECTS) $(test_str_from_value_DEPENDENCIES) $(EXTRA_test_str_from_value_DEPENDENCIES) @rm -f test_str_from_value$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_str_from_value_OBJECTS) $(test_str_from_value_LDADD) $(LIBS) test_str_pct$(EXEEXT): $(test_str_pct_OBJECTS) $(test_str_pct_DEPENDENCIES) $(EXTRA_test_str_pct_DEPENDENCIES) @rm -f test_str_pct$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_str_pct_OBJECTS) $(test_str_pct_LDADD) $(LIBS) test_str_quote$(EXEEXT): $(test_str_quote_OBJECTS) $(test_str_quote_DEPENDENCIES) $(EXTRA_test_str_quote_DEPENDENCIES) @rm -f test_str_quote$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_str_quote_OBJECTS) $(test_str_quote_LDADD) $(LIBS) test_str_to_value$(EXEEXT): $(test_str_to_value_OBJECTS) $(test_str_to_value_DEPENDENCIES) $(EXTRA_test_str_to_value_DEPENDENCIES) @rm -f test_str_to_value$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_str_to_value_OBJECTS) $(test_str_to_value_LDADD) $(LIBS) test_str_token$(EXEEXT): $(test_str_token_OBJECTS) $(test_str_token_DEPENDENCIES) $(EXTRA_test_str_token_DEPENDENCIES) @rm -f test_str_token$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_str_token_OBJECTS) $(test_str_token_LDADD) $(LIBS) test_str_token_remove$(EXEEXT): $(test_str_token_remove_OBJECTS) $(test_str_token_remove_DEPENDENCIES) $(EXTRA_test_str_token_remove_DEPENDENCIES) @rm -f test_str_token_remove$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_str_token_remove_OBJECTS) $(test_str_token_remove_LDADD) $(LIBS) test_str_tokens_remove$(EXEEXT): $(test_str_tokens_remove_OBJECTS) $(test_str_tokens_remove_DEPENDENCIES) $(EXTRA_test_str_tokens_remove_DEPENDENCIES) @rm -f test_str_tokens_remove$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_str_tokens_remove_OBJECTS) $(test_str_tokens_remove_LDADD) $(LIBS) test_upgrade$(EXEEXT): $(test_upgrade_OBJECTS) $(test_upgrade_DEPENDENCIES) $(EXTRA_test_upgrade_DEPENDENCIES) @rm -f test_upgrade$(EXEEXT) $(AM_V_CCLD)$(test_upgrade_LINK) $(test_upgrade_OBJECTS) $(test_upgrade_LDADD) $(LIBS) test_upgrade_large$(EXEEXT): $(test_upgrade_large_OBJECTS) $(test_upgrade_large_DEPENDENCIES) $(EXTRA_test_upgrade_large_DEPENDENCIES) @rm -f test_upgrade_large$(EXEEXT) $(AM_V_CCLD)$(test_upgrade_large_LINK) $(test_upgrade_large_OBJECTS) $(test_upgrade_large_LDADD) $(LIBS) test_upgrade_large_tls$(EXEEXT): $(test_upgrade_large_tls_OBJECTS) $(test_upgrade_large_tls_DEPENDENCIES) $(EXTRA_test_upgrade_large_tls_DEPENDENCIES) @rm -f test_upgrade_large_tls$(EXEEXT) $(AM_V_CCLD)$(test_upgrade_large_tls_LINK) $(test_upgrade_large_tls_OBJECTS) $(test_upgrade_large_tls_LDADD) $(LIBS) test_upgrade_tls$(EXEEXT): $(test_upgrade_tls_OBJECTS) $(test_upgrade_tls_DEPENDENCIES) $(EXTRA_test_upgrade_tls_DEPENDENCIES) @rm -f test_upgrade_tls$(EXEEXT) $(AM_V_CCLD)$(test_upgrade_tls_LINK) $(test_upgrade_tls_OBJECTS) $(test_upgrade_tls_LDADD) $(LIBS) test_upgrade_vlarge$(EXEEXT): $(test_upgrade_vlarge_OBJECTS) $(test_upgrade_vlarge_DEPENDENCIES) $(EXTRA_test_upgrade_vlarge_DEPENDENCIES) @rm -f test_upgrade_vlarge$(EXEEXT) $(AM_V_CCLD)$(test_upgrade_vlarge_LINK) $(test_upgrade_vlarge_OBJECTS) $(test_upgrade_vlarge_LDADD) $(LIBS) test_upgrade_vlarge_tls$(EXEEXT): $(test_upgrade_vlarge_tls_OBJECTS) $(test_upgrade_vlarge_tls_DEPENDENCIES) $(EXTRA_test_upgrade_vlarge_tls_DEPENDENCIES) @rm -f test_upgrade_vlarge_tls$(EXEEXT) $(AM_V_CCLD)$(test_upgrade_vlarge_tls_LINK) $(test_upgrade_vlarge_tls_OBJECTS) $(test_upgrade_vlarge_tls_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-basicauth.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-connection.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-connection_https.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-daemon.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-digestauth.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-gen_auth.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-internal.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-md5.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-md5_ext.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-memorypool.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-mhd_compat.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-mhd_itc.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-mhd_mono_clock.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-mhd_panic.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-mhd_send.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-mhd_sockets.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-mhd_str.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-mhd_threads.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-postprocessor.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-reason_phrase.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-response.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-sha256.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-sha256_ext.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-sha512_256.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-sysfdsetsize.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_la-tsearch.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mhd_str.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reason_phrase.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha512_256.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_auth_parse-gen_auth.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_auth_parse-mhd_str.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_auth_parse-test_auth_parse.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_client_put_stop.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_daemon.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dauth_userdigest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dauth_userhash.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_http_reasons.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_md5-md5.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_md5-md5_ext.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_md5-test_md5.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_mhd_version.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_options.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_postprocessor-test_postprocessor.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_postprocessor_amp-test_postprocessor_amp.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_postprocessor_large-test_postprocessor_large.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_postprocessor_md-internal.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_postprocessor_md-mhd_panic.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_postprocessor_md-mhd_str.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_postprocessor_md-postprocessor.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_postprocessor_md-test_postprocessor_md.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_response_entries.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_set_panic.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_sha1.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_sha256-sha256.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_sha256-sha256_ext.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_sha256-test_sha256.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_sha512_256.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_shutdown_poll-test_shutdown_select.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_shutdown_poll_ignore-test_shutdown_select.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_shutdown_select-test_shutdown_select.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_shutdown_select_ignore-test_shutdown_select.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_start_stop.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_str.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_str_base64.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_str_bin_hex.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_str_pct.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_str_quote.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_str_token.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_str_token_remove.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_str_tokens_remove.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_upgrade-test_upgrade.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_upgrade_large-test_upgrade.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_upgrade_large_tls-test_upgrade.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_upgrade_tls-test_upgrade.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_upgrade_vlarge-test_upgrade.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_upgrade_vlarge_tls-test_upgrade.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< libmicrohttpd_la-connection.lo: connection.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-connection.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-connection.Tpo -c -o libmicrohttpd_la-connection.lo `test -f 'connection.c' || echo '$(srcdir)/'`connection.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-connection.Tpo $(DEPDIR)/libmicrohttpd_la-connection.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection.c' object='libmicrohttpd_la-connection.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-connection.lo `test -f 'connection.c' || echo '$(srcdir)/'`connection.c libmicrohttpd_la-reason_phrase.lo: reason_phrase.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-reason_phrase.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-reason_phrase.Tpo -c -o libmicrohttpd_la-reason_phrase.lo `test -f 'reason_phrase.c' || echo '$(srcdir)/'`reason_phrase.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-reason_phrase.Tpo $(DEPDIR)/libmicrohttpd_la-reason_phrase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='reason_phrase.c' object='libmicrohttpd_la-reason_phrase.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-reason_phrase.lo `test -f 'reason_phrase.c' || echo '$(srcdir)/'`reason_phrase.c libmicrohttpd_la-daemon.lo: daemon.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-daemon.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-daemon.Tpo -c -o libmicrohttpd_la-daemon.lo `test -f 'daemon.c' || echo '$(srcdir)/'`daemon.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-daemon.Tpo $(DEPDIR)/libmicrohttpd_la-daemon.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='daemon.c' object='libmicrohttpd_la-daemon.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-daemon.lo `test -f 'daemon.c' || echo '$(srcdir)/'`daemon.c libmicrohttpd_la-internal.lo: internal.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-internal.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-internal.Tpo -c -o libmicrohttpd_la-internal.lo `test -f 'internal.c' || echo '$(srcdir)/'`internal.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-internal.Tpo $(DEPDIR)/libmicrohttpd_la-internal.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='internal.c' object='libmicrohttpd_la-internal.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-internal.lo `test -f 'internal.c' || echo '$(srcdir)/'`internal.c libmicrohttpd_la-memorypool.lo: memorypool.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-memorypool.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-memorypool.Tpo -c -o libmicrohttpd_la-memorypool.lo `test -f 'memorypool.c' || echo '$(srcdir)/'`memorypool.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-memorypool.Tpo $(DEPDIR)/libmicrohttpd_la-memorypool.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='memorypool.c' object='libmicrohttpd_la-memorypool.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-memorypool.lo `test -f 'memorypool.c' || echo '$(srcdir)/'`memorypool.c libmicrohttpd_la-mhd_mono_clock.lo: mhd_mono_clock.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-mhd_mono_clock.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-mhd_mono_clock.Tpo -c -o libmicrohttpd_la-mhd_mono_clock.lo `test -f 'mhd_mono_clock.c' || echo '$(srcdir)/'`mhd_mono_clock.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-mhd_mono_clock.Tpo $(DEPDIR)/libmicrohttpd_la-mhd_mono_clock.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_mono_clock.c' object='libmicrohttpd_la-mhd_mono_clock.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-mhd_mono_clock.lo `test -f 'mhd_mono_clock.c' || echo '$(srcdir)/'`mhd_mono_clock.c libmicrohttpd_la-mhd_str.lo: mhd_str.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-mhd_str.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-mhd_str.Tpo -c -o libmicrohttpd_la-mhd_str.lo `test -f 'mhd_str.c' || echo '$(srcdir)/'`mhd_str.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-mhd_str.Tpo $(DEPDIR)/libmicrohttpd_la-mhd_str.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_str.c' object='libmicrohttpd_la-mhd_str.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-mhd_str.lo `test -f 'mhd_str.c' || echo '$(srcdir)/'`mhd_str.c libmicrohttpd_la-mhd_send.lo: mhd_send.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-mhd_send.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-mhd_send.Tpo -c -o libmicrohttpd_la-mhd_send.lo `test -f 'mhd_send.c' || echo '$(srcdir)/'`mhd_send.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-mhd_send.Tpo $(DEPDIR)/libmicrohttpd_la-mhd_send.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_send.c' object='libmicrohttpd_la-mhd_send.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-mhd_send.lo `test -f 'mhd_send.c' || echo '$(srcdir)/'`mhd_send.c libmicrohttpd_la-mhd_sockets.lo: mhd_sockets.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-mhd_sockets.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-mhd_sockets.Tpo -c -o libmicrohttpd_la-mhd_sockets.lo `test -f 'mhd_sockets.c' || echo '$(srcdir)/'`mhd_sockets.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-mhd_sockets.Tpo $(DEPDIR)/libmicrohttpd_la-mhd_sockets.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_sockets.c' object='libmicrohttpd_la-mhd_sockets.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-mhd_sockets.lo `test -f 'mhd_sockets.c' || echo '$(srcdir)/'`mhd_sockets.c libmicrohttpd_la-mhd_itc.lo: mhd_itc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-mhd_itc.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-mhd_itc.Tpo -c -o libmicrohttpd_la-mhd_itc.lo `test -f 'mhd_itc.c' || echo '$(srcdir)/'`mhd_itc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-mhd_itc.Tpo $(DEPDIR)/libmicrohttpd_la-mhd_itc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_itc.c' object='libmicrohttpd_la-mhd_itc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-mhd_itc.lo `test -f 'mhd_itc.c' || echo '$(srcdir)/'`mhd_itc.c libmicrohttpd_la-mhd_compat.lo: mhd_compat.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-mhd_compat.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-mhd_compat.Tpo -c -o libmicrohttpd_la-mhd_compat.lo `test -f 'mhd_compat.c' || echo '$(srcdir)/'`mhd_compat.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-mhd_compat.Tpo $(DEPDIR)/libmicrohttpd_la-mhd_compat.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_compat.c' object='libmicrohttpd_la-mhd_compat.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-mhd_compat.lo `test -f 'mhd_compat.c' || echo '$(srcdir)/'`mhd_compat.c libmicrohttpd_la-mhd_panic.lo: mhd_panic.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-mhd_panic.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-mhd_panic.Tpo -c -o libmicrohttpd_la-mhd_panic.lo `test -f 'mhd_panic.c' || echo '$(srcdir)/'`mhd_panic.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-mhd_panic.Tpo $(DEPDIR)/libmicrohttpd_la-mhd_panic.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_panic.c' object='libmicrohttpd_la-mhd_panic.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-mhd_panic.lo `test -f 'mhd_panic.c' || echo '$(srcdir)/'`mhd_panic.c libmicrohttpd_la-response.lo: response.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-response.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-response.Tpo -c -o libmicrohttpd_la-response.lo `test -f 'response.c' || echo '$(srcdir)/'`response.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-response.Tpo $(DEPDIR)/libmicrohttpd_la-response.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='response.c' object='libmicrohttpd_la-response.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-response.lo `test -f 'response.c' || echo '$(srcdir)/'`response.c libmicrohttpd_la-mhd_threads.lo: mhd_threads.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-mhd_threads.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-mhd_threads.Tpo -c -o libmicrohttpd_la-mhd_threads.lo `test -f 'mhd_threads.c' || echo '$(srcdir)/'`mhd_threads.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-mhd_threads.Tpo $(DEPDIR)/libmicrohttpd_la-mhd_threads.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_threads.c' object='libmicrohttpd_la-mhd_threads.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-mhd_threads.lo `test -f 'mhd_threads.c' || echo '$(srcdir)/'`mhd_threads.c libmicrohttpd_la-sysfdsetsize.lo: sysfdsetsize.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-sysfdsetsize.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-sysfdsetsize.Tpo -c -o libmicrohttpd_la-sysfdsetsize.lo `test -f 'sysfdsetsize.c' || echo '$(srcdir)/'`sysfdsetsize.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-sysfdsetsize.Tpo $(DEPDIR)/libmicrohttpd_la-sysfdsetsize.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sysfdsetsize.c' object='libmicrohttpd_la-sysfdsetsize.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-sysfdsetsize.lo `test -f 'sysfdsetsize.c' || echo '$(srcdir)/'`sysfdsetsize.c libmicrohttpd_la-tsearch.lo: tsearch.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-tsearch.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-tsearch.Tpo -c -o libmicrohttpd_la-tsearch.lo `test -f 'tsearch.c' || echo '$(srcdir)/'`tsearch.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-tsearch.Tpo $(DEPDIR)/libmicrohttpd_la-tsearch.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tsearch.c' object='libmicrohttpd_la-tsearch.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-tsearch.lo `test -f 'tsearch.c' || echo '$(srcdir)/'`tsearch.c libmicrohttpd_la-postprocessor.lo: postprocessor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-postprocessor.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-postprocessor.Tpo -c -o libmicrohttpd_la-postprocessor.lo `test -f 'postprocessor.c' || echo '$(srcdir)/'`postprocessor.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-postprocessor.Tpo $(DEPDIR)/libmicrohttpd_la-postprocessor.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='postprocessor.c' object='libmicrohttpd_la-postprocessor.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-postprocessor.lo `test -f 'postprocessor.c' || echo '$(srcdir)/'`postprocessor.c libmicrohttpd_la-gen_auth.lo: gen_auth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-gen_auth.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-gen_auth.Tpo -c -o libmicrohttpd_la-gen_auth.lo `test -f 'gen_auth.c' || echo '$(srcdir)/'`gen_auth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-gen_auth.Tpo $(DEPDIR)/libmicrohttpd_la-gen_auth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gen_auth.c' object='libmicrohttpd_la-gen_auth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-gen_auth.lo `test -f 'gen_auth.c' || echo '$(srcdir)/'`gen_auth.c libmicrohttpd_la-digestauth.lo: digestauth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-digestauth.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-digestauth.Tpo -c -o libmicrohttpd_la-digestauth.lo `test -f 'digestauth.c' || echo '$(srcdir)/'`digestauth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-digestauth.Tpo $(DEPDIR)/libmicrohttpd_la-digestauth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='digestauth.c' object='libmicrohttpd_la-digestauth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-digestauth.lo `test -f 'digestauth.c' || echo '$(srcdir)/'`digestauth.c libmicrohttpd_la-md5.lo: md5.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-md5.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-md5.Tpo -c -o libmicrohttpd_la-md5.lo `test -f 'md5.c' || echo '$(srcdir)/'`md5.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-md5.Tpo $(DEPDIR)/libmicrohttpd_la-md5.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5.c' object='libmicrohttpd_la-md5.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-md5.lo `test -f 'md5.c' || echo '$(srcdir)/'`md5.c libmicrohttpd_la-md5_ext.lo: md5_ext.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-md5_ext.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-md5_ext.Tpo -c -o libmicrohttpd_la-md5_ext.lo `test -f 'md5_ext.c' || echo '$(srcdir)/'`md5_ext.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-md5_ext.Tpo $(DEPDIR)/libmicrohttpd_la-md5_ext.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5_ext.c' object='libmicrohttpd_la-md5_ext.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-md5_ext.lo `test -f 'md5_ext.c' || echo '$(srcdir)/'`md5_ext.c libmicrohttpd_la-sha256.lo: sha256.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-sha256.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-sha256.Tpo -c -o libmicrohttpd_la-sha256.lo `test -f 'sha256.c' || echo '$(srcdir)/'`sha256.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-sha256.Tpo $(DEPDIR)/libmicrohttpd_la-sha256.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha256.c' object='libmicrohttpd_la-sha256.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-sha256.lo `test -f 'sha256.c' || echo '$(srcdir)/'`sha256.c libmicrohttpd_la-sha256_ext.lo: sha256_ext.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-sha256_ext.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-sha256_ext.Tpo -c -o libmicrohttpd_la-sha256_ext.lo `test -f 'sha256_ext.c' || echo '$(srcdir)/'`sha256_ext.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-sha256_ext.Tpo $(DEPDIR)/libmicrohttpd_la-sha256_ext.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha256_ext.c' object='libmicrohttpd_la-sha256_ext.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-sha256_ext.lo `test -f 'sha256_ext.c' || echo '$(srcdir)/'`sha256_ext.c libmicrohttpd_la-sha512_256.lo: sha512_256.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-sha512_256.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-sha512_256.Tpo -c -o libmicrohttpd_la-sha512_256.lo `test -f 'sha512_256.c' || echo '$(srcdir)/'`sha512_256.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-sha512_256.Tpo $(DEPDIR)/libmicrohttpd_la-sha512_256.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha512_256.c' object='libmicrohttpd_la-sha512_256.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-sha512_256.lo `test -f 'sha512_256.c' || echo '$(srcdir)/'`sha512_256.c libmicrohttpd_la-basicauth.lo: basicauth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-basicauth.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-basicauth.Tpo -c -o libmicrohttpd_la-basicauth.lo `test -f 'basicauth.c' || echo '$(srcdir)/'`basicauth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-basicauth.Tpo $(DEPDIR)/libmicrohttpd_la-basicauth.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='basicauth.c' object='libmicrohttpd_la-basicauth.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-basicauth.lo `test -f 'basicauth.c' || echo '$(srcdir)/'`basicauth.c libmicrohttpd_la-connection_https.lo: connection_https.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_la-connection_https.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_la-connection_https.Tpo -c -o libmicrohttpd_la-connection_https.lo `test -f 'connection_https.c' || echo '$(srcdir)/'`connection_https.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_la-connection_https.Tpo $(DEPDIR)/libmicrohttpd_la-connection_https.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection_https.c' object='libmicrohttpd_la-connection_https.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_la-connection_https.lo `test -f 'connection_https.c' || echo '$(srcdir)/'`connection_https.c test_auth_parse-test_auth_parse.o: test_auth_parse.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_auth_parse-test_auth_parse.o -MD -MP -MF $(DEPDIR)/test_auth_parse-test_auth_parse.Tpo -c -o test_auth_parse-test_auth_parse.o `test -f 'test_auth_parse.c' || echo '$(srcdir)/'`test_auth_parse.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_auth_parse-test_auth_parse.Tpo $(DEPDIR)/test_auth_parse-test_auth_parse.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_auth_parse.c' object='test_auth_parse-test_auth_parse.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_auth_parse-test_auth_parse.o `test -f 'test_auth_parse.c' || echo '$(srcdir)/'`test_auth_parse.c test_auth_parse-test_auth_parse.obj: test_auth_parse.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_auth_parse-test_auth_parse.obj -MD -MP -MF $(DEPDIR)/test_auth_parse-test_auth_parse.Tpo -c -o test_auth_parse-test_auth_parse.obj `if test -f 'test_auth_parse.c'; then $(CYGPATH_W) 'test_auth_parse.c'; else $(CYGPATH_W) '$(srcdir)/test_auth_parse.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_auth_parse-test_auth_parse.Tpo $(DEPDIR)/test_auth_parse-test_auth_parse.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_auth_parse.c' object='test_auth_parse-test_auth_parse.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_auth_parse-test_auth_parse.obj `if test -f 'test_auth_parse.c'; then $(CYGPATH_W) 'test_auth_parse.c'; else $(CYGPATH_W) '$(srcdir)/test_auth_parse.c'; fi` test_auth_parse-gen_auth.o: gen_auth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_auth_parse-gen_auth.o -MD -MP -MF $(DEPDIR)/test_auth_parse-gen_auth.Tpo -c -o test_auth_parse-gen_auth.o `test -f 'gen_auth.c' || echo '$(srcdir)/'`gen_auth.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_auth_parse-gen_auth.Tpo $(DEPDIR)/test_auth_parse-gen_auth.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gen_auth.c' object='test_auth_parse-gen_auth.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_auth_parse-gen_auth.o `test -f 'gen_auth.c' || echo '$(srcdir)/'`gen_auth.c test_auth_parse-gen_auth.obj: gen_auth.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_auth_parse-gen_auth.obj -MD -MP -MF $(DEPDIR)/test_auth_parse-gen_auth.Tpo -c -o test_auth_parse-gen_auth.obj `if test -f 'gen_auth.c'; then $(CYGPATH_W) 'gen_auth.c'; else $(CYGPATH_W) '$(srcdir)/gen_auth.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_auth_parse-gen_auth.Tpo $(DEPDIR)/test_auth_parse-gen_auth.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gen_auth.c' object='test_auth_parse-gen_auth.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_auth_parse-gen_auth.obj `if test -f 'gen_auth.c'; then $(CYGPATH_W) 'gen_auth.c'; else $(CYGPATH_W) '$(srcdir)/gen_auth.c'; fi` test_auth_parse-mhd_str.o: mhd_str.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_auth_parse-mhd_str.o -MD -MP -MF $(DEPDIR)/test_auth_parse-mhd_str.Tpo -c -o test_auth_parse-mhd_str.o `test -f 'mhd_str.c' || echo '$(srcdir)/'`mhd_str.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_auth_parse-mhd_str.Tpo $(DEPDIR)/test_auth_parse-mhd_str.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_str.c' object='test_auth_parse-mhd_str.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_auth_parse-mhd_str.o `test -f 'mhd_str.c' || echo '$(srcdir)/'`mhd_str.c test_auth_parse-mhd_str.obj: mhd_str.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_auth_parse-mhd_str.obj -MD -MP -MF $(DEPDIR)/test_auth_parse-mhd_str.Tpo -c -o test_auth_parse-mhd_str.obj `if test -f 'mhd_str.c'; then $(CYGPATH_W) 'mhd_str.c'; else $(CYGPATH_W) '$(srcdir)/mhd_str.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_auth_parse-mhd_str.Tpo $(DEPDIR)/test_auth_parse-mhd_str.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_str.c' object='test_auth_parse-mhd_str.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_auth_parse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_auth_parse-mhd_str.obj `if test -f 'mhd_str.c'; then $(CYGPATH_W) 'mhd_str.c'; else $(CYGPATH_W) '$(srcdir)/mhd_str.c'; fi` test_md5-test_md5.o: test_md5.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -MT test_md5-test_md5.o -MD -MP -MF $(DEPDIR)/test_md5-test_md5.Tpo -c -o test_md5-test_md5.o `test -f 'test_md5.c' || echo '$(srcdir)/'`test_md5.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_md5-test_md5.Tpo $(DEPDIR)/test_md5-test_md5.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_md5.c' object='test_md5-test_md5.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -c -o test_md5-test_md5.o `test -f 'test_md5.c' || echo '$(srcdir)/'`test_md5.c test_md5-test_md5.obj: test_md5.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -MT test_md5-test_md5.obj -MD -MP -MF $(DEPDIR)/test_md5-test_md5.Tpo -c -o test_md5-test_md5.obj `if test -f 'test_md5.c'; then $(CYGPATH_W) 'test_md5.c'; else $(CYGPATH_W) '$(srcdir)/test_md5.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_md5-test_md5.Tpo $(DEPDIR)/test_md5-test_md5.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_md5.c' object='test_md5-test_md5.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -c -o test_md5-test_md5.obj `if test -f 'test_md5.c'; then $(CYGPATH_W) 'test_md5.c'; else $(CYGPATH_W) '$(srcdir)/test_md5.c'; fi` test_md5-md5.o: md5.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -MT test_md5-md5.o -MD -MP -MF $(DEPDIR)/test_md5-md5.Tpo -c -o test_md5-md5.o `test -f 'md5.c' || echo '$(srcdir)/'`md5.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_md5-md5.Tpo $(DEPDIR)/test_md5-md5.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5.c' object='test_md5-md5.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -c -o test_md5-md5.o `test -f 'md5.c' || echo '$(srcdir)/'`md5.c test_md5-md5.obj: md5.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -MT test_md5-md5.obj -MD -MP -MF $(DEPDIR)/test_md5-md5.Tpo -c -o test_md5-md5.obj `if test -f 'md5.c'; then $(CYGPATH_W) 'md5.c'; else $(CYGPATH_W) '$(srcdir)/md5.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_md5-md5.Tpo $(DEPDIR)/test_md5-md5.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5.c' object='test_md5-md5.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -c -o test_md5-md5.obj `if test -f 'md5.c'; then $(CYGPATH_W) 'md5.c'; else $(CYGPATH_W) '$(srcdir)/md5.c'; fi` test_md5-md5_ext.o: md5_ext.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -MT test_md5-md5_ext.o -MD -MP -MF $(DEPDIR)/test_md5-md5_ext.Tpo -c -o test_md5-md5_ext.o `test -f 'md5_ext.c' || echo '$(srcdir)/'`md5_ext.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_md5-md5_ext.Tpo $(DEPDIR)/test_md5-md5_ext.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5_ext.c' object='test_md5-md5_ext.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -c -o test_md5-md5_ext.o `test -f 'md5_ext.c' || echo '$(srcdir)/'`md5_ext.c test_md5-md5_ext.obj: md5_ext.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -MT test_md5-md5_ext.obj -MD -MP -MF $(DEPDIR)/test_md5-md5_ext.Tpo -c -o test_md5-md5_ext.obj `if test -f 'md5_ext.c'; then $(CYGPATH_W) 'md5_ext.c'; else $(CYGPATH_W) '$(srcdir)/md5_ext.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_md5-md5_ext.Tpo $(DEPDIR)/test_md5-md5_ext.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5_ext.c' object='test_md5-md5_ext.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_md5_CPPFLAGS) $(CPPFLAGS) $(test_md5_CFLAGS) $(CFLAGS) -c -o test_md5-md5_ext.obj `if test -f 'md5_ext.c'; then $(CYGPATH_W) 'md5_ext.c'; else $(CYGPATH_W) '$(srcdir)/md5_ext.c'; fi` test_postprocessor-test_postprocessor.o: test_postprocessor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_CFLAGS) $(CFLAGS) -MT test_postprocessor-test_postprocessor.o -MD -MP -MF $(DEPDIR)/test_postprocessor-test_postprocessor.Tpo -c -o test_postprocessor-test_postprocessor.o `test -f 'test_postprocessor.c' || echo '$(srcdir)/'`test_postprocessor.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor-test_postprocessor.Tpo $(DEPDIR)/test_postprocessor-test_postprocessor.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_postprocessor.c' object='test_postprocessor-test_postprocessor.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_CFLAGS) $(CFLAGS) -c -o test_postprocessor-test_postprocessor.o `test -f 'test_postprocessor.c' || echo '$(srcdir)/'`test_postprocessor.c test_postprocessor-test_postprocessor.obj: test_postprocessor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_CFLAGS) $(CFLAGS) -MT test_postprocessor-test_postprocessor.obj -MD -MP -MF $(DEPDIR)/test_postprocessor-test_postprocessor.Tpo -c -o test_postprocessor-test_postprocessor.obj `if test -f 'test_postprocessor.c'; then $(CYGPATH_W) 'test_postprocessor.c'; else $(CYGPATH_W) '$(srcdir)/test_postprocessor.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor-test_postprocessor.Tpo $(DEPDIR)/test_postprocessor-test_postprocessor.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_postprocessor.c' object='test_postprocessor-test_postprocessor.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_CFLAGS) $(CFLAGS) -c -o test_postprocessor-test_postprocessor.obj `if test -f 'test_postprocessor.c'; then $(CYGPATH_W) 'test_postprocessor.c'; else $(CYGPATH_W) '$(srcdir)/test_postprocessor.c'; fi` test_postprocessor_amp-test_postprocessor_amp.o: test_postprocessor_amp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_amp_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_amp_CFLAGS) $(CFLAGS) -MT test_postprocessor_amp-test_postprocessor_amp.o -MD -MP -MF $(DEPDIR)/test_postprocessor_amp-test_postprocessor_amp.Tpo -c -o test_postprocessor_amp-test_postprocessor_amp.o `test -f 'test_postprocessor_amp.c' || echo '$(srcdir)/'`test_postprocessor_amp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_amp-test_postprocessor_amp.Tpo $(DEPDIR)/test_postprocessor_amp-test_postprocessor_amp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_postprocessor_amp.c' object='test_postprocessor_amp-test_postprocessor_amp.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_amp_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_amp_CFLAGS) $(CFLAGS) -c -o test_postprocessor_amp-test_postprocessor_amp.o `test -f 'test_postprocessor_amp.c' || echo '$(srcdir)/'`test_postprocessor_amp.c test_postprocessor_amp-test_postprocessor_amp.obj: test_postprocessor_amp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_amp_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_amp_CFLAGS) $(CFLAGS) -MT test_postprocessor_amp-test_postprocessor_amp.obj -MD -MP -MF $(DEPDIR)/test_postprocessor_amp-test_postprocessor_amp.Tpo -c -o test_postprocessor_amp-test_postprocessor_amp.obj `if test -f 'test_postprocessor_amp.c'; then $(CYGPATH_W) 'test_postprocessor_amp.c'; else $(CYGPATH_W) '$(srcdir)/test_postprocessor_amp.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_amp-test_postprocessor_amp.Tpo $(DEPDIR)/test_postprocessor_amp-test_postprocessor_amp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_postprocessor_amp.c' object='test_postprocessor_amp-test_postprocessor_amp.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_amp_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_amp_CFLAGS) $(CFLAGS) -c -o test_postprocessor_amp-test_postprocessor_amp.obj `if test -f 'test_postprocessor_amp.c'; then $(CYGPATH_W) 'test_postprocessor_amp.c'; else $(CYGPATH_W) '$(srcdir)/test_postprocessor_amp.c'; fi` test_postprocessor_large-test_postprocessor_large.o: test_postprocessor_large.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_large_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_large_CFLAGS) $(CFLAGS) -MT test_postprocessor_large-test_postprocessor_large.o -MD -MP -MF $(DEPDIR)/test_postprocessor_large-test_postprocessor_large.Tpo -c -o test_postprocessor_large-test_postprocessor_large.o `test -f 'test_postprocessor_large.c' || echo '$(srcdir)/'`test_postprocessor_large.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_large-test_postprocessor_large.Tpo $(DEPDIR)/test_postprocessor_large-test_postprocessor_large.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_postprocessor_large.c' object='test_postprocessor_large-test_postprocessor_large.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_large_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_large_CFLAGS) $(CFLAGS) -c -o test_postprocessor_large-test_postprocessor_large.o `test -f 'test_postprocessor_large.c' || echo '$(srcdir)/'`test_postprocessor_large.c test_postprocessor_large-test_postprocessor_large.obj: test_postprocessor_large.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_large_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_large_CFLAGS) $(CFLAGS) -MT test_postprocessor_large-test_postprocessor_large.obj -MD -MP -MF $(DEPDIR)/test_postprocessor_large-test_postprocessor_large.Tpo -c -o test_postprocessor_large-test_postprocessor_large.obj `if test -f 'test_postprocessor_large.c'; then $(CYGPATH_W) 'test_postprocessor_large.c'; else $(CYGPATH_W) '$(srcdir)/test_postprocessor_large.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_large-test_postprocessor_large.Tpo $(DEPDIR)/test_postprocessor_large-test_postprocessor_large.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_postprocessor_large.c' object='test_postprocessor_large-test_postprocessor_large.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_large_CPPFLAGS) $(CPPFLAGS) $(test_postprocessor_large_CFLAGS) $(CFLAGS) -c -o test_postprocessor_large-test_postprocessor_large.obj `if test -f 'test_postprocessor_large.c'; then $(CYGPATH_W) 'test_postprocessor_large.c'; else $(CYGPATH_W) '$(srcdir)/test_postprocessor_large.c'; fi` test_postprocessor_md-test_postprocessor_md.o: test_postprocessor_md.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_postprocessor_md-test_postprocessor_md.o -MD -MP -MF $(DEPDIR)/test_postprocessor_md-test_postprocessor_md.Tpo -c -o test_postprocessor_md-test_postprocessor_md.o `test -f 'test_postprocessor_md.c' || echo '$(srcdir)/'`test_postprocessor_md.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_md-test_postprocessor_md.Tpo $(DEPDIR)/test_postprocessor_md-test_postprocessor_md.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_postprocessor_md.c' object='test_postprocessor_md-test_postprocessor_md.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_postprocessor_md-test_postprocessor_md.o `test -f 'test_postprocessor_md.c' || echo '$(srcdir)/'`test_postprocessor_md.c test_postprocessor_md-test_postprocessor_md.obj: test_postprocessor_md.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_postprocessor_md-test_postprocessor_md.obj -MD -MP -MF $(DEPDIR)/test_postprocessor_md-test_postprocessor_md.Tpo -c -o test_postprocessor_md-test_postprocessor_md.obj `if test -f 'test_postprocessor_md.c'; then $(CYGPATH_W) 'test_postprocessor_md.c'; else $(CYGPATH_W) '$(srcdir)/test_postprocessor_md.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_md-test_postprocessor_md.Tpo $(DEPDIR)/test_postprocessor_md-test_postprocessor_md.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_postprocessor_md.c' object='test_postprocessor_md-test_postprocessor_md.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_postprocessor_md-test_postprocessor_md.obj `if test -f 'test_postprocessor_md.c'; then $(CYGPATH_W) 'test_postprocessor_md.c'; else $(CYGPATH_W) '$(srcdir)/test_postprocessor_md.c'; fi` test_postprocessor_md-postprocessor.o: postprocessor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_postprocessor_md-postprocessor.o -MD -MP -MF $(DEPDIR)/test_postprocessor_md-postprocessor.Tpo -c -o test_postprocessor_md-postprocessor.o `test -f 'postprocessor.c' || echo '$(srcdir)/'`postprocessor.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_md-postprocessor.Tpo $(DEPDIR)/test_postprocessor_md-postprocessor.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='postprocessor.c' object='test_postprocessor_md-postprocessor.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_postprocessor_md-postprocessor.o `test -f 'postprocessor.c' || echo '$(srcdir)/'`postprocessor.c test_postprocessor_md-postprocessor.obj: postprocessor.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_postprocessor_md-postprocessor.obj -MD -MP -MF $(DEPDIR)/test_postprocessor_md-postprocessor.Tpo -c -o test_postprocessor_md-postprocessor.obj `if test -f 'postprocessor.c'; then $(CYGPATH_W) 'postprocessor.c'; else $(CYGPATH_W) '$(srcdir)/postprocessor.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_md-postprocessor.Tpo $(DEPDIR)/test_postprocessor_md-postprocessor.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='postprocessor.c' object='test_postprocessor_md-postprocessor.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_postprocessor_md-postprocessor.obj `if test -f 'postprocessor.c'; then $(CYGPATH_W) 'postprocessor.c'; else $(CYGPATH_W) '$(srcdir)/postprocessor.c'; fi` test_postprocessor_md-internal.o: internal.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_postprocessor_md-internal.o -MD -MP -MF $(DEPDIR)/test_postprocessor_md-internal.Tpo -c -o test_postprocessor_md-internal.o `test -f 'internal.c' || echo '$(srcdir)/'`internal.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_md-internal.Tpo $(DEPDIR)/test_postprocessor_md-internal.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='internal.c' object='test_postprocessor_md-internal.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_postprocessor_md-internal.o `test -f 'internal.c' || echo '$(srcdir)/'`internal.c test_postprocessor_md-internal.obj: internal.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_postprocessor_md-internal.obj -MD -MP -MF $(DEPDIR)/test_postprocessor_md-internal.Tpo -c -o test_postprocessor_md-internal.obj `if test -f 'internal.c'; then $(CYGPATH_W) 'internal.c'; else $(CYGPATH_W) '$(srcdir)/internal.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_md-internal.Tpo $(DEPDIR)/test_postprocessor_md-internal.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='internal.c' object='test_postprocessor_md-internal.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_postprocessor_md-internal.obj `if test -f 'internal.c'; then $(CYGPATH_W) 'internal.c'; else $(CYGPATH_W) '$(srcdir)/internal.c'; fi` test_postprocessor_md-mhd_str.o: mhd_str.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_postprocessor_md-mhd_str.o -MD -MP -MF $(DEPDIR)/test_postprocessor_md-mhd_str.Tpo -c -o test_postprocessor_md-mhd_str.o `test -f 'mhd_str.c' || echo '$(srcdir)/'`mhd_str.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_md-mhd_str.Tpo $(DEPDIR)/test_postprocessor_md-mhd_str.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_str.c' object='test_postprocessor_md-mhd_str.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_postprocessor_md-mhd_str.o `test -f 'mhd_str.c' || echo '$(srcdir)/'`mhd_str.c test_postprocessor_md-mhd_str.obj: mhd_str.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_postprocessor_md-mhd_str.obj -MD -MP -MF $(DEPDIR)/test_postprocessor_md-mhd_str.Tpo -c -o test_postprocessor_md-mhd_str.obj `if test -f 'mhd_str.c'; then $(CYGPATH_W) 'mhd_str.c'; else $(CYGPATH_W) '$(srcdir)/mhd_str.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_md-mhd_str.Tpo $(DEPDIR)/test_postprocessor_md-mhd_str.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_str.c' object='test_postprocessor_md-mhd_str.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_postprocessor_md-mhd_str.obj `if test -f 'mhd_str.c'; then $(CYGPATH_W) 'mhd_str.c'; else $(CYGPATH_W) '$(srcdir)/mhd_str.c'; fi` test_postprocessor_md-mhd_panic.o: mhd_panic.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_postprocessor_md-mhd_panic.o -MD -MP -MF $(DEPDIR)/test_postprocessor_md-mhd_panic.Tpo -c -o test_postprocessor_md-mhd_panic.o `test -f 'mhd_panic.c' || echo '$(srcdir)/'`mhd_panic.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_md-mhd_panic.Tpo $(DEPDIR)/test_postprocessor_md-mhd_panic.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_panic.c' object='test_postprocessor_md-mhd_panic.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_postprocessor_md-mhd_panic.o `test -f 'mhd_panic.c' || echo '$(srcdir)/'`mhd_panic.c test_postprocessor_md-mhd_panic.obj: mhd_panic.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_postprocessor_md-mhd_panic.obj -MD -MP -MF $(DEPDIR)/test_postprocessor_md-mhd_panic.Tpo -c -o test_postprocessor_md-mhd_panic.obj `if test -f 'mhd_panic.c'; then $(CYGPATH_W) 'mhd_panic.c'; else $(CYGPATH_W) '$(srcdir)/mhd_panic.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_postprocessor_md-mhd_panic.Tpo $(DEPDIR)/test_postprocessor_md-mhd_panic.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_panic.c' object='test_postprocessor_md-mhd_panic.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_postprocessor_md_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_postprocessor_md-mhd_panic.obj `if test -f 'mhd_panic.c'; then $(CYGPATH_W) 'mhd_panic.c'; else $(CYGPATH_W) '$(srcdir)/mhd_panic.c'; fi` test_sha256-test_sha256.o: test_sha256.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -MT test_sha256-test_sha256.o -MD -MP -MF $(DEPDIR)/test_sha256-test_sha256.Tpo -c -o test_sha256-test_sha256.o `test -f 'test_sha256.c' || echo '$(srcdir)/'`test_sha256.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_sha256-test_sha256.Tpo $(DEPDIR)/test_sha256-test_sha256.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_sha256.c' object='test_sha256-test_sha256.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -c -o test_sha256-test_sha256.o `test -f 'test_sha256.c' || echo '$(srcdir)/'`test_sha256.c test_sha256-test_sha256.obj: test_sha256.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -MT test_sha256-test_sha256.obj -MD -MP -MF $(DEPDIR)/test_sha256-test_sha256.Tpo -c -o test_sha256-test_sha256.obj `if test -f 'test_sha256.c'; then $(CYGPATH_W) 'test_sha256.c'; else $(CYGPATH_W) '$(srcdir)/test_sha256.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_sha256-test_sha256.Tpo $(DEPDIR)/test_sha256-test_sha256.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_sha256.c' object='test_sha256-test_sha256.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -c -o test_sha256-test_sha256.obj `if test -f 'test_sha256.c'; then $(CYGPATH_W) 'test_sha256.c'; else $(CYGPATH_W) '$(srcdir)/test_sha256.c'; fi` test_sha256-sha256.o: sha256.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -MT test_sha256-sha256.o -MD -MP -MF $(DEPDIR)/test_sha256-sha256.Tpo -c -o test_sha256-sha256.o `test -f 'sha256.c' || echo '$(srcdir)/'`sha256.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_sha256-sha256.Tpo $(DEPDIR)/test_sha256-sha256.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha256.c' object='test_sha256-sha256.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -c -o test_sha256-sha256.o `test -f 'sha256.c' || echo '$(srcdir)/'`sha256.c test_sha256-sha256.obj: sha256.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -MT test_sha256-sha256.obj -MD -MP -MF $(DEPDIR)/test_sha256-sha256.Tpo -c -o test_sha256-sha256.obj `if test -f 'sha256.c'; then $(CYGPATH_W) 'sha256.c'; else $(CYGPATH_W) '$(srcdir)/sha256.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_sha256-sha256.Tpo $(DEPDIR)/test_sha256-sha256.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha256.c' object='test_sha256-sha256.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -c -o test_sha256-sha256.obj `if test -f 'sha256.c'; then $(CYGPATH_W) 'sha256.c'; else $(CYGPATH_W) '$(srcdir)/sha256.c'; fi` test_sha256-sha256_ext.o: sha256_ext.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -MT test_sha256-sha256_ext.o -MD -MP -MF $(DEPDIR)/test_sha256-sha256_ext.Tpo -c -o test_sha256-sha256_ext.o `test -f 'sha256_ext.c' || echo '$(srcdir)/'`sha256_ext.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_sha256-sha256_ext.Tpo $(DEPDIR)/test_sha256-sha256_ext.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha256_ext.c' object='test_sha256-sha256_ext.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -c -o test_sha256-sha256_ext.o `test -f 'sha256_ext.c' || echo '$(srcdir)/'`sha256_ext.c test_sha256-sha256_ext.obj: sha256_ext.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -MT test_sha256-sha256_ext.obj -MD -MP -MF $(DEPDIR)/test_sha256-sha256_ext.Tpo -c -o test_sha256-sha256_ext.obj `if test -f 'sha256_ext.c'; then $(CYGPATH_W) 'sha256_ext.c'; else $(CYGPATH_W) '$(srcdir)/sha256_ext.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_sha256-sha256_ext.Tpo $(DEPDIR)/test_sha256-sha256_ext.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha256_ext.c' object='test_sha256-sha256_ext.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_sha256_CPPFLAGS) $(CPPFLAGS) $(test_sha256_CFLAGS) $(CFLAGS) -c -o test_sha256-sha256_ext.obj `if test -f 'sha256_ext.c'; then $(CYGPATH_W) 'sha256_ext.c'; else $(CYGPATH_W) '$(srcdir)/sha256_ext.c'; fi` test_shutdown_poll-test_shutdown_select.o: test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_poll_CFLAGS) $(CFLAGS) -MT test_shutdown_poll-test_shutdown_select.o -MD -MP -MF $(DEPDIR)/test_shutdown_poll-test_shutdown_select.Tpo -c -o test_shutdown_poll-test_shutdown_select.o `test -f 'test_shutdown_select.c' || echo '$(srcdir)/'`test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_shutdown_poll-test_shutdown_select.Tpo $(DEPDIR)/test_shutdown_poll-test_shutdown_select.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_shutdown_select.c' object='test_shutdown_poll-test_shutdown_select.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_poll_CFLAGS) $(CFLAGS) -c -o test_shutdown_poll-test_shutdown_select.o `test -f 'test_shutdown_select.c' || echo '$(srcdir)/'`test_shutdown_select.c test_shutdown_poll-test_shutdown_select.obj: test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_poll_CFLAGS) $(CFLAGS) -MT test_shutdown_poll-test_shutdown_select.obj -MD -MP -MF $(DEPDIR)/test_shutdown_poll-test_shutdown_select.Tpo -c -o test_shutdown_poll-test_shutdown_select.obj `if test -f 'test_shutdown_select.c'; then $(CYGPATH_W) 'test_shutdown_select.c'; else $(CYGPATH_W) '$(srcdir)/test_shutdown_select.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_shutdown_poll-test_shutdown_select.Tpo $(DEPDIR)/test_shutdown_poll-test_shutdown_select.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_shutdown_select.c' object='test_shutdown_poll-test_shutdown_select.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_poll_CFLAGS) $(CFLAGS) -c -o test_shutdown_poll-test_shutdown_select.obj `if test -f 'test_shutdown_select.c'; then $(CYGPATH_W) 'test_shutdown_select.c'; else $(CYGPATH_W) '$(srcdir)/test_shutdown_select.c'; fi` test_shutdown_poll_ignore-test_shutdown_select.o: test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_poll_ignore_CFLAGS) $(CFLAGS) -MT test_shutdown_poll_ignore-test_shutdown_select.o -MD -MP -MF $(DEPDIR)/test_shutdown_poll_ignore-test_shutdown_select.Tpo -c -o test_shutdown_poll_ignore-test_shutdown_select.o `test -f 'test_shutdown_select.c' || echo '$(srcdir)/'`test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_shutdown_poll_ignore-test_shutdown_select.Tpo $(DEPDIR)/test_shutdown_poll_ignore-test_shutdown_select.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_shutdown_select.c' object='test_shutdown_poll_ignore-test_shutdown_select.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_poll_ignore_CFLAGS) $(CFLAGS) -c -o test_shutdown_poll_ignore-test_shutdown_select.o `test -f 'test_shutdown_select.c' || echo '$(srcdir)/'`test_shutdown_select.c test_shutdown_poll_ignore-test_shutdown_select.obj: test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_poll_ignore_CFLAGS) $(CFLAGS) -MT test_shutdown_poll_ignore-test_shutdown_select.obj -MD -MP -MF $(DEPDIR)/test_shutdown_poll_ignore-test_shutdown_select.Tpo -c -o test_shutdown_poll_ignore-test_shutdown_select.obj `if test -f 'test_shutdown_select.c'; then $(CYGPATH_W) 'test_shutdown_select.c'; else $(CYGPATH_W) '$(srcdir)/test_shutdown_select.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_shutdown_poll_ignore-test_shutdown_select.Tpo $(DEPDIR)/test_shutdown_poll_ignore-test_shutdown_select.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_shutdown_select.c' object='test_shutdown_poll_ignore-test_shutdown_select.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_poll_ignore_CFLAGS) $(CFLAGS) -c -o test_shutdown_poll_ignore-test_shutdown_select.obj `if test -f 'test_shutdown_select.c'; then $(CYGPATH_W) 'test_shutdown_select.c'; else $(CYGPATH_W) '$(srcdir)/test_shutdown_select.c'; fi` test_shutdown_select-test_shutdown_select.o: test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_select_CFLAGS) $(CFLAGS) -MT test_shutdown_select-test_shutdown_select.o -MD -MP -MF $(DEPDIR)/test_shutdown_select-test_shutdown_select.Tpo -c -o test_shutdown_select-test_shutdown_select.o `test -f 'test_shutdown_select.c' || echo '$(srcdir)/'`test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_shutdown_select-test_shutdown_select.Tpo $(DEPDIR)/test_shutdown_select-test_shutdown_select.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_shutdown_select.c' object='test_shutdown_select-test_shutdown_select.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_select_CFLAGS) $(CFLAGS) -c -o test_shutdown_select-test_shutdown_select.o `test -f 'test_shutdown_select.c' || echo '$(srcdir)/'`test_shutdown_select.c test_shutdown_select-test_shutdown_select.obj: test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_select_CFLAGS) $(CFLAGS) -MT test_shutdown_select-test_shutdown_select.obj -MD -MP -MF $(DEPDIR)/test_shutdown_select-test_shutdown_select.Tpo -c -o test_shutdown_select-test_shutdown_select.obj `if test -f 'test_shutdown_select.c'; then $(CYGPATH_W) 'test_shutdown_select.c'; else $(CYGPATH_W) '$(srcdir)/test_shutdown_select.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_shutdown_select-test_shutdown_select.Tpo $(DEPDIR)/test_shutdown_select-test_shutdown_select.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_shutdown_select.c' object='test_shutdown_select-test_shutdown_select.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_select_CFLAGS) $(CFLAGS) -c -o test_shutdown_select-test_shutdown_select.obj `if test -f 'test_shutdown_select.c'; then $(CYGPATH_W) 'test_shutdown_select.c'; else $(CYGPATH_W) '$(srcdir)/test_shutdown_select.c'; fi` test_shutdown_select_ignore-test_shutdown_select.o: test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_select_ignore_CFLAGS) $(CFLAGS) -MT test_shutdown_select_ignore-test_shutdown_select.o -MD -MP -MF $(DEPDIR)/test_shutdown_select_ignore-test_shutdown_select.Tpo -c -o test_shutdown_select_ignore-test_shutdown_select.o `test -f 'test_shutdown_select.c' || echo '$(srcdir)/'`test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_shutdown_select_ignore-test_shutdown_select.Tpo $(DEPDIR)/test_shutdown_select_ignore-test_shutdown_select.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_shutdown_select.c' object='test_shutdown_select_ignore-test_shutdown_select.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_select_ignore_CFLAGS) $(CFLAGS) -c -o test_shutdown_select_ignore-test_shutdown_select.o `test -f 'test_shutdown_select.c' || echo '$(srcdir)/'`test_shutdown_select.c test_shutdown_select_ignore-test_shutdown_select.obj: test_shutdown_select.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_select_ignore_CFLAGS) $(CFLAGS) -MT test_shutdown_select_ignore-test_shutdown_select.obj -MD -MP -MF $(DEPDIR)/test_shutdown_select_ignore-test_shutdown_select.Tpo -c -o test_shutdown_select_ignore-test_shutdown_select.obj `if test -f 'test_shutdown_select.c'; then $(CYGPATH_W) 'test_shutdown_select.c'; else $(CYGPATH_W) '$(srcdir)/test_shutdown_select.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_shutdown_select_ignore-test_shutdown_select.Tpo $(DEPDIR)/test_shutdown_select_ignore-test_shutdown_select.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_shutdown_select.c' object='test_shutdown_select_ignore-test_shutdown_select.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_shutdown_select_ignore_CFLAGS) $(CFLAGS) -c -o test_shutdown_select_ignore-test_shutdown_select.obj `if test -f 'test_shutdown_select.c'; then $(CYGPATH_W) 'test_shutdown_select.c'; else $(CYGPATH_W) '$(srcdir)/test_shutdown_select.c'; fi` test_upgrade-test_upgrade.o: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_CFLAGS) $(CFLAGS) -MT test_upgrade-test_upgrade.o -MD -MP -MF $(DEPDIR)/test_upgrade-test_upgrade.Tpo -c -o test_upgrade-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade-test_upgrade.Tpo $(DEPDIR)/test_upgrade-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade-test_upgrade.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_CFLAGS) $(CFLAGS) -c -o test_upgrade-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c test_upgrade-test_upgrade.obj: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_CFLAGS) $(CFLAGS) -MT test_upgrade-test_upgrade.obj -MD -MP -MF $(DEPDIR)/test_upgrade-test_upgrade.Tpo -c -o test_upgrade-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade-test_upgrade.Tpo $(DEPDIR)/test_upgrade-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade-test_upgrade.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_CFLAGS) $(CFLAGS) -c -o test_upgrade-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` test_upgrade_large-test_upgrade.o: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_large_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_large_CFLAGS) $(CFLAGS) -MT test_upgrade_large-test_upgrade.o -MD -MP -MF $(DEPDIR)/test_upgrade_large-test_upgrade.Tpo -c -o test_upgrade_large-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade_large-test_upgrade.Tpo $(DEPDIR)/test_upgrade_large-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade_large-test_upgrade.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_large_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_large_CFLAGS) $(CFLAGS) -c -o test_upgrade_large-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c test_upgrade_large-test_upgrade.obj: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_large_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_large_CFLAGS) $(CFLAGS) -MT test_upgrade_large-test_upgrade.obj -MD -MP -MF $(DEPDIR)/test_upgrade_large-test_upgrade.Tpo -c -o test_upgrade_large-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade_large-test_upgrade.Tpo $(DEPDIR)/test_upgrade_large-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade_large-test_upgrade.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_large_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_large_CFLAGS) $(CFLAGS) -c -o test_upgrade_large-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` test_upgrade_large_tls-test_upgrade.o: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_large_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_large_tls_CFLAGS) $(CFLAGS) -MT test_upgrade_large_tls-test_upgrade.o -MD -MP -MF $(DEPDIR)/test_upgrade_large_tls-test_upgrade.Tpo -c -o test_upgrade_large_tls-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade_large_tls-test_upgrade.Tpo $(DEPDIR)/test_upgrade_large_tls-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade_large_tls-test_upgrade.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_large_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_large_tls_CFLAGS) $(CFLAGS) -c -o test_upgrade_large_tls-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c test_upgrade_large_tls-test_upgrade.obj: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_large_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_large_tls_CFLAGS) $(CFLAGS) -MT test_upgrade_large_tls-test_upgrade.obj -MD -MP -MF $(DEPDIR)/test_upgrade_large_tls-test_upgrade.Tpo -c -o test_upgrade_large_tls-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade_large_tls-test_upgrade.Tpo $(DEPDIR)/test_upgrade_large_tls-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade_large_tls-test_upgrade.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_large_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_large_tls_CFLAGS) $(CFLAGS) -c -o test_upgrade_large_tls-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` test_upgrade_tls-test_upgrade.o: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_tls_CFLAGS) $(CFLAGS) -MT test_upgrade_tls-test_upgrade.o -MD -MP -MF $(DEPDIR)/test_upgrade_tls-test_upgrade.Tpo -c -o test_upgrade_tls-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade_tls-test_upgrade.Tpo $(DEPDIR)/test_upgrade_tls-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade_tls-test_upgrade.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_tls_CFLAGS) $(CFLAGS) -c -o test_upgrade_tls-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c test_upgrade_tls-test_upgrade.obj: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_tls_CFLAGS) $(CFLAGS) -MT test_upgrade_tls-test_upgrade.obj -MD -MP -MF $(DEPDIR)/test_upgrade_tls-test_upgrade.Tpo -c -o test_upgrade_tls-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade_tls-test_upgrade.Tpo $(DEPDIR)/test_upgrade_tls-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade_tls-test_upgrade.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_tls_CFLAGS) $(CFLAGS) -c -o test_upgrade_tls-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` test_upgrade_vlarge-test_upgrade.o: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_vlarge_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_vlarge_CFLAGS) $(CFLAGS) -MT test_upgrade_vlarge-test_upgrade.o -MD -MP -MF $(DEPDIR)/test_upgrade_vlarge-test_upgrade.Tpo -c -o test_upgrade_vlarge-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade_vlarge-test_upgrade.Tpo $(DEPDIR)/test_upgrade_vlarge-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade_vlarge-test_upgrade.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_vlarge_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_vlarge_CFLAGS) $(CFLAGS) -c -o test_upgrade_vlarge-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c test_upgrade_vlarge-test_upgrade.obj: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_vlarge_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_vlarge_CFLAGS) $(CFLAGS) -MT test_upgrade_vlarge-test_upgrade.obj -MD -MP -MF $(DEPDIR)/test_upgrade_vlarge-test_upgrade.Tpo -c -o test_upgrade_vlarge-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade_vlarge-test_upgrade.Tpo $(DEPDIR)/test_upgrade_vlarge-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade_vlarge-test_upgrade.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_vlarge_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_vlarge_CFLAGS) $(CFLAGS) -c -o test_upgrade_vlarge-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` test_upgrade_vlarge_tls-test_upgrade.o: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_vlarge_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_vlarge_tls_CFLAGS) $(CFLAGS) -MT test_upgrade_vlarge_tls-test_upgrade.o -MD -MP -MF $(DEPDIR)/test_upgrade_vlarge_tls-test_upgrade.Tpo -c -o test_upgrade_vlarge_tls-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade_vlarge_tls-test_upgrade.Tpo $(DEPDIR)/test_upgrade_vlarge_tls-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade_vlarge_tls-test_upgrade.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_vlarge_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_vlarge_tls_CFLAGS) $(CFLAGS) -c -o test_upgrade_vlarge_tls-test_upgrade.o `test -f 'test_upgrade.c' || echo '$(srcdir)/'`test_upgrade.c test_upgrade_vlarge_tls-test_upgrade.obj: test_upgrade.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_vlarge_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_vlarge_tls_CFLAGS) $(CFLAGS) -MT test_upgrade_vlarge_tls-test_upgrade.obj -MD -MP -MF $(DEPDIR)/test_upgrade_vlarge_tls-test_upgrade.Tpo -c -o test_upgrade_vlarge_tls-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_upgrade_vlarge_tls-test_upgrade.Tpo $(DEPDIR)/test_upgrade_vlarge_tls-test_upgrade.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_upgrade.c' object='test_upgrade_vlarge_tls-test_upgrade.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_upgrade_vlarge_tls_CPPFLAGS) $(CPPFLAGS) $(test_upgrade_vlarge_tls_CFLAGS) $(CFLAGS) -c -o test_upgrade_vlarge_tls-test_upgrade.obj `if test -f 'test_upgrade.c'; then $(CYGPATH_W) 'test_upgrade.c'; else $(CYGPATH_W) '$(srcdir)/test_upgrade.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: $(check_PROGRAMS) @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? test_str_compare.log: test_str_compare$(EXEEXT) @p='test_str_compare$(EXEEXT)'; \ b='test_str_compare'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_str_to_value.log: test_str_to_value$(EXEEXT) @p='test_str_to_value$(EXEEXT)'; \ b='test_str_to_value'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_str_from_value.log: test_str_from_value$(EXEEXT) @p='test_str_from_value$(EXEEXT)'; \ b='test_str_from_value'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_str_token.log: test_str_token$(EXEEXT) @p='test_str_token$(EXEEXT)'; \ b='test_str_token'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_str_token_remove.log: test_str_token_remove$(EXEEXT) @p='test_str_token_remove$(EXEEXT)'; \ b='test_str_token_remove'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_str_tokens_remove.log: test_str_tokens_remove$(EXEEXT) @p='test_str_tokens_remove$(EXEEXT)'; \ b='test_str_tokens_remove'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_str_pct.log: test_str_pct$(EXEEXT) @p='test_str_pct$(EXEEXT)'; \ b='test_str_pct'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_str_bin_hex.log: test_str_bin_hex$(EXEEXT) @p='test_str_bin_hex$(EXEEXT)'; \ b='test_str_bin_hex'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_http_reasons.log: test_http_reasons$(EXEEXT) @p='test_http_reasons$(EXEEXT)'; \ b='test_http_reasons'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_sha1.log: test_sha1$(EXEEXT) @p='test_sha1$(EXEEXT)'; \ b='test_sha1'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_start_stop.log: test_start_stop$(EXEEXT) @p='test_start_stop$(EXEEXT)'; \ b='test_start_stop'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_daemon.log: test_daemon$(EXEEXT) @p='test_daemon$(EXEEXT)'; \ b='test_daemon'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_response_entries.log: test_response_entries$(EXEEXT) @p='test_response_entries$(EXEEXT)'; \ b='test_response_entries'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_postprocessor_md.log: test_postprocessor_md$(EXEEXT) @p='test_postprocessor_md$(EXEEXT)'; \ b='test_postprocessor_md'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_shutdown.log: test_client_put_shutdown$(EXEEXT) @p='test_client_put_shutdown$(EXEEXT)'; \ b='test_client_put_shutdown'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_close.log: test_client_put_close$(EXEEXT) @p='test_client_put_close$(EXEEXT)'; \ b='test_client_put_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_hard_close.log: test_client_put_hard_close$(EXEEXT) @p='test_client_put_hard_close$(EXEEXT)'; \ b='test_client_put_hard_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_steps_shutdown.log: test_client_put_steps_shutdown$(EXEEXT) @p='test_client_put_steps_shutdown$(EXEEXT)'; \ b='test_client_put_steps_shutdown'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_steps_close.log: test_client_put_steps_close$(EXEEXT) @p='test_client_put_steps_close$(EXEEXT)'; \ b='test_client_put_steps_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_steps_hard_close.log: test_client_put_steps_hard_close$(EXEEXT) @p='test_client_put_steps_hard_close$(EXEEXT)'; \ b='test_client_put_steps_hard_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_chunked_shutdown.log: test_client_put_chunked_shutdown$(EXEEXT) @p='test_client_put_chunked_shutdown$(EXEEXT)'; \ b='test_client_put_chunked_shutdown'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_chunked_close.log: test_client_put_chunked_close$(EXEEXT) @p='test_client_put_chunked_close$(EXEEXT)'; \ b='test_client_put_chunked_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_chunked_hard_close.log: test_client_put_chunked_hard_close$(EXEEXT) @p='test_client_put_chunked_hard_close$(EXEEXT)'; \ b='test_client_put_chunked_hard_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_chunked_steps_shutdown.log: test_client_put_chunked_steps_shutdown$(EXEEXT) @p='test_client_put_chunked_steps_shutdown$(EXEEXT)'; \ b='test_client_put_chunked_steps_shutdown'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_chunked_steps_close.log: test_client_put_chunked_steps_close$(EXEEXT) @p='test_client_put_chunked_steps_close$(EXEEXT)'; \ b='test_client_put_chunked_steps_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_chunked_steps_hard_close.log: test_client_put_chunked_steps_hard_close$(EXEEXT) @p='test_client_put_chunked_steps_hard_close$(EXEEXT)'; \ b='test_client_put_chunked_steps_hard_close'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_options.log: test_options$(EXEEXT) @p='test_options$(EXEEXT)'; \ b='test_options'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_mhd_version.log: test_mhd_version$(EXEEXT) @p='test_mhd_version$(EXEEXT)'; \ b='test_mhd_version'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_set_panic.log: test_set_panic$(EXEEXT) @p='test_set_panic$(EXEEXT)'; \ b='test_set_panic'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_md5.log: test_md5$(EXEEXT) @p='test_md5$(EXEEXT)'; \ b='test_md5'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_sha256.log: test_sha256$(EXEEXT) @p='test_sha256$(EXEEXT)'; \ b='test_sha256'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_sha512_256.log: test_sha512_256$(EXEEXT) @p='test_sha512_256$(EXEEXT)'; \ b='test_sha512_256'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_upgrade.log: test_upgrade$(EXEEXT) @p='test_upgrade$(EXEEXT)'; \ b='test_upgrade'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_upgrade_large.log: test_upgrade_large$(EXEEXT) @p='test_upgrade_large$(EXEEXT)'; \ b='test_upgrade_large'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_upgrade_vlarge.log: test_upgrade_vlarge$(EXEEXT) @p='test_upgrade_vlarge$(EXEEXT)'; \ b='test_upgrade_vlarge'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_upgrade_tls.log: test_upgrade_tls$(EXEEXT) @p='test_upgrade_tls$(EXEEXT)'; \ b='test_upgrade_tls'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_upgrade_large_tls.log: test_upgrade_large_tls$(EXEEXT) @p='test_upgrade_large_tls$(EXEEXT)'; \ b='test_upgrade_large_tls'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_upgrade_vlarge_tls.log: test_upgrade_vlarge_tls$(EXEEXT) @p='test_upgrade_vlarge_tls$(EXEEXT)'; \ b='test_upgrade_vlarge_tls'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_postprocessor.log: test_postprocessor$(EXEEXT) @p='test_postprocessor$(EXEEXT)'; \ b='test_postprocessor'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_postprocessor_large.log: test_postprocessor_large$(EXEEXT) @p='test_postprocessor_large$(EXEEXT)'; \ b='test_postprocessor_large'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_postprocessor_amp.log: test_postprocessor_amp$(EXEEXT) @p='test_postprocessor_amp$(EXEEXT)'; \ b='test_postprocessor_amp'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_shutdown_select.log: test_shutdown_select$(EXEEXT) @p='test_shutdown_select$(EXEEXT)'; \ b='test_shutdown_select'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_shutdown_poll.log: test_shutdown_poll$(EXEEXT) @p='test_shutdown_poll$(EXEEXT)'; \ b='test_shutdown_poll'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_shutdown_select_ignore.log: test_shutdown_select_ignore$(EXEEXT) @p='test_shutdown_select_ignore$(EXEEXT)'; \ b='test_shutdown_select_ignore'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_shutdown_poll_ignore.log: test_shutdown_poll_ignore$(EXEEXT) @p='test_shutdown_poll_ignore$(EXEEXT)'; \ b='test_shutdown_poll_ignore'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_auth_parse.log: test_auth_parse$(EXEEXT) @p='test_auth_parse$(EXEEXT)'; \ b='test_auth_parse'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_str_quote.log: test_str_quote$(EXEEXT) @p='test_str_quote$(EXEEXT)'; \ b='test_str_quote'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_dauth_userdigest.log: test_dauth_userdigest$(EXEEXT) @p='test_dauth_userdigest$(EXEEXT)'; \ b='test_dauth_userdigest'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_dauth_userhash.log: test_dauth_userhash$(EXEEXT) @p='test_dauth_userhash$(EXEEXT)'; \ b='test_dauth_userhash'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_str_base64.log: test_str_base64$(EXEEXT) @p='test_str_base64$(EXEEXT)'; \ b='test_str_base64'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_hard_close_stress_os.log: test_client_put_hard_close_stress_os$(EXEEXT) @p='test_client_put_hard_close_stress_os$(EXEEXT)'; \ b='test_client_put_hard_close_stress_os'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_steps_hard_close_stress_os.log: test_client_put_steps_hard_close_stress_os$(EXEEXT) @p='test_client_put_steps_hard_close_stress_os$(EXEEXT)'; \ b='test_client_put_steps_hard_close_stress_os'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_client_put_chunked_steps_hard_close_stress_os.log: test_client_put_chunked_steps_hard_close_stress_os$(EXEEXT) @p='test_client_put_chunked_steps_hard_close_stress_os$(EXEEXT)'; \ b='test_client_put_chunked_steps_hard_close_stress_os'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(LTLIBRARIES) $(DATA) install-checkPROGRAMS: install-libLTLIBRARIES installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/libmicrohttpd_la-basicauth.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-connection.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-connection_https.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-daemon.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-digestauth.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-gen_auth.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-internal.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-md5.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-md5_ext.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-memorypool.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_compat.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_itc.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_mono_clock.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_panic.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_send.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_sockets.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_str.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_threads.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-postprocessor.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-reason_phrase.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-response.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-sha256.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-sha256_ext.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-sha512_256.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-sysfdsetsize.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-tsearch.Plo -rm -f ./$(DEPDIR)/mhd_str.Po -rm -f ./$(DEPDIR)/reason_phrase.Po -rm -f ./$(DEPDIR)/sha1.Po -rm -f ./$(DEPDIR)/sha512_256.Po -rm -f ./$(DEPDIR)/test_auth_parse-gen_auth.Po -rm -f ./$(DEPDIR)/test_auth_parse-mhd_str.Po -rm -f ./$(DEPDIR)/test_auth_parse-test_auth_parse.Po -rm -f ./$(DEPDIR)/test_client_put_stop.Po -rm -f ./$(DEPDIR)/test_daemon.Po -rm -f ./$(DEPDIR)/test_dauth_userdigest.Po -rm -f ./$(DEPDIR)/test_dauth_userhash.Po -rm -f ./$(DEPDIR)/test_http_reasons.Po -rm -f ./$(DEPDIR)/test_md5-md5.Po -rm -f ./$(DEPDIR)/test_md5-md5_ext.Po -rm -f ./$(DEPDIR)/test_md5-test_md5.Po -rm -f ./$(DEPDIR)/test_mhd_version.Po -rm -f ./$(DEPDIR)/test_options.Po -rm -f ./$(DEPDIR)/test_postprocessor-test_postprocessor.Po -rm -f ./$(DEPDIR)/test_postprocessor_amp-test_postprocessor_amp.Po -rm -f ./$(DEPDIR)/test_postprocessor_large-test_postprocessor_large.Po -rm -f ./$(DEPDIR)/test_postprocessor_md-internal.Po -rm -f ./$(DEPDIR)/test_postprocessor_md-mhd_panic.Po -rm -f ./$(DEPDIR)/test_postprocessor_md-mhd_str.Po -rm -f ./$(DEPDIR)/test_postprocessor_md-postprocessor.Po -rm -f ./$(DEPDIR)/test_postprocessor_md-test_postprocessor_md.Po -rm -f ./$(DEPDIR)/test_response_entries.Po -rm -f ./$(DEPDIR)/test_set_panic.Po -rm -f ./$(DEPDIR)/test_sha1.Po -rm -f ./$(DEPDIR)/test_sha256-sha256.Po -rm -f ./$(DEPDIR)/test_sha256-sha256_ext.Po -rm -f ./$(DEPDIR)/test_sha256-test_sha256.Po -rm -f ./$(DEPDIR)/test_sha512_256.Po -rm -f ./$(DEPDIR)/test_shutdown_poll-test_shutdown_select.Po -rm -f ./$(DEPDIR)/test_shutdown_poll_ignore-test_shutdown_select.Po -rm -f ./$(DEPDIR)/test_shutdown_select-test_shutdown_select.Po -rm -f ./$(DEPDIR)/test_shutdown_select_ignore-test_shutdown_select.Po -rm -f ./$(DEPDIR)/test_start_stop.Po -rm -f ./$(DEPDIR)/test_str.Po -rm -f ./$(DEPDIR)/test_str_base64.Po -rm -f ./$(DEPDIR)/test_str_bin_hex.Po -rm -f ./$(DEPDIR)/test_str_pct.Po -rm -f ./$(DEPDIR)/test_str_quote.Po -rm -f ./$(DEPDIR)/test_str_token.Po -rm -f ./$(DEPDIR)/test_str_token_remove.Po -rm -f ./$(DEPDIR)/test_str_tokens_remove.Po -rm -f ./$(DEPDIR)/test_upgrade-test_upgrade.Po -rm -f ./$(DEPDIR)/test_upgrade_large-test_upgrade.Po -rm -f ./$(DEPDIR)/test_upgrade_large_tls-test_upgrade.Po -rm -f ./$(DEPDIR)/test_upgrade_tls-test_upgrade.Po -rm -f ./$(DEPDIR)/test_upgrade_vlarge-test_upgrade.Po -rm -f ./$(DEPDIR)/test_upgrade_vlarge_tls-test_upgrade.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/libmicrohttpd_la-basicauth.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-connection.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-connection_https.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-daemon.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-digestauth.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-gen_auth.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-internal.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-md5.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-md5_ext.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-memorypool.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_compat.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_itc.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_mono_clock.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_panic.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_send.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_sockets.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_str.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-mhd_threads.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-postprocessor.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-reason_phrase.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-response.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-sha256.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-sha256_ext.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-sha512_256.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-sysfdsetsize.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_la-tsearch.Plo -rm -f ./$(DEPDIR)/mhd_str.Po -rm -f ./$(DEPDIR)/reason_phrase.Po -rm -f ./$(DEPDIR)/sha1.Po -rm -f ./$(DEPDIR)/sha512_256.Po -rm -f ./$(DEPDIR)/test_auth_parse-gen_auth.Po -rm -f ./$(DEPDIR)/test_auth_parse-mhd_str.Po -rm -f ./$(DEPDIR)/test_auth_parse-test_auth_parse.Po -rm -f ./$(DEPDIR)/test_client_put_stop.Po -rm -f ./$(DEPDIR)/test_daemon.Po -rm -f ./$(DEPDIR)/test_dauth_userdigest.Po -rm -f ./$(DEPDIR)/test_dauth_userhash.Po -rm -f ./$(DEPDIR)/test_http_reasons.Po -rm -f ./$(DEPDIR)/test_md5-md5.Po -rm -f ./$(DEPDIR)/test_md5-md5_ext.Po -rm -f ./$(DEPDIR)/test_md5-test_md5.Po -rm -f ./$(DEPDIR)/test_mhd_version.Po -rm -f ./$(DEPDIR)/test_options.Po -rm -f ./$(DEPDIR)/test_postprocessor-test_postprocessor.Po -rm -f ./$(DEPDIR)/test_postprocessor_amp-test_postprocessor_amp.Po -rm -f ./$(DEPDIR)/test_postprocessor_large-test_postprocessor_large.Po -rm -f ./$(DEPDIR)/test_postprocessor_md-internal.Po -rm -f ./$(DEPDIR)/test_postprocessor_md-mhd_panic.Po -rm -f ./$(DEPDIR)/test_postprocessor_md-mhd_str.Po -rm -f ./$(DEPDIR)/test_postprocessor_md-postprocessor.Po -rm -f ./$(DEPDIR)/test_postprocessor_md-test_postprocessor_md.Po -rm -f ./$(DEPDIR)/test_response_entries.Po -rm -f ./$(DEPDIR)/test_set_panic.Po -rm -f ./$(DEPDIR)/test_sha1.Po -rm -f ./$(DEPDIR)/test_sha256-sha256.Po -rm -f ./$(DEPDIR)/test_sha256-sha256_ext.Po -rm -f ./$(DEPDIR)/test_sha256-test_sha256.Po -rm -f ./$(DEPDIR)/test_sha512_256.Po -rm -f ./$(DEPDIR)/test_shutdown_poll-test_shutdown_select.Po -rm -f ./$(DEPDIR)/test_shutdown_poll_ignore-test_shutdown_select.Po -rm -f ./$(DEPDIR)/test_shutdown_select-test_shutdown_select.Po -rm -f ./$(DEPDIR)/test_shutdown_select_ignore-test_shutdown_select.Po -rm -f ./$(DEPDIR)/test_start_stop.Po -rm -f ./$(DEPDIR)/test_str.Po -rm -f ./$(DEPDIR)/test_str_base64.Po -rm -f ./$(DEPDIR)/test_str_bin_hex.Po -rm -f ./$(DEPDIR)/test_str_pct.Po -rm -f ./$(DEPDIR)/test_str_quote.Po -rm -f ./$(DEPDIR)/test_str_token.Po -rm -f ./$(DEPDIR)/test_str_token_remove.Po -rm -f ./$(DEPDIR)/test_str_tokens_remove.Po -rm -f ./$(DEPDIR)/test_upgrade-test_upgrade.Po -rm -f ./$(DEPDIR)/test_upgrade_large-test_upgrade.Po -rm -f ./$(DEPDIR)/test_upgrade_large_tls-test_upgrade.Po -rm -f ./$(DEPDIR)/test_upgrade_tls-test_upgrade.Po -rm -f ./$(DEPDIR)/test_upgrade_vlarge-test_upgrade.Po -rm -f ./$(DEPDIR)/test_upgrade_vlarge_tls-test_upgrade.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \ check-am clean clean-checkPROGRAMS clean-generic \ clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ recheck tags tags-am uninstall uninstall-am \ uninstall-libLTLIBRARIES .PRECIOUS: Makefile @W32_SHARED_LIB_EXP_TRUE@$(lt_cv_objdir)/libmicrohttpd.def: libmicrohttpd.la @W32_SHARED_LIB_EXP_TRUE@ $(AM_V_at)test -f $@ && touch $@ || \ @W32_SHARED_LIB_EXP_TRUE@ ( rm -f libmicrohttpd.la ; $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la && touch $@ ) @USE_EXPORT_FILE_TRUE@@W32_SHARED_LIB_EXP_TRUE@$(lt_cv_objdir)/libmicrohttpd.exp: $(lt_cv_objdir)/libmicrohttpd.lib @USE_EXPORT_FILE_TRUE@@W32_SHARED_LIB_EXP_TRUE@ $(AM_V_at)test -f $@ && touch $@ || \ @USE_EXPORT_FILE_TRUE@@W32_SHARED_LIB_EXP_TRUE@ ( rm -f $(lt_cv_objdir)/libmicrohttpd.lib ; $(MAKE) $(AM_MAKEFLAGS) $(lt_cv_objdir)/libmicrohttpd.lib && touch $@ ) @USE_MS_LIB_TOOL_TRUE@@W32_SHARED_LIB_EXP_TRUE@$(lt_cv_objdir)/libmicrohttpd.lib: $(lt_cv_objdir)/libmicrohttpd.def libmicrohttpd.la $(libmicrohttpd_la_OBJECTS) @USE_MS_LIB_TOOL_TRUE@@W32_SHARED_LIB_EXP_TRUE@ $(AM_V_LIB) cd "$(lt_cv_objdir)" && dll_name=`$(SED) -n -e "s/^dlname='\(.*\)'/\1/p" libmicrohttpd.la` && test -n "$$dll_name" && \ @USE_MS_LIB_TOOL_TRUE@@W32_SHARED_LIB_EXP_TRUE@ $(MS_LIB_TOOL) -nologo -def:libmicrohttpd.def -name:$$dll_name -out:libmicrohttpd.lib $(libmicrohttpd_la_OBJECTS:.lo=.o) -ignore:4221 @USE_EXPORT_FILE_TRUE@@USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@$(lt_cv_objdir)/libmicrohttpd.lib: $(lt_cv_objdir)/libmicrohttpd.def libmicrohttpd.la $(libmicrohttpd_la_OBJECTS) @USE_EXPORT_FILE_TRUE@@USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@ $(AM_V_DLLTOOL) cd "$(lt_cv_objdir)" && dll_name=`$(SED) -n -e "s/^dlname='\(.*\)'/\1/p" libmicrohttpd.la` && test -n "$$dll_name" && \ @USE_EXPORT_FILE_TRUE@@USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@ $(DLLTOOL) -d libmicrohttpd.def -D $$dll_name -l libmicrohttpd.lib $(libmicrohttpd_la_OBJECTS:.lo=.o) -e ./libmicrohttpd.exp @USE_EXPORT_FILE_FALSE@@USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@$(lt_cv_objdir)/libmicrohttpd.lib: $(lt_cv_objdir)/libmicrohttpd.def libmicrohttpd.la @USE_EXPORT_FILE_FALSE@@USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@ $(AM_V_DLLTOOL) cd "$(lt_cv_objdir)" && dll_name=`$(SED) -n -e "s/^dlname='\(.*\)'/\1/p" libmicrohttpd.la` && test -n "$$dll_name" && \ @USE_EXPORT_FILE_FALSE@@USE_MS_LIB_TOOL_FALSE@@W32_SHARED_LIB_EXP_TRUE@ $(DLLTOOL) -d libmicrohttpd.def -D $$dll_name -l libmicrohttpd.lib @W32_STATIC_LIB_TRUE@$(lt_cv_objdir)/libmicrohttpd-static.lib: libmicrohttpd.la $(libmicrohttpd_la_OBJECTS) @USE_MS_LIB_TOOL_TRUE@@W32_STATIC_LIB_TRUE@ $(AM_V_LIB) $(MS_LIB_TOOL) -nologo -out:$@ $(libmicrohttpd_la_OBJECTS:.lo=.o) @USE_MS_LIB_TOOL_FALSE@@W32_STATIC_LIB_TRUE@ $(AM_V_at)cp $(lt_cv_objdir)/libmicrohttpd.a $@ # General rule is not required, but keep it just in case @HAVE_W32_TRUE@.rc.lo: @HAVE_W32_TRUE@ $(AM_V_RC) $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $< -o $@ # To add dll resource only to .dll file and exclude it form static # lib, a little trick was used. Allow libtool to create file.lo, # file.o and .libs/file.lo, .libs/file.o files, then overwrite file.o # by empty object generated from empty c-file. Later libtool will # use .libs/file.o for shared lib and empty file.o for static lib. # This implementation is based on trick found in liblzma. # Note: windres does not understand '-isystem' flag, so all # possible '-isystem' flags are replaced by simple '-I' flags. @HAVE_W32_TRUE@$(MHD_DLL_RES_LO): $(MHD_DLL_RES_SRC) @HAVE_W32_TRUE@ $(AM_V_RC) RC_CPP_FLAGS=" $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) " && \ @HAVE_W32_TRUE@ $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $${RC_CPP_FLAGS// -isystem / -I} $< -o $@ && \ @HAVE_W32_TRUE@ echo > $@-empty.c && $(CC) $(DEFS) $(AM_CFLAGS) $(CFLAGS) -c $@-empty.c -o $(@:.lo=.o) && rm -f $@-empty.c update-po-POTFILES.in: $(top_srcdir)/po/POTFILES.in $(top_srcdir)/po/POTFILES.in: $(srcdir)/Makefile.am @echo "Creating $@" @echo src/include/microhttpd.h > "$@" && \ for src in $(am__libmicrohttpd_la_SOURCES_DIST) ; do \ echo "$(subdir)/$$src" >> "$@" ; \ done .PHONY: update-po-POTFILES.in # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/src/microhttpd/test_postprocessor_large.c0000644000175000017500000000675714441373361020331 /* This file is part of libmicrohttpd Copyright (C) 2008 Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_postprocessor_large.c * @brief Testcase with very large input for postprocessor * @author Christian Grothoff */ #include "platform.h" #include "microhttpd.h" #include "internal.h" #include "mhd_compat.h" #ifndef WINDOWS #include #endif static enum MHD_Result value_checker (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { size_t *pos = (size_t *) cls; (void) kind; (void) key; (void) filename; (void) content_type; /* Unused. Silent compiler warning. */ (void) transfer_encoding; (void) data; (void) off; /* Unused. Silent compiler warning. */ #if 0 fprintf (stderr, "VC: %" PRIu64 " %u `%s' `%s' `%s' `%s' `%.*s'\n", off, size, key, filename, content_type, transfer_encoding, size, data); #endif if (size == 0) return MHD_YES; *pos += size; return MHD_YES; } static unsigned int test_simple_large (void) { struct MHD_Connection connection; struct MHD_HTTP_Req_Header header; struct MHD_PostProcessor *pp; size_t i; size_t delta; size_t size; char data[102400]; size_t pos; pos = 0; memset (data, 'A', sizeof (data)); memcpy (data, "key=", 4); data[sizeof (data) - 1] = '\0'; memset (&connection, 0, sizeof (struct MHD_Connection)); memset (&header, 0, sizeof (struct MHD_HTTP_Res_Header)); connection.rq.headers_received = &header; header.header = MHD_HTTP_HEADER_CONTENT_TYPE; header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; header.header_size = strlen (header.header); header.value_size = strlen (header.value); header.kind = MHD_HEADER_KIND; pp = MHD_create_post_processor (&connection, 1024, &value_checker, &pos); i = 0; size = strlen (data); while (i < size) { delta = 1 + ((size_t) MHD_random_ ()) % (size - i); if (MHD_YES != MHD_post_process (pp, &data[i], delta)) { fprintf (stderr, "MHD_post_process() failed!\n"); MHD_destroy_post_processor (pp); return 1; } i += delta; } MHD_destroy_post_processor (pp); if (pos != sizeof (data) - 5) /* minus 0-termination and 'key=' */ return 1; return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errorCount += test_simple_large (); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); return errorCount != 0; /* 0 == pass */ } libmicrohttpd-1.0.1/src/microhttpd/memorypool.c0000644000175000017500000006057514556705750015403 /* This file is part of libmicrohttpd Copyright (C) 2007--2024 Daniel Pittman and Christian Grothoff Copyright (C) 2014--2024 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file memorypool.c * @brief memory pool * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "memorypool.h" #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include #include "mhd_assert.h" #ifdef HAVE_SYS_MMAN_H #include #endif #ifdef _WIN32 #include #endif #ifdef HAVE_SYSCONF #include #if defined(_SC_PAGE_SIZE) #define MHD_SC_PAGESIZE _SC_PAGE_SIZE #elif defined(_SC_PAGESIZE) #define MHD_SC_PAGESIZE _SC_PAGESIZE #endif /* _SC_PAGESIZE */ #endif /* HAVE_SYSCONF */ #include "mhd_limits.h" /* for SIZE_MAX, PAGESIZE / PAGE_SIZE */ #if defined(MHD_USE_PAGESIZE_MACRO) || defined(MHD_USE_PAGE_SIZE_MACRO) #ifndef HAVE_SYSCONF /* Avoid duplicate include */ #include #endif /* HAVE_SYSCONF */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #endif /* MHD_USE_PAGESIZE_MACRO || MHD_USE_PAGE_SIZE_MACRO */ /** * Fallback value of page size */ #define _MHD_FALLBACK_PAGE_SIZE (4096) #if defined(MHD_USE_PAGESIZE_MACRO) #define MHD_DEF_PAGE_SIZE_ PAGESIZE #elif defined(MHD_USE_PAGE_SIZE_MACRO) #define MHD_DEF_PAGE_SIZE_ PAGE_SIZE #else /* ! PAGESIZE */ #define MHD_DEF_PAGE_SIZE_ _MHD_FALLBACK_PAGE_SIZE #endif /* ! PAGESIZE */ #ifdef MHD_ASAN_POISON_ACTIVE #include #endif /* MHD_ASAN_POISON_ACTIVE */ /* define MAP_ANONYMOUS for Mac OS X */ #if defined(MAP_ANON) && ! defined(MAP_ANONYMOUS) #define MAP_ANONYMOUS MAP_ANON #endif #if defined(_WIN32) #define MAP_FAILED NULL #elif ! defined(MAP_FAILED) #define MAP_FAILED ((void*) -1) #endif /** * Align to 2x word size (as GNU libc does). */ #define ALIGN_SIZE (2 * sizeof(void*)) /** * Round up 'n' to a multiple of ALIGN_SIZE. */ #define ROUND_TO_ALIGN(n) (((n) + (ALIGN_SIZE - 1)) \ / (ALIGN_SIZE) *(ALIGN_SIZE)) #ifndef MHD_ASAN_POISON_ACTIVE #define _MHD_NOSANITIZE_PTRS /**/ #define _MHD_RED_ZONE_SIZE (0) #define ROUND_TO_ALIGN_PLUS_RED_ZONE(n) ROUND_TO_ALIGN(n) #define _MHD_POISON_MEMORY(pointer, size) (void)0 #define _MHD_UNPOISON_MEMORY(pointer, size) (void)0 /** * Boolean 'true' if the first pointer is less or equal the second pointer */ #define mp_ptr_le_(p1,p2) \ (((const uint8_t*)(p1)) <= ((const uint8_t*)(p2))) /** * The difference in bytes between positions of the first and * the second pointers */ #define mp_ptr_diff_(p1,p2) \ ((size_t)(((const uint8_t*)(p1)) - ((const uint8_t*)(p2)))) #else /* MHD_ASAN_POISON_ACTIVE */ #define _MHD_RED_ZONE_SIZE (ALIGN_SIZE) #define ROUND_TO_ALIGN_PLUS_RED_ZONE(n) (ROUND_TO_ALIGN(n) + _MHD_RED_ZONE_SIZE) #define _MHD_POISON_MEMORY(pointer, size) \ ASAN_POISON_MEMORY_REGION ((pointer), (size)) #define _MHD_UNPOISON_MEMORY(pointer, size) \ ASAN_UNPOISON_MEMORY_REGION ((pointer), (size)) #if defined(FUNC_PTRCOMPARE_CAST_WORKAROUND_WORKS) /** * Boolean 'true' if the first pointer is less or equal the second pointer */ #define mp_ptr_le_(p1,p2) \ (((uintptr_t)((const void*)(p1))) <= ((uintptr_t)((const void*)(p2)))) /** * The difference in bytes between positions of the first and * the second pointers */ #define mp_ptr_diff_(p1,p2) \ ((size_t)(((uintptr_t)((const uint8_t*)(p1))) - \ ((uintptr_t)((const uint8_t*)(p2))))) #elif defined(FUNC_ATTR_PTRCOMPARE_WORKS) && \ defined(FUNC_ATTR_PTRSUBTRACT_WORKS) #ifdef _DEBUG /** * Boolean 'true' if the first pointer is less or equal the second pointer */ __attribute__((no_sanitize ("pointer-compare"))) static bool mp_ptr_le_ (const void *p1, const void *p2) { return (((const uint8_t *) p1) <= ((const uint8_t *) p2)); } #endif /* _DEBUG */ /** * The difference in bytes between positions of the first and * the second pointers */ __attribute__((no_sanitize ("pointer-subtract"))) static size_t mp_ptr_diff_ (const void *p1, const void *p2) { return (size_t) (((const uint8_t *) p1) - ((const uint8_t *) p2)); } #elif defined(FUNC_ATTR_NOSANITIZE_WORKS) #ifdef _DEBUG /** * Boolean 'true' if the first pointer is less or equal the second pointer */ __attribute__((no_sanitize ("address"))) static bool mp_ptr_le_ (const void *p1, const void *p2) { return (((const uint8_t *) p1) <= ((const uint8_t *) p2)); } #endif /* _DEBUG */ /** * The difference in bytes between positions of the first and * the second pointers */ __attribute__((no_sanitize ("address"))) static size_t mp_ptr_diff_ (const void *p1, const void *p2) { return (size_t) (((const uint8_t *) p1) - ((const uint8_t *) p2)); } #else /* ! FUNC_ATTR_NOSANITIZE_WORKS */ #error User-poisoning cannot be used #endif /* ! FUNC_ATTR_NOSANITIZE_WORKS */ #endif /* MHD_ASAN_POISON_ACTIVE */ /** * Size of memory page */ static size_t MHD_sys_page_size_ = (size_t) #if defined(MHD_USE_PAGESIZE_MACRO_STATIC) PAGESIZE; #elif defined(MHD_USE_PAGE_SIZE_MACRO_STATIC) PAGE_SIZE; #else /* ! MHD_USE_PAGE_SIZE_MACRO_STATIC */ _MHD_FALLBACK_PAGE_SIZE; /* Default fallback value */ #endif /* ! MHD_USE_PAGE_SIZE_MACRO_STATIC */ /** * Initialise values for memory pools */ void MHD_init_mem_pools_ (void) { #ifdef MHD_SC_PAGESIZE long result; result = sysconf (MHD_SC_PAGESIZE); if (-1 != result) MHD_sys_page_size_ = (size_t) result; else MHD_sys_page_size_ = (size_t) MHD_DEF_PAGE_SIZE_; #elif defined(_WIN32) SYSTEM_INFO si; GetSystemInfo (&si); MHD_sys_page_size_ = (size_t) si.dwPageSize; #else MHD_sys_page_size_ = (size_t) MHD_DEF_PAGE_SIZE_; #endif /* _WIN32 */ mhd_assert (0 == (MHD_sys_page_size_ % ALIGN_SIZE)); } /** * Handle for a memory pool. Pools are not reentrant and must not be * used by multiple threads. */ struct MemoryPool { /** * Pointer to the pool's memory */ uint8_t *memory; /** * Size of the pool. */ size_t size; /** * Offset of the first unallocated byte. */ size_t pos; /** * Offset of the byte after the last unallocated byte. */ size_t end; /** * 'false' if pool was malloc'ed, 'true' if mmapped (VirtualAlloc'ed for W32). */ bool is_mmap; }; /** * Create a memory pool. * * @param max maximum size of the pool * @return NULL on error */ struct MemoryPool * MHD_pool_create (size_t max) { struct MemoryPool *pool; size_t alloc_size; mhd_assert (max > 0); alloc_size = 0; pool = malloc (sizeof (struct MemoryPool)); if (NULL == pool) return NULL; #if defined(MAP_ANONYMOUS) || defined(_WIN32) if ( (max <= 32 * 1024) || (max < MHD_sys_page_size_ * 4 / 3) ) { pool->memory = MAP_FAILED; } else { /* Round up allocation to page granularity. */ alloc_size = max + MHD_sys_page_size_ - 1; alloc_size -= alloc_size % MHD_sys_page_size_; #if defined(MAP_ANONYMOUS) && ! defined(_WIN32) pool->memory = mmap (NULL, alloc_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); #elif defined(_WIN32) pool->memory = VirtualAlloc (NULL, alloc_size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #endif /* _WIN32 */ } #else /* ! _WIN32 && ! MAP_ANONYMOUS */ pool->memory = MAP_FAILED; #endif /* ! _WIN32 && ! MAP_ANONYMOUS */ if (MAP_FAILED == pool->memory) { alloc_size = ROUND_TO_ALIGN (max); pool->memory = malloc (alloc_size); if (NULL == pool->memory) { free (pool); return NULL; } pool->is_mmap = false; } #if defined(MAP_ANONYMOUS) || defined(_WIN32) else { pool->is_mmap = true; } #endif /* _WIN32 || MAP_ANONYMOUS */ mhd_assert (0 == (((uintptr_t) pool->memory) % ALIGN_SIZE)); pool->pos = 0; pool->end = alloc_size; pool->size = alloc_size; mhd_assert (0 < alloc_size); _MHD_POISON_MEMORY (pool->memory, pool->size); return pool; } /** * Destroy a memory pool. * * @param pool memory pool to destroy */ void MHD_pool_destroy (struct MemoryPool *pool) { if (NULL == pool) return; mhd_assert (pool->end >= pool->pos); mhd_assert (pool->size >= pool->end - pool->pos); mhd_assert (pool->pos == ROUND_TO_ALIGN (pool->pos)); _MHD_UNPOISON_MEMORY (pool->memory, pool->size); if (! pool->is_mmap) free (pool->memory); else #if defined(MAP_ANONYMOUS) && ! defined(_WIN32) munmap (pool->memory, pool->size); #elif defined(_WIN32) VirtualFree (pool->memory, 0, MEM_RELEASE); #else abort (); #endif free (pool); } /** * Check how much memory is left in the @a pool * * @param pool pool to check * @return number of bytes still available in @a pool */ size_t MHD_pool_get_free (struct MemoryPool *pool) { mhd_assert (pool->end >= pool->pos); mhd_assert (pool->size >= pool->end - pool->pos); mhd_assert (pool->pos == ROUND_TO_ALIGN (pool->pos)); #ifdef MHD_ASAN_POISON_ACTIVE if ((pool->end - pool->pos) <= _MHD_RED_ZONE_SIZE) return 0; #endif /* MHD_ASAN_POISON_ACTIVE */ return (pool->end - pool->pos) - _MHD_RED_ZONE_SIZE; } /** * Allocate size bytes from the pool. * * @param pool memory pool to use for the operation * @param size number of bytes to allocate * @param from_end allocate from end of pool (set to 'true'); * use this for small, persistent allocations that * will never be reallocated * @return NULL if the pool cannot support size more * bytes */ void * MHD_pool_allocate (struct MemoryPool *pool, size_t size, bool from_end) { void *ret; size_t asize; mhd_assert (pool->end >= pool->pos); mhd_assert (pool->size >= pool->end - pool->pos); mhd_assert (pool->pos == ROUND_TO_ALIGN (pool->pos)); asize = ROUND_TO_ALIGN_PLUS_RED_ZONE (size); if ( (0 == asize) && (0 != size) ) return NULL; /* size too close to SIZE_MAX */ if (asize > pool->end - pool->pos) return NULL; if (from_end) { ret = &pool->memory[pool->end - asize]; pool->end -= asize; } else { ret = &pool->memory[pool->pos]; pool->pos += asize; } _MHD_UNPOISON_MEMORY (ret, size); return ret; } /** * Checks whether allocated block is re-sizable in-place. * If block is not re-sizable in-place, it still could be shrunk, but freed * memory will not be re-used until reset of the pool. * @param pool the memory pool to use * @param block the pointer to the allocated block to check * @param block_size the size of the allocated @a block * @return true if block can be resized in-place in the optimal way, * false otherwise */ bool MHD_pool_is_resizable_inplace (struct MemoryPool *pool, void *block, size_t block_size) { mhd_assert (pool->end >= pool->pos); mhd_assert (pool->size >= pool->end - pool->pos); mhd_assert (block != NULL || block_size == 0); mhd_assert (pool->size >= block_size); if (NULL != block) { const size_t block_offset = mp_ptr_diff_ (block, pool->memory); mhd_assert (mp_ptr_le_ (pool->memory, block)); mhd_assert (pool->size >= block_offset); mhd_assert (pool->size >= block_offset + block_size); return (pool->pos == ROUND_TO_ALIGN_PLUS_RED_ZONE (block_offset + block_size)); } return false; /* Unallocated blocks cannot be resized in-place */ } /** * Try to allocate @a size bytes memory area from the @a pool. * * If allocation fails, @a required_bytes is updated with size required to be * freed in the @a pool from rellocatable area to allocate requested number * of bytes. * Allocated memory area is always not rellocatable ("from end"). * * @param pool memory pool to use for the operation * @param size the size of memory in bytes to allocate * @param[out] required_bytes the pointer to variable to be updated with * the size of the required additional free * memory area, set to 0 if function succeeds. * Cannot be NULL. * @return the pointer to allocated memory area if succeed, * NULL if the pool doesn't have enough space, required_bytes is updated * with amount of space needed to be freed in rellocatable area or * set to SIZE_MAX if requested size is too large for the pool. */ void * MHD_pool_try_alloc (struct MemoryPool *pool, size_t size, size_t *required_bytes) { void *ret; size_t asize; mhd_assert (pool->end >= pool->pos); mhd_assert (pool->size >= pool->end - pool->pos); mhd_assert (pool->pos == ROUND_TO_ALIGN (pool->pos)); asize = ROUND_TO_ALIGN_PLUS_RED_ZONE (size); if ( (0 == asize) && (0 != size) ) { /* size is too close to SIZE_MAX, very unlikely */ *required_bytes = SIZE_MAX; return NULL; } if (asize > pool->end - pool->pos) { mhd_assert ((pool->end - pool->pos) == \ ROUND_TO_ALIGN (pool->end - pool->pos)); if (asize <= pool->end) *required_bytes = asize - (pool->end - pool->pos); else *required_bytes = SIZE_MAX; return NULL; } *required_bytes = 0; ret = &pool->memory[pool->end - asize]; pool->end -= asize; _MHD_UNPOISON_MEMORY (ret, size); return ret; } /** * Reallocate a block of memory obtained from the pool. * This is particularly efficient when growing or * shrinking the block that was last (re)allocated. * If the given block is not the most recently * (re)allocated block, the memory of the previous * allocation may be not released until the pool is * destroyed or reset. * * @param pool memory pool to use for the operation * @param old the existing block * @param old_size the size of the existing block * @param new_size the new size of the block * @return new address of the block, or * NULL if the pool cannot support @a new_size * bytes (old continues to be valid for @a old_size) */ void * MHD_pool_reallocate (struct MemoryPool *pool, void *old, size_t old_size, size_t new_size) { size_t asize; uint8_t *new_blc; mhd_assert (pool->end >= pool->pos); mhd_assert (pool->size >= pool->end - pool->pos); mhd_assert (old != NULL || old_size == 0); mhd_assert (pool->size >= old_size); mhd_assert (pool->pos == ROUND_TO_ALIGN (pool->pos)); #if defined(MHD_ASAN_POISON_ACTIVE) && defined(HAVE___ASAN_REGION_IS_POISONED) mhd_assert (NULL == __asan_region_is_poisoned (old, old_size)); #endif /* MHD_ASAN_POISON_ACTIVE && HAVE___ASAN_REGION_IS_POISONED */ if (NULL != old) { /* Have previously allocated data */ const size_t old_offset = mp_ptr_diff_ (old, pool->memory); const bool shrinking = (old_size > new_size); mhd_assert (mp_ptr_le_ (pool->memory, old)); /* (pool->memory + pool->size >= (uint8_t*) old + old_size) */ mhd_assert ((pool->size - _MHD_RED_ZONE_SIZE) >= (old_offset + old_size)); /* Blocks "from the end" must not be reallocated */ /* (old_size == 0 || pool->memory + pool->pos > (uint8_t*) old) */ mhd_assert ((old_size == 0) || \ (pool->pos > old_offset)); mhd_assert ((old_size == 0) || \ ((pool->end - _MHD_RED_ZONE_SIZE) >= (old_offset + old_size))); /* Try resizing in-place */ if (shrinking) { /* Shrinking in-place, zero-out freed part */ memset ((uint8_t *) old + new_size, 0, old_size - new_size); _MHD_POISON_MEMORY ((uint8_t *) old + new_size, old_size - new_size); } if (pool->pos == ROUND_TO_ALIGN_PLUS_RED_ZONE (old_offset + old_size)) { /* "old" block is the last allocated block */ const size_t new_apos = ROUND_TO_ALIGN_PLUS_RED_ZONE (old_offset + new_size); if (! shrinking) { /* Grow in-place, check for enough space. */ if ( (new_apos > pool->end) || (new_apos < pool->pos) ) /* Value wrap */ return NULL; /* No space */ } /* Resized in-place */ pool->pos = new_apos; _MHD_UNPOISON_MEMORY (old, new_size); return old; } if (shrinking) return old; /* Resized in-place, freed part remains allocated */ } /* Need to allocate new block */ asize = ROUND_TO_ALIGN_PLUS_RED_ZONE (new_size); if ( ( (0 == asize) && (0 != new_size) ) || /* Value wrap, too large new_size. */ (asize > pool->end - pool->pos) ) /* Not enough space */ return NULL; new_blc = pool->memory + pool->pos; pool->pos += asize; _MHD_UNPOISON_MEMORY (new_blc, new_size); if (0 != old_size) { /* Move data to new block, old block remains allocated */ memcpy (new_blc, old, old_size); /* Zero-out old block */ memset (old, 0, old_size); _MHD_POISON_MEMORY (old, old_size); } return new_blc; } /** * Deallocate a block of memory obtained from the pool. * * If the given block is not the most recently * (re)allocated block, the memory of the this block * allocation may be not released until the pool is * destroyed or reset. * * @param pool memory pool to use for the operation * @param block the allocated block, the NULL is tolerated * @param block_size the size of the allocated block */ void MHD_pool_deallocate (struct MemoryPool *pool, void *block, size_t block_size) { mhd_assert (pool->end >= pool->pos); mhd_assert (pool->size >= pool->end - pool->pos); mhd_assert (block != NULL || block_size == 0); mhd_assert (pool->size >= block_size); mhd_assert (pool->pos == ROUND_TO_ALIGN (pool->pos)); if (NULL != block) { /* Have previously allocated data */ const size_t block_offset = mp_ptr_diff_ (block, pool->memory); mhd_assert (mp_ptr_le_ (pool->memory, block)); mhd_assert (block_offset <= pool->size); mhd_assert ((block_offset != pool->pos) || (block_size == 0)); /* Zero-out deallocated region */ if (0 != block_size) { memset (block, 0, block_size); _MHD_POISON_MEMORY (block, block_size); } #if ! defined(MHD_FAVOR_SMALL_CODE) && ! defined(MHD_ASAN_POISON_ACTIVE) else return; /* Zero size, no need to do anything */ #endif /* ! MHD_FAVOR_SMALL_CODE && ! MHD_ASAN_POISON_ACTIVE */ if (block_offset <= pool->pos) { /* "Normal" block, not allocated "from the end". */ const size_t alg_end = ROUND_TO_ALIGN_PLUS_RED_ZONE (block_offset + block_size); mhd_assert (alg_end <= pool->pos); if (alg_end == pool->pos) { /* The last allocated block, return deallocated block to the pool */ size_t alg_start = ROUND_TO_ALIGN (block_offset); mhd_assert (alg_start >= block_offset); #if defined(MHD_ASAN_POISON_ACTIVE) if (alg_start != block_offset) { _MHD_POISON_MEMORY (pool->memory + block_offset, \ alg_start - block_offset); } else if (0 != alg_start) { bool need_red_zone_before; mhd_assert (_MHD_RED_ZONE_SIZE <= alg_start); #if defined(HAVE___ASAN_REGION_IS_POISONED) need_red_zone_before = (NULL == __asan_region_is_poisoned (pool->memory + alg_start - _MHD_RED_ZONE_SIZE, _MHD_RED_ZONE_SIZE)); #elif defined(HAVE___ASAN_ADDRESS_IS_POISONED) need_red_zone_before = (0 == __asan_address_is_poisoned (pool->memory + alg_start - 1)); #else /* ! HAVE___ASAN_ADDRESS_IS_POISONED */ need_red_zone_before = true; /* Unknown, assume new red zone needed */ #endif /* ! HAVE___ASAN_ADDRESS_IS_POISONED */ if (need_red_zone_before) { _MHD_POISON_MEMORY (pool->memory + alg_start, _MHD_RED_ZONE_SIZE); alg_start += _MHD_RED_ZONE_SIZE; } } #endif /* MHD_ASAN_POISON_ACTIVE */ mhd_assert (alg_start <= pool->pos); mhd_assert (alg_start == ROUND_TO_ALIGN (alg_start)); pool->pos = alg_start; } } else { /* Allocated "from the end" block. */ /* The size and the pointers of such block should not be manipulated by MHD code (block split is disallowed). */ mhd_assert (block_offset >= pool->end); mhd_assert (ROUND_TO_ALIGN (block_offset) == block_offset); if (block_offset == pool->end) { /* The last allocated block, return deallocated block to the pool */ const size_t alg_end = ROUND_TO_ALIGN_PLUS_RED_ZONE (block_offset + block_size); pool->end = alg_end; } } } } /** * Clear all entries from the memory pool except * for @a keep of the given @a copy_bytes. The pointer * returned should be a buffer of @a new_size where * the first @a copy_bytes are from @a keep. * * @param pool memory pool to use for the operation * @param keep pointer to the entry to keep (maybe NULL) * @param copy_bytes how many bytes need to be kept at this address * @param new_size how many bytes should the allocation we return have? * (should be larger or equal to @a copy_bytes) * @return addr new address of @a keep (if it had to change) */ void * MHD_pool_reset (struct MemoryPool *pool, void *keep, size_t copy_bytes, size_t new_size) { mhd_assert (pool->end >= pool->pos); mhd_assert (pool->size >= pool->end - pool->pos); mhd_assert (copy_bytes <= new_size); mhd_assert (copy_bytes <= pool->size); mhd_assert (keep != NULL || copy_bytes == 0); mhd_assert (keep == NULL || mp_ptr_le_ (pool->memory, keep)); /* (keep == NULL || pool->memory + pool->size >= (uint8_t*) keep + copy_bytes) */ mhd_assert ((keep == NULL) || \ (pool->size >= mp_ptr_diff_ (keep, pool->memory) + copy_bytes)); #if defined(MHD_ASAN_POISON_ACTIVE) && defined(HAVE___ASAN_REGION_IS_POISONED) mhd_assert (NULL == __asan_region_is_poisoned (keep, copy_bytes)); #endif /* MHD_ASAN_POISON_ACTIVE && HAVE___ASAN_REGION_IS_POISONED */ _MHD_UNPOISON_MEMORY (pool->memory, new_size); if ( (NULL != keep) && (keep != pool->memory) ) { if (0 != copy_bytes) memmove (pool->memory, keep, copy_bytes); } /* technically not needed, but safer to zero out */ if (pool->size > copy_bytes) { size_t to_zero; /** Size of area to zero-out */ to_zero = pool->size - copy_bytes; _MHD_UNPOISON_MEMORY (pool->memory + copy_bytes, to_zero); #ifdef _WIN32 if (pool->is_mmap) { size_t to_recommit; /** Size of decommitted and re-committed area. */ uint8_t *recommit_addr; /* Round down to page size */ to_recommit = to_zero - to_zero % MHD_sys_page_size_; recommit_addr = pool->memory + pool->size - to_recommit; /* De-committing and re-committing again clear memory and make * pages free / available for other needs until accessed. */ if (VirtualFree (recommit_addr, to_recommit, MEM_DECOMMIT)) { to_zero -= to_recommit; if (recommit_addr != VirtualAlloc (recommit_addr, to_recommit, MEM_COMMIT, PAGE_READWRITE)) abort (); /* Serious error, must never happen */ } } #endif /* _WIN32 */ memset (&pool->memory[copy_bytes], 0, to_zero); } pool->pos = ROUND_TO_ALIGN_PLUS_RED_ZONE (new_size); pool->end = pool->size; _MHD_POISON_MEMORY (((uint8_t *) pool->memory) + new_size, \ pool->size - new_size); return pool->memory; } /* end of memorypool.c */ libmicrohttpd-1.0.1/src/microhttpd/test_dauth_userdigest.c0000644000175000017500000005145514441373361017570 /* This file is part of libmicrohttpd Copyright (C) 2022 Evgeny Grin (Karlson2) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_dauth_userdigest.c * @brief Tests for Digest Auth calculations of userdigest * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include #include "microhttpd.h" #include "test_helpers.h" #if defined(MHD_HTTPS_REQUIRE_GCRYPT) && \ (defined(MHD_SHA256_TLSLIB) || defined(MHD_MD5_TLSLIB)) #define NEED_GCRYP_INIT 1 #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT && (MHD_SHA256_TLSLIB || MHD_MD5_TLSLIB) */ static int verbose = 1; /* verbose level (0-1)*/ /* Declarations and data */ struct data_md5 { unsigned int line_num; const char *const username; const char *const realm; const char *const password; const uint8_t hash[MHD_MD5_DIGEST_SIZE]; }; static const struct data_md5 md5_tests[] = { {__LINE__, "u", "r", "p", {0x44, 0xad, 0xd2, 0x2b, 0x6f, 0x31, 0x79, 0xb7, 0x51, 0xea, 0xfd, 0x68, 0xee, 0x37, 0x0f, 0x7d}}, {__LINE__, "testuser", "testrealm", "testpass", {0xeb, 0xff, 0x22, 0x5e, 0x1c, 0xeb, 0x73, 0xe0, 0x26, 0xfc, 0xc6, 0x45, 0xaf, 0x3e, 0x84, 0xf6}}, {__LINE__, /* Values from testcurl/test_digestauth2.c */ "test_user", "TestRealm", "test pass", {0xd8, 0xb4, 0xa6, 0xd0, 0x01, 0x13, 0x07, 0xb7, 0x67, 0x94, 0xea, 0x66, 0x86, 0x03, 0x6b, 0x43}}, {__LINE__, "Mufasa", "myhost@testrealm.com", "CircleOfLife", {0x7e, 0xbe, 0xcc, 0x07, 0x18, 0xa5, 0x4a, 0xb4, 0x7e, 0x21, 0x65, 0x69, 0x07, 0x66, 0x41, 0x6a}}, {__LINE__, "Mufasa", "myhost@example.com", "Circle Of Life", {0x6a, 0x6d, 0x4e, 0x7c, 0xd7, 0x15, 0x18, 0x68, 0xf9, 0xb8, 0xc7, 0xc8, 0xd1, 0xcd, 0xd4, 0xe0}}, {__LINE__, "Mufasa", "http-auth@example.org", "Circle of Life", {0x3d, 0x78, 0x80, 0x7d, 0xef, 0xe7, 0xde, 0x21, 0x57, 0xe2, 0xb0, 0xb6, 0x57, 0x3a, 0x85, 0x5f}}, {__LINE__, "J" "\xC3\xA4" "s" "\xC3\xB8" "n Doe" /* "Jäsøn Doe" */, "api@example.org", "Secret, or not?", {0x83, 0xa3, 0xf7, 0xf6, 0xb8, 0x3f, 0x71, 0xc5, 0xc2, 0xeb, 0x7c, 0x6d, 0xd2, 0xdd, 0x4c, 0x4b}} }; struct data_sha256 { unsigned int line_num; const char *const username; const char *const realm; const char *const password; const uint8_t hash[MHD_SHA256_DIGEST_SIZE]; }; static const struct data_sha256 sha256_tests[] = { {__LINE__, "u", "r", "p", {0xdc, 0xb0, 0x21, 0x10, 0x2e, 0x49, 0x1e, 0x70, 0x1a, 0x4a, 0x23, 0x6d, 0xaa, 0x89, 0x23, 0xaf, 0x21, 0x61, 0x44, 0x7b, 0xce, 0x7b, 0xb7, 0x26, 0x0a, 0x35, 0x1e, 0xe8, 0x3e, 0x9f, 0x81, 0x54}}, {__LINE__, "testuser", "testrealm", "testpass", {0xa9, 0x2e, 0xf6, 0x3b, 0x3d, 0xec, 0x38, 0x95, 0xb0, 0x8f, 0x3d, 0x4d, 0x67, 0x33, 0xf0, 0x70, 0x74, 0xcb, 0xe6, 0xd4, 0xa0, 0x01, 0x27, 0xf5, 0x74, 0x1a, 0x77, 0x4f, 0x05, 0xf9, 0xd4, 0x99}}, {__LINE__, /* Values from testcurl/test_digestauth2.c */ "test_user", "TestRealm", "test pass", {0xc3, 0x4e, 0x16, 0x5a, 0x17, 0x0f, 0xe5, 0xac, 0x04, 0xf1, 0x6e, 0x46, 0x48, 0x2b, 0xa0, 0xc6, 0x56, 0xc1, 0xfb, 0x8f, 0x66, 0xa6, 0xd6, 0x3f, 0x91, 0x12, 0xf8, 0x56, 0xa5, 0xec, 0x6d, 0x6d}}, {__LINE__, "Mufasa", "myhost@testrealm.com", "CircleOfLife", {0x8e, 0x64, 0x1f, 0xaa, 0x71, 0x7d, 0x20, 0x70, 0x5a, 0xd7, 0x3c, 0x54, 0xfb, 0x04, 0x9e, 0x32, 0x6a, 0xe1, 0x1c, 0x80, 0xd6, 0x05, 0x9f, 0xc3, 0x7e, 0xbb, 0x2d, 0x7b, 0x60, 0x6c, 0x11, 0xb9}}, {__LINE__, "Mufasa", "myhost@example.com", "Circle Of Life", {0x8b, 0xc5, 0xa8, 0xed, 0xe3, 0x02, 0x15, 0x6b, 0x9f, 0x51, 0xce, 0x97, 0x81, 0xb5, 0x26, 0xff, 0x99, 0x29, 0x0b, 0xb2, 0xc3, 0xe4, 0x41, 0x71, 0x8e, 0xa3, 0xa1, 0x7e, 0x5a, 0xd9, 0xd6, 0x49}}, {__LINE__, "Mufasa", "http-auth@example.org", "Circle of Life", {0x79, 0x87, 0xc6, 0x4c, 0x30, 0xe2, 0x5f, 0x1b, 0x74, 0xbe, 0x53, 0xf9, 0x66, 0xb4, 0x9b, 0x90, 0xf2, 0x80, 0x8a, 0xa9, 0x2f, 0xaf, 0x9a, 0x00, 0x26, 0x23, 0x92, 0xd7, 0xb4, 0x79, 0x42, 0x32}}, {__LINE__, "J" "\xC3\xA4" "s" "\xC3\xB8" "n Doe" /* "Jäsøn Doe" */, "api@example.org", "Secret, or not?", {0xfd, 0x0b, 0xe3, 0x93, 0x9d, 0xca, 0x4b, 0x5c, 0x2d, 0x46, 0xe8, 0xfa, 0x6a, 0x3d, 0x16, 0xdb, 0xea, 0x82, 0x47, 0x4c, 0xb9, 0xa5, 0x88, 0xd4, 0xcb, 0x14, 0x9c, 0x54, 0xf3, 0x7c, 0xff, 0x37}} }; struct data_sha512_256 { unsigned int line_num; const char *const username; const char *const realm; const char *const password; const uint8_t hash[MHD_SHA512_256_DIGEST_SIZE]; }; static const struct data_sha512_256 sha512_256_tests[] = { {__LINE__, "u", "r", "p", {0xd5, 0xe8, 0xe7, 0x3b, 0xa3, 0x47, 0xb9, 0xad, 0xf0, 0xe4, 0x7a, 0x9a, 0xce, 0x43, 0xb7, 0x08, 0x2a, 0xbc, 0x8d, 0x27, 0x27, 0x2e, 0x38, 0x7d, 0x1d, 0x9c, 0xe2, 0x44, 0x25, 0x68, 0x74, 0x04}}, {__LINE__, "testuser", "testrealm", "testpass", {0x41, 0x7d, 0xf9, 0x60, 0x7c, 0xc9, 0x60, 0x28, 0x44, 0x74, 0x75, 0xf7, 0x7b, 0x78, 0xe7, 0x60, 0xec, 0x9a, 0xe1, 0x62, 0xd4, 0x95, 0x82, 0x61, 0x68, 0xa7, 0x94, 0xe8, 0x3b, 0xdf, 0x8d, 0x59}}, {__LINE__, /* Values from testcurl/test_digestauth2.c */ "test_user", "TestRealm", "test pass", {0xe7, 0xa1, 0x9e, 0x27, 0xf6, 0x73, 0x88, 0xb2, 0xde, 0xa4, 0xe2, 0x66, 0xc5, 0x16, 0x37, 0x17, 0x4d, 0x29, 0xcc, 0xa3, 0xc1, 0xf5, 0xb2, 0x49, 0x20, 0xc1, 0x05, 0xc9, 0x20, 0x13, 0x3c, 0x3d}}, {__LINE__, "Mufasa", "myhost@testrealm.com", "CircleOfLife", {0x44, 0xbc, 0xd2, 0xb1, 0x1f, 0x6f, 0x7d, 0xd3, 0xae, 0xa6, 0x66, 0x8a, 0x24, 0x84, 0x4b, 0x87, 0x7d, 0xe1, 0x80, 0x24, 0x9a, 0x26, 0x6b, 0xe6, 0xdb, 0x7f, 0xe3, 0xc8, 0x7a, 0xf9, 0x75, 0x64}}, {__LINE__, "Mufasa", "myhost@example.com", "Circle Of Life", {0xd5, 0xf6, 0x25, 0x7c, 0x64, 0xe4, 0x01, 0xd2, 0x87, 0xd5, 0xaa, 0x19, 0xae, 0xf0, 0xa2, 0xa2, 0xce, 0x4e, 0x5d, 0xfc, 0x77, 0x70, 0x0b, 0x72, 0x90, 0x43, 0x96, 0xd2, 0x95, 0x6e, 0x83, 0x0a}}, {__LINE__, "Mufasa", "http-auth@example.org", "Circle of Life", {0xfb, 0x17, 0x4f, 0x5c, 0x3c, 0x78, 0x02, 0x72, 0x15, 0x17, 0xca, 0xe1, 0x3b, 0x98, 0xe2, 0xb8, 0xda, 0xe2, 0xe0, 0x11, 0x8c, 0xb7, 0x05, 0xd9, 0x4e, 0xe2, 0x99, 0x46, 0x31, 0x92, 0x04, 0xce}}, {__LINE__, "J" "\xC3\xA4" "s" "\xC3\xB8" "n Doe" /* "Jäsøn Doe" */, "api@example.org", "Secret, or not?", {0x2d, 0x3d, 0x9f, 0x12, 0xc9, 0xf3, 0xd3, 0x00, 0x11, 0x25, 0x9d, 0xc5, 0xfe, 0xce, 0xe0, 0x05, 0xae, 0x24, 0xde, 0x40, 0xe3, 0xe1, 0xf6, 0x18, 0x06, 0xd0, 0x3e, 0x65, 0xf1, 0xe6, 0x02, 0x4f}} }; /* * Helper functions */ /** * Print bin as lower case hex * * @param bin binary data * @param len number of bytes in bin * @param hex pointer to len*2+1 bytes buffer */ static void bin2hex (const uint8_t *bin, size_t len, char *hex) { while (len-- > 0) { unsigned int b1, b2; b1 = (*bin >> 4) & 0xf; *hex++ = (char) ((b1 > 9) ? (b1 + 'a' - 10) : (b1 + '0')); b2 = *bin++ & 0xf; *hex++ = (char) ((b2 > 9) ? (b2 + 'a' - 10) : (b2 + '0')); } *hex = 0; } /* Tests */ static unsigned int check_md5 (const struct data_md5 *const data) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_MD5; uint8_t hash_bin[MHD_MD5_DIGEST_SIZE]; char hash_hex[MHD_MD5_DIGEST_SIZE * 2 + 1]; char expected_hex[MHD_MD5_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userdigest"; if (MHD_YES != MHD_digest_auth_calc_userdigest (algo3, data->username, data->realm, data->password, hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_YES.\n", func_name); } else if (0 != memcmp (hash_bin, data->hash, sizeof(data->hash))) { failed++; bin2hex (hash_bin, sizeof(hash_bin), hash_hex); bin2hex (data->hash, sizeof(data->hash), expected_hex); fprintf (stderr, "FAILED: %s() produced wrong hash. " "Calculated digest %s, expected digest %s.\n", func_name, hash_hex, expected_hex); } if (failed) { fprintf (stderr, "The check failed for data located at line: %u.\n", data->line_num); fflush (stderr); } else if (verbose) { printf ("PASSED: check for data at line: %u.\n", data->line_num); } return failed ? 1 : 0; } static unsigned int test_md5 (void) { unsigned int num_failed = 0; size_t i; for (i = 0; i < sizeof(md5_tests) / sizeof(md5_tests[0]); i++) num_failed += check_md5 (md5_tests + i); return num_failed; } static unsigned int test_md5_failure (void) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_MD5; uint8_t hash_bin[MHD_MD5_DIGEST_SIZE]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userdigest"; if (MHD_NO != MHD_digest_auth_calc_userdigest (algo3, "u", "r", "p", hash_bin, sizeof(hash_bin) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userdigest (algo3, "u", "r", "p", hash_bin, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_MD5)) { if (MHD_NO != MHD_digest_auth_calc_userdigest (algo3, "u", "r", "p", hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } if (! failed && verbose) { printf ("PASSED: all checks with expected MHD_NO result near line: %u.\n", (unsigned) __LINE__); } return failed ? 1 : 0; } static unsigned int check_sha256 (const struct data_sha256 *const data) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_SHA256; uint8_t hash_bin[MHD_SHA256_DIGEST_SIZE]; char hash_hex[MHD_SHA256_DIGEST_SIZE * 2 + 1]; char expected_hex[MHD_SHA256_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userdigest"; if (MHD_YES != MHD_digest_auth_calc_userdigest (algo3, data->username, data->realm, data->password, hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_YES.\n", func_name); } else if (0 != memcmp (hash_bin, data->hash, sizeof(data->hash))) { failed++; bin2hex (hash_bin, sizeof(hash_bin), hash_hex); bin2hex (data->hash, sizeof(data->hash), expected_hex); fprintf (stderr, "FAILED: %s() produced wrong hash. " "Calculated digest %s, expected digest %s.\n", func_name, hash_hex, expected_hex); } if (failed) { fprintf (stderr, "The check failed for data located at line: %u.\n", data->line_num); fflush (stderr); } else if (verbose) { printf ("PASSED: check for data at line: %u.\n", data->line_num); } return failed ? 1 : 0; } static unsigned int test_sha256 (void) { unsigned int num_failed = 0; size_t i; for (i = 0; i < sizeof(sha256_tests) / sizeof(sha256_tests[0]); i++) num_failed += check_sha256 (sha256_tests + i); return num_failed; } static unsigned int test_sha256_failure (void) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_SHA256; uint8_t hash_bin[MHD_SHA256_DIGEST_SIZE]; char hash_hex[MHD_SHA256_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userhash"; if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, sizeof(hash_bin) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_SHA256)) { if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } func_name = "MHD_digest_auth_calc_userhash_hex"; if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, sizeof(hash_hex) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_SHA256)) { if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } if (! failed && verbose) { printf ("PASSED: all checks with expected MHD_NO result near line: %u.\n", (unsigned) __LINE__); } return failed ? 1 : 0; } static unsigned int check_sha512_256 (const struct data_sha512_256 *const data) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_SHA512_256; uint8_t hash_bin[MHD_SHA512_256_DIGEST_SIZE]; char hash_hex[MHD_SHA512_256_DIGEST_SIZE * 2 + 1]; char expected_hex[MHD_SHA512_256_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userdigest"; if (MHD_YES != MHD_digest_auth_calc_userdigest (algo3, data->username, data->realm, data->password, hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_YES.\n", func_name); } else if (0 != memcmp (hash_bin, data->hash, sizeof(data->hash))) { failed++; bin2hex (hash_bin, sizeof(hash_bin), hash_hex); bin2hex (data->hash, sizeof(data->hash), expected_hex); fprintf (stderr, "FAILED: %s() produced wrong hash. " "Calculated digest %s, expected digest %s.\n", func_name, hash_hex, expected_hex); } if (failed) { fprintf (stderr, "The check failed for data located at line: %u.\n", data->line_num); fflush (stderr); } else if (verbose) { printf ("PASSED: check for data at line: %u.\n", data->line_num); } return failed ? 1 : 0; } static unsigned int test_sha512_256 (void) { unsigned int num_failed = 0; size_t i; for (i = 0; i < sizeof(sha512_256_tests) / sizeof(sha512_256_tests[0]); i++) num_failed += check_sha512_256 (sha512_256_tests + i); return num_failed; } static unsigned int test_sha512_256_failure (void) { static const enum MHD_DigestAuthAlgo3 algo3 = MHD_DIGEST_AUTH_ALGO3_SHA512_256; static const enum MHD_FEATURE feature = MHD_FEATURE_DIGEST_AUTH_SHA512_256; uint8_t hash_bin[MHD_SHA512_256_DIGEST_SIZE]; char hash_hex[MHD_SHA512_256_DIGEST_SIZE * 2 + 1]; const char *func_name; unsigned int failed = 0; func_name = "MHD_digest_auth_calc_userhash"; if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, sizeof(hash_bin) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (feature)) { if (MHD_NO != MHD_digest_auth_calc_userhash (algo3, "u", "r", hash_bin, sizeof(hash_bin))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } func_name = "MHD_digest_auth_calc_userhash_hex"; if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, sizeof(hash_hex) - 1)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, 0)) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } if (MHD_NO == MHD_is_feature_supported (feature)) { if (MHD_NO != MHD_digest_auth_calc_userhash_hex (algo3, "u", "r", hash_hex, sizeof(hash_hex))) { failed++; fprintf (stderr, "FAILED: %s() has not returned MHD_NO at line: %u.\n", func_name, (unsigned) __LINE__); } } if (! failed && verbose) { printf ("PASSED: all checks with expected MHD_NO result near line: %u.\n", (unsigned) __LINE__); } return failed ? 1 : 0; } int main (int argc, char *argv[]) { unsigned int num_failed = 0; (void) has_in_name; /* Mute compiler warning. */ if (has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")) verbose = 0; #ifdef NEED_GCRYP_INIT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* GCRYCTL_INITIALIZATION_FINISHED */ #endif /* NEED_GCRYP_INIT */ if (MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_MD5)) num_failed += test_md5 (); num_failed += test_md5_failure (); if (MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_SHA256)) num_failed += test_sha256 (); num_failed += test_sha256_failure (); if (MHD_is_feature_supported (MHD_FEATURE_DIGEST_AUTH_SHA512_256)) num_failed += test_sha512_256 (); num_failed += test_sha512_256_failure (); return num_failed ? 1 : 0; } libmicrohttpd-1.0.1/src/microhttpd/mhd_str.c0000644000175000017500000017764014556705750014643 /* This file is part of libmicrohttpd Copyright (C) 2015-2024 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_str.c * @brief Functions implementations for string manipulating * @author Karlson2k (Evgeny Grin) */ #include "mhd_str.h" #ifdef HAVE_STDBOOL_H #include #endif /* HAVE_STDBOOL_H */ #include #include "mhd_assert.h" #include "mhd_limits.h" #include "mhd_assert.h" #ifdef MHD_FAVOR_SMALL_CODE #ifdef _MHD_static_inline #undef _MHD_static_inline #endif /* _MHD_static_inline */ /* Do not force inlining and do not use macro functions, use normal static functions instead. This may give more flexibility for size optimizations. */ #define _MHD_static_inline static #ifndef INLINE_FUNC #define INLINE_FUNC 1 #endif /* !INLINE_FUNC */ #endif /* MHD_FAVOR_SMALL_CODE */ /* * Block of functions/macros that use US-ASCII charset as required by HTTP * standards. Not affected by current locale settings. */ #ifdef INLINE_FUNC #if 0 /* Disable unused functions. */ /** * Check whether character is lower case letter in US-ASCII * * @param c character to check * @return non-zero if character is lower case letter, zero otherwise */ _MHD_static_inline bool isasciilower (char c) { return (c >= 'a') && (c <= 'z'); } #endif /* Disable unused functions. */ /** * Check whether character is upper case letter in US-ASCII * * @param c character to check * @return non-zero if character is upper case letter, zero otherwise */ _MHD_static_inline bool isasciiupper (char c) { return (c >= 'A') && (c <= 'Z'); } #if 0 /* Disable unused functions. */ /** * Check whether character is letter in US-ASCII * * @param c character to check * @return non-zero if character is letter in US-ASCII, zero otherwise */ _MHD_static_inline bool isasciialpha (char c) { return isasciilower (c) || isasciiupper (c); } #endif /* Disable unused functions. */ /** * Check whether character is decimal digit in US-ASCII * * @param c character to check * @return non-zero if character is decimal digit, zero otherwise */ _MHD_static_inline bool isasciidigit (char c) { return (c >= '0') && (c <= '9'); } #if 0 /* Disable unused functions. */ /** * Check whether character is hexadecimal digit in US-ASCII * * @param c character to check * @return non-zero if character is decimal digit, zero otherwise */ _MHD_static_inline bool isasciixdigit (char c) { return isasciidigit (c) || ( (c >= 'A') && (c <= 'F') ) || ( (c >= 'a') && (c <= 'f') ); } /** * Check whether character is decimal digit or letter in US-ASCII * * @param c character to check * @return non-zero if character is decimal digit or letter, zero otherwise */ _MHD_static_inline bool isasciialnum (char c) { return isasciialpha (c) || isasciidigit (c); } #endif /* Disable unused functions. */ #if 0 /* Disable unused functions. */ /** * Convert US-ASCII character to lower case. * If character is upper case letter in US-ASCII than it's converted to lower * case analog. If character is NOT upper case letter than it's returned * unmodified. * * @param c character to convert * @return converted to lower case character */ _MHD_static_inline char toasciilower (char c) { return isasciiupper (c) ? (c - 'A' + 'a') : c; } /** * Convert US-ASCII character to upper case. * If character is lower case letter in US-ASCII than it's converted to upper * case analog. If character is NOT lower case letter than it's returned * unmodified. * * @param c character to convert * @return converted to upper case character */ _MHD_static_inline char toasciiupper (char c) { return isasciilower (c) ? (c - 'a' + 'A') : c; } #endif /* Disable unused functions. */ #if defined(MHD_FAVOR_SMALL_CODE) /* Used only in MHD_str_to_uvalue_n_() */ /** * Convert US-ASCII decimal digit to its value. * * @param c character to convert * @return value of decimal digit or -1 if @ c is not decimal digit */ _MHD_static_inline int todigitvalue (char c) { if (isasciidigit (c)) return (unsigned char) (c - '0'); return -1; } #endif /* MHD_FAVOR_SMALL_CODE */ /** * Convert US-ASCII hexadecimal digit to its value. * * @param c character to convert * @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit */ _MHD_static_inline int toxdigitvalue (char c) { #if ! defined(MHD_FAVOR_SMALL_CODE) switch ((unsigned char) c) { #if 0 /* Disabled to give the compiler a hint about low probability */ case 0x00U: /* NUL */ case 0x01U: /* SOH */ case 0x02U: /* STX */ case 0x03U: /* ETX */ case 0x04U: /* EOT */ case 0x05U: /* ENQ */ case 0x06U: /* ACK */ case 0x07U: /* BEL */ case 0x08U: /* BS */ case 0x09U: /* HT */ case 0x0AU: /* LF */ case 0x0BU: /* VT */ case 0x0CU: /* FF */ case 0x0DU: /* CR */ case 0x0EU: /* SO */ case 0x0FU: /* SI */ case 0x10U: /* DLE */ case 0x11U: /* DC1 */ case 0x12U: /* DC2 */ case 0x13U: /* DC3 */ case 0x14U: /* DC4 */ case 0x15U: /* NAK */ case 0x16U: /* SYN */ case 0x17U: /* ETB */ case 0x18U: /* CAN */ case 0x19U: /* EM */ case 0x1AU: /* SUB */ case 0x1BU: /* ESC */ case 0x1CU: /* FS */ case 0x1DU: /* GS */ case 0x1EU: /* RS */ case 0x1FU: /* US */ case 0x20U: /* ' ' */ case 0x21U: /* '!' */ case 0x22U: /* '"' */ case 0x23U: /* '#' */ case 0x24U: /* '$' */ case 0x25U: /* '%' */ case 0x26U: /* '&' */ case 0x27U: /* '\'' */ case 0x28U: /* '(' */ case 0x29U: /* ')' */ case 0x2AU: /* '*' */ case 0x2BU: /* '+' */ case 0x2CU: /* ',' */ case 0x2DU: /* '-' */ case 0x2EU: /* '.' */ case 0x2FU: /* '/' */ return -1; #endif case 0x30U: /* '0' */ return 0; case 0x31U: /* '1' */ return 1; case 0x32U: /* '2' */ return 2; case 0x33U: /* '3' */ return 3; case 0x34U: /* '4' */ return 4; case 0x35U: /* '5' */ return 5; case 0x36U: /* '6' */ return 6; case 0x37U: /* '7' */ return 7; case 0x38U: /* '8' */ return 8; case 0x39U: /* '9' */ return 9; #if 0 /* Disabled to give the compiler a hint about low probability */ case 0x3AU: /* ':' */ case 0x3BU: /* ';' */ case 0x3CU: /* '<' */ case 0x3DU: /* '=' */ case 0x3EU: /* '>' */ case 0x3FU: /* '?' */ case 0x40U: /* '@' */ return -1; #endif case 0x41U: /* 'A' */ return 0xAU; case 0x42U: /* 'B' */ return 0xBU; case 0x43U: /* 'C' */ return 0xCU; case 0x44U: /* 'D' */ return 0xDU; case 0x45U: /* 'E' */ return 0xEU; case 0x46U: /* 'F' */ return 0xFU; #if 0 /* Disabled to give the compiler a hint about low probability */ case 0x47U: /* 'G' */ case 0x48U: /* 'H' */ case 0x49U: /* 'I' */ case 0x4AU: /* 'J' */ case 0x4BU: /* 'K' */ case 0x4CU: /* 'L' */ case 0x4DU: /* 'M' */ case 0x4EU: /* 'N' */ case 0x4FU: /* 'O' */ case 0x50U: /* 'P' */ case 0x51U: /* 'Q' */ case 0x52U: /* 'R' */ case 0x53U: /* 'S' */ case 0x54U: /* 'T' */ case 0x55U: /* 'U' */ case 0x56U: /* 'V' */ case 0x57U: /* 'W' */ case 0x58U: /* 'X' */ case 0x59U: /* 'Y' */ case 0x5AU: /* 'Z' */ case 0x5BU: /* '[' */ case 0x5CU: /* '\' */ case 0x5DU: /* ']' */ case 0x5EU: /* '^' */ case 0x5FU: /* '_' */ case 0x60U: /* '`' */ return -1; #endif case 0x61U: /* 'a' */ return 0xAU; case 0x62U: /* 'b' */ return 0xBU; case 0x63U: /* 'c' */ return 0xCU; case 0x64U: /* 'd' */ return 0xDU; case 0x65U: /* 'e' */ return 0xEU; case 0x66U: /* 'f' */ return 0xFU; #if 0 /* Disabled to give the compiler a hint about low probability */ case 0x67U: /* 'g' */ case 0x68U: /* 'h' */ case 0x69U: /* 'i' */ case 0x6AU: /* 'j' */ case 0x6BU: /* 'k' */ case 0x6CU: /* 'l' */ case 0x6DU: /* 'm' */ case 0x6EU: /* 'n' */ case 0x6FU: /* 'o' */ case 0x70U: /* 'p' */ case 0x71U: /* 'q' */ case 0x72U: /* 'r' */ case 0x73U: /* 's' */ case 0x74U: /* 't' */ case 0x75U: /* 'u' */ case 0x76U: /* 'v' */ case 0x77U: /* 'w' */ case 0x78U: /* 'x' */ case 0x79U: /* 'y' */ case 0x7AU: /* 'z' */ case 0x7BU: /* '{' */ case 0x7CU: /* '|' */ case 0x7DU: /* '}' */ case 0x7EU: /* '~' */ case 0x7FU: /* DEL */ case 0x80U: /* EXT */ case 0x81U: /* EXT */ case 0x82U: /* EXT */ case 0x83U: /* EXT */ case 0x84U: /* EXT */ case 0x85U: /* EXT */ case 0x86U: /* EXT */ case 0x87U: /* EXT */ case 0x88U: /* EXT */ case 0x89U: /* EXT */ case 0x8AU: /* EXT */ case 0x8BU: /* EXT */ case 0x8CU: /* EXT */ case 0x8DU: /* EXT */ case 0x8EU: /* EXT */ case 0x8FU: /* EXT */ case 0x90U: /* EXT */ case 0x91U: /* EXT */ case 0x92U: /* EXT */ case 0x93U: /* EXT */ case 0x94U: /* EXT */ case 0x95U: /* EXT */ case 0x96U: /* EXT */ case 0x97U: /* EXT */ case 0x98U: /* EXT */ case 0x99U: /* EXT */ case 0x9AU: /* EXT */ case 0x9BU: /* EXT */ case 0x9CU: /* EXT */ case 0x9DU: /* EXT */ case 0x9EU: /* EXT */ case 0x9FU: /* EXT */ case 0xA0U: /* EXT */ case 0xA1U: /* EXT */ case 0xA2U: /* EXT */ case 0xA3U: /* EXT */ case 0xA4U: /* EXT */ case 0xA5U: /* EXT */ case 0xA6U: /* EXT */ case 0xA7U: /* EXT */ case 0xA8U: /* EXT */ case 0xA9U: /* EXT */ case 0xAAU: /* EXT */ case 0xABU: /* EXT */ case 0xACU: /* EXT */ case 0xADU: /* EXT */ case 0xAEU: /* EXT */ case 0xAFU: /* EXT */ case 0xB0U: /* EXT */ case 0xB1U: /* EXT */ case 0xB2U: /* EXT */ case 0xB3U: /* EXT */ case 0xB4U: /* EXT */ case 0xB5U: /* EXT */ case 0xB6U: /* EXT */ case 0xB7U: /* EXT */ case 0xB8U: /* EXT */ case 0xB9U: /* EXT */ case 0xBAU: /* EXT */ case 0xBBU: /* EXT */ case 0xBCU: /* EXT */ case 0xBDU: /* EXT */ case 0xBEU: /* EXT */ case 0xBFU: /* EXT */ case 0xC0U: /* EXT */ case 0xC1U: /* EXT */ case 0xC2U: /* EXT */ case 0xC3U: /* EXT */ case 0xC4U: /* EXT */ case 0xC5U: /* EXT */ case 0xC6U: /* EXT */ case 0xC7U: /* EXT */ case 0xC8U: /* EXT */ case 0xC9U: /* EXT */ case 0xCAU: /* EXT */ case 0xCBU: /* EXT */ case 0xCCU: /* EXT */ case 0xCDU: /* EXT */ case 0xCEU: /* EXT */ case 0xCFU: /* EXT */ case 0xD0U: /* EXT */ case 0xD1U: /* EXT */ case 0xD2U: /* EXT */ case 0xD3U: /* EXT */ case 0xD4U: /* EXT */ case 0xD5U: /* EXT */ case 0xD6U: /* EXT */ case 0xD7U: /* EXT */ case 0xD8U: /* EXT */ case 0xD9U: /* EXT */ case 0xDAU: /* EXT */ case 0xDBU: /* EXT */ case 0xDCU: /* EXT */ case 0xDDU: /* EXT */ case 0xDEU: /* EXT */ case 0xDFU: /* EXT */ case 0xE0U: /* EXT */ case 0xE1U: /* EXT */ case 0xE2U: /* EXT */ case 0xE3U: /* EXT */ case 0xE4U: /* EXT */ case 0xE5U: /* EXT */ case 0xE6U: /* EXT */ case 0xE7U: /* EXT */ case 0xE8U: /* EXT */ case 0xE9U: /* EXT */ case 0xEAU: /* EXT */ case 0xEBU: /* EXT */ case 0xECU: /* EXT */ case 0xEDU: /* EXT */ case 0xEEU: /* EXT */ case 0xEFU: /* EXT */ case 0xF0U: /* EXT */ case 0xF1U: /* EXT */ case 0xF2U: /* EXT */ case 0xF3U: /* EXT */ case 0xF4U: /* EXT */ case 0xF5U: /* EXT */ case 0xF6U: /* EXT */ case 0xF7U: /* EXT */ case 0xF8U: /* EXT */ case 0xF9U: /* EXT */ case 0xFAU: /* EXT */ case 0xFBU: /* EXT */ case 0xFCU: /* EXT */ case 0xFDU: /* EXT */ case 0xFEU: /* EXT */ case 0xFFU: /* EXT */ return -1; default: mhd_assert (0); break; /* Should be unreachable */ #else default: break; #endif } return -1; #else /* MHD_FAVOR_SMALL_CODE */ if (isasciidigit (c)) return (unsigned char) (c - '0'); if ( (c >= 'A') && (c <= 'F') ) return (unsigned char) (c - 'A' + 10); if ( (c >= 'a') && (c <= 'f') ) return (unsigned char) (c - 'a' + 10); return -1; #endif /* MHD_FAVOR_SMALL_CODE */ } /** * Caseless compare two characters. * * @param c1 the first char to compare * @param c2 the second char to compare * @return boolean 'true' if chars are caseless equal, false otherwise */ _MHD_static_inline bool charsequalcaseless (const char c1, const char c2) { return ( (c1 == c2) || (isasciiupper (c1) ? ((c1 - 'A' + 'a') == c2) : ((c1 == (c2 - 'A' + 'a')) && isasciiupper (c2))) ); } #else /* !INLINE_FUNC */ /** * Checks whether character is lower case letter in US-ASCII * * @param c character to check * @return boolean true if character is lower case letter, * boolean false otherwise */ #define isasciilower(c) (((char) (c)) >= 'a' && ((char) (c)) <= 'z') /** * Checks whether character is upper case letter in US-ASCII * * @param c character to check * @return boolean true if character is upper case letter, * boolean false otherwise */ #define isasciiupper(c) (((char) (c)) >= 'A' && ((char) (c)) <= 'Z') /** * Checks whether character is letter in US-ASCII * * @param c character to check * @return boolean true if character is letter, boolean false * otherwise */ #define isasciialpha(c) (isasciilower (c) || isasciiupper (c)) /** * Check whether character is decimal digit in US-ASCII * * @param c character to check * @return boolean true if character is decimal digit, boolean false * otherwise */ #define isasciidigit(c) (((char) (c)) >= '0' && ((char) (c)) <= '9') /** * Check whether character is hexadecimal digit in US-ASCII * * @param c character to check * @return boolean true if character is hexadecimal digit, * boolean false otherwise */ #define isasciixdigit(c) (isasciidigit ((c)) || \ (((char) (c)) >= 'A' && ((char) (c)) <= 'F') || \ (((char) (c)) >= 'a' && ((char) (c)) <= 'f') ) /** * Check whether character is decimal digit or letter in US-ASCII * * @param c character to check * @return boolean true if character is decimal digit or letter, * boolean false otherwise */ #define isasciialnum(c) (isasciialpha (c) || isasciidigit (c)) /** * Convert US-ASCII character to lower case. * If character is upper case letter in US-ASCII than it's converted to lower * case analog. If character is NOT upper case letter than it's returned * unmodified. * * @param c character to convert * @return converted to lower case character */ #define toasciilower(c) ((isasciiupper (c)) ? (((char) (c)) - 'A' + 'a') : \ ((char) (c))) /** * Convert US-ASCII character to upper case. * If character is lower case letter in US-ASCII than it's converted to upper * case analog. If character is NOT lower case letter than it's returned * unmodified. * * @param c character to convert * @return converted to upper case character */ #define toasciiupper(c) ((isasciilower (c)) ? (((char) (c)) - 'a' + 'A') : \ ((char) (c))) /** * Convert US-ASCII decimal digit to its value. * * @param c character to convert * @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit */ #define todigitvalue(c) (isasciidigit (c) ? (int) (((char) (c)) - '0') : \ (int) (-1)) /** * Convert US-ASCII hexadecimal digit to its value. * @param c character to convert * @return value of hexadecimal digit or -1 if @ c is not hexadecimal digit */ #define toxdigitvalue(c) (isasciidigit (c) ? (int) (((char) (c)) - '0') : \ ( (((char) (c)) >= 'A' && ((char) (c)) <= 'F') ? \ (int) (((unsigned char) (c)) - 'A' + 10) : \ ( (((char) (c)) >= 'a' && ((char) (c)) <= 'f') ? \ (int) (((unsigned char) (c)) - 'a' + 10) : \ (int) (-1) ))) /** * Caseless compare two characters. * * @param c1 the first char to compare * @param c2 the second char to compare * @return boolean 'true' if chars are caseless equal, false otherwise */ #define charsequalcaseless(c1, c2) \ ( ((c1) == (c2)) || \ (isasciiupper (c1) ? \ (((c1) - 'A' + 'a') == (c2)) : \ (((c1) == ((c2) - 'A' + 'a')) && isasciiupper (c2))) ) #endif /* !INLINE_FUNC */ #ifndef MHD_FAVOR_SMALL_CODE /** * Check two strings for equality, ignoring case of US-ASCII letters. * * @param str1 first string to compare * @param str2 second string to compare * @return non-zero if two strings are equal, zero otherwise. */ int MHD_str_equal_caseless_ (const char *str1, const char *str2) { while (0 != (*str1)) { const char c1 = *str1; const char c2 = *str2; if (charsequalcaseless (c1, c2)) { str1++; str2++; } else return 0; } return 0 == (*str2); } #endif /* ! MHD_FAVOR_SMALL_CODE */ /** * Check two string for equality, ignoring case of US-ASCII letters and * checking not more than @a maxlen characters. * Compares up to first terminating null character, but not more than * first @a maxlen characters. * * @param str1 first string to compare * @param str2 second string to compare * @param maxlen maximum number of characters to compare * @return non-zero if two strings are equal, zero otherwise. */ int MHD_str_equal_caseless_n_ (const char *const str1, const char *const str2, size_t maxlen) { size_t i; for (i = 0; i < maxlen; ++i) { const char c1 = str1[i]; const char c2 = str2[i]; if (0 == c2) return 0 == c1; if (charsequalcaseless (c1, c2)) continue; else return 0; } return ! 0; } /** * Check two string for equality, ignoring case of US-ASCII letters and * checking not more than @a len bytes. * Compares not more first than @a len bytes, including binary zero characters. * Comparison stops at first unmatched byte. * @param str1 first string to compare * @param str2 second string to compare * @param len number of characters to compare * @return non-zero if @a len bytes are equal, zero otherwise. */ bool MHD_str_equal_caseless_bin_n_ (const char *const str1, const char *const str2, size_t len) { size_t i; for (i = 0; i < len; ++i) { const char c1 = str1[i]; const char c2 = str2[i]; if (charsequalcaseless (c1, c2)) continue; else return 0; } return ! 0; } /** * Check whether @a str has case-insensitive @a token. * Token could be surrounded by spaces and tabs and delimited by comma. * Match succeed if substring between start, end (of string) or comma * contains only case-insensitive token and optional spaces and tabs. * @warning token must not contain null-characters except optional * terminating null-character. * @param str the string to check * @param token the token to find * @param token_len length of token, not including optional terminating * null-character. * @return non-zero if two strings are equal, zero otherwise. */ bool MHD_str_has_token_caseless_ (const char *str, const char *const token, size_t token_len) { if (0 == token_len) return false; while (0 != *str) { size_t i; /* Skip all whitespaces and empty tokens. */ while (' ' == *str || '\t' == *str || ',' == *str) str++; /* Check for token match. */ i = 0; while (1) { const char sc = *(str++); const char tc = token[i++]; if (0 == sc) return false; if (! charsequalcaseless (sc, tc)) break; if (i >= token_len) { /* Check whether substring match token fully or * has additional unmatched chars at tail. */ while (' ' == *str || '\t' == *str) str++; /* End of (sub)string? */ if ((0 == *str) || (',' == *str) ) return true; /* Unmatched chars at end of substring. */ break; } } /* Find next substring. */ while (0 != *str && ',' != *str) str++; } return false; } /** * Remove case-insensitive @a token from the @a str and put result * to the output @a buf. * * Tokens in @a str could be surrounded by spaces and tabs and delimited by * comma. The token match succeed if substring between start, end (of string) * or comma contains only case-insensitive token and optional spaces and tabs. * The quoted strings and comments are not supported by this function. * * The output string is normalised: empty tokens and repeated whitespaces * are removed, no whitespaces before commas, exactly one space is used after * each comma. * * @param str the string to process * @param str_len the length of the @a str, not including optional * terminating null-character. * @param token the token to find * @param token_len the length of @a token, not including optional * terminating null-character. * @param[out] buf the output buffer, not null-terminated. * @param[in,out] buf_size pointer to the size variable, at input it * is the size of allocated buffer, at output * it is the size of the resulting string (can * be up to 50% larger than input) or negative value * if there is not enough space for the result * @return 'true' if token has been removed, * 'false' otherwise. */ bool MHD_str_remove_token_caseless_ (const char *str, size_t str_len, const char *const token, const size_t token_len, char *buf, ssize_t *buf_size) { const char *s1; /**< the "input" string / character */ char *s2; /**< the "output" string / character */ size_t t_pos; /**< position of matched character in the token */ bool token_removed; mhd_assert (NULL == memchr (token, 0, token_len)); mhd_assert (NULL == memchr (token, ' ', token_len)); mhd_assert (NULL == memchr (token, '\t', token_len)); mhd_assert (NULL == memchr (token, ',', token_len)); mhd_assert (0 <= *buf_size); if (SSIZE_MAX <= ((str_len / 2) * 3 + 3)) { /* The return value may overflow, refuse */ *buf_size = (ssize_t) -1; return false; } s1 = str; s2 = buf; token_removed = false; while ((size_t) (s1 - str) < str_len) { const char *cur_token; /**< the first char of current token */ size_t copy_size; /* Skip any initial whitespaces and empty tokens */ while ( ((size_t) (s1 - str) < str_len) && ((' ' == *s1) || ('\t' == *s1) || (',' == *s1)) ) s1++; /* 's1' points to the first char of token in the input string or * points just beyond the end of the input string */ if ((size_t) (s1 - str) >= str_len) break; /* Nothing to copy, end of the input string */ /* 's1' points to the first char of token in the input string */ cur_token = s1; /* the first char of input token */ /* Check the token with case-insensetive match */ t_pos = 0; while ( ((size_t) (s1 - str) < str_len) && (token_len > t_pos) && (charsequalcaseless (*s1, token[t_pos])) ) { s1++; t_pos++; } /* s1 may point just beyond the end of the input string */ if ( (token_len == t_pos) && (0 != token_len) ) { /* 'token' matched, check that current input token does not have * any suffixes */ while ( ((size_t) (s1 - str) < str_len) && ((' ' == *s1) || ('\t' == *s1)) ) s1++; /* 's1' points to the first non-whitespace char after the token matched * requested token or points just beyond the end of the input string after * the requested token */ if (((size_t) (s1 - str) == str_len) || (',' == *s1)) {/* full token match, do not copy current token to the output */ token_removed = true; continue; } } /* 's1' points to first non-whitespace char, to some char after * first non-whitespace char in the token in the input string, to * the ',', or just beyond the end of the input string */ /* The current token in the input string does not match the token * to exclude, it must be copied to the output string */ /* the current token size excluding leading whitespaces and current char */ copy_size = (size_t) (s1 - cur_token); if (buf == s2) { /* The first token to copy to the output */ if ((size_t) *buf_size < copy_size) { /* Not enough space in the output buffer */ *buf_size = (ssize_t) -1; return false; } } else { /* Some token was already copied to the output buffer */ mhd_assert (s2 > buf); if ((size_t) *buf_size < ((size_t) (s2 - buf)) + copy_size + 2) { /* Not enough space in the output buffer */ *buf_size = (ssize_t) -1; return false; } *(s2++) = ','; *(s2++) = ' '; } /* Copy non-matched token to the output */ if (0 != copy_size) { memcpy (s2, cur_token, copy_size); s2 += copy_size; } while ( ((size_t) (s1 - str) < str_len) && (',' != *s1)) { /* 's1' points to first non-whitespace char, to some char after * first non-whitespace char in the token in the input string */ /* Copy all non-whitespace chars from the current token in * the input string */ while ( ((size_t) (s1 - str) < str_len) && (',' != *s1) && (' ' != *s1) && ('\t' != *s1) ) { mhd_assert (s2 >= buf); if ((size_t) *buf_size <= (size_t) (s2 - buf)) /* '<= s2' equals '< s2 + 1' */ { /* Not enough space in the output buffer */ *buf_size = (ssize_t) -1; return false; } *(s2++) = *(s1++); } /* 's1' points to some whitespace char in the token in the input * string, to the ',', or just beyond the end of the input string */ /* Skip all whitespaces */ while ( ((size_t) (s1 - str) < str_len) && ((' ' == *s1) || ('\t' == *s1)) ) s1++; /* 's1' points to the first non-whitespace char in the input string * after whitespace chars, to the ',', or just beyond the end of * the input string */ if (((size_t) (s1 - str) < str_len) && (',' != *s1)) { /* Not the end of the current token */ mhd_assert (s2 >= buf); if ((size_t) *buf_size <= (size_t) (s2 - buf)) /* '<= s2' equals '< s2 + 1' */ { /* Not enough space in the output buffer */ *buf_size = (ssize_t) -1; return false; } *(s2++) = ' '; } } } mhd_assert (((ssize_t) (s2 - buf)) <= *buf_size); *buf_size = (ssize_t) (s2 - buf); return token_removed; } /** * Perform in-place case-insensitive removal of @a tokens from the @a str. * * Token could be surrounded by spaces and tabs and delimited by comma. * The token match succeed if substring between start, end (of the string), or * comma contains only case-insensitive token and optional spaces and tabs. * The quoted strings and comments are not supported by this function. * * The input string must be normalised: empty tokens and repeated whitespaces * are removed, no whitespaces before commas, exactly one space is used after * each comma. The string is updated in-place. * * Behavior is undefined is the input string in not normalised. * * @param[in,out] str the string to update * @param[in,out] str_len the length of the @a str, not including optional * terminating null-character, not null-terminated * @param tokens the token to find * @param tokens_len the length of @a tokens, not including optional * terminating null-character. * @return 'true' if any token has been removed, * 'false' otherwise. */ bool MHD_str_remove_tokens_caseless_ (char *str, size_t *str_len, const char *const tokens, const size_t tokens_len) { const char *const t = tokens; /**< a short alias for @a tokens */ size_t pt; /**< position in @a tokens */ bool token_removed; mhd_assert (NULL == memchr (tokens, 0, tokens_len)); token_removed = false; pt = 0; while (pt < tokens_len && *str_len != 0) { const char *tkn; /**< the current token */ size_t tkn_len; /* Skip any initial whitespaces and empty tokens in 'tokens' */ while ( (pt < tokens_len) && ((' ' == t[pt]) || ('\t' == t[pt]) || (',' == t[pt])) ) pt++; if (pt >= tokens_len) break; /* No more tokens, nothing to remove */ /* Found non-whitespace char which is not a comma */ tkn = t + pt; do { do { pt++; } while (pt < tokens_len && (' ' != t[pt] && '\t' != t[pt] && ',' != t[pt])); /* Found end of the token string, space, tab, or comma */ tkn_len = pt - (size_t) (tkn - t); /* Skip all spaces and tabs */ while (pt < tokens_len && (' ' == t[pt] || '\t' == t[pt])) pt++; /* Found end of the token string or non-whitespace char */ } while (pt < tokens_len && ',' != t[pt]); /* 'tkn' is the input token with 'tkn_len' chars */ mhd_assert (0 != tkn_len); if (*str_len == tkn_len) { if (MHD_str_equal_caseless_bin_n_ (str, tkn, tkn_len)) { *str_len = 0; token_removed = true; } continue; } /* 'tkn' cannot match part of 'str' if length of 'tkn' is larger * than length of 'str'. * It's know that 'tkn' is not equal to the 'str' (was checked previously). * As 'str' is normalized when 'tkn' is not equal to the 'str' * it is required that 'str' to be at least 3 chars larger then 'tkn' * (the comma, the space and at least one additional character for the next * token) to remove 'tkn' from the 'str'. */ if (*str_len > tkn_len + 2) { /* Remove 'tkn' from the input string */ size_t pr; /**< the 'read' position in the @a str */ size_t pw; /**< the 'write' position in the @a str */ pr = 0; pw = 0; do { mhd_assert (pr >= pw); mhd_assert ((*str_len) >= (pr + tkn_len)); if ( ( ((*str_len) == (pr + tkn_len)) || (',' == str[pr + tkn_len]) ) && MHD_str_equal_caseless_bin_n_ (str + pr, tkn, tkn_len) ) { /* current token in the input string matches the 'tkn', skip it */ mhd_assert ((*str_len == pr + tkn_len) || \ (' ' == str[pr + tkn_len + 1])); /* 'str' must be normalized */ token_removed = true; /* Advance to the next token in the input string or beyond * the end of the input string. */ pr += tkn_len + 2; } else { /* current token in the input string does not match the 'tkn', * copy to the output */ if (0 != pw) { /* not the first output token, add ", " to separate */ if (pr != pw + 2) { str[pw++] = ','; str[pw++] = ' '; } else pw += 2; /* 'str' is not yet modified in this round */ } do { if (pr != pw) str[pw] = str[pr]; pr++; pw++; } while (pr < *str_len && ',' != str[pr]); /* Advance to the next token in the input string or beyond * the end of the input string. */ pr += 2; } /* 'pr' should point to the next token in the input string or beyond * the end of the input string */ if ((*str_len) < (pr + tkn_len)) { /* The rest of the 'str + pr' is too small to match 'tkn' */ if ((*str_len) > pr) { /* Copy the rest of the string */ size_t copy_size; copy_size = *str_len - pr; if (0 != pw) { /* not the first output token, add ", " to separate */ if (pr != pw + 2) { str[pw++] = ','; str[pw++] = ' '; } else pw += 2; /* 'str' is not yet modified in this round */ } if (pr != pw) memmove (str + pw, str + pr, copy_size); pw += copy_size; } *str_len = pw; break; } mhd_assert ((' ' != str[0]) && ('\t' != str[0])); mhd_assert ((0 == pr) || (3 <= pr)); mhd_assert ((0 == pr) || (' ' == str[pr - 1])); mhd_assert ((0 == pr) || (',' == str[pr - 2])); } while (1); } } return token_removed; } #ifndef MHD_FAVOR_SMALL_CODE /* Use individual function for each case */ /** * Convert decimal US-ASCII digits in string to number in uint64_t. * Conversion stopped at first non-digit character. * * @param str string to convert * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_str_to_uint64_ (const char *str, uint64_t *out_val) { const char *const start = str; uint64_t res; if (! str || ! out_val || ! isasciidigit (str[0])) return 0; res = 0; do { const int digit = (unsigned char) (*str) - '0'; if ( (res > (UINT64_MAX / 10)) || ( (res == (UINT64_MAX / 10)) && ((uint64_t) digit > (UINT64_MAX % 10)) ) ) return 0; res *= 10; res += (unsigned int) digit; str++; } while (isasciidigit (*str)); *out_val = res; return (size_t) (str - start); } /** * Convert not more then @a maxlen decimal US-ASCII digits in string to * number in uint64_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * * @param str string to convert * @param maxlen maximum number of characters to process * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_str_to_uint64_n_ (const char *str, size_t maxlen, uint64_t *out_val) { uint64_t res; size_t i; if (! str || ! maxlen || ! out_val || ! isasciidigit (str[0])) return 0; res = 0; i = 0; do { const int digit = (unsigned char) str[i] - '0'; if ( (res > (UINT64_MAX / 10)) || ( (res == (UINT64_MAX / 10)) && ((uint64_t) digit > (UINT64_MAX % 10)) ) ) return 0; res *= 10; res += (unsigned int) digit; i++; } while ( (i < maxlen) && isasciidigit (str[i]) ); *out_val = res; return i; } /** * Convert hexadecimal US-ASCII digits in string to number in uint32_t. * Conversion stopped at first non-digit character. * * @param str string to convert * @param[out] out_val pointer to uint32_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint32_t or @a out_val is NULL */ size_t MHD_strx_to_uint32_ (const char *str, uint32_t *out_val) { const char *const start = str; uint32_t res; int digit; if (! str || ! out_val) return 0; res = 0; digit = toxdigitvalue (*str); while (digit >= 0) { if ( (res < (UINT32_MAX / 16)) || ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit <= (UINT32_MAX % 16)) ) ) { res *= 16; res += (unsigned int) digit; } else return 0; str++; digit = toxdigitvalue (*str); } if (str - start > 0) *out_val = res; return (size_t) (str - start); } /** * Convert not more then @a maxlen hexadecimal US-ASCII digits in string * to number in uint32_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * * @param str string to convert * @param maxlen maximum number of characters to process * @param[out] out_val pointer to uint32_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint32_t or @a out_val is NULL */ size_t MHD_strx_to_uint32_n_ (const char *str, size_t maxlen, uint32_t *out_val) { size_t i; uint32_t res; int digit; if (! str || ! out_val) return 0; res = 0; i = 0; while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) { if ( (res > (UINT32_MAX / 16)) || ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit > (UINT32_MAX % 16)) ) ) return 0; res *= 16; res += (unsigned int) digit; i++; } if (i) *out_val = res; return i; } /** * Convert hexadecimal US-ASCII digits in string to number in uint64_t. * Conversion stopped at first non-digit character. * * @param str string to convert * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_strx_to_uint64_ (const char *str, uint64_t *out_val) { const char *const start = str; uint64_t res; int digit; if (! str || ! out_val) return 0; res = 0; digit = toxdigitvalue (*str); while (digit >= 0) { if ( (res < (UINT64_MAX / 16)) || ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit <= (UINT64_MAX % 16)) ) ) { res *= 16; res += (unsigned int) digit; } else return 0; str++; digit = toxdigitvalue (*str); } if (str - start > 0) *out_val = res; return (size_t) (str - start); } /** * Convert not more then @a maxlen hexadecimal US-ASCII digits in string * to number in uint64_t. * Conversion stopped at first non-digit character or after @a maxlen * digits. * * @param str string to convert * @param maxlen maximum number of characters to process * @param[out] out_val pointer to uint64_t to store result of conversion * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then possible to store in uint64_t or @a out_val is NULL */ size_t MHD_strx_to_uint64_n_ (const char *str, size_t maxlen, uint64_t *out_val) { size_t i; uint64_t res; int digit; if (! str || ! out_val) return 0; res = 0; i = 0; while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) { if ( (res > (UINT64_MAX / 16)) || ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit > (UINT64_MAX % 16)) ) ) return 0; res *= 16; res += (unsigned int) digit; i++; } if (i) *out_val = res; return i; } #else /* MHD_FAVOR_SMALL_CODE */ /** * Generic function for converting not more then @a maxlen * hexadecimal or decimal US-ASCII digits in string to number. * Conversion stopped at first non-digit character or after @a maxlen * digits. * To be used only within macro. * * @param str the string to convert * @param maxlen the maximum number of characters to process * @param out_val the pointer to variable to store result of conversion * @param val_size the size of variable pointed by @a out_val, in bytes, 4 or 8 * @param max_val the maximum decoded number * @param base the numeric base, 10 or 16 * @return non-zero number of characters processed on succeed, * zero if no digit is found, resulting value is larger * then @a max_val, @a val_size is not 4/8 or @a out_val is NULL */ size_t MHD_str_to_uvalue_n_ (const char *str, size_t maxlen, void *out_val, size_t val_size, uint64_t max_val, unsigned int base) { size_t i; uint64_t res; const uint64_t max_v_div_b = max_val / base; const uint64_t max_v_mod_b = max_val % base; if (! str || ! out_val || ((base != 16) && (base != 10)) ) return 0; res = 0; i = 0; while (maxlen > i) { const int digit = (base == 16) ? toxdigitvalue (str[i]) : todigitvalue (str[i]); if (0 > digit) break; if ( ((max_v_div_b) < res) || (( (max_v_div_b) == res) && ( (max_v_mod_b) < (uint64_t) digit) ) ) return 0; res *= base; res += (unsigned int) digit; i++; } if (i) { if (8 == val_size) *(uint64_t *) out_val = res; else if (4 == val_size) *(uint32_t *) out_val = (uint32_t) res; else return 0; } return i; } #endif /* MHD_FAVOR_SMALL_CODE */ size_t MHD_uint32_to_strx (uint32_t val, char *buf, size_t buf_size) { size_t o_pos = 0; /**< position of the output character */ int digit_pos = 8; /** zero-based, digit position in @a 'val' */ int digit; /* Skip leading zeros */ do { digit_pos--; digit = (int) (val >> 28); val <<= 4; } while ((0 == digit) && (0 != digit_pos)); while (o_pos < buf_size) { buf[o_pos++] = (char) ((digit <= 9) ? ('0' + (char) digit) : ('A' + (char) digit - 10)); if (0 == digit_pos) return o_pos; digit_pos--; digit = (int) (val >> 28); val <<= 4; } return 0; /* The buffer is too small */ } #ifndef MHD_FAVOR_SMALL_CODE size_t MHD_uint16_to_str (uint16_t val, char *buf, size_t buf_size) { char *chr; /**< pointer to the current printed digit */ /* The biggest printable number is 65535 */ uint16_t divisor = UINT16_C (10000); int digit; chr = buf; digit = (int) (val / divisor); mhd_assert (digit < 10); /* Do not print leading zeros */ while ((0 == digit) && (1 < divisor)) { divisor /= 10; digit = (int) (val / divisor); mhd_assert (digit < 10); } while (0 != buf_size) { *chr = (char) ((char) digit + '0'); chr++; buf_size--; if (1 == divisor) return (size_t) (chr - buf); val = (uint16_t) (val % divisor); divisor /= 10; digit = (int) (val / divisor); mhd_assert (digit < 10); } return 0; /* The buffer is too small */ } #endif /* !MHD_FAVOR_SMALL_CODE */ size_t MHD_uint64_to_str (uint64_t val, char *buf, size_t buf_size) { char *chr; /**< pointer to the current printed digit */ /* The biggest printable number is 18446744073709551615 */ uint64_t divisor = UINT64_C (10000000000000000000); int digit; chr = buf; digit = (int) (val / divisor); mhd_assert (digit < 10); /* Do not print leading zeros */ while ((0 == digit) && (1 < divisor)) { divisor /= 10; digit = (int) (val / divisor); mhd_assert (digit < 10); } while (0 != buf_size) { *chr = (char) ((char) digit + '0'); chr++; buf_size--; if (1 == divisor) return (size_t) (chr - buf); val %= divisor; divisor /= 10; digit = (int) (val / divisor); mhd_assert (digit < 10); } return 0; /* The buffer is too small */ } size_t MHD_uint8_to_str_pad (uint8_t val, uint8_t min_digits, char *buf, size_t buf_size) { size_t pos; /**< the position of the current printed digit */ int digit; mhd_assert (3 >= min_digits); if (0 == buf_size) return 0; pos = 0; digit = val / 100; if (0 == digit) { if (3 <= min_digits) buf[pos++] = '0'; } else { buf[pos++] = (char) ('0' + (char) digit); val %= 100; min_digits = 2; } if (buf_size <= pos) return 0; digit = val / 10; if (0 == digit) { if (2 <= min_digits) buf[pos++] = '0'; } else { buf[pos++] = (char) ('0' + (char) digit); val %= 10; } if (buf_size <= pos) return 0; buf[pos++] = (char) ('0' + (char) val); return pos; } size_t MHD_bin_to_hex (const void *bin, size_t size, char *hex) { size_t i; for (i = 0; i < size; ++i) { uint8_t j; const uint8_t b = ((const uint8_t *) bin)[i]; j = b >> 4; hex[i * 2] = (char) ((j < 10) ? (j + '0') : (j - 10 + 'a')); j = b & 0x0f; hex[i * 2 + 1] = (char) ((j < 10) ? (j + '0') : (j - 10 + 'a')); } return i * 2; } size_t MHD_bin_to_hex_z (const void *bin, size_t size, char *hex) { size_t res; res = MHD_bin_to_hex (bin, size, hex); hex[res] = 0; return res; } size_t MHD_hex_to_bin (const char *hex, size_t len, void *bin) { uint8_t *const out = (uint8_t *) bin; size_t r; size_t w; if (0 == len) return 0; r = 0; w = 0; if (0 != len % 2) { /* Assume the first byte is encoded with single digit */ const int l = toxdigitvalue (hex[r++]); if (0 > l) return 0; out[w++] = (uint8_t) ((unsigned int) l); } while (r < len) { const int h = toxdigitvalue (hex[r++]); const int l = toxdigitvalue (hex[r++]); if ((0 > h) || (0 > l)) return 0; out[w++] = (uint8_t) ( ((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) | ((uint8_t) ((unsigned int) l)) ); } mhd_assert (len == r); mhd_assert ((len + 1) / 2 == w); return w; } size_t MHD_str_pct_decode_strict_n_ (const char *pct_encoded, size_t pct_encoded_len, char *decoded, size_t buf_size) { #ifdef MHD_FAVOR_SMALL_CODE bool broken; size_t res; res = MHD_str_pct_decode_lenient_n_ (pct_encoded, pct_encoded_len, decoded, buf_size, &broken); if (broken) return 0; return res; #else /* ! MHD_FAVOR_SMALL_CODE */ size_t r; size_t w; r = 0; w = 0; if (buf_size >= pct_encoded_len) { while (r < pct_encoded_len) { const char chr = pct_encoded[r]; if ('%' == chr) { if (2 > pct_encoded_len - r) return 0; else { const int h = toxdigitvalue (pct_encoded[++r]); const int l = toxdigitvalue (pct_encoded[++r]); unsigned char out; if ((0 > h) || (0 > l)) return 0; out = (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) | ((uint8_t) ((unsigned int) l))); decoded[w] = (char) out; } } else decoded[w] = chr; ++r; ++w; } return w; } while (r < pct_encoded_len) { const char chr = pct_encoded[r]; if (w >= buf_size) return 0; if ('%' == chr) { if (2 > pct_encoded_len - r) return 0; else { const int h = toxdigitvalue (pct_encoded[++r]); const int l = toxdigitvalue (pct_encoded[++r]); unsigned char out; if ((0 > h) || (0 > l)) return 0; out = (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) | ((uint8_t) ((unsigned int) l))); decoded[w] = (char) out; } } else decoded[w] = chr; ++r; ++w; } return w; #endif /* ! MHD_FAVOR_SMALL_CODE */ } size_t MHD_str_pct_decode_lenient_n_ (const char *pct_encoded, size_t pct_encoded_len, char *decoded, size_t buf_size, bool *broken_encoding) { size_t r; size_t w; r = 0; w = 0; if (NULL != broken_encoding) *broken_encoding = false; #ifndef MHD_FAVOR_SMALL_CODE if (buf_size >= pct_encoded_len) { while (r < pct_encoded_len) { const char chr = pct_encoded[r]; if ('%' == chr) { if (2 > pct_encoded_len - r) { if (NULL != broken_encoding) *broken_encoding = true; decoded[w] = chr; /* Copy "as is" */ } else { const int h = toxdigitvalue (pct_encoded[++r]); const int l = toxdigitvalue (pct_encoded[++r]); unsigned char out; if ((0 > h) || (0 > l)) { r -= 2; if (NULL != broken_encoding) *broken_encoding = true; decoded[w] = chr; /* Copy "as is" */ } else { out = (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) | ((uint8_t) ((unsigned int) l))); decoded[w] = (char) out; } } } else decoded[w] = chr; ++r; ++w; } return w; } #endif /* ! MHD_FAVOR_SMALL_CODE */ while (r < pct_encoded_len) { const char chr = pct_encoded[r]; if (w >= buf_size) return 0; if ('%' == chr) { if (2 > pct_encoded_len - r) { if (NULL != broken_encoding) *broken_encoding = true; decoded[w] = chr; /* Copy "as is" */ } else { const int h = toxdigitvalue (pct_encoded[++r]); const int l = toxdigitvalue (pct_encoded[++r]); if ((0 > h) || (0 > l)) { r -= 2; if (NULL != broken_encoding) *broken_encoding = true; decoded[w] = chr; /* Copy "as is" */ } else { unsigned char out; out = (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) | ((uint8_t) ((unsigned int) l))); decoded[w] = (char) out; } } } else decoded[w] = chr; ++r; ++w; } return w; } size_t MHD_str_pct_decode_in_place_strict_ (char *str) { #ifdef MHD_FAVOR_SMALL_CODE size_t res; bool broken; res = MHD_str_pct_decode_in_place_lenient_ (str, &broken); if (broken) { res = 0; str[0] = 0; } return res; #else /* ! MHD_FAVOR_SMALL_CODE */ size_t r; size_t w; r = 0; w = 0; while (0 != str[r]) { const char chr = str[r++]; if ('%' == chr) { const char d1 = str[r++]; if (0 == d1) return 0; else { const char d2 = str[r++]; if (0 == d2) return 0; else { const int h = toxdigitvalue (d1); const int l = toxdigitvalue (d2); unsigned char out; if ((0 > h) || (0 > l)) return 0; out = (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) | ((uint8_t) ((unsigned int) l))); str[w++] = (char) out; } } } else str[w++] = chr; } str[w] = 0; return w; #endif /* ! MHD_FAVOR_SMALL_CODE */ } size_t MHD_str_pct_decode_in_place_lenient_ (char *str, bool *broken_encoding) { #ifdef MHD_FAVOR_SMALL_CODE size_t len; size_t res; len = strlen (str); res = MHD_str_pct_decode_lenient_n_ (str, len, str, len, broken_encoding); str[res] = 0; return res; #else /* ! MHD_FAVOR_SMALL_CODE */ size_t r; size_t w; if (NULL != broken_encoding) *broken_encoding = false; r = 0; w = 0; while (0 != str[r]) { const char chr = str[r++]; if ('%' == chr) { const char d1 = str[r++]; if (0 == d1) { if (NULL != broken_encoding) *broken_encoding = true; str[w++] = chr; /* Copy "as is" */ str[w] = 0; return w; } else { const char d2 = str[r++]; if (0 == d2) { if (NULL != broken_encoding) *broken_encoding = true; str[w++] = chr; /* Copy "as is" */ str[w++] = d1; /* Copy "as is" */ str[w] = 0; return w; } else { const int h = toxdigitvalue (d1); const int l = toxdigitvalue (d2); unsigned char out; if ((0 > h) || (0 > l)) { if (NULL != broken_encoding) *broken_encoding = true; str[w++] = chr; /* Copy "as is" */ str[w++] = d1; str[w++] = d2; continue; } out = (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4)) | ((uint8_t) ((unsigned int) l))); str[w++] = (char) out; continue; } } } str[w++] = chr; } str[w] = 0; return w; #endif /* ! MHD_FAVOR_SMALL_CODE */ } #ifdef DAUTH_SUPPORT bool MHD_str_equal_quoted_bin_n (const char *quoted, size_t quoted_len, const char *unquoted, size_t unquoted_len) { size_t i; size_t j; if (unquoted_len < quoted_len / 2) return false; j = 0; for (i = 0; quoted_len > i && unquoted_len > j; ++i, ++j) { if ('\\' == quoted[i]) { i++; /* Advance to the next character */ if (quoted_len == i) return false; /* No character after escaping backslash */ } if (quoted[i] != unquoted[j]) return false; /* Different characters */ } if ((quoted_len != i) || (unquoted_len != j)) return false; /* The strings have different length */ return true; } bool MHD_str_equal_caseless_quoted_bin_n (const char *quoted, size_t quoted_len, const char *unquoted, size_t unquoted_len) { size_t i; size_t j; if (unquoted_len < quoted_len / 2) return false; j = 0; for (i = 0; quoted_len > i && unquoted_len > j; ++i, ++j) { if ('\\' == quoted[i]) { i++; /* Advance to the next character */ if (quoted_len == i) return false; /* No character after escaping backslash */ } if (! charsequalcaseless (quoted[i], unquoted[j])) return false; /* Different characters */ } if ((quoted_len != i) || (unquoted_len != j)) return false; /* The strings have different length */ return true; } size_t MHD_str_unquote (const char *quoted, size_t quoted_len, char *result) { size_t r; size_t w; r = 0; w = 0; while (quoted_len > r) { if ('\\' == quoted[r]) { ++r; if (quoted_len == r) return 0; /* Last backslash is not followed by char to unescape */ } result[w++] = quoted[r++]; } return w; } #endif /* DAUTH_SUPPORT */ #if defined(DAUTH_SUPPORT) || defined(BAUTH_SUPPORT) size_t MHD_str_quote (const char *unquoted, size_t unquoted_len, char *result, size_t buf_size) { size_t r; size_t w; r = 0; w = 0; #ifndef MHD_FAVOR_SMALL_CODE if (unquoted_len * 2 <= buf_size) { /* Fast loop: the output will fit the buffer with any input string content */ while (unquoted_len > r) { const char chr = unquoted[r++]; if (('\\' == chr) || ('\"' == chr)) result[w++] = '\\'; /* Escape current char */ result[w++] = chr; } } else { if (unquoted_len > buf_size) return 0; /* Quick fail: the output buffer is too small */ #else /* MHD_FAVOR_SMALL_CODE */ if (1) { #endif /* MHD_FAVOR_SMALL_CODE */ while (unquoted_len > r) { if (buf_size <= w) return 0; /* The output buffer is too small */ else { const char chr = unquoted[r++]; if (('\\' == chr) || ('\"' == chr)) { result[w++] = '\\'; /* Escape current char */ if (buf_size <= w) return 0; /* The output buffer is too small */ } result[w++] = chr; } } } mhd_assert (w >= r); mhd_assert (w <= r * 2); return w; } #endif /* DAUTH_SUPPORT || BAUTH_SUPPORT */ #ifdef BAUTH_SUPPORT /* * MHD_BASE64_FUNC_VERSION * 1 = smallest, * 2 = medium, * 3 = fastest */ #ifndef MHD_BASE64_FUNC_VERSION #ifdef MHD_FAVOR_SMALL_CODE #define MHD_BASE64_FUNC_VERSION 1 #else /* ! MHD_FAVOR_SMALL_CODE */ #define MHD_BASE64_FUNC_VERSION 3 #endif /* ! MHD_FAVOR_SMALL_CODE */ #endif /* ! MHD_BASE64_FUNC_VERSION */ #if MHD_BASE64_FUNC_VERSION < 1 || MHD_BASE64_FUNC_VERSION > 3 #error Wrong MHD_BASE64_FUNC_VERSION value #endif /* MHD_BASE64_FUNC_VERSION < 1 || MHD_BASE64_FUNC_VERSION > 3 */ #if MHD_BASE64_FUNC_VERSION == 3 #define MHD_base64_map_type_ int #else /* MHD_BASE64_FUNC_VERSION < 3 */ #define MHD_base64_map_type_ int8_t #endif /* MHD_BASE64_FUNC_VERSION < 3 */ #if MHD_BASE64_FUNC_VERSION == 1 static MHD_base64_map_type_ base64_char_to_value_ (uint8_t c) { if ('Z' >= c) { if ('A' <= c) return (MHD_base64_map_type_) ((c - 'A') + 0); if ('0' <= c) { if ('9' >= c) return (MHD_base64_map_type_) ((c - '0') + 52); if ('=' == c) return -2; return -1; } if ('+' == c) return 62; if ('/' == c) return 63; return -1; } if (('z' >= c) && ('a' <= c)) return (MHD_base64_map_type_) ((c - 'a') + 26); return -1; } #endif /* MHD_BASE64_FUNC_VERSION == 1 */ MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ size_t MHD_base64_to_bin_n (const char *base64, size_t base64_len, void *bin, size_t bin_size) { #if MHD_BASE64_FUNC_VERSION >= 2 static const MHD_base64_map_type_ map[] = { /* -1 = invalid char, -2 = padding 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, BS, HT, LF, VT, FF, CR, SO, SI, */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, CAN, EM, SUB, ESC, FS, GS, RS, US, */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, ' ', '!', '"', '#', '$', '%', '&', '\'', */ -1, -1, -1, -1, -1, -1, -1, -1, /* 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, '(', ')', '*', '+', ',', '-', '.', '/', */ -1, -1, -1, 62, -1, -1, -1, 63, /* 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, '0', '1', '2', '3', '4', '5', '6', '7', */ 52, 53, 54, 55, 56, 57, 58, 59, /* 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, '8', '9', ':', ';', '<', '=', '>', '?', */ 60, 61, -1, -1, -1, -2, -1, -1, /* 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', */ -1, 0, 1, 2, 3, 4, 5, 6, /* 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', */ 7, 8, 9, 10, 11, 12, 13, 14, /* 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', */ 15, 16, 17, 18, 19, 20, 21, 22, /* 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 'X', 'Y', 'Z', '[', '\', ']', '^', '_', */ 23, 24, 25, -1, -1, -1, -1, -1, /* 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', */ -1, 26, 27, 28, 29, 30, 31, 32, /* 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', */ 33, 34, 35, 36, 37, 38, 39, 40, /* 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', */ 41, 42, 43, 44, 45, 46, 47, 48, /* 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 'x', 'y', 'z', '{', '|', '}', '~', DEL, */ 49, 50, 51, -1, -1, -1, -1, -1 #if MHD_BASE64_FUNC_VERSION == 3 , -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 80..8F */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 90..9F */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* A0..AF */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* B0..BF */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* C0..CF */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* D0..DF */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* E0..EF */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* F0..FF */ #endif /* ! MHD_BASE64_FUNC_VERSION == 3 */ }; #define base64_char_to_value_(c) map[(c)] #endif /* MHD_BASE64_FUNC_VERSION >= 2 */ const uint8_t *const in = (const uint8_t *) base64; uint8_t *const out = (uint8_t *) bin; size_t i; size_t j; if (0 == base64_len) return 0; /* Nothing to decode */ if (0 != base64_len % 4) return 0; /* Wrong input length */ if (base64_len / 4 * 3 - 2 > bin_size) return 0; j = 0; for (i = 0; i < (base64_len - 4); i += 4) { #if MHD_BASE64_FUNC_VERSION == 2 if (0 != (0x80 & (in[i] | in[i + 1] | in[i + 2] | in[i + 3]))) return 0; #endif /* MHD_BASE64_FUNC_VERSION == 2 */ if (1) { const MHD_base64_map_type_ v1 = base64_char_to_value_ (in[i + 0]); const MHD_base64_map_type_ v2 = base64_char_to_value_ (in[i + 1]); const MHD_base64_map_type_ v3 = base64_char_to_value_ (in[i + 2]); const MHD_base64_map_type_ v4 = base64_char_to_value_ (in[i + 3]); if ((0 > v1) || (0 > v2) || (0 > v3) || (0 > v4)) return 0; out[j + 0] = (uint8_t) (((uint8_t) (((uint8_t) v1) << 2)) | ((uint8_t) (((uint8_t) v2) >> 4))); out[j + 1] = (uint8_t) (((uint8_t) (((uint8_t) v2) << 4)) | ((uint8_t) (((uint8_t) v3) >> 2))); out[j + 2] = (uint8_t) (((uint8_t) (((uint8_t) v3) << 6)) | ((uint8_t) v4)); } j += 3; } #if MHD_BASE64_FUNC_VERSION == 2 if (0 != (0x80 & (in[i] | in[i + 1] | in[i + 2] | in[i + 3]))) return 0; #endif /* MHD_BASE64_FUNC_VERSION == 2 */ if (1) { /* The last four chars block */ const MHD_base64_map_type_ v1 = base64_char_to_value_ (in[i + 0]); const MHD_base64_map_type_ v2 = base64_char_to_value_ (in[i + 1]); const MHD_base64_map_type_ v3 = base64_char_to_value_ (in[i + 2]); const MHD_base64_map_type_ v4 = base64_char_to_value_ (in[i + 3]); if ((0 > v1) || (0 > v2)) return 0; /* Invalid char or padding at first two positions */ mhd_assert (j < bin_size); out[j++] = (uint8_t) (((uint8_t) (((uint8_t) v1) << 2)) | ((uint8_t) (((uint8_t) v2) >> 4))); if (0 > v3) { /* Third char is either padding or invalid */ if ((-2 != v3) || (-2 != v4)) return 0; /* Both two last chars must be padding */ if (0 != (uint8_t) (((uint8_t) v2) << 4)) return 0; /* Wrong last char */ return j; } if (j >= bin_size) return 0; /* Not enough space */ out[j++] = (uint8_t) (((uint8_t) (((uint8_t) v2) << 4)) | ((uint8_t) (((uint8_t) v3) >> 2))); if (0 > v4) { /* Fourth char is either padding or invalid */ if (-2 != v4) return 0; /* The char must be padding */ if (0 != (uint8_t) (((uint8_t) v3) << 6)) return 0; /* Wrong last char */ return j; } if (j >= bin_size) return 0; /* Not enough space */ out[j++] = (uint8_t) (((uint8_t) (((uint8_t) v3) << 6)) | ((uint8_t) v4)); } return j; #if MHD_BASE64_FUNC_VERSION >= 2 #undef base64_char_to_value_ #endif /* MHD_BASE64_FUNC_VERSION >= 2 */ } MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ #undef MHD_base64_map_type_ #endif /* BAUTH_SUPPORT */ libmicrohttpd-1.0.1/src/microhttpd/response.h0000644000175000017500000001066614441373361015030 /* This file is part of libmicrohttpd Copyright (C) 2007 Daniel Pittman and Christian Grothoff Copyright (C) 2015-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file response.h * @brief Methods for managing response objects * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #ifndef RESPONSE_H #define RESPONSE_H /** * Increments the reference counter for the @a response. * * @param response object to modify */ void MHD_increment_response_rc (struct MHD_Response *response); /** * We are done sending the header of a given response * to the client. Now it is time to perform the upgrade * and hand over the connection to the application. * @remark To be called only from thread that process connection's * recv(), send() and response. Must be called right after sending * response headers. * * @param response the response that was created for an upgrade * @param connection the specific connection we are upgrading * @return #MHD_YES on success, #MHD_NO on failure (will cause * connection to be closed) */ enum MHD_Result MHD_response_execute_upgrade_ (struct MHD_Response *response, struct MHD_Connection *connection); /** * Get a particular header (or footer) element from the response. * * Function returns the first found element. * @param response response to query * @param kind the kind of element: header or footer * @param key the key which header to get * @param key_len the length of the @a key * @return NULL if header element does not exist * @ingroup response */ struct MHD_HTTP_Res_Header * MHD_get_response_element_n_ (struct MHD_Response *response, enum MHD_ValueKind kind, const char *key, size_t key_len); /** * Add a header or footer line to the response without checking. * * It is assumed that parameters are correct. * * @param response response to add a header to * @param kind header or footer * @param header the header to add, does not need to be zero-terminated * @param header_len the length of the @a header * @param content value to add, does not need to be zero-terminated * @param content_len the length of the @a content * @return false on error (like out-of-memory), * true if succeed */ bool MHD_add_response_entry_no_check_ (struct MHD_Response *response, enum MHD_ValueKind kind, const char *header, size_t header_len, const char *content, size_t content_len); /** * Add preallocated strings a header or footer line to the response without * checking. * * Header/footer strings are not checked and assumed to be correct. * * The string must not be statically allocated! * The strings must be malloc()'ed and zero terminated. The strings will * be free()'ed when the response is destroyed. * * @param response response to add a header to * @param kind header or footer * @param header the header string to add, must be malloc()'ed and * zero-terminated * @param header_len the length of the @a header * @param content the value string to add, must be malloc()'ed and * zero-terminated * @param content_len the length of the @a content */ bool MHD_add_response_entry_no_alloc_ (struct MHD_Response *response, enum MHD_ValueKind kind, char *header, size_t header_len, char *content, size_t content_len); #endif libmicrohttpd-1.0.1/src/microhttpd/daemon.c0000644000175000017500000116411214566122702014424 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff Copyright (C) 2015-2024 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/daemon.c * @brief A minimal-HTTP server library * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) #include "mhd_threads.h" #endif #include "internal.h" #include "response.h" #include "connection.h" #include "memorypool.h" #include "mhd_limits.h" #include "autoinit_funcs.h" #include "mhd_mono_clock.h" #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) #include "mhd_locks.h" #endif #include "mhd_sockets.h" #include "mhd_itc.h" #include "mhd_compat.h" #include "mhd_send.h" #include "mhd_align.h" #include "mhd_str.h" #ifdef MHD_USE_SYS_TSEARCH #include #else /* ! MHD_USE_SYS_TSEARCH */ #include "tsearch.h" #endif /* ! MHD_USE_SYS_TSEARCH */ #ifdef HTTPS_SUPPORT #include "connection_https.h" #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ #endif /* HTTPS_SUPPORT */ #if defined(_WIN32) && ! defined(__CYGWIN__) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #ifdef MHD_USE_POSIX_THREADS #ifdef HAVE_SIGNAL_H #include #endif /* HAVE_SIGNAL_H */ #endif /* MHD_USE_POSIX_THREADS */ /** * Default connection limit. */ #ifdef MHD_POSIX_SOCKETS #define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 3 - 1 - MHD_ITC_NUM_FDS_) #else #define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 2) #endif /** * Default memory allowed per connection. */ #define MHD_POOL_SIZE_DEFAULT (32 * 1024) /* Forward declarations. */ /** * Global initialisation function. */ void MHD_init (void); /** * Global deinitialisation function. */ void MHD_fini (void); /** * Close all connections for the daemon. * Must only be called when MHD_Daemon::shutdown was set to true. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon daemon to close down */ static void close_all_connections (struct MHD_Daemon *daemon); #ifdef EPOLL_SUPPORT /** * Do epoll()-based processing. * * @param daemon daemon to run poll loop for * @param millisec the maximum time in milliseconds to wait for events, * set to '0' for non-blocking processing, * set to '-1' to wait indefinitely. * @return #MHD_NO on serious errors, #MHD_YES on success */ static enum MHD_Result MHD_epoll (struct MHD_Daemon *daemon, int32_t millisec); #endif /* EPOLL_SUPPORT */ #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED /** * Do nothing - global initialisation is * performed by library constructor. */ #define MHD_check_global_init_() (void) 0 #else /* ! _AUTOINIT_FUNCS_ARE_SUPPORTED */ /** * Track global initialisation */ volatile int global_init_count = 0; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) #ifdef MHD_MUTEX_STATIC_DEFN_INIT_ /** * Global initialisation mutex */ MHD_MUTEX_STATIC_DEFN_INIT_ (global_init_mutex_); #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ #endif /** * Check whether global initialisation was performed * and call initialiser if necessary. */ void MHD_check_global_init_ (void) { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) #ifdef MHD_MUTEX_STATIC_DEFN_INIT_ MHD_mutex_lock_chk_ (&global_init_mutex_); #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ #endif if (0 == global_init_count++) MHD_init (); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) #ifdef MHD_MUTEX_STATIC_DEFN_INIT_ MHD_mutex_unlock_chk_ (&global_init_mutex_); #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ #endif } #endif /* ! _AUTOINIT_FUNCS_ARE_SUPPORTED */ #ifdef HAVE_MESSAGES /** * Default logger function */ static void MHD_default_logger_ (void *cls, const char *fm, va_list ap) { vfprintf ((FILE *) cls, fm, ap); #ifdef _DEBUG fflush ((FILE *) cls); #endif /* _DEBUG */ } #endif /* HAVE_MESSAGES */ /** * Free the memory allocated by MHD. * * If any MHD function explicitly mentions that returned pointer must be * freed by this function, then no other method must be used to free * the memory. * * @param ptr the pointer to free. * @sa #MHD_digest_auth_get_username(), #MHD_basic_auth_get_username_password3() * @sa #MHD_basic_auth_get_username_password() * @note Available since #MHD_VERSION 0x00095600 * @ingroup specialized */ _MHD_EXTERN void MHD_free (void *ptr) { free (ptr); } /** * Maintain connection count for single address. */ struct MHD_IPCount { /** * Address family. AF_INET or AF_INET6 for now. */ int family; /** * Actual address. */ union { /** * IPv4 address. */ struct in_addr ipv4; #ifdef HAVE_INET6 /** * IPv6 address. */ struct in6_addr ipv6; #endif } addr; /** * Counter. */ unsigned int count; }; /** * Lock shared structure for IP connection counts and connection DLLs. * * @param daemon handle to daemon where lock is */ static void MHD_ip_count_lock (struct MHD_Daemon *daemon) { mhd_assert (NULL == daemon->master); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&daemon->per_ip_connection_mutex); #else (void) daemon; #endif } /** * Unlock shared structure for IP connection counts and connection DLLs. * * @param daemon handle to daemon where lock is */ static void MHD_ip_count_unlock (struct MHD_Daemon *daemon) { mhd_assert (NULL == daemon->master); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->per_ip_connection_mutex); #else (void) daemon; #endif } /** * Tree comparison function for IP addresses (supplied to tsearch() family). * We compare everything in the struct up through the beginning of the * 'count' field. * * @param a1 first address to compare * @param a2 second address to compare * @return -1, 0 or 1 depending on result of compare */ static int MHD_ip_addr_compare (const void *a1, const void *a2) { return memcmp (a1, a2, offsetof (struct MHD_IPCount, count)); } /** * Parse address and initialize @a key using the address. * * @param addr address to parse * @param addrlen number of bytes in @a addr * @param key where to store the parsed address * @return #MHD_YES on success and #MHD_NO otherwise (e.g., invalid address type) */ static enum MHD_Result MHD_ip_addr_to_key (const struct sockaddr_storage *addr, socklen_t addrlen, struct MHD_IPCount *key) { memset (key, 0, sizeof(*key)); /* IPv4 addresses */ if (sizeof (struct sockaddr_in) <= (size_t) addrlen) { if (AF_INET == addr->ss_family) { key->family = AF_INET; memcpy (&key->addr.ipv4, &((const struct sockaddr_in *) addr)->sin_addr, sizeof(((const struct sockaddr_in *) NULL)->sin_addr)); return MHD_YES; } } #ifdef HAVE_INET6 if (sizeof (struct sockaddr_in6) <= (size_t) addrlen) { /* IPv6 addresses */ if (AF_INET6 == addr->ss_family) { key->family = AF_INET6; memcpy (&key->addr.ipv6, &((const struct sockaddr_in6 *) addr)->sin6_addr, sizeof(((const struct sockaddr_in6 *) NULL)->sin6_addr)); return MHD_YES; } } #endif /* Some other address */ return MHD_NO; } /** * Check if IP address is over its limit in terms of the number * of allowed concurrent connections. If the IP is still allowed, * increments the connection counter. * * @param daemon handle to daemon where connection counts are tracked * @param addr address to add (or increment counter) * @param addrlen number of bytes in @a addr * @return Return #MHD_YES if IP below limit, #MHD_NO if IP has surpassed limit. * Also returns #MHD_NO if fails to allocate memory. */ static enum MHD_Result MHD_ip_limit_add (struct MHD_Daemon *daemon, const struct sockaddr_storage *addr, socklen_t addrlen) { struct MHD_IPCount *newkeyp; struct MHD_IPCount *keyp; struct MHD_IPCount **nodep; enum MHD_Result result; daemon = MHD_get_master (daemon); /* Ignore if no connection limit assigned */ if (0 == daemon->per_ip_connection_limit) return MHD_YES; newkeyp = (struct MHD_IPCount *) malloc (sizeof(struct MHD_IPCount)); if (NULL == newkeyp) return MHD_NO; /* Initialize key */ if (MHD_NO == MHD_ip_addr_to_key (addr, addrlen, newkeyp)) { free (newkeyp); return MHD_YES; /* Allow unhandled address types through */ } MHD_ip_count_lock (daemon); /* Search for the IP address */ nodep = (struct MHD_IPCount **) tsearch (newkeyp, &daemon->per_ip_connection_count, &MHD_ip_addr_compare); if (NULL == nodep) { MHD_ip_count_unlock (daemon); free (newkeyp); #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to add IP connection count node.\n")); #endif return MHD_NO; } keyp = *nodep; /* Test if there is room for another connection; if so, * increment count */ result = (keyp->count < daemon->per_ip_connection_limit) ? MHD_YES : MHD_NO; if (MHD_NO != result) ++keyp->count; MHD_ip_count_unlock (daemon); /* If we got an existing node back, free the one we created */ if (keyp != newkeyp) free (newkeyp); return result; } /** * Decrement connection count for IP address, removing from table * count reaches 0. * * @param daemon handle to daemon where connection counts are tracked * @param addr address to remove (or decrement counter) * @param addrlen number of bytes in @a addr */ static void MHD_ip_limit_del (struct MHD_Daemon *daemon, const struct sockaddr_storage *addr, socklen_t addrlen) { struct MHD_IPCount search_key; struct MHD_IPCount *found_key; void **nodep; daemon = MHD_get_master (daemon); /* Ignore if no connection limit assigned */ if (0 == daemon->per_ip_connection_limit) return; /* Initialize search key */ if (MHD_NO == MHD_ip_addr_to_key (addr, addrlen, &search_key)) return; MHD_ip_count_lock (daemon); /* Search for the IP address */ if (NULL == (nodep = tfind (&search_key, &daemon->per_ip_connection_count, &MHD_ip_addr_compare))) { /* Something's wrong if we couldn't find an IP address * that was previously added */ MHD_PANIC (_ ("Failed to find previously-added IP address.\n")); } found_key = (struct MHD_IPCount *) *nodep; /* Validate existing count for IP address */ if (0 == found_key->count) { MHD_PANIC (_ ("Previously-added IP address had counter of zero.\n")); } /* Remove the node entirely if count reduces to 0 */ if (0 == --found_key->count) { tdelete (found_key, &daemon->per_ip_connection_count, &MHD_ip_addr_compare); MHD_ip_count_unlock (daemon); free (found_key); } else MHD_ip_count_unlock (daemon); } #ifdef HTTPS_SUPPORT /** * Read and setup our certificate and key. * * @param daemon handle to daemon to initialize * @return 0 on success */ static int MHD_init_daemon_certificate (struct MHD_Daemon *daemon) { gnutls_datum_t key; gnutls_datum_t cert; int ret; #if GNUTLS_VERSION_MAJOR >= 3 if (NULL != daemon->cert_callback) { gnutls_certificate_set_retrieve_function2 (daemon->x509_cred, daemon->cert_callback); } #endif #if GNUTLS_VERSION_NUMBER >= 0x030603 else if (NULL != daemon->cert_callback2) { gnutls_certificate_set_retrieve_function3 (daemon->x509_cred, daemon->cert_callback2); } #endif if (NULL != daemon->https_mem_trust) { size_t paramlen; paramlen = strlen (daemon->https_mem_trust); if (UINT_MAX < paramlen) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Too long trust certificate.\n")); #endif return -1; } cert.data = (unsigned char *) _MHD_DROP_CONST (daemon->https_mem_trust); cert.size = (unsigned int) paramlen; if (gnutls_certificate_set_x509_trust_mem (daemon->x509_cred, &cert, GNUTLS_X509_FMT_PEM) < 0) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Bad trust certificate format.\n")); #endif return -1; } } if (daemon->have_dhparams) { gnutls_certificate_set_dh_params (daemon->x509_cred, daemon->https_mem_dhparams); } /* certificate & key loaded from memory */ if ( (NULL != daemon->https_mem_cert) && (NULL != daemon->https_mem_key) ) { size_t param1len; size_t param2len; param1len = strlen (daemon->https_mem_key); param2len = strlen (daemon->https_mem_cert); if ( (UINT_MAX < param1len) || (UINT_MAX < param2len) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Too long key or certificate.\n")); #endif return -1; } key.data = (unsigned char *) _MHD_DROP_CONST (daemon->https_mem_key); key.size = (unsigned int) param1len; cert.data = (unsigned char *) _MHD_DROP_CONST (daemon->https_mem_cert); cert.size = (unsigned int) param2len; if (NULL != daemon->https_key_password) { #if GNUTLS_VERSION_NUMBER >= 0x030111 ret = gnutls_certificate_set_x509_key_mem2 (daemon->x509_cred, &cert, &key, GNUTLS_X509_FMT_PEM, daemon->https_key_password, 0); #else #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to setup x509 certificate/key: pre 3.X.X version " \ "of GnuTLS does not support setting key password.\n")); #endif return -1; #endif } else ret = gnutls_certificate_set_x509_key_mem (daemon->x509_cred, &cert, &key, GNUTLS_X509_FMT_PEM); #ifdef HAVE_MESSAGES if (0 != ret) MHD_DLOG (daemon, _ ("GnuTLS failed to setup x509 certificate/key: %s\n"), gnutls_strerror (ret)); #endif return ret; } #if GNUTLS_VERSION_MAJOR >= 3 if (NULL != daemon->cert_callback) return 0; #endif #if GNUTLS_VERSION_NUMBER >= 0x030603 else if (NULL != daemon->cert_callback2) return 0; #endif #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("You need to specify a certificate and key location.\n")); #endif return -1; } /** * Initialize security aspects of the HTTPS daemon * * @param daemon handle to daemon to initialize * @return 0 on success */ static int MHD_TLS_init (struct MHD_Daemon *daemon) { switch (daemon->cred_type) { case GNUTLS_CRD_CERTIFICATE: if (0 != gnutls_certificate_allocate_credentials (&daemon->x509_cred)) return GNUTLS_E_MEMORY_ERROR; return MHD_init_daemon_certificate (daemon); case GNUTLS_CRD_PSK: if (0 != gnutls_psk_allocate_server_credentials (&daemon->psk_cred)) return GNUTLS_E_MEMORY_ERROR; return 0; case GNUTLS_CRD_ANON: case GNUTLS_CRD_SRP: case GNUTLS_CRD_IA: default: #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Error: invalid credentials type %d specified.\n"), daemon->cred_type); #endif return -1; } } #endif /* HTTPS_SUPPORT */ #undef MHD_get_fdset /** * Obtain the `select()` sets for this daemon. * Daemon's FDs will be added to fd_sets. To get only * daemon FDs in fd_sets, call FD_ZERO for each fd_set * before calling this function. FD_SETSIZE is assumed * to be platform's default. * * This function should be called only when MHD is configured to * use "external" sockets polling with 'select()' or with 'epoll'. * In the latter case, it will only add the single 'epoll' file * descriptor used by MHD to the sets. * It's necessary to use #MHD_get_timeout() to get maximum timeout * value for `select()`. Usage of `select()` with indefinite timeout * (or timeout larger than returned by #MHD_get_timeout()) will * violate MHD API and may results in pending unprocessed data. * * This function must be called only for daemon started * without #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @return #MHD_YES on success, #MHD_NO if this * daemon was not started with the right * options for this call or any FD didn't * fit fd_set. * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_get_fdset (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd) { return MHD_get_fdset2 (daemon, read_fd_set, write_fd_set, except_fd_set, max_fd, #ifdef HAS_FD_SETSIZE_OVERRIDABLE daemon->fdset_size_set_by_app ? ((unsigned int) daemon->fdset_size) : ((unsigned int) _MHD_SYS_DEFAULT_FD_SETSIZE) #else /* ! HAS_FD_SETSIZE_OVERRIDABLE */ ((unsigned int) _MHD_SYS_DEFAULT_FD_SETSIZE) #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ ); } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Obtain the select() file descriptor sets for the * given @a urh. * * @param urh upgrade handle to wait for * @param[out] rs read set to initialize * @param[out] ws write set to initialize * @param[out] es except set to initialize * @param[out] max_fd maximum FD to update * @param fd_setsize value of FD_SETSIZE * @return true on success, false on error */ static bool urh_to_fdset (struct MHD_UpgradeResponseHandle *urh, fd_set *rs, fd_set *ws, fd_set *es, MHD_socket *max_fd, int fd_setsize) { const MHD_socket conn_sckt = urh->connection->socket_fd; const MHD_socket mhd_sckt = urh->mhd.socket; bool res = true; #ifndef HAS_FD_SETSIZE_OVERRIDABLE (void) fd_setsize; /* Mute compiler warning */ fd_setsize = (int) FD_SETSIZE; /* Help compiler to optimise */ #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ /* Do not add to 'es' only if socket is closed * or not used anymore. */ if (MHD_INVALID_SOCKET != conn_sckt) { if ( (urh->in_buffer_used < urh->in_buffer_size) && (! MHD_add_to_fd_set_ (conn_sckt, rs, max_fd, fd_setsize)) ) res = false; if ( (0 != urh->out_buffer_used) && (! MHD_add_to_fd_set_ (conn_sckt, ws, max_fd, fd_setsize)) ) res = false; /* Do not monitor again for errors if error was detected before as * error state is remembered. */ if ((0 == (urh->app.celi & MHD_EPOLL_STATE_ERROR)) && ((0 != urh->in_buffer_size) || (0 != urh->out_buffer_size) || (0 != urh->out_buffer_used)) && (NULL != es)) (void) MHD_add_to_fd_set_ (conn_sckt, es, max_fd, fd_setsize); } if (MHD_INVALID_SOCKET != mhd_sckt) { if ( (urh->out_buffer_used < urh->out_buffer_size) && (! MHD_add_to_fd_set_ (mhd_sckt, rs, max_fd, fd_setsize)) ) res = false; if ( (0 != urh->in_buffer_used) && (! MHD_add_to_fd_set_ (mhd_sckt, ws, max_fd, fd_setsize)) ) res = false; /* Do not monitor again for errors if error was detected before as * error state is remembered. */ if ((0 == (urh->mhd.celi & MHD_EPOLL_STATE_ERROR)) && ((0 != urh->out_buffer_size) || (0 != urh->in_buffer_size) || (0 != urh->in_buffer_used)) && (NULL != es)) MHD_add_to_fd_set_ (mhd_sckt, es, max_fd, fd_setsize); } return res; } /** * Update the @a urh based on the ready FDs in * the @a rs, @a ws, and @a es. * * @param urh upgrade handle to update * @param rs read result from select() * @param ws write result from select() * @param es except result from select() * @param fd_setsize value of FD_SETSIZE used when fd_sets were created */ static void urh_from_fdset (struct MHD_UpgradeResponseHandle *urh, const fd_set *rs, const fd_set *ws, const fd_set *es, int fd_setsize) { const MHD_socket conn_sckt = urh->connection->socket_fd; const MHD_socket mhd_sckt = urh->mhd.socket; /* Reset read/write ready, preserve error state. */ urh->app.celi &= (~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY) & ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY)); urh->mhd.celi &= (~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY) & ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY)); mhd_assert (urh->connection->sk_nonblck); #ifndef HAS_FD_SETSIZE_OVERRIDABLE (void) fd_setsize; /* Mute compiler warning */ mhd_assert (((int) FD_SETSIZE) <= fd_setsize); fd_setsize = FD_SETSIZE; /* Help compiler to optimise */ #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ if (MHD_INVALID_SOCKET != conn_sckt) { if (MHD_SCKT_FD_FITS_FDSET_SETSIZE_ (conn_sckt, NULL, fd_setsize)) { if (FD_ISSET (conn_sckt, (fd_set *) _MHD_DROP_CONST (rs))) urh->app.celi |= MHD_EPOLL_STATE_READ_READY; if (FD_ISSET (conn_sckt, (fd_set *) _MHD_DROP_CONST (ws))) urh->app.celi |= MHD_EPOLL_STATE_WRITE_READY; if ((NULL != es) && FD_ISSET (conn_sckt, (fd_set *) _MHD_DROP_CONST (es))) urh->app.celi |= MHD_EPOLL_STATE_ERROR; } else { /* Cannot check readiness. Force ready state is safe as socket is non-blocking */ urh->app.celi |= MHD_EPOLL_STATE_READ_READY; urh->app.celi |= MHD_EPOLL_STATE_WRITE_READY; } } if ((MHD_INVALID_SOCKET != mhd_sckt)) { if (MHD_SCKT_FD_FITS_FDSET_SETSIZE_ (mhd_sckt, NULL, fd_setsize)) { if (FD_ISSET (mhd_sckt, (fd_set *) _MHD_DROP_CONST (rs))) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; if (FD_ISSET (mhd_sckt, (fd_set *) _MHD_DROP_CONST (ws))) urh->mhd.celi |= MHD_EPOLL_STATE_WRITE_READY; if ((NULL != es) && FD_ISSET (mhd_sckt, (fd_set *) _MHD_DROP_CONST (es))) urh->mhd.celi |= MHD_EPOLL_STATE_ERROR; } else { /* Cannot check readiness. Force ready state is safe as socket is non-blocking */ urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; urh->mhd.celi |= MHD_EPOLL_STATE_WRITE_READY; } } } #ifdef HAVE_POLL /** * Set required 'event' members in 'pollfd' elements, * assuming that @a p[0].fd is MHD side of socketpair * and @a p[1].fd is TLS connected socket. * * @param urh upgrade handle to watch for * @param p pollfd array to update */ static void urh_update_pollfd (struct MHD_UpgradeResponseHandle *urh, struct pollfd p[2]) { p[0].events = 0; p[1].events = 0; if (urh->in_buffer_used < urh->in_buffer_size) p[0].events |= POLLIN; if (0 != urh->out_buffer_used) p[0].events |= POLLOUT; /* Do not monitor again for errors if error was detected before as * error state is remembered. */ if ((0 == (urh->app.celi & MHD_EPOLL_STATE_ERROR)) && ((0 != urh->in_buffer_size) || (0 != urh->out_buffer_size) || (0 != urh->out_buffer_used))) p[0].events |= MHD_POLL_EVENTS_ERR_DISC; if (urh->out_buffer_used < urh->out_buffer_size) p[1].events |= POLLIN; if (0 != urh->in_buffer_used) p[1].events |= POLLOUT; /* Do not monitor again for errors if error was detected before as * error state is remembered. */ if ((0 == (urh->mhd.celi & MHD_EPOLL_STATE_ERROR)) && ((0 != urh->out_buffer_size) || (0 != urh->in_buffer_size) || (0 != urh->in_buffer_used))) p[1].events |= MHD_POLL_EVENTS_ERR_DISC; } /** * Set @a p to watch for @a urh. * * @param urh upgrade handle to watch for * @param p pollfd array to set */ static void urh_to_pollfd (struct MHD_UpgradeResponseHandle *urh, struct pollfd p[2]) { p[0].fd = urh->connection->socket_fd; p[1].fd = urh->mhd.socket; urh_update_pollfd (urh, p); } /** * Update ready state in @a urh based on pollfd. * @param urh upgrade handle to update * @param p 'poll()' processed pollfd. */ static void urh_from_pollfd (struct MHD_UpgradeResponseHandle *urh, struct pollfd p[2]) { /* Reset read/write ready, preserve error state. */ urh->app.celi &= (~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY) & ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY)); urh->mhd.celi &= (~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY) & ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY)); if (0 != (p[0].revents & POLLIN)) urh->app.celi |= MHD_EPOLL_STATE_READ_READY; if (0 != (p[0].revents & POLLOUT)) urh->app.celi |= MHD_EPOLL_STATE_WRITE_READY; if (0 != (p[0].revents & POLLHUP)) urh->app.celi |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY; if (0 != (p[0].revents & MHD_POLL_REVENTS_ERRROR)) urh->app.celi |= MHD_EPOLL_STATE_ERROR; if (0 != (p[1].revents & POLLIN)) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; if (0 != (p[1].revents & POLLOUT)) urh->mhd.celi |= MHD_EPOLL_STATE_WRITE_READY; if (0 != (p[1].revents & POLLHUP)) urh->mhd.celi |= MHD_EPOLL_STATE_ERROR; if (0 != (p[1].revents & MHD_POLL_REVENTS_ERRROR)) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY; } #endif /* HAVE_POLL */ #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /** * Internal version of #MHD_get_fdset2(). * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @param fd_setsize value of FD_SETSIZE * @return #MHD_YES on success, #MHD_NO if any FD didn't * fit fd_set. * @ingroup event */ static enum MHD_Result internal_get_fdset2 (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, int fd_setsize) { struct MHD_Connection *pos; struct MHD_Connection *posn; enum MHD_Result result = MHD_YES; MHD_socket ls; bool itc_added; #ifndef HAS_FD_SETSIZE_OVERRIDABLE (void) fd_setsize; /* Mute compiler warning */ fd_setsize = (int) FD_SETSIZE; /* Help compiler to optimise */ #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ if (daemon->shutdown) return MHD_YES; /* The order of FDs added is important for W32 sockets as W32 fd_set has limits for number of added FDs instead of the limit for the higher FD value. */ /* Add ITC FD first. The daemon must be able to respond on application commands issued in other threads. */ itc_added = false; if (MHD_ITC_IS_VALID_ (daemon->itc)) { itc_added = MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), read_fd_set, max_fd, fd_setsize); if (! itc_added) result = MHD_NO; } ls = daemon->was_quiesced ? MHD_INVALID_SOCKET : daemon->listen_fd; if (! itc_added && (MHD_INVALID_SOCKET != ls)) { /* Add listen FD if ITC was not added. Listen FD could be used to signal the daemon shutdown. */ if (MHD_add_to_fd_set_ (ls, read_fd_set, max_fd, fd_setsize)) ls = MHD_INVALID_SOCKET; /* Already added */ else result = MHD_NO; } /* Add all sockets to 'except_fd_set' as well to watch for * out-of-band data. However, ignore errors if INFO_READ * or INFO_WRITE sockets will not fit 'except_fd_set'. */ /* Start from oldest connections. Make sense for W32 FDSETs. */ for (pos = daemon->connections_tail; NULL != pos; pos = posn) { posn = pos->prev; switch (pos->event_loop_info) { case MHD_EVENT_LOOP_INFO_READ: case MHD_EVENT_LOOP_INFO_PROCESS_READ: if (! MHD_add_to_fd_set_ (pos->socket_fd, read_fd_set, max_fd, fd_setsize)) result = MHD_NO; #ifdef MHD_POSIX_SOCKETS if (NULL != except_fd_set) (void) MHD_add_to_fd_set_ (pos->socket_fd, except_fd_set, max_fd, fd_setsize); #endif /* MHD_POSIX_SOCKETS */ break; case MHD_EVENT_LOOP_INFO_WRITE: if (! MHD_add_to_fd_set_ (pos->socket_fd, write_fd_set, max_fd, fd_setsize)) result = MHD_NO; #ifdef MHD_POSIX_SOCKETS if (NULL != except_fd_set) (void) MHD_add_to_fd_set_ (pos->socket_fd, except_fd_set, max_fd, fd_setsize); #endif /* MHD_POSIX_SOCKETS */ break; case MHD_EVENT_LOOP_INFO_PROCESS: if ( (NULL == except_fd_set) || ! MHD_add_to_fd_set_ (pos->socket_fd, except_fd_set, max_fd, fd_setsize)) result = MHD_NO; break; case MHD_EVENT_LOOP_INFO_CLEANUP: /* this should never happen */ break; } } #ifdef MHD_WINSOCK_SOCKETS /* W32 use limited array for fd_set so add INFO_READ/INFO_WRITE sockets * only after INFO_BLOCK sockets to ensure that INFO_BLOCK sockets will * not be pushed out. */ if (NULL != except_fd_set) { for (pos = daemon->connections_tail; NULL != pos; pos = posn) { posn = pos->prev; MHD_add_to_fd_set_ (pos->socket_fd, except_fd_set, max_fd, fd_setsize); } } #endif /* MHD_WINSOCK_SOCKETS */ #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if (1) { struct MHD_UpgradeResponseHandle *urh; for (urh = daemon->urh_tail; NULL != urh; urh = urh->prev) { if (MHD_NO == urh_to_fdset (urh, read_fd_set, write_fd_set, except_fd_set, max_fd, fd_setsize)) result = MHD_NO; } } #endif if (MHD_INVALID_SOCKET != ls) { /* The listen socket is present and hasn't been added */ if ((daemon->connections < daemon->connection_limit) && ! daemon->at_limit) { if (! MHD_add_to_fd_set_ (ls, read_fd_set, max_fd, fd_setsize)) result = MHD_NO; } } #if _MHD_DEBUG_CONNECT #ifdef HAVE_MESSAGES if (NULL != max_fd) MHD_DLOG (daemon, _ ("Maximum socket in select set: %d\n"), *max_fd); #endif #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ return result; } /** * Obtain the `select()` sets for this daemon. * Daemon's FDs will be added to fd_sets. To get only * daemon FDs in fd_sets, call FD_ZERO for each fd_set * before calling this function. * * Passing custom FD_SETSIZE as @a fd_setsize allow usage of * larger/smaller than platform's default fd_sets. * * This function should be called only when MHD is configured to * use "external" sockets polling with 'select()' or with 'epoll'. * In the latter case, it will only add the single 'epoll' file * descriptor used by MHD to the sets. * It's necessary to use #MHD_get_timeout() to get maximum timeout * value for `select()`. Usage of `select()` with indefinite timeout * (or timeout larger than returned by #MHD_get_timeout()) will * violate MHD API and may results in pending unprocessed data. * * This function must be called only for daemon started * without #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value); can be NULL * @param fd_setsize value of FD_SETSIZE * @return #MHD_YES on success, #MHD_NO if this * daemon was not started with the right * options for this call or any FD didn't * fit fd_set. * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_get_fdset2 (struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize) { if ( (NULL == daemon) || (NULL == read_fd_set) || (NULL == write_fd_set) || MHD_D_IS_USING_THREADS_ (daemon) || MHD_D_IS_USING_POLL_ (daemon)) return MHD_NO; #ifdef HAVE_MESSAGES if (NULL == except_fd_set) { MHD_DLOG (daemon, _ ("MHD_get_fdset2() called with except_fd_set " "set to NULL. Such behavior is unsupported.\n")); } #endif #ifdef HAS_FD_SETSIZE_OVERRIDABLE if (0 == fd_setsize) return MHD_NO; else if (((unsigned int) INT_MAX) < fd_setsize) fd_setsize = (unsigned int) INT_MAX; #ifdef HAVE_MESSAGES else if (daemon->fdset_size > ((int) fd_setsize)) { if (daemon->fdset_size_set_by_app) { MHD_DLOG (daemon, _ ("%s() called with fd_setsize (%u) " \ "less than value set by MHD_OPTION_APP_FD_SETSIZE (%d). " \ "Some socket FDs may be not processed. " \ "Use MHD_OPTION_APP_FD_SETSIZE with the correct value.\n"), "MHD_get_fdset2", fd_setsize, daemon->fdset_size); } else { MHD_DLOG (daemon, _ ("%s() called with fd_setsize (%u) " \ "less than FD_SETSIZE used by MHD (%d). " \ "Some socket FDs may be not processed. " \ "Consider using MHD_OPTION_APP_FD_SETSIZE option.\n"), "MHD_get_fdset2", fd_setsize, daemon->fdset_size); } } #endif /* HAVE_MESSAGES */ #else /* ! HAS_FD_SETSIZE_OVERRIDABLE */ if (((unsigned int) FD_SETSIZE) > fd_setsize) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("%s() called with fd_setsize (%u) " \ "less than fixed FD_SETSIZE value (%d) used on the " \ "platform.\n"), "MHD_get_fdset2", fd_setsize, (int) FD_SETSIZE); #endif /* HAVE_MESSAGES */ return MHD_NO; } fd_setsize = (int) FD_SETSIZE; /* Help compiler to optimise */ #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon)) { if (daemon->shutdown) return MHD_YES; /* we're in epoll mode, use the epoll FD as a stand-in for the entire event set */ return MHD_add_to_fd_set_ (daemon->epoll_fd, read_fd_set, max_fd, (int) fd_setsize) ? MHD_YES : MHD_NO; } #endif return internal_get_fdset2 (daemon, read_fd_set, write_fd_set, except_fd_set, max_fd, (int) fd_setsize); } /** * Call the handlers for a connection in the appropriate order based * on the readiness as detected by the event loop. * * @param con connection to handle * @param read_ready set if the socket is ready for reading * @param write_ready set if the socket is ready for writing * @param force_close set if a hard error was detected on the socket; * if this information is not available, simply pass #MHD_NO * @return #MHD_YES to continue normally, * #MHD_NO if a serious error was encountered and the * connection is to be closed. */ static enum MHD_Result call_handlers (struct MHD_Connection *con, bool read_ready, bool write_ready, bool force_close) { enum MHD_Result ret; bool states_info_processed = false; /* Fast track flag */ bool on_fasttrack = (con->state == MHD_CONNECTION_INIT); ret = MHD_YES; mhd_assert ((0 == (con->daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (MHD_thread_handle_ID_is_valid_ID_ (con->tid))); mhd_assert ((0 != (con->daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (! MHD_thread_handle_ID_is_valid_ID_ (con->tid))); mhd_assert ((0 == (con->daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (MHD_thread_handle_ID_is_current_thread_ (con->tid))); #ifdef HTTPS_SUPPORT if (con->tls_read_ready) read_ready = true; #endif /* HTTPS_SUPPORT */ if ( (0 != (MHD_EVENT_LOOP_INFO_READ & con->event_loop_info)) && (read_ready || (force_close && con->sk_nonblck)) ) { MHD_connection_handle_read (con, force_close); mhd_assert (! force_close || MHD_CONNECTION_CLOSED == con->state); ret = MHD_connection_handle_idle (con); if (force_close) return ret; states_info_processed = true; } if (! force_close) { /* No need to check value of 'ret' here as closed connection * cannot be in MHD_EVENT_LOOP_INFO_WRITE state. */ if ( (MHD_EVENT_LOOP_INFO_WRITE == con->event_loop_info) && write_ready) { MHD_connection_handle_write (con); ret = MHD_connection_handle_idle (con); states_info_processed = true; } } else { MHD_connection_close_ (con, MHD_REQUEST_TERMINATED_WITH_ERROR); return MHD_connection_handle_idle (con); } if (! states_info_processed) { /* Connection is not read or write ready, but external conditions * may be changed and need to be processed. */ ret = MHD_connection_handle_idle (con); } /* Fast track for fast connections. */ /* If full request was read by single read_handler() invocation and headers were completely prepared by single MHD_connection_handle_idle() then try not to wait for next sockets polling and send response immediately. As writeability of socket was not checked and it may have some data pending in system buffers, use this optimization only for non-blocking sockets. */ /* No need to check 'ret' as connection is always in * MHD_CONNECTION_CLOSED state if 'ret' is equal 'MHD_NO'. */ else if (on_fasttrack && con->sk_nonblck) { if (MHD_CONNECTION_HEADERS_SENDING == con->state) { MHD_connection_handle_write (con); /* Always call 'MHD_connection_handle_idle()' after each read/write. */ ret = MHD_connection_handle_idle (con); } /* If all headers were sent by single write_handler() and * response body is prepared by single MHD_connection_handle_idle() * call - continue. */ if ((MHD_CONNECTION_NORMAL_BODY_READY == con->state) || (MHD_CONNECTION_CHUNKED_BODY_READY == con->state)) { MHD_connection_handle_write (con); ret = MHD_connection_handle_idle (con); } } /* All connection's data and states are processed for this turn. * If connection already has more data to be processed - use * zero timeout for next select()/poll(). */ /* Thread-per-connection do not need global zero timeout as * connections are processed individually. */ /* Note: no need to check for read buffer availability for * TLS read-ready connection in 'read info' state as connection * without space in read buffer will be marked as 'info block'. */ if ( (! con->daemon->data_already_pending) && (! MHD_D_IS_USING_THREAD_PER_CONN_ (con->daemon)) ) { if (0 != (MHD_EVENT_LOOP_INFO_PROCESS & con->event_loop_info)) con->daemon->data_already_pending = true; #ifdef HTTPS_SUPPORT else if ( (con->tls_read_ready) && (0 != (MHD_EVENT_LOOP_INFO_READ & con->event_loop_info)) ) con->daemon->data_already_pending = true; #endif /* HTTPS_SUPPORT */ } return ret; } #ifdef UPGRADE_SUPPORT /** * Finally cleanup upgrade-related resources. It should * be called when TLS buffers have been drained and * application signaled MHD by #MHD_UPGRADE_ACTION_CLOSE. * * @param connection handle to the upgraded connection to clean */ static void cleanup_upgraded_connection (struct MHD_Connection *connection) { struct MHD_UpgradeResponseHandle *urh = connection->urh; if (NULL == urh) return; #ifdef HTTPS_SUPPORT /* Signal remote client the end of TLS connection by * gracefully closing TLS session. */ if (0 != (connection->daemon->options & MHD_USE_TLS)) gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR); if (MHD_INVALID_SOCKET != urh->mhd.socket) MHD_socket_close_chk_ (urh->mhd.socket); if (MHD_INVALID_SOCKET != urh->app.socket) MHD_socket_close_chk_ (urh->app.socket); #endif /* HTTPS_SUPPORT */ connection->urh = NULL; free (urh); } #endif /* UPGRADE_SUPPORT */ #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Performs bi-directional forwarding on upgraded HTTPS connections * based on the readiness state stored in the @a urh handle. * @remark To be called only from thread that processes * connection's recv(), send() and response. * * @param urh handle to process */ static void process_urh (struct MHD_UpgradeResponseHandle *urh) { /* Help compiler to optimize: * pointers to 'connection' and 'daemon' are not changed * during this processing, so no need to chain dereference * each time. */ struct MHD_Connection *const connection = urh->connection; struct MHD_Daemon *const daemon = connection->daemon; /* Prevent data races: use same value of 'was_closed' throughout * this function. If 'was_closed' changed externally in the middle * of processing - it will be processed on next iteration. */ bool was_closed; #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); #endif /* MHD_USE_THREADS */ mhd_assert (0 != (daemon->options & MHD_USE_TLS)); if (daemon->shutdown) { /* Daemon shutting down, application will not receive any more data. */ #ifdef HAVE_MESSAGES if (! urh->was_closed) { MHD_DLOG (daemon, _ ("Initiated daemon shutdown while \"upgraded\" " \ "connection was not closed.\n")); } #endif urh->was_closed = true; } was_closed = urh->was_closed; if (was_closed) { /* Application was closed connections: no more data * can be forwarded to application socket. */ if (0 < urh->in_buffer_used) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to forward to application %" PRIu64 \ " bytes of data received from remote side: " \ "application closed data forwarding.\n"), (uint64_t) urh->in_buffer_used); #endif } /* Discard any data received form remote. */ urh->in_buffer_used = 0; /* Do not try to push data to application. */ urh->mhd.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); /* Reading from remote client is not required anymore. */ urh->in_buffer_size = 0; urh->app.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); connection->tls_read_ready = false; } /* On some platforms (W32, possibly Darwin) failed send() (send() will * always fail after remote disconnect was detected) may discard data in * system buffers received by system but not yet read by recv(). So, before * trying send() on any socket, recv() must be performed at first otherwise * last part of incoming data may be lost. If disconnect or error was * detected - try to read from socket to dry data possibly pending is system * buffers. */ /* * handle reading from remote TLS client */ if (((0 != ((MHD_EPOLL_STATE_ERROR | MHD_EPOLL_STATE_READ_READY) & urh->app.celi)) || (connection->tls_read_ready)) && (urh->in_buffer_used < urh->in_buffer_size)) { ssize_t res; size_t buf_size; buf_size = urh->in_buffer_size - urh->in_buffer_used; if (buf_size > SSIZE_MAX) buf_size = SSIZE_MAX; res = gnutls_record_recv (connection->tls_session, &urh->in_buffer[urh->in_buffer_used], buf_size); if (0 >= res) { connection->tls_read_ready = false; if (GNUTLS_E_INTERRUPTED != res) { urh->app.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); if ((GNUTLS_E_AGAIN != res) || (0 != (MHD_EPOLL_STATE_ERROR & urh->app.celi))) { /* TLS unrecoverable error has been detected, socket error was detected and all data has been read, or socket was disconnected/shut down. */ /* Stop trying to read from this TLS socket. */ urh->in_buffer_size = 0; } } } else /* 0 < res */ { urh->in_buffer_used += (size_t) res; connection->tls_read_ready = (0 < gnutls_record_check_pending (connection->tls_session)); } } /* * handle reading from application */ /* If application signalled MHD about socket closure then * check for any pending data even if socket is not marked * as 'ready' (signal may arrive after poll()/select()). * Socketpair for forwarding is always in non-blocking mode * so no risk that recv() will block the thread. */ if (((0 != ((MHD_EPOLL_STATE_ERROR | MHD_EPOLL_STATE_READ_READY) & urh->mhd.celi)) || was_closed) /* Force last reading from app if app has closed the connection */ && (urh->out_buffer_used < urh->out_buffer_size)) { ssize_t res; size_t buf_size; buf_size = urh->out_buffer_size - urh->out_buffer_used; if (buf_size > MHD_SCKT_SEND_MAX_SIZE_) buf_size = MHD_SCKT_SEND_MAX_SIZE_; res = MHD_recv_ (urh->mhd.socket, &urh->out_buffer[urh->out_buffer_used], buf_size); if (0 >= res) { const int err = MHD_socket_get_error_ (); if ((0 == res) || ((! MHD_SCKT_ERR_IS_EINTR_ (err)) && (! MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err)))) { urh->mhd.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); if ((0 == res) || (was_closed) || (0 != (MHD_EPOLL_STATE_ERROR & urh->mhd.celi)) || (! MHD_SCKT_ERR_IS_EAGAIN_ (err))) { /* Socket disconnect/shutdown was detected; * Application signalled about closure of 'upgraded' socket and * all data has been read from application; * or persistent / unrecoverable error. */ /* Do not try to pull more data from application. */ urh->out_buffer_size = 0; } } } else /* 0 < res */ { urh->out_buffer_used += (size_t) res; if (buf_size > (size_t) res) urh->mhd.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); } } /* * handle writing to remote HTTPS client */ if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->app.celi)) && (urh->out_buffer_used > 0) ) { ssize_t res; size_t data_size; data_size = urh->out_buffer_used; if (data_size > SSIZE_MAX) data_size = SSIZE_MAX; res = gnutls_record_send (connection->tls_session, urh->out_buffer, data_size); if (0 >= res) { if (GNUTLS_E_INTERRUPTED != res) { urh->app.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); if (GNUTLS_E_AGAIN != res) { /* TLS connection shut down or * persistent / unrecoverable error. */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to forward to remote client %" PRIu64 \ " bytes of data received from application: %s\n"), (uint64_t) urh->out_buffer_used, gnutls_strerror ((int) res)); #endif /* Discard any data unsent to remote. */ urh->out_buffer_used = 0; /* Do not try to pull more data from application. */ urh->out_buffer_size = 0; urh->mhd.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); } } } else /* 0 < res */ { const size_t next_out_buffer_used = urh->out_buffer_used - (size_t) res; if (0 != next_out_buffer_used) { memmove (urh->out_buffer, &urh->out_buffer[res], next_out_buffer_used); } urh->out_buffer_used = next_out_buffer_used; } if ( (0 == urh->out_buffer_used) && (0 != (MHD_EPOLL_STATE_ERROR & urh->app.celi)) ) { /* Unrecoverable error on socket was detected and all * pending data was sent to remote. */ /* Do not try to send to remote anymore. */ urh->app.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); /* Do not try to pull more data from application. */ urh->out_buffer_size = 0; urh->mhd.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); } } /* * handle writing to application */ if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->mhd.celi)) && (urh->in_buffer_used > 0) ) { ssize_t res; size_t data_size; data_size = urh->in_buffer_used; if (data_size > MHD_SCKT_SEND_MAX_SIZE_) data_size = MHD_SCKT_SEND_MAX_SIZE_; res = MHD_send_ (urh->mhd.socket, urh->in_buffer, data_size); if (0 >= res) { const int err = MHD_socket_get_error_ (); if ( (! MHD_SCKT_ERR_IS_EINTR_ (err)) && (! MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err)) ) { urh->mhd.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); if (! MHD_SCKT_ERR_IS_EAGAIN_ (err)) { /* Socketpair connection shut down or * persistent / unrecoverable error. */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to forward to application %" PRIu64 \ " bytes of data received from remote side: %s\n"), (uint64_t) urh->in_buffer_used, MHD_socket_strerr_ (err)); #endif /* Discard any data received from remote. */ urh->in_buffer_used = 0; /* Reading from remote client is not required anymore. */ urh->in_buffer_size = 0; urh->app.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); connection->tls_read_ready = false; } } } else /* 0 < res */ { const size_t next_in_buffer_used = urh->in_buffer_used - (size_t) res; if (0 != next_in_buffer_used) { memmove (urh->in_buffer, &urh->in_buffer[res], next_in_buffer_used); if (data_size > (size_t) res) urh->mhd.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); } urh->in_buffer_used = next_in_buffer_used; } if ( (0 == urh->in_buffer_used) && (0 != (MHD_EPOLL_STATE_ERROR & urh->mhd.celi)) ) { /* Do not try to push data to application. */ urh->mhd.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); /* Reading from remote client is not required anymore. */ urh->in_buffer_size = 0; urh->app.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); connection->tls_read_ready = false; } } /* Check whether data is present in TLS buffers * and incoming forward buffer have some space. */ if ( (connection->tls_read_ready) && (urh->in_buffer_used < urh->in_buffer_size) && (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) ) daemon->data_already_pending = true; if ( (daemon->shutdown) && ( (0 != urh->out_buffer_size) || (0 != urh->out_buffer_used) ) ) { /* Daemon shutting down, discard any remaining forward data. */ #ifdef HAVE_MESSAGES if (0 < urh->out_buffer_used) MHD_DLOG (daemon, _ ("Failed to forward to remote client %" PRIu64 \ " bytes of data received from application: daemon shut down.\n"), (uint64_t) urh->out_buffer_used); #endif /* Discard any data unsent to remote. */ urh->out_buffer_used = 0; /* Do not try to sent to remote anymore. */ urh->app.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_WRITE_READY); /* Do not try to pull more data from application. */ urh->out_buffer_size = 0; urh->mhd.celi &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); } if (! was_closed && urh->was_closed) daemon->data_already_pending = true; /* Force processing again */ } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) #ifdef UPGRADE_SUPPORT /** * Main function of the thread that handles an individual connection * after it was "upgraded" when #MHD_USE_THREAD_PER_CONNECTION is set. * @remark To be called only from thread that process * connection's recv(), send() and response. * * @param con the connection this thread will handle */ static void thread_main_connection_upgrade (struct MHD_Connection *con) { #ifdef HTTPS_SUPPORT struct MHD_UpgradeResponseHandle *urh = con->urh; struct MHD_Daemon *daemon = con->daemon; mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (con->tid) ); /* Here, we need to bi-directionally forward until the application tells us that it is done with the socket; */ if ( (0 != (daemon->options & MHD_USE_TLS)) && MHD_D_IS_USING_SELECT_ (daemon)) { while ( (0 != urh->in_buffer_size) || (0 != urh->out_buffer_size) || (0 != urh->in_buffer_used) || (0 != urh->out_buffer_used) ) { /* use select */ fd_set rs; fd_set ws; fd_set es; MHD_socket max_fd; int num_ready; bool result; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); max_fd = MHD_INVALID_SOCKET; result = urh_to_fdset (urh, &rs, &ws, &es, &max_fd, FD_SETSIZE); if (! result) { #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Error preparing select.\n")); #endif break; } /* FIXME: does this check really needed? */ if (MHD_INVALID_SOCKET != max_fd) { struct timeval *tvp; struct timeval tv; if (((con->tls_read_ready) && (urh->in_buffer_used < urh->in_buffer_size)) || (daemon->shutdown)) { /* No need to wait if incoming data is already pending in TLS buffers. */ tv.tv_sec = 0; tv.tv_usec = 0; tvp = &tv; } else tvp = NULL; num_ready = MHD_SYS_select_ (max_fd + 1, &rs, &ws, &es, tvp); } else num_ready = 0; if (num_ready < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Error during select (%d): `%s'\n"), err, MHD_socket_strerr_ (err)); #endif break; } urh_from_fdset (urh, &rs, &ws, &es, (int) FD_SETSIZE); process_urh (urh); } } #ifdef HAVE_POLL else if (0 != (daemon->options & MHD_USE_TLS)) { /* use poll() */ struct pollfd p[2]; memset (p, 0, sizeof (p)); p[0].fd = urh->connection->socket_fd; p[1].fd = urh->mhd.socket; while ( (0 != urh->in_buffer_size) || (0 != urh->out_buffer_size) || (0 != urh->in_buffer_used) || (0 != urh->out_buffer_used) ) { int timeout; urh_update_pollfd (urh, p); if (((con->tls_read_ready) && (urh->in_buffer_used < urh->in_buffer_size)) || (daemon->shutdown)) timeout = 0; /* No need to wait if incoming data is already pending in TLS buffers. */ else timeout = -1; if (MHD_sys_poll_ (p, 2, timeout) < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Error during poll: `%s'\n"), MHD_socket_strerr_ (err)); #endif break; } urh_from_pollfd (urh, p); process_urh (urh); } } /* end POLL */ #endif /* end HTTPS */ #endif /* HTTPS_SUPPORT */ /* TLS forwarding was finished. Cleanup socketpair. */ MHD_connection_finish_forward_ (con); /* Do not set 'urh->clean_ready' yet as 'urh' will be used * in connection thread for a little while. */ } #endif /* UPGRADE_SUPPORT */ /** * Get maximum wait period for the connection (the amount of time left before * connection time out) * @param c the connection to check * @return the maximum number of millisecond before the connection must be * processed again. */ static uint64_t connection_get_wait (struct MHD_Connection *c) { const uint64_t now = MHD_monotonic_msec_counter (); const uint64_t since_actv = now - c->last_activity; const uint64_t timeout = c->connection_timeout_ms; uint64_t mseconds_left; mhd_assert (0 != timeout); /* Keep the next lines in sync with #connection_check_timedout() to avoid * undesired side-effects like busy-waiting. */ if (timeout < since_actv) { if (UINT64_MAX / 2 < since_actv) { const uint64_t jump_back = c->last_activity - now; /* Very unlikely that it is more than quarter-million years pause. * More likely that system clock jumps back. */ if (5000 >= jump_back) { /* Jump back is less than 5 seconds, try to recover. */ return 100; /* Set wait time to 0.1 seconds */ } /* Too large jump back */ } return 0; /* Connection has timed out */ } else if (since_actv == timeout) { /* Exact match for timeout and time from last activity. * Maybe this is just a precise match or this happens because the timer * resolution is too low. * Set wait time to 0.1 seconds to avoid busy-waiting with low * timer resolution as connection is not timed-out yet. */ return 100; } mseconds_left = timeout - since_actv; return mseconds_left; } /** * Main function of the thread that handles an individual * connection when #MHD_USE_THREAD_PER_CONNECTION is set. * * @param data the `struct MHD_Connection` this thread will handle * @return always 0 */ static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ thread_main_handle_connection (void *data) { struct MHD_Connection *con = data; struct MHD_Daemon *daemon = con->daemon; int num_ready; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; #ifdef WINDOWS #ifdef HAVE_POLL unsigned int extra_slot; #endif /* HAVE_POLL */ #define EXTRA_SLOTS 1 #else /* !WINDOWS */ #define EXTRA_SLOTS 0 #endif /* !WINDOWS */ #ifdef HAVE_POLL struct pollfd p[1 + EXTRA_SLOTS]; #endif #undef EXTRA_SLOTS #ifdef HAVE_POLL const bool use_poll = MHD_D_IS_USING_POLL_ (daemon); #else /* ! HAVE_POLL */ const bool use_poll = 0; #endif /* ! HAVE_POLL */ bool was_suspended = false; MHD_thread_handle_ID_set_current_thread_ID_ (&(con->tid)); while ( (! daemon->shutdown) && (MHD_CONNECTION_CLOSED != con->state) ) { bool use_zero_timeout; #ifdef UPGRADE_SUPPORT struct MHD_UpgradeResponseHandle *const urh = con->urh; #else /* ! UPGRADE_SUPPORT */ static const void *const urh = NULL; #endif /* ! UPGRADE_SUPPORT */ if ( (con->suspended) && (NULL == urh) ) { /* Connection was suspended, wait for resume. */ was_suspended = true; if (! use_poll) { FD_ZERO (&rs); if (! MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), &rs, NULL, FD_SETSIZE)) { #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Failed to add FD to fd_set.\n")); #endif goto exit; } if (0 > MHD_SYS_select_ (MHD_itc_r_fd_ (daemon->itc) + 1, &rs, NULL, NULL, NULL)) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Error during select (%d): `%s'\n"), err, MHD_socket_strerr_ (err)); #endif break; } } #ifdef HAVE_POLL else /* use_poll */ { p[0].events = POLLIN; p[0].fd = MHD_itc_r_fd_ (daemon->itc); p[0].revents = 0; if (0 > MHD_sys_poll_ (p, 1, -1)) { if (MHD_SCKT_LAST_ERR_IS_ (MHD_SCKT_EINTR_)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Error during poll: `%s'\n"), MHD_socket_last_strerr_ ()); #endif break; } } #endif /* HAVE_POLL */ MHD_itc_clear_ (daemon->itc); continue; /* Check again for resume. */ } /* End of "suspended" branch. */ if (was_suspended) { MHD_update_last_activity_ (con); /* Reset timeout timer. */ /* Process response queued during suspend and update states. */ MHD_connection_handle_idle (con); was_suspended = false; } use_zero_timeout = (0 != (MHD_EVENT_LOOP_INFO_PROCESS & con->event_loop_info) #ifdef HTTPS_SUPPORT || ( (con->tls_read_ready) && (0 != (MHD_EVENT_LOOP_INFO_READ & con->event_loop_info)) ) #endif /* HTTPS_SUPPORT */ ); if (! use_poll) { /* use select */ bool err_state = false; struct timeval tv; struct timeval *tvp; if (use_zero_timeout) { tv.tv_sec = 0; tv.tv_usec = 0; tvp = &tv; } else if (con->connection_timeout_ms > 0) { const uint64_t mseconds_left = connection_get_wait (con); #if (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC if (mseconds_left / 1000 > TIMEVAL_TV_SEC_MAX) tv.tv_sec = TIMEVAL_TV_SEC_MAX; else #endif /* (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC */ tv.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) mseconds_left / 1000; tv.tv_usec = ((uint16_t) (mseconds_left % 1000)) * ((int32_t) 1000); tvp = &tv; } else tvp = NULL; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); maxsock = MHD_INVALID_SOCKET; switch (con->event_loop_info) { case MHD_EVENT_LOOP_INFO_READ: case MHD_EVENT_LOOP_INFO_PROCESS_READ: if (! MHD_add_to_fd_set_ (con->socket_fd, &rs, &maxsock, FD_SETSIZE)) err_state = true; break; case MHD_EVENT_LOOP_INFO_WRITE: if (! MHD_add_to_fd_set_ (con->socket_fd, &ws, &maxsock, FD_SETSIZE)) err_state = true; break; case MHD_EVENT_LOOP_INFO_PROCESS: if (! MHD_add_to_fd_set_ (con->socket_fd, &es, &maxsock, FD_SETSIZE)) err_state = true; break; case MHD_EVENT_LOOP_INFO_CLEANUP: /* how did we get here!? */ goto exit; } #ifdef WINDOWS if (MHD_ITC_IS_VALID_ (daemon->itc) ) { if (! MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), &rs, &maxsock, FD_SETSIZE)) err_state = 1; } #endif if (err_state) { #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Failed to add FD to fd_set.\n")); #endif goto exit; } num_ready = MHD_SYS_select_ (maxsock + 1, &rs, &ws, &es, tvp); if (num_ready < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Error during select (%d): `%s'\n"), err, MHD_socket_strerr_ (err)); #endif break; } #ifdef WINDOWS /* Clear ITC before other processing so additional * signals will trigger select() again */ if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (FD_ISSET (MHD_itc_r_fd_ (daemon->itc), &rs)) ) MHD_itc_clear_ (daemon->itc); #endif if (MHD_NO == call_handlers (con, FD_ISSET (con->socket_fd, &rs), FD_ISSET (con->socket_fd, &ws), FD_ISSET (con->socket_fd, &es)) ) goto exit; } #ifdef HAVE_POLL else { int timeout_val; /* use poll */ if (use_zero_timeout) timeout_val = 0; else if (con->connection_timeout_ms > 0) { const uint64_t mseconds_left = connection_get_wait (con); #if SIZEOF_UINT64_T >= SIZEOF_INT if (mseconds_left >= INT_MAX) timeout_val = INT_MAX; else #endif /* SIZEOF_UINT64_T >= SIZEOF_INT */ timeout_val = (int) mseconds_left; } else timeout_val = -1; memset (&p, 0, sizeof (p)); p[0].fd = con->socket_fd; switch (con->event_loop_info) { case MHD_EVENT_LOOP_INFO_READ: case MHD_EVENT_LOOP_INFO_PROCESS_READ: p[0].events |= POLLIN | MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_WRITE: p[0].events |= POLLOUT | MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_PROCESS: p[0].events |= MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_CLEANUP: /* how did we get here!? */ goto exit; } #ifdef WINDOWS extra_slot = 0; if (MHD_ITC_IS_VALID_ (daemon->itc)) { p[1].events |= POLLIN; p[1].fd = MHD_itc_r_fd_ (daemon->itc); p[1].revents = 0; extra_slot = 1; } #endif if (MHD_sys_poll_ (p, #ifdef WINDOWS 1 + extra_slot, #else 1, #endif timeout_val) < 0) { if (MHD_SCKT_LAST_ERR_IS_ (MHD_SCKT_EINTR_)) continue; #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Error during poll: `%s'\n"), MHD_socket_last_strerr_ ()); #endif break; } #ifdef WINDOWS /* Clear ITC before other processing so additional * signals will trigger poll() again */ if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (0 != (p[1].revents & (POLLERR | POLLHUP | POLLIN))) ) MHD_itc_clear_ (daemon->itc); #endif if (MHD_NO == call_handlers (con, (0 != (p[0].revents & POLLIN)), (0 != (p[0].revents & POLLOUT)), (0 != (p[0].revents & MHD_POLL_REVENTS_ERR_DISC)) )) goto exit; } #endif #ifdef UPGRADE_SUPPORT if (MHD_CONNECTION_UPGRADE == con->state) { /* Normal HTTP processing is finished, * notify application. */ if ( (NULL != daemon->notify_completed) && (con->rq.client_aware) ) daemon->notify_completed (daemon->notify_completed_cls, con, &con->rq.client_context, MHD_REQUEST_TERMINATED_COMPLETED_OK); con->rq.client_aware = false; thread_main_connection_upgrade (con); /* MHD_connection_finish_forward_() was called by thread_main_connection_upgrade(). */ /* "Upgraded" data will not be used in this thread from this point. */ con->urh->clean_ready = true; /* If 'urh->was_closed' set to true, connection will be * moved immediately to cleanup list. Otherwise connection * will stay in suspended list until 'urh' will be marked * with 'was_closed' by application. */ MHD_resume_connection (con); /* skip usual clean up */ return (MHD_THRD_RTRN_TYPE_) 0; } #endif /* UPGRADE_SUPPORT */ } #if _MHD_DEBUG_CLOSE #ifdef HAVE_MESSAGES MHD_DLOG (con->daemon, _ ("Processing thread terminating. Closing connection.\n")); #endif #endif if (MHD_CONNECTION_CLOSED != con->state) MHD_connection_close_ (con, (daemon->shutdown) ? MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN : MHD_REQUEST_TERMINATED_WITH_ERROR); MHD_connection_handle_idle (con); exit: if (NULL != con->rp.response) { MHD_destroy_response (con->rp.response); con->rp.response = NULL; } if (MHD_INVALID_SOCKET != con->socket_fd) { shutdown (con->socket_fd, SHUT_WR); /* 'socket_fd' can be used in other thread to signal shutdown. * To avoid data races, do not close socket here. Daemon will * use more connections only after cleanup anyway. */ } if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "t")) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to signal thread termination via inter-thread " \ "communication channel.\n")); #endif } return (MHD_THRD_RTRN_TYPE_) 0; } #endif /** * Free resources associated with all closed connections. * (destroy responses, free buffers, etc.). All closed * connections are kept in the "cleanup" doubly-linked list. * * @param daemon daemon to clean up */ static void MHD_cleanup_connections (struct MHD_Daemon *daemon); #if defined(HTTPS_SUPPORT) #if defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) && \ defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) && \ ! defined(MHD_socket_nosignal_) && \ (GNUTLS_VERSION_NUMBER + 0 < 0x030402) && defined(MSG_NOSIGNAL) /** * Older version of GnuTLS do not support suppressing of SIGPIPE signal. * Use push function replacement with suppressing SIGPIPE signal where necessary * and if possible. */ #define MHD_TLSLIB_NEED_PUSH_FUNC 1 #endif /* MHD_SEND_SPIPE_SUPPRESS_NEEDED && MHD_SEND_SPIPE_SUPPRESS_POSSIBLE && ! MHD_socket_nosignal_ && (GNUTLS_VERSION_NUMBER+0 < 0x030402) && MSG_NOSIGNAL */ #ifdef MHD_TLSLIB_NEED_PUSH_FUNC /** * Data push function replacement with suppressing SIGPIPE signal * for TLS library. */ static ssize_t MHD_tls_push_func_ (gnutls_transport_ptr_t trnsp, const void *data, size_t data_size) { #if (MHD_SCKT_SEND_MAX_SIZE_ < SSIZE_MAX) || (0 == SSIZE_MAX) if (data_size > MHD_SCKT_SEND_MAX_SIZE_) data_size = MHD_SCKT_SEND_MAX_SIZE_; #endif /* (MHD_SCKT_SEND_MAX_SIZE_ < SSIZE_MAX) || (0 == SSIZE_MAX) */ return MHD_send_ ((MHD_socket) (intptr_t) (trnsp), data, data_size); } #endif /* MHD_TLSLIB_DONT_SUPPRESS_SIGPIPE */ /** * Function called by GNUtls to obtain the PSK for a given session. * * @param session the session to lookup PSK for * @param username username to lookup PSK for * @param[out] key where to write PSK * @return 0 on success, -1 on error */ static int psk_gnutls_adapter (gnutls_session_t session, const char *username, gnutls_datum_t *key) { struct MHD_Connection *connection; struct MHD_Daemon *daemon; #if GNUTLS_VERSION_MAJOR >= 3 void *app_psk; size_t app_psk_size; #endif /* GNUTLS_VERSION_MAJOR >= 3 */ connection = gnutls_session_get_ptr (session); if (NULL == connection) { #ifdef HAVE_MESSAGES /* Cannot use our logger, we don't even have "daemon" */ MHD_PANIC (_ ("Internal server error. This should be impossible.\n")); #endif return -1; } daemon = connection->daemon; #if GNUTLS_VERSION_MAJOR >= 3 if (NULL == daemon->cred_callback) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("PSK not supported by this server.\n")); #endif return -1; } if (0 != daemon->cred_callback (daemon->cred_callback_cls, connection, username, &app_psk, &app_psk_size)) return -1; if (NULL == (key->data = gnutls_malloc (app_psk_size))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("PSK authentication failed: gnutls_malloc failed to " \ "allocate memory.\n")); #endif free (app_psk); return -1; } if (UINT_MAX < app_psk_size) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("PSK authentication failed: PSK too long.\n")); #endif free (app_psk); return -1; } key->size = (unsigned int) app_psk_size; memcpy (key->data, app_psk, app_psk_size); free (app_psk); return 0; #else (void) username; (void) key; /* Mute compiler warning */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("PSK not supported by this server.\n")); #endif return -1; #endif } #endif /* HTTPS_SUPPORT */ /** * Do basic preparation work on the new incoming connection. * * This function do all preparation that is possible outside main daemon * thread. * @remark Could be called from any thread. * * @param daemon daemon that manages the connection * @param client_socket socket to manage (MHD will expect * to receive an HTTP request from this socket next). * @param addr IP address of the client * @param addrlen number of bytes in @a addr * @param external_add indicate that socket has been added externally * @param non_blck indicate that socket in non-blocking mode * @param sk_spipe_supprs indicate that the @a client_socket has * set SIGPIPE suppression * @param sk_is_nonip _MHD_YES if this is not a TCP/IP socket * @return pointer to the connection on success, NULL if this daemon could * not handle the connection (i.e. malloc failed, etc). * The socket will be closed in case of error; 'errno' is * set to indicate further details about the error. */ static struct MHD_Connection * new_connection_prepare_ (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr_storage *addr, socklen_t addrlen, bool external_add, bool non_blck, bool sk_spipe_supprs, enum MHD_tristate sk_is_nonip) { struct MHD_Connection *connection; int eno = 0; #ifdef HAVE_MESSAGES #if _MHD_DEBUG_CONNECT MHD_DLOG (daemon, _ ("Accepted connection on socket %d.\n"), client_socket); #endif #endif if ( (daemon->connections == daemon->connection_limit) || (MHD_NO == MHD_ip_limit_add (daemon, addr, addrlen)) ) { /* above connection limit - reject */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Server reached connection limit. " \ "Closing inbound connection.\n")); #endif MHD_socket_close_chk_ (client_socket); #if defined(ENFILE) && (ENFILE + 0 != 0) errno = ENFILE; #endif return NULL; } /* apply connection acceptance policy if present */ if ( (NULL != daemon->apc) && (MHD_NO == daemon->apc (daemon->apc_cls, (const struct sockaddr *) addr, addrlen)) ) { #if _MHD_DEBUG_CLOSE #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Connection rejected by application. Closing connection.\n")); #endif #endif MHD_socket_close_chk_ (client_socket); MHD_ip_limit_del (daemon, addr, addrlen); #if defined(EACCESS) && (EACCESS + 0 != 0) errno = EACCESS; #endif return NULL; } if (NULL == (connection = MHD_calloc_ (1, sizeof (struct MHD_Connection)))) { eno = errno; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Error allocating memory: %s\n"), MHD_strerror_ (errno)); #endif MHD_socket_close_chk_ (client_socket); MHD_ip_limit_del (daemon, addr, addrlen); errno = eno; return NULL; } if (! external_add) { connection->sk_corked = _MHD_OFF; connection->sk_nodelay = _MHD_OFF; } else { connection->sk_corked = _MHD_UNKNOWN; connection->sk_nodelay = _MHD_UNKNOWN; } if (0 < addrlen) { if (NULL == (connection->addr = malloc ((size_t) addrlen))) { eno = errno; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Error allocating memory: %s\n"), MHD_strerror_ (errno)); #endif MHD_socket_close_chk_ (client_socket); MHD_ip_limit_del (daemon, addr, addrlen); free (connection); errno = eno; return NULL; } memcpy (connection->addr, addr, (size_t) addrlen); } else connection->addr = NULL; connection->addr_len = addrlen; connection->socket_fd = client_socket; connection->sk_nonblck = non_blck; connection->is_nonip = sk_is_nonip; connection->sk_spipe_suppress = sk_spipe_supprs; #ifdef MHD_USE_THREADS MHD_thread_handle_ID_set_invalid_ (&connection->tid); #endif /* MHD_USE_THREADS */ connection->daemon = daemon; connection->connection_timeout_ms = daemon->connection_timeout_ms; connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ; if (0 != connection->connection_timeout_ms) connection->last_activity = MHD_monotonic_msec_counter (); if (0 == (daemon->options & MHD_USE_TLS)) { /* set default connection handlers */ MHD_set_http_callbacks_ (connection); } else { #ifdef HTTPS_SUPPORT #if (GNUTLS_VERSION_NUMBER + 0 >= 0x030500) gnutls_init_flags_t #else unsigned int #endif flags; flags = GNUTLS_SERVER; #if (GNUTLS_VERSION_NUMBER + 0 >= 0x030402) flags |= GNUTLS_NO_SIGNAL; #endif /* GNUTLS_VERSION_NUMBER >= 0x030402 */ #if GNUTLS_VERSION_MAJOR >= 3 flags |= GNUTLS_NONBLOCK; #endif /* GNUTLS_VERSION_MAJOR >= 3*/ #if (GNUTLS_VERSION_NUMBER + 0 >= 0x030603) if (0 != (daemon->options & MHD_USE_POST_HANDSHAKE_AUTH_SUPPORT)) flags |= GNUTLS_POST_HANDSHAKE_AUTH; #endif #if (GNUTLS_VERSION_NUMBER + 0 >= 0x030605) if (0 != (daemon->options & MHD_USE_INSECURE_TLS_EARLY_DATA)) flags |= GNUTLS_ENABLE_EARLY_DATA; #endif connection->tls_state = MHD_TLS_CONN_INIT; MHD_set_https_callbacks (connection); if ((GNUTLS_E_SUCCESS != gnutls_init (&connection->tls_session, flags)) || (GNUTLS_E_SUCCESS != gnutls_priority_set (connection->tls_session, daemon->priority_cache))) { if (NULL != connection->tls_session) gnutls_deinit (connection->tls_session); MHD_socket_close_chk_ (client_socket); MHD_ip_limit_del (daemon, addr, addrlen); if (NULL != connection->addr) free (connection->addr); free (connection); #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to initialise TLS session.\n")); #endif #if defined(EPROTO) && (EPROTO + 0 != 0) errno = EPROTO; #endif return NULL; } #if (GNUTLS_VERSION_NUMBER + 0 >= 0x030200) if (! daemon->disable_alpn) { static const char prt1[] = "http/1.1"; /* Registered code for HTTP/1.1 */ static const char prt2[] = "http/1.0"; /* Registered code for HTTP/1.0 */ static const gnutls_datum_t prts[2] = { {_MHD_DROP_CONST (prt1), MHD_STATICSTR_LEN_ (prt1)}, {_MHD_DROP_CONST (prt2), MHD_STATICSTR_LEN_ (prt2)} }; if (GNUTLS_E_SUCCESS != gnutls_alpn_set_protocols (connection->tls_session, prts, sizeof(prts) / sizeof(prts[0]), 0 /* | GNUTLS_ALPN_SERVER_PRECEDENCE */)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to set ALPN protocols.\n")); #else /* ! HAVE_MESSAGES */ (void) 0; /* Mute compiler warning */ #endif /* ! HAVE_MESSAGES */ } } #endif /* GNUTLS_VERSION_NUMBER >= 0x030200 */ gnutls_session_set_ptr (connection->tls_session, connection); switch (daemon->cred_type) { /* set needed credentials for certificate authentication. */ case GNUTLS_CRD_CERTIFICATE: gnutls_credentials_set (connection->tls_session, GNUTLS_CRD_CERTIFICATE, daemon->x509_cred); break; case GNUTLS_CRD_PSK: gnutls_credentials_set (connection->tls_session, GNUTLS_CRD_PSK, daemon->psk_cred); gnutls_psk_set_server_credentials_function (daemon->psk_cred, &psk_gnutls_adapter); break; case GNUTLS_CRD_ANON: case GNUTLS_CRD_SRP: case GNUTLS_CRD_IA: default: #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to setup TLS credentials: " \ "unknown credential type %d.\n"), daemon->cred_type); #endif gnutls_deinit (connection->tls_session); MHD_socket_close_chk_ (client_socket); MHD_ip_limit_del (daemon, addr, addrlen); if (NULL != connection->addr) free (connection->addr); free (connection); MHD_PANIC (_ ("Unknown credential type.\n")); #if defined(EINVAL) && (EINVAL + 0 != 0) errno = EINVAL; #endif return NULL; } #if (GNUTLS_VERSION_NUMBER + 0 >= 0x030109) && ! defined(_WIN64) gnutls_transport_set_int (connection->tls_session, (int) (client_socket)); #else /* GnuTLS before 3.1.9 or Win x64 */ gnutls_transport_set_ptr (connection->tls_session, (gnutls_transport_ptr_t) \ (intptr_t) client_socket); #endif /* GnuTLS before 3.1.9 or Win x64 */ #ifdef MHD_TLSLIB_NEED_PUSH_FUNC gnutls_transport_set_push_function (connection->tls_session, MHD_tls_push_func_); #endif /* MHD_TLSLIB_NEED_PUSH_FUNC */ if (daemon->https_mem_trust) gnutls_certificate_server_set_request (connection->tls_session, GNUTLS_CERT_REQUEST); #else /* ! HTTPS_SUPPORT */ MHD_socket_close_chk_ (client_socket); MHD_ip_limit_del (daemon, addr, addrlen); free (connection->addr); free (connection); MHD_PANIC (_ ("TLS connection on non-TLS daemon.\n")); #if 0 /* Unreachable code */ eno = EINVAL; return NULL; #endif #endif /* ! HTTPS_SUPPORT */ } return connection; } #ifdef MHD_USE_THREADS /** * Close prepared, but not yet processed connection. * @param daemon the daemon * @param connection the connection to close */ static void new_connection_close_ (struct MHD_Daemon *daemon, struct MHD_Connection *connection) { mhd_assert (connection->daemon == daemon); mhd_assert (! connection->in_cleanup); mhd_assert (NULL == connection->next); mhd_assert (NULL == connection->nextX); #ifdef EPOLL_SUPPORT mhd_assert (NULL == connection->nextE); #endif /* EPOLL_SUPPORT */ #ifdef HTTPS_SUPPORT if (NULL != connection->tls_session) { mhd_assert (0 != (daemon->options & MHD_USE_TLS)); gnutls_deinit (connection->tls_session); } #endif /* HTTPS_SUPPORT */ MHD_socket_close_chk_ (connection->socket_fd); MHD_ip_limit_del (daemon, connection->addr, connection->addr_len); if (NULL != connection->addr) free (connection->addr); free (connection); } #endif /* MHD_USE_THREADS */ /** * Finally insert the new connection to the list of connections * served by the daemon and start processing. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon daemon that manages the connection * @param connection the newly created connection * @return #MHD_YES on success, #MHD_NO on error */ static enum MHD_Result new_connection_process_ (struct MHD_Daemon *daemon, struct MHD_Connection *connection) { int eno = 0; mhd_assert (connection->daemon == daemon); #ifdef MHD_USE_THREADS /* Function manipulate connection and timeout DL-lists, * must be called only within daemon thread. */ mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ /* Allocate memory pool in the processing thread so * intensively used memory area is allocated in "good" * (for the thread) memory region. It is important with * NUMA and/or complex cache hierarchy. */ connection->pool = MHD_pool_create (daemon->pool_size); if (NULL == connection->pool) { /* 'pool' creation failed */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Error allocating memory: %s\n"), MHD_strerror_ (errno)); #endif #if defined(ENOMEM) && (ENOMEM + 0 != 0) eno = ENOMEM; #endif (void) 0; /* Mute possible compiler warning */ } else { /* 'pool' creation succeed */ MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); /* Firm check under lock. */ if (daemon->connections >= daemon->connection_limit) { /* Connections limit */ MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Server reached connection limit. " "Closing inbound connection.\n")); #endif #if defined(ENFILE) && (ENFILE + 0 != 0) eno = ENFILE; #endif (void) 0; /* Mute possible compiler warning */ } else { /* Have space for new connection */ daemon->connections++; DLL_insert (daemon->connections_head, daemon->connections_tail, connection); if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { XDLL_insert (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); } MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); MHD_connection_set_initial_state_ (connection); if (NULL != daemon->notify_connection) daemon->notify_connection (daemon->notify_connection_cls, connection, &connection->socket_context, MHD_CONNECTION_NOTIFY_STARTED); #ifdef MHD_USE_THREADS if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { mhd_assert (! MHD_D_IS_USING_EPOLL_ (daemon)); if (! MHD_create_named_thread_ (&connection->tid, "MHD-connection", daemon->thread_stack_size, &thread_main_handle_connection, connection)) { eno = errno; #ifdef HAVE_MESSAGES #ifdef EAGAIN if (EAGAIN == eno) MHD_DLOG (daemon, _ ("Failed to create a new thread because it would " "have exceeded the system limit on the number of " "threads or no system resources available.\n")); else #endif /* EAGAIN */ MHD_DLOG (daemon, _ ("Failed to create a thread: %s\n"), MHD_strerror_ (eno)); #endif /* HAVE_MESSAGES */ } else /* New thread has been created successfully */ return MHD_YES; /* *** Function success exit point *** */ } else #else /* ! MHD_USE_THREADS */ if (1) #endif /* ! MHD_USE_THREADS */ { /* No 'thread-per-connection' */ #ifdef MHD_USE_THREADS connection->tid = daemon->tid; #endif /* MHD_USE_THREADS */ #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon)) { if (0 == (daemon->options & MHD_USE_TURBO)) { struct epoll_event event; event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET | EPOLLRDHUP; event.data.ptr = connection; if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, connection->socket_fd, &event)) { eno = errno; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif } else { /* 'socket_fd' has been added to 'epool' */ connection->epoll_state |= MHD_EPOLL_STATE_IN_EPOLL_SET; return MHD_YES; /* *** Function success exit point *** */ } } else { connection->epoll_state |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY | MHD_EPOLL_STATE_IN_EREADY_EDLL; EDLL_insert (daemon->eready_head, daemon->eready_tail, connection); return MHD_YES; /* *** Function success exit point *** */ } } else /* No 'epoll' */ #endif /* EPOLL_SUPPORT */ return MHD_YES; /* *** Function success exit point *** */ } /* ** Below is a cleanup path ** */ if (NULL != daemon->notify_connection) daemon->notify_connection (daemon->notify_connection_cls, connection, &connection->socket_context, MHD_CONNECTION_NOTIFY_CLOSED); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); } DLL_remove (daemon->connections_head, daemon->connections_tail, connection); daemon->connections--; MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } MHD_pool_destroy (connection->pool); } /* Free resources allocated before the call of this functions */ #ifdef HTTPS_SUPPORT if (NULL != connection->tls_session) gnutls_deinit (connection->tls_session); #endif /* HTTPS_SUPPORT */ MHD_ip_limit_del (daemon, connection->addr, connection->addr_len); if (NULL != connection->addr) free (connection->addr); MHD_socket_close_chk_ (connection->socket_fd); free (connection); if (0 != eno) errno = eno; #ifdef EINVAL else errno = EINVAL; #endif /* EINVAL */ return MHD_NO; /* *** Function failure exit point *** */ } /** * Add another client connection to the set of connections * managed by MHD. This API is usually not needed (since * MHD will accept inbound connections on the server socket). * Use this API in special cases, for example if your HTTP * server is behind NAT and needs to connect out to the * HTTP client. * * The given client socket will be managed (and closed!) by MHD after * this call and must no longer be used directly by the application * afterwards. * * @param daemon daemon that manages the connection * @param client_socket socket to manage (MHD will expect * to receive an HTTP request from this socket next). * @param addr IP address of the client * @param addrlen number of bytes in @a addr * @param external_add perform additional operations needed due * to the application calling us directly * @param non_blck indicate that socket in non-blocking mode * @param sk_spipe_supprs indicate that the @a client_socket has * set SIGPIPE suppression * @param sk_is_nonip _MHD_YES if this is not a TCP/IP socket * @return #MHD_YES on success, #MHD_NO if this daemon could * not handle the connection (i.e. malloc failed, etc). * The socket will be closed in any case; 'errno' is * set to indicate further details about the error. */ static enum MHD_Result internal_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr_storage *addr, socklen_t addrlen, bool external_add, bool non_blck, bool sk_spipe_supprs, enum MHD_tristate sk_is_nonip) { struct MHD_Connection *connection; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) /* Direct add to master daemon could never happen. */ mhd_assert (NULL == daemon->worker_pool); #endif if (MHD_D_IS_USING_SELECT_ (daemon) && (! MHD_D_DOES_SCKT_FIT_FDSET_ (client_socket, daemon)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("New connection socket descriptor (%d) is not less " \ "than FD_SETSIZE (%d).\n"), (int) client_socket, (int) MHD_D_GET_FD_SETSIZE_ (daemon)); #endif MHD_socket_close_chk_ (client_socket); #if defined(ENFILE) && (ENFILE + 0 != 0) errno = ENFILE; #endif return MHD_NO; } if (MHD_D_IS_USING_EPOLL_ (daemon) && (! non_blck) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Epoll mode supports only non-blocking sockets\n")); #endif MHD_socket_close_chk_ (client_socket); #if defined(EINVAL) && (EINVAL + 0 != 0) errno = EINVAL; #endif return MHD_NO; } connection = new_connection_prepare_ (daemon, client_socket, addr, addrlen, external_add, non_blck, sk_spipe_supprs, sk_is_nonip); if (NULL == connection) return MHD_NO; if ((external_add) && MHD_D_IS_THREAD_SAFE_ (daemon)) { /* Connection is added externally and MHD is thread safe mode. */ MHD_mutex_lock_chk_ (&daemon->new_connections_mutex); DLL_insert (daemon->new_connections_head, daemon->new_connections_tail, connection); daemon->have_new = true; MHD_mutex_unlock_chk_ (&daemon->new_connections_mutex); /* The rest of connection processing must be handled in * the daemon thread. */ if ((MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "n"))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to signal new connection via inter-thread " \ "communication channel.\n")); #endif } return MHD_YES; } return new_connection_process_ (daemon, connection); } static void new_connections_list_process_ (struct MHD_Daemon *daemon) { struct MHD_Connection *local_head; struct MHD_Connection *local_tail; mhd_assert (daemon->have_new); mhd_assert (MHD_D_IS_THREAD_SAFE_ (daemon)); /* Detach DL-list of new connections from the daemon for * following local processing. */ MHD_mutex_lock_chk_ (&daemon->new_connections_mutex); mhd_assert (NULL != daemon->new_connections_head); local_head = daemon->new_connections_head; local_tail = daemon->new_connections_tail; daemon->new_connections_head = NULL; daemon->new_connections_tail = NULL; daemon->have_new = false; MHD_mutex_unlock_chk_ (&daemon->new_connections_mutex); (void) local_head; /* Mute compiler warning */ /* Process new connections in FIFO order. */ do { struct MHD_Connection *c; /**< Currently processed connection */ c = local_tail; DLL_remove (local_head, local_tail, c); mhd_assert (daemon == c->daemon); if (MHD_NO == new_connection_process_ (daemon, c)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to start serving new connection.\n")); #endif (void) 0; } } while (NULL != local_tail); } /** * Internal version of ::MHD_suspend_connection(). * * @remark In thread-per-connection mode: can be called from any thread, * in any other mode: to be called only from thread that process * daemon's select()/poll()/etc. * * @param connection the connection to suspend */ void internal_suspend_connection_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; mhd_assert (NULL == daemon->worker_pool); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif if (connection->resuming) { /* suspending again while we didn't even complete resuming yet */ connection->resuming = false; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif return; } if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { if (connection->connection_timeout_ms == daemon->connection_timeout_ms) XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); else XDLL_remove (daemon->manual_timeout_head, daemon->manual_timeout_tail, connection); } DLL_remove (daemon->connections_head, daemon->connections_tail, connection); mhd_assert (! connection->suspended); DLL_insert (daemon->suspended_connections_head, daemon->suspended_connections_tail, connection); connection->suspended = true; #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon)) { if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) { EDLL_remove (daemon->eready_head, daemon->eready_tail, connection); connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_IN_EREADY_EDLL); } if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) { if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, connection->socket_fd, NULL)) MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_IN_EPOLL_SET); } connection->epoll_state |= MHD_EPOLL_STATE_SUSPENDED; } #endif #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif } /** * Suspend handling of network data for a given connection. * This can be used to dequeue a connection from MHD's event loop * (not applicable to thread-per-connection!) for a while. * * If you use this API in conjunction with an "internal" socket polling, * you must set the option #MHD_USE_ITC to ensure that a resumed * connection is immediately processed by MHD. * * Suspended connections continue to count against the total number of * connections allowed (per daemon, as well as per IP, if such limits * are set). Suspended connections will NOT time out; timeouts will * restart when the connection handling is resumed. While a * connection is suspended, MHD will not detect disconnects by the * client. * * The only safe way to call this function is to call it from the * #MHD_AccessHandlerCallback or #MHD_ContentReaderCallback. * * Finally, it is an API violation to call #MHD_stop_daemon while * having suspended connections (this will at least create memory and * socket leaks or lead to undefined behavior). You must explicitly * resume all connections before stopping the daemon. * * @param connection the connection to suspend * * @sa #MHD_AccessHandlerCallback */ _MHD_EXTERN void MHD_suspend_connection (struct MHD_Connection *connection) { struct MHD_Daemon *const daemon = connection->daemon; #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); #endif /* MHD_USE_THREADS */ if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) MHD_PANIC (_ ("Cannot suspend connections without " \ "enabling MHD_ALLOW_SUSPEND_RESUME!\n")); #ifdef UPGRADE_SUPPORT if (NULL != connection->urh) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Error: connection scheduled for \"upgrade\" cannot " \ "be suspended.\n")); #endif /* HAVE_MESSAGES */ return; } #endif /* UPGRADE_SUPPORT */ internal_suspend_connection_ (connection); } /** * Resume handling of network data for suspended connection. It is * safe to resume a suspended connection at any time. Calling this * function on a connection that was not previously suspended will * result in undefined behavior. * * If you are using this function in "external" sockets polling mode, you must * make sure to run #MHD_run() and #MHD_get_timeout() afterwards (before * again calling #MHD_get_fdset()), as otherwise the change may not be * reflected in the set returned by #MHD_get_fdset() and you may end up * with a connection that is stuck until the next network activity. * * @param connection the connection to resume */ _MHD_EXTERN void MHD_resume_connection (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; #if defined(MHD_USE_THREADS) mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) MHD_PANIC (_ ("Cannot resume connections without enabling " \ "MHD_ALLOW_SUSPEND_RESUME!\n")); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif connection->resuming = true; daemon->resuming = true; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "r")) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to signal resume via inter-thread " \ "communication channel.\n")); #endif } } #ifdef UPGRADE_SUPPORT /** * Mark upgraded connection as closed by application. * * The @a connection pointer must not be used after call of this function * as it may be freed in other thread immediately. * @param connection the upgraded connection to mark as closed by application */ void MHD_upgraded_connection_mark_app_closed_ (struct MHD_Connection *connection) { /* Cache 'daemon' here to avoid data races */ struct MHD_Daemon *const daemon = connection->daemon; #if defined(MHD_USE_THREADS) mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ mhd_assert (NULL != connection->urh); mhd_assert (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); connection->urh->was_closed = true; connection->resuming = true; daemon->resuming = true; MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "r")) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to signal resume via " \ "inter-thread communication channel.\n")); #endif } } #endif /* UPGRADE_SUPPORT */ /** * Run through the suspended connections and move any that are no * longer suspended back to the active state. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon daemon context * @return #MHD_YES if a connection was actually resumed */ static enum MHD_Result resume_suspended_connections (struct MHD_Daemon *daemon) { struct MHD_Connection *pos; struct MHD_Connection *prev = NULL; enum MHD_Result ret; const bool used_thr_p_c = (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) mhd_assert (NULL == daemon->worker_pool); mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); #endif ret = MHD_NO; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif if (daemon->resuming) { prev = daemon->suspended_connections_tail; /* During shutdown check for resuming is forced. */ mhd_assert ((NULL != prev) || (daemon->shutdown) || \ (0 != (daemon->options & MHD_ALLOW_UPGRADE))); } daemon->resuming = false; while (NULL != (pos = prev)) { #ifdef UPGRADE_SUPPORT struct MHD_UpgradeResponseHandle *const urh = pos->urh; #else /* ! UPGRADE_SUPPORT */ static const void *const urh = NULL; #endif /* ! UPGRADE_SUPPORT */ prev = pos->prev; if ( (! pos->resuming) #ifdef UPGRADE_SUPPORT || ( (NULL != urh) && ( (! urh->was_closed) || (! urh->clean_ready) ) ) #endif /* UPGRADE_SUPPORT */ ) continue; ret = MHD_YES; mhd_assert (pos->suspended); DLL_remove (daemon->suspended_connections_head, daemon->suspended_connections_tail, pos); pos->suspended = false; if (NULL == urh) { DLL_insert (daemon->connections_head, daemon->connections_tail, pos); if (! used_thr_p_c) { /* Reset timeout timer on resume. */ if (0 != pos->connection_timeout_ms) pos->last_activity = MHD_monotonic_msec_counter (); if (pos->connection_timeout_ms == daemon->connection_timeout_ms) XDLL_insert (daemon->normal_timeout_head, daemon->normal_timeout_tail, pos); else XDLL_insert (daemon->manual_timeout_head, daemon->manual_timeout_tail, pos); } #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon)) { if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) MHD_PANIC ("Resumed connection was already in EREADY set.\n"); /* we always mark resumed connections as ready, as we might have missed the edge poll event during suspension */ EDLL_insert (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL \ | MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY; pos->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_SUSPENDED); } #endif } #ifdef UPGRADE_SUPPORT else { /* Data forwarding was finished (for TLS connections) AND * application was closed upgraded connection. * Insert connection into cleanup list. */ if ( (NULL != daemon->notify_completed) && (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) && (pos->rq.client_aware) ) { daemon->notify_completed (daemon->notify_completed_cls, pos, &pos->rq.client_context, MHD_REQUEST_TERMINATED_COMPLETED_OK); pos->rq.client_aware = false; } DLL_insert (daemon->cleanup_head, daemon->cleanup_tail, pos); daemon->data_already_pending = true; } #endif /* UPGRADE_SUPPORT */ pos->resuming = false; } #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif if ( (used_thr_p_c) && (MHD_NO != ret) ) { /* Wake up suspended connections. */ if (! MHD_itc_activate_ (daemon->itc, "w")) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to signal resume of connection via " \ "inter-thread communication channel.\n")); #endif } } return ret; } /** * Add another client connection to the set of connections managed by * MHD. This API is usually not needed (since MHD will accept inbound * connections on the server socket). Use this API in special cases, * for example if your HTTP server is behind NAT and needs to connect * out to the HTTP client, or if you are building a proxy. * * If you use this API in conjunction with a internal select or a * thread pool, you must set the option * #MHD_USE_ITC to ensure that the freshly added * connection is immediately processed by MHD. * * The given client socket will be managed (and closed!) by MHD after * this call and must no longer be used directly by the application * afterwards. * * @param daemon daemon that manages the connection * @param client_socket socket to manage (MHD will expect * to receive an HTTP request from this socket next). * @param addr IP address of the client * @param addrlen number of bytes in @a addr * @return #MHD_YES on success, #MHD_NO if this daemon could * not handle the connection (i.e. malloc() failed, etc). * The socket will be closed in any case; `errno` is * set to indicate further details about the error. * @ingroup specialized */ _MHD_EXTERN enum MHD_Result MHD_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen) { bool sk_nonbl; bool sk_spipe_supprs; struct sockaddr_storage addrstorage; /* TODO: fix atomic value reading */ if ((! MHD_D_IS_THREAD_SAFE_ (daemon)) && (daemon->connection_limit <= daemon->connections)) MHD_cleanup_connections (daemon); #ifdef HAVE_MESSAGES if (MHD_D_IS_USING_THREADS_ (daemon) && (0 == (daemon->options & MHD_USE_ITC))) { MHD_DLOG (daemon, _ ("MHD_add_connection() has been called for daemon started" " without MHD_USE_ITC flag.\nDaemon will not process newly" " added connection until any activity occurs in already" " added sockets.\n")); } #endif /* HAVE_MESSAGES */ if (0 != addrlen) { if (AF_INET == addr->sa_family) { if (sizeof(struct sockaddr_in) > (size_t) addrlen) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD_add_connection() has been called with " "incorrect 'addrlen' value.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN if ((0 != addr->sa_len) && (sizeof(struct sockaddr_in) > (size_t) addr->sa_len) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD_add_connection() has been called with " \ "non-zero value of 'sa_len' member of " \ "'struct sockaddr' which does not match 'sa_family'.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ } #ifdef HAVE_INET6 if (AF_INET6 == addr->sa_family) { if (sizeof(struct sockaddr_in6) > (size_t) addrlen) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD_add_connection() has been called with " "incorrect 'addrlen' value.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN if ((0 != addr->sa_len) && (sizeof(struct sockaddr_in6) > (size_t) addr->sa_len) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD_add_connection() has been called with " \ "non-zero value of 'sa_len' member of " \ "'struct sockaddr' which does not match 'sa_family'.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ } #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN if ((0 != addr->sa_len) && (addrlen > addr->sa_len)) addrlen = (socklen_t) addr->sa_len; /* Use safest value */ #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ #endif /* HAVE_INET6 */ } if (! MHD_socket_nonblocking_ (client_socket)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to set nonblocking mode on new client socket: %s\n"), MHD_socket_last_strerr_ ()); #endif sk_nonbl = false; } else sk_nonbl = true; #ifndef MHD_WINSOCK_SOCKETS sk_spipe_supprs = false; #else /* MHD_WINSOCK_SOCKETS */ sk_spipe_supprs = true; /* Nothing to suppress on W32 */ #endif /* MHD_WINSOCK_SOCKETS */ #if defined(MHD_socket_nosignal_) if (! sk_spipe_supprs) sk_spipe_supprs = MHD_socket_nosignal_ (client_socket); if (! sk_spipe_supprs) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to suppress SIGPIPE on new client socket: %s\n"), MHD_socket_last_strerr_ ()); #else /* ! HAVE_MESSAGES */ (void) 0; /* Mute compiler warning */ #endif /* ! HAVE_MESSAGES */ #ifndef MSG_NOSIGNAL /* Application expects that SIGPIPE will be suppressed, * but suppression failed and SIGPIPE cannot be suppressed with send(). */ if (! daemon->sigpipe_blocked) { int err = MHD_socket_get_error_ (); MHD_socket_close_ (client_socket); MHD_socket_fset_error_ (err); return MHD_NO; } #endif /* MSG_NOSIGNAL */ } #endif /* MHD_socket_nosignal_ */ if ( (0 != (daemon->options & MHD_USE_TURBO)) && (! MHD_socket_noninheritable_ (client_socket)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to set noninheritable mode on new client socket.\n")); #endif } /* Copy to sockaddr_storage structure to avoid alignment problems */ if (0 < addrlen) memcpy (&addrstorage, addr, (size_t) addrlen); #ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN addrstorage.ss_len = addrlen; /* Force set the right length */ #endif /* HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != daemon->worker_pool) { unsigned int i; /* have a pool, try to find a pool with capacity; we use the socket as the initial offset into the pool for load balancing */ for (i = 0; i < daemon->worker_pool_size; ++i) { struct MHD_Daemon *const worker = &daemon->worker_pool[(i + (unsigned int) client_socket) % daemon->worker_pool_size]; if (worker->connections < worker->connection_limit) return internal_add_connection (worker, client_socket, &addrstorage, addrlen, true, sk_nonbl, sk_spipe_supprs, _MHD_UNKNOWN); } /* all pools are at their connection limit, must refuse */ MHD_socket_close_chk_ (client_socket); #if defined(ENFILE) && (ENFILE + 0 != 0) errno = ENFILE; #endif return MHD_NO; } #endif /* MHD_USE_POSIX_THREADS || MHD_USE_W32_THREADS */ return internal_add_connection (daemon, client_socket, &addrstorage, addrlen, true, sk_nonbl, sk_spipe_supprs, _MHD_UNKNOWN); } /** * Accept an incoming connection and create the MHD_Connection object for * it. This function also enforces policy by way of checking with the * accept policy callback. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon handle with the listen socket * @return #MHD_YES on success (connections denied by policy or due * to 'out of memory' and similar errors) are still considered * successful as far as #MHD_accept_connection() is concerned); * a return code of #MHD_NO only refers to the actual * accept() system call. */ static enum MHD_Result MHD_accept_connection (struct MHD_Daemon *daemon) { struct sockaddr_storage addrstorage; socklen_t addrlen; MHD_socket s; MHD_socket fd; bool sk_nonbl; bool sk_spipe_supprs; bool sk_cloexec; enum MHD_tristate sk_non_ip; #if defined(_DEBUG) && defined (USE_ACCEPT4) const bool use_accept4 = ! daemon->avoid_accept4; #elif defined (USE_ACCEPT4) static const bool use_accept4 = true; #else /* ! USE_ACCEPT4 && ! _DEBUG */ static const bool use_accept4 = false; #endif /* ! USE_ACCEPT4 && ! _DEBUG */ #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ if ( (MHD_INVALID_SOCKET == (fd = daemon->listen_fd)) || (daemon->was_quiesced) ) return MHD_NO; addrlen = (socklen_t) sizeof (addrstorage); memset (&addrstorage, 0, (size_t) addrlen); #ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN addrstorage.ss_len = addrlen; #endif /* HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN */ /* Initialise with default values to avoid compiler warnings */ sk_nonbl = false; sk_spipe_supprs = false; sk_cloexec = false; s = MHD_INVALID_SOCKET; #ifdef USE_ACCEPT4 if (use_accept4 && (MHD_INVALID_SOCKET != (s = accept4 (fd, (struct sockaddr *) &addrstorage, &addrlen, SOCK_CLOEXEC_OR_ZERO | SOCK_NONBLOCK_OR_ZERO | SOCK_NOSIGPIPE_OR_ZERO)))) { sk_nonbl = (SOCK_NONBLOCK_OR_ZERO != 0); #ifndef MHD_WINSOCK_SOCKETS sk_spipe_supprs = (SOCK_NOSIGPIPE_OR_ZERO != 0); #else /* MHD_WINSOCK_SOCKETS */ sk_spipe_supprs = true; /* Nothing to suppress on W32 */ #endif /* MHD_WINSOCK_SOCKETS */ sk_cloexec = (SOCK_CLOEXEC_OR_ZERO != 0); } #endif /* USE_ACCEPT4 */ #if defined(_DEBUG) || ! defined(USE_ACCEPT4) if (! use_accept4 && (MHD_INVALID_SOCKET != (s = accept (fd, (struct sockaddr *) &addrstorage, &addrlen)))) { #ifdef MHD_ACCEPT_INHERIT_NONBLOCK sk_nonbl = daemon->listen_nonblk; #else /* ! MHD_ACCEPT_INHERIT_NONBLOCK */ sk_nonbl = false; #endif /* ! MHD_ACCEPT_INHERIT_NONBLOCK */ #ifndef MHD_WINSOCK_SOCKETS sk_spipe_supprs = false; #else /* MHD_WINSOCK_SOCKETS */ sk_spipe_supprs = true; /* Nothing to suppress on W32 */ #endif /* MHD_WINSOCK_SOCKETS */ sk_cloexec = false; } #endif /* _DEBUG || !USE_ACCEPT4 */ if (MHD_INVALID_SOCKET == s) { const int err = MHD_socket_get_error_ (); /* This could be a common occurrence with multiple worker threads */ if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINVAL_)) return MHD_NO; /* can happen during shutdown */ if (MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_ (err)) return MHD_NO; /* do not print error if client just disconnected early */ #ifdef HAVE_MESSAGES if (! MHD_SCKT_ERR_IS_EAGAIN_ (err) ) MHD_DLOG (daemon, _ ("Error accepting connection: %s\n"), MHD_socket_strerr_ (err)); #endif if (MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err) ) { /* system/process out of resources */ if (0 == daemon->connections) { #ifdef HAVE_MESSAGES /* Not setting 'at_limit' flag, as there is no way it would ever be cleared. Instead trying to produce bit fat ugly warning. */ MHD_DLOG (daemon, _ ("Hit process or system resource limit at FIRST " \ "connection. This is really bad as there is no sane " \ "way to proceed. Will try busy waiting for system " \ "resources to become magically available.\n")); #endif } else { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif daemon->at_limit = true; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Hit process or system resource limit at %u " \ "connections, temporarily suspending accept(). " \ "Consider setting a lower MHD_OPTION_CONNECTION_LIMIT.\n"), (unsigned int) daemon->connections); #endif } } return MHD_NO; } sk_non_ip = daemon->listen_is_unix; if (0 >= addrlen) { #ifdef HAVE_MESSAGES if (_MHD_NO != daemon->listen_is_unix) MHD_DLOG (daemon, _ ("Accepted socket has zero-length address. " "Processing the new socket as a socket with " \ "unknown type.\n")); #endif addrlen = 0; sk_non_ip = _MHD_YES; /* IP-type addresses have non-zero length */ } if (((socklen_t) sizeof (addrstorage)) < addrlen) { /* Should not happen as 'sockaddr_storage' must be large enough to * store any address supported by the system. */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Accepted socket address is larger than expected by " \ "system headers. Processing the new socket as a socket with " \ "unknown type.\n")); #endif addrlen = 0; sk_non_ip = _MHD_YES; /* IP-type addresses must fit */ } if (! sk_nonbl && ! MHD_socket_nonblocking_ (s)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to set nonblocking mode on incoming connection " \ "socket: %s\n"), MHD_socket_last_strerr_ ()); #else /* ! HAVE_MESSAGES */ (void) 0; /* Mute compiler warning */ #endif /* ! HAVE_MESSAGES */ } else sk_nonbl = true; if (! sk_cloexec && ! MHD_socket_noninheritable_ (s)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to set noninheritable mode on incoming connection " \ "socket.\n")); #else /* ! HAVE_MESSAGES */ (void) 0; /* Mute compiler warning */ #endif /* ! HAVE_MESSAGES */ } #if defined(MHD_socket_nosignal_) if (! sk_spipe_supprs && ! MHD_socket_nosignal_ (s)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to suppress SIGPIPE on incoming connection " \ "socket: %s\n"), MHD_socket_last_strerr_ ()); #else /* ! HAVE_MESSAGES */ (void) 0; /* Mute compiler warning */ #endif /* ! HAVE_MESSAGES */ #ifndef MSG_NOSIGNAL /* Application expects that SIGPIPE will be suppressed, * but suppression failed and SIGPIPE cannot be suppressed with send(). */ if (! daemon->sigpipe_blocked) { (void) MHD_socket_close_ (s); return MHD_NO; } #endif /* MSG_NOSIGNAL */ } else sk_spipe_supprs = true; #endif /* MHD_socket_nosignal_ */ #ifdef HAVE_MESSAGES #if _MHD_DEBUG_CONNECT MHD_DLOG (daemon, _ ("Accepted connection on socket %d\n"), s); #endif #endif (void) internal_add_connection (daemon, s, &addrstorage, addrlen, false, sk_nonbl, sk_spipe_supprs, sk_non_ip); return MHD_YES; } /** * Free resources associated with all closed connections. * (destroy responses, free buffers, etc.). All closed * connections are kept in the "cleanup" doubly-linked list. * @remark To be called only from thread that * process daemon's select()/poll()/etc. * * @param daemon daemon to clean up */ static void MHD_cleanup_connections (struct MHD_Daemon *daemon) { struct MHD_Connection *pos; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); mhd_assert (NULL == daemon->worker_pool); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif while (NULL != (pos = daemon->cleanup_tail)) { DLL_remove (daemon->cleanup_head, daemon->cleanup_tail, pos); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) && (! pos->thread_joined) && (! MHD_thread_handle_ID_join_thread_ (pos->tid)) ) MHD_PANIC (_ ("Failed to join a thread.\n")); #endif #ifdef UPGRADE_SUPPORT cleanup_upgraded_connection (pos); #endif /* UPGRADE_SUPPORT */ MHD_pool_destroy (pos->pool); #ifdef HTTPS_SUPPORT if (NULL != pos->tls_session) gnutls_deinit (pos->tls_session); #endif /* HTTPS_SUPPORT */ /* clean up the connection */ if (NULL != daemon->notify_connection) daemon->notify_connection (daemon->notify_connection_cls, pos, &pos->socket_context, MHD_CONNECTION_NOTIFY_CLOSED); MHD_ip_limit_del (daemon, pos->addr, pos->addr_len); #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon)) { if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) { EDLL_remove (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_IN_EREADY_EDLL); } if ( (-1 != daemon->epoll_fd) && (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) ) { /* epoll documentation suggests that closing a FD automatically removes it from the epoll set; however, this is not true as if we fail to do manually remove it, we are still seeing an event for this fd in epoll, causing grief (use-after-free...) --- at least on my system. */ if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, pos->socket_fd, NULL)) MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); pos->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_IN_EPOLL_SET); } } #endif if (NULL != pos->rp.response) { MHD_destroy_response (pos->rp.response); pos->rp.response = NULL; } if (MHD_INVALID_SOCKET != pos->socket_fd) MHD_socket_close_chk_ (pos->socket_fd); if (NULL != pos->addr) free (pos->addr); free (pos); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif daemon->connections--; daemon->at_limit = false; } #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif } /** * Obtain timeout value for polling function for this daemon. * * This function set value to the amount of milliseconds for which polling * function (`select()`, `poll()` or epoll) should at most block, not the * timeout value set for connections. * * Any "external" sockets polling function must be called with the timeout * value provided by this function. Smaller timeout values can be used for * polling function if it is required for any reason, but using larger * timeout value or no timeout (indefinite timeout) when this function * return #MHD_YES will break MHD processing logic and result in "hung" * connections with data pending in network buffers and other problems. * * It is important to always use this function (or #MHD_get_timeout64(), * #MHD_get_timeout64s(), #MHD_get_timeout_i() functions) when "external" * polling is used. * If this function returns #MHD_YES then #MHD_run() (or #MHD_run_from_select()) * must be called right after return from polling function, regardless of * the states of MHD FDs. * * In practice, if #MHD_YES is returned then #MHD_run() (or * #MHD_run_from_select()) must be called not later than @a timeout * millisecond even if no activity is detected on sockets by sockets * polling function. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon daemon to query for timeout * @param[out] timeout set to the timeout (in milliseconds) * @return #MHD_YES on success, #MHD_NO if timeouts are * not used and no data processing is pending. * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_get_timeout (struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout) { uint64_t t64; if (MHD_NO == MHD_get_timeout64 (daemon, &t64)) return MHD_NO; #if SIZEOF_UINT64_T > SIZEOF_UNSIGNED_LONG_LONG if (ULLONG_MAX <= t64) *timeout = ULLONG_MAX; else #endif /* SIZEOF_UINT64_T > SIZEOF_UNSIGNED_LONG_LONG */ *timeout = (MHD_UNSIGNED_LONG_LONG) t64; return MHD_YES; } /** * Obtain timeout value for external polling function for this daemon. * * This function set value to the amount of milliseconds for which polling * function (`select()`, `poll()` or epoll) should at most block, not the * timeout value set for connections. * * Any "external" sockets polling function must be called with the timeout * value provided by this function. Smaller timeout values can be used for * polling function if it is required for any reason, but using larger * timeout value or no timeout (indefinite timeout) when this function * return #MHD_YES will break MHD processing logic and result in "hung" * connections with data pending in network buffers and other problems. * * It is important to always use this function (or #MHD_get_timeout(), * #MHD_get_timeout64s(), #MHD_get_timeout_i() functions) when "external" * polling is used. * If this function returns #MHD_YES then #MHD_run() (or #MHD_run_from_select()) * must be called right after return from polling function, regardless of * the states of MHD FDs. * * In practice, if #MHD_YES is returned then #MHD_run() (or * #MHD_run_from_select()) must be called not later than @a timeout * millisecond even if no activity is detected on sockets by sockets * polling function. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon daemon to query for timeout * @param[out] timeout64 the pointer to the variable to be set to the * timeout (in milliseconds) * @return #MHD_YES if timeout value has been set, * #MHD_NO if timeouts are not used and no data processing is pending. * @note Available since #MHD_VERSION 0x00097701 * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_get_timeout64 (struct MHD_Daemon *daemon, uint64_t *timeout64) { uint64_t earliest_deadline; struct MHD_Connection *pos; struct MHD_Connection *earliest_tmot_conn; /**< the connection with earliest timeout */ #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); #endif /* MHD_USE_THREADS */ if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Illegal call to MHD_get_timeout.\n")); #endif return MHD_NO; } if (daemon->data_already_pending || (NULL != daemon->cleanup_head) || daemon->resuming || daemon->have_new || daemon->shutdown) { /* Some data or connection statuses already waiting to be processed. */ *timeout64 = 0; return MHD_YES; } #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon) && ((NULL != daemon->eready_head) #if defined(UPGRADE_SUPPORT) && defined(HTTPS_SUPPORT) || (NULL != daemon->eready_urh_head) #endif /* UPGRADE_SUPPORT && HTTPS_SUPPORT */ ) ) { /* Some connection(s) already have some data pending. */ *timeout64 = 0; return MHD_YES; } #endif /* EPOLL_SUPPORT */ earliest_tmot_conn = NULL; earliest_deadline = 0; /* mute compiler warning */ /* normal timeouts are sorted, so we only need to look at the 'tail' (oldest) */ pos = daemon->normal_timeout_tail; if ( (NULL != pos) && (0 != pos->connection_timeout_ms) ) { earliest_tmot_conn = pos; earliest_deadline = pos->last_activity + pos->connection_timeout_ms; } for (pos = daemon->manual_timeout_tail; NULL != pos; pos = pos->prevX) { if (0 != pos->connection_timeout_ms) { if ( (NULL == earliest_tmot_conn) || (earliest_deadline - pos->last_activity > pos->connection_timeout_ms) ) { earliest_tmot_conn = pos; earliest_deadline = pos->last_activity + pos->connection_timeout_ms; } } } if (NULL != earliest_tmot_conn) { *timeout64 = connection_get_wait (earliest_tmot_conn); return MHD_YES; } return MHD_NO; } #if defined(HAVE_POLL) || defined(EPOLL_SUPPORT) /** * Obtain timeout value for external polling function for this daemon. * * This function set value to the amount of milliseconds for which polling * function (`select()`, `poll()` or epoll) should at most block, not the * timeout value set for connections. * * Any "external" sockets polling function must be called with the timeout * value provided by this function (if returned value is non-negative). * Smaller timeout values can be used for polling function if it is required * for any reason, but using larger timeout value or no timeout (indefinite * timeout) when this function returns non-negative value will break MHD * processing logic and result in "hung" connections with data pending in * network buffers and other problems. * * It is important to always use this function (or #MHD_get_timeout(), * #MHD_get_timeout64(), #MHD_get_timeout_i() functions) when "external" * polling is used. * If this function returns non-negative value then #MHD_run() (or * #MHD_run_from_select()) must be called right after return from polling * function, regardless of the states of MHD FDs. * * In practice, if zero or positive value is returned then #MHD_run() (or * #MHD_run_from_select()) must be called not later than returned amount of * millisecond even if no activity is detected on sockets by sockets * polling function. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon the daemon to query for timeout * @return -1 if connections' timeouts are not set and no data processing * is pending, so external polling function may wait for sockets * activity for indefinite amount of time, * otherwise returned value is the the maximum amount of millisecond * that external polling function must wait for the activity of FDs. * @note Available since #MHD_VERSION 0x00097701 * @ingroup event */ _MHD_EXTERN int64_t MHD_get_timeout64s (struct MHD_Daemon *daemon) { uint64_t utimeout; if (MHD_NO == MHD_get_timeout64 (daemon, &utimeout)) return -1; if (INT64_MAX < utimeout) return INT64_MAX; return (int64_t) utimeout; } /** * Obtain timeout value for external polling function for this daemon. * * This function set value to the amount of milliseconds for which polling * function (`select()`, `poll()` or epoll) should at most block, not the * timeout value set for connections. * * Any "external" sockets polling function must be called with the timeout * value provided by this function (if returned value is non-negative). * Smaller timeout values can be used for polling function if it is required * for any reason, but using larger timeout value or no timeout (indefinite * timeout) when this function returns non-negative value will break MHD * processing logic and result in "hung" connections with data pending in * network buffers and other problems. * * It is important to always use this function (or #MHD_get_timeout(), * #MHD_get_timeout64(), #MHD_get_timeout64s() functions) when "external" * polling is used. * If this function returns non-negative value then #MHD_run() (or * #MHD_run_from_select()) must be called right after return from polling * function, regardless of the states of MHD FDs. * * In practice, if zero or positive value is returned then #MHD_run() (or * #MHD_run_from_select()) must be called not later than returned amount of * millisecond even if no activity is detected on sockets by sockets * polling function. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon the daemon to query for timeout * @return -1 if connections' timeouts are not set and no data processing * is pending, so external polling function may wait for sockets * activity for indefinite amount of time, * otherwise returned value is the the maximum amount of millisecond * (capped at INT_MAX) that external polling function must wait * for the activity of FDs. * @note Available since #MHD_VERSION 0x00097701 * @ingroup event */ _MHD_EXTERN int MHD_get_timeout_i (struct MHD_Daemon *daemon) { #if SIZEOF_INT >= SIZEOF_INT64_T return MHD_get_timeout64s (daemon); #else /* SIZEOF_INT < SIZEOF_INT64_T */ const int64_t to64 = MHD_get_timeout64s (daemon); if (INT_MAX >= to64) return (int) to64; return INT_MAX; #endif /* SIZEOF_INT < SIZEOF_INT64_T */ } /** * Obtain timeout value for polling function for this daemon. * @remark To be called only from the thread that processes * daemon's select()/poll()/etc. * * @param daemon the daemon to query for timeout * @param max_timeout the maximum return value (in milliseconds), * ignored if set to '-1' * @return timeout value in milliseconds or -1 if no timeout is expected. */ static int64_t get_timeout_millisec_ (struct MHD_Daemon *daemon, int32_t max_timeout) { uint64_t d_timeout; mhd_assert (0 <= max_timeout || -1 == max_timeout); if (0 == max_timeout) return 0; if (MHD_NO == MHD_get_timeout64 (daemon, &d_timeout)) return max_timeout; if ((0 < max_timeout) && ((uint64_t) max_timeout < d_timeout)) return max_timeout; if (INT64_MAX <= d_timeout) return INT64_MAX; return (int64_t) d_timeout; } /** * Obtain timeout value for polling function for this daemon. * @remark To be called only from the thread that processes * daemon's select()/poll()/etc. * * @param daemon the daemon to query for timeout * @param max_timeout the maximum return value (in milliseconds), * ignored if set to '-1' * @return timeout value in milliseconds, capped to INT_MAX, or * -1 if no timeout is expected. */ static int get_timeout_millisec_int (struct MHD_Daemon *daemon, int32_t max_timeout) { int64_t res; res = get_timeout_millisec_ (daemon, max_timeout); #if SIZEOF_INT < SIZEOF_INT64_T if (INT_MAX <= res) return INT_MAX; #endif /* SIZEOF_INT < SIZEOF_INT64_T */ return (int) res; } #endif /* HAVE_POLL || EPOLL_SUPPORT */ /** * Internal version of #MHD_run_from_select(). * * @param daemon daemon to run select loop for * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @param fd_setsize value of FD_SETSIZE used when fd_sets were created * @return #MHD_NO on serious errors, #MHD_YES on success * @ingroup event */ static enum MHD_Result internal_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set, int fd_setsize) { MHD_socket ds; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) struct MHD_UpgradeResponseHandle *urh; struct MHD_UpgradeResponseHandle *urhn; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (MHD_thread_handle_ID_is_valid_ID_ (daemon->tid))); mhd_assert ((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (! MHD_thread_handle_ID_is_valid_ID_ (daemon->tid))); mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (MHD_thread_handle_ID_is_current_thread_ (daemon->tid))); mhd_assert (0 < fd_setsize); (void) fd_setsize; /* Mute compiler warning */ #ifndef HAS_FD_SETSIZE_OVERRIDABLE (void) fd_setsize; /* Mute compiler warning */ mhd_assert (((int) FD_SETSIZE) <= fd_setsize); fd_setsize = FD_SETSIZE; /* Help compiler to optimise */ #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ /* Clear ITC to avoid spinning select */ /* Do it before any other processing so new signals will trigger select again and will be processed */ if (MHD_ITC_IS_VALID_ (daemon->itc)) { /* Have ITC */ bool need_to_clear_itc = true; /* ITC is always non-blocking, it is safe to clear even if ITC not activated */ if (MHD_SCKT_FD_FITS_FDSET_SETSIZE_ (MHD_itc_r_fd_ (daemon->itc), NULL, fd_setsize)) need_to_clear_itc = FD_ISSET (MHD_itc_r_fd_ (daemon->itc), \ (fd_set *) _MHD_DROP_CONST (read_fd_set)); /* Skip clearing, if not needed */ if (need_to_clear_itc) MHD_itc_clear_ (daemon->itc); } /* Reset. New value will be set when connections are processed. */ /* Note: no-op for thread-per-connection as it is always false in that mode. */ daemon->data_already_pending = false; /* Process externally added connection if any */ if (daemon->have_new) new_connections_list_process_ (daemon); /* select connection thread handling type */ ds = daemon->listen_fd; if ( (MHD_INVALID_SOCKET != ds) && (! daemon->was_quiesced) ) { bool need_to_accept; if (MHD_SCKT_FD_FITS_FDSET_SETSIZE_ (ds, NULL, fd_setsize)) need_to_accept = FD_ISSET (ds, (fd_set *) _MHD_DROP_CONST (read_fd_set)); else /* Cannot check whether new connection are pending */ need_to_accept = daemon->listen_nonblk; /* Try to accept if non-blocking */ if (need_to_accept) (void) MHD_accept_connection (daemon); } if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { /* do not have a thread per connection, process all connections now */ struct MHD_Connection *pos; for (pos = daemon->connections_tail; NULL != pos; pos = pos->prev) { MHD_socket cs; bool r_ready; bool w_ready; bool has_err; cs = pos->socket_fd; if (MHD_INVALID_SOCKET == cs) continue; if (MHD_SCKT_FD_FITS_FDSET_SETSIZE_ (cs, NULL, fd_setsize)) { r_ready = FD_ISSET (cs, (fd_set *) _MHD_DROP_CONST (read_fd_set)); w_ready = FD_ISSET (cs, (fd_set *) _MHD_DROP_CONST (write_fd_set)); has_err = (NULL != except_fd_set) && FD_ISSET (cs, (fd_set *) _MHD_DROP_CONST (except_fd_set)); } else { /* Cannot check the real readiness */ r_ready = pos->sk_nonblck; w_ready = r_ready; has_err = false; } call_handlers (pos, r_ready, w_ready, has_err); } } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /* handle upgraded HTTPS connections */ for (urh = daemon->urh_tail; NULL != urh; urh = urhn) { urhn = urh->prev; /* update urh state based on select() output */ urh_from_fdset (urh, read_fd_set, write_fd_set, except_fd_set, fd_setsize); /* call generic forwarding function for passing data */ process_urh (urh); /* Finished forwarding? */ if ( (0 == urh->in_buffer_size) && (0 == urh->out_buffer_size) && (0 == urh->in_buffer_used) && (0 == urh->out_buffer_used) ) { MHD_connection_finish_forward_ (urh->connection); urh->clean_ready = true; /* Resuming will move connection to cleanup list. */ MHD_resume_connection (urh->connection); } } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ MHD_cleanup_connections (daemon); return MHD_YES; } #undef MHD_run_from_select /** * Run webserver operations. This method should be called by clients * in combination with #MHD_get_fdset and #MHD_get_timeout() if the * client-controlled select method is used. * This function specifies FD_SETSIZE used when provided fd_sets were * created. It is important on platforms where FD_SETSIZE can be * overridden. * * You can use this function instead of #MHD_run if you called * 'select()' on the result from #MHD_get_fdset2(). File descriptors in * the sets that are not controlled by MHD will be ignored. Calling * this function instead of #MHD_run() is more efficient as MHD will * not have to call 'select()' again to determine which operations are * ready. * * If #MHD_get_timeout() returned #MHD_YES, than this function must be * called right after 'select()' returns regardless of detected activity * on the daemon's FDs. * * This function cannot be used with daemon started with * #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon the daemon to run select loop for * @param read_fd_set the read set * @param write_fd_set the write set * @param except_fd_set the except set * @param fd_setsize the value of FD_SETSIZE * @return #MHD_NO on serious errors, #MHD_YES on success * @sa #MHD_get_fdset2(), #MHD_OPTION_APP_FD_SETSIZE * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_run_from_select2 (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set, unsigned int fd_setsize) { if (MHD_D_IS_USING_POLL_ (daemon) || MHD_D_IS_USING_THREADS_ (daemon)) return MHD_NO; if ((NULL == read_fd_set) || (NULL == write_fd_set)) return MHD_NO; #ifdef HAVE_MESSAGES if (NULL == except_fd_set) { MHD_DLOG (daemon, _ ("MHD_run_from_select() called with except_fd_set " "set to NULL. Such behavior is deprecated.\n")); } #endif /* HAVE_MESSAGES */ #ifdef HAS_FD_SETSIZE_OVERRIDABLE if (0 == fd_setsize) return MHD_NO; else if (((unsigned int) INT_MAX) < fd_setsize) fd_setsize = (unsigned int) INT_MAX; #ifdef HAVE_MESSAGES else if (daemon->fdset_size > ((int) fd_setsize)) { if (daemon->fdset_size_set_by_app) { MHD_DLOG (daemon, _ ("%s() called with fd_setsize (%u) " \ "less than value set by MHD_OPTION_APP_FD_SETSIZE (%d). " \ "Some socket FDs may be not processed. " \ "Use MHD_OPTION_APP_FD_SETSIZE with the correct value.\n"), "MHD_run_from_select2", fd_setsize, daemon->fdset_size); } else { MHD_DLOG (daemon, _ ("%s() called with fd_setsize (%u) " \ "less than FD_SETSIZE used by MHD (%d). " \ "Some socket FDs may be not processed. " \ "Consider using MHD_OPTION_APP_FD_SETSIZE option.\n"), "MHD_run_from_select2", fd_setsize, daemon->fdset_size); } } #endif /* HAVE_MESSAGES */ #else /* ! HAS_FD_SETSIZE_OVERRIDABLE */ if (((unsigned int) FD_SETSIZE) > fd_setsize) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("%s() called with fd_setsize (%u) " \ "less than fixed FD_SETSIZE value (%d) used on the " \ "platform.\n"), "MHD_run_from_select2", fd_setsize, (int) FD_SETSIZE); #endif /* HAVE_MESSAGES */ return MHD_NO; } #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ if (MHD_D_IS_USING_EPOLL_ (daemon)) { #ifdef EPOLL_SUPPORT enum MHD_Result ret = MHD_epoll (daemon, 0); MHD_cleanup_connections (daemon); return ret; #else /* ! EPOLL_SUPPORT */ return MHD_NO; #endif /* ! EPOLL_SUPPORT */ } /* Resuming external connections when using an extern mainloop */ if (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) resume_suspended_connections (daemon); return internal_run_from_select (daemon, read_fd_set, write_fd_set, except_fd_set, (int) fd_setsize); } /** * Run webserver operations. This method should be called by clients * in combination with #MHD_get_fdset and #MHD_get_timeout() if the * client-controlled select method is used. * * You can use this function instead of #MHD_run if you called * `select()` on the result from #MHD_get_fdset. File descriptors in * the sets that are not controlled by MHD will be ignored. Calling * this function instead of #MHD_run is more efficient as MHD will * not have to call `select()` again to determine which operations are * ready. * * If #MHD_get_timeout() returned #MHD_YES, than this function must be * called right after `select()` returns regardless of detected activity * on the daemon's FDs. * * This function cannot be used with daemon started with * #MHD_USE_INTERNAL_POLLING_THREAD flag. * * @param daemon daemon to run select loop for * @param read_fd_set read set * @param write_fd_set write set * @param except_fd_set except set * @return #MHD_NO on serious errors, #MHD_YES on success * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set) { return MHD_run_from_select2 (daemon, read_fd_set, write_fd_set, except_fd_set, #ifdef HAS_FD_SETSIZE_OVERRIDABLE daemon->fdset_size_set_by_app ? ((unsigned int) daemon->fdset_size) : ((unsigned int) _MHD_SYS_DEFAULT_FD_SETSIZE) #else /* ! HAS_FD_SETSIZE_OVERRIDABLE */ ((unsigned int) _MHD_SYS_DEFAULT_FD_SETSIZE) #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ ); } /** * Main internal select() call. Will compute select sets, call select() * and then #internal_run_from_select with the result. * * @param daemon daemon to run select() loop for * @param millisec the maximum time in milliseconds to wait for events, * set to '0' for non-blocking processing, * set to '-1' to wait indefinitely. * @return #MHD_NO on serious errors, #MHD_YES on success */ static enum MHD_Result MHD_select (struct MHD_Daemon *daemon, int32_t millisec) { int num_ready; fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock; struct timeval timeout; struct timeval *tv; int err_state; MHD_socket ls; timeout.tv_sec = 0; timeout.tv_usec = 0; if (daemon->shutdown) return MHD_NO; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); maxsock = MHD_INVALID_SOCKET; err_state = MHD_NO; if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) && (MHD_NO != resume_suspended_connections (daemon)) && (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) ) millisec = 0; if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { /* single-threaded, go over everything */ if (MHD_NO == internal_get_fdset2 (daemon, &rs, &ws, &es, &maxsock, (int) FD_SETSIZE)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Could not obtain daemon fdsets.\n")); #endif err_state = MHD_YES; } } else { bool itc_added; /* accept only, have one thread per connection */ itc_added = false; if (MHD_ITC_IS_VALID_ (daemon->itc)) { itc_added = MHD_add_to_fd_set_ (MHD_itc_r_fd_ (daemon->itc), &rs, &maxsock, (int) FD_SETSIZE); if (! itc_added) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Could not add control inter-thread " \ "communication channel FD to fdset.\n")); #endif err_state = MHD_YES; } } if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) && (! daemon->was_quiesced) ) { /* Stop listening if we are at the configured connection limit */ /* If we're at the connection limit, no point in really accepting new connections; however, make sure we do not miss the shutdown OR the termination of an existing connection; so only do this optimisation if we have a signaling ITC in place. */ if (! itc_added || ((daemon->connections < daemon->connection_limit) && ! daemon->at_limit)) { if (! MHD_add_to_fd_set_ (ls, &rs, &maxsock, (int) FD_SETSIZE)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Could not add listen socket to fdset.\n")); #endif err_state = MHD_YES; } } } } if (MHD_NO != err_state) millisec = 0; if (0 == millisec) { timeout.tv_usec = 0; timeout.tv_sec = 0; tv = &timeout; } else { uint64_t mhd_tmo; uint64_t select_tmo; if ( (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) && (MHD_NO != MHD_get_timeout64 (daemon, &mhd_tmo)) ) { if ( (0 < millisec) && (mhd_tmo > (uint64_t) millisec) ) select_tmo = (uint64_t) millisec; else select_tmo = mhd_tmo; tv = &timeout; /* have timeout value */ } else if (0 < millisec) { select_tmo = (uint64_t) millisec; tv = &timeout; /* have timeout value */ } else { select_tmo = 0; /* Not actually used, silent compiler warning */ tv = NULL; } if (NULL != tv) { /* have timeout value */ #if (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC if (select_tmo / 1000 > TIMEVAL_TV_SEC_MAX) timeout.tv_sec = TIMEVAL_TV_SEC_MAX; else #endif /* (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC */ timeout.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) (select_tmo / 1000); timeout.tv_usec = ((uint16_t) (select_tmo % 1000)) * ((int32_t) 1000); } } num_ready = MHD_SYS_select_ (maxsock + 1, &rs, &ws, &es, tv); if (daemon->shutdown) return MHD_NO; if (num_ready < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) return (MHD_NO == err_state) ? MHD_YES : MHD_NO; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("select failed: %s\n"), MHD_socket_strerr_ (err)); #endif return MHD_NO; } if (MHD_NO != internal_run_from_select (daemon, &rs, &ws, &es, (int) FD_SETSIZE)) return (MHD_NO == err_state) ? MHD_YES : MHD_NO; return MHD_NO; } #ifdef HAVE_POLL /** * Process all of our connections and possibly the server * socket using poll(). * * @param daemon daemon to run poll loop for * @param millisec the maximum time in milliseconds to wait for events, * set to '0' for non-blocking processing, * set to '-1' to wait indefinitely. * @return #MHD_NO on serious errors, #MHD_YES on success */ static enum MHD_Result MHD_poll_all (struct MHD_Daemon *daemon, int32_t millisec) { unsigned int num_connections; struct MHD_Connection *pos; struct MHD_Connection *prev; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) struct MHD_UpgradeResponseHandle *urh; struct MHD_UpgradeResponseHandle *urhn; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (MHD_thread_handle_ID_is_valid_ID_ (daemon->tid))); mhd_assert ((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (! MHD_thread_handle_ID_is_valid_ID_ (daemon->tid))); mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (MHD_thread_handle_ID_is_current_thread_ (daemon->tid))); if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) && (MHD_NO != resume_suspended_connections (daemon)) ) millisec = 0; /* count number of connections and thus determine poll set size */ num_connections = 0; for (pos = daemon->connections_head; NULL != pos; pos = pos->next) num_connections++; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) for (urh = daemon->urh_head; NULL != urh; urh = urh->next) num_connections += 2; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ { unsigned int i; int timeout; unsigned int poll_server; int poll_listen; int poll_itc_idx; struct pollfd *p; MHD_socket ls; p = MHD_calloc_ ((2 + (size_t) num_connections), sizeof (struct pollfd)); if (NULL == p) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Error allocating memory: %s\n"), MHD_strerror_ (errno)); #endif return MHD_NO; } poll_server = 0; poll_listen = -1; if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) && (! daemon->was_quiesced) && (daemon->connections < daemon->connection_limit) && (! daemon->at_limit) ) { /* only listen if we are not at the connection limit */ p[poll_server].fd = ls; p[poll_server].events = POLLIN; p[poll_server].revents = 0; poll_listen = (int) poll_server; poll_server++; } poll_itc_idx = -1; if (MHD_ITC_IS_VALID_ (daemon->itc)) { p[poll_server].fd = MHD_itc_r_fd_ (daemon->itc); p[poll_server].events = POLLIN; p[poll_server].revents = 0; poll_itc_idx = (int) poll_server; poll_server++; } timeout = get_timeout_millisec_int (daemon, millisec); i = 0; for (pos = daemon->connections_tail; NULL != pos; pos = pos->prev) { p[poll_server + i].fd = pos->socket_fd; switch (pos->event_loop_info) { case MHD_EVENT_LOOP_INFO_READ: case MHD_EVENT_LOOP_INFO_PROCESS_READ: p[poll_server + i].events |= POLLIN | MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_WRITE: p[poll_server + i].events |= POLLOUT | MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_PROCESS: p[poll_server + i].events |= MHD_POLL_EVENTS_ERR_DISC; break; case MHD_EVENT_LOOP_INFO_CLEANUP: timeout = 0; /* clean up "pos" immediately */ break; } i++; } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) for (urh = daemon->urh_tail; NULL != urh; urh = urh->prev) { urh_to_pollfd (urh, &(p[poll_server + i])); i += 2; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if (0 == poll_server + num_connections) { free (p); return MHD_YES; } if (MHD_sys_poll_ (p, poll_server + num_connections, timeout) < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) { free (p); return MHD_YES; } #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("poll failed: %s\n"), MHD_socket_strerr_ (err)); #endif free (p); return MHD_NO; } /* handle ITC FD */ /* do it before any other processing so new signals will be processed in next loop */ if ( (-1 != poll_itc_idx) && (0 != (p[poll_itc_idx].revents & POLLIN)) ) MHD_itc_clear_ (daemon->itc); /* handle shutdown */ if (daemon->shutdown) { free (p); return MHD_NO; } /* Process externally added connection if any */ if (daemon->have_new) new_connections_list_process_ (daemon); /* handle 'listen' FD */ if ( (-1 != poll_listen) && (0 != (p[poll_listen].revents & POLLIN)) ) (void) MHD_accept_connection (daemon); /* Reset. New value will be set when connections are processed. */ daemon->data_already_pending = false; i = 0; prev = daemon->connections_tail; while (NULL != (pos = prev)) { prev = pos->prev; /* first, sanity checks */ if (i >= num_connections) break; /* connection list changed somehow, retry later ... */ if (p[poll_server + i].fd != pos->socket_fd) continue; /* fd mismatch, something else happened, retry later ... */ call_handlers (pos, 0 != (p[poll_server + i].revents & POLLIN), 0 != (p[poll_server + i].revents & POLLOUT), 0 != (p[poll_server + i].revents & MHD_POLL_REVENTS_ERR_DISC)); i++; } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) for (urh = daemon->urh_tail; NULL != urh; urh = urhn) { if (i >= num_connections) break; /* connection list changed somehow, retry later ... */ /* Get next connection here as connection can be removed * from 'daemon->urh_head' list. */ urhn = urh->prev; /* Check for fd mismatch. FIXME: required for safety? */ if ((p[poll_server + i].fd != urh->connection->socket_fd) || (p[poll_server + i + 1].fd != urh->mhd.socket)) break; urh_from_pollfd (urh, &p[poll_server + i]); i += 2; process_urh (urh); /* Finished forwarding? */ if ( (0 == urh->in_buffer_size) && (0 == urh->out_buffer_size) && (0 == urh->in_buffer_used) && (0 == urh->out_buffer_used) ) { /* MHD_connection_finish_forward_() will remove connection from * 'daemon->urh_head' list. */ MHD_connection_finish_forward_ (urh->connection); urh->clean_ready = true; /* If 'urh->was_closed' already was set to true, connection will be * moved immediately to cleanup list. Otherwise connection * will stay in suspended list until 'urh' will be marked * with 'was_closed' by application. */ MHD_resume_connection (urh->connection); } } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ free (p); } return MHD_YES; } /** * Process only the listen socket using poll(). * * @param daemon daemon to run poll loop for * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking * @return #MHD_NO on serious errors, #MHD_YES on success */ static enum MHD_Result MHD_poll_listen_socket (struct MHD_Daemon *daemon, int may_block) { struct pollfd p[2]; int timeout; unsigned int poll_count; int poll_listen; int poll_itc_idx; MHD_socket ls; mhd_assert (MHD_thread_handle_ID_is_valid_ID_ (daemon->tid)); mhd_assert (MHD_thread_handle_ID_is_current_thread_ (daemon->tid)); memset (&p, 0, sizeof (p)); poll_count = 0; poll_listen = -1; poll_itc_idx = -1; if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) && (! daemon->was_quiesced) ) { p[poll_count].fd = ls; p[poll_count].events = POLLIN; p[poll_count].revents = 0; poll_listen = (int) poll_count; poll_count++; } if (MHD_ITC_IS_VALID_ (daemon->itc)) { p[poll_count].fd = MHD_itc_r_fd_ (daemon->itc); p[poll_count].events = POLLIN; p[poll_count].revents = 0; poll_itc_idx = (int) poll_count; poll_count++; } if (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) (void) resume_suspended_connections (daemon); if (MHD_NO == may_block) timeout = 0; else timeout = -1; if (0 == poll_count) return MHD_YES; if (MHD_sys_poll_ (p, poll_count, timeout) < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_YES; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("poll failed: %s\n"), MHD_socket_strerr_ (err)); #endif return MHD_NO; } if ( (0 <= poll_itc_idx) && (0 != (p[poll_itc_idx].revents & POLLIN)) ) MHD_itc_clear_ (daemon->itc); /* handle shutdown */ if (daemon->shutdown) return MHD_NO; /* Process externally added connection if any */ if (daemon->have_new) new_connections_list_process_ (daemon); if ( (0 <= poll_listen) && (0 != (p[poll_listen].revents & POLLIN)) ) (void) MHD_accept_connection (daemon); return MHD_YES; } #endif #ifdef HAVE_POLL /** * Do poll()-based processing. * * @param daemon daemon to run poll()-loop for * @param may_block #MHD_YES if blocking, #MHD_NO if non-blocking * @return #MHD_NO on serious errors, #MHD_YES on success */ static enum MHD_Result MHD_poll (struct MHD_Daemon *daemon, int may_block) { if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) return MHD_poll_all (daemon, may_block ? -1 : 0); return MHD_poll_listen_socket (daemon, may_block); } #endif /* HAVE_POLL */ #ifdef EPOLL_SUPPORT /** * How many events to we process at most per epoll() call? Trade-off * between required stack-size and number of system calls we have to * make; 128 should be way enough to avoid more than one system call * for most scenarios, and still be moderate in stack size * consumption. Embedded systems might want to choose a smaller value * --- but why use epoll() on such a system in the first place? */ #define MAX_EVENTS 128 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Checks whether @a urh has some data to process. * * @param urh upgrade handler to analyse * @return 'true' if @a urh has some data to process, * 'false' otherwise */ static bool is_urh_ready (struct MHD_UpgradeResponseHandle *const urh) { const struct MHD_Connection *const connection = urh->connection; if ( (0 == urh->in_buffer_size) && (0 == urh->out_buffer_size) && (0 == urh->in_buffer_used) && (0 == urh->out_buffer_used) ) return false; if (connection->daemon->shutdown) return true; if ( ( (0 != ((MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_ERROR) & urh->app.celi)) || (connection->tls_read_ready) ) && (urh->in_buffer_used < urh->in_buffer_size) ) return true; if ( ( (0 != ((MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_ERROR) & urh->mhd.celi)) || urh->was_closed) && (urh->out_buffer_used < urh->out_buffer_size) ) return true; if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->app.celi)) && (urh->out_buffer_used > 0) ) return true; if ( (0 != (MHD_EPOLL_STATE_WRITE_READY & urh->mhd.celi)) && (urh->in_buffer_used > 0) ) return true; return false; } /** * Do epoll()-based processing for TLS connections that have been * upgraded. This requires a separate epoll() invocation as we * cannot use the `struct MHD_Connection` data structures for * the `union epoll_data` in this case. * @remark To be called only from thread that process * daemon's select()/poll()/etc. */ static enum MHD_Result run_epoll_for_upgrade (struct MHD_Daemon *daemon) { struct epoll_event events[MAX_EVENTS]; int num_events; struct MHD_UpgradeResponseHandle *pos; struct MHD_UpgradeResponseHandle *prev; #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); #endif /* MHD_USE_THREADS */ num_events = MAX_EVENTS; while (0 != num_events) { unsigned int i; /* update event masks */ num_events = epoll_wait (daemon->epoll_upgrade_fd, events, MAX_EVENTS, 0); if (-1 == num_events) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_YES; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Call to epoll_wait failed: %s\n"), MHD_socket_strerr_ (err)); #endif return MHD_NO; } for (i = 0; i < (unsigned int) num_events; i++) { struct UpgradeEpollHandle *const ueh = events[i].data.ptr; struct MHD_UpgradeResponseHandle *const urh = ueh->urh; bool new_err_state = false; if (urh->clean_ready) continue; /* Update ueh state based on what is ready according to epoll() */ if (0 != (events[i].events & EPOLLIN)) { ueh->celi |= MHD_EPOLL_STATE_READ_READY; } if (0 != (events[i].events & EPOLLOUT)) { ueh->celi |= MHD_EPOLL_STATE_WRITE_READY; } if (0 != (events[i].events & EPOLLHUP)) { ueh->celi |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY; } if ( (0 == (ueh->celi & MHD_EPOLL_STATE_ERROR)) && (0 != (events[i].events & (EPOLLERR | EPOLLPRI))) ) { /* Process new error state only one time and avoid continuously * marking this connection as 'ready'. */ ueh->celi |= MHD_EPOLL_STATE_ERROR; new_err_state = true; } if (! urh->in_eready_list) { if (new_err_state || is_urh_ready (urh)) { EDLL_insert (daemon->eready_urh_head, daemon->eready_urh_tail, urh); urh->in_eready_list = true; } } } } prev = daemon->eready_urh_tail; while (NULL != (pos = prev)) { prev = pos->prevE; process_urh (pos); if (! is_urh_ready (pos)) { EDLL_remove (daemon->eready_urh_head, daemon->eready_urh_tail, pos); pos->in_eready_list = false; } /* Finished forwarding? */ if ( (0 == pos->in_buffer_size) && (0 == pos->out_buffer_size) && (0 == pos->in_buffer_used) && (0 == pos->out_buffer_used) ) { MHD_connection_finish_forward_ (pos->connection); pos->clean_ready = true; /* If 'pos->was_closed' already was set to true, connection * will be moved immediately to cleanup list. Otherwise * connection will stay in suspended list until 'pos' will * be marked with 'was_closed' by application. */ MHD_resume_connection (pos->connection); } } return MHD_YES; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /** * Pointer-marker to distinguish ITC slot in epoll sets. */ static const char *const epoll_itc_marker = "itc_marker"; /** * Do epoll()-based processing. * * @param daemon daemon to run poll loop for * @param millisec the maximum time in milliseconds to wait for events, * set to '0' for non-blocking processing, * set to '-1' to wait indefinitely. * @return #MHD_NO on serious errors, #MHD_YES on success */ static enum MHD_Result MHD_epoll (struct MHD_Daemon *daemon, int32_t millisec) { #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) static const char *const upgrade_marker = "upgrade_ptr"; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ struct MHD_Connection *pos; struct MHD_Connection *prev; struct epoll_event events[MAX_EVENTS]; struct epoll_event event; int timeout_ms; int num_events; unsigned int i; MHD_socket ls; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) bool run_upgraded = false; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ bool need_to_accept; mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (MHD_thread_handle_ID_is_valid_ID_ (daemon->tid))); mhd_assert ((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (! MHD_thread_handle_ID_is_valid_ID_ (daemon->tid))); mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (MHD_thread_handle_ID_is_current_thread_ (daemon->tid))); if (-1 == daemon->epoll_fd) return MHD_NO; /* we're down! */ if (daemon->shutdown) return MHD_NO; if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) && (! daemon->was_quiesced) && (daemon->connections < daemon->connection_limit) && (! daemon->listen_socket_in_epoll) && (! daemon->at_limit) ) { event.events = EPOLLIN | EPOLLRDHUP; event.data.ptr = daemon; if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, ls, &event)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_NO; } daemon->listen_socket_in_epoll = true; } if ( (daemon->was_quiesced) && (daemon->listen_socket_in_epoll) ) { if ( (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, ls, NULL)) && (ENOENT != errno) ) /* ENOENT can happen due to race with #MHD_quiesce_daemon() */ MHD_PANIC ("Failed to remove listen FD from epoll set.\n"); daemon->listen_socket_in_epoll = false; } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if ( ( (! daemon->upgrade_fd_in_epoll) && (-1 != daemon->epoll_upgrade_fd) ) ) { event.events = EPOLLIN | EPOLLOUT | EPOLLRDHUP; event.data.ptr = _MHD_DROP_CONST (upgrade_marker); if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, daemon->epoll_upgrade_fd, &event)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_NO; } daemon->upgrade_fd_in_epoll = true; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if ( (daemon->listen_socket_in_epoll) && ( (daemon->connections == daemon->connection_limit) || (daemon->at_limit) || (daemon->was_quiesced) ) ) { /* we're at the connection limit, disable listen socket for event loop for now */ if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, ls, NULL)) MHD_PANIC (_ ("Failed to remove listen FD from epoll set.\n")); daemon->listen_socket_in_epoll = false; } if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) && (MHD_NO != resume_suspended_connections (daemon)) ) millisec = 0; timeout_ms = get_timeout_millisec_int (daemon, millisec); /* Reset. New value will be set when connections are processed. */ /* Note: Used mostly for uniformity here as same situation is * signaled in epoll mode by non-empty eready DLL. */ daemon->data_already_pending = false; need_to_accept = false; /* drain 'epoll' event queue; need to iterate as we get at most MAX_EVENTS in one system call here; in practice this should pretty much mean only one round, but better an extra loop here than unfair behavior... */ num_events = MAX_EVENTS; while (MAX_EVENTS == num_events) { /* update event masks */ num_events = epoll_wait (daemon->epoll_fd, events, MAX_EVENTS, timeout_ms); if (-1 == num_events) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_YES; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Call to epoll_wait failed: %s\n"), MHD_socket_strerr_ (err)); #endif return MHD_NO; } for (i = 0; i < (unsigned int) num_events; i++) { /* First, check for the values of `ptr` that would indicate that this event is not about a normal connection. */ if (NULL == events[i].data.ptr) continue; /* shutdown signal! */ #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if (upgrade_marker == events[i].data.ptr) { /* activity on an upgraded connection, we process those in a separate epoll() */ run_upgraded = true; continue; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if (epoll_itc_marker == events[i].data.ptr) { /* It's OK to clear ITC here as all external conditions will be processed later. */ MHD_itc_clear_ (daemon->itc); continue; } if (daemon == events[i].data.ptr) { /* Check for error conditions on listen socket. */ /* FIXME: Initiate MHD_quiesce_daemon() to prevent busy waiting? */ if (0 == (events[i].events & (EPOLLERR | EPOLLHUP))) need_to_accept = true; continue; } /* this is an event relating to a 'normal' connection, remember the event and if appropriate mark the connection as 'eready'. */ pos = events[i].data.ptr; /* normal processing: update read/write data */ if (0 != (events[i].events & (EPOLLPRI | EPOLLERR | EPOLLHUP))) { pos->epoll_state |= MHD_EPOLL_STATE_ERROR; if (0 == (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) { EDLL_insert (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL; } } else { if (0 != (events[i].events & EPOLLIN)) { pos->epoll_state |= MHD_EPOLL_STATE_READ_READY; if ( ( (0 != (MHD_EVENT_LOOP_INFO_READ & pos->event_loop_info)) || (pos->read_buffer_size > pos->read_buffer_offset) ) && (0 == (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL) ) ) { EDLL_insert (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL; } } if (0 != (events[i].events & EPOLLOUT)) { pos->epoll_state |= MHD_EPOLL_STATE_WRITE_READY; if ( (MHD_EVENT_LOOP_INFO_WRITE == pos->event_loop_info) && (0 == (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL) ) ) { EDLL_insert (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL; } } } } } /* Process externally added connection if any */ if (daemon->have_new) new_connections_list_process_ (daemon); if (need_to_accept) { unsigned int series_length = 0; /* Run 'accept' until it fails or daemon at limit of connections. * Do not accept more then 10 connections at once. The rest will * be accepted on next turn (level trigger is used for listen * socket). */ while ( (MHD_NO != MHD_accept_connection (daemon)) && (series_length < 10) && (daemon->connections < daemon->connection_limit) && (! daemon->at_limit) ) series_length++; } /* Handle timed-out connections; we need to do this here as the epoll mechanism won't call the 'MHD_connection_handle_idle()' on everything, as the other event loops do. As timeouts do not get an explicit event, we need to find those connections that might have timed out here. Connections with custom timeouts must all be looked at, as we do not bother to sort that (presumably very short) list. */ prev = daemon->manual_timeout_tail; while (NULL != (pos = prev)) { prev = pos->prevX; MHD_connection_handle_idle (pos); } /* Connections with the default timeout are sorted by prepending them to the head of the list whenever we touch the connection; thus it suffices to iterate from the tail until the first connection is NOT timed out */ prev = daemon->normal_timeout_tail; while (NULL != (pos = prev)) { prev = pos->prevX; MHD_connection_handle_idle (pos); if (MHD_CONNECTION_CLOSED != pos->state) break; /* sorted by timeout, no need to visit the rest! */ } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if (run_upgraded || (NULL != daemon->eready_urh_head)) run_epoll_for_upgrade (daemon); #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /* process events for connections */ prev = daemon->eready_tail; while (NULL != (pos = prev)) { prev = pos->prevE; call_handlers (pos, 0 != (pos->epoll_state & MHD_EPOLL_STATE_READ_READY), 0 != (pos->epoll_state & MHD_EPOLL_STATE_WRITE_READY), 0 != (pos->epoll_state & MHD_EPOLL_STATE_ERROR)); if (MHD_EPOLL_STATE_IN_EREADY_EDLL == (pos->epoll_state & (MHD_EPOLL_STATE_SUSPENDED | MHD_EPOLL_STATE_IN_EREADY_EDLL))) { if ( ((MHD_EVENT_LOOP_INFO_READ == pos->event_loop_info) && (0 == (pos->epoll_state & MHD_EPOLL_STATE_READ_READY)) ) || ((MHD_EVENT_LOOP_INFO_WRITE == pos->event_loop_info) && (0 == (pos->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) ) || (MHD_EVENT_LOOP_INFO_CLEANUP == pos->event_loop_info) ) { EDLL_remove (daemon->eready_head, daemon->eready_tail, pos); pos->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_IN_EREADY_EDLL); } } } return MHD_YES; } #endif /** * Run webserver operations (without blocking unless in client callbacks). * * This method should be called by clients in combination with * #MHD_get_fdset() (or #MHD_get_daemon_info() with MHD_DAEMON_INFO_EPOLL_FD * if epoll is used) and #MHD_get_timeout() if the client-controlled * connection polling method is used (i.e. daemon was started without * #MHD_USE_INTERNAL_POLLING_THREAD flag). * * This function is a convenience method, which is useful if the * fd_sets from #MHD_get_fdset were not directly passed to `select()`; * with this function, MHD will internally do the appropriate `select()` * call itself again. While it is acceptable to call #MHD_run (if * #MHD_USE_INTERNAL_POLLING_THREAD is not set) at any moment, you should * call #MHD_run_from_select() if performance is important (as it saves an * expensive call to `select()`). * * If #MHD_get_timeout() returned #MHD_YES, than this function must be called * right after polling function returns regardless of detected activity on * the daemon's FDs. * * @param daemon daemon to run * @return #MHD_YES on success, #MHD_NO if this * daemon was not started with the right * options for this call. * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_run (struct MHD_Daemon *daemon) { if ( (daemon->shutdown) || MHD_D_IS_USING_THREADS_ (daemon) ) return MHD_NO; (void) MHD_run_wait (daemon, 0); return MHD_YES; } /** * Run webserver operation with possible blocking. * * This function does the following: waits for any network event not more than * specified number of milliseconds, processes all incoming and outgoing data, * processes new connections, processes any timed-out connection, and does * other things required to run webserver. * Once all connections are processed, function returns. * * This function is useful for quick and simple (lazy) webserver implementation * if application needs to run a single thread only and does not have any other * network activity. * * This function calls MHD_get_timeout() internally and use returned value as * maximum wait time if it less than value of @a millisec parameter. * * It is expected that the "external" socket polling function is not used in * conjunction with this function unless the @a millisec is set to zero. * * @param daemon the daemon to run * @param millisec the maximum time in milliseconds to wait for network and * other events. Note: there is no guarantee that function * blocks for the specified amount of time. The real processing * time can be shorter (if some data or connection timeout * comes earlier) or longer (if data processing requires more * time, especially in user callbacks). * If set to '0' then function does not block and processes * only already available data (if any). * If set to '-1' then function waits for events * indefinitely (blocks until next network activity or * connection timeout). * @return #MHD_YES on success, #MHD_NO if this * daemon was not started with the right * options for this call or some serious * unrecoverable error occurs. * @note Available since #MHD_VERSION 0x00097206 * @ingroup event */ _MHD_EXTERN enum MHD_Result MHD_run_wait (struct MHD_Daemon *daemon, int32_t millisec) { enum MHD_Result res; if ( (daemon->shutdown) || MHD_D_IS_USING_THREADS_ (daemon) ) return MHD_NO; mhd_assert (! MHD_thread_handle_ID_is_valid_handle_ (daemon->tid)); if (0 > millisec) millisec = -1; #ifdef HAVE_POLL if (MHD_D_IS_USING_POLL_ (daemon)) { res = MHD_poll_all (daemon, millisec); MHD_cleanup_connections (daemon); } else #endif /* HAVE_POLL */ #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon)) { res = MHD_epoll (daemon, millisec); MHD_cleanup_connections (daemon); } else #endif if (1) { mhd_assert (MHD_D_IS_USING_SELECT_ (daemon)); #ifdef HAS_FD_SETSIZE_OVERRIDABLE #ifdef HAVE_MESSAGES if (daemon->fdset_size_set_by_app && (((int) FD_SETSIZE) < daemon->fdset_size)) { MHD_DLOG (daemon, _ ("MHD_run()/MHD_run_wait() called for daemon started with " \ "MHD_OPTION_APP_FD_SETSIZE option (%d). " \ "The library was compiled with smaller FD_SETSIZE (%d). " \ "Some socket FDs may be not processed. " \ "Use MHD_run_from_select2() instead of MHD_run() or " \ "do not use MHD_OPTION_APP_FD_SETSIZE option.\n"), daemon->fdset_size, (int) FD_SETSIZE); } #endif /* HAVE_MESSAGES */ #endif /* HAS_FD_SETSIZE_OVERRIDABLE */ res = MHD_select (daemon, millisec); /* MHD_select does MHD_cleanup_connections already */ } return res; } /** * Close the given connection, remove it from all of its * DLLs and move it into the cleanup queue. * @remark To be called only from thread that * process daemon's select()/poll()/etc. * * @param pos connection to move to cleanup */ static void close_connection (struct MHD_Connection *pos) { struct MHD_Daemon *daemon = pos->daemon; #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { MHD_connection_mark_closed_ (pos); return; /* must let thread to do the rest */ } MHD_connection_close_ (pos, MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif mhd_assert (! pos->suspended); mhd_assert (! pos->resuming); if (pos->connection_timeout_ms == daemon->connection_timeout_ms) XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, pos); else XDLL_remove (daemon->manual_timeout_head, daemon->manual_timeout_tail, pos); DLL_remove (daemon->connections_head, daemon->connections_tail, pos); DLL_insert (daemon->cleanup_head, daemon->cleanup_tail, pos); daemon->data_already_pending = true; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif } #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) /** * Thread that runs the polling loop until the daemon * is explicitly shut down. * * @param cls `struct MHD_Deamon` to run select loop in a thread for * @return always 0 (on shutdown) */ static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ MHD_polling_thread (void *cls) { struct MHD_Daemon *daemon = cls; #ifdef HAVE_PTHREAD_SIGMASK sigset_t s_mask; int err; #endif /* HAVE_PTHREAD_SIGMASK */ MHD_thread_handle_ID_set_current_thread_ID_ (&(daemon->tid)); #ifdef HAVE_PTHREAD_SIGMASK if ((0 == sigemptyset (&s_mask)) && (0 == sigaddset (&s_mask, SIGPIPE))) { err = pthread_sigmask (SIG_BLOCK, &s_mask, NULL); } else err = errno; if (0 == err) daemon->sigpipe_blocked = true; #ifdef HAVE_MESSAGES else MHD_DLOG (daemon, _ ("Failed to block SIGPIPE on daemon thread: %s\n"), MHD_strerror_ (errno)); #endif /* HAVE_MESSAGES */ #endif /* HAVE_PTHREAD_SIGMASK */ while (! daemon->shutdown) { #ifdef HAVE_POLL if (MHD_D_IS_USING_POLL_ (daemon)) MHD_poll (daemon, MHD_YES); else #endif /* HAVE_POLL */ #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon)) MHD_epoll (daemon, -1); else #endif MHD_select (daemon, -1); MHD_cleanup_connections (daemon); } /* Resume any pending for resume connections, join * all connection's threads (if any) and finally cleanup * everything. */ if (0 != (MHD_TEST_ALLOW_SUSPEND_RESUME & daemon->options)) resume_suspended_connections (daemon); close_all_connections (daemon); return (MHD_THRD_RTRN_TYPE_) 0; } #endif /** * Process escape sequences ('%HH') Updates val in place; the * result cannot be larger than the input. * The result must also still be 0-terminated. * * @param cls closure (use NULL) * @param connection handle to connection, not used * @param val value to unescape (modified in the process) * @return length of the resulting val (strlen(val) maybe * shorter afterwards due to elimination of escape sequences) */ static size_t unescape_wrapper (void *cls, struct MHD_Connection *connection, char *val) { bool broken; size_t res; (void) cls; /* Mute compiler warning. */ /* TODO: add individual parameter */ if (0 <= connection->daemon->client_discipline) return MHD_str_pct_decode_in_place_strict_ (val); res = MHD_str_pct_decode_in_place_lenient_ (val, &broken); #ifdef HAVE_MESSAGES if (broken) { MHD_DLOG (connection->daemon, _ ("The URL encoding is broken.\n")); } #endif /* HAVE_MESSAGES */ return res; } /** * Start a webserver on the given port. Variadic version of * #MHD_start_daemon_va. * * @param flags combination of `enum MHD_FLAG` values * @param port port to bind to (in host byte order), * use '0' to bind to random free port, * ignored if #MHD_OPTION_SOCK_ADDR or * #MHD_OPTION_LISTEN_SOCKET is provided * or #MHD_USE_NO_LISTEN_SOCKET is specified * @param apc callback to call to check which clients * will be allowed to connect; you can pass NULL * in which case connections from any IP will be * accepted * @param apc_cls extra argument to @a apc * @param dh handler called for all requests (repeatedly) * @param dh_cls extra argument to @a dh * @return NULL on error, handle to daemon on success * @ingroup event */ _MHD_EXTERN struct MHD_Daemon * MHD_start_daemon (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, ...) { struct MHD_Daemon *daemon; va_list ap; va_start (ap, dh_cls); daemon = MHD_start_daemon_va (flags, port, apc, apc_cls, dh, dh_cls, ap); va_end (ap); return daemon; } /** * Stop accepting connections from the listening socket. Allows * clients to continue processing, but stops accepting new * connections. Note that the caller is responsible for closing the * returned socket; however, if MHD is run using threads (anything but * external select mode), socket will be removed from existing threads * with some delay and it must not be closed while it's in use. To make * sure that the socket is not used anymore, call #MHD_stop_daemon. * * Note that some thread modes require the caller to have passed * #MHD_USE_ITC when using this API. If this daemon is * in one of those modes and this option was not given to * #MHD_start_daemon, this function will return #MHD_INVALID_SOCKET. * * @param daemon daemon to stop accepting new connections for * @return old listen socket on success, #MHD_INVALID_SOCKET if * the daemon was already not listening anymore * @ingroup specialized */ _MHD_EXTERN MHD_socket MHD_quiesce_daemon (struct MHD_Daemon *daemon) { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) unsigned int i; #endif MHD_socket ret; ret = daemon->listen_fd; if ((MHD_INVALID_SOCKET == ret) || daemon->was_quiesced) return MHD_INVALID_SOCKET; if ( (0 == (daemon->options & (MHD_USE_ITC))) && MHD_D_IS_USING_THREADS_ (daemon) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Using MHD_quiesce_daemon in this mode " \ "requires MHD_USE_ITC.\n")); #endif return MHD_INVALID_SOCKET; } #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != daemon->worker_pool) for (i = 0; i < daemon->worker_pool_size; i++) { daemon->worker_pool[i].was_quiesced = true; #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon) && (-1 != daemon->worker_pool[i].epoll_fd) && (daemon->worker_pool[i].listen_socket_in_epoll) ) { if (0 != epoll_ctl (daemon->worker_pool[i].epoll_fd, EPOLL_CTL_DEL, ret, NULL)) MHD_PANIC (_ ("Failed to remove listen FD from epoll set.\n")); daemon->worker_pool[i].listen_socket_in_epoll = false; } else #endif if (MHD_ITC_IS_VALID_ (daemon->worker_pool[i].itc)) { if (! MHD_itc_activate_ (daemon->worker_pool[i].itc, "q")) MHD_PANIC (_ ("Failed to signal quiesce via inter-thread " \ "communication channel.\n")); } } #endif daemon->was_quiesced = true; #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon) && (-1 != daemon->epoll_fd) && (daemon->listen_socket_in_epoll) ) { if ( (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, ret, NULL)) && (ENOENT != errno) ) /* ENOENT can happen due to race with #MHD_epoll() */ MHD_PANIC ("Failed to remove listen FD from epoll set.\n"); daemon->listen_socket_in_epoll = false; } #endif if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "q")) ) MHD_PANIC (_ ("failed to signal quiesce via inter-thread " \ "communication channel.\n")); return ret; } /** * Temporal location of the application-provided parameters/options. * Used when options are decoded from #MHD_start_deamon() parameters, but * not yet processed/applied. */ struct MHD_InterimParams_ { /** * The total number of all user options used. * * Contains number only of meaningful options, i.e. #MHD_OPTION_END and * #MHD_OPTION_ARRAY themselves are not counted, while options inside * #MHD_OPTION_ARRAY are counted. */ size_t num_opts; /** * Set to 'true' if @a fdset_size is set by application. */ bool fdset_size_set; /** * The value for #MHD_OPTION_APP_FD_SETSIZE set by application. */ int fdset_size; /** * Set to 'true' if @a listen_fd is set by application. */ bool listen_fd_set; /** * Application-provided listen socket. */ MHD_socket listen_fd; /** * Set to 'true' if @a server_addr is set by application. */ bool pserver_addr_set; /** * Application-provided struct sockaddr to bind server to. */ const struct sockaddr *pserver_addr; /** * Set to 'true' if @a server_addr_len is set by application. */ bool server_addr_len_set; /** * Applicaiton-provided the size of the memory pointed by @a server_addr. */ socklen_t server_addr_len; }; /** * Signature of the MHD custom logger function. * * @param cls closure * @param format format string * @param va arguments to the format string (fprintf-style) */ typedef void (*VfprintfFunctionPointerType)(void *cls, const char *format, va_list va); /** * Parse a list of options given as varargs. * * @param daemon the daemon to initialize * @param servaddr where to store the server's listen address * @param params the interim parameters to be assigned to * @param ap the options * @return #MHD_YES on success, #MHD_NO on error */ static enum MHD_Result parse_options_va (struct MHD_Daemon *daemon, struct MHD_InterimParams_ *params, va_list ap); /** * Parse a list of options given as varargs. * * @param daemon the daemon to initialize * @param servaddr where to store the server's listen address * @param params the interim parameters to be assigned to * @param ... the options * @return #MHD_YES on success, #MHD_NO on error */ static enum MHD_Result parse_options (struct MHD_Daemon *daemon, struct MHD_InterimParams_ *params, ...) { va_list ap; enum MHD_Result ret; va_start (ap, params); ret = parse_options_va (daemon, params, ap); va_end (ap); return ret; } #ifdef HTTPS_SUPPORT /** * Type of GnuTLS priorities base string */ enum MHD_TlsPrioritiesBaseType { MHD_TLS_PRIO_BASE_LIBMHD = 0, /**< @c "@LIBMICROHTTPD" */ MHD_TLS_PRIO_BASE_SYSTEM = 1, /**< @c "@SYSTEM" */ #if GNUTLS_VERSION_NUMBER >= 0x030300 MHD_TLS_PRIO_BASE_DEFAULT, /**< Default priorities string */ #endif /* GNUTLS_VERSION_NUMBER >= 0x030300 */ MHD_TLS_PRIO_BASE_NORMAL /**< @c "NORMAL */ }; static const struct _MHD_cstr_w_len MHD_TlsBasePriotities[] = { _MHD_S_STR_W_LEN ("@LIBMICROHTTPD"), _MHD_S_STR_W_LEN ("@SYSTEM"), #if GNUTLS_VERSION_NUMBER >= 0x030300 {NULL, 0}, #endif /* GNUTLS_VERSION_NUMBER >= 0x030300 */ _MHD_S_STR_W_LEN ("NORMAL") }; /** * Initialise TLS priorities with default settings * @param daemon the daemon to initialise TLS priorities * @return true on success, false on error */ static bool daemon_tls_priorities_init_default (struct MHD_Daemon *daemon) { unsigned int p; int res; mhd_assert (0 != (((unsigned int) daemon->options) & MHD_USE_TLS)); mhd_assert (NULL == daemon->priority_cache); mhd_assert (MHD_TLS_PRIO_BASE_NORMAL + 1 == \ sizeof(MHD_TlsBasePriotities) / sizeof(MHD_TlsBasePriotities[0])); res = GNUTLS_E_SUCCESS; /* Mute compiler warning */ for (p = 0; p < sizeof(MHD_TlsBasePriotities) / sizeof(MHD_TlsBasePriotities[0]); ++p) { res = gnutls_priority_init (&daemon->priority_cache, MHD_TlsBasePriotities[p].str, NULL); if (GNUTLS_E_SUCCESS == res) { #ifdef _DEBUG #ifdef HAVE_MESSAGES switch ((enum MHD_TlsPrioritiesBaseType) p) { case MHD_TLS_PRIO_BASE_LIBMHD: MHD_DLOG (daemon, _ ("GnuTLS priorities have been initialised with " \ "@LIBMICROHTTPD application-specific system-wide " \ "configuration.\n") ); break; case MHD_TLS_PRIO_BASE_SYSTEM: MHD_DLOG (daemon, _ ("GnuTLS priorities have been initialised with " \ "@SYSTEM system-wide configuration.\n") ); break; #if GNUTLS_VERSION_NUMBER >= 0x030300 case MHD_TLS_PRIO_BASE_DEFAULT: MHD_DLOG (daemon, _ ("GnuTLS priorities have been initialised with " \ "GnuTLS default configuration.\n") ); break; #endif /* GNUTLS_VERSION_NUMBER >= 0x030300 */ case MHD_TLS_PRIO_BASE_NORMAL: MHD_DLOG (daemon, _ ("GnuTLS priorities have been initialised with " \ "NORMAL configuration.\n") ); break; default: mhd_assert (0); } #endif /* HAVE_MESSAGES */ #endif /* _DEBUG */ return true; } } #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to set GnuTLS priorities. Last error: %s\n"), gnutls_strerror (res)); #endif /* HAVE_MESSAGES */ return false; } /** * The inner helper function for #daemon_tls_priorities_init_app(). * @param daemon the daemon to use * @param prio the appication-specified appendix for default priorities * @param prio_len the length of @a prio * @param buf the temporal buffer for string manipulations * @param buf_size the size of the @a buf * @return true on success, false on error */ static bool daemon_tls_priorities_init_append_inner_ (struct MHD_Daemon *daemon, const char *prio, size_t prio_len, char *buf, const size_t buf_size) { unsigned int p; int res; const char *err_pos; (void) buf_size; /* Mute compiler warning for non-Debug builds */ mhd_assert (0 != (((unsigned int) daemon->options) & MHD_USE_TLS)); mhd_assert (NULL == daemon->priority_cache); mhd_assert (MHD_TLS_PRIO_BASE_NORMAL + 1 == \ sizeof(MHD_TlsBasePriotities) / sizeof(MHD_TlsBasePriotities[0])); res = GNUTLS_E_SUCCESS; /* Mute compiler warning */ for (p = 0; p < sizeof(MHD_TlsBasePriotities) / sizeof(MHD_TlsBasePriotities[0]); ++p) { #if GNUTLS_VERSION_NUMBER >= 0x030300 #if GNUTLS_VERSION_NUMBER >= 0x030603 if (NULL == MHD_TlsBasePriotities[p].str) res = gnutls_priority_init2 (&daemon->priority_cache, prio, &err_pos, GNUTLS_PRIORITY_INIT_DEF_APPEND); else #else /* 0x030300 <= GNUTLS_VERSION_NUMBER && GNUTLS_VERSION_NUMBER < 0x030603 */ if (NULL == MHD_TlsBasePriotities[p].str) continue; /* Skip the value, no way to append priorities to the default string */ else #endif /* GNUTLS_VERSION_NUMBER < 0x030603 */ #endif /* GNUTLS_VERSION_NUMBER >= 0x030300 */ if (1) { size_t buf_pos; mhd_assert (NULL != MHD_TlsBasePriotities[p].str); buf_pos = 0; memcpy (buf + buf_pos, MHD_TlsBasePriotities[p].str, MHD_TlsBasePriotities[p].len); buf_pos += MHD_TlsBasePriotities[p].len; buf[buf_pos++] = ':'; memcpy (buf + buf_pos, prio, prio_len + 1); #ifdef _DEBUG buf_pos += prio_len + 1; mhd_assert (buf_size >= buf_pos); #endif /* _DEBUG */ res = gnutls_priority_init (&daemon->priority_cache, buf, &err_pos); } if (GNUTLS_E_SUCCESS == res) { #ifdef _DEBUG #ifdef HAVE_MESSAGES switch ((enum MHD_TlsPrioritiesBaseType) p) { case MHD_TLS_PRIO_BASE_LIBMHD: MHD_DLOG (daemon, _ ("GnuTLS priorities have been initialised with " \ "priorities specified by application appended to " \ "@LIBMICROHTTPD application-specific system-wide " \ "configuration.\n") ); break; case MHD_TLS_PRIO_BASE_SYSTEM: MHD_DLOG (daemon, _ ("GnuTLS priorities have been initialised with " \ "priorities specified by application appended to " \ "@SYSTEM system-wide configuration.\n") ); break; #if GNUTLS_VERSION_NUMBER >= 0x030300 case MHD_TLS_PRIO_BASE_DEFAULT: MHD_DLOG (daemon, _ ("GnuTLS priorities have been initialised with " \ "priorities specified by application appended to " \ "GnuTLS default configuration.\n") ); break; #endif /* GNUTLS_VERSION_NUMBER >= 0x030300 */ case MHD_TLS_PRIO_BASE_NORMAL: MHD_DLOG (daemon, _ ("GnuTLS priorities have been initialised with " \ "priorities specified by application appended to " \ "NORMAL configuration.\n") ); break; default: mhd_assert (0); } #endif /* HAVE_MESSAGES */ #endif /* _DEBUG */ return true; } } #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to set GnuTLS priorities. Last error: %s. " \ "The problematic part starts at: %s\n"), gnutls_strerror (res), err_pos); #endif /* HAVE_MESSAGES */ return false; } #define LOCAL_BUFF_SIZE 128 /** * Initialise TLS priorities with default settings with application-specified * appended string. * @param daemon the daemon to initialise TLS priorities * @param prio the application specified priorities to be appended to * the GnuTLS standard priorities string * @return true on success, false on error */ static bool daemon_tls_priorities_init_append (struct MHD_Daemon *daemon, const char *prio) { static const size_t longest_base_prio = MHD_STATICSTR_LEN_ ("@LIBMICROHTTPD"); bool ret; size_t prio_len; size_t buf_size_needed; if (NULL == prio) return daemon_tls_priorities_init_default (daemon); if (':' == prio[0]) ++prio; prio_len = strlen (prio); buf_size_needed = longest_base_prio + 1 + prio_len + 1; if (LOCAL_BUFF_SIZE >= buf_size_needed) { char local_buffer[LOCAL_BUFF_SIZE]; ret = daemon_tls_priorities_init_append_inner_ (daemon, prio, prio_len, local_buffer, LOCAL_BUFF_SIZE); } else { char *allocated_buffer; allocated_buffer = (char *) malloc (buf_size_needed); if (NULL == allocated_buffer) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Error allocating memory: %s\n"), MHD_strerror_ (errno)); #endif return false; } ret = daemon_tls_priorities_init_append_inner_ (daemon, prio, prio_len, allocated_buffer, buf_size_needed); free (allocated_buffer); } return ret; } #endif /* HTTPS_SUPPORT */ /** * Parse a list of options given as varargs. * * @param[in,out] daemon the daemon to initialize * @param[out] params the interim parameters to be assigned to * @param ap the options * @return #MHD_YES on success, #MHD_NO on error */ static enum MHD_Result parse_options_va (struct MHD_Daemon *daemon, struct MHD_InterimParams_ *params, va_list ap) { enum MHD_OPTION opt; struct MHD_OptionItem *oa; unsigned int i; unsigned int uv; #ifdef HTTPS_SUPPORT const char *pstr; #if GNUTLS_VERSION_MAJOR >= 3 gnutls_certificate_retrieve_function2 * pgcrf; #endif #if GNUTLS_VERSION_NUMBER >= 0x030603 gnutls_certificate_retrieve_function3 * pgcrf2; #endif #endif /* HTTPS_SUPPORT */ while (MHD_OPTION_END != (opt = (enum MHD_OPTION) va_arg (ap, int))) { /* Increase counter at start, so resulting value is number of * processed options, including any failed ones. */ params->num_opts++; switch (opt) { case MHD_OPTION_CONNECTION_MEMORY_LIMIT: if (1) { size_t val; val = va_arg (ap, size_t); if (0 != val) { daemon->pool_size = val; if (64 > daemon->pool_size) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Warning: specified " \ "MHD_OPTION_CONNECTION_MEMORY_LIMIT " \ "value is too small and rounded up to 64.\n")); #endif /* HAVE_MESSAGES */ daemon->pool_size = 64; } if (daemon->pool_size / 4 < daemon->pool_increment) daemon->pool_increment = daemon->pool_size / 4; } } break; case MHD_OPTION_CONNECTION_MEMORY_INCREMENT: if (1) { size_t val; val = va_arg (ap, size_t); if (0 != val) { daemon->pool_increment = val; if (daemon->pool_size / 4 < daemon->pool_increment) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Warning: specified " \ "MHD_OPTION_CONNECTION_MEMORY_INCREMENT value is " \ "too large and rounded down to 1/4 of " \ "MHD_OPTION_CONNECTION_MEMORY_LIMIT.\n")); #endif /* HAVE_MESSAGES */ daemon->pool_increment = daemon->pool_size / 4; } } } break; case MHD_OPTION_CONNECTION_LIMIT: daemon->connection_limit = va_arg (ap, unsigned int); break; case MHD_OPTION_CONNECTION_TIMEOUT: uv = va_arg (ap, unsigned int); #if (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT if ((UINT64_MAX / 4000 - 1) < uv) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("The specified connection timeout (%u) is too large. " \ "Maximum allowed value (%" PRIu64 ") will be used " \ "instead.\n"), uv, (UINT64_MAX / 4000 - 1)); #endif uv = UINT64_MAX / 4000 - 1; } #endif /* (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT */ daemon->connection_timeout_ms = ((uint64_t) uv) * 1000; break; case MHD_OPTION_NOTIFY_COMPLETED: daemon->notify_completed = va_arg (ap, MHD_RequestCompletedCallback); daemon->notify_completed_cls = va_arg (ap, void *); break; case MHD_OPTION_NOTIFY_CONNECTION: daemon->notify_connection = va_arg (ap, MHD_NotifyConnectionCallback); daemon->notify_connection_cls = va_arg (ap, void *); break; case MHD_OPTION_PER_IP_CONNECTION_LIMIT: daemon->per_ip_connection_limit = va_arg (ap, unsigned int); break; case MHD_OPTION_SOCK_ADDR_LEN: params->server_addr_len = va_arg (ap, socklen_t); params->server_addr_len_set = true; params->pserver_addr = va_arg (ap, const struct sockaddr *); params->pserver_addr_set = true; break; case MHD_OPTION_SOCK_ADDR: params->server_addr_len_set = false; params->pserver_addr = va_arg (ap, const struct sockaddr *); params->pserver_addr_set = true; break; case MHD_OPTION_URI_LOG_CALLBACK: daemon->uri_log_callback = va_arg (ap, LogCallback); daemon->uri_log_callback_cls = va_arg (ap, void *); break; case MHD_OPTION_SERVER_INSANITY: daemon->insanity_level = (enum MHD_DisableSanityCheck) va_arg (ap, unsigned int); break; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) case MHD_OPTION_THREAD_POOL_SIZE: daemon->worker_pool_size = va_arg (ap, unsigned int); if (0 == daemon->worker_pool_size) { (void) 0; /* MHD_OPTION_THREAD_POOL_SIZE ignored, do nothing */ } else if (1 == daemon->worker_pool_size) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Warning: value \"1\", specified as the thread pool " \ "size, is ignored. Thread pool is not used.\n")); #endif daemon->worker_pool_size = 0; } #if SIZEOF_UNSIGNED_INT >= (SIZEOF_SIZE_T - 2) /* Next comparison could be always false on some platforms and whole branch will * be optimized out on these platforms. On others it will be compiled into real * check. */ else if (daemon->worker_pool_size >= (SIZE_MAX / sizeof (struct MHD_Daemon))) /* Compiler may warn on some platforms, ignore warning. */ { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Specified thread pool size (%u) too big.\n"), daemon->worker_pool_size); #endif return MHD_NO; } #endif /* SIZEOF_UNSIGNED_INT >= (SIZEOF_SIZE_T - 2) */ else { if (! MHD_D_IS_USING_THREADS_ (daemon)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD_OPTION_THREAD_POOL_SIZE option is specified but " "MHD_USE_INTERNAL_POLLING_THREAD flag is not specified.\n")); #endif return MHD_NO; } if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Both MHD_OPTION_THREAD_POOL_SIZE option and " "MHD_USE_THREAD_PER_CONNECTION flag are specified.\n")); #endif return MHD_NO; } } break; #endif #ifdef HTTPS_SUPPORT case MHD_OPTION_HTTPS_MEM_KEY: pstr = va_arg (ap, const char *); if (0 != (daemon->options & MHD_USE_TLS)) daemon->https_mem_key = pstr; #ifdef HAVE_MESSAGES else MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD but " \ "MHD_USE_TLS not set.\n"), opt); #endif break; case MHD_OPTION_HTTPS_KEY_PASSWORD: pstr = va_arg (ap, const char *); if (0 != (daemon->options & MHD_USE_TLS)) daemon->https_key_password = pstr; #ifdef HAVE_MESSAGES else MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD but " \ "MHD_USE_TLS not set.\n"), opt); #endif break; case MHD_OPTION_HTTPS_MEM_CERT: pstr = va_arg (ap, const char *); if (0 != (daemon->options & MHD_USE_TLS)) daemon->https_mem_cert = pstr; #ifdef HAVE_MESSAGES else MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD but " \ "MHD_USE_TLS not set.\n"), opt); #endif break; case MHD_OPTION_HTTPS_MEM_TRUST: pstr = va_arg (ap, const char *); if (0 != (daemon->options & MHD_USE_TLS)) daemon->https_mem_trust = pstr; #ifdef HAVE_MESSAGES else MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD but " \ "MHD_USE_TLS not set.\n"), opt); #endif break; case MHD_OPTION_HTTPS_CRED_TYPE: daemon->cred_type = (gnutls_credentials_type_t) va_arg (ap, int); break; case MHD_OPTION_HTTPS_MEM_DHPARAMS: pstr = va_arg (ap, const char *); if (0 != (daemon->options & MHD_USE_TLS)) { gnutls_datum_t dhpar; size_t pstr_len; if (gnutls_dh_params_init (&daemon->https_mem_dhparams) < 0) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Error initializing DH parameters.\n")); #endif return MHD_NO; } dhpar.data = (unsigned char *) _MHD_DROP_CONST (pstr); pstr_len = strlen (pstr); if (UINT_MAX < pstr_len) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Diffie-Hellman parameters string too long.\n")); #endif return MHD_NO; } dhpar.size = (unsigned int) pstr_len; if (gnutls_dh_params_import_pkcs3 (daemon->https_mem_dhparams, &dhpar, GNUTLS_X509_FMT_PEM) < 0) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Bad Diffie-Hellman parameters format.\n")); #endif gnutls_dh_params_deinit (daemon->https_mem_dhparams); return MHD_NO; } daemon->have_dhparams = true; } #ifdef HAVE_MESSAGES else MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD but " \ "MHD_USE_TLS not set.\n"), opt); #endif break; case MHD_OPTION_HTTPS_PRIORITIES: case MHD_OPTION_HTTPS_PRIORITIES_APPEND: pstr = va_arg (ap, const char *); if (0 != (daemon->options & MHD_USE_TLS)) { if (NULL != daemon->priority_cache) gnutls_priority_deinit (daemon->priority_cache); if (MHD_OPTION_HTTPS_PRIORITIES == opt) { int init_res; const char *err_pos; init_res = gnutls_priority_init (&daemon->priority_cache, pstr, &err_pos); if (GNUTLS_E_SUCCESS != init_res) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Setting priorities to '%s' failed: %s " \ "The problematic part starts at: %s\n"), pstr, gnutls_strerror (init_res), err_pos); #endif daemon->priority_cache = NULL; return MHD_NO; } } else { /* The cache has been deinited */ daemon->priority_cache = NULL; if (! daemon_tls_priorities_init_append (daemon, pstr)) return MHD_NO; } } #ifdef HAVE_MESSAGES else MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD but " \ "MHD_USE_TLS not set.\n"), opt); #endif break; case MHD_OPTION_HTTPS_CERT_CALLBACK: #if GNUTLS_VERSION_MAJOR < 3 #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD_OPTION_HTTPS_CERT_CALLBACK requires building " \ "MHD with GnuTLS >= 3.0.\n")); #endif return MHD_NO; #else pgcrf = va_arg (ap, gnutls_certificate_retrieve_function2 *); if (0 != (daemon->options & MHD_USE_TLS)) daemon->cert_callback = pgcrf; #ifdef HAVE_MESSAGES else MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD but " \ "MHD_USE_TLS not set.\n"), opt); #endif /* HAVE_MESSAGES */ break; #endif case MHD_OPTION_HTTPS_CERT_CALLBACK2: #if GNUTLS_VERSION_NUMBER < 0x030603 #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD_OPTION_HTTPS_CERT_CALLBACK2 requires building " \ "MHD with GnuTLS >= 3.6.3.\n")); #endif return MHD_NO; #else pgcrf2 = va_arg (ap, gnutls_certificate_retrieve_function3 *); if (0 != (daemon->options & MHD_USE_TLS)) daemon->cert_callback2 = pgcrf2; #ifdef HAVE_MESSAGES else MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD but " \ "MHD_USE_TLS not set.\n"), opt); #endif /* HAVE_MESSAGES */ break; #endif #endif /* HTTPS_SUPPORT */ #ifdef DAUTH_SUPPORT case MHD_OPTION_DIGEST_AUTH_RANDOM: case MHD_OPTION_DIGEST_AUTH_RANDOM_COPY: daemon->digest_auth_rand_size = va_arg (ap, size_t); daemon->digest_auth_random = va_arg (ap, const char *); if (MHD_OPTION_DIGEST_AUTH_RANDOM_COPY == opt) /* Set to some non-NULL value just to indicate that copy is required. */ daemon->digest_auth_random_copy = daemon; else daemon->digest_auth_random_copy = NULL; break; case MHD_OPTION_NONCE_NC_SIZE: daemon->nonce_nc_size = va_arg (ap, unsigned int); break; case MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE: daemon->dauth_bind_type = va_arg (ap, unsigned int); if (0 != (daemon->dauth_bind_type & MHD_DAUTH_BIND_NONCE_URI_PARAMS)) daemon->dauth_bind_type |= MHD_DAUTH_BIND_NONCE_URI; break; case MHD_OPTION_DIGEST_AUTH_DEFAULT_NONCE_TIMEOUT: if (1) { unsigned int val; val = va_arg (ap, unsigned int); if (0 != val) daemon->dauth_def_nonce_timeout = val; } break; case MHD_OPTION_DIGEST_AUTH_DEFAULT_MAX_NC: if (1) { uint32_t val; val = va_arg (ap, uint32_t); if (0 != val) daemon->dauth_def_max_nc = val; } break; #else /* ! DAUTH_SUPPORT */ case MHD_OPTION_DIGEST_AUTH_RANDOM: case MHD_OPTION_DIGEST_AUTH_RANDOM_COPY: case MHD_OPTION_NONCE_NC_SIZE: case MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE: case MHD_OPTION_DIGEST_AUTH_DEFAULT_NONCE_TIMEOUT: case MHD_OPTION_DIGEST_AUTH_DEFAULT_MAX_NC: #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Digest Auth is disabled for this build " \ "of GNU libmicrohttpd.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; #endif /* ! DAUTH_SUPPORT */ case MHD_OPTION_LISTEN_SOCKET: params->listen_fd = va_arg (ap, MHD_socket); params->listen_fd_set = true; break; case MHD_OPTION_EXTERNAL_LOGGER: #ifdef HAVE_MESSAGES daemon->custom_error_log = va_arg (ap, VfprintfFunctionPointerType); daemon->custom_error_log_cls = va_arg (ap, void *); if (1 != params->num_opts) MHD_DLOG (daemon, _ ("MHD_OPTION_EXTERNAL_LOGGER is not the first option " "specified for the daemon. Some messages may be " "printed by the standard MHD logger.\n")); #else (void) va_arg (ap, VfprintfFunctionPointerType); (void) va_arg (ap, void *); #endif break; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) case MHD_OPTION_THREAD_STACK_SIZE: daemon->thread_stack_size = va_arg (ap, size_t); break; #endif case MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE: #ifdef TCP_FASTOPEN daemon->fastopen_queue_size = va_arg (ap, unsigned int); break; #else /* ! TCP_FASTOPEN */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("TCP fastopen is not supported on this platform.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; #endif /* ! TCP_FASTOPEN */ case MHD_OPTION_LISTENING_ADDRESS_REUSE: daemon->listening_address_reuse = va_arg (ap, unsigned int) ? 1 : -1; break; case MHD_OPTION_LISTEN_BACKLOG_SIZE: daemon->listen_backlog_size = va_arg (ap, unsigned int); break; case MHD_OPTION_STRICT_FOR_CLIENT: daemon->client_discipline = va_arg (ap, int); /* Temporal assignment */ /* Map to correct value */ if (-1 >= daemon->client_discipline) daemon->client_discipline = -3; else if (1 <= daemon->client_discipline) daemon->client_discipline = 1; #ifdef HAVE_MESSAGES if ( (0 != (daemon->options & MHD_USE_PEDANTIC_CHECKS)) && (1 != daemon->client_discipline) ) { MHD_DLOG (daemon, _ ("Flag MHD_USE_PEDANTIC_CHECKS is ignored because " "another behaviour is specified by " "MHD_OPTION_STRICT_CLIENT.\n")); } #endif /* HAVE_MESSAGES */ break; case MHD_OPTION_CLIENT_DISCIPLINE_LVL: daemon->client_discipline = va_arg (ap, int); #ifdef HAVE_MESSAGES if ( (0 != (daemon->options & MHD_USE_PEDANTIC_CHECKS)) && (1 != daemon->client_discipline) ) { MHD_DLOG (daemon, _ ("Flag MHD_USE_PEDANTIC_CHECKS is ignored because " "another behaviour is specified by " "MHD_OPTION_CLIENT_DISCIPLINE_LVL.\n")); } #endif /* HAVE_MESSAGES */ break; case MHD_OPTION_ARRAY: params->num_opts--; /* Do not count MHD_OPTION_ARRAY */ oa = va_arg (ap, struct MHD_OptionItem *); i = 0; while (MHD_OPTION_END != (opt = oa[i].option)) { switch (opt) { /* all options taking 'size_t' */ case MHD_OPTION_CONNECTION_MEMORY_LIMIT: case MHD_OPTION_CONNECTION_MEMORY_INCREMENT: case MHD_OPTION_THREAD_STACK_SIZE: if (MHD_NO == parse_options (daemon, params, opt, (size_t) oa[i].value, MHD_OPTION_END)) return MHD_NO; break; /* all options taking 'unsigned int' */ case MHD_OPTION_NONCE_NC_SIZE: case MHD_OPTION_CONNECTION_LIMIT: case MHD_OPTION_CONNECTION_TIMEOUT: case MHD_OPTION_PER_IP_CONNECTION_LIMIT: case MHD_OPTION_THREAD_POOL_SIZE: case MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE: case MHD_OPTION_LISTENING_ADDRESS_REUSE: case MHD_OPTION_LISTEN_BACKLOG_SIZE: case MHD_OPTION_SERVER_INSANITY: case MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE: case MHD_OPTION_DIGEST_AUTH_DEFAULT_NONCE_TIMEOUT: if (MHD_NO == parse_options (daemon, params, opt, (unsigned int) oa[i].value, MHD_OPTION_END)) return MHD_NO; break; /* all options taking 'enum' */ case MHD_OPTION_HTTPS_CRED_TYPE: #ifdef HTTPS_SUPPORT if (MHD_NO == parse_options (daemon, params, opt, (gnutls_credentials_type_t) oa[i].value, MHD_OPTION_END)) #endif /* HTTPS_SUPPORT */ return MHD_NO; break; /* all options taking 'MHD_socket' */ case MHD_OPTION_LISTEN_SOCKET: if (MHD_NO == parse_options (daemon, params, opt, (MHD_socket) oa[i].value, MHD_OPTION_END)) return MHD_NO; break; /* all options taking 'int' */ case MHD_OPTION_STRICT_FOR_CLIENT: case MHD_OPTION_CLIENT_DISCIPLINE_LVL: case MHD_OPTION_SIGPIPE_HANDLED_BY_APP: case MHD_OPTION_TLS_NO_ALPN: case MHD_OPTION_APP_FD_SETSIZE: if (MHD_NO == parse_options (daemon, params, opt, (int) oa[i].value, MHD_OPTION_END)) return MHD_NO; break; /* all options taking 'uint32_t' */ case MHD_OPTION_DIGEST_AUTH_DEFAULT_MAX_NC: if (MHD_NO == parse_options (daemon, params, opt, (uint32_t) oa[i].value, MHD_OPTION_END)) return MHD_NO; break; /* all options taking one pointer */ case MHD_OPTION_SOCK_ADDR: case MHD_OPTION_HTTPS_MEM_KEY: case MHD_OPTION_HTTPS_KEY_PASSWORD: case MHD_OPTION_HTTPS_MEM_CERT: case MHD_OPTION_HTTPS_MEM_TRUST: case MHD_OPTION_HTTPS_MEM_DHPARAMS: case MHD_OPTION_HTTPS_PRIORITIES: case MHD_OPTION_HTTPS_PRIORITIES_APPEND: case MHD_OPTION_ARRAY: case MHD_OPTION_HTTPS_CERT_CALLBACK: case MHD_OPTION_HTTPS_CERT_CALLBACK2: if (MHD_NO == parse_options (daemon, params, opt, oa[i].ptr_value, MHD_OPTION_END)) return MHD_NO; break; /* all options taking two pointers */ case MHD_OPTION_NOTIFY_COMPLETED: case MHD_OPTION_NOTIFY_CONNECTION: case MHD_OPTION_URI_LOG_CALLBACK: case MHD_OPTION_EXTERNAL_LOGGER: case MHD_OPTION_UNESCAPE_CALLBACK: case MHD_OPTION_GNUTLS_PSK_CRED_HANDLER: if (MHD_NO == parse_options (daemon, params, opt, (void *) oa[i].value, oa[i].ptr_value, MHD_OPTION_END)) return MHD_NO; break; /* options taking size_t-number followed by pointer */ case MHD_OPTION_DIGEST_AUTH_RANDOM: case MHD_OPTION_DIGEST_AUTH_RANDOM_COPY: if (MHD_NO == parse_options (daemon, params, opt, (size_t) oa[i].value, oa[i].ptr_value, MHD_OPTION_END)) return MHD_NO; break; /* options taking socklen_t-number followed by pointer */ case MHD_OPTION_SOCK_ADDR_LEN: if (MHD_NO == parse_options (daemon, params, opt, (socklen_t) oa[i].value, oa[i].ptr_value, MHD_OPTION_END)) return MHD_NO; break; case MHD_OPTION_END: /* Not possible */ default: return MHD_NO; } i++; } break; case MHD_OPTION_UNESCAPE_CALLBACK: daemon->unescape_callback = va_arg (ap, UnescapeCallback); daemon->unescape_callback_cls = va_arg (ap, void *); break; #ifdef HTTPS_SUPPORT case MHD_OPTION_GNUTLS_PSK_CRED_HANDLER: #if GNUTLS_VERSION_MAJOR >= 3 daemon->cred_callback = va_arg (ap, MHD_PskServerCredentialsCallback); daemon->cred_callback_cls = va_arg (ap, void *); break; #else MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD compiled " \ "without GNUtls >= 3.\n"), opt); return MHD_NO; #endif #endif /* HTTPS_SUPPORT */ case MHD_OPTION_SIGPIPE_HANDLED_BY_APP: if (! MHD_D_IS_USING_THREADS_ (daemon)) daemon->sigpipe_blocked = ( (va_arg (ap, int)) != 0); else { (void) va_arg (ap, int); } break; case MHD_OPTION_TLS_NO_ALPN: #ifdef HTTPS_SUPPORT daemon->disable_alpn = (va_arg (ap, int) != 0); #else /* ! HTTPS_SUPPORT */ (void) va_arg (ap, int); #endif /* ! HTTPS_SUPPORT */ #ifdef HAVE_MESSAGES if (0 == (daemon->options & MHD_USE_TLS)) MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD " \ "but MHD_USE_TLS not set.\n"), (int) opt); #endif /* HAVE_MESSAGES */ break; case MHD_OPTION_APP_FD_SETSIZE: params->fdset_size_set = true; params->fdset_size = va_arg (ap, int); break; #ifndef HTTPS_SUPPORT case MHD_OPTION_HTTPS_MEM_KEY: case MHD_OPTION_HTTPS_MEM_CERT: case MHD_OPTION_HTTPS_CRED_TYPE: case MHD_OPTION_HTTPS_PRIORITIES: case MHD_OPTION_HTTPS_PRIORITIES_APPEND: case MHD_OPTION_HTTPS_MEM_TRUST: case MHD_OPTION_HTTPS_CERT_CALLBACK: case MHD_OPTION_HTTPS_MEM_DHPARAMS: case MHD_OPTION_HTTPS_KEY_PASSWORD: case MHD_OPTION_GNUTLS_PSK_CRED_HANDLER: case MHD_OPTION_HTTPS_CERT_CALLBACK2: #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD HTTPS option %d passed to MHD " "compiled without HTTPS support.\n"), opt); #endif return MHD_NO; #endif /* HTTPS_SUPPORT */ case MHD_OPTION_END: /* Not possible */ default: #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Invalid option %d! (Did you terminate " "the list with MHD_OPTION_END?).\n"), opt); #endif return MHD_NO; } } return MHD_YES; } #ifdef EPOLL_SUPPORT static int setup_epoll_fd (struct MHD_Daemon *daemon) { int fd; #ifndef HAVE_MESSAGES (void) daemon; /* Mute compiler warning. */ #endif /* ! HAVE_MESSAGES */ #ifdef USE_EPOLL_CREATE1 fd = epoll_create1 (EPOLL_CLOEXEC); #else /* ! USE_EPOLL_CREATE1 */ fd = epoll_create (MAX_EVENTS); #endif /* ! USE_EPOLL_CREATE1 */ if (MHD_INVALID_SOCKET == fd) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Call to epoll_create1 failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_INVALID_SOCKET; } #if ! defined(USE_EPOLL_CREATE1) if (! MHD_socket_noninheritable_ (fd)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to set noninheritable mode on epoll FD.\n")); #endif } #endif /* ! USE_EPOLL_CREATE1 */ return fd; } /** * Setup epoll() FD for the daemon and initialize it to listen * on the listen FD. * @remark To be called only from MHD_start_daemon_va() * * @param daemon daemon to initialize for epoll() * @return #MHD_YES on success, #MHD_NO on failure */ static enum MHD_Result setup_epoll_to_listen (struct MHD_Daemon *daemon) { struct epoll_event event; MHD_socket ls; mhd_assert (MHD_D_IS_USING_EPOLL_ (daemon)); mhd_assert (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)); mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) || \ MHD_ITC_IS_VALID_ (daemon->itc) ); daemon->epoll_fd = setup_epoll_fd (daemon); if (! MHD_D_IS_USING_THREADS_ (daemon) && (0 != (daemon->options & MHD_USE_AUTO))) { /* Application requested "MHD_USE_AUTO", probably MHD_get_fdset() will be used. Make sure that epoll FD is suitable for fd_set. Actually, MHD_get_fdset() is allowed for MHD_USE_EPOLL direct, but most probably direct requirement for MHD_USE_EPOLL means that epoll FD will be used directly. This logic is fuzzy, but better than nothing with current MHD API. */ if (! MHD_D_DOES_SCKT_FIT_FDSET_ (daemon->epoll_fd, daemon)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("The epoll FD is too large to be used with fd_set.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } } if (-1 == daemon->epoll_fd) return MHD_NO; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if (0 != (MHD_ALLOW_UPGRADE & daemon->options)) { daemon->epoll_upgrade_fd = setup_epoll_fd (daemon); if (MHD_INVALID_SOCKET == daemon->epoll_upgrade_fd) return MHD_NO; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if ( (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) && (! daemon->was_quiesced) ) { event.events = EPOLLIN | EPOLLRDHUP; event.data.ptr = daemon; if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, ls, &event)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_NO; } daemon->listen_socket_in_epoll = true; } if (MHD_ITC_IS_VALID_ (daemon->itc)) { event.events = EPOLLIN | EPOLLRDHUP; event.data.ptr = _MHD_DROP_CONST (epoll_itc_marker); if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, MHD_itc_r_fd_ (daemon->itc), &event)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif return MHD_NO; } } return MHD_YES; } #endif /** * Apply interim parameters * @param[in,out] d the daemon to use * @param[out] ppsockaddr the pointer to store the pointer to 'struct sockaddr' * if provided by application * @param[out] psockaddr_len the size memory area pointed by 'struct sockaddr' * if provided by application * @param[in,out] params the interim parameters to process * @return true in case of success, * false in case of critical error (the daemon must be closed). */ static bool process_interim_params (struct MHD_Daemon *d, const struct sockaddr **ppsockaddr, socklen_t *psockaddr_len, struct MHD_InterimParams_ *params) { if (params->fdset_size_set) { if (0 >= params->fdset_size) { #ifdef HAVE_MESSAGES MHD_DLOG (d, _ ("MHD_OPTION_APP_FD_SETSIZE value (%d) is not positive.\n"), params->fdset_size); #endif /* HAVE_MESSAGES */ return false; } if (MHD_D_IS_USING_THREADS_ (d)) { #ifdef HAVE_MESSAGES MHD_DLOG (d, _ ("MHD_OPTION_APP_FD_SETSIZE is ignored for daemon started " \ "with MHD_USE_INTERNAL_POLLING_THREAD.\n")); #endif /* HAVE_MESSAGES */ (void) 0; } else if (MHD_D_IS_USING_POLL_ (d)) { #ifdef HAVE_MESSAGES MHD_DLOG (d, _ ("MHD_OPTION_APP_FD_SETSIZE is ignored for daemon started " \ "with MHD_USE_POLL.\n")); #endif /* HAVE_MESSAGES */ (void) 0; } else { /* The daemon without internal threads, external sockets polling */ #ifndef HAS_FD_SETSIZE_OVERRIDABLE if (((int) FD_SETSIZE) != params->fdset_size) { #ifdef HAVE_MESSAGES MHD_DLOG (d, _ ("MHD_OPTION_APP_FD_SETSIZE value (%d) does not match " \ "the platform FD_SETSIZE value (%d) and this platform " \ "does not support overriding of FD_SETSIZE.\n"), params->fdset_size, (int) FD_SETSIZE); #endif /* HAVE_MESSAGES */ return false; } #else /* HAS_FD_SETSIZE_OVERRIDABLE */ d->fdset_size = params->fdset_size; d->fdset_size_set_by_app = true; #endif /* HAS_FD_SETSIZE_OVERRIDABLE */ } } if (params->listen_fd_set) { if (MHD_INVALID_SOCKET == params->listen_fd) { (void) 0; /* Use MHD-created socket */ } #ifdef HAS_SIGNED_SOCKET else if (0 > params->listen_fd) { #ifdef HAVE_MESSAGES MHD_DLOG (d, _ ("The value provided for MHD_OPTION_LISTEN_SOCKET " \ "is invalid.\n")); #endif /* HAVE_MESSAGES */ return false; } #endif /* HAS_SIGNED_SOCKET */ else if (0 != (d->options & MHD_USE_NO_LISTEN_SOCKET)) { #ifdef HAVE_MESSAGES MHD_DLOG (d, _ ("MHD_OPTION_LISTEN_SOCKET specified for daemon " "with MHD_USE_NO_LISTEN_SOCKET flag set.\n")); #endif /* HAVE_MESSAGES */ (void) MHD_socket_close_ (params->listen_fd); return false; } else { d->listen_fd = params->listen_fd; d->listen_is_unix = _MHD_UNKNOWN; #ifdef MHD_USE_GETSOCKNAME d->port = 0; /* Force use of autodetection */ #endif /* MHD_USE_GETSOCKNAME */ } } mhd_assert (! params->server_addr_len_set || params->pserver_addr_set); if (params->pserver_addr_set) { if (NULL == params->pserver_addr) { /* The size must be zero if set */ if (params->server_addr_len_set && (0 != params->server_addr_len)) return false; /* Ignore parameter if it is NULL */ } else if (MHD_INVALID_SOCKET != d->listen_fd) { #ifdef HAVE_MESSAGES MHD_DLOG (d, _ ("MHD_OPTION_LISTEN_SOCKET cannot be used together with " \ "MHD_OPTION_SOCK_ADDR_LEN or MHD_OPTION_SOCK_ADDR.\n")); #endif /* HAVE_MESSAGES */ return false; } else if (0 != (d->options & MHD_USE_NO_LISTEN_SOCKET)) { #ifdef HAVE_MESSAGES MHD_DLOG (d, _ ("MHD_OPTION_SOCK_ADDR_LEN or MHD_OPTION_SOCK_ADDR " \ "specified for daemon with MHD_USE_NO_LISTEN_SOCKET " \ "flag set.\n")); #endif /* HAVE_MESSAGES */ if (MHD_INVALID_SOCKET != d->listen_fd) { (void) MHD_socket_close_ (params->listen_fd); params->listen_fd = MHD_INVALID_SOCKET; } return false; } else { *ppsockaddr = params->pserver_addr; if (params->server_addr_len_set) { /* The size must be non-zero if set */ if (0 == params->server_addr_len) return false; *psockaddr_len = params->server_addr_len; } else *psockaddr_len = 0; } } return true; } /** * Start a webserver on the given port. * * @param flags combination of `enum MHD_FLAG` values * @param port port to bind to (in host byte order), * use '0' to bind to random free port, * ignored if #MHD_OPTION_SOCK_ADDR or * #MHD_OPTION_LISTEN_SOCKET is provided * or #MHD_USE_NO_LISTEN_SOCKET is specified * @param apc callback to call to check which clients * will be allowed to connect; you can pass NULL * in which case connections from any IP will be * accepted * @param apc_cls extra argument to @a apc * @param dh handler called for all requests (repeatedly) * @param dh_cls extra argument to @a dh * @param ap list of options (type-value pairs, * terminated with #MHD_OPTION_END). * @return NULL on error, handle to daemon on success * @ingroup event */ _MHD_EXTERN struct MHD_Daemon * MHD_start_daemon_va (unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, va_list ap) { const MHD_SCKT_OPT_BOOL_ on = 1; struct MHD_Daemon *daemon; MHD_socket listen_fd = MHD_INVALID_SOCKET; const struct sockaddr *pservaddr = NULL; socklen_t addrlen; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) unsigned int i; #endif enum MHD_FLAG eflags; /* same type as in MHD_Daemon */ enum MHD_FLAG *pflags; struct MHD_InterimParams_ *interim_params; MHD_check_global_init_ (); eflags = (enum MHD_FLAG) flags; pflags = &eflags; if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) *pflags |= MHD_USE_INTERNAL_POLLING_THREAD; /* Force enable, log warning later if needed */ #ifndef HAVE_INET6 if (0 != (*pflags & MHD_USE_IPv6)) return NULL; #endif #ifndef HAVE_POLL if (0 != (*pflags & MHD_USE_POLL)) return NULL; #endif #ifndef EPOLL_SUPPORT if (0 != (*pflags & MHD_USE_EPOLL)) return NULL; #endif /* ! EPOLL_SUPPORT */ #ifndef HTTPS_SUPPORT if (0 != (*pflags & MHD_USE_TLS)) return NULL; #endif /* ! HTTPS_SUPPORT */ #ifndef TCP_FASTOPEN if (0 != (*pflags & MHD_USE_TCP_FASTOPEN)) return NULL; #endif if (0 != (*pflags & MHD_ALLOW_UPGRADE)) { #ifdef UPGRADE_SUPPORT *pflags |= MHD_ALLOW_SUSPEND_RESUME; #else /* ! UPGRADE_SUPPORT */ return NULL; #endif /* ! UPGRADE_SUPPORT */ } #ifdef MHD_USE_THREADS if ((MHD_USE_NO_THREAD_SAFETY | MHD_USE_INTERNAL_POLLING_THREAD) == ((MHD_USE_NO_THREAD_SAFETY | MHD_USE_INTERNAL_POLLING_THREAD) & *pflags)) return NULL; /* Cannot be thread-unsafe with multiple threads */ #else /* ! MHD_USE_THREADS */ if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) return NULL; #endif /* ! MHD_USE_THREADS */ if (NULL == dh) return NULL; /* Check for invalid combinations of flags. */ if ((0 != (*pflags & MHD_USE_POLL)) && (0 != (*pflags & MHD_USE_EPOLL))) return NULL; if ((0 != (*pflags & MHD_USE_EPOLL)) && (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION))) return NULL; if ((0 != (*pflags & MHD_USE_POLL)) && (0 == (*pflags & (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION)))) return NULL; if ((0 != (*pflags & MHD_USE_AUTO)) && (0 != (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL)))) return NULL; if (0 != (*pflags & MHD_USE_AUTO)) { #if defined(EPOLL_SUPPORT) && defined(HAVE_POLL) if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) *pflags |= MHD_USE_POLL; else *pflags |= MHD_USE_EPOLL; /* Including "external select" mode */ #elif defined(HAVE_POLL) if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) *pflags |= MHD_USE_POLL; /* Including thread-per-connection */ #elif defined(EPOLL_SUPPORT) if (0 == (*pflags & MHD_USE_THREAD_PER_CONNECTION)) *pflags |= MHD_USE_EPOLL; /* Including "external select" mode */ #else /* No choice: use select() for any mode - do not modify flags */ #endif } if (0 != (*pflags & MHD_USE_NO_THREAD_SAFETY)) *pflags = (*pflags & ~((enum MHD_FLAG) MHD_USE_ITC)); /* useless in single-threaded environment */ else if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) { #ifdef HAVE_LISTEN_SHUTDOWN if (0 != (*pflags & MHD_USE_NO_LISTEN_SOCKET)) #endif *pflags |= MHD_USE_ITC; /* yes, must use ITC to signal thread */ } if (NULL == (daemon = MHD_calloc_ (1, sizeof (struct MHD_Daemon)))) return NULL; interim_params = (struct MHD_InterimParams_ *) \ MHD_calloc_ (1, sizeof (struct MHD_InterimParams_)); if (NULL == interim_params) { int err_num = errno; free (daemon); errno = err_num; return NULL; } #ifdef EPOLL_SUPPORT daemon->epoll_fd = -1; #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) daemon->epoll_upgrade_fd = -1; #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ #endif /* try to open listen socket */ #ifdef HTTPS_SUPPORT daemon->priority_cache = NULL; #endif /* HTTPS_SUPPORT */ daemon->listen_fd = MHD_INVALID_SOCKET; daemon->listen_is_unix = _MHD_NO; daemon->listening_address_reuse = 0; daemon->options = *pflags; pflags = &daemon->options; daemon->client_discipline = (0 != (*pflags & MHD_USE_PEDANTIC_CHECKS)) ? 1 : 0; daemon->port = port; daemon->apc = apc; daemon->apc_cls = apc_cls; daemon->default_handler = dh; daemon->default_handler_cls = dh_cls; daemon->connections = 0; daemon->connection_limit = MHD_MAX_CONNECTIONS_DEFAULT; daemon->pool_size = MHD_POOL_SIZE_DEFAULT; daemon->pool_increment = MHD_BUF_INC_SIZE; daemon->unescape_callback = &unescape_wrapper; daemon->connection_timeout_ms = 0; /* no timeout */ MHD_itc_set_invalid_ (daemon->itc); #ifdef MHD_USE_THREADS MHD_thread_handle_ID_set_invalid_ (&daemon->tid); #endif /* MHD_USE_THREADS */ #ifdef SOMAXCONN daemon->listen_backlog_size = SOMAXCONN; #else /* !SOMAXCONN */ daemon->listen_backlog_size = 511; /* should be safe value */ #endif /* !SOMAXCONN */ #ifdef HAVE_MESSAGES daemon->custom_error_log = &MHD_default_logger_; daemon->custom_error_log_cls = stderr; #endif #ifndef MHD_WINSOCK_SOCKETS daemon->sigpipe_blocked = false; #else /* MHD_WINSOCK_SOCKETS */ /* There is no SIGPIPE on W32, nothing to block. */ daemon->sigpipe_blocked = true; #endif /* _WIN32 && ! __CYGWIN__ */ #if defined(_DEBUG) && defined(HAVE_ACCEPT4) daemon->avoid_accept4 = false; #endif /* _DEBUG */ #ifdef HAS_FD_SETSIZE_OVERRIDABLE daemon->fdset_size = (int) FD_SETSIZE; daemon->fdset_size_set_by_app = false; #endif /* HAS_FD_SETSIZE_OVERRIDABLE */ #ifdef DAUTH_SUPPORT daemon->digest_auth_rand_size = 0; daemon->digest_auth_random = NULL; daemon->nonce_nc_size = 4; /* tiny */ daemon->dauth_def_nonce_timeout = MHD_DAUTH_DEF_TIMEOUT_; daemon->dauth_def_max_nc = MHD_DAUTH_DEF_MAX_NC_; #endif #ifdef HTTPS_SUPPORT if (0 != (*pflags & MHD_USE_TLS)) { daemon->cred_type = GNUTLS_CRD_CERTIFICATE; } #endif /* HTTPS_SUPPORT */ interim_params->num_opts = 0; interim_params->fdset_size_set = false; interim_params->fdset_size = 0; interim_params->listen_fd_set = false; interim_params->listen_fd = MHD_INVALID_SOCKET; interim_params->pserver_addr_set = false; interim_params->pserver_addr = NULL; interim_params->server_addr_len_set = false; interim_params->server_addr_len = 0; if (MHD_NO == parse_options_va (daemon, interim_params, ap)) { #ifdef HTTPS_SUPPORT if ( (0 != (*pflags & MHD_USE_TLS)) && (NULL != daemon->priority_cache) ) gnutls_priority_deinit (daemon->priority_cache); #endif /* HTTPS_SUPPORT */ free (interim_params); free (daemon); return NULL; } if (! process_interim_params (daemon, &pservaddr, &addrlen, interim_params)) { free (interim_params); free (daemon); return NULL; } free (interim_params); interim_params = NULL; #ifdef HTTPS_SUPPORT if ((0 != (*pflags & MHD_USE_TLS)) && (NULL == daemon->priority_cache) && ! daemon_tls_priorities_init_default (daemon)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to initialise GnuTLS priorities.\n")); #endif /* HAVE_MESSAGES */ free (daemon); return NULL; } #endif /* HTTPS_SUPPORT */ #ifdef HAVE_MESSAGES if ( (0 != (flags & MHD_USE_THREAD_PER_CONNECTION)) && (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD)) ) { MHD_DLOG (daemon, _ ("Warning: MHD_USE_THREAD_PER_CONNECTION must be used " \ "only with MHD_USE_INTERNAL_POLLING_THREAD. " \ "Flag MHD_USE_INTERNAL_POLLING_THREAD was added. " \ "Consider setting MHD_USE_INTERNAL_POLLING_THREAD " \ "explicitly.\n")); } #endif if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) && ((NULL != daemon->notify_completed) || (NULL != daemon->notify_connection)) ) *pflags |= MHD_USE_ITC; /* requires ITC */ #ifdef _DEBUG #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Using debug build of libmicrohttpd.\n") ); #endif /* HAVE_MESSAGES */ #endif /* _DEBUG */ if ( (0 != (*pflags & MHD_USE_ITC)) #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) && (0 == daemon->worker_pool_size) #endif ) { if (! MHD_itc_init_ (daemon->itc)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to create inter-thread communication channel: %s\n"), MHD_itc_last_strerror_ ()); #endif #ifdef HTTPS_SUPPORT if (NULL != daemon->priority_cache) gnutls_priority_deinit (daemon->priority_cache); #endif /* HTTPS_SUPPORT */ free (daemon); return NULL; } if (MHD_D_IS_USING_SELECT_ (daemon) && (! MHD_D_DOES_SCKT_FIT_FDSET_ (MHD_itc_r_fd_ (daemon->itc), daemon)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("file descriptor for inter-thread communication " \ "channel exceeds maximum value.\n")); #endif MHD_itc_destroy_chk_ (daemon->itc); #ifdef HTTPS_SUPPORT if (NULL != daemon->priority_cache) gnutls_priority_deinit (daemon->priority_cache); #endif /* HTTPS_SUPPORT */ free (daemon); return NULL; } } #ifdef DAUTH_SUPPORT if (NULL != daemon->digest_auth_random_copy) { mhd_assert (daemon == daemon->digest_auth_random_copy); daemon->digest_auth_random_copy = malloc (daemon->digest_auth_rand_size); if (NULL == daemon->digest_auth_random_copy) { #ifdef HTTPS_SUPPORT if (0 != (*pflags & MHD_USE_TLS)) gnutls_priority_deinit (daemon->priority_cache); #endif /* HTTPS_SUPPORT */ free (daemon); return NULL; } memcpy (daemon->digest_auth_random_copy, daemon->digest_auth_random, daemon->digest_auth_rand_size); daemon->digest_auth_random = daemon->digest_auth_random_copy; } if (daemon->nonce_nc_size > 0) { if ( ( (size_t) (daemon->nonce_nc_size * sizeof (struct MHD_NonceNc))) / sizeof(struct MHD_NonceNc) != daemon->nonce_nc_size) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Specified value for NC_SIZE too large.\n")); #endif #ifdef HTTPS_SUPPORT if (0 != (*pflags & MHD_USE_TLS)) gnutls_priority_deinit (daemon->priority_cache); #endif /* HTTPS_SUPPORT */ free (daemon->digest_auth_random_copy); free (daemon); return NULL; } daemon->nnc = MHD_calloc_ (daemon->nonce_nc_size, sizeof (struct MHD_NonceNc)); if (NULL == daemon->nnc) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to allocate memory for nonce-nc map: %s\n"), MHD_strerror_ (errno)); #endif #ifdef HTTPS_SUPPORT if (0 != (*pflags & MHD_USE_TLS)) gnutls_priority_deinit (daemon->priority_cache); #endif /* HTTPS_SUPPORT */ free (daemon->digest_auth_random_copy); free (daemon); return NULL; } } #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (! MHD_mutex_init_ (&daemon->nnc_lock)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD failed to initialize nonce-nc mutex.\n")); #endif #ifdef HTTPS_SUPPORT if (0 != (*pflags & MHD_USE_TLS)) gnutls_priority_deinit (daemon->priority_cache); #endif /* HTTPS_SUPPORT */ free (daemon->digest_auth_random_copy); free (daemon->nnc); free (daemon); return NULL; } #endif #endif /* Thread polling currently works only with internal select thread mode */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if ( (! MHD_D_IS_USING_THREADS_ (daemon)) && (daemon->worker_pool_size > 0) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD thread polling only works with " \ "MHD_USE_INTERNAL_POLLING_THREAD.\n")); #endif goto free_and_fail; } #endif if ( (MHD_INVALID_SOCKET == daemon->listen_fd) && (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) ) { /* try to open listen socket */ struct sockaddr_in servaddr4; #ifdef HAVE_INET6 struct sockaddr_in6 servaddr6; const bool use_ipv6 = (0 != (*pflags & MHD_USE_IPv6)); #else /* ! HAVE_INET6 */ const bool use_ipv6 = false; #endif /* ! HAVE_INET6 */ int domain; if (NULL != pservaddr) { #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN const socklen_t sa_len = pservaddr->sa_len; #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ #ifdef HAVE_INET6 if (use_ipv6 && (AF_INET6 != pservaddr->sa_family)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD_USE_IPv6 is enabled, but 'struct sockaddr *' " \ "specified for MHD_OPTION_SOCK_ADDR_LEN or " \ "MHD_OPTION_SOCK_ADDR is not IPv6 address.\n")); #endif /* HAVE_MESSAGES */ goto free_and_fail; } #endif /* HAVE_INET6 */ switch (pservaddr->sa_family) { case AF_INET: if (1) { struct sockaddr_in sa4; uint16_t sa4_port; if ((0 != addrlen) && (((socklen_t) sizeof(sa4)) > addrlen)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("The size specified for MHD_OPTION_SOCK_ADDR_LEN " \ "option is wrong.\n")); #endif /* HAVE_MESSAGES */ goto free_and_fail; } #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN if (0 != sa_len) { if (((socklen_t) sizeof(sa4)) > sa_len) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("The value of 'struct sockaddr.sa_len' provided " \ "via MHD_OPTION_SOCK_ADDR_LEN option is not zero " \ "and does not match 'sa_family' value of the " \ "same structure.\n")); #endif /* HAVE_MESSAGES */ goto free_and_fail; } if ((0 == addrlen) || (sa_len < addrlen)) addrlen = sa_len; /* Use smaller value for safety */ } #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ if (0 == addrlen) addrlen = sizeof(sa4); memcpy (&sa4, pservaddr, sizeof(sa4)); /* Required due to stronger alignment */ sa4_port = (uint16_t) ntohs (sa4.sin_port); #ifndef MHD_USE_GETSOCKNAME if (0 != sa4_port) #endif /* ! MHD_USE_GETSOCKNAME */ daemon->port = sa4_port; domain = PF_INET; } break; #ifdef HAVE_INET6 case AF_INET6: if (1) { struct sockaddr_in6 sa6; uint16_t sa6_port; if ((0 != addrlen) && (((socklen_t) sizeof(sa6)) > addrlen)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("The size specified for MHD_OPTION_SOCK_ADDR_LEN " \ "option is wrong.\n")); #endif /* HAVE_MESSAGES */ goto free_and_fail; } #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN if (0 != sa_len) { if (((socklen_t) sizeof(sa6)) > sa_len) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("The value of 'struct sockaddr.sa_len' provided " \ "via MHD_OPTION_SOCK_ADDR_LEN option is not zero " \ "and does not match 'sa_family' value of the " \ "same structure.\n")); #endif /* HAVE_MESSAGES */ goto free_and_fail; } if ((0 == addrlen) || (sa_len < addrlen)) addrlen = sa_len; /* Use smaller value for safety */ } #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ if (0 == addrlen) addrlen = sizeof(sa6); memcpy (&sa6, pservaddr, sizeof(sa6)); /* Required due to stronger alignment */ sa6_port = (uint16_t) ntohs (sa6.sin6_port); #ifndef MHD_USE_GETSOCKNAME if (0 != sa6_port) #endif /* ! MHD_USE_GETSOCKNAME */ daemon->port = sa6_port; domain = PF_INET6; *pflags |= ((enum MHD_FLAG) MHD_USE_IPv6); } break; #endif /* HAVE_INET6 */ #ifdef AF_UNIX case AF_UNIX: #endif /* AF_UNIX */ default: #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN if (0 == addrlen) addrlen = sa_len; else if ((0 != sa_len) && (sa_len < addrlen)) addrlen = sa_len; /* Use smaller value for safety */ #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ if (0 >= addrlen) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("The 'sa_family' of the 'struct sockaddr' provided " \ "via MHD_OPTION_SOCK_ADDR option is not supported.\n")); #endif /* HAVE_MESSAGES */ goto free_and_fail; } #ifdef AF_UNIX if (AF_UNIX == pservaddr->sa_family) { daemon->port = 0; /* special value for UNIX domain sockets */ daemon->listen_is_unix = _MHD_YES; #ifdef PF_UNIX domain = PF_UNIX; #else /* ! PF_UNIX */ domain = AF_UNIX; #endif /* ! PF_UNIX */ } else /* combined with the next 'if' */ #endif /* AF_UNIX */ if (1) { daemon->port = 0; /* ugh */ daemon->listen_is_unix = _MHD_UNKNOWN; /* Assumed the same values for AF_* and PF_* */ domain = pservaddr->sa_family; } break; } } else { if (! use_ipv6) { memset (&servaddr4, 0, sizeof (struct sockaddr_in)); servaddr4.sin_family = AF_INET; servaddr4.sin_port = htons (port); if (0 != INADDR_ANY) servaddr4.sin_addr.s_addr = htonl (INADDR_ANY); #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN servaddr4.sin_len = sizeof (struct sockaddr_in); #endif pservaddr = (struct sockaddr *) &servaddr4; addrlen = (socklen_t) sizeof(servaddr4); daemon->listen_is_unix = _MHD_NO; domain = PF_INET; } #ifdef HAVE_INET6 else { #ifdef IN6ADDR_ANY_INIT static const struct in6_addr static_in6any = IN6ADDR_ANY_INIT; #endif memset (&servaddr6, 0, sizeof (struct sockaddr_in6)); servaddr6.sin6_family = AF_INET6; servaddr6.sin6_port = htons (port); #ifdef IN6ADDR_ANY_INIT servaddr6.sin6_addr = static_in6any; #endif #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN servaddr6.sin6_len = sizeof (struct sockaddr_in6); #endif pservaddr = (struct sockaddr *) &servaddr6; addrlen = (socklen_t) sizeof (servaddr6); daemon->listen_is_unix = _MHD_NO; domain = PF_INET6; } #endif /* HAVE_INET6 */ } listen_fd = MHD_socket_create_listen_ (domain); if (MHD_INVALID_SOCKET == listen_fd) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to create socket for listening: %s\n"), MHD_socket_last_strerr_ ()); #endif goto free_and_fail; } if (MHD_D_IS_USING_SELECT_ (daemon) && (! MHD_D_DOES_SCKT_FIT_FDSET_ (listen_fd, daemon)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Listen socket descriptor (%d) is not " \ "less than daemon FD_SETSIZE value (%d).\n"), (int) listen_fd, (int) MHD_D_GET_FD_SETSIZE_ (daemon)); #endif MHD_socket_close_chk_ (listen_fd); listen_fd = MHD_INVALID_SOCKET; goto free_and_fail; } /* Apply the socket options according to listening_address_reuse. */ if (0 == daemon->listening_address_reuse) { #ifndef MHD_WINSOCK_SOCKETS /* No user requirement, use "traditional" default SO_REUSEADDR * on non-W32 platforms, and do not fail if it doesn't work. * Don't use it on W32, because on W32 it will allow multiple * bind to the same address:port, like SO_REUSEPORT on others. */ if (0 > setsockopt (listen_fd, SOL_SOCKET, SO_REUSEADDR, (const void *) &on, sizeof (on))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif } #endif /* ! MHD_WINSOCK_SOCKETS */ } else if (daemon->listening_address_reuse > 0) { /* User requested to allow reusing listening address:port. */ #ifndef MHD_WINSOCK_SOCKETS /* Use SO_REUSEADDR on non-W32 platforms, and do not fail if * it doesn't work. */ if (0 > setsockopt (listen_fd, SOL_SOCKET, SO_REUSEADDR, (const void *) &on, sizeof (on))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif } #endif /* ! MHD_WINSOCK_SOCKETS */ /* Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms. * Fail if SO_REUSEPORT is not defined or setsockopt fails. */ /* SO_REUSEADDR on W32 has the same semantics as SO_REUSEPORT on BSD/Linux */ #if defined(MHD_WINSOCK_SOCKETS) || defined(SO_REUSEPORT) if (0 > setsockopt (listen_fd, SOL_SOCKET, #ifndef MHD_WINSOCK_SOCKETS SO_REUSEPORT, #else /* MHD_WINSOCK_SOCKETS */ SO_REUSEADDR, #endif /* MHD_WINSOCK_SOCKETS */ (const void *) &on, sizeof (on))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif goto free_and_fail; } #else /* !MHD_WINSOCK_SOCKETS && !SO_REUSEPORT */ /* we're supposed to allow address:port re-use, but on this platform we cannot; fail hard */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Cannot allow listening address reuse: " \ "SO_REUSEPORT not defined.\n")); #endif goto free_and_fail; #endif /* !MHD_WINSOCK_SOCKETS && !SO_REUSEPORT */ } else /* if (daemon->listening_address_reuse < 0) */ { /* User requested to disallow reusing listening address:port. * Do nothing except for Windows where SO_EXCLUSIVEADDRUSE * is used and Solaris with SO_EXCLBIND. * Fail if MHD was compiled for W32 without SO_EXCLUSIVEADDRUSE * or setsockopt fails. */ #if (defined(MHD_WINSOCK_SOCKETS) && defined(SO_EXCLUSIVEADDRUSE)) || \ (defined(__sun) && defined(SO_EXCLBIND)) if (0 > setsockopt (listen_fd, SOL_SOCKET, #ifdef SO_EXCLUSIVEADDRUSE SO_EXCLUSIVEADDRUSE, #else /* SO_EXCLBIND */ SO_EXCLBIND, #endif /* SO_EXCLBIND */ (const void *) &on, sizeof (on))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif goto free_and_fail; } #elif defined(MHD_WINSOCK_SOCKETS) /* SO_EXCLUSIVEADDRUSE not defined on W32? */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Cannot disallow listening address reuse: " \ "SO_EXCLUSIVEADDRUSE not defined.\n")); #endif goto free_and_fail; #endif /* MHD_WINSOCK_SOCKETS */ } /* check for user supplied sockaddr */ daemon->listen_fd = listen_fd; if (0 != (*pflags & MHD_USE_IPv6)) { #ifdef IPPROTO_IPV6 #ifdef IPV6_V6ONLY /* Note: "IPV6_V6ONLY" is declared by Windows Vista ff., see "IPPROTO_IPV6 Socket Options" (http://msdn.microsoft.com/en-us/library/ms738574%28v=VS.85%29.aspx); and may also be missing on older POSIX systems; good luck if you have any of those, your IPv6 socket may then also bind against IPv4 anyway... */ const MHD_SCKT_OPT_BOOL_ v6_only = (MHD_USE_DUAL_STACK != (*pflags & MHD_USE_DUAL_STACK)); if (0 > setsockopt (listen_fd, IPPROTO_IPV6, IPV6_V6ONLY, (const void *) &v6_only, sizeof (v6_only))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif } #endif #endif } if (0 != bind (listen_fd, pservaddr, addrlen)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to bind to port %u: %s\n"), (unsigned int) port, MHD_socket_last_strerr_ ()); #endif MHD_socket_close_chk_ (listen_fd); listen_fd = MHD_INVALID_SOCKET; goto free_and_fail; } #ifdef TCP_FASTOPEN if (0 != (*pflags & MHD_USE_TCP_FASTOPEN)) { if (0 == daemon->fastopen_queue_size) daemon->fastopen_queue_size = MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT; if (0 != setsockopt (listen_fd, IPPROTO_TCP, TCP_FASTOPEN, (const void *) &daemon->fastopen_queue_size, sizeof (daemon->fastopen_queue_size))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("setsockopt failed: %s\n"), MHD_socket_last_strerr_ ()); #endif } } #endif if (0 != listen (listen_fd, (int) daemon->listen_backlog_size)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to listen for connections: %s\n"), MHD_socket_last_strerr_ ()); #endif MHD_socket_close_chk_ (listen_fd); listen_fd = MHD_INVALID_SOCKET; goto free_and_fail; } } else { if (MHD_D_IS_USING_SELECT_ (daemon) && (! MHD_D_DOES_SCKT_FIT_FDSET_ (daemon->listen_fd, daemon)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Listen socket descriptor (%d) is not " \ "less than daemon FD_SETSIZE value (%d).\n"), (int) daemon->listen_fd, (int) MHD_D_GET_FD_SETSIZE_ (daemon)); #endif goto free_and_fail; } else { #if defined(SOL_SOCKET) && (defined(SO_DOMAIN) || defined(SO_PROTOCOL_INFOW)) int af; int opt_name; void *poptval; socklen_t optval_size; #ifdef SO_DOMAIN opt_name = SO_DOMAIN; poptval = ⁡ optval_size = (socklen_t) sizeof (af); #else /* SO_PROTOCOL_INFOW */ WSAPROTOCOL_INFOW prot_info; opt_name = SO_PROTOCOL_INFOW; poptval = &prot_info; optval_size = (socklen_t) sizeof (prot_info); #endif /* SO_PROTOCOL_INFOW */ if (0 == getsockopt (daemon->listen_fd, SOL_SOCKET, opt_name, poptval, &optval_size)) { #ifndef SO_DOMAIN af = prot_info.iAddressFamily; #endif /* SO_DOMAIN */ switch (af) { case AF_INET: daemon->listen_is_unix = _MHD_NO; break; #ifdef HAVE_INET6 case AF_INET6: *pflags |= MHD_USE_IPv6; daemon->listen_is_unix = _MHD_NO; break; #endif /* HAVE_INET6 */ #ifdef AF_UNIX case AF_UNIX: daemon->port = 0; /* special value for UNIX domain sockets */ daemon->listen_is_unix = _MHD_YES; break; #endif /* AF_UNIX */ default: daemon->port = 0; /* ugh */ daemon->listen_is_unix = _MHD_UNKNOWN; break; } } else #endif /* SOL_SOCKET && (SO_DOMAIN || SO_PROTOCOL_INFOW)) */ daemon->listen_is_unix = _MHD_UNKNOWN; } listen_fd = daemon->listen_fd; #ifdef MHD_USE_GETSOCKNAME daemon->port = 0; /* Force use of autodetection */ #endif /* MHD_USE_GETSOCKNAME */ } #ifdef MHD_USE_GETSOCKNAME if ( (0 == daemon->port) && (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) && (_MHD_YES != daemon->listen_is_unix) ) { /* Get port number. */ struct sockaddr_storage bindaddr; memset (&bindaddr, 0, sizeof (struct sockaddr_storage)); addrlen = sizeof (struct sockaddr_storage); #ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN bindaddr.ss_len = (socklen_t) addrlen; #endif if (0 != getsockname (listen_fd, (struct sockaddr *) &bindaddr, &addrlen)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to get listen port number: %s\n"), MHD_socket_last_strerr_ ()); #endif /* HAVE_MESSAGES */ } #ifdef MHD_POSIX_SOCKETS else if (sizeof (bindaddr) < addrlen) { /* should be impossible with `struct sockaddr_storage` */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to get listen port number " \ "(`struct sockaddr_storage` too small!?).\n")); #endif /* HAVE_MESSAGES */ } #ifndef __linux__ else if (0 == addrlen) { /* Many non-Linux-based platforms return zero addrlen * for AF_UNIX sockets */ daemon->port = 0; /* special value for UNIX domain sockets */ if (_MHD_UNKNOWN == daemon->listen_is_unix) daemon->listen_is_unix = _MHD_YES; } #endif /* __linux__ */ #endif /* MHD_POSIX_SOCKETS */ else { switch (bindaddr.ss_family) { case AF_INET: { struct sockaddr_in *s4 = (struct sockaddr_in *) &bindaddr; daemon->port = ntohs (s4->sin_port); daemon->listen_is_unix = _MHD_NO; break; } #ifdef HAVE_INET6 case AF_INET6: { struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) &bindaddr; daemon->port = ntohs (s6->sin6_port); daemon->listen_is_unix = _MHD_NO; mhd_assert (0 != (*pflags & MHD_USE_IPv6)); break; } #endif /* HAVE_INET6 */ #ifdef AF_UNIX case AF_UNIX: daemon->port = 0; /* special value for UNIX domain sockets */ daemon->listen_is_unix = _MHD_YES; break; #endif default: #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Listen socket has unknown address family!\n")); #endif daemon->port = 0; /* ugh */ daemon->listen_is_unix = _MHD_UNKNOWN; break; } } } #endif /* MHD_USE_GETSOCKNAME */ if (MHD_INVALID_SOCKET != listen_fd) { mhd_assert (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)); if (! MHD_socket_nonblocking_ (listen_fd)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to set nonblocking mode on listening socket: %s\n"), MHD_socket_last_strerr_ ()); #endif if (MHD_D_IS_USING_EPOLL_ (daemon) #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) || (daemon->worker_pool_size > 0) #endif ) { /* Accept must be non-blocking. Multiple children may wake up * to handle a new connection, but only one will win the race. * The others must immediately return. */ MHD_socket_close_chk_ (listen_fd); listen_fd = MHD_INVALID_SOCKET; goto free_and_fail; } daemon->listen_nonblk = false; } else daemon->listen_nonblk = true; } else { mhd_assert (0 != (*pflags & MHD_USE_NO_LISTEN_SOCKET)); daemon->listen_nonblk = false; /* Actually listen socket does not exist */ } #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon) #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) && (0 == daemon->worker_pool_size) #endif ) { if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Combining MHD_USE_THREAD_PER_CONNECTION and " \ "MHD_USE_EPOLL is not supported.\n")); #endif goto free_and_fail; } if (MHD_NO == setup_epoll_to_listen (daemon)) goto free_and_fail; } #endif /* EPOLL_SUPPORT */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (! MHD_mutex_init_ (&daemon->per_ip_connection_mutex)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("MHD failed to initialize IP connection limit mutex.\n")); #endif if (MHD_INVALID_SOCKET != listen_fd) MHD_socket_close_chk_ (listen_fd); goto free_and_fail; } #endif #ifdef HTTPS_SUPPORT /* initialize HTTPS daemon certificate aspects & send / recv functions */ if ( (0 != (*pflags & MHD_USE_TLS)) && (0 != MHD_TLS_init (daemon)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to initialize TLS support.\n")); #endif if (MHD_INVALID_SOCKET != listen_fd) MHD_socket_close_chk_ (listen_fd); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex); #endif goto free_and_fail; } #endif /* HTTPS_SUPPORT */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) /* Start threads if requested by parameters */ if (MHD_D_IS_USING_THREADS_ (daemon)) { /* Internal thread (or threads) is used. * Make sure that MHD will be able to communicate with threads. */ /* If using a thread pool ITC will be initialised later * for each individual worker thread. */ #ifdef HAVE_LISTEN_SHUTDOWN mhd_assert ((1 < daemon->worker_pool_size) || \ (MHD_ITC_IS_VALID_ (daemon->itc)) || \ (MHD_INVALID_SOCKET != daemon->listen_fd)); #else /* ! HAVE_LISTEN_SHUTDOWN */ mhd_assert ((1 < daemon->worker_pool_size) || \ (MHD_ITC_IS_VALID_ (daemon->itc))); #endif /* ! HAVE_LISTEN_SHUTDOWN */ if (0 == daemon->worker_pool_size) { if (! MHD_mutex_init_ (&daemon->cleanup_connection_mutex)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to initialise internal lists mutex.\n")); #endif MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex); if (MHD_INVALID_SOCKET != listen_fd) MHD_socket_close_chk_ (listen_fd); goto free_and_fail; } if (! MHD_mutex_init_ (&daemon->new_connections_mutex)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to initialise mutex.\n")); #endif MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex); MHD_mutex_destroy_chk_ (&daemon->cleanup_connection_mutex); if (MHD_INVALID_SOCKET != listen_fd) MHD_socket_close_chk_ (listen_fd); goto free_and_fail; } if (! MHD_create_named_thread_ (&daemon->tid, MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) ? "MHD-listen" : "MHD-single", daemon->thread_stack_size, &MHD_polling_thread, daemon) ) { #ifdef HAVE_MESSAGES #ifdef EAGAIN if (EAGAIN == errno) MHD_DLOG (daemon, _ ("Failed to create a new thread because it would have " \ "exceeded the system limit on the number of threads or " \ "no system resources available.\n")); else #endif /* EAGAIN */ MHD_DLOG (daemon, _ ("Failed to create listen thread: %s\n"), MHD_strerror_ (errno)); #endif /* HAVE_MESSAGES */ MHD_mutex_destroy_chk_ (&daemon->new_connections_mutex); MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex); MHD_mutex_destroy_chk_ (&daemon->cleanup_connection_mutex); if (MHD_INVALID_SOCKET != listen_fd) MHD_socket_close_chk_ (listen_fd); goto free_and_fail; } } else /* 0 < daemon->worker_pool_size */ { /* Coarse-grained count of connections per thread (note error * due to integer division). Also keep track of how many * connections are leftover after an equal split. */ unsigned int conns_per_thread = daemon->connection_limit / daemon->worker_pool_size; unsigned int leftover_conns = daemon->connection_limit % daemon->worker_pool_size; mhd_assert (2 <= daemon->worker_pool_size); i = 0; /* we need this in case fcntl or malloc fails */ /* Allocate memory for pooled objects */ daemon->worker_pool = malloc (sizeof (struct MHD_Daemon) * daemon->worker_pool_size); if (NULL == daemon->worker_pool) goto thread_failed; /* Start the workers in the pool */ for (i = 0; i < daemon->worker_pool_size; ++i) { /* Create copy of the Daemon object for each worker */ struct MHD_Daemon *d = &daemon->worker_pool[i]; memcpy (d, daemon, sizeof (struct MHD_Daemon)); /* Adjust polling params for worker daemons; note that memcpy() has already copied MHD_USE_INTERNAL_POLLING_THREAD thread mode into the worker threads. */ d->master = daemon; d->worker_pool_size = 0; d->worker_pool = NULL; if (! MHD_mutex_init_ (&d->cleanup_connection_mutex)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to initialise internal lists mutex.\n")); #endif goto thread_failed; } if (! MHD_mutex_init_ (&d->new_connections_mutex)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to initialise mutex.\n")); #endif MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex); goto thread_failed; } if (0 != (*pflags & MHD_USE_ITC)) { if (! MHD_itc_init_ (d->itc)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to create worker inter-thread " \ "communication channel: %s\n"), MHD_itc_last_strerror_ () ); #endif MHD_mutex_destroy_chk_ (&d->new_connections_mutex); MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex); goto thread_failed; } if (MHD_D_IS_USING_SELECT_ (d) && (! MHD_D_DOES_SCKT_FIT_FDSET_ (MHD_itc_r_fd_ (d->itc), daemon)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("File descriptor for worker inter-thread " \ "communication channel exceeds maximum value.\n")); #endif MHD_itc_destroy_chk_ (d->itc); MHD_mutex_destroy_chk_ (&d->new_connections_mutex); MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex); goto thread_failed; } } else MHD_itc_set_invalid_ (d->itc); #ifdef HAVE_LISTEN_SHUTDOWN mhd_assert ((MHD_ITC_IS_VALID_ (d->itc)) || \ (MHD_INVALID_SOCKET != d->listen_fd)); #else /* ! HAVE_LISTEN_SHUTDOWN */ mhd_assert (MHD_ITC_IS_VALID_ (d->itc)); #endif /* ! HAVE_LISTEN_SHUTDOWN */ /* Divide available connections evenly amongst the threads. * Thread indexes in [0, leftover_conns) each get one of the * leftover connections. */ d->connection_limit = conns_per_thread; if (i < leftover_conns) ++d->connection_limit; #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (d) && (MHD_NO == setup_epoll_to_listen (d)) ) { if (MHD_ITC_IS_VALID_ (d->itc)) MHD_itc_destroy_chk_ (d->itc); MHD_mutex_destroy_chk_ (&d->new_connections_mutex); MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex); goto thread_failed; } #endif /* Some members must be used only in master daemon */ #if defined(MHD_USE_THREADS) memset (&d->per_ip_connection_mutex, 0x7F, sizeof(d->per_ip_connection_mutex)); #endif /* MHD_USE_THREADS */ #ifdef DAUTH_SUPPORT d->nnc = NULL; d->nonce_nc_size = 0; d->digest_auth_random_copy = NULL; #if defined(MHD_USE_THREADS) memset (&d->nnc_lock, 0x7F, sizeof(d->nnc_lock)); #endif /* MHD_USE_THREADS */ #endif /* DAUTH_SUPPORT */ /* Spawn the worker thread */ if (! MHD_create_named_thread_ (&d->tid, "MHD-worker", daemon->thread_stack_size, &MHD_polling_thread, d)) { #ifdef HAVE_MESSAGES #ifdef EAGAIN if (EAGAIN == errno) MHD_DLOG (daemon, _ ("Failed to create a new pool thread because it would " \ "have exceeded the system limit on the number of " \ "threads or no system resources available.\n")); else #endif /* EAGAIN */ MHD_DLOG (daemon, _ ("Failed to create pool thread: %s\n"), MHD_strerror_ (errno)); #endif /* Free memory for this worker; cleanup below handles * all previously-created workers. */ MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex); if (MHD_ITC_IS_VALID_ (d->itc)) MHD_itc_destroy_chk_ (d->itc); MHD_mutex_destroy_chk_ (&d->new_connections_mutex); MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex); goto thread_failed; } } } } else { /* Daemon without internal threads */ if (! MHD_mutex_init_ (&daemon->cleanup_connection_mutex)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to initialise internal lists mutex.\n")); #endif MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex); if (MHD_INVALID_SOCKET != listen_fd) MHD_socket_close_chk_ (listen_fd); goto free_and_fail; } if (! MHD_mutex_init_ (&daemon->new_connections_mutex)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to initialise mutex.\n")); #endif MHD_mutex_destroy_chk_ (&daemon->cleanup_connection_mutex); MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex); if (MHD_INVALID_SOCKET != listen_fd) MHD_socket_close_chk_ (listen_fd); goto free_and_fail; } } #endif #ifdef HTTPS_SUPPORT /* API promises to never use the password after initialization, so we additionally NULL it here to not deref a dangling pointer. */ daemon->https_key_password = NULL; #endif /* HTTPS_SUPPORT */ return daemon; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) thread_failed: /* If no worker threads created, then shut down normally. Calling MHD_stop_daemon (as we do below) doesn't work here since it assumes a 0-sized thread pool means we had been in the default MHD_USE_INTERNAL_POLLING_THREAD mode. */ if (0 == i) { if (MHD_INVALID_SOCKET != listen_fd) MHD_socket_close_chk_ (listen_fd); listen_fd = MHD_INVALID_SOCKET; MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex); if (NULL != daemon->worker_pool) free (daemon->worker_pool); goto free_and_fail; } /* Shutdown worker threads we've already created. Pretend as though we had fully initialized our daemon, but with a smaller number of threads than had been requested. */ daemon->worker_pool_size = i; MHD_stop_daemon (daemon); return NULL; #endif free_and_fail: /* clean up basic memory state in 'daemon' and return NULL to indicate failure */ #ifdef EPOLL_SUPPORT #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if (daemon->upgrade_fd_in_epoll) { if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, daemon->epoll_upgrade_fd, NULL)) MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); daemon->upgrade_fd_in_epoll = false; } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ if (-1 != daemon->epoll_fd) close (daemon->epoll_fd); #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if (-1 != daemon->epoll_upgrade_fd) close (daemon->epoll_upgrade_fd); #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ #endif /* EPOLL_SUPPORT */ #ifdef DAUTH_SUPPORT free (daemon->digest_auth_random_copy); free (daemon->nnc); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_destroy_chk_ (&daemon->nnc_lock); #endif #endif #ifdef HTTPS_SUPPORT if (0 != (*pflags & MHD_USE_TLS)) { gnutls_priority_deinit (daemon->priority_cache); if (daemon->x509_cred) gnutls_certificate_free_credentials (daemon->x509_cred); if (daemon->psk_cred) gnutls_psk_free_server_credentials (daemon->psk_cred); } #endif /* HTTPS_SUPPORT */ if (MHD_ITC_IS_VALID_ (daemon->itc)) MHD_itc_destroy_chk_ (daemon->itc); if (MHD_INVALID_SOCKET != listen_fd) (void) MHD_socket_close_ (listen_fd); if ((MHD_INVALID_SOCKET != daemon->listen_fd) && (listen_fd != daemon->listen_fd)) (void) MHD_socket_close_ (daemon->listen_fd); free (daemon); return NULL; } /** * Close all connections for the daemon. * Must only be called when MHD_Daemon::shutdown was set to true. * @remark To be called only from thread that process * daemon's select()/poll()/etc. * * @param daemon daemon to close down */ static void close_all_connections (struct MHD_Daemon *daemon) { struct MHD_Connection *pos; const bool used_thr_p_c = MHD_D_IS_USING_THREAD_PER_CONN_ (daemon); #ifdef UPGRADE_SUPPORT const bool upg_allowed = (0 != (daemon->options & MHD_ALLOW_UPGRADE)); #endif /* UPGRADE_SUPPORT */ #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) struct MHD_UpgradeResponseHandle *urh; struct MHD_UpgradeResponseHandle *urhn; const bool used_tls = (0 != (daemon->options & MHD_USE_TLS)); #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ mhd_assert (daemon->shutdown); #ifdef MHD_USE_THREADS /* Remove externally added new connections that are * not processed by the daemon thread. */ MHD_mutex_lock_chk_ (&daemon->new_connections_mutex); while (NULL != (pos = daemon->new_connections_tail)) { mhd_assert (MHD_D_IS_USING_THREADS_ (daemon)); DLL_remove (daemon->new_connections_head, daemon->new_connections_tail, pos); new_connection_close_ (daemon, pos); } MHD_mutex_unlock_chk_ (&daemon->new_connections_mutex); #endif /* MHD_USE_THREADS */ #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /* give upgraded HTTPS connections a chance to finish */ /* 'daemon->urh_head' is not used in thread-per-connection mode. */ for (urh = daemon->urh_tail; NULL != urh; urh = urhn) { mhd_assert (! used_thr_p_c); urhn = urh->prev; /* call generic forwarding function for passing data with chance to detect that application is done. */ process_urh (urh); MHD_connection_finish_forward_ (urh->connection); urh->clean_ready = true; /* Resuming will move connection to cleanup list. */ MHD_resume_connection (urh->connection); } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /* Give suspended connections a chance to resume to avoid running into the check for there not being any suspended connections left in case of a tight race with a recently resumed connection. */ if (0 != (MHD_TEST_ALLOW_SUSPEND_RESUME & daemon->options)) { daemon->resuming = true; /* Force check for pending resume. */ resume_suspended_connections (daemon); } /* first, make sure all threads are aware of shutdown; need to traverse DLLs in peace... */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif #ifdef UPGRADE_SUPPORT if (upg_allowed) { struct MHD_Connection *susp; susp = daemon->suspended_connections_tail; while (NULL != susp) { if (NULL == susp->urh) /* "Upgraded" connection? */ MHD_PANIC (_ ("MHD_stop_daemon() called while we have " \ "suspended connections.\n")); #ifdef HTTPS_SUPPORT else if (used_tls && used_thr_p_c && (! susp->urh->clean_ready) ) shutdown (susp->urh->app.socket, SHUT_RDWR); /* Wake thread by shutdown of app socket. */ #endif /* HTTPS_SUPPORT */ else { #ifdef HAVE_MESSAGES if (! susp->urh->was_closed) MHD_DLOG (daemon, _ ("Initiated daemon shutdown while \"upgraded\" " \ "connection was not closed.\n")); #endif susp->urh->was_closed = true; /* If thread-per-connection is used, connection's thread * may still processing "upgrade" (exiting). */ if (! used_thr_p_c) MHD_connection_finish_forward_ (susp); /* Do not use MHD_resume_connection() as mutex is * already locked. */ susp->resuming = true; daemon->resuming = true; } susp = susp->prev; } } else /* This 'else' is combined with next 'if' */ #endif /* UPGRADE_SUPPORT */ if (NULL != daemon->suspended_connections_head) MHD_PANIC (_ ("MHD_stop_daemon() called while we have " \ "suspended connections.\n")); #if defined(UPGRADE_SUPPORT) && defined(HTTPS_SUPPORT) #ifdef MHD_USE_THREADS if (upg_allowed && used_tls && used_thr_p_c) { /* "Upgraded" threads may be running in parallel. Connection will not be * moved to the "cleanup list" until connection's thread finishes. * We must ensure that all "upgraded" connections are finished otherwise * connection may stay in "suspended" list and will not be cleaned. */ for (pos = daemon->suspended_connections_tail; NULL != pos; pos = pos->prev) { /* Any connection found here is "upgraded" connection, normal suspended * connections are already removed from this list. */ mhd_assert (NULL != pos->urh); if (! pos->thread_joined) { /* While "cleanup" list is not manipulated by "upgraded" * connection, "cleanup" mutex is required for call of * MHD_resume_connection() during finishing of "upgraded" * thread. */ MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); if (! MHD_thread_handle_ID_join_thread_ (pos->tid)) MHD_PANIC (_ ("Failed to join a thread.\n")); pos->thread_joined = true; MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); } } } #endif /* MHD_USE_THREADS */ #endif for (pos = daemon->connections_tail; NULL != pos; pos = pos->prev) { shutdown (pos->socket_fd, SHUT_RDWR); #ifdef MHD_WINSOCK_SOCKETS if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) && (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "e")) ) MHD_PANIC (_ ("Failed to signal shutdown via inter-thread " \ "communication channel.\n")); #endif } #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) /* now, collect per-connection threads */ if (used_thr_p_c) { pos = daemon->connections_tail; while (NULL != pos) { if (! pos->thread_joined) { MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); if (! MHD_thread_handle_ID_join_thread_ (pos->tid)) MHD_PANIC (_ ("Failed to join a thread.\n")); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); pos->thread_joined = true; /* The thread may have concurrently modified the DLL, need to restart from the beginning */ pos = daemon->connections_tail; continue; } pos = pos->prev; } } MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif #ifdef UPGRADE_SUPPORT /* Finished threads with "upgraded" connections need to be moved * to cleanup list by resume_suspended_connections(). */ /* "Upgraded" connections that were not closed explicitly by * application should be moved to cleanup list too. */ if (upg_allowed) { daemon->resuming = true; /* Force check for pending resume. */ resume_suspended_connections (daemon); } #endif /* UPGRADE_SUPPORT */ mhd_assert (NULL == daemon->suspended_connections_head); /* now that we're alone, move everyone to cleanup */ while (NULL != (pos = daemon->connections_tail)) { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) && (! pos->thread_joined) ) MHD_PANIC (_ ("Failed to join a thread.\n")); #endif close_connection (pos); } MHD_cleanup_connections (daemon); } /** * Shutdown an HTTP daemon. * * @param daemon daemon to stop * @ingroup event */ _MHD_EXTERN void MHD_stop_daemon (struct MHD_Daemon *daemon) { MHD_socket fd; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) unsigned int i; #endif if (NULL == daemon) return; if ( (daemon->shutdown) && (NULL == daemon->master) ) MHD_PANIC (_ ("MHD_stop_daemon() was called twice.")); mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (NULL != daemon->worker_pool) || \ (MHD_thread_handle_ID_is_valid_handle_ (daemon->tid))); mhd_assert (((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) && (NULL == daemon->worker_pool)) || \ (! MHD_thread_handle_ID_is_valid_handle_ (daemon->tid))); /* Slave daemons must be stopped by master daemon. */ mhd_assert ( (NULL == daemon->master) || (daemon->shutdown) ); daemon->shutdown = true; if (daemon->was_quiesced) fd = MHD_INVALID_SOCKET; /* Do not use FD if daemon was quiesced */ else fd = daemon->listen_fd; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != daemon->worker_pool) { /* Master daemon with worker pool. */ mhd_assert (1 < daemon->worker_pool_size); mhd_assert (MHD_D_IS_USING_THREADS_ (daemon)); /* Let workers shutdown in parallel. */ for (i = 0; i < daemon->worker_pool_size; ++i) { daemon->worker_pool[i].shutdown = true; if (MHD_ITC_IS_VALID_ (daemon->worker_pool[i].itc)) { if (! MHD_itc_activate_ (daemon->worker_pool[i].itc, "e")) MHD_PANIC (_ ("Failed to signal shutdown via inter-thread " \ "communication channel.\n")); } else mhd_assert (MHD_INVALID_SOCKET != fd); } #ifdef HAVE_LISTEN_SHUTDOWN if (MHD_INVALID_SOCKET != fd) { (void) shutdown (fd, SHUT_RDWR); } #endif /* HAVE_LISTEN_SHUTDOWN */ for (i = 0; i < daemon->worker_pool_size; ++i) { MHD_stop_daemon (&daemon->worker_pool[i]); } free (daemon->worker_pool); mhd_assert (MHD_ITC_IS_INVALID_ (daemon->itc)); #ifdef EPOLL_SUPPORT mhd_assert (-1 == daemon->epoll_fd); #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) mhd_assert (-1 == daemon->epoll_upgrade_fd); #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ #endif /* EPOLL_SUPPORT */ } else #endif { /* Worker daemon or single daemon. */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (MHD_D_IS_USING_THREADS_ (daemon)) { /* Worker daemon or single daemon with internal thread(s). */ mhd_assert (0 == daemon->worker_pool_size); /* Separate thread(s) is used for polling sockets. */ if (MHD_ITC_IS_VALID_ (daemon->itc)) { if (! MHD_itc_activate_ (daemon->itc, "e")) MHD_PANIC (_ ("Failed to signal shutdown via inter-thread " \ "communication channel.\n")); } else { #ifdef HAVE_LISTEN_SHUTDOWN if (MHD_INVALID_SOCKET != fd) { if (NULL == daemon->master) (void) shutdown (fd, SHUT_RDWR); } else #endif /* HAVE_LISTEN_SHUTDOWN */ mhd_assert (false); /* Should never happen */ } if (! MHD_thread_handle_ID_join_thread_ (daemon->tid)) { MHD_PANIC (_ ("Failed to join a thread.\n")); } /* close_all_connections() was called in daemon thread. */ } else #endif { /* No internal threads are used for polling sockets. */ close_all_connections (daemon); } mhd_assert (NULL == daemon->connections_head); mhd_assert (NULL == daemon->cleanup_head); mhd_assert (NULL == daemon->suspended_connections_head); mhd_assert (NULL == daemon->new_connections_head); #if defined(UPGRADE_SUPPORT) && defined(HTTPS_SUPPORT) mhd_assert (NULL == daemon->urh_head); #endif /* UPGRADE_SUPPORT && HTTPS_SUPPORT */ if (MHD_ITC_IS_VALID_ (daemon->itc)) MHD_itc_destroy_chk_ (daemon->itc); #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon) && (-1 != daemon->epoll_fd) ) MHD_socket_close_chk_ (daemon->epoll_fd); #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) if (MHD_D_IS_USING_EPOLL_ (daemon) && (-1 != daemon->epoll_upgrade_fd) ) MHD_socket_close_chk_ (daemon->epoll_upgrade_fd); #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ #endif /* EPOLL_SUPPORT */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_destroy_chk_ (&daemon->cleanup_connection_mutex); MHD_mutex_destroy_chk_ (&daemon->new_connections_mutex); #endif } if (NULL == daemon->master) { /* Cleanup that should be done only one time in master/single daemon. * Do not perform this cleanup in worker daemons. */ if (MHD_INVALID_SOCKET != fd) MHD_socket_close_chk_ (fd); /* TLS clean up */ #ifdef HTTPS_SUPPORT if (daemon->have_dhparams) { gnutls_dh_params_deinit (daemon->https_mem_dhparams); daemon->have_dhparams = false; } if (0 != (daemon->options & MHD_USE_TLS)) { gnutls_priority_deinit (daemon->priority_cache); if (daemon->x509_cred) gnutls_certificate_free_credentials (daemon->x509_cred); if (daemon->psk_cred) gnutls_psk_free_server_credentials (daemon->psk_cred); } #endif /* HTTPS_SUPPORT */ #ifdef DAUTH_SUPPORT free (daemon->digest_auth_random_copy); free (daemon->nnc); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_destroy_chk_ (&daemon->nnc_lock); #endif #endif #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex); #endif free (daemon); } } /** * Obtain information about the given daemon. * The returned pointer is invalidated with the next call of this function or * when the daemon is stopped. * * @param daemon what daemon to get information about * @param info_type what information is desired? * @param ... depends on @a info_type * @return NULL if this information is not available * (or if the @a info_type is unknown) * @ingroup specialized */ _MHD_EXTERN const union MHD_DaemonInfo * MHD_get_daemon_info (struct MHD_Daemon *daemon, enum MHD_DaemonInfoType info_type, ...) { if (NULL == daemon) return NULL; mhd_assert ((0 == (daemon->options & MHD_USE_SELECT_INTERNALLY)) || \ (NULL != daemon->worker_pool) || \ (MHD_thread_handle_ID_is_valid_handle_ (daemon->tid))); mhd_assert (((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) && (NULL == daemon->worker_pool)) || \ (! MHD_thread_handle_ID_is_valid_handle_ (daemon->tid))); switch (info_type) { case MHD_DAEMON_INFO_KEY_SIZE: return NULL; /* no longer supported */ case MHD_DAEMON_INFO_MAC_KEY_SIZE: return NULL; /* no longer supported */ case MHD_DAEMON_INFO_LISTEN_FD: daemon->daemon_info_dummy_listen_fd.listen_fd = daemon->listen_fd; return &daemon->daemon_info_dummy_listen_fd; case MHD_DAEMON_INFO_EPOLL_FD: #ifdef EPOLL_SUPPORT daemon->daemon_info_dummy_epoll_fd.epoll_fd = daemon->epoll_fd; return &daemon->daemon_info_dummy_epoll_fd; #else /* ! EPOLL_SUPPORT */ return NULL; #endif /* ! EPOLL_SUPPORT */ case MHD_DAEMON_INFO_CURRENT_CONNECTIONS: if (! MHD_D_IS_THREAD_SAFE_ (daemon)) MHD_cleanup_connections (daemon); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) else if (daemon->worker_pool) { unsigned int i; /* Collect the connection information stored in the workers. */ daemon->connections = 0; for (i = 0; i < daemon->worker_pool_size; i++) { /* FIXME: next line is thread-safe only if read is atomic. */ daemon->connections += daemon->worker_pool[i].connections; } } #endif daemon->daemon_info_dummy_num_connections.num_connections = daemon->connections; return &daemon->daemon_info_dummy_num_connections; case MHD_DAEMON_INFO_FLAGS: daemon->daemon_info_dummy_flags.flags = daemon->options; return &daemon->daemon_info_dummy_flags; case MHD_DAEMON_INFO_BIND_PORT: daemon->daemon_info_dummy_port.port = daemon->port; return &daemon->daemon_info_dummy_port; default: return NULL; } } /** * Obtain the version of this library * * @return static version string, e.g. "0.9.9" * @ingroup specialized */ _MHD_EXTERN const char * MHD_get_version (void) { #ifdef PACKAGE_VERSION return PACKAGE_VERSION; #else /* !PACKAGE_VERSION */ static char ver[12] = "\0\0\0\0\0\0\0\0\0\0\0"; if (0 == ver[0]) { int res = MHD_snprintf_ (ver, sizeof(ver), "%x.%x.%x", (int) (((uint32_t) MHD_VERSION >> 24) & 0xFF), (int) (((uint32_t) MHD_VERSION >> 16) & 0xFF), (int) (((uint32_t) MHD_VERSION >> 8) & 0xFF)); if ((0 >= res) || (sizeof(ver) <= res)) return "0.0.0"; /* Can't return real version */ } return ver; #endif /* !PACKAGE_VERSION */ } /** * Obtain the version of this library as a binary value. * * @return version binary value, e.g. "0x00090900" (#MHD_VERSION of * compiled MHD binary) * @note Available since #MHD_VERSION 0x00097601 * @ingroup specialized */ _MHD_EXTERN uint32_t MHD_get_version_bin (void) { return (uint32_t) MHD_VERSION; } /** * Get information about supported MHD features. * Indicate that MHD was compiled with or without support for * particular feature. Some features require additional support * by kernel. Kernel support is not checked by this function. * * @param feature type of requested information * @return #MHD_YES if feature is supported by MHD, #MHD_NO if * feature is not supported or feature is unknown. * @ingroup specialized */ _MHD_EXTERN enum MHD_Result MHD_is_feature_supported (enum MHD_FEATURE feature) { switch (feature) { case MHD_FEATURE_MESSAGES: #ifdef HAVE_MESSAGES return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_TLS: #ifdef HTTPS_SUPPORT return MHD_YES; #else /* ! HTTPS_SUPPORT */ return MHD_NO; #endif /* ! HTTPS_SUPPORT */ case MHD_FEATURE_HTTPS_CERT_CALLBACK: #if defined(HTTPS_SUPPORT) && GNUTLS_VERSION_MAJOR >= 3 return MHD_YES; #else /* !HTTPS_SUPPORT || GNUTLS_VERSION_MAJOR < 3 */ return MHD_NO; #endif /* !HTTPS_SUPPORT || GNUTLS_VERSION_MAJOR < 3 */ case MHD_FEATURE_HTTPS_CERT_CALLBACK2: #if defined(HTTPS_SUPPORT) && GNUTLS_VERSION_NUMBER >= 0x030603 return MHD_YES; #else /* !HTTPS_SUPPORT || GNUTLS_VERSION_NUMBER < 0x030603 */ return MHD_NO; #endif /* !HTTPS_SUPPORT || GNUTLS_VERSION_NUMBER < 0x030603 */ case MHD_FEATURE_IPv6: #ifdef HAVE_INET6 return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_IPv6_ONLY: #if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_POLL: #ifdef HAVE_POLL return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_EPOLL: #ifdef EPOLL_SUPPORT return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET: #ifdef HAVE_LISTEN_SHUTDOWN return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_SOCKETPAIR: #ifdef _MHD_ITC_SOCKETPAIR return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_TCP_FASTOPEN: #ifdef TCP_FASTOPEN return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_BASIC_AUTH: #ifdef BAUTH_SUPPORT return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_DIGEST_AUTH: #ifdef DAUTH_SUPPORT return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_POSTPROCESSOR: #ifdef HAVE_POSTPROCESSOR return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_HTTPS_KEY_PASSWORD: #if defined(HTTPS_SUPPORT) && GNUTLS_VERSION_NUMBER >= 0x030111 return MHD_YES; #else /* !HTTPS_SUPPORT || GNUTLS_VERSION_NUMBER < 0x030111 */ return MHD_NO; #endif /* !HTTPS_SUPPORT || GNUTLS_VERSION_NUMBER < 0x030111 */ case MHD_FEATURE_LARGE_FILE: #if defined(HAVE_PREAD64) || defined(_WIN32) return MHD_YES; #elif defined(HAVE_PREAD) return (sizeof(uint64_t) > sizeof(off_t)) ? MHD_NO : MHD_YES; #elif defined(HAVE_LSEEK64) return MHD_YES; #else return (sizeof(uint64_t) > sizeof(off_t)) ? MHD_NO : MHD_YES; #endif case MHD_FEATURE_THREAD_NAMES: #if defined(MHD_USE_THREAD_NAME_) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_UPGRADE: #if defined(UPGRADE_SUPPORT) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_RESPONSES_SHARED_FD: #if defined(HAVE_PREAD64) || defined(HAVE_PREAD) || defined(_WIN32) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_AUTODETECT_BIND_PORT: #ifdef MHD_USE_GETSOCKNAME return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_AUTOSUPPRESS_SIGPIPE: #if defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) || \ ! defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_SENDFILE: #ifdef _MHD_HAVE_SENDFILE return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_THREADS: #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_HTTPS_COOKIE_PARSING: #if defined(COOKIE_SUPPORT) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_DIGEST_AUTH_RFC2069: #ifdef DAUTH_SUPPORT return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_DIGEST_AUTH_MD5: #if defined(DAUTH_SUPPORT) && defined(MHD_MD5_SUPPORT) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_DIGEST_AUTH_SHA256: #if defined(DAUTH_SUPPORT) && defined(MHD_SHA256_SUPPORT) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_DIGEST_AUTH_SHA512_256: #if defined(DAUTH_SUPPORT) && defined(MHD_SHA512_256_SUPPORT) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_DIGEST_AUTH_AUTH_INT: #ifdef DAUTH_SUPPORT return MHD_NO; #else return MHD_NO; #endif case MHD_FEATURE_DIGEST_AUTH_ALGO_SESSION: #ifdef DAUTH_SUPPORT return MHD_NO; #else return MHD_NO; #endif case MHD_FEATURE_DIGEST_AUTH_USERHASH: #ifdef DAUTH_SUPPORT return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_EXTERN_HASH: #if defined(MHD_MD5_TLSLIB) || defined(MHD_SHA256_TLSLIB) return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_DEBUG_BUILD: #ifdef _DEBUG return MHD_YES; #else return MHD_NO; #endif case MHD_FEATURE_FLEXIBLE_FD_SETSIZE: #ifdef HAS_FD_SETSIZE_OVERRIDABLE return MHD_YES; #else /* ! HAS_FD_SETSIZE_OVERRIDABLE */ return MHD_NO; #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ default: break; } return MHD_NO; } #ifdef MHD_HTTPS_REQUIRE_GCRYPT #if defined(HTTPS_SUPPORT) && GCRYPT_VERSION_NUMBER < 0x010600 #if defined(MHD_USE_POSIX_THREADS) GCRY_THREAD_OPTION_PTHREAD_IMPL; #elif defined(MHD_W32_MUTEX_) static int gcry_w32_mutex_init (void **ppmtx) { *ppmtx = malloc (sizeof (MHD_mutex_)); if (NULL == *ppmtx) return ENOMEM; if (! MHD_mutex_init_ ((MHD_mutex_ *) *ppmtx)) { free (*ppmtx); *ppmtx = NULL; return EPERM; } return 0; } static int gcry_w32_mutex_destroy (void **ppmtx) { int res = (MHD_mutex_destroy_ ((MHD_mutex_ *) *ppmtx)) ? 0 : EINVAL; free (*ppmtx); return res; } static int gcry_w32_mutex_lock (void **ppmtx) { return MHD_mutex_lock_ ((MHD_mutex_ *) *ppmtx) ? 0 : EINVAL; } static int gcry_w32_mutex_unlock (void **ppmtx) { return MHD_mutex_unlock_ ((MHD_mutex_ *) *ppmtx) ? 0 : EINVAL; } static struct gcry_thread_cbs gcry_threads_w32 = { (GCRY_THREAD_OPTION_USER | (GCRY_THREAD_OPTION_VERSION << 8)), NULL, gcry_w32_mutex_init, gcry_w32_mutex_destroy, gcry_w32_mutex_lock, gcry_w32_mutex_unlock, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; #endif /* defined(MHD_W32_MUTEX_) */ #endif /* HTTPS_SUPPORT && GCRYPT_VERSION_NUMBER < 0x010600 */ #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ /** * Initialize do setup work. */ void MHD_init (void) { #if defined(MHD_WINSOCK_SOCKETS) WSADATA wsd; #endif /* MHD_WINSOCK_SOCKETS */ MHD_set_panic_func (NULL, NULL); #if defined(MHD_WINSOCK_SOCKETS) if (0 != WSAStartup (MAKEWORD (2, 2), &wsd)) MHD_PANIC (_ ("Failed to initialize winsock.\n")); if ((2 != LOBYTE (wsd.wVersion)) && (2 != HIBYTE (wsd.wVersion))) MHD_PANIC (_ ("Winsock version 2.2 is not available.\n")); #endif /* MHD_WINSOCK_SOCKETS */ #ifdef HTTPS_SUPPORT #ifdef MHD_HTTPS_REQUIRE_GCRYPT #if GCRYPT_VERSION_NUMBER < 0x010600 #if GNUTLS_VERSION_NUMBER <= 0x020b00 #if defined(MHD_USE_POSIX_THREADS) if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread)) MHD_PANIC (_ ("Failed to initialise multithreading in libgcrypt.\n")); #elif defined(MHD_W32_MUTEX_) if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_w32)) MHD_PANIC (_ ("Failed to initialise multithreading in libgcrypt.\n")); #endif /* defined(MHD_W32_MUTEX_) */ #endif /* GNUTLS_VERSION_NUMBER <= 0x020b00 */ gcry_check_version (NULL); #else if (NULL == gcry_check_version ("1.6.0")) MHD_PANIC (_ ("libgcrypt is too old. MHD was compiled for " \ "libgcrypt 1.6.0 or newer.\n")); #endif #endif /* MHD_HTTPS_REQUIRE_GCRYPT */ gnutls_global_init (); #endif /* HTTPS_SUPPORT */ MHD_monotonic_sec_counter_init (); MHD_send_init_static_vars_ (); MHD_init_mem_pools_ (); /* Check whether sizes were correctly detected by configure */ #ifdef _DEBUG if (1) { struct timeval tv; mhd_assert (sizeof(tv.tv_sec) == SIZEOF_STRUCT_TIMEVAL_TV_SEC); } #endif /* _DEBUG */ mhd_assert (sizeof(uint64_t) == SIZEOF_UINT64_T); } void MHD_fini (void) { #ifdef HTTPS_SUPPORT gnutls_global_deinit (); #endif /* HTTPS_SUPPORT */ #if defined(MHD_WINSOCK_SOCKETS) WSACleanup (); #endif /* MHD_WINSOCK_SOCKETS */ MHD_monotonic_sec_counter_finish (); } #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED _SET_INIT_AND_DEINIT_FUNCS (MHD_init, MHD_fini); #endif /* _AUTOINIT_FUNCS_ARE_SUPPORTED */ /* end of daemon.c */ libmicrohttpd-1.0.1/src/microhttpd/mhd_sockets.c0000644000175000017500000004174014556705750015475 /* This file is part of libmicrohttpd Copyright (C) 2014-2024 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_sockets.c * @brief Implementation for sockets functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_sockets.h" #ifdef MHD_WINSOCK_SOCKETS /** * Return pointer to string description of specified WinSock error * @param err the WinSock error code. * @return pointer to string description of specified WinSock error. */ const char * MHD_W32_strerror_winsock_ (int err) { switch (err) { case 0: return "No error"; case WSA_INVALID_HANDLE: return "Specified event object handle is invalid"; case WSA_NOT_ENOUGH_MEMORY: return "Insufficient memory available"; case WSA_INVALID_PARAMETER: return "One or more parameters are invalid"; case WSA_OPERATION_ABORTED: return "Overlapped operation aborted"; case WSA_IO_INCOMPLETE: return "Overlapped I/O event object not in signaled state"; case WSA_IO_PENDING: return "Overlapped operations will complete later"; case WSAEINTR: return "Interrupted function call"; case WSAEBADF: return "File handle is not valid"; case WSAEACCES: return "Permission denied"; case WSAEFAULT: return "Bad address"; case WSAEINVAL: return "Invalid argument"; case WSAEMFILE: return "Too many open files"; case WSAEWOULDBLOCK: return "Resource temporarily unavailable"; case WSAEINPROGRESS: return "Operation now in progress"; case WSAEALREADY: return "Operation already in progress"; case WSAENOTSOCK: return "Socket operation on nonsocket"; case WSAEDESTADDRREQ: return "Destination address required"; case WSAEMSGSIZE: return "Message too long"; case WSAEPROTOTYPE: return "Protocol wrong type for socket"; case WSAENOPROTOOPT: return "Bad protocol option"; case WSAEPROTONOSUPPORT: return "Protocol not supported"; case WSAESOCKTNOSUPPORT: return "Socket type not supported"; case WSAEOPNOTSUPP: return "Operation not supported"; case WSAEPFNOSUPPORT: return "Protocol family not supported"; case WSAEAFNOSUPPORT: return "Address family not supported by protocol family"; case WSAEADDRINUSE: return "Address already in use"; case WSAEADDRNOTAVAIL: return "Cannot assign requested address"; case WSAENETDOWN: return "Network is down"; case WSAENETUNREACH: return "Network is unreachable"; case WSAENETRESET: return "Network dropped connection on reset"; case WSAECONNABORTED: return "Software caused connection abort"; case WSAECONNRESET: return "Connection reset by peer"; case WSAENOBUFS: return "No buffer space available"; case WSAEISCONN: return "Socket is already connected"; case WSAENOTCONN: return "Socket is not connected"; case WSAESHUTDOWN: return "Cannot send after socket shutdown"; case WSAETOOMANYREFS: return "Too many references"; case WSAETIMEDOUT: return "Connection timed out"; case WSAECONNREFUSED: return "Connection refused"; case WSAELOOP: return "Cannot translate name"; case WSAENAMETOOLONG: return "Name too long"; case WSAEHOSTDOWN: return "Host is down"; case WSAEHOSTUNREACH: return "No route to host"; case WSAENOTEMPTY: return "Directory not empty"; case WSAEPROCLIM: return "Too many processes"; case WSAEUSERS: return "User quota exceeded"; case WSAEDQUOT: return "Disk quota exceeded"; case WSAESTALE: return "Stale file handle reference"; case WSAEREMOTE: return "Item is remote"; case WSASYSNOTREADY: return "Network subsystem is unavailable"; case WSAVERNOTSUPPORTED: return "Winsock.dll version out of range"; case WSANOTINITIALISED: return "Successful WSAStartup not yet performed"; case WSAEDISCON: return "Graceful shutdown in progress"; case WSAENOMORE: return "No more results"; case WSAECANCELLED: return "Call has been canceled"; case WSAEINVALIDPROCTABLE: return "Procedure call table is invalid"; case WSAEINVALIDPROVIDER: return "Service provider is invalid"; case WSAEPROVIDERFAILEDINIT: return "Service provider failed to initialize"; case WSASYSCALLFAILURE: return "System call failure"; case WSASERVICE_NOT_FOUND: return "Service not found"; case WSATYPE_NOT_FOUND: return "Class type not found"; case WSA_E_NO_MORE: return "No more results"; case WSA_E_CANCELLED: return "Call was canceled"; case WSAEREFUSED: return "Database query was refused"; case WSAHOST_NOT_FOUND: return "Host not found"; case WSATRY_AGAIN: return "Nonauthoritative host not found"; case WSANO_RECOVERY: return "This is a nonrecoverable error"; case WSANO_DATA: return "Valid name, no data record of requested type"; case WSA_QOS_RECEIVERS: return "QoS receivers"; case WSA_QOS_SENDERS: return "QoS senders"; case WSA_QOS_NO_SENDERS: return "No QoS senders"; case WSA_QOS_NO_RECEIVERS: return "QoS no receivers"; case WSA_QOS_REQUEST_CONFIRMED: return "QoS request confirmed"; case WSA_QOS_ADMISSION_FAILURE: return "QoS admission error"; case WSA_QOS_POLICY_FAILURE: return "QoS policy failure"; case WSA_QOS_BAD_STYLE: return "QoS bad style"; case WSA_QOS_BAD_OBJECT: return "QoS bad object"; case WSA_QOS_TRAFFIC_CTRL_ERROR: return "QoS traffic control error"; case WSA_QOS_GENERIC_ERROR: return "QoS generic error"; case WSA_QOS_ESERVICETYPE: return "QoS service type error"; case WSA_QOS_EFLOWSPEC: return "QoS flowspec error"; case WSA_QOS_EPROVSPECBUF: return "Invalid QoS provider buffer"; case WSA_QOS_EFILTERSTYLE: return "Invalid QoS filter style"; case WSA_QOS_EFILTERTYPE: return "Invalid QoS filter type"; case WSA_QOS_EFILTERCOUNT: return "Incorrect QoS filter count"; case WSA_QOS_EOBJLENGTH: return "Invalid QoS object length"; case WSA_QOS_EFLOWCOUNT: return "Incorrect QoS flow count"; case WSA_QOS_EUNKOWNPSOBJ: return "Unrecognized QoS object"; case WSA_QOS_EPOLICYOBJ: return "Invalid QoS policy object"; case WSA_QOS_EFLOWDESC: return "Invalid QoS flow descriptor"; case WSA_QOS_EPSFLOWSPEC: return "Invalid QoS provider-specific flowspec"; case WSA_QOS_EPSFILTERSPEC: return "Invalid QoS provider-specific filterspec"; case WSA_QOS_ESDMODEOBJ: return "Invalid QoS shape discard mode object"; case WSA_QOS_ESHAPERATEOBJ: return "Invalid QoS shaping rate object"; case WSA_QOS_RESERVED_PETYPE: return "Reserved policy QoS element type"; } return "Unknown winsock error"; } /** * Create pair of mutually connected TCP/IP sockets on loopback address * @param sockets_pair array to receive resulted sockets * @param non_blk if set to non-zero value, sockets created in non-blocking mode * otherwise sockets will be in blocking mode * @return non-zero if succeeded, zero otherwise */ int MHD_W32_socket_pair_ (SOCKET sockets_pair[2], int non_blk) { int i; if (! sockets_pair) { WSASetLastError (WSAEFAULT); return 0; } #define PAIRMAXTRYIES 800 for (i = 0; i < PAIRMAXTRYIES; i++) { struct sockaddr_in listen_addr; SOCKET listen_s; static const int c_addinlen = sizeof(struct sockaddr_in); /* help compiler to optimize */ int addr_len = c_addinlen; unsigned long on_val = 1; unsigned long off_val = 0; listen_s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); if (INVALID_SOCKET == listen_s) break; /* can't create even single socket */ listen_addr.sin_family = AF_INET; listen_addr.sin_port = 0; /* same as htons(0) */ listen_addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); if ( ((0 == bind (listen_s, (struct sockaddr *) &listen_addr, c_addinlen)) && (0 == listen (listen_s, 1) ) && (0 == getsockname (listen_s, (struct sockaddr *) &listen_addr, &addr_len))) ) { SOCKET client_s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); struct sockaddr_in accepted_from_addr; struct sockaddr_in client_addr; SOCKET server_s; if (INVALID_SOCKET == client_s) { /* try again */ closesocket (listen_s); continue; } if ( (0 != ioctlsocket (client_s, (int) FIONBIO, &on_val)) || ( (0 != connect (client_s, (struct sockaddr *) &listen_addr, c_addinlen)) && (WSAGetLastError () != WSAEWOULDBLOCK)) ) { /* try again */ closesocket (listen_s); closesocket (client_s); continue; } addr_len = c_addinlen; server_s = accept (listen_s, (struct sockaddr *) &accepted_from_addr, &addr_len); if (INVALID_SOCKET == server_s) { /* try again */ closesocket (listen_s); closesocket (client_s); continue; } addr_len = c_addinlen; if ( (0 == getsockname (client_s, (struct sockaddr *) &client_addr, &addr_len)) && (accepted_from_addr.sin_port == client_addr.sin_port) && (accepted_from_addr.sin_addr.s_addr == client_addr.sin_addr.s_addr) && (accepted_from_addr.sin_family == client_addr.sin_family) && ( (0 != non_blk) ? (0 == ioctlsocket (server_s, (int) FIONBIO, &on_val)) : (0 == ioctlsocket (client_s, (int) FIONBIO, &off_val)) ) && (0 == setsockopt (server_s, IPPROTO_TCP, TCP_NODELAY, (const void *) (&on_val), sizeof (on_val))) && (0 == setsockopt (client_s, IPPROTO_TCP, TCP_NODELAY, (const void *) (&on_val), sizeof (on_val))) ) { closesocket (listen_s); sockets_pair[0] = server_s; sockets_pair[1] = client_s; return ! 0; } closesocket (server_s); closesocket (client_s); } closesocket (listen_s); } sockets_pair[0] = INVALID_SOCKET; sockets_pair[1] = INVALID_SOCKET; WSASetLastError (WSAECONNREFUSED); return 0; } #endif /* MHD_WINSOCK_SOCKETS */ /** * Add @a fd to the @a set. If @a fd is * greater than @a max_fd, set @a max_fd to @a fd. * * @param fd file descriptor to add to the @a set * @param set set to modify * @param max_fd maximum value to potentially update * @param fd_setsize value of FD_SETSIZE * @return non-zero if succeeded, zero otherwise */ int MHD_add_to_fd_set_ (MHD_socket fd, fd_set *set, MHD_socket *max_fd, int fd_setsize) { if ( (NULL == set) || (MHD_INVALID_SOCKET == fd) ) return 0; #ifndef HAS_FD_SETSIZE_OVERRIDABLE (void) fd_setsize; /* Mute compiler warning */ fd_setsize = (int) FD_SETSIZE; /* Help compiler to optimise */ #endif /* ! HAS_FD_SETSIZE_OVERRIDABLE */ if (! MHD_SCKT_FD_FITS_FDSET_SETSIZE_ (fd, set, fd_setsize)) return 0; MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_ (fd, set, fd_setsize); if ( (NULL != max_fd) && ( (fd > *max_fd) || (MHD_INVALID_SOCKET == *max_fd) ) ) *max_fd = fd; return ! 0; } /** * Change socket options to be non-blocking. * * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise */ int MHD_socket_nonblocking_ (MHD_socket sock) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (sock, F_GETFL); if (-1 == flags) return 0; if ( ((flags | O_NONBLOCK) != flags) && (0 != fcntl (sock, F_SETFL, flags | O_NONBLOCK)) ) return 0; #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 1; if (0 != ioctlsocket (sock, (int) FIONBIO, &flags)) return 0; #endif /* MHD_WINSOCK_SOCKETS */ return ! 0; } /** * Change socket options to be non-inheritable. * * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise * @warning Does not set socket error on W32. */ int MHD_socket_noninheritable_ (MHD_socket sock) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (sock, F_GETFD); if (-1 == flags) return 0; if ( ((flags | FD_CLOEXEC) != flags) && (0 != fcntl (sock, F_SETFD, flags | FD_CLOEXEC)) ) return 0; #elif defined(MHD_WINSOCK_SOCKETS) if (! SetHandleInformation ((HANDLE) sock, HANDLE_FLAG_INHERIT, 0)) return 0; #endif /* MHD_WINSOCK_SOCKETS */ return ! 0; } /** * Disable Nagle's algorithm on @a sock. This is what we do by default for * all TCP sockets in MHD, unless the platform does not support the MSG_MORE * or MSG_CORK or MSG_NOPUSH options. * * @param sock socket to manipulate * @param on value to use * @return 0 on success */ int MHD_socket_set_nodelay_ (MHD_socket sock, bool on) { #ifdef TCP_NODELAY { const MHD_SCKT_OPT_BOOL_ off_val = 0; const MHD_SCKT_OPT_BOOL_ on_val = 1; /* Disable Nagle's algorithm for normal buffering */ return setsockopt (sock, IPPROTO_TCP, TCP_NODELAY, (const void *) ((on) ? &on_val : &off_val), sizeof (on_val)); } #else (void) sock; return 0; #endif /* TCP_NODELAY */ } /** * Create a listen socket, with noninheritable flag if possible. * * @param pf protocol family to use * @return created socket or MHD_INVALID_SOCKET in case of errors */ MHD_socket MHD_socket_create_listen_ (int pf) { MHD_socket fd; int cloexec_set; #if defined(SOCK_NOSIGPIPE) || defined(MHD_socket_nosignal_) int nosigpipe_set; #endif /* SOCK_NOSIGPIPE || MHD_socket_nosignal_ */ #if defined(MHD_POSIX_SOCKETS) && (defined(SOCK_CLOEXEC) || \ defined(SOCK_NOSIGPIPE) ) fd = socket (pf, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NOSIGPIPE_OR_ZERO, 0); cloexec_set = (SOCK_CLOEXEC_OR_ZERO != 0); #if defined(SOCK_NOSIGPIPE) || defined(MHD_socket_nosignal_) nosigpipe_set = (SOCK_NOSIGPIPE_OR_ZERO != 0); #endif /* SOCK_NOSIGPIPE || MHD_socket_nosignal_ */ #elif defined(MHD_WINSOCK_SOCKETS) && defined(WSA_FLAG_NO_HANDLE_INHERIT) fd = WSASocketW (pf, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED | WSA_FLAG_NO_HANDLE_INHERIT); cloexec_set = ! 0; #else /* No special socket init function / flags */ fd = MHD_INVALID_SOCKET; cloexec_set = 0; #if defined(SOCK_NOSIGPIPE) || defined(MHD_socket_nosignal_) nosigpipe_set = 0; #endif /* SOCK_NOSIGPIPE || MHD_socket_nosignal_ */ #endif /* No special socket init function / flags */ if (MHD_INVALID_SOCKET == fd) { fd = socket (pf, SOCK_STREAM, 0); cloexec_set = 0; #if defined(SOCK_NOSIGPIPE) || defined(MHD_socket_nosignal_) nosigpipe_set = 0; #endif /* SOCK_NOSIGPIPE || MHD_socket_nosignal_ */ } if (MHD_INVALID_SOCKET == fd) return MHD_INVALID_SOCKET; #if defined(MHD_socket_nosignal_) if ( (! nosigpipe_set) && (0 == MHD_socket_nosignal_ (fd)) && (0 == MSG_NOSIGNAL_OR_ZERO) ) { /* SIGPIPE disable is possible on this platform * (so application expect that it will be disabled), * but failed to be disabled here and it is not * possible to disable SIGPIPE by MSG_NOSIGNAL. */ const int err = MHD_socket_get_error_ (); (void) MHD_socket_close_ (fd); MHD_socket_fset_error_ (err); return MHD_INVALID_SOCKET; } #endif /* defined(MHD_socket_nosignal_) */ if (! cloexec_set) (void) MHD_socket_noninheritable_ (fd); return fd; } libmicrohttpd-1.0.1/src/microhttpd/mhd_limits.h0000644000175000017500000001033714556705750015326 /* This file is part of libmicrohttpd Copyright (C) 2015-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_limits.h * @brief limits values definitions * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_LIMITS_H #define MHD_LIMITS_H #include "platform.h" #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ #define MHD_UNSIGNED_TYPE_MAX_(type) ((type) - 1) /* Assume 8 bits per byte, no padding bits. */ #define MHD_SIGNED_TYPE_MAX_(type) \ ( (type) ((( ((type) 1) << (sizeof(type) * 8 - 2)) - 1) * 2 + 1) ) #define MHD_TYPE_IS_SIGNED_(type) (((type) 0)>((type) - 1)) #ifndef INT_MAX #ifdef __INT_MAX__ #define INT_MAX __INT_MAX__ #else /* ! __UINT_MAX__ */ #define INT_MAX MHD_SIGNED_TYPE_MAX_ (int) #endif /* ! __UINT_MAX__ */ #endif /* !UINT_MAX */ #ifndef UINT_MAX #ifdef __UINT_MAX__ #define UINT_MAX __UINT_MAX__ #else /* ! __UINT_MAX__ */ #define UINT_MAX MHD_UNSIGNED_TYPE_MAX_ (unsigned int) #endif /* ! __UINT_MAX__ */ #endif /* !UINT_MAX */ #ifndef LONG_MAX #ifdef __LONG_MAX__ #define LONG_MAX __LONG_MAX__ #else /* ! __LONG_MAX__ */ #define LONG_MAX MHD_SIGNED_TYPE_MAX (long) #endif /* ! __LONG_MAX__ */ #endif /* !LONG_MAX */ #ifndef ULLONG_MAX #ifdef ULONGLONG_MAX #define ULLONG_MAX ULONGLONG_MAX #else /* ! ULONGLONG_MAX */ #define ULLONG_MAX MHD_UNSIGNED_TYPE_MAX_ (MHD_UNSIGNED_LONG_LONG) #endif /* ! ULONGLONG_MAX */ #endif /* !ULLONG_MAX */ #ifndef INT32_MAX #ifdef __INT32_MAX__ #define INT32_MAX __INT32_MAX__ #else /* ! __INT32_MAX__ */ #define INT32_MAX ((int32_t) 0x7FFFFFFF) #endif /* ! __INT32_MAX__ */ #endif /* !INT32_MAX */ #ifndef UINT32_MAX #ifdef __UINT32_MAX__ #define UINT32_MAX __UINT32_MAX__ #else /* ! __UINT32_MAX__ */ #define UINT32_MAX ((int32_t) 0xFFFFFFFF) #endif /* ! __UINT32_MAX__ */ #endif /* !UINT32_MAX */ #ifndef UINT64_MAX #ifdef __UINT64_MAX__ #define UINT64_MAX __UINT64_MAX__ #else /* ! __UINT64_MAX__ */ #define UINT64_MAX ((uint64_t) 0xFFFFFFFFFFFFFFFF) #endif /* ! __UINT64_MAX__ */ #endif /* !UINT64_MAX */ #ifndef INT64_MAX #ifdef __INT64_MAX__ #define INT64_MAX __INT64_MAX__ #else /* ! __INT64_MAX__ */ #define INT64_MAX ((int64_t) 0x7FFFFFFFFFFFFFFF) #endif /* ! __UINT64_MAX__ */ #endif /* !INT64_MAX */ #ifndef SIZE_MAX #ifdef __SIZE_MAX__ #define SIZE_MAX __SIZE_MAX__ #elif defined(UINTPTR_MAX) #define SIZE_MAX UINTPTR_MAX #else /* ! __SIZE_MAX__ */ #define SIZE_MAX MHD_UNSIGNED_TYPE_MAX_ (size_t) #endif /* ! __SIZE_MAX__ */ #endif /* !SIZE_MAX */ #ifndef SSIZE_MAX #ifdef __SSIZE_MAX__ #define SSIZE_MAX __SSIZE_MAX__ #elif defined(INTPTR_MAX) #define SSIZE_MAX INTPTR_MAX #else #define SSIZE_MAX MHD_SIGNED_TYPE_MAX_ (ssize_t) #endif #endif /* ! SSIZE_MAX */ #ifndef OFF_T_MAX #ifdef OFF_MAX #define OFF_T_MAX OFF_MAX #elif defined(OFFT_MAX) #define OFF_T_MAX OFFT_MAX #elif defined(__APPLE__) && defined(__MACH__) #define OFF_T_MAX INT64_MAX #else #define OFF_T_MAX MHD_SIGNED_TYPE_MAX_ (off_t) #endif #endif /* !OFF_T_MAX */ #if defined(_LARGEFILE64_SOURCE) && ! defined(OFF64_T_MAX) #define OFF64_T_MAX MHD_SIGNED_TYPE_MAX_ (uint64_t) #endif /* _LARGEFILE64_SOURCE && !OFF64_T_MAX */ #ifndef TIME_T_MAX #define TIME_T_MAX ((time_t) \ (MHD_TYPE_IS_SIGNED_ (time_t) ? \ MHD_SIGNED_TYPE_MAX_ (time_t) : \ MHD_UNSIGNED_TYPE_MAX_ (time_t))) #endif /* !TIME_T_MAX */ #ifndef TIMEVAL_TV_SEC_MAX #ifndef _WIN32 #define TIMEVAL_TV_SEC_MAX TIME_T_MAX #else /* _WIN32 */ #define TIMEVAL_TV_SEC_MAX LONG_MAX #endif /* _WIN32 */ #endif /* !TIMEVAL_TV_SEC_MAX */ #endif /* MHD_LIMITS_H */ libmicrohttpd-1.0.1/src/microhttpd/test_set_panic.c0000644000175000017500000014113114530120375016153 /* This file is part of libmicrohttpd Copyright (C) 2021-2022 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_set_panic.c * @brief Testcase for MHD_set_panic_func() * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #ifdef HAVE_STRINGS_H #include #endif /* HAVE_STRINGS_H */ #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #ifndef WINDOWS #include #include #endif #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ #ifdef HAVE_SIGNAL_H #include #endif /* HAVE_SIGNAL_H */ #ifdef HAVE_SYSCTL #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ #ifdef HAVE_NETINET_ICMP_VAR_H #include #endif /* HAVE_NETINET_ICMP_VAR_H */ #endif /* HAVE_SYSCTL */ #include #include "mhd_sockets.h" /* only macros used */ #include "test_helpers.h" #include "mhd_assert.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #if MHD_CPU_COUNT > 32 #undef MHD_CPU_COUNT /* Limit to reasonable value */ #define MHD_CPU_COUNT 32 #endif /* MHD_CPU_COUNT > 32 */ #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 /* Time in ms to wait for final packets to be delivered */ #define FINAL_PACKETS_MS 20 #define EXPECTED_URI_BASE_PATH "/a" #define REQ_HOST "localhost" #define REQ_METHOD "PUT" #define REQ_BODY "Some content data." #define REQ_LINE_END "\r\n" /* Mandatory request headers */ #define REQ_HEADER_HOST_NAME "Host" #define REQ_HEADER_HOST_VALUE REQ_HOST #define REQ_HEADER_HOST \ REQ_HEADER_HOST_NAME ": " REQ_HEADER_HOST_VALUE REQ_LINE_END #define REQ_HEADER_UA_NAME "User-Agent" #define REQ_HEADER_UA_VALUE "dummyclient/0.9" #define REQ_HEADER_UA REQ_HEADER_UA_NAME ": " REQ_HEADER_UA_VALUE REQ_LINE_END /* Optional request headers */ #define REQ_HEADER_CT_NAME "Content-Type" #define REQ_HEADER_CT_VALUE "text/plain" #define REQ_HEADER_CT REQ_HEADER_CT_NAME ": " REQ_HEADER_CT_VALUE REQ_LINE_END #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func (NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func (NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func (errDesc, __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func (NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func (errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func (NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func (errDesc, NULL, __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); fflush (stderr); exit (8); } #ifndef MHD_POSIX_SOCKETS /** * Pause execution for specified number of milliseconds. * @param ms the number of milliseconds to sleep */ static void _MHD_sleep (uint32_t ms) { #if defined(_WIN32) Sleep (ms); #elif defined(HAVE_NANOSLEEP) struct timespec slp = {ms / 1000, (ms % 1000) * 1000000}; struct timespec rmn; int num_retries = 0; while (0 != nanosleep (&slp, &rmn)) { if (EINTR != errno) externalErrorExit (); if (num_retries++ > 8) break; slp = rmn; } #elif defined(HAVE_USLEEP) uint64_t us = ms * 1000; do { uint64_t this_sleep; if (999999 < us) this_sleep = 999999; else this_sleep = us; /* Ignore return value as it could be void */ usleep (this_sleep); us -= this_sleep; } while (us > 0); #else externalErrorExitDesc ("No sleep function available on this system"); #endif } #endif /* ! MHD_POSIX_SOCKETS */ /* Global parameters */ static int verbose; /**< Be verbose */ static uint16_t global_port; /**< MHD daemons listen port number */ static void test_global_init (void) { if (MHD_YES != MHD_is_feature_supported (MHD_FEATURE_AUTOSUPPRESS_SIGPIPE)) { #if defined(HAVE_SIGNAL_H) && defined(SIGPIPE) if (SIG_ERR == signal (SIGPIPE, SIG_IGN)) externalErrorExitDesc ("Error suppressing SIGPIPE signal"); #else /* ! HAVE_SIGNAL_H || ! SIGPIPE */ fprintf (stderr, "Cannot suppress SIGPIPE signal.\n"); /* exit (77); */ #endif } } static void test_global_cleanup (void) { } /** * Change socket to blocking. * * @param fd the socket to manipulate */ static void make_blocking (MHD_socket fd) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (fd, F_GETFL); if (-1 == flags) externalErrorExitDesc ("Cannot make socket non-blocking"); if ((flags & ~O_NONBLOCK) != flags) { if (-1 == fcntl (fd, F_SETFL, flags & ~O_NONBLOCK)) externalErrorExitDesc ("Cannot make socket non-blocking"); } #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 0; if (0 != ioctlsocket (fd, (int) FIONBIO, &flags)) externalErrorExitDesc ("Cannot make socket non-blocking"); #endif /* MHD_WINSOCK_SOCKETS */ } /** * Change socket to non-blocking. * * @param fd the socket to manipulate */ static void make_nonblocking (MHD_socket fd) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (fd, F_GETFL); if (-1 == flags) externalErrorExitDesc ("Cannot make socket non-blocking"); if ((flags | O_NONBLOCK) != flags) { if (-1 == fcntl (fd, F_SETFL, flags | O_NONBLOCK)) externalErrorExitDesc ("Cannot make socket non-blocking"); } #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 1; if (0 != ioctlsocket (fd, (int) FIONBIO, &flags)) externalErrorExitDesc ("Cannot make socket non-blocking"); #endif /* MHD_WINSOCK_SOCKETS */ } enum _MHD_clientStage { DUMB_CLIENT_INIT = 0, DUMB_CLIENT_CONNECTING, DUMB_CLIENT_CONNECTED, DUMB_CLIENT_REQ_SENDING, DUMB_CLIENT_REQ_SENT, DUMB_CLIENT_HEADER_RECVEIVING, DUMB_CLIENT_HEADER_RECVEIVED, DUMB_CLIENT_BODY_RECVEIVING, DUMB_CLIENT_BODY_RECVEIVED, DUMB_CLIENT_FINISHING, DUMB_CLIENT_FINISHED }; struct _MHD_dumbClient { MHD_socket sckt; /**< the socket to communicate */ int sckt_nonblock; /**< non-zero if socket is non-blocking */ uint16_t port; /**< the port to connect to */ char *send_buf; /**< the buffer for the request, malloced */ size_t req_size; /**< the size of the request, including header */ size_t send_off; /**< the number of bytes already sent */ enum _MHD_clientStage stage; /* the test-specific variables */ size_t single_send_size; /**< the maximum number of bytes to be sent by single send() */ size_t send_size_limit; /**< the total number of send bytes limit */ }; struct _MHD_dumbClient * _MHD_dumbClient_create (uint16_t port, const char *method, const char *url, const char *add_headers, const uint8_t *req_body, size_t req_body_size, int chunked); void _MHD_dumbClient_set_send_limits (struct _MHD_dumbClient *clnt, size_t step_size, size_t max_total_send); void _MHD_dumbClient_start_connect (struct _MHD_dumbClient *clnt); int _MHD_dumbClient_is_req_sent (struct _MHD_dumbClient *clnt); int _MHD_dumbClient_process (struct _MHD_dumbClient *clnt); void _MHD_dumbClient_get_fdsets (struct _MHD_dumbClient *clnt, MHD_socket *maxsckt, fd_set *rs, fd_set *ws, fd_set *es); /** * Process the client data with send()/recv() as needed based on * information in fd_sets. * @param clnt the client to process * @return non-zero if client finished processing the request, * zero otherwise. */ int _MHD_dumbClient_process_from_fdsets (struct _MHD_dumbClient *clnt, fd_set *rs, fd_set *ws, fd_set *es); /** * Perform full request. * @param clnt the client to run * @return zero if client finished processing the request, * non-zero if timeout is reached. */ int _MHD_dumbClient_perform (struct _MHD_dumbClient *clnt); /** * Close the client and free internally allocated resources. * @param clnt the client to close */ void _MHD_dumbClient_close (struct _MHD_dumbClient *clnt); struct _MHD_dumbClient * _MHD_dumbClient_create (uint16_t port, const char *method, const char *url, const char *add_headers, const uint8_t *req_body, size_t req_body_size, int chunked) { struct _MHD_dumbClient *clnt; size_t method_size; size_t url_size; size_t add_hdrs_size; size_t buf_alloc_size; char *send_buf; mhd_assert (0 != port); mhd_assert (NULL != req_body || 0 == req_body_size); mhd_assert (0 == req_body_size || NULL != req_body); clnt = (struct _MHD_dumbClient *) malloc (sizeof(struct _MHD_dumbClient)); if (NULL == clnt) externalErrorExit (); memset (clnt, 0, sizeof(struct _MHD_dumbClient)); clnt->sckt = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); if (MHD_INVALID_SOCKET == clnt->sckt) externalErrorExitDesc ("Cannot create the client socket"); #ifdef MHD_socket_nosignal_ if (! MHD_socket_nosignal_ (clnt->sckt)) externalErrorExitDesc ("Cannot suppress SIGPIPE on the client socket"); #endif /* MHD_socket_nosignal_ */ clnt->sckt_nonblock = 0; if (clnt->sckt_nonblock) make_nonblocking (clnt->sckt); else make_blocking (clnt->sckt); if (1) { /* Always set TCP NODELAY */ const MHD_SCKT_OPT_BOOL_ on_val = 1; if (0 != setsockopt (clnt->sckt, IPPROTO_TCP, TCP_NODELAY, (const void *) &on_val, sizeof (on_val))) externalErrorExitDesc ("Cannot set TCP_NODELAY option"); } clnt->port = port; if (NULL != method) method_size = strlen (method); else { method = MHD_HTTP_METHOD_GET; method_size = MHD_STATICSTR_LEN_ (MHD_HTTP_METHOD_GET); } mhd_assert (0 != method_size); if (NULL != url) url_size = strlen (url); else { url = "/"; url_size = 1; } mhd_assert (0 != url_size); add_hdrs_size = (NULL == add_headers) ? 0 : strlen (add_headers); buf_alloc_size = 1024 + method_size + url_size + add_hdrs_size + req_body_size; send_buf = (char *) malloc (buf_alloc_size); if (NULL == send_buf) externalErrorExit (); clnt->req_size = 0; /* Form the request line */ memcpy (send_buf + clnt->req_size, method, method_size); clnt->req_size += method_size; send_buf[clnt->req_size++] = ' '; memcpy (send_buf + clnt->req_size, url, url_size); clnt->req_size += url_size; send_buf[clnt->req_size++] = ' '; memcpy (send_buf + clnt->req_size, MHD_HTTP_VERSION_1_1, MHD_STATICSTR_LEN_ (MHD_HTTP_VERSION_1_1)); clnt->req_size += MHD_STATICSTR_LEN_ (MHD_HTTP_VERSION_1_1); send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; /* Form the header */ memcpy (send_buf + clnt->req_size, REQ_HEADER_HOST, MHD_STATICSTR_LEN_ (REQ_HEADER_HOST)); clnt->req_size += MHD_STATICSTR_LEN_ (REQ_HEADER_HOST); memcpy (send_buf + clnt->req_size, REQ_HEADER_UA, MHD_STATICSTR_LEN_ (REQ_HEADER_UA)); clnt->req_size += MHD_STATICSTR_LEN_ (REQ_HEADER_UA); if ((NULL != req_body) || chunked) { if (! chunked) { int prn_size; memcpy (send_buf + clnt->req_size, MHD_HTTP_HEADER_CONTENT_LENGTH ": ", MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": ")); clnt->req_size += MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": "); prn_size = snprintf (send_buf + clnt->req_size, (buf_alloc_size - clnt->req_size), "%u", (unsigned int) req_body_size); if (0 >= prn_size) externalErrorExit (); if ((unsigned int) prn_size >= buf_alloc_size - clnt->req_size) externalErrorExit (); clnt->req_size += (unsigned int) prn_size; send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; } else { memcpy (send_buf + clnt->req_size, MHD_HTTP_HEADER_TRANSFER_ENCODING ": chunked\r\n", MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_TRANSFER_ENCODING \ ": chunked\r\n")); clnt->req_size += MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_TRANSFER_ENCODING \ ": chunked\r\n"); } } if (0 != add_hdrs_size) { memcpy (send_buf + clnt->req_size, add_headers, add_hdrs_size); clnt->req_size += add_hdrs_size; } /* Terminate header */ send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; /* Add body (if any) */ if (! chunked) { if (0 != req_body_size) { memcpy (send_buf + clnt->req_size, req_body, req_body_size); clnt->req_size += req_body_size; } } else { if (0 != req_body_size) { int prn_size; prn_size = snprintf (send_buf + clnt->req_size, (buf_alloc_size - clnt->req_size), "%x", (unsigned int) req_body_size); if (0 >= prn_size) externalErrorExit (); if ((unsigned int) prn_size >= buf_alloc_size - clnt->req_size) externalErrorExit (); clnt->req_size += (unsigned int) prn_size; send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; memcpy (send_buf + clnt->req_size, req_body, req_body_size); clnt->req_size += req_body_size; send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; } send_buf[clnt->req_size++] = '0'; send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; } mhd_assert (clnt->req_size < buf_alloc_size); clnt->send_buf = send_buf; return clnt; } void _MHD_dumbClient_set_send_limits (struct _MHD_dumbClient *clnt, size_t step_size, size_t max_total_send) { clnt->single_send_size = step_size; clnt->send_size_limit = max_total_send; } /* internal */ static void _MHD_dumbClient_connect_init (struct _MHD_dumbClient *clnt) { struct sockaddr_in sa; mhd_assert (DUMB_CLIENT_INIT == clnt->stage); sa.sin_family = AF_INET; sa.sin_port = htons (clnt->port); sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); if (0 != connect (clnt->sckt, (struct sockaddr *) &sa, sizeof(sa))) { const int err = MHD_socket_get_error_ (); if ( (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINPROGRESS_)) || (MHD_SCKT_ERR_IS_EAGAIN_ (err))) clnt->stage = DUMB_CLIENT_CONNECTING; else externalErrorExitDesc ("Cannot 'connect()' the client socket"); } else clnt->stage = DUMB_CLIENT_CONNECTED; } void _MHD_dumbClient_start_connect (struct _MHD_dumbClient *clnt) { mhd_assert (DUMB_CLIENT_INIT == clnt->stage); _MHD_dumbClient_connect_init (clnt); } /* internal */ static void _MHD_dumbClient_connect_finish (struct _MHD_dumbClient *clnt) { int err = 0; socklen_t err_size = sizeof(err); mhd_assert (DUMB_CLIENT_CONNECTING == clnt->stage); if (0 != getsockopt (clnt->sckt, SOL_SOCKET, SO_ERROR, (void *) &err, &err_size)) externalErrorExitDesc ("'getsockopt()' call failed"); if (0 != err) externalErrorExitDesc ("Socket connect() failed"); clnt->stage = DUMB_CLIENT_CONNECTED; } /* internal */ static void _MHD_dumbClient_send_req (struct _MHD_dumbClient *clnt) { size_t send_size; ssize_t res; mhd_assert (DUMB_CLIENT_CONNECTED <= clnt->stage); mhd_assert (DUMB_CLIENT_REQ_SENT > clnt->stage); mhd_assert (clnt->req_size > clnt->send_off); send_size = (((0 != clnt->send_size_limit) && (clnt->req_size > clnt->send_size_limit)) ? clnt->send_size_limit : clnt->req_size) - clnt->send_off; mhd_assert (0 != send_size); if ((0 != clnt->single_send_size) && (clnt->single_send_size < send_size)) send_size = clnt->single_send_size; res = MHD_send_ (clnt->sckt, clnt->send_buf + clnt->send_off, send_size); if (res < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) return; if (MHD_SCKT_ERR_IS_EINTR_ (err)) return; if (MHD_SCKT_ERR_IS_REMOTE_DISCNN_ (err)) mhdErrorExitDesc ("The connection was aborted by MHD"); if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EPIPE_)) mhdErrorExitDesc ("The connection was shut down on MHD side"); externalErrorExitDesc ("Unexpected network error"); } clnt->send_off += (size_t) res; mhd_assert (clnt->send_off <= clnt->req_size); mhd_assert (clnt->send_off <= clnt->send_size_limit || \ 0 == clnt->send_size_limit); if (clnt->req_size == clnt->send_off) clnt->stage = DUMB_CLIENT_REQ_SENT; if ((0 != clnt->send_size_limit) && (clnt->send_size_limit == clnt->send_off)) clnt->stage = DUMB_CLIENT_FINISHING; } /* internal */ _MHD_NORETURN /* not implemented */ static void _MHD_dumbClient_recv_reply (struct _MHD_dumbClient *clnt) { (void) clnt; externalErrorExitDesc ("Not implemented for this test"); } int _MHD_dumbClient_is_req_sent (struct _MHD_dumbClient *clnt) { return DUMB_CLIENT_REQ_SENT <= clnt->stage; } /* internal */ static void _MHD_dumbClient_socket_close (struct _MHD_dumbClient *clnt) { if (MHD_INVALID_SOCKET != clnt->sckt) { if (! MHD_socket_close_ (clnt->sckt)) externalErrorExitDesc ("Unexpected error while closing " \ "the client socket"); clnt->sckt = MHD_INVALID_SOCKET; } } /* internal */ static void _MHD_dumbClient_finalize (struct _MHD_dumbClient *clnt) { if (MHD_INVALID_SOCKET != clnt->sckt) { if (0 != shutdown (clnt->sckt, SHUT_WR)) { const int err = MHD_socket_get_error_ (); if (! MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ENOTCONN_) && ! MHD_SCKT_ERR_IS_REMOTE_DISCNN_ (err)) mhdErrorExitDesc ("Unexpected error when shutting down " \ "the client socket"); } } clnt->stage = DUMB_CLIENT_FINISHED; } /* internal */ static int _MHD_dumbClient_needs_send (const struct _MHD_dumbClient *clnt) { return ((DUMB_CLIENT_CONNECTING <= clnt->stage) && (DUMB_CLIENT_REQ_SENT > clnt->stage)) || (DUMB_CLIENT_FINISHING == clnt->stage); } /* internal */ static int _MHD_dumbClient_needs_recv (const struct _MHD_dumbClient *clnt) { return (DUMB_CLIENT_HEADER_RECVEIVING <= clnt->stage) && (DUMB_CLIENT_BODY_RECVEIVED > clnt->stage); } /* internal */ /** * Check whether the client needs unconditionally process the data. * @param clnt the client to check * @return non-zero if client needs unconditionally process the data, * zero otherwise. */ static int _MHD_dumbClient_needs_process (const struct _MHD_dumbClient *clnt) { switch (clnt->stage) { case DUMB_CLIENT_INIT: case DUMB_CLIENT_REQ_SENT: case DUMB_CLIENT_HEADER_RECVEIVED: case DUMB_CLIENT_BODY_RECVEIVED: case DUMB_CLIENT_FINISHED: return ! 0; case DUMB_CLIENT_CONNECTING: case DUMB_CLIENT_CONNECTED: case DUMB_CLIENT_REQ_SENDING: case DUMB_CLIENT_HEADER_RECVEIVING: case DUMB_CLIENT_BODY_RECVEIVING: case DUMB_CLIENT_FINISHING: default: return 0; } return 0; /* Should be unreachable */ } /** * Process the client data with send()/recv() as needed. * @param clnt the client to process * @return non-zero if client finished processing the request, * zero otherwise. */ int _MHD_dumbClient_process (struct _MHD_dumbClient *clnt) { do { switch (clnt->stage) { case DUMB_CLIENT_INIT: _MHD_dumbClient_connect_init (clnt); break; case DUMB_CLIENT_CONNECTING: _MHD_dumbClient_connect_finish (clnt); break; case DUMB_CLIENT_CONNECTED: case DUMB_CLIENT_REQ_SENDING: _MHD_dumbClient_send_req (clnt); break; case DUMB_CLIENT_REQ_SENT: mhd_assert (0); clnt->stage = DUMB_CLIENT_HEADER_RECVEIVING; break; case DUMB_CLIENT_HEADER_RECVEIVING: _MHD_dumbClient_recv_reply (clnt); break; case DUMB_CLIENT_HEADER_RECVEIVED: clnt->stage = DUMB_CLIENT_BODY_RECVEIVING; break; case DUMB_CLIENT_BODY_RECVEIVING: _MHD_dumbClient_recv_reply (clnt); break; case DUMB_CLIENT_BODY_RECVEIVED: clnt->stage = DUMB_CLIENT_FINISHING; break; case DUMB_CLIENT_FINISHING: _MHD_dumbClient_finalize (clnt); break; case DUMB_CLIENT_FINISHED: return ! 0; default: mhd_assert (0); mhdErrorExit (); } } while (_MHD_dumbClient_needs_process (clnt)); return DUMB_CLIENT_FINISHED == clnt->stage; } void _MHD_dumbClient_get_fdsets (struct _MHD_dumbClient *clnt, MHD_socket *maxsckt, fd_set *rs, fd_set *ws, fd_set *es) { mhd_assert (NULL != rs); mhd_assert (NULL != ws); mhd_assert (NULL != es); if (DUMB_CLIENT_FINISHED > clnt->stage) { if (MHD_INVALID_SOCKET != clnt->sckt) { if ( (MHD_INVALID_SOCKET == *maxsckt) || (clnt->sckt > *maxsckt) ) *maxsckt = clnt->sckt; if (_MHD_dumbClient_needs_recv (clnt)) FD_SET (clnt->sckt, rs); if (_MHD_dumbClient_needs_send (clnt)) FD_SET (clnt->sckt, ws); FD_SET (clnt->sckt, es); } } } /** * Process the client data with send()/recv() as needed based on * information in fd_sets. * @param clnt the client to process * @return non-zero if client finished processing the request, * zero otherwise. */ int _MHD_dumbClient_process_from_fdsets (struct _MHD_dumbClient *clnt, fd_set *rs, fd_set *ws, fd_set *es) { if (_MHD_dumbClient_needs_process (clnt)) return _MHD_dumbClient_process (clnt); else if (MHD_INVALID_SOCKET != clnt->sckt) { if (_MHD_dumbClient_needs_recv (clnt) && FD_ISSET (clnt->sckt, rs)) return _MHD_dumbClient_process (clnt); else if (_MHD_dumbClient_needs_send (clnt) && FD_ISSET (clnt->sckt, ws)) return _MHD_dumbClient_process (clnt); else if (FD_ISSET (clnt->sckt, es)) return _MHD_dumbClient_process (clnt); } return DUMB_CLIENT_FINISHED == clnt->stage; } /** * Perform full request. * @param clnt the client to run * @return zero if client finished processing the request, * non-zero if timeout is reached. */ int _MHD_dumbClient_perform (struct _MHD_dumbClient *clnt) { time_t start; time_t now; start = time (NULL); now = start; do { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; struct timeval tv; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (! _MHD_dumbClient_needs_process (clnt)) { maxMhdSk = MHD_INVALID_SOCKET; _MHD_dumbClient_get_fdsets (clnt, &maxMhdSk, &rs, &ws, &es); mhd_assert (now >= start); #ifndef _WIN32 tv.tv_sec = (time_t) (TIMEOUTS_VAL * 2 - (now - start) + 1); #else tv.tv_sec = (long) (TIMEOUTS_VAL * 2 - (now - start) + 1); #endif tv.tv_usec = 250 * 1000; if (-1 == select ((int) (maxMhdSk + 1), &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else /* ! MHD_POSIX_SOCKETS */ mhd_assert ((0 != rs.fd_count) || (0 != ws.fd_count) || \ (0 != es.fd_count)); externalErrorExitDesc ("Unexpected select() error"); _MHD_sleep ((uint32_t) (tv.tv_sec * 1000 + tv.tv_usec / 1000)); #endif /* ! MHD_POSIX_SOCKETS */ continue; } if (_MHD_dumbClient_process_from_fdsets (clnt, &rs, &ws, &es)) return 0; } /* Use double timeout value here as MHD must catch timeout situations * in this test. Timeout in client as a last resort. */ } while ((now = time (NULL)) - start <= (TIMEOUTS_VAL * 2)); return 1; } /** * Close the client and free internally allocated resources. * @param clnt the client to close */ void _MHD_dumbClient_close (struct _MHD_dumbClient *clnt) { if (DUMB_CLIENT_FINISHED != clnt->stage) _MHD_dumbClient_finalize (clnt); _MHD_dumbClient_socket_close (clnt); if (NULL != clnt->send_buf) { free ((void *) clnt->send_buf); clnt->send_buf = NULL; } free (clnt); } _MHD_NORETURN static void socket_cb (void *cls, struct MHD_Connection *c, void **socket_context, enum MHD_ConnectionNotificationCode toe) { (void) cls; /* Unused */ (void) socket_context; /* Unused */ (void) toe; /* Unused */ MHD_suspend_connection (c); /* Should trigger panic */ mhdErrorExitDesc ("Function \"MHD_suspend_connection()\" succeed, while " \ "it must fail as daemon was started without MHD_ALLOW_SUSPEND_RESUME " \ "flag"); } struct ahc_cls_type { const char *volatile rp_data; volatile size_t rp_data_size; const char *volatile rq_method; const char *volatile rq_url; const char *volatile req_body; volatile unsigned int cb_called; /* Non-zero indicates that callback was called at least one time */ size_t req_body_size; /**< The number of bytes in @a req_body */ size_t req_body_uploaded; /* Updated by callback */ }; static enum MHD_Result ahcCheck (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker; enum MHD_Result ret; struct ahc_cls_type *const param = (struct ahc_cls_type *) cls; (void) connection; /* Unused */ if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); param->cb_called++; if (0 != strcmp (version, MHD_HTTP_VERSION_1_1)) mhdErrorExitDesc ("Unexpected HTTP version"); if (0 != strcmp (url, param->rq_url)) mhdErrorExitDesc ("Unexpected URI"); if (0 != strcmp (param->rq_method, method)) mhdErrorExitDesc ("Unexpected request method"); if (NULL == upload_data_size) mhdErrorExitDesc ("'upload_data_size' pointer is NULL"); if (0 != *upload_data_size) { const char *const upload_body = param->req_body; if (NULL == upload_data) mhdErrorExitDesc ("'upload_data' is NULL while " \ "'*upload_data_size' value is not zero"); if (NULL == upload_body) mhdErrorExitDesc ("'*upload_data_size' value is not zero " \ "while no request body is expected"); if (param->req_body_uploaded + *upload_data_size > param->req_body_size) { fprintf (stderr, "Too large upload body received. Got %u, expected %u", (unsigned int) (param->req_body_uploaded + *upload_data_size), (unsigned int) param->req_body_size); mhdErrorExit (); } if (0 != memcmp (upload_data, upload_body + param->req_body_uploaded, *upload_data_size)) { fprintf (stderr, "Unexpected request body at offset %u: " \ "'%.*s', expected: '%.*s'\n", (unsigned int) param->req_body_uploaded, (int) *upload_data_size, upload_data, (int) *upload_data_size, upload_body + param->req_body_uploaded); mhdErrorExit (); } param->req_body_uploaded += *upload_data_size; *upload_data_size = 0; } if (&marker != *req_cls) { /* The first call of the callback for this connection */ mhd_assert (NULL == upload_data); param->req_body_uploaded = 0; *req_cls = ▮ return MHD_YES; } if (NULL != upload_data) return MHD_YES; /* Full request has not been received so far */ #if 0 /* Code unused in this test */ struct MHD_Response *response; response = MHD_create_response_from_buffer (param->rp_data_size, (void *) param->rp_data, MHD_RESPMEM_MUST_COPY); if (NULL == response) mhdErrorExitDesc ("Failed to create response"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (MHD_YES != ret) mhdErrorExitDesc ("Failed to queue response"); #else if (NULL == upload_data) mhdErrorExitDesc ("Full request received, " \ "while incomplete request expected"); ret = MHD_NO; #endif return ret; } struct simpleQueryParams { /* Destination path for HTTP query */ const char *queryPath; /* Custom query method, NULL for default */ const char *method; /* Destination port for HTTP query */ uint16_t queryPort; /* Additional request headers, static */ const char *headers; /* NULL for request without body */ const uint8_t *req_body; size_t req_body_size; /* Non-zero to use chunked encoding for request body */ int chunked; /* HTTP query result error flag */ volatile int queryError; /* Response HTTP code, zero if no response */ volatile int responseCode; }; /* returns non-zero if timed-out */ static int performQueryExternal (struct MHD_Daemon *d, struct _MHD_dumbClient *clnt) { time_t start; struct timeval tv; int ret; const union MHD_DaemonInfo *di; MHD_socket lstn_sk; int client_accepted; int full_req_recieved; int full_req_sent; int some_data_recieved; di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD); if (NULL == di) mhdErrorExitDesc ("Cannot get listener socket"); lstn_sk = di->listen_fd; ret = 1; /* will be replaced with real result */ client_accepted = 0; _MHD_dumbClient_start_connect (clnt); full_req_recieved = 0; some_data_recieved = 0; start = time (NULL); do { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int num_ready; int do_client; /**< Process data in client */ maxMhdSk = MHD_INVALID_SOCKET; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL == clnt) { /* client has finished, check whether MHD is still * processing any connections */ full_req_sent = 1; do_client = 0; if (client_accepted && (0 > MHD_get_timeout64s (d))) { ret = 0; break; /* MHD finished as well */ } } else { full_req_sent = _MHD_dumbClient_is_req_sent (clnt); if (! full_req_sent) do_client = 1; /* Request hasn't been sent yet, send the data */ else { /* All request data has been sent. * Client will close the socket as the next step. */ if (full_req_recieved) do_client = 1; /* All data has been received by the MHD */ else if (some_data_recieved) { /* at least something was received by the MHD */ do_client = 1; } else { /* The MHD must receive at least something before closing * the connection. */ do_client = 0; } } if (do_client) _MHD_dumbClient_get_fdsets (clnt, &maxMhdSk, &rs, &ws, &es); } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); if (do_client) { tv.tv_sec = 1; tv.tv_usec = 250 * 1000; } else { /* Request completely sent but not yet fully received */ tv.tv_sec = 0; tv.tv_usec = FINAL_PACKETS_MS * 1000; } num_ready = select ((int) (maxMhdSk + 1), &rs, &ws, &es, &tv); if (-1 == num_ready) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); _MHD_sleep ((uint32_t) (tv.tv_sec * 1000 + tv.tv_usec / 1000)); #endif continue; } if (0 == num_ready) { /* select() finished by timeout, looks like no more packets are pending */ if (do_client) externalErrorExitDesc ("Timeout waiting for sockets"); if (full_req_sent && (! full_req_recieved)) full_req_recieved = 1; } if (full_req_recieved) mhdErrorExitDesc ("Full request has been received by MHD, while it " "must be aborted by the panic function"); if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); if (! client_accepted) client_accepted = FD_ISSET (lstn_sk, &rs); else { /* Client connection was already accepted by MHD */ if (! some_data_recieved) { if (! do_client) { if (0 != num_ready) { /* Connection was accepted before, "ready" socket means data */ some_data_recieved = 1; } } else { if (2 == num_ready) some_data_recieved = 1; else if ((1 == num_ready) && ((MHD_INVALID_SOCKET == clnt->sckt) || ! FD_ISSET (clnt->sckt, &ws))) some_data_recieved = 1; } } } if (do_client) { if (_MHD_dumbClient_process_from_fdsets (clnt, &rs, &ws, &es)) clnt = NULL; } /* Use double timeout value here so MHD would be able to catch timeout * internally */ } while (time (NULL) - start <= (TIMEOUTS_VAL * 2)); return ret; } /* Returns zero for successful response and non-zero for failed response */ static int doClientQueryInThread (struct MHD_Daemon *d, struct simpleQueryParams *p) { const union MHD_DaemonInfo *dinfo; struct _MHD_dumbClient *c; int errornum; int use_external_poll; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_FLAGS); if (NULL == dinfo) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); use_external_poll = (0 == (dinfo->flags & MHD_USE_INTERNAL_POLLING_THREAD)); if (0 == p->queryPort) externalErrorExit (); c = _MHD_dumbClient_create (p->queryPort, p->method, p->queryPath, p->headers, p->req_body, p->req_body_size, p->chunked); _MHD_dumbClient_set_send_limits (c, 1, 0); /* 'internal' polling should not be used in this test */ mhd_assert (use_external_poll); if (! use_external_poll) errornum = _MHD_dumbClient_perform (c); else errornum = performQueryExternal (d, c); if (errornum) fprintf (stderr, "Request timeout out.\n"); else mhdErrorExitDesc ("Request succeed, but it must fail"); _MHD_dumbClient_close (c); return errornum; } /* Perform test queries, shut down MHD daemon, and free parameters */ static unsigned int performTestQueries (struct MHD_Daemon *d, uint16_t d_port, struct ahc_cls_type *ahc_param) { struct simpleQueryParams qParam; /* Common parameters, to be individually overridden by specific test cases * if needed */ qParam.queryPort = d_port; qParam.method = MHD_HTTP_METHOD_PUT; qParam.queryPath = EXPECTED_URI_BASE_PATH; qParam.headers = REQ_HEADER_CT; qParam.req_body = (const uint8_t *) REQ_BODY; qParam.req_body_size = MHD_STATICSTR_LEN_ (REQ_BODY); qParam.chunked = 0; ahc_param->rq_url = EXPECTED_URI_BASE_PATH; ahc_param->rq_method = MHD_HTTP_METHOD_PUT; ahc_param->rp_data = "~"; ahc_param->rp_data_size = 1; ahc_param->req_body = (const char *) qParam.req_body; ahc_param->req_body_size = qParam.req_body_size; /* Make sure that maximum size is tested */ /* To be updated by callbacks */ ahc_param->cb_called = 0; if (0 != doClientQueryInThread (d, &qParam)) fprintf (stderr, "FAILED: client query failed."); MHD_stop_daemon (d); free (ahc_param); return 1; /* Always error if reached this point */ } enum testMhdThreadsType { testMhdThreadExternal = 0, testMhdThreadInternal = MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPerConnection = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPool }; enum testMhdPollType { testMhdPollBySelect = 0, testMhdPollByPoll = MHD_USE_POLL, testMhdPollByEpoll = MHD_USE_EPOLL, testMhdPollAuto = MHD_USE_AUTO }; /* Get number of threads for thread pool depending * on used poll function and test type. */ static unsigned int testNumThreadsForPool (enum testMhdPollType pollType) { unsigned int numThreads = MHD_CPU_COUNT; (void) pollType; /* Don't care about pollType for this test */ return numThreads; /* No practical limit for non-cleanup test */ } #define PANIC_MAGIC_CHECK 1133 _MHD_NORETURN static void myPanicCallback (void *cls, const char *file, unsigned int line, const char *reason) { int *const param = (int *) cls; if (NULL == cls) mhdErrorExitDesc ("The 'cls' parameter is NULL"); if (PANIC_MAGIC_CHECK != *param) mhdErrorExitDesc ("Wrong '*cls' value"); #ifdef HAVE_MESSAGES if (NULL == file) mhdErrorExitDesc ("The 'file' parameter is NULL"); if (NULL == reason) mhdErrorExitDesc ("The 'reason' parameter is NULL"); #else /* ! HAVE_MESSAGES */ if (NULL != file) mhdErrorExitDesc ("The 'file' parameter is not NULL"); if (NULL != reason) mhdErrorExitDesc ("The 'reason' parameter is not NULL"); #endif /* ! HAVE_MESSAGES */ fflush (stderr); fflush (stdout); printf ("User panic function has been called from file '%s' at line '%u' " "with the reason:\n%s", file, line, ((NULL != reason) ? reason : "(NULL)\n")); fflush (stdout); exit (0); } static struct MHD_Daemon * startTestMhdDaemon (enum testMhdThreadsType thrType, enum testMhdPollType pollType, uint16_t *pport, struct ahc_cls_type **ahc_param) { struct MHD_Daemon *d; const union MHD_DaemonInfo *dinfo; static int magic_panic_param = PANIC_MAGIC_CHECK; if (NULL == ahc_param) externalErrorExit (); *ahc_param = (struct ahc_cls_type *) malloc (sizeof(struct ahc_cls_type)); if (NULL == *ahc_param) externalErrorExit (); if ( (0 == *pport) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { *pport = 4190; } MHD_set_panic_func (&myPanicCallback, (void *) &magic_panic_param); if (testMhdThreadExternal == thrType) d = MHD_start_daemon (((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0) | MHD_USE_NO_THREAD_SAFETY, *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_NOTIFY_CONNECTION, &socket_cb, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned) TIMEOUTS_VAL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); else if (testMhdThreadInternalPool != thrType) d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0), *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_NOTIFY_CONNECTION, &socket_cb, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned) TIMEOUTS_VAL, MHD_OPTION_END); else d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | ((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0), *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_THREAD_POOL_SIZE, testNumThreadsForPool (pollType), MHD_OPTION_NOTIFY_CONNECTION, &socket_cb, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned) TIMEOUTS_VAL, MHD_OPTION_END); if (NULL == d) mhdErrorExitDesc ("Failed to start MHD daemon"); if (0 == *pport) { dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port)) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); *pport = dinfo->port; if (0 == global_port) global_port = *pport; /* Reuse the same port for all tests */ } return d; } /* Test runners */ static unsigned int testExternalGet (void) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; d = startTestMhdDaemon (testMhdThreadExternal, testMhdPollBySelect, &d_port, &ahc_param); return performTestQueries (d, d_port, ahc_param); } #if 0 /* disabled runners, not suitable for this test */ static unsigned int testInternalGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; struct term_notif_cb_param *term_result; d = startTestMhdDaemon (testMhdThreadInternal, pollType, &d_port, &ahc_param, &uri_cb_param, &term_result); return performTestQueries (d, d_port, ahc_param, uri_cb_param, term_result); } static int testMultithreadedGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; struct term_notif_cb_param *term_result; d = startTestMhdDaemon (testMhdThreadInternalPerConnection, pollType, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param, term_result); } static unsigned int testMultithreadedPoolGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; struct term_notif_cb_param *term_result; d = startTestMhdDaemon (testMhdThreadInternalPool, pollType, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param, term_result); } #endif /* disabled runners, not suitable for this test */ int main (int argc, char *const *argv) { unsigned int errorCount = 0; unsigned int test_result = 0; verbose = 0; (void) has_in_name; /* Unused, mute compiler warning */ if ((NULL == argv) || (0 == argv[0])) return 99; verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); test_global_init (); /* Could be set to non-zero value to enforce using specific port * in the test */ global_port = 0; test_result = testExternalGet (); if (test_result) fprintf (stderr, "FAILED: testExternalGet (). Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testExternalGet ().\n"); errorCount += test_result; #if 0 /* disabled runners, not suitable for this test */ if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { test_result = testInternalGet (testMhdPollAuto); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollAuto). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollBySelect).\n"); errorCount += test_result; #ifdef _MHD_HEAVY_TESTS /* Actually tests are not heavy, but took too long to complete while * not really provide any additional results. */ test_result = testInternalGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollBySelect). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedPoolGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (testMhdPollBySelect). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedGet (testMhdPollBySelect). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedGet (testMhdPollBySelect).\n"); errorCount += test_result; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { test_result = testInternalGet (testMhdPollByPoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByPoll). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByPoll).\n"); errorCount += test_result; } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { test_result = testInternalGet (testMhdPollByEpoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByEpoll). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByEpoll).\n"); errorCount += test_result; } #else /* Mute compiler warnings */ (void) testMultithreadedGet; (void) testMultithreadedPoolGet; #endif /* _MHD_HEAVY_TESTS */ } #endif /* disabled runners, not suitable for this test */ if (0 != errorCount) fprintf (stderr, "Error (code: %u)\n", errorCount); else if (verbose) printf ("All tests passed.\n"); test_global_cleanup (); return (errorCount == 0) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/microhttpd/microhttpd_dll_res.rc.in0000644000175000017500000000264414441373361017632 /* W32 resources for .dll */ #include LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO FILEVERSION @PACKAGE_VERSION_MAJOR@,@PACKAGE_VERSION_MINOR@,@PACKAGE_VERSION_SUBMINOR@,0 PRODUCTVERSION @PACKAGE_VERSION_MAJOR@,@PACKAGE_VERSION_MINOR@,@PACKAGE_VERSION_SUBMINOR@,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #if defined(_DEBUG) FILEFLAGS VS_FF_DEBUG #else FILEFLAGS 0 #endif FILEOS VOS_NT_WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE VFT2_UNKNOWN BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "04090000" /* Lang = US English, Charset = ASCII */ BEGIN VALUE "ProductName", "GNU libmicrohttpd\0" VALUE "ProductVersion", "@PACKAGE_VERSION@\0" VALUE "FileVersion", "@PACKAGE_VERSION@\0" VALUE "FileDescription", "GNU libmicrohttpd DLL for Windows (MinGW build, @W32CRT@ run-time lib)\0" VALUE "InternalName", "libmicrohttpd\0" VALUE "OriginalFilename", "libmicrohttpd-@MHD_W32_DLL_SUFF@.dll\0" VALUE "CompanyName", "Free Software Foundation\0" VALUE "LegalCopyright", "Copyright (C) 2007-2021 Christian Grothoff, Evgeny Grin, and project contributors\0" VALUE "Comments", "http://www.gnu.org/software/libmicrohttpd/\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 0 /* US English, ASCII */ END END libmicrohttpd-1.0.1/src/microhttpd/mhd_assert.h0000644000175000017500000000370014556705750015322 /* This file is part of libmicrohttpd Copyright (C) 2017-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/mhd_assert.h * @brief macros for mhd_assert() * @author Karlson2k (Evgeny Grin) */ /* Unlike POSIX version of 'assert.h', MHD version of 'assert' header * does not allow multiple redefinition of 'mhd_assert' macro within single * source file. */ #ifndef MHD_ASSERT_H #define MHD_ASSERT_H 1 #include "mhd_options.h" #if ! defined(_DEBUG) && ! defined(NDEBUG) #ifndef DEBUG /* Used by some toolchains */ #define NDEBUG 1 /* Use NDEBUG by default */ #else /* DEBUG */ #define _DEBUG 1 #endif /* DEBUG */ #endif /* !_DEBUG && !NDEBUG */ #if defined(_DEBUG) && defined(NDEBUG) #error Both _DEBUG and NDEBUG are defined #endif /* _DEBUG && NDEBUG */ #ifdef NDEBUG # define mhd_assert(ignore) ((void) 0) #else /* _DEBUG */ # ifdef HAVE_ASSERT # include # define mhd_assert(CHK) assert (CHK) # else /* ! HAVE_ASSERT */ # include # include # define mhd_assert(CHK) \ do { \ if (! (CHK)) { \ fprintf (stderr, "%s:%u Assertion failed: %s\nProgram aborted.\n", \ __FILE__, (unsigned) __LINE__, #CHK); \ fflush (stderr); abort (); } \ } while (0) # endif /* ! HAVE_ASSERT */ #endif /* _DEBUG */ #endif /* ! MHD_ASSERT_H */ libmicrohttpd-1.0.1/src/microhttpd/postprocessor.h0000644000175000017500000001205514441373361016111 /* This file is part of libmicrohttpd Copyright (C) 2007-2022 Daniel Pittman, Christian Grothoff, and Evgeny Grin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file postprocessor.h * @brief Declarations for parsing POST data * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_POSTPROCESSOR_H #define MHD_POSTPROCESSOR_H 1 #include "internal.h" /** * States in the PP parser's state machine. */ enum PP_State { /* general states */ PP_Error, PP_Done, PP_Init, PP_NextBoundary, /* url encoding-states */ PP_ProcessKey, PP_ProcessValue, PP_Callback, /* post encoding-states */ PP_ProcessEntryHeaders, PP_PerformCheckMultipart, PP_ProcessValueToBoundary, PP_PerformCleanup, /* nested post-encoding states */ PP_Nested_Init, PP_Nested_PerformMarking, PP_Nested_ProcessEntryHeaders, PP_Nested_ProcessValueToBoundary, PP_Nested_PerformCleanup }; enum RN_State { /** * No RN-preprocessing in this state. */ RN_Inactive = 0, /** * If the next character is CR, skip it. Otherwise, * just go inactive. */ RN_OptN = 1, /** * Expect CRLF (and only CRLF). As always, we also * expect only LF or only CR. */ RN_Full = 2, /** * Expect either CRLF or '--'CRLF. If '--'CRLF, transition into dash-state * for the main state machine */ RN_Dash = 3, /** * Got a single dash, expect second dash. */ RN_Dash2 = 4 }; /** * Bits for the globally known fields that * should not be deleted when we exit the * nested state. */ enum NE_State { NE_none = 0, NE_content_name = 1, NE_content_type = 2, NE_content_filename = 4, NE_content_transfer_encoding = 8 }; /** * Internal state of the post-processor. Note that the fields * are sorted by type to enable optimal packing by the compiler. */ struct MHD_PostProcessor { /** * The connection for which we are doing * POST processing. */ struct MHD_Connection *connection; /** * Function to call with POST data. */ MHD_PostDataIterator ikvi; /** * Extra argument to ikvi. */ void *cls; /** * Encoding as given by the headers of the connection. */ const char *encoding; /** * Primary boundary (points into encoding string) */ const char *boundary; /** * Nested boundary (if we have multipart/mixed encoding). */ char *nested_boundary; /** * Pointer to the name given in disposition. */ char *content_name; /** * Pointer to the (current) content type. */ char *content_type; /** * Pointer to the (current) filename. */ char *content_filename; /** * Pointer to the (current) encoding. */ char *content_transfer_encoding; /** * Value data left over from previous iteration. */ char xbuf[2]; /** * Size of our buffer for the key. */ size_t buffer_size; /** * Current position in the key buffer. */ size_t buffer_pos; /** * Current position in @e xbuf. */ size_t xbuf_pos; /** * Current offset in the value being processed. */ uint64_t value_offset; /** * strlen(boundary) -- if boundary != NULL. */ size_t blen; /** * strlen(nested_boundary) -- if nested_boundary != NULL. */ size_t nlen; /** * Do we have to call the 'ikvi' callback when processing the * multipart post body even if the size of the payload is zero? * Set to #MHD_YES whenever we parse a new multiparty entry header, * and to #MHD_NO the first time we call the 'ikvi' callback. * Used to ensure that we do always call 'ikvi' even if the * payload is empty (but not more than once). */ bool must_ikvi; /** * Set if we still need to run the unescape logic * on the key allocated at the end of this struct. */ bool must_unescape_key; /** * State of the parser. */ enum PP_State state; /** * Side-state-machine: skip CRLF (or just LF). * Set to 0 if we are not in skip mode. Set to 2 * if a CRLF is expected, set to 1 if a CR should * be skipped if it is the next character. */ enum RN_State skip_rn; /** * If we are in skip_rn with "dash" mode and * do find 2 dashes, what state do we go into? */ enum PP_State dash_state; /** * Which headers are global? (used to tell which * headers were only valid for the nested multipart). */ enum NE_State have; }; #endif /* ! MHD_POSTPROCESSOR_H */ libmicrohttpd-1.0.1/src/microhttpd/mhd_itc.h0000644000175000017500000002533414556705750014607 /* This file is part of libmicrohttpd Copyright (C) 2016-2023 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_itc.h * @brief Header for platform-independent inter-thread communication * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff * * Provides basic abstraction for inter-thread communication. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid * variable modification in function parameters. */ #ifndef MHD_ITC_H #define MHD_ITC_H 1 #include "mhd_itc_types.h" #include #ifndef MHD_PANIC # include # ifdef HAVE_STDLIB_H # include # endif /* HAVE_STDLIB_H */ /* Simple implementation of MHD_PANIC, to be used outside lib */ # define MHD_PANIC(msg) \ do { fprintf (stderr, \ "Abnormal termination at %d line in file %s: %s\n", \ (int) __LINE__, __FILE__, msg); abort (); \ } while (0) #endif /* ! MHD_PANIC */ #if defined(_MHD_ITC_EVENTFD) /* **************** Optimized GNU/Linux ITC implementation by eventfd ********** */ #include #include /* for uint64_t */ #ifdef HAVE_UNISTD_H #include /* for read(), write() */ #endif /* HAVE_UNISTD_H */ #ifdef HAVE_STRING_H #include /* for strerror() */ #include #endif /** * Number of FDs used by every ITC. */ #define MHD_ITC_NUM_FDS_ (1) /** * Initialise ITC by generating eventFD * @param itc the itc to initialise * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_init_(itc) \ (-1 != ((itc).fd = eventfd (0, EFD_CLOEXEC | EFD_NONBLOCK))) /** * Get description string of last errno for itc operations. */ #define MHD_itc_last_strerror_() strerror (errno) /** * Internal static const helper for MHD_itc_activate_() */ static const uint64_t _MHD_itc_wr_data = 1; /** * Activate signal on @a itc * @param itc the itc to use * @param str ignored * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_activate_(itc, str) \ ((write ((itc).fd, (const void*) &_MHD_itc_wr_data, \ sizeof(_MHD_itc_wr_data)) > 0) || (EAGAIN == errno)) /** * Return read FD of @a itc which can be used for poll(), select() etc. * @param itc the itc to get FD * @return FD of read side */ #define MHD_itc_r_fd_(itc) ((itc).fd) /** * Return write FD of @a itc * @param itc the itc to get FD * @return FD of write side */ #define MHD_itc_w_fd_(itc) ((itc).fd) /** * Clear signaled state on @a itc * @param itc the itc to clear */ #define MHD_itc_clear_(itc) \ do { uint64_t __b; \ (void) read ((itc).fd, (void*)&__b, sizeof(__b)); \ } while (0) /** * Destroy previously initialised ITC. Note that close() * on some platforms returns odd errors, so we ONLY fail * if the errno is EBADF. * @param itc the itc to destroy * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_destroy_(itc) \ ((0 == close ((itc).fd)) || (EBADF != errno)) /** * Check whether ITC has valid value. * * Macro check whether @a itc value is valid (allowed), * macro does not check whether @a itc was really initialised. * @param itc the itc to check * @return boolean true if @a itc has valid value, * boolean false otherwise. */ #define MHD_ITC_IS_VALID_(itc) (-1 != ((itc).fd)) /** * Set @a itc to invalid value. * @param itc the itc to set */ #define MHD_itc_set_invalid_(itc) ((itc).fd = -1) #elif defined(_MHD_ITC_PIPE) /* **************** Standard UNIX ITC implementation by pipe ********** */ #if defined(HAVE_PIPE2_FUNC) && defined(HAVE_FCNTL_H) # include /* for O_CLOEXEC, O_NONBLOCK */ #endif /* HAVE_PIPE2_FUNC && HAVE_FCNTL_H */ #ifdef HAVE_UNISTD_H #include /* for read(), write(), errno */ #endif /* HAVE_UNISTD_H */ #ifdef HAVE_STRING_H #include /* for strerror() */ #endif /** * Number of FDs used by every ITC. */ #define MHD_ITC_NUM_FDS_ (2) /** * Initialise ITC by generating pipe * @param itc the itc to initialise * @return non-zero if succeeded, zero otherwise */ #ifdef HAVE_PIPE2_FUNC # define MHD_itc_init_(itc) (! pipe2 ((itc).fd, O_CLOEXEC | O_NONBLOCK)) #else /* ! HAVE_PIPE2_FUNC */ # define MHD_itc_init_(itc) \ ( (! pipe ((itc).fd)) ? \ (MHD_itc_nonblocking_ ((itc)) ? \ (! 0) : \ (MHD_itc_destroy_ ((itc)), 0) ) \ : (0) ) #endif /* ! HAVE_PIPE2_FUNC */ /** * Get description string of last errno for itc operations. */ #define MHD_itc_last_strerror_() strerror (errno) /** * Activate signal on @a itc * @param itc the itc to use * @param str one-symbol string, useful only for strace debug * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_activate_(itc, str) \ ((write ((itc).fd[1], (const void*) (str), 1) > 0) || (EAGAIN == errno)) /** * Return read FD of @a itc which can be used for poll(), select() etc. * @param itc the itc to get FD * @return FD of read side */ #define MHD_itc_r_fd_(itc) ((itc).fd[0]) /** * Return write FD of @a itc * @param itc the itc to get FD * @return FD of write side */ #define MHD_itc_w_fd_(itc) ((itc).fd[1]) /** * Clear signaled state on @a itc * @param itc the itc to clear */ #define MHD_itc_clear_(itc) do \ { long __b; \ while (0 < read ((itc).fd[0], (void*) &__b, sizeof(__b))) \ {(void)0;} } while (0) /** * Destroy previously initialised ITC * @param itc the itc to destroy * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_destroy_(itc) \ ( (0 == close ((itc).fd[0])) ? \ (0 == close ((itc).fd[1])) : \ ((close ((itc).fd[1])), 0) ) /** * Check whether ITC has valid value. * * Macro check whether @a itc value is valid (allowed), * macro does not check whether @a itc was really initialised. * @param itc the itc to check * @return boolean true if @a itc has valid value, * boolean false otherwise. */ #define MHD_ITC_IS_VALID_(itc) (-1 != (itc).fd[0]) /** * Set @a itc to invalid value. * @param itc the itc to set */ #define MHD_itc_set_invalid_(itc) ((itc).fd[0] = (itc).fd[1] = -1) #ifndef HAVE_PIPE2_FUNC /** * Change itc FD options to be non-blocking. * * @param fd the FD to manipulate * @return non-zero if succeeded, zero otherwise */ int MHD_itc_nonblocking_ (struct MHD_itc_ itc); #endif /* ! HAVE_PIPE2_FUNC */ #elif defined(_MHD_ITC_SOCKETPAIR) /* **************** ITC implementation by socket pair ********** */ #include "mhd_sockets.h" /** * Number of FDs used by every ITC. */ #define MHD_ITC_NUM_FDS_ (2) /** * Initialise ITC by generating socketpair * @param itc the itc to initialise * @return non-zero if succeeded, zero otherwise */ #ifdef MHD_socket_pair_nblk_ # define MHD_itc_init_(itc) MHD_socket_pair_nblk_ ((itc).sk) #else /* ! MHD_socket_pair_nblk_ */ # define MHD_itc_init_(itc) \ (MHD_socket_pair_ ((itc).sk) ? \ (MHD_itc_nonblocking_ ((itc)) ? \ (! 0) : \ (MHD_itc_destroy_ ((itc)), 0) ) \ : (0)) #endif /* ! MHD_socket_pair_nblk_ */ /** * Get description string of last error for itc operations. */ #define MHD_itc_last_strerror_() MHD_socket_last_strerr_ () /** * Activate signal on @a itc * @param itc the itc to use * @param str one-symbol string, useful only for strace debug * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_activate_(itc, str) \ ((MHD_send_ ((itc).sk[1], (str), 1) > 0) || \ (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))) /** * Return read FD of @a itc which can be used for poll(), select() etc. * @param itc the itc to get FD * @return FD of read side */ #define MHD_itc_r_fd_(itc) ((itc).sk[0]) /** * Return write FD of @a itc * @param itc the itc to get FD * @return FD of write side */ #define MHD_itc_w_fd_(itc) ((itc).sk[1]) /** * Clear signaled state on @a itc * @param itc the itc to clear */ #define MHD_itc_clear_(itc) do \ { long __b; \ while (0 < recv ((itc).sk[0], (void*) &__b, sizeof(__b), 0)) \ {(void)0;} } while (0) /** * Destroy previously initialised ITC * @param itc the itc to destroy * @return non-zero if succeeded, zero otherwise */ #define MHD_itc_destroy_(itc) \ (MHD_socket_close_ ((itc).sk[0]) ? \ MHD_socket_close_ ((itc).sk[1]) : \ ((void) MHD_socket_close_ ((itc).sk[1]), 0) ) /** * Check whether ITC has valid value. * * Macro check whether @a itc value is valid (allowed), * macro does not check whether @a itc was really initialised. * @param itc the itc to check * @return boolean true if @a itc has valid value, * boolean false otherwise. */ #define MHD_ITC_IS_VALID_(itc) (MHD_INVALID_SOCKET != (itc).sk[0]) /** * Set @a itc to invalid value. * @param itc the itc to set */ #define MHD_itc_set_invalid_(itc) \ ((itc).sk[0] = (itc).sk[1] = MHD_INVALID_SOCKET) #ifndef MHD_socket_pair_nblk_ # define MHD_itc_nonblocking_(pip) \ (MHD_socket_nonblocking_ ((pip).sk[0]) && \ MHD_socket_nonblocking_ ((pip).sk[1])) #endif /* ! MHD_socket_pair_nblk_ */ #endif /* _MHD_ITC_SOCKETPAIR */ /** * Destroy previously initialised ITC and abort execution * if error is detected. * @param itc the itc to destroy */ #define MHD_itc_destroy_chk_(itc) do { \ if (! MHD_itc_destroy_ (itc)) \ MHD_PANIC (_ ("Failed to destroy ITC.\n")); \ } while (0) /** * Check whether ITC has invalid value. * * Macro check whether @a itc value is invalid, * macro does not check whether @a itc was destroyed. * @param itc the itc to check * @return boolean true if @a itc has invalid value, * boolean false otherwise. */ #define MHD_ITC_IS_INVALID_(itc) (! MHD_ITC_IS_VALID_ (itc)) #endif /* MHD_ITC_H */ libmicrohttpd-1.0.1/src/microhttpd/mhd_itc.c0000644000175000017500000000356014417460232014564 /* This file is part of libmicrohttpd Copyright (C) 2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_itc.c * @brief Implementation of inter-thread communication functions * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff */ #include "mhd_itc.h" #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include "internal.h" #if defined(_MHD_ITC_PIPE) #if ! defined(_WIN32) || defined(__CYGWIN__) #ifndef HAVE_PIPE2_FUNC /** * Change itc FD options to be non-blocking. * * @param itc the inter-thread communication primitive to manipulate * @return non-zero if succeeded, zero otherwise */ int MHD_itc_nonblocking_ (struct MHD_itc_ itc) { unsigned int i; for (i = 0; i<2; i++) { int flags; flags = fcntl (itc.fd[i], F_GETFL); if (-1 == flags) return 0; if ( ((flags | O_NONBLOCK) != flags) && (0 != fcntl (itc.fd[i], F_SETFL, flags | O_NONBLOCK)) ) return 0; } return ! 0; } #endif /* ! HAVE_PIPE2_FUNC */ #endif /* !_WIN32 || __CYGWIN__ */ #endif /* _MHD_ITC_EVENTFD || _MHD_ITC_PIPE */ libmicrohttpd-1.0.1/src/microhttpd/test_auth_parse.c0000644000175000017500000022626414556705750016372 /* This file is part of libmicrohttpd Copyright (C) 2022-2023 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_auth_parse.c * @brief Unit tests for request's 'Authorization" headers parsing * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include #include "gen_auth.h" #ifdef BAUTH_SUPPORT #include "basicauth.h" #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT #include "digestauth.h" #endif /* DAUTH_SUPPORT */ #include "mhd_assert.h" #include "internal.h" #include "connection.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); fflush (stderr); exit (8); } /* Declarations for local replacements of MHD functions */ /* None, headers are included */ /* Local replacements implementations */ void * MHD_connection_alloc_memory_ (struct MHD_Connection *connection, size_t size) { void *ret; if (NULL == connection) mhdErrorExitDesc ("'connection' parameter is NULL"); /* Use 'read_buffer' just as a flag */ if (NULL != connection->read_buffer) { /* Use 'write_buffer' just as a flag */ if (NULL != connection->write_buffer) mhdErrorExitDesc ("Unexpected third memory allocation, " \ "while previous allocations was not freed"); } /* Just use simple "malloc()" here */ ret = malloc (size); if (NULL == ret) externalErrorExit (); /* Track up to two allocations */ if (NULL == connection->read_buffer) connection->read_buffer = (char *) ret; else connection->write_buffer = (char *) ret; return ret; } /** * Static variable to avoid additional malloc()/free() pairs */ static struct MHD_Connection conn; void MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...) { (void) daemon; if (! conn.rq.client_aware) { fprintf (stderr, "Unexpected call of 'MHD_LOG(), format is '%s'.\n", format); fprintf (stderr, "'Authorization' header value: '%s'.\n", (NULL == conn.rq.headers_received) ? "NULL" : (conn.rq.headers_received->value)); mhdErrorExit (); } conn.rq.client_aware = false; /* Clear the flag */ return; } /** * Static variable to avoid additional malloc()/free() pairs */ static struct MHD_HTTP_Req_Header req_header; static void test_global_init (void) { memset (&conn, 0, sizeof(conn)); memset (&req_header, 0, sizeof(req_header)); } /** * Add "Authorization" client test header. * * @param hdr the pointer to the headr value, must be valid until end of * checking of this header * @param hdr_len the length of the @a hdr * @note The function is NOT thread-safe */ static void add_AuthHeader (const char *hdr, size_t hdr_len) { if ((NULL != conn.rq.headers_received) || (NULL != conn.rq.headers_received_tail)) externalErrorExitDesc ("Connection's test headers are not empty already"); if (NULL != hdr) { /* Skip initial whitespaces, emulate MHD's headers processing */ while (' ' == hdr[0] || '\t' == hdr[0]) { hdr++; hdr_len--; } req_header.header = MHD_HTTP_HEADER_AUTHORIZATION; /* Static string */ req_header.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_AUTHORIZATION); req_header.value = hdr; req_header.value_size = hdr_len; req_header.kind = MHD_HEADER_KIND; req_header.prev = NULL; req_header.next = NULL; conn.rq.headers_received = &req_header; conn.rq.headers_received_tail = &req_header; } else { conn.rq.headers_received = NULL; conn.rq.headers_received_tail = NULL; } conn.state = MHD_CONNECTION_FULL_REQ_RECEIVED; /* Should be a typical value */ } #ifdef BAUTH_SUPPORT /** * Parse previously added Basic Authorization client header and return * result of the parsing. * * Function performs basic checking of the parsing result * @return result of header parsing * @note The function is NOT thread-safe */ static const struct MHD_RqBAuth * get_BAuthRqParams (void) { const struct MHD_RqBAuth *res1; const struct MHD_RqBAuth *res2; /* Store pointer in some member unused in this test */ res1 = MHD_get_rq_bauth_params_ (&conn); if (! conn.rq.bauth_tried) mhdErrorExitDesc ("'rq.bauth_tried' is not set"); res2 = MHD_get_rq_bauth_params_ (&conn); if (res1 != res2) mhdErrorExitDesc ("MHD_get_rq_bauth_params_() returned another pointer " \ "when called for the second time"); return res2; } #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT /** * Parse previously added Digest Authorization client header and return * result of the parsing. * * Function performs basic checking of the parsing result * @return result of header parsing * @note The function is NOT thread-safe */ static const struct MHD_RqDAuth * get_DAuthRqParams (void) { const struct MHD_RqDAuth *res1; const struct MHD_RqDAuth *res2; /* Store pointer in some member unused in this test */ res1 = MHD_get_rq_dauth_params_ (&conn); if (! conn.rq.dauth_tried) mhdErrorExitDesc ("'rq.dauth_tried' is not set"); res2 = MHD_get_rq_dauth_params_ (&conn); if (res1 != res2) mhdErrorExitDesc ("MHD_get_rq_bauth_params_() returned another pointer " \ "when called for the second time"); return res2; } #endif /* DAUTH_SUPPORT */ static void clean_AuthHeaders (void) { conn.state = MHD_CONNECTION_INIT; free (conn.read_buffer); free (conn.write_buffer); #ifdef BAUTH_SUPPORT conn.rq.bauth_tried = false; #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT conn.rq.dauth_tried = false; #endif /* BAUTH_SUPPORT */ #ifdef BAUTH_SUPPORT if ((NULL != conn.rq.bauth) && (conn.read_buffer != (const char *) conn.rq.bauth) && (conn.write_buffer != (const char *) conn.rq.bauth)) externalErrorExitDesc ("Memory allocation is not tracked as it should be"); conn.rq.bauth = NULL; #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT if ((NULL != conn.rq.dauth) && (conn.read_buffer != (const char *) conn.rq.dauth) && (conn.write_buffer != (const char *) conn.rq.dauth)) externalErrorExitDesc ("Memory allocation is not tracked as it should be"); conn.rq.dauth = NULL; #endif /* BAUTH_SUPPORT */ conn.rq.headers_received = NULL; conn.rq.headers_received_tail = NULL; conn.read_buffer = NULL; conn.write_buffer = NULL; conn.rq.client_aware = false; } enum MHD_TestAuthType { MHD_TEST_AUTHTYPE_NONE, MHD_TEST_AUTHTYPE_BASIC, MHD_TEST_AUTHTYPE_DIGEST, }; /* return zero if succeed, non-zero otherwise */ static unsigned int expect_result_type_n (const char *hdr, size_t hdr_len, const enum MHD_TestAuthType expected_type, int expect_log, unsigned int line_num) { unsigned int ret; ret = 0; add_AuthHeader (hdr, hdr_len); if (expect_log) conn.rq.client_aware = true; /* Use like a flag */ else conn.rq.client_aware = false; #ifdef BAUTH_SUPPORT if (MHD_TEST_AUTHTYPE_BASIC == expected_type) { if (NULL == get_BAuthRqParams ()) { fprintf (stderr, "'Authorization' header parsing FAILED:\n" "Basic Authorization was not found, while it should be.\n"); ret++; } } else #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT if (MHD_TEST_AUTHTYPE_DIGEST == expected_type) { if (NULL == get_DAuthRqParams ()) { fprintf (stderr, "'Authorization' header parsing FAILED:\n" "Digest Authorization was not found, while it should be.\n"); ret++; } } else #endif /* BAUTH_SUPPORT */ { #ifdef BAUTH_SUPPORT if (NULL != get_BAuthRqParams ()) { fprintf (stderr, "'Authorization' header parsing FAILED:\n" "Found Basic Authorization, while it should not be.\n"); ret++; } #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT if (NULL != get_DAuthRqParams ()) { fprintf (stderr, "'Authorization' header parsing FAILED:\n" "Found Digest Authorization, while it should not be.\n"); ret++; } #endif /* DAUTH_SUPPORT */ } #if defined(BAUTH_SUPPORT) && defined(DAUTH_SUPPORT) if (conn.rq.client_aware) { fprintf (stderr, "'Authorization' header parsing ERROR:\n" "Log function must be called, but it was not.\n"); ret++; } #endif /* BAUTH_SUPPORT && DAUTH_SUPPORT */ if (ret) { if (NULL == hdr) fprintf (stderr, "Input: Absence of 'Authorization' header.\n"); else if (0 == hdr_len) fprintf (stderr, "Input: empty 'Authorization' header.\n"); else fprintf (stderr, "Input Header: '%.*s'\n", (int) hdr_len, hdr); fprintf (stderr, "The check is at line: %u\n\n", line_num); ret = 1; } clean_AuthHeaders (); return ret; } #define expect_result_type(h,t,l) \ expect_result_type_n(h,MHD_STATICSTR_LEN_(h),t,l,__LINE__) static unsigned int check_type (void) { unsigned int r = 0; /**< The number of errors */ r += expect_result_type_n (NULL, 0, MHD_TEST_AUTHTYPE_NONE, 0, __LINE__); r += expect_result_type ("", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\t", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" \t", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\t ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\t \t", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" \t ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" \t \t", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\t \t ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Basic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" Basic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\tBasic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t Basic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" \tBasic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" Basic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t\tBasic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t \tBasic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t \t Basic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("Basic ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("Basic \t", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("Basic \t ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("Basic 123", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("Basic \t123", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("Basic abc ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("bAsIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" bAsIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\tbAsIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t bAsIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" \tbAsIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" bAsIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t\tbAsIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t \tbAsIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t \t bAsIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("bAsIC ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("bAsIC \t", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("bAsIC \t ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("bAsIC 123", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("bAsIC \t123", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("bAsIC abc ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("basic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" basic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\tbasic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t basic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" \tbasic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" basic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t\tbasic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t \tbasic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t \t basic", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("basic ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("basic \t", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("basic \t ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("basic 123", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("basic \t123", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("basic abc ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("BASIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" BASIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\tBASIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t BASIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" \tBASIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type (" BASIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t\tBASIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t \tBASIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("\t\t \t BASIC", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("BASIC ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("BASIC \t", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("BASIC \t ", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("BASIC 123", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("BASIC \t123", MHD_TEST_AUTHTYPE_BASIC, 0); r += expect_result_type ("BASIC abc ", MHD_TEST_AUTHTYPE_BASIC, 0); /* Only single token is allowed for 'Basic' Authorization */ r += expect_result_type ("Basic a b", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic a\tb", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic a\tb", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic abc1 b", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic c abc1", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic c abc1 ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic c abc1\t", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic c\tabc1\t", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic c abc1 b", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic zyx, b", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic zyx,b", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic zyx ,b", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic zyx;b", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic zyx; b", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Basic2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" Basic2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" Basic2 ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\tBasic2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\t Basic2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" \tBasic2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" Basic2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\t\t\tBasic2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\t\t \tBasic2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\t\t \t Basic2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Basic2 ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Basic2 \t", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Basic2 \t ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Basic2 123", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Basic2 \t123", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Basic2 abc ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("BasicBasic", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" BasicBasic", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\tBasicBasic", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\t BasicBasic", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" \tBasicBasic", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("BasicBasic ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("BasicBasic \t", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("BasicBasic \t\t", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("BasicDigest", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" BasicDigest", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("BasicDigest ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Basic\0", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\0" "Basic", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Digest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" Digest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\tDigest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t Digest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" \tDigest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" Digest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t\tDigest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t \tDigest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t \t Digest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest \t", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest \t ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\tDigest ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" Digest \t", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t \tDigest \t ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("digEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" digEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\tdigEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t digEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" \tdigEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" digEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t\tdigEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t \tdigEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t \t digEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("digEST ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("digEST \t", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("digEST \t ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\tdigEST ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" digEST \t", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t \tdigEST \t ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("digest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" digest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\tdigest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t digest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" \tdigest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" digest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t\tdigest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t \tdigest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t \t digest", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("digest ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("digest \t", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("digest \t ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\tdigest ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" digest \t", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t \tdigest \t ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("DIGEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" DIGEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\tDIGEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t DIGEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" \tDIGEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" DIGEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t\tDIGEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t \tDIGEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t\t \t DIGEST", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("DIGEST ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("DIGEST \t", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("DIGEST \t ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\tDIGEST ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type (" DIGEST \t", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("\t \tDIGEST \t ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,\t", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest , ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest , ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,\t, ,\t, ,\t, ,", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,\t,\t,\t,\t,\t,\t,", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest a=b", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest a=\"b\"", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc=1", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc=\"1\"", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest a=b ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest a=\"b\" ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc=1 ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc=\"1\" ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest a = b", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest a\t=\t\"b\"", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc =1", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc= \"1\"", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest a=\tb ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest a = \"b\" ", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc\t\t\t= 1 ", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc =\t\t\t\"1\" ", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc =1,,,,", MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc =1 ,,,,", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,,,,nc= \"1 \"", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,,,, nc= \" 1\"", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,,,, nc= \"1\",,,,", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,,,, nc= \"1\" ,,,,", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,,,, nc= \"1\" ,,,,", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,,,, nc= \"1\" ,,,,", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest ,,,, nc= \"1\" ,,,,,", \ MHD_TEST_AUTHTYPE_DIGEST, 0); r += expect_result_type ("Digest nc", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc ,", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc , ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest \tnc\t ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest \tnc\t ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc,", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc,uri", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1,uri", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1,uri ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1,uri,", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1, uri,", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1,uri ,", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1,uri , ", \ MHD_TEST_AUTHTYPE_NONE, 1); /* Binary zero */ r += expect_result_type ("Digest nc=1\0", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1\0" " ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1\t\0", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\0" "1", MHD_TEST_AUTHTYPE_NONE, 1); /* Semicolon */ r += expect_result_type ("Digest nc=1;", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1; ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=;1", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc;=1", MHD_TEST_AUTHTYPE_NONE, 1); /* The equal sign alone */ r += expect_result_type ("Digest =", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest =", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest = ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest ,=", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest , =", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest ,= ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest , = ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1,=", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=1, =", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=bar,=", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=bar, =", \ MHD_TEST_AUTHTYPE_NONE, 1); /* Unclosed quotation */ r += expect_result_type ("Digest nc=\"", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\"abc", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\" ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\"abc ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\" abc", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\" abc", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\"\\", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\"\\\"", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\" \\\"", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\"\\\" ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\" \\\" ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc=\"\\\"\\\"\\\"\\\"", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \"", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \"abc", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \" ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \"abc ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \" abc", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \" abc", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \"\\", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \"\\\"", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \" \\\"", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \"\\\" ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \" \\\" ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest nc= \"\\\"\\\"\\\"\\\"", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\"", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\"bar", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\" ", MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\"bar ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\" bar", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\" bar", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo= \" bar", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\", bar", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\" bar,", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\"\\\"", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\" \\\"", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\"\\\" ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\" \\\" ", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest foo=\"\\\"\\\"\\\"\\\"", \ MHD_TEST_AUTHTYPE_NONE, 1); /* Full set of parameters with semicolon inside */ r += expect_result_type ("Digest username=\"test@example.com\", " \ "realm=\"users@example.com\", nonce=\"32141232413abcde\", " \ "uri=\"/example\", qop=auth, nc=00000001; cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\"", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest username=\"test@example.com\", " \ "realm=\"users@example.com\", nonce=\"32141232413abcde\", " \ "uri=\"/example\", qop=auth, nc=00000001;cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\"", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest username;=\"test@example.com\", " \ "realm=\"users@example.com\", nonce=\"32141232413abcde\", " \ "uri=\"/example\", qop=auth, nc=00000001, cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\"", \ MHD_TEST_AUTHTYPE_NONE, 1); r += expect_result_type ("Digest2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("2Digest", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Digest" "a", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("a" "Digest", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" Digest2", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" 2Digest", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" Digest" "a", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" a" "Digest", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Digest2 ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("2Digest ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Digest" "a", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("a" "Digest ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("DigestBasic", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("DigestBasic ", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type (" DigestBasic", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("DigestBasic" "a", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("Digest" "\0", MHD_TEST_AUTHTYPE_NONE, 0); r += expect_result_type ("\0" "Digest", MHD_TEST_AUTHTYPE_NONE, 0); return r; } #ifdef BAUTH_SUPPORT /* return zero if succeed, 1 otherwise */ static unsigned int expect_basic_n (const char *hdr, size_t hdr_len, const char *tkn, size_t tkn_len, unsigned int line_num) { const struct MHD_RqBAuth *h; unsigned int ret; mhd_assert (NULL != hdr); mhd_assert (0 != hdr_len); add_AuthHeader (hdr, hdr_len); h = get_BAuthRqParams (); if (NULL == h) mhdErrorExitDesc ("'MHD_get_rq_bauth_params_()' returned NULL"); ret = 1; if (tkn_len != h->token68.len) fprintf (stderr, "'Authorization' header parsing FAILED:\n" "Wrong token length:\tRESULT[%u]: %.*s\tEXPECTED[%u]: %.*s\n", (unsigned) h->token68.len, (int) h->token68.len, h->token68.str ? h->token68.str : "(NULL)", (unsigned) tkn_len, (int) tkn_len, tkn ? tkn : "(NULL)"); else if ( ((NULL == tkn) != (NULL == h->token68.str)) || ((NULL != tkn) && (0 != memcmp (tkn, h->token68.str, tkn_len))) ) fprintf (stderr, "'Authorization' header parsing FAILED:\n" "Wrong token string:\tRESULT[%u]: %.*s\tEXPECTED[%u]: %.*s\n", (unsigned) h->token68.len, (int) h->token68.len, h->token68.str ? h->token68.str : "(NULL)", (unsigned) tkn_len, (int) tkn_len, tkn ? tkn : "(NULL)"); else ret = 0; if (0 != ret) { fprintf (stderr, "Input Header: '%.*s'\n", (int) hdr_len, hdr); fprintf (stderr, "The check is at line: %u\n\n", line_num); } clean_AuthHeaders (); return ret; } #define expect_basic(h,t) \ expect_basic_n(h,MHD_STATICSTR_LEN_(h),t,MHD_STATICSTR_LEN_(t),__LINE__) static unsigned int check_basic (void) { unsigned int r = 0; /**< The number of errors */ r += expect_basic ("Basic a", "a"); r += expect_basic ("Basic a", "a"); r += expect_basic ("Basic \ta", "a"); r += expect_basic ("Basic \ta\t", "a"); r += expect_basic ("Basic \ta ", "a"); r += expect_basic ("Basic a ", "a"); r += expect_basic ("Basic \t a\t ", "a"); r += expect_basic ("Basic \t abc\t ", "abc"); r += expect_basic ("Basic 2143sdfa4325sdfgfdab354354314SDSDFc", \ "2143sdfa4325sdfgfdab354354314SDSDFc"); r += expect_basic ("Basic 2143sdfa4325sdfgfdab354354314SDSDFc ", \ "2143sdfa4325sdfgfdab354354314SDSDFc"); r += expect_basic ("Basic 2143sdfa4325sdfgfdab354354314SDSDFc", \ "2143sdfa4325sdfgfdab354354314SDSDFc"); r += expect_basic ("Basic 2143sdfa4325sdfgfdab354354314SDSDFc ", \ "2143sdfa4325sdfgfdab354354314SDSDFc"); r += expect_basic (" Basic 2143sdfa4325sdfgfdab354354314SDSDFc", \ "2143sdfa4325sdfgfdab354354314SDSDFc"); r += expect_basic (" Basic 2143sdfa4325sdfgfdab354354314SDSDFc", \ "2143sdfa4325sdfgfdab354354314SDSDFc"); r += expect_basic (" Basic 2143sdfa4325sdfgfdab354354314SDSDFc ", \ "2143sdfa4325sdfgfdab354354314SDSDFc"); r += expect_basic (" Basic 2143sdfa4325sdfgfdab354354314SDSDFc ", \ "2143sdfa4325sdfgfdab354354314SDSDFc"); r += expect_basic (" Basic 2143sdfa4325sdfgfdab354354314SDSDFc ", \ "2143sdfa4325sdfgfdab354354314SDSDFc"); r += expect_basic ("Basic -A.1-z~9+/=====", "-A.1-z~9+/====="); r += expect_basic (" Basic -A.1-z~9+/===== ", "-A.1-z~9+/====="); r += expect_basic_n ("Basic", MHD_STATICSTR_LEN_ ("Basic"), NULL, 0,__LINE__); r += expect_basic_n (" Basic", MHD_STATICSTR_LEN_ (" Basic"), NULL, 0, __LINE__); r += expect_basic_n ("Basic ", MHD_STATICSTR_LEN_ ("Basic "), NULL, 0, __LINE__); r += expect_basic_n ("Basic \t\t", MHD_STATICSTR_LEN_ ("Basic \t\t"), NULL, 0, __LINE__); return r; } #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT /* return zero if succeed, 1 otherwise */ static unsigned int cmp_dauth_param (const char *pname, const struct MHD_RqDAuthParam *param, const char *expected_value) { unsigned int ret; size_t expected_len; bool expected_quoted; mhd_assert (NULL != param); mhd_assert (NULL != pname); ret = 0; if (NULL == expected_value) { expected_len = 0; expected_quoted = false; if (NULL != param->value.str) ret = 1; else if (param->value.len != expected_len) ret = 1; else if (param->quoted != expected_quoted) ret = 1; } else { expected_len = strlen (expected_value); expected_quoted = (NULL != memchr (expected_value, '\\', expected_len)); if (NULL == param->value.str) ret = 1; else if (param->value.len != expected_len) ret = 1; else if (param->quoted != expected_quoted) ret = 1; else if (0 != memcmp (param->value.str, expected_value, expected_len)) ret = 1; } if (0 != ret) { fprintf (stderr, "Parameter '%s' parsed incorrectly:\n", pname); fprintf (stderr, "\tRESULT :\tvalue.str: %.*s", (int) (param->value.str ? param->value.len : 6), param->value.str ? param->value.str : "(NULL)"); fprintf (stderr, "\tvalue.len: %u", (unsigned) param->value.len); fprintf (stderr, "\tquoted: %s\n", (unsigned) param->quoted ? "true" : "false"); fprintf (stderr, "\tEXPECTED:\tvalue.str: %.*s", (int) (expected_value ? expected_len : 6), expected_value ? expected_value : "(NULL)"); fprintf (stderr, "\tvalue.len: %u", (unsigned) expected_len); fprintf (stderr, "\tquoted: %s\n", (unsigned) expected_quoted ? "true" : "false"); } return ret; } /* return zero if succeed, 1 otherwise */ static unsigned int expect_digest_n (const char *hdr, size_t hdr_len, const char *nonce, enum MHD_DigestAuthAlgo3 algo3, const char *response, const char *username, const char *username_ext, const char *realm, const char *uri, const char *qop_raw, enum MHD_DigestAuthQOP qop, const char *cnonce, const char *nc, int userhash, unsigned int line_num) { const struct MHD_RqDAuth *h; unsigned int ret; mhd_assert (NULL != hdr); mhd_assert (0 != hdr_len); add_AuthHeader (hdr, hdr_len); h = get_DAuthRqParams (); if (NULL == h) mhdErrorExitDesc ("'MHD_get_rq_dauth_params_()' returned NULL"); ret = 0; ret += cmp_dauth_param ("nonce", &h->nonce, nonce); if (h->algo3 != algo3) { ret += 1; fprintf (stderr, "Parameter 'algorithm' detected incorrectly:\n"); fprintf (stderr, "\tRESULT :\t%u\n", (unsigned) h->algo3); fprintf (stderr, "\tEXPECTED:\t%u\n", (unsigned) algo3); } ret += cmp_dauth_param ("response", &h->response, response); ret += cmp_dauth_param ("username", &h->username, username); ret += cmp_dauth_param ("username_ext", &h->username_ext, username_ext); ret += cmp_dauth_param ("realm", &h->realm, realm); ret += cmp_dauth_param ("uri", &h->uri, uri); ret += cmp_dauth_param ("qop", &h->qop_raw, qop_raw); if (h->qop != qop) { ret += 1; fprintf (stderr, "Parameter 'qop' detected incorrectly:\n"); fprintf (stderr, "\tRESULT :\t%u\n", (unsigned) h->qop); fprintf (stderr, "\tEXPECTED:\t%u\n", (unsigned) qop); } ret += cmp_dauth_param ("cnonce", &h->cnonce, cnonce); ret += cmp_dauth_param ("nc", &h->nc, nc); if (h->userhash != ! (! userhash)) { ret += 1; fprintf (stderr, "Parameter 'userhash' parsed incorrectly:\n"); fprintf (stderr, "\tRESULT :\t%s\n", h->userhash ? "true" : "false"); fprintf (stderr, "\tEXPECTED:\t%s\n", userhash ? "true" : "false"); } if (0 != ret) { fprintf (stderr, "Input Header: '%.*s'\n", (int) hdr_len, hdr); fprintf (stderr, "The check is at line: %u\n\n", line_num); } clean_AuthHeaders (); return ret; } #define expect_digest(h,no,a,rs,un,ux,rm,ur,qr,qe,c,nc,uh) \ expect_digest_n(h,MHD_STATICSTR_LEN_(h),\ no,a,rs,un,ux,rm,ur,qr,qe,c,nc,uh,__LINE__) static unsigned int check_digest (void) { unsigned int r = 0; /**< The number of errors */ r += expect_digest ("Digest", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest nc=1", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, NULL, \ MHD_DIGEST_AUTH_QOP_NONE, NULL, "1", 0); r += expect_digest ("Digest nc=\"1\"", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1", 0); r += expect_digest ("Digest nc=\"1\" ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1", 0); r += expect_digest ("Digest ,nc=\"1\" ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1", 0); r += expect_digest ("Digest nc=\"1\", ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1", 0); r += expect_digest ("Digest nc=\"1\" , ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1", 0); r += expect_digest ("Digest nc=1, ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1", 0); r += expect_digest ("Digest nc=1 , ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1", 0); r += expect_digest ("Digest ,,,nc=1, ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1", 0); r += expect_digest ("Digest ,,,nc=1 , ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1", 0); r += expect_digest ("Digest ,,,nc=\"1 \", ", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1 ", 0); r += expect_digest ("Digest nc=\"1 \"", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1 ", 0); r += expect_digest ("Digest nc=\"1 \" ,", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1 ", 0); r += expect_digest ("Digest nc=\"1 \", ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1 ", 0); r += expect_digest ("Digest nc=\"1;\", ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1;", 0); r += expect_digest ("Digest nc=\"1\\;\", ", NULL, MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, "1\\;", 0); r += expect_digest ("Digest userhash=false", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest userhash=\"false\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest userhash=foo", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest userhash=true", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 1); r += expect_digest ("Digest userhash=\"true\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 1); r += expect_digest ("Digest userhash=\"\\t\\r\\u\\e\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 1); r += expect_digest ("Digest userhash=TRUE", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 1); r += expect_digest ("Digest userhash=True", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 1); r += expect_digest ("Digest userhash = true", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 1); r += expect_digest ("Digest userhash=True2", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest userhash=\" true\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=MD5", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=md5", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=Md5", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=mD5", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=\"MD5\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=\"\\M\\D\\5\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=\"\\m\\d\\5\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=SHA-256", NULL, \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=sha-256", NULL, \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=Sha-256", NULL, \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=\"SHA-256\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=\"SHA\\-25\\6\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=\"shA-256\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=MD5-sess", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5_SESSION, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=MD5-SESS", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5_SESSION, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=md5-Sess", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5_SESSION, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=SHA-256-seSS", NULL, \ MHD_DIGEST_AUTH_ALGO3_SHA256_SESSION, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=SHA-512-256", NULL, \ MHD_DIGEST_AUTH_ALGO3_SHA512_256, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=SHA-512-256-sess", NULL, \ MHD_DIGEST_AUTH_ALGO3_SHA512_256_SESSION, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=MD5-2", NULL, \ MHD_DIGEST_AUTH_ALGO3_INVALID, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=MD5-sess2", NULL, \ MHD_DIGEST_AUTH_ALGO3_INVALID, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=SHA-256-512", NULL, \ MHD_DIGEST_AUTH_ALGO3_INVALID, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest algorithm=", NULL, \ MHD_DIGEST_AUTH_ALGO3_INVALID, \ NULL, NULL, NULL, NULL, NULL, \ NULL, MHD_DIGEST_AUTH_QOP_NONE, NULL, NULL, 0); r += expect_digest ("Digest qop=auth", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, NULL, NULL, 0); r += expect_digest ("Digest qop=\"auth\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, NULL, NULL, 0); r += expect_digest ("Digest qop=Auth", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ "Auth", MHD_DIGEST_AUTH_QOP_AUTH, NULL, NULL, 0); r += expect_digest ("Digest qop=AUTH", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ "AUTH", MHD_DIGEST_AUTH_QOP_AUTH, NULL, NULL, 0); r += expect_digest ("Digest qop=\"\\A\\ut\\H\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ "\\A\\ut\\H", MHD_DIGEST_AUTH_QOP_AUTH, NULL, NULL, 0); r += expect_digest ("Digest qop=\"auth \"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ "auth ", MHD_DIGEST_AUTH_QOP_INVALID, NULL, NULL, 0); r += expect_digest ("Digest qop=auth-int", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ "auth-int", MHD_DIGEST_AUTH_QOP_AUTH_INT, NULL, NULL, 0); r += expect_digest ("Digest qop=\"auth-int\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ "auth-int", MHD_DIGEST_AUTH_QOP_AUTH_INT, NULL, NULL, 0); r += expect_digest ("Digest qop=\"auTh-iNt\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ "auTh-iNt", MHD_DIGEST_AUTH_QOP_AUTH_INT, NULL, NULL, 0); r += expect_digest ("Digest qop=\"auTh-iNt2\"", NULL, \ MHD_DIGEST_AUTH_ALGO3_MD5, \ NULL, NULL, NULL, NULL, NULL, \ "auTh-iNt2", MHD_DIGEST_AUTH_QOP_INVALID, NULL, NULL, 0); r += expect_digest ("Digest username=\"test@example.com\", " \ "realm=\"users@example.com\", " \ "nonce=\"32141232413abcde\", " \ "uri=\"/example\", qop=auth, nc=00000001, " \ "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\"", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_MD5, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ NULL, "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, \ "0a4f113b", "00000001", 0); r += expect_digest ("Digest username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, " \ "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\"", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest username=test@example.com, " \ "realm=users@example.com, algorithm=\"SHA-256-sess\", " \ "nonce=32141232413abcde, " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=/example, qop=\"auth\", nc=\"00000001\", " \ "cnonce=0a4f113b, " \ "response=6629fae49393a05397450978507c4ef1, " \ "opaque=sadfljk32sdaf", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256_SESSION, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest username = \"test@example.com\", " \ "realm\t=\t\"users@example.com\", algorithm\t= SHA-256, " \ "nonce\t= \"32141232413abcde\", " \ "username*\t=\tUTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri = \"/example\", qop = auth, nc\t=\t00000001, " \ "cnonce\t\t\t= \"0a4f113b\", " \ "response =\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\t\t\"sadfljk32sdaf\"", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest username=\"test@example.com\"," \ "realm=\"users@example.com\",algorithm=SHA-512-256," \ "nonce=\"32141232413abcde\"," \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates," \ "uri=\"/example\",qop=auth,nc=00000001," \ "cnonce=\"0a4f113b\"," \ "response=\"6629fae49393a05397450978507c4ef1\"," \ "opaque=\"sadfljk32sdaf\"", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA512_256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest username=\"test@example.com\"," \ "realm=\"users@example.com\",algorithm=SHA-256," \ "nonce=\"32141232413abcde\",asdf=asdffdsaf," \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates," \ "uri=\"/example\",qop=auth,nc=00000001,cnonce=\"0a4f113b\"," \ "response=\"6629fae49393a05397450978507c4ef1\"," \ "opaque=\"sadfljk32sdaf\"", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest abc=zyx, username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, " \ "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\"", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest abc=zyx,,,,,,,username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, " \ "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\"", "32141232413abcde", MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest abc=zyx,,,,,,,username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, " "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\",,,,,", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest abc=zyx,,,,,,,username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, " \ "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\",foo=bar", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest abc=\"zyx\", username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, " "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\",foo=bar", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest abc=\"zyx, abc\", " \ "username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, " "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\",foo=bar", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest abc=\"zyx, abc=cde\", " \ "username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, " \ "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\",foo=bar", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest abc=\"zyx, abc=cde\", " \ "username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, " \ "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\", foo=\"bar1, bar2\"", \ "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest abc=\"zyx, \\\\\"abc=cde\\\\\"\", " \ "username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\", foo=\"bar1, bar2\"", \ "32141232413abcde", MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); r += expect_digest ("Digest abc=\"zyx, \\\\\"abc=cde\\\\\"\", " \ "username=\"test@example.com\", " \ "realm=\"users@example.com\", algorithm=SHA-256, " \ "nonce=\"32141232413abcde\", " \ "username*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates, " \ "uri=\"/example\", qop=auth, nc=00000001, " "cnonce=\"0a4f113b\", " \ "response=\"6629fae49393a05397450978507c4ef1\", " \ "opaque=\"sadfljk32sdaf\", foo=\",nc=02\"", "32141232413abcde", \ MHD_DIGEST_AUTH_ALGO3_SHA256, \ "6629fae49393a05397450978507c4ef1", "test@example.com", \ "UTF-8''%c2%a3%20and%20%e2%82%ac%20rates", \ "users@example.com", "/example", \ "auth", MHD_DIGEST_AUTH_QOP_AUTH, "0a4f113b", \ "00000001", 0); return r; } #endif /* DAUTH_SUPPORT */ #define TEST_AUTH_STR "dXNlcjpwYXNz" static unsigned int check_two_auths (void) { unsigned int ret; static struct MHD_HTTP_Req_Header h1; static struct MHD_HTTP_Req_Header h2; static struct MHD_HTTP_Req_Header h3; #ifdef BAUTH_SUPPORT const struct MHD_RqBAuth *bauth; #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT const struct MHD_RqDAuth *dauth; #endif /* DAUTH_SUPPORT */ if ((NULL != conn.rq.headers_received) || (NULL != conn.rq.headers_received_tail)) externalErrorExitDesc ("Connection's test headers are not empty already"); /* Init and use both Basic and Digest Auth headers */ memset (&h1, 0, sizeof(h1)); memset (&h2, 0, sizeof(h2)); memset (&h3, 0, sizeof(h3)); h1.kind = MHD_HEADER_KIND; h1.header = MHD_HTTP_HEADER_HOST; /* Just some random header */ h1.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_HOST); h1.value = "localhost"; h1.value_size = strlen (h1.value); h2.kind = MHD_HEADER_KIND; h2.header = MHD_HTTP_HEADER_AUTHORIZATION; h2.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_AUTHORIZATION); h2.value = "Basic " TEST_AUTH_STR; h2.value_size = strlen (h2.value); h3.kind = MHD_HEADER_KIND; h3.header = MHD_HTTP_HEADER_AUTHORIZATION; h3.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_AUTHORIZATION); h3.value = "Digest cnonce=" TEST_AUTH_STR; h3.value_size = strlen (h3.value); conn.rq.headers_received = &h1; h1.next = &h2; h2.prev = &h1; h2.next = &h3; h3.prev = &h2; conn.rq.headers_received_tail = &h3; conn.state = MHD_CONNECTION_FULL_REQ_RECEIVED; /* Should be a typical value */ ret = 0; #ifdef BAUTH_SUPPORT bauth = get_BAuthRqParams (); #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT dauth = get_DAuthRqParams (); #endif /* DAUTH_SUPPORT */ #ifdef BAUTH_SUPPORT if (NULL == bauth) { fprintf (stderr, "No Basic Authorization header detected. Line: %u\n", (unsigned int) __LINE__); ret++; } else if ((MHD_STATICSTR_LEN_ (TEST_AUTH_STR) != bauth->token68.len) || (0 != memcmp (bauth->token68.str, TEST_AUTH_STR, bauth->token68.len))) { fprintf (stderr, "Basic Authorization token does not match. Line: %u\n", (unsigned int) __LINE__); ret++; } #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT if (NULL == dauth) { fprintf (stderr, "No Digest Authorization header detected. Line: %u\n", (unsigned int) __LINE__); ret++; } else if ((MHD_STATICSTR_LEN_ (TEST_AUTH_STR) != dauth->cnonce.value.len) || (0 != memcmp (dauth->cnonce.value.str, TEST_AUTH_STR, dauth->cnonce.value.len))) { fprintf (stderr, "Digest Authorization 'cnonce' does not match. Line: %u\n", (unsigned int) __LINE__); ret++; } #endif /* DAUTH_SUPPORT */ /* Cleanup */ conn.rq.headers_received = NULL; conn.rq.headers_received_tail = NULL; conn.state = MHD_CONNECTION_INIT; return ret; } int main (int argc, char *argv[]) { unsigned int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ test_global_init (); errcount += check_type (); #ifdef BAUTH_SUPPORT errcount += check_basic (); #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT errcount += check_digest (); #endif /* DAUTH_SUPPORT */ errcount += check_two_auths (); if (0 == errcount) printf ("All tests were passed without errors.\n"); return errcount == 0 ? 0 : 1; } libmicrohttpd-1.0.1/src/microhttpd/internal.c0000644000175000017500000001761114556705750015006 /* This file is part of libmicrohttpd Copyright (C) 2007 Daniel Pittman and Christian Grothoff Copyright (C) 2015-2023 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/internal.c * @brief internal shared structures * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "internal.h" #include "mhd_str.h" #ifdef HAVE_MESSAGES #if DEBUG_STATES /** * State to string dictionary. */ const char * MHD_state_to_string (enum MHD_CONNECTION_STATE state) { switch (state) { case MHD_CONNECTION_INIT: return "connection init"; case MHD_CONNECTION_REQ_LINE_RECEIVING: return "receiving request line"; case MHD_CONNECTION_REQ_LINE_RECEIVED: return "request line received"; case MHD_CONNECTION_REQ_HEADERS_RECEIVING: return "headers receiving"; case MHD_CONNECTION_HEADERS_RECEIVED: return "headers received"; case MHD_CONNECTION_HEADERS_PROCESSED: return "headers processed"; case MHD_CONNECTION_CONTINUE_SENDING: return "continue sending"; case MHD_CONNECTION_BODY_RECEIVING: return "body receiving"; case MHD_CONNECTION_BODY_RECEIVED: return "body received"; case MHD_CONNECTION_FOOTERS_RECEIVING: return "footers receiving"; case MHD_CONNECTION_FOOTERS_RECEIVED: return "footers received"; case MHD_CONNECTION_FULL_REQ_RECEIVED: return "full request received"; case MHD_CONNECTION_START_REPLY: return "start sending reply"; case MHD_CONNECTION_HEADERS_SENDING: return "headers sending"; case MHD_CONNECTION_HEADERS_SENT: return "headers sent"; case MHD_CONNECTION_NORMAL_BODY_UNREADY: return "normal body unready"; case MHD_CONNECTION_NORMAL_BODY_READY: return "normal body ready"; case MHD_CONNECTION_CHUNKED_BODY_UNREADY: return "chunked body unready"; case MHD_CONNECTION_CHUNKED_BODY_READY: return "chunked body ready"; case MHD_CONNECTION_CHUNKED_BODY_SENT: return "chunked body sent"; case MHD_CONNECTION_FOOTERS_SENDING: return "footers sending"; case MHD_CONNECTION_FULL_REPLY_SENT: return "reply sent completely"; case MHD_CONNECTION_CLOSED: return "closed"; default: return "unrecognized connection state"; } } #endif #endif #ifdef HAVE_MESSAGES /** * fprintf-like helper function for logging debug * messages. */ void MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...) { va_list va; if (0 == (daemon->options & MHD_USE_ERROR_LOG)) return; va_start (va, format); daemon->custom_error_log (daemon->custom_error_log_cls, format, va); va_end (va); } #endif /** * Convert all occurrences of '+' to ' '. * * @param arg string that is modified (in place), must be 0-terminated */ void MHD_unescape_plus (char *arg) { char *p; for (p = strchr (arg, '+'); NULL != p; p = strchr (p + 1, '+')) *p = ' '; } /** * Process escape sequences ('%HH') Updates val in place; the * result cannot be larger than the input. * The result is still be 0-terminated. * * @param val value to unescape (modified in the process) * @return length of the resulting val (`strlen(val)` may be * shorter afterwards due to elimination of escape sequences) */ _MHD_EXTERN size_t MHD_http_unescape (char *val) { return MHD_str_pct_decode_in_place_lenient_ (val, NULL); } /** * Parse and unescape the arguments given by the client * as part of the HTTP request URI. * * @param kind header kind to pass to @a cb * @param connection connection to add headers to * @param[in,out] args argument URI string (after "?" in URI), * clobbered in the process! * @param cb function to call on each key-value pair found * @param cls the iterator context * @return #MHD_NO on failure (@a cb returned #MHD_NO), * #MHD_YES for success (parsing succeeded, @a cb always * returned #MHD_YES) */ enum MHD_Result MHD_parse_arguments_ (struct MHD_Connection *connection, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, void *cls) { struct MHD_Daemon *daemon = connection->daemon; char *equals; char *amper; while ( (NULL != args) && ('\0' != args[0]) ) { size_t key_len; size_t value_len; equals = strchr (args, '='); amper = strchr (args, '&'); if (NULL == amper) { /* last argument */ if (NULL == equals) { /* last argument, without '=' */ MHD_unescape_plus (args); key_len = daemon->unescape_callback (daemon->unescape_callback_cls, connection, args); if (MHD_NO == cb (cls, args, key_len, NULL, 0, kind)) return MHD_NO; break; } /* got 'foo=bar' */ equals[0] = '\0'; equals++; MHD_unescape_plus (args); key_len = daemon->unescape_callback (daemon->unescape_callback_cls, connection, args); MHD_unescape_plus (equals); value_len = daemon->unescape_callback (daemon->unescape_callback_cls, connection, equals); if (MHD_NO == cb (cls, args, key_len, equals, value_len, kind)) return MHD_NO; break; } /* amper is non-NULL here */ amper[0] = '\0'; amper++; if ( (NULL == equals) || (equals >= amper) ) { /* got 'foo&bar' or 'foo&bar=val', add key 'foo' with NULL for value */ MHD_unescape_plus (args); key_len = daemon->unescape_callback (daemon->unescape_callback_cls, connection, args); if (MHD_NO == cb (cls, args, key_len, NULL, 0, kind)) return MHD_NO; /* continue with 'bar' */ args = amper; continue; } /* equals and amper are non-NULL here, and equals < amper, so we got regular 'foo=value&bar...'-kind of argument */ equals[0] = '\0'; equals++; MHD_unescape_plus (args); key_len = daemon->unescape_callback (daemon->unescape_callback_cls, connection, args); MHD_unescape_plus (equals); value_len = daemon->unescape_callback (daemon->unescape_callback_cls, connection, equals); if (MHD_NO == cb (cls, args, key_len, equals, value_len, kind)) return MHD_NO; args = amper; } return MHD_YES; } /* end of internal.c */ libmicrohttpd-1.0.1/src/microhttpd/basicauth.c0000644000175000017500000002424414556705750015135 /* This file is part of libmicrohttpd Copyright (C) 2010, 2011, 2012 Daniel Pittman and Christian Grothoff Copyright (C) 2014-2023 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file basicauth.c * @brief Implements HTTP basic authentication methods * @author Amr Ali * @author Matthieu Speder * @author Karlson2k (Evgeny Grin) */ #include "basicauth.h" #include "gen_auth.h" #include "platform.h" #include "mhd_limits.h" #include "internal.h" #include "mhd_compat.h" #include "mhd_str.h" /** * Get the username and password from the Basic Authorisation header * sent by the client * * @param connection the MHD connection structure * @return NULL if no valid Basic Authentication header is present in * current request, or * pointer to structure with username and password, which must be * freed by #MHD_free(). * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN struct MHD_BasicAuthInfo * MHD_basic_auth_get_username_password3 (struct MHD_Connection *connection) { const struct MHD_RqBAuth *params; size_t decoded_max_len; struct MHD_BasicAuthInfo *ret; params = MHD_get_rq_bauth_params_ (connection); if (NULL == params) return NULL; if ((NULL == params->token68.str) || (0 == params->token68.len)) return NULL; decoded_max_len = MHD_base64_max_dec_size_ (params->token68.len); ret = (struct MHD_BasicAuthInfo *) malloc (sizeof(struct MHD_BasicAuthInfo) + decoded_max_len + 1); if (NULL != ret) { size_t decoded_len; char *decoded; decoded = (char *) (ret + 1); decoded_len = MHD_base64_to_bin_n (params->token68.str, params->token68.len, decoded, decoded_max_len); mhd_assert (decoded_max_len >= decoded_len); if (0 != decoded_len) { size_t username_len; char *colon; colon = memchr (decoded, ':', decoded_len); if (NULL != colon) { size_t password_pos; size_t password_len; username_len = (size_t) (colon - decoded); password_pos = username_len + 1; password_len = decoded_len - password_pos; ret->password = decoded + password_pos; ret->password[password_len] = 0; /* Zero-terminate the string */ ret->password_len = password_len; } else { username_len = decoded_len; ret->password = NULL; ret->password_len = 0; } ret->username = decoded; ret->username[username_len] = 0; /* Zero-terminate the string */ ret->username_len = username_len; return ret; /* Success exit point */ } #ifdef HAVE_MESSAGES else MHD_DLOG (connection->daemon, _ ("Error decoding Basic Authorization authentication.\n")); #endif /* HAVE_MESSAGES */ free (ret); } #ifdef HAVE_MESSAGES else { MHD_DLOG (connection->daemon, _ ("Failed to allocate memory to process " \ "Basic Authorization authentication.\n")); } #endif /* HAVE_MESSAGES */ return NULL; /* Failure exit point */ } /** * Get the username and password from the basic authorization header sent by the client * * @param connection The MHD connection structure * @param[out] password a pointer for the password, free using #MHD_free(). * @return NULL if no username could be found, a pointer * to the username if found, free using #MHD_free(). * @deprecated use #MHD_basic_auth_get_username_password3() * @ingroup authentication */ _MHD_EXTERN char * MHD_basic_auth_get_username_password (struct MHD_Connection *connection, char **password) { struct MHD_BasicAuthInfo *info; info = MHD_basic_auth_get_username_password3 (connection); if (NULL == info) return NULL; /* For backward compatibility this function must return NULL if * no password is provided */ if (NULL != info->password) { char *username; username = malloc (info->username_len + 1); if (NULL != username) { memcpy (username, info->username, info->username_len + 1); mhd_assert (0 == username[info->username_len]); if (NULL != password) { *password = malloc (info->password_len + 1); if (NULL != *password) { memcpy (*password, info->password, info->password_len + 1); mhd_assert (0 == (*password)[info->password_len]); free (info); return username; /* Success exit point */ } #ifdef HAVE_MESSAGES else MHD_DLOG (connection->daemon, _ ("Failed to allocate memory.\n")); #endif /* HAVE_MESSAGES */ } else { free (info); return username; /* Success exit point */ } free (username); } #ifdef HAVE_MESSAGES else MHD_DLOG (connection->daemon, _ ("Failed to allocate memory.\n")); #endif /* HAVE_MESSAGES */ } free (info); if (NULL != password) *password = NULL; return NULL; /* Failure exit point */ } /** * Queues a response to request basic authentication from the client. * * The given response object is expected to include the payload for * the response; the "WWW-Authenticate" header will be added and the * response queued with the 'UNAUTHORIZED' status code. * * See RFC 7617#section-2 for details. * * The @a response is modified by this function. The modified response object * can be used to respond subsequent requests by #MHD_queue_response() * function with status code #MHD_HTTP_UNAUTHORIZED and must not be used again * with MHD_queue_basic_auth_required_response3() function. The response could * be destroyed right after call of this function. * * @param connection the MHD connection structure * @param realm the realm presented to the client * @param prefer_utf8 if not set to #MHD_NO, parameter'charset="UTF-8"' will * be added, indicating for client that UTF-8 encoding * is preferred * @param response the response object to modify and queue; the NULL * is tolerated * @return #MHD_YES on success, #MHD_NO otherwise * @note Available since #MHD_VERSION 0x00097704 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_queue_basic_auth_required_response3 (struct MHD_Connection *connection, const char *realm, int prefer_utf8, struct MHD_Response *response) { static const char prefix[] = "Basic realm=\""; static const char suff_charset[] = "\", charset=\"UTF-8\""; static const size_t prefix_len = MHD_STATICSTR_LEN_ (prefix); static const size_t suff_simple_len = MHD_STATICSTR_LEN_ ("\""); static const size_t suff_charset_len = MHD_STATICSTR_LEN_ (suff_charset); enum MHD_Result ret; char *h_str; size_t h_maxlen; size_t suffix_len; size_t realm_len; size_t realm_quoted_len; size_t pos; if (NULL == response) return MHD_NO; suffix_len = (0 == prefer_utf8) ? suff_simple_len : suff_charset_len; realm_len = strlen (realm); h_maxlen = prefix_len + realm_len * 2 + suffix_len; h_str = (char *) malloc (h_maxlen + 1); if (NULL == h_str) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, "Failed to allocate memory for Basic Authentication header.\n"); #endif /* HAVE_MESSAGES */ return MHD_NO; } memcpy (h_str, prefix, prefix_len); pos = prefix_len; realm_quoted_len = MHD_str_quote (realm, realm_len, h_str + pos, h_maxlen - prefix_len - suffix_len); pos += realm_quoted_len; mhd_assert (pos + suffix_len <= h_maxlen); if (0 == prefer_utf8) { h_str[pos++] = '\"'; h_str[pos++] = 0; /* Zero terminate the result */ mhd_assert (pos <= h_maxlen + 1); } else { /* Copy with the final zero-termination */ mhd_assert (pos + suff_charset_len <= h_maxlen); memcpy (h_str + pos, suff_charset, suff_charset_len + 1); mhd_assert (0 == h_str[pos + suff_charset_len]); } ret = MHD_add_response_header (response, MHD_HTTP_HEADER_WWW_AUTHENTICATE, h_str); free (h_str); if (MHD_NO != ret) { ret = MHD_queue_response (connection, MHD_HTTP_UNAUTHORIZED, response); } else { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Failed to add Basic Authentication header.\n")); #endif /* HAVE_MESSAGES */ } return ret; } /** * Queues a response to request basic authentication from the client * The given response object is expected to include the payload for * the response; the "WWW-Authenticate" header will be added and the * response queued with the 'UNAUTHORIZED' status code. * * @param connection The MHD connection structure * @param realm the realm presented to the client * @param response response object to modify and queue; the NULL is tolerated * @return #MHD_YES on success, #MHD_NO otherwise * @deprecated use MHD_queue_basic_auth_required_response3() * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, const char *realm, struct MHD_Response *response) { return MHD_queue_basic_auth_required_response3 (connection, realm, MHD_NO, response); } /* end of basicauth.c */ libmicrohttpd-1.0.1/src/microhttpd/test_str_token_remove.c0000644000175000017500000002755714504515253017616 /* This file is part of libmicrohttpd Copyright (C) 2017-2021 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_str_token.c * @brief Unit tests for MHD_str_remove_token_caseless_() function * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include "mhd_str.h" #include "mhd_assert.h" static int expect_result_n (const char *str, size_t str_len, const char *token, size_t token_len, const char *expected, size_t expected_len, const bool expected_removed) { char buf_in[1024]; char buf_token[256]; char buf_out[1024]; size_t buf_len; mhd_assert (sizeof(buf_in) > str_len + 2); mhd_assert (sizeof(buf_token) > token_len + 2); mhd_assert (sizeof(buf_out) > expected_len + 2); memset (buf_in, '#', sizeof(buf_in)); memset (buf_token, '#', sizeof(buf_token)); memcpy (buf_in, str, str_len); /* Copy without zero-termination */ memcpy (buf_token, token, token_len); /* Copy without zero-termination */ for (buf_len = 0; buf_len <= expected_len + 3; ++buf_len) { bool res; ssize_t result_len; memset (buf_out, '$', sizeof(buf_out)); result_len = (ssize_t) buf_len; mhd_assert (0 <= result_len); res = MHD_str_remove_token_caseless_ (buf_in, str_len, buf_token, token_len, buf_out, &result_len); if (buf_len < expected_len) { /* The result should not fit into the buffer */ if (res || (0 <= result_len)) { fprintf (stderr, "MHD_str_remove_token_caseless_() FAILED:\n" "\tMHD_str_remove_token_caseless_(\"%.*s\", %lu," " \"%.*s\", %lu, buf, &(%ld->%ld)) returned %s\n", (int) str_len + 2, buf_in, (unsigned long) str_len, (int) token_len + 2, buf_token, (unsigned long) token_len, (long) buf_len, (long) result_len, res ? "true" : "false"); return 1; } } else { /* The result should fit into the buffer */ if ( (expected_removed != res) || (result_len < 0) || (expected_len != (size_t) result_len) || ((0 != result_len) && (0 != memcmp (expected, buf_out, (size_t) result_len))) || ('$' != buf_out[result_len])) { fprintf (stderr, "MHD_str_remove_token_caseless_() FAILED:\n" "\tMHD_str_remove_token_caseless_(\"%.*s\", %lu," " \"%.*s\", %lu, \"%.*s\", &(%ld->%ld)) returned %s\n", (int) str_len + 2, buf_in, (unsigned long) str_len, (int) token_len + 2, buf_token, (unsigned long) token_len, (int) expected_len + 2, buf_out, (long) buf_len, (long) result_len, res ? "true" : "false"); return 1; } } } return 0; } #define expect_result(s,t,e,found) \ expect_result_n ((s),MHD_STATICSTR_LEN_ (s), \ (t),MHD_STATICSTR_LEN_ (t), \ (e),MHD_STATICSTR_LEN_ (e), found) static int check_result (void) { int errcount = 0; errcount += expect_result ("string", "string", "", true); errcount += expect_result ("String", "string", "", true); errcount += expect_result ("string", "String", "", true); errcount += expect_result ("strinG", "String", "", true); errcount += expect_result ("\t strinG", "String", "", true); errcount += expect_result ("strinG\t ", "String", "", true); errcount += expect_result (" \t tOkEn ", "toKEN", "", true); errcount += expect_result ("not token\t, tOkEn ", "toKEN", "not token", true); errcount += expect_result ("not token,\t tOkEn, more token", "toKEN", "not token, more token", true); errcount += expect_result ("not token,\t tOkEn\t, more token", "toKEN", "not token, more token", true); errcount += expect_result (",,,,,,test,,,,", "TESt", "", true); errcount += expect_result (",,,,,\t,test,,,,", "TESt", "", true); errcount += expect_result (",,,,,,test, ,,,", "TESt", "", true); errcount += expect_result (",,,,,, test,,,,", "TESt", "", true); errcount += expect_result (",,,,,, test not,test,,", "TESt", "test not", true); errcount += expect_result (",,,,,, test not,,test,,", "TESt", "test not", true); errcount += expect_result (",,,,,, test not ,test,,", "TESt", "test not", true); errcount += expect_result (",,,,,, test", "TESt", "", true); errcount += expect_result (",,,,,, test ", "TESt", "", true); errcount += expect_result ("no test,,,,,, test ", "TESt", "no test", true); errcount += expect_result ("the-token,, the-token , the-token" \ ",the-token ,the-token", "the-token", "", true); errcount += expect_result (" the-token,, the-token , the-token," \ "the-token ,the-token ", "the-token", "", true); errcount += expect_result (" the-token ,, the-token , the-token," \ "the-token , the-token ", "the-token", "", true); errcount += expect_result ("the-token,a, the-token , the-token,b," \ "the-token , c,the-token", "the-token", "a, b, c", true); errcount += expect_result (" the-token, a, the-token , the-token, b," \ "the-token ,c ,the-token ", "the-token", "a, b, c", true); errcount += expect_result (" the-token , a , the-token , the-token, b ," \ "the-token , c , the-token ", "the-token", "a, b, c",true); errcount += expect_result ("the-token,aa, the-token , the-token,bb," \ "the-token , cc,the-token", "the-token", "aa, bb, cc", true); errcount += expect_result (" the-token, aa, the-token , the-token, bb," \ "the-token ,cc ,the-token ", "the-token", "aa, bb, cc", true); errcount += expect_result (" the-token , aa , the-token , the-token, bb ," \ "the-token , cc , the-token ", "the-token", "aa, bb, cc", true); errcount += expect_result ("strin", "string", "strin", false); errcount += expect_result ("Stringer", "string", "Stringer", false); errcount += expect_result ("sstring", "String", "sstring", false); errcount += expect_result ("string", "Strin", "string", false); errcount += expect_result ("\t( strinG", "String", "( strinG", false); errcount += expect_result (")strinG\t ", "String", ")strinG", false); errcount += expect_result (" \t tOkEn t ", "toKEN", "tOkEn t", false); errcount += expect_result ("not token\t, tOkEner ", "toKEN", "not token, tOkEner", false); errcount += expect_result ("not token,\t tOkEns, more token", "toKEN", "not token, tOkEns, more token", false); errcount += expect_result ("not token,\t tOkEns\t, more token", "toKEN", "not token, tOkEns, more token", false); errcount += expect_result (",,,,,,testing,,,,", "TESt", "testing", false); errcount += expect_result (",,,,,\t,test,,,,", "TESting", "test", false); errcount += expect_result ("tests,,,,,,quest, ,,,", "TESt", "tests, quest", false); errcount += expect_result (",,,,,, testÑ‹,,,,", "TESt", "testÑ‹", false); errcount += expect_result (",,,,,, test not,Ñ…test,,", "TESt", "test not, Ñ…test", false); errcount += expect_result ("testing,,,,,, test not,,test2,,", "TESt", "testing, test not, test2", false); errcount += expect_result (",testi,,,,, test not ,test,,", "TESting", "testi, test not, test", false); errcount += expect_result (",,,,,,2 test", "TESt", "2 test", false); errcount += expect_result (",,,,,,test test ", "test", "test test", false); errcount += expect_result ("no test,,,,,,test test", "test", "no test, test test", false); errcount += expect_result (",,,,,,,,,,,,,,,,,,,", "the-token", "", false); errcount += expect_result (",a,b,c,d,e,f,g,,,,,,,,,,,,", "the-token", "a, b, c, d, e, f, g", false); errcount += expect_result (",,,,,,,,,,,,,,,,,,,", "", "", false); errcount += expect_result (",a,b,c,d,e,f,g,,,,,,,,,,,,", "", "a, b, c, d, e, f, g", false); errcount += expect_result ("a,b,c,d,e,f,g", "", "a, b, c, d, e, f, g", false); errcount += expect_result ("a1,b1,c1,d1,e1,f1,g1", "", "a1, b1, c1, d1, e1, f1, g1", false); errcount += expect_result (",a,b,c,d,e,f,g,,,,,,,,,,,,the-token", "the-token", "a, b, c, d, e, f, g", true); errcount += expect_result (",a,b,c,d,e,f,g,,,,,,,,,,,,the-token,", "the-token", "a, b, c, d, e, f, g", true); errcount += expect_result (",a,b,c,d,e,f,g,,,,,,,,,,,,the-token,x", "the-token", "a, b, c, d, e, f, g, x", true); errcount += expect_result (",a,b,c,d,e,f,g,,,,,,,,,,,,the-token x", "the-token", "a, b, c, d, e, f, g, the-token x", false); errcount += expect_result (",a,b,c,d,e,f,g,,,,,,,,,,,,the-token x,", "the-token", "a, b, c, d, e, f, g, the-token x", false); errcount += expect_result (",a,b,c,d,e,f,g,,,,,,,,,,,,the-token x,x", "the-token", "a, b, c, d, e, f, g," \ " the-token x, x", false); errcount += expect_result ("the-token,a,b,c,d,e,f,g,,,,,,,,,,,,the-token", "the-token", "a, b, c, d, e, f, g", true); errcount += expect_result ("the-token ,a,b,c,d,e,f,g,,,,,,,,,,,,the-token,", "the-token", "a, b, c, d, e, f, g", true); errcount += expect_result ("the-token,a,b,c,d,e,f,g,,,,,,,,,,,,the-token,x", "the-token", "a, b, c, d, e, f, g, x", true); errcount += expect_result ("the-token x,a,b,c,d,e,f,g,,,,,,,,,,,," \ "the-token x", "the-token", "the-token x, a, b, c, d, e, f, g, the-token x", false); errcount += expect_result ("the-token x,a,b,c,d,e,f,g,,,,,,,,,,,," \ "the-token x,", "the-token", "the-token x, a, b, c, d, e, f, g, the-token x", false); errcount += expect_result ("the-token x,a,b,c,d,e,f,g,,,,,,,,,,,," \ "the-token x,x", "the-token", "the-token x, a, b, c, d, e, f, g, " \ "the-token x, x", false); return errcount; } int main (int argc, char *argv[]) { int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errcount += check_result (); return errcount == 0 ? 0 : 1; } libmicrohttpd-1.0.1/src/microhttpd/test_client_put_stop.c0000644000175000017500000020757314556705750017454 /* This file is part of libmicrohttpd Copyright (C) 2021-2024 Evgeny Grin (Karlson2k) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_client_put_stop.c * @brief Testcase for handling of clients aborts * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #ifdef HAVE_STRINGS_H #include #endif /* HAVE_STRINGS_H */ #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #ifndef WINDOWS #include #include #endif #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ #ifdef HAVE_SIGNAL_H #include #endif /* HAVE_SIGNAL_H */ #ifdef HAVE_SYSCTL #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ #ifdef HAVE_NETINET_ICMP_VAR_H #include #endif /* HAVE_NETINET_ICMP_VAR_H */ #endif /* HAVE_SYSCTL */ #include #include "mhd_sockets.h" /* only macros used */ #include "test_helpers.h" #include "mhd_assert.h" #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #if MHD_CPU_COUNT > 32 #undef MHD_CPU_COUNT /* Limit to reasonable value */ #define MHD_CPU_COUNT 32 #endif /* MHD_CPU_COUNT > 32 */ #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #ifndef _MHD_INSTRMACRO /* Quoted macro parameter */ #define _MHD_INSTRMACRO(a) #a #endif /* ! _MHD_INSTRMACRO */ #ifndef _MHD_STRMACRO /* Quoted expanded macro parameter */ #define _MHD_STRMACRO(a) _MHD_INSTRMACRO (a) #endif /* ! _MHD_STRMACRO */ /* Could be increased to facilitate debugging */ #define TIMEOUTS_VAL 5 /* Time in ms to wait for final packets to be delivered */ #define FINAL_PACKETS_MS 20 #define EXPECTED_URI_BASE_PATH "/a" #define REQ_HOST "localhost" #define REQ_METHOD "PUT" #define REQ_BODY "Some content data." #define REQ_LINE_END "\r\n" /* Mandatory request headers */ #define REQ_HEADER_HOST_NAME "Host" #define REQ_HEADER_HOST_VALUE REQ_HOST #define REQ_HEADER_HOST \ REQ_HEADER_HOST_NAME ": " REQ_HEADER_HOST_VALUE REQ_LINE_END #define REQ_HEADER_UA_NAME "User-Agent" #define REQ_HEADER_UA_VALUE "dummyclient/0.9" #define REQ_HEADER_UA REQ_HEADER_UA_NAME ": " REQ_HEADER_UA_VALUE REQ_LINE_END /* Optional request headers */ #define REQ_HEADER_CT_NAME "Content-Type" #define REQ_HEADER_CT_VALUE "text/plain" #define REQ_HEADER_CT REQ_HEADER_CT_NAME ": " REQ_HEADER_CT_VALUE REQ_LINE_END #if defined(HAVE___FUNC__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __func__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __func__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __func__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __func__, __LINE__) #elif defined(HAVE___FUNCTION__) #define externalErrorExit(ignore) \ _externalErrorExit_func(NULL, __FUNCTION__, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, __FUNCTION__, __LINE__) #define mhdErrorExit(ignore) \ _mhdErrorExit_func(NULL, __FUNCTION__, __LINE__) #define mhdErrorExitDesc(errDesc) \ _mhdErrorExit_func(errDesc, __FUNCTION__, __LINE__) #else #define externalErrorExit(ignore) _externalErrorExit_func(NULL, NULL, __LINE__) #define externalErrorExitDesc(errDesc) \ _externalErrorExit_func(errDesc, NULL, __LINE__) #define mhdErrorExit(ignore) _mhdErrorExit_func(NULL, NULL, __LINE__) #define mhdErrorExitDesc(errDesc) _mhdErrorExit_func(errDesc, NULL, __LINE__) #endif _MHD_NORETURN static void _externalErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "System or external library call failed"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); #ifdef MHD_WINSOCK_SOCKETS fprintf (stderr, "WSAGetLastError() value: %d\n", (int) WSAGetLastError ()); #endif /* MHD_WINSOCK_SOCKETS */ fflush (stderr); exit (99); } _MHD_NORETURN static void _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum) { if ((NULL != errDesc) && (0 != errDesc[0])) fprintf (stderr, "%s", errDesc); else fprintf (stderr, "MHD unexpected error"); if ((NULL != funcName) && (0 != funcName[0])) fprintf (stderr, " in %s", funcName); if (0 < lineNum) fprintf (stderr, " at line %d", lineNum); fprintf (stderr, ".\nLast errno value: %d (%s)\n", (int) errno, strerror (errno)); fflush (stderr); exit (8); } /* Global generic functions */ void _MHD_sleep (uint32_t ms); /** * Pause execution for specified number of milliseconds. * @param ms the number of milliseconds to sleep */ void _MHD_sleep (uint32_t ms) { #if defined(_WIN32) Sleep (ms); #elif defined(HAVE_NANOSLEEP) struct timespec slp = {ms / 1000, (ms % 1000) * 1000000}; struct timespec rmn; int num_retries = 0; while (0 != nanosleep (&slp, &rmn)) { if (EINTR != errno) externalErrorExit (); if (num_retries++ > 8) break; slp = rmn; } #elif defined(HAVE_USLEEP) uint64_t us = ms * 1000; do { uint64_t this_sleep; if (999999 < us) this_sleep = 999999; else this_sleep = us; /* Ignore return value as it could be void */ usleep (this_sleep); us -= this_sleep; } while (us > 0); #else externalErrorExitDesc ("No sleep function available on this system"); #endif } /* Global parameters */ static int verbose; /**< Be verbose */ static int oneone; /**< If false use HTTP/1.0 for requests*/ static uint16_t global_port; /**< MHD daemons listen port number */ static int use_shutdown; /**< Use shutdown at client side */ static int use_close; /**< Use socket close at client side */ static int use_hard_close; /**< Use socket close with RST at client side */ static int use_stress_os; /**< Stress OS by RST before getting ACKs for sent packets */ static int by_step; /**< Send request byte-by-byte */ static int upl_chunked; /**< Use chunked encoding for request body */ static unsigned int rate_limiter; /**< Maximum number of checks per second */ static void test_global_init (void) { rate_limiter = 0; if (use_hard_close) { #ifdef HAVE_SYSCTLBYNAME if (1) { int blck_hl; size_t blck_hl_size = sizeof (blck_hl); if (0 == sysctlbyname ("net.inet.tcp.blackhole", &blck_hl, &blck_hl_size, NULL, 0)) { if (2 <= blck_hl) { fprintf (stderr, "'sysctl net.inet.tcp.blackhole = %d', test is " "unreliable with this system setting, skipping.\n", blck_hl); exit (77); } } else { if (ENOENT != errno) externalErrorExitDesc ("Cannot get 'net.inet.tcp.blackhole' value"); } } #endif #if defined(HAVE_SYSCTL) && defined(HAVE_DECL_CTL_NET) && \ defined(HAVE_DECL_PF_INET) && defined(HAVE_DECL_IPPROTO_ICMP) && \ defined(HAVE_DECL_ICMPCTL_ICMPLIM) /* Macros may have zero values */ #if HAVE_DECL_CTL_NET && HAVE_DECL_PF_INET && HAVE_DECL_IPPROTO_ICMP && \ HAVE_DECL_ICMPCTL_ICMPLIM if (1) { int mib[4]; int limit; size_t limit_size = sizeof(limit); mib[0] = CTL_NET; mib[1] = PF_INET; mib[2] = IPPROTO_ICMP; mib[3] = ICMPCTL_ICMPLIM; if (0 != sysctl (mib, 4, &limit, &limit_size, NULL, 0)) { if (ENOENT == errno) limit = 0; /* No such parameter (new Darwin versions) */ else externalErrorExitDesc ("Cannot get RST rate limit value"); } else if (sizeof(limit) != limit_size) externalErrorExitDesc ("Cannot get RST rate limit value"); if (limit > 0) { #ifndef _MHD_HEAVY_TESTS fprintf (stderr, "This system has limits on number of RST packets" " per second (%d).\nThis test will be used only if configured " "with '--enable-heavy-test'.\n", limit); exit (77); #else /* _MHD_HEAVY_TESTS */ int test_limit; /**< Maximum number of checks per second */ if (use_stress_os) { fprintf (stderr, "This system has limits on number of RST packet" " per second (%d).\n'_stress_os' is not possible.\n", limit); exit (77); } test_limit = limit - limit / 10; /* Add some space to not hit the limiter */ test_limit /= 4; /* Assume that all four tests with 'hard_close' run in parallel */ test_limit -= 5; /* Add some more space to not hit the limiter */ test_limit /= 3; /* Use only one third of available limit */ if (test_limit <= 0) { fprintf (stderr, "System limit for 'net.inet.icmp.icmplim' is " "too strict for this test (value: %d).\n", limit); exit (77); } if (verbose) { printf ("Limiting number of checks to %d checks/second.\n", test_limit); fflush (stdout); } rate_limiter = (unsigned int) test_limit; #if ! defined(HAVE_USLEEP) && ! defined(HAVE_NANOSLEEP) && ! defined(_WIN32) fprintf (stderr, "Sleep function is required for this test, " "but not available on this system.\n"); exit (77); #endif #endif /* _MHD_HEAVY_TESTS */ } } #endif /* HAVE_DECL_CTL_NET && HAVE_DECL_PF_INET && HAVE_DECL_IPPROTO_ICMP && \ HAVE_DECL_ICMPCTL_ICMPLIM */ #endif /* HAVE_SYSCTL && HAVE_DECL_CTL_NET && HAVE_DECL_PF_INET && HAVE_DECL_IPPROTO_ICMP && HAVE_DECL_ICMPCTL_ICMPLIM */ } if (MHD_YES != MHD_is_feature_supported (MHD_FEATURE_AUTOSUPPRESS_SIGPIPE)) { #if defined(HAVE_SIGNAL_H) && defined(SIGPIPE) if (SIG_ERR == signal (SIGPIPE, SIG_IGN)) externalErrorExitDesc ("Error suppressing SIGPIPE signal"); #else /* ! HAVE_SIGNAL_H || ! SIGPIPE */ fprintf (stderr, "Cannot suppress SIGPIPE signal.\n"); /* exit (77); */ #endif } } static void test_global_cleanup (void) { } /** * Change socket to blocking. * * @param fd the socket to manipulate */ static void make_blocking (MHD_socket fd) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (fd, F_GETFL); if (-1 == flags) externalErrorExitDesc ("Cannot make socket non-blocking"); if ((flags & ~O_NONBLOCK) != flags) { if (-1 == fcntl (fd, F_SETFL, flags & ~O_NONBLOCK)) externalErrorExitDesc ("Cannot make socket non-blocking"); } #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 0; if (0 != ioctlsocket (fd, (int) FIONBIO, &flags)) externalErrorExitDesc ("Cannot make socket non-blocking"); #endif /* MHD_WINSOCK_SOCKETS */ } /** * Change socket to non-blocking. * * @param fd the socket to manipulate */ static void make_nonblocking (MHD_socket fd) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (fd, F_GETFL); if (-1 == flags) externalErrorExitDesc ("Cannot make socket non-blocking"); if ((flags | O_NONBLOCK) != flags) { if (-1 == fcntl (fd, F_SETFL, flags | O_NONBLOCK)) externalErrorExitDesc ("Cannot make socket non-blocking"); } #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 1; if (0 != ioctlsocket (fd, (int) FIONBIO, &flags)) externalErrorExitDesc ("Cannot make socket non-blocking"); #endif /* MHD_WINSOCK_SOCKETS */ } /* DumbClient API */ struct _MHD_dumbClient * _MHD_dumbClient_create (uint16_t port, const char *method, const char *url, const char *add_headers, const uint8_t *req_body, size_t req_body_size, int chunked); void _MHD_dumbClient_set_send_limits (struct _MHD_dumbClient *clnt, size_t step_size, size_t max_total_send); void _MHD_dumbClient_start_connect (struct _MHD_dumbClient *clnt); int _MHD_dumbClient_is_req_sent (struct _MHD_dumbClient *clnt); /** * Process the client data with send()/recv() as needed. * @param clnt the client to process * @return non-zero if client finished processing the request, * zero otherwise. */ int _MHD_dumbClient_process (struct _MHD_dumbClient *clnt); void _MHD_dumbClient_get_fdsets (struct _MHD_dumbClient *clnt, MHD_socket *maxsckt, fd_set *rs, fd_set *ws, fd_set *es); /** * Process the client data with send()/recv() as needed based on * information in fd_sets. * @param clnt the client to process * @return non-zero if client finished processing the request, * zero otherwise. */ int _MHD_dumbClient_process_from_fdsets (struct _MHD_dumbClient *clnt, fd_set *rs, fd_set *ws, fd_set *es); /** * Perform full request. * @param clnt the client to run * @return zero if client finished processing the request, * non-zero if timeout is reached. */ int _MHD_dumbClient_perform (struct _MHD_dumbClient *clnt); /** * Close the client and free internally allocated resources. * @param clnt the client to close */ void _MHD_dumbClient_close (struct _MHD_dumbClient *clnt); /* DumbClient implementation */ enum _MHD_clientStage { DUMB_CLIENT_INIT = 0, DUMB_CLIENT_CONNECTING, DUMB_CLIENT_CONNECTED, DUMB_CLIENT_REQ_SENDING, DUMB_CLIENT_REQ_SENT, DUMB_CLIENT_HEADER_RECVEIVING, DUMB_CLIENT_HEADER_RECVEIVED, DUMB_CLIENT_BODY_RECVEIVING, DUMB_CLIENT_BODY_RECVEIVED, DUMB_CLIENT_FINISHING, DUMB_CLIENT_FINISHED }; struct _MHD_dumbClient { MHD_socket sckt; /**< the socket to communicate */ int sckt_nonblock; /**< non-zero if socket is non-blocking */ uint16_t port; /**< the port to connect to */ const char *send_buf; /**< the buffer for the request, malloced */ void *buf; /**< the buffer location */ size_t req_size; /**< the size of the request, including header */ size_t send_off; /**< the number of bytes already sent */ enum _MHD_clientStage stage; /* the test-specific variables */ size_t single_send_size; /**< the maximum number of bytes to be sent by single send() */ size_t send_size_limit; /**< the total number of send bytes limit */ }; struct _MHD_dumbClient * _MHD_dumbClient_create (uint16_t port, const char *method, const char *url, const char *add_headers, const uint8_t *req_body, size_t req_body_size, int chunked) { struct _MHD_dumbClient *clnt; size_t method_size; size_t url_size; size_t add_hdrs_size; size_t buf_alloc_size; char *send_buf; mhd_assert (0 != port); mhd_assert (NULL != req_body || 0 == req_body_size); mhd_assert (0 == req_body_size || NULL != req_body); clnt = (struct _MHD_dumbClient *) malloc (sizeof(struct _MHD_dumbClient)); if (NULL == clnt) externalErrorExit (); memset (clnt, 0, sizeof(struct _MHD_dumbClient)); clnt->sckt = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); if (MHD_INVALID_SOCKET == clnt->sckt) externalErrorExitDesc ("Cannot create the client socket"); #ifdef MHD_socket_nosignal_ if (! MHD_socket_nosignal_ (clnt->sckt)) externalErrorExitDesc ("Cannot suppress SIGPIPE on the client socket"); #endif /* MHD_socket_nosignal_ */ clnt->sckt_nonblock = 0; if (clnt->sckt_nonblock) make_nonblocking (clnt->sckt); else make_blocking (clnt->sckt); if (1) { /* Always set TCP NODELAY */ const MHD_SCKT_OPT_BOOL_ on_val = 1; if (0 != setsockopt (clnt->sckt, IPPROTO_TCP, TCP_NODELAY, (const void *) &on_val, sizeof (on_val))) externalErrorExitDesc ("Cannot set TCP_NODELAY option"); } clnt->port = port; if (NULL != method) method_size = strlen (method); else { method = MHD_HTTP_METHOD_GET; method_size = MHD_STATICSTR_LEN_ (MHD_HTTP_METHOD_GET); } mhd_assert (0 != method_size); if (NULL != url) url_size = strlen (url); else { url = "/"; url_size = 1; } mhd_assert (0 != url_size); add_hdrs_size = (NULL == add_headers) ? 0 : strlen (add_headers); buf_alloc_size = 1024 + method_size + url_size + add_hdrs_size + req_body_size; send_buf = (char *) malloc (buf_alloc_size); if (NULL == send_buf) externalErrorExit (); clnt->req_size = 0; /* Form the request line */ memcpy (send_buf + clnt->req_size, method, method_size); clnt->req_size += method_size; send_buf[clnt->req_size++] = ' '; memcpy (send_buf + clnt->req_size, url, url_size); clnt->req_size += url_size; send_buf[clnt->req_size++] = ' '; memcpy (send_buf + clnt->req_size, MHD_HTTP_VERSION_1_1, MHD_STATICSTR_LEN_ (MHD_HTTP_VERSION_1_1)); clnt->req_size += MHD_STATICSTR_LEN_ (MHD_HTTP_VERSION_1_1); send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; /* Form the header */ memcpy (send_buf + clnt->req_size, REQ_HEADER_HOST, MHD_STATICSTR_LEN_ (REQ_HEADER_HOST)); clnt->req_size += MHD_STATICSTR_LEN_ (REQ_HEADER_HOST); memcpy (send_buf + clnt->req_size, REQ_HEADER_UA, MHD_STATICSTR_LEN_ (REQ_HEADER_UA)); clnt->req_size += MHD_STATICSTR_LEN_ (REQ_HEADER_UA); if ((NULL != req_body) || chunked) { if (! chunked) { int prn_size; memcpy (send_buf + clnt->req_size, MHD_HTTP_HEADER_CONTENT_LENGTH ": ", MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": ")); clnt->req_size += MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH ": "); prn_size = snprintf (send_buf + clnt->req_size, (buf_alloc_size - clnt->req_size), "%u", (unsigned int) req_body_size); if (0 >= prn_size) externalErrorExit (); if ((unsigned int) prn_size >= buf_alloc_size - clnt->req_size) externalErrorExit (); clnt->req_size += (unsigned int) prn_size; send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; } else { memcpy (send_buf + clnt->req_size, MHD_HTTP_HEADER_TRANSFER_ENCODING ": chunked\r\n", MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_TRANSFER_ENCODING \ ": chunked\r\n")); clnt->req_size += MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_TRANSFER_ENCODING \ ": chunked\r\n"); } } if (0 != add_hdrs_size) { memcpy (send_buf + clnt->req_size, add_headers, add_hdrs_size); clnt->req_size += add_hdrs_size; } /* Terminate header */ send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; /* Add body (if any) */ if (! chunked) { if (0 != req_body_size) { memcpy (send_buf + clnt->req_size, req_body, req_body_size); clnt->req_size += req_body_size; } } else { if (0 != req_body_size) { int prn_size; prn_size = snprintf (send_buf + clnt->req_size, (buf_alloc_size - clnt->req_size), "%x", (unsigned int) req_body_size); if (0 >= prn_size) externalErrorExit (); if ((unsigned int) prn_size >= buf_alloc_size - clnt->req_size) externalErrorExit (); clnt->req_size += (unsigned int) prn_size; send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; memcpy (send_buf + clnt->req_size, req_body, req_body_size); clnt->req_size += req_body_size; send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; } send_buf[clnt->req_size++] = '0'; send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; send_buf[clnt->req_size++] = '\r'; send_buf[clnt->req_size++] = '\n'; } mhd_assert (clnt->req_size < buf_alloc_size); clnt->buf = send_buf; clnt->send_buf = send_buf; return clnt; } void _MHD_dumbClient_set_send_limits (struct _MHD_dumbClient *clnt, size_t step_size, size_t max_total_send) { clnt->single_send_size = step_size; clnt->send_size_limit = max_total_send; } /* internal */ static void _MHD_dumbClient_connect_init (struct _MHD_dumbClient *clnt) { struct sockaddr_in sa; mhd_assert (DUMB_CLIENT_INIT == clnt->stage); sa.sin_family = AF_INET; sa.sin_port = htons ((uint16_t) clnt->port); sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); if (0 != connect (clnt->sckt, (struct sockaddr *) &sa, sizeof(sa))) { const int err = MHD_socket_get_error_ (); if ( (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINPROGRESS_)) || (MHD_SCKT_ERR_IS_EAGAIN_ (err))) clnt->stage = DUMB_CLIENT_CONNECTING; else externalErrorExitDesc ("Cannot 'connect()' the client socket"); } else clnt->stage = DUMB_CLIENT_CONNECTED; } void _MHD_dumbClient_start_connect (struct _MHD_dumbClient *clnt) { mhd_assert (DUMB_CLIENT_INIT == clnt->stage); _MHD_dumbClient_connect_init (clnt); } /* internal */ static void _MHD_dumbClient_connect_finish (struct _MHD_dumbClient *clnt) { int err = 0; socklen_t err_size = sizeof(err); mhd_assert (DUMB_CLIENT_CONNECTING == clnt->stage); if (0 != getsockopt (clnt->sckt, SOL_SOCKET, SO_ERROR, (void *) &err, &err_size)) externalErrorExitDesc ("'getsockopt()' call failed"); if (0 != err) externalErrorExitDesc ("Socket connect() failed"); clnt->stage = DUMB_CLIENT_CONNECTED; } /* internal */ static void _MHD_dumbClient_send_req (struct _MHD_dumbClient *clnt) { size_t send_size; ssize_t res; mhd_assert (DUMB_CLIENT_CONNECTED <= clnt->stage); mhd_assert (DUMB_CLIENT_REQ_SENT > clnt->stage); mhd_assert (clnt->req_size > clnt->send_off); send_size = (((0 != clnt->send_size_limit) && (clnt->req_size > clnt->send_size_limit)) ? clnt->send_size_limit : clnt->req_size) - clnt->send_off; mhd_assert (0 != send_size); if ((0 != clnt->single_send_size) && (clnt->single_send_size < send_size)) send_size = clnt->single_send_size; res = MHD_send_ (clnt->sckt, clnt->send_buf + clnt->send_off, send_size); if (res < 0) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) return; if (MHD_SCKT_ERR_IS_EINTR_ (err)) return; if (MHD_SCKT_ERR_IS_REMOTE_DISCNN_ (err)) mhdErrorExitDesc ("The connection was aborted by MHD"); if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EPIPE_)) mhdErrorExitDesc ("The connection was shut down on MHD side"); externalErrorExitDesc ("Unexpected network error"); } clnt->send_off += (size_t) res; mhd_assert (clnt->send_off <= clnt->req_size); mhd_assert (clnt->send_off <= clnt->send_size_limit || \ 0 == clnt->send_size_limit); if (clnt->req_size == clnt->send_off) clnt->stage = DUMB_CLIENT_REQ_SENT; if ((0 != clnt->send_size_limit) && (clnt->send_size_limit == clnt->send_off)) clnt->stage = DUMB_CLIENT_FINISHING; } /* internal */ _MHD_NORETURN /* Declared as 'noreturn' until it is implemented */ static void _MHD_dumbClient_recv_reply (struct _MHD_dumbClient *clnt) { (void) clnt; externalErrorExitDesc ("Not implemented for this test"); } int _MHD_dumbClient_is_req_sent (struct _MHD_dumbClient *clnt) { return DUMB_CLIENT_REQ_SENT <= clnt->stage; } /* internal */ static void _MHD_dumbClient_socket_close (struct _MHD_dumbClient *clnt) { if (MHD_INVALID_SOCKET != clnt->sckt) { if (use_hard_close) { #ifdef SO_LINGER static const struct linger hard_close = {1, 0}; mhd_assert (0 == hard_close.l_linger); if (0 != setsockopt (clnt->sckt, SOL_SOCKET, SO_LINGER, (const void *) &hard_close, sizeof (hard_close))) #endif /* SO_LINGER */ externalErrorExitDesc ("Failed to set SO_LINGER option"); } if (! MHD_socket_close_ (clnt->sckt)) externalErrorExitDesc ("Unexpected error while closing " \ "the client socket"); clnt->sckt = MHD_INVALID_SOCKET; } } /* internal */ static void _MHD_dumbClient_finalize (struct _MHD_dumbClient *clnt) { if (MHD_INVALID_SOCKET != clnt->sckt) { if (use_shutdown) { if (0 != shutdown (clnt->sckt, SHUT_WR)) { const int err = MHD_socket_get_error_ (); if (! MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ENOTCONN_) && ! MHD_SCKT_ERR_IS_REMOTE_DISCNN_ (err)) mhdErrorExitDesc ("Unexpected error when shutting down " \ "the client socket"); } } else if (use_close) { _MHD_dumbClient_socket_close (clnt); } else mhd_assert (0); } clnt->stage = DUMB_CLIENT_FINISHED; } /* internal */ static int _MHD_dumbClient_needs_send (const struct _MHD_dumbClient *clnt) { return ((DUMB_CLIENT_CONNECTING <= clnt->stage) && (DUMB_CLIENT_REQ_SENT > clnt->stage)) || (DUMB_CLIENT_FINISHING == clnt->stage); } /* internal */ static int _MHD_dumbClient_needs_recv (const struct _MHD_dumbClient *clnt) { return (DUMB_CLIENT_HEADER_RECVEIVING <= clnt->stage) && (DUMB_CLIENT_BODY_RECVEIVED > clnt->stage); } /* internal */ /** * Check whether the client needs unconditionally process the data. * @param clnt the client to check * @return non-zero if client needs unconditionally process the data, * zero otherwise. */ static int _MHD_dumbClient_needs_process (const struct _MHD_dumbClient *clnt) { switch (clnt->stage) { case DUMB_CLIENT_INIT: case DUMB_CLIENT_REQ_SENT: case DUMB_CLIENT_HEADER_RECVEIVED: case DUMB_CLIENT_BODY_RECVEIVED: case DUMB_CLIENT_FINISHED: return ! 0; case DUMB_CLIENT_CONNECTING: case DUMB_CLIENT_CONNECTED: case DUMB_CLIENT_REQ_SENDING: case DUMB_CLIENT_HEADER_RECVEIVING: case DUMB_CLIENT_BODY_RECVEIVING: case DUMB_CLIENT_FINISHING: default: break; } return 0; } /** * Process the client data with send()/recv() as needed. * @param clnt the client to process * @return non-zero if client finished processing the request, * zero otherwise. */ int _MHD_dumbClient_process (struct _MHD_dumbClient *clnt) { do { switch (clnt->stage) { case DUMB_CLIENT_INIT: _MHD_dumbClient_connect_init (clnt); break; case DUMB_CLIENT_CONNECTING: _MHD_dumbClient_connect_finish (clnt); break; case DUMB_CLIENT_CONNECTED: case DUMB_CLIENT_REQ_SENDING: _MHD_dumbClient_send_req (clnt); break; case DUMB_CLIENT_REQ_SENT: mhd_assert (0); clnt->stage = DUMB_CLIENT_HEADER_RECVEIVING; break; case DUMB_CLIENT_HEADER_RECVEIVING: _MHD_dumbClient_recv_reply (clnt); break; case DUMB_CLIENT_HEADER_RECVEIVED: clnt->stage = DUMB_CLIENT_BODY_RECVEIVING; break; case DUMB_CLIENT_BODY_RECVEIVING: _MHD_dumbClient_recv_reply (clnt); break; case DUMB_CLIENT_BODY_RECVEIVED: clnt->stage = DUMB_CLIENT_FINISHING; break; case DUMB_CLIENT_FINISHING: _MHD_dumbClient_finalize (clnt); break; case DUMB_CLIENT_FINISHED: return ! 0; default: mhd_assert (0); mhdErrorExit (); } } while (_MHD_dumbClient_needs_process (clnt)); return DUMB_CLIENT_FINISHED == clnt->stage; } void _MHD_dumbClient_get_fdsets (struct _MHD_dumbClient *clnt, MHD_socket *maxsckt, fd_set *rs, fd_set *ws, fd_set *es) { mhd_assert (NULL != rs); mhd_assert (NULL != ws); mhd_assert (NULL != es); if (DUMB_CLIENT_FINISHED > clnt->stage) { if (MHD_INVALID_SOCKET != clnt->sckt) { if ( (MHD_INVALID_SOCKET == *maxsckt) || (clnt->sckt > *maxsckt) ) *maxsckt = clnt->sckt; if (_MHD_dumbClient_needs_recv (clnt)) FD_SET (clnt->sckt, rs); if (_MHD_dumbClient_needs_send (clnt)) FD_SET (clnt->sckt, ws); FD_SET (clnt->sckt, es); } } } /** * Process the client data with send()/recv() as needed based on * information in fd_sets. * @param clnt the client to process * @return non-zero if client finished processing the request, * zero otherwise. */ int _MHD_dumbClient_process_from_fdsets (struct _MHD_dumbClient *clnt, fd_set *rs, fd_set *ws, fd_set *es) { if (_MHD_dumbClient_needs_process (clnt)) return _MHD_dumbClient_process (clnt); else if (MHD_INVALID_SOCKET != clnt->sckt) { if (_MHD_dumbClient_needs_recv (clnt) && FD_ISSET (clnt->sckt, rs)) return _MHD_dumbClient_process (clnt); else if (_MHD_dumbClient_needs_send (clnt) && FD_ISSET (clnt->sckt, ws)) return _MHD_dumbClient_process (clnt); else if (FD_ISSET (clnt->sckt, es)) return _MHD_dumbClient_process (clnt); } return DUMB_CLIENT_FINISHED == clnt->stage; } /** * Perform full request. * @param clnt the client to run * @return zero if client finished processing the request, * non-zero if timeout is reached. */ int _MHD_dumbClient_perform (struct _MHD_dumbClient *clnt) { time_t start; time_t now; start = time (NULL); now = start; do { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; struct timeval tv; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (! _MHD_dumbClient_needs_process (clnt)) { maxMhdSk = MHD_INVALID_SOCKET; _MHD_dumbClient_get_fdsets (clnt, &maxMhdSk, &rs, &ws, &es); mhd_assert (now >= start); #if ! defined(_WIN32) || defined(__CYGWIN__) tv.tv_sec = (time_t) (TIMEOUTS_VAL * 2 - (now - start) + 1); #else /* Native W32 */ tv.tv_sec = (long) (TIMEOUTS_VAL * 2 - (now - start) + 1); #endif /* Native W32 */ tv.tv_usec = 250 * 1000; if (-1 == select ((int) maxMhdSk + 1, &rs, &ws, &es, &tv)) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else /* ! MHD_POSIX_SOCKETS */ mhd_assert ((0 != rs.fd_count) || (0 != ws.fd_count) || \ (0 != es.fd_count)); externalErrorExitDesc ("Unexpected select() error"); Sleep ((DWORD) (tv.tv_sec * 1000 + tv.tv_usec / 1000)); #endif /* ! MHD_POSIX_SOCKETS */ continue; } if (_MHD_dumbClient_process_from_fdsets (clnt, &rs, &ws, &es)) return 0; } /* Use double timeout value here as MHD must catch timeout situations * in this test. Timeout in client as a last resort. */ } while ((now = time (NULL)) - start <= (TIMEOUTS_VAL * 2)); return 1; } /** * Close the client and free internally allocated resources. * @param clnt the client to close */ void _MHD_dumbClient_close (struct _MHD_dumbClient *clnt) { if (DUMB_CLIENT_FINISHED != clnt->stage) _MHD_dumbClient_finalize (clnt); _MHD_dumbClient_socket_close (clnt); if (NULL != clnt->send_buf) { mhd_assert (clnt->send_buf == clnt->buf); free (clnt->buf); clnt->buf = NULL; clnt->send_buf = NULL; } free (clnt); } struct sckt_notif_cb_param { volatile unsigned int num_started; volatile unsigned int num_finished; }; static void socket_cb (void *cls, struct MHD_Connection *c, void **socket_context, enum MHD_ConnectionNotificationCode toe) { struct sckt_notif_cb_param *param = (struct sckt_notif_cb_param *) cls; if (NULL == socket_context) mhdErrorExitDesc ("'socket_context' pointer is NULL"); if (NULL == c) mhdErrorExitDesc ("'connection' pointer is NULL"); if (NULL == param) mhdErrorExitDesc ("'cls' pointer is NULL"); if (MHD_CONNECTION_NOTIFY_STARTED == toe) param->num_started++; else if (MHD_CONNECTION_NOTIFY_CLOSED == toe) param->num_finished++; else mhdErrorExitDesc ("Unknown 'toe' value"); } struct term_notif_cb_param { volatile int term_reason; volatile unsigned int num_called; }; static void term_cb (void *cls, struct MHD_Connection *c, void **req_cls, enum MHD_RequestTerminationCode term_code) { struct term_notif_cb_param *param = (struct term_notif_cb_param *) cls; if (NULL == req_cls) mhdErrorExitDesc ("'req_cls' pointer is NULL"); if (NULL == c) mhdErrorExitDesc ("'connection' pointer is NULL"); if (NULL == param) mhdErrorExitDesc ("'cls' pointer is NULL"); param->term_reason = (int) term_code; param->num_called++; } static const char * term_reason_str (enum MHD_RequestTerminationCode term_code) { switch ((int) term_code) { case MHD_REQUEST_TERMINATED_COMPLETED_OK: return "COMPLETED_OK"; case MHD_REQUEST_TERMINATED_WITH_ERROR: return "TERMINATED_WITH_ERROR"; case MHD_REQUEST_TERMINATED_TIMEOUT_REACHED: return "TIMEOUT_REACHED"; case MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN: return "DAEMON_SHUTDOWN"; case MHD_REQUEST_TERMINATED_READ_ERROR: return "READ_ERROR"; case MHD_REQUEST_TERMINATED_CLIENT_ABORT: return "CLIENT_ABORT"; case -1: return "(not called)"; default: break; } return "(unknown code)"; } struct check_uri_cls { const char *volatile uri; volatile unsigned int cb_called; }; static void * check_uri_cb (void *cls, const char *uri, struct MHD_Connection *con) { struct check_uri_cls *param = (struct check_uri_cls *) cls; if (NULL == con) mhdErrorExitDesc ("The 'con' pointer is NULL"); param->cb_called++; if (0 != strcmp (param->uri, uri)) { fprintf (stderr, "Wrong URI: '%s'\n", uri); mhdErrorExit (); } return NULL; } struct mhd_header_checker_param { int found_header_host; /**< the number of 'Host' headers */ int found_header_ua; /**< the number of 'User-Agent' headers */ int found_header_ct; /**< the number of 'Content-Type' headers */ int found_header_cl; /**< the number of 'Content-Length' headers */ int found_header_te; /**< the number of 'Transfer-Encoding' headers */ }; static enum MHD_Result headerCheckerInterator (void *cls, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size) { struct mhd_header_checker_param *const param = (struct mhd_header_checker_param *) cls; if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); if (MHD_HEADER_KIND != kind) return MHD_YES; /* Continue iteration */ if (0 == key_size) mhdErrorExitDesc ("Zero key length"); if ((strlen (REQ_HEADER_HOST_NAME) == key_size) && (0 == memcmp (key, REQ_HEADER_HOST_NAME, key_size))) { if ((strlen (REQ_HEADER_HOST_VALUE) == value_size) && (0 == memcmp (value, REQ_HEADER_HOST_VALUE, value_size))) param->found_header_host++; else fprintf (stderr, "Unexpected header value: '%.*s', expected: '%s'\n", (int) value_size, value, REQ_HEADER_HOST_VALUE); } else if ((strlen (REQ_HEADER_UA_NAME) == key_size) && (0 == memcmp (key, REQ_HEADER_UA_NAME, key_size))) { if ((strlen (REQ_HEADER_UA_VALUE) == value_size) && (0 == memcmp (value, REQ_HEADER_UA_VALUE, value_size))) param->found_header_ua++; else fprintf (stderr, "Unexpected header value: '%.*s', expected: '%s'\n", (int) value_size, value, REQ_HEADER_UA_VALUE); } else if ((strlen (REQ_HEADER_CT_NAME) == key_size) && (0 == memcmp (key, REQ_HEADER_CT_NAME, key_size))) { if ((strlen (REQ_HEADER_CT_VALUE) == value_size) && (0 == memcmp (value, REQ_HEADER_CT_VALUE, value_size))) param->found_header_ct++; else fprintf (stderr, "Unexpected header value: '%.*s', expected: '%s'\n", (int) value_size, value, REQ_HEADER_CT_VALUE); } else if ((strlen (MHD_HTTP_HEADER_CONTENT_LENGTH) == key_size) && (0 == memcmp (key, MHD_HTTP_HEADER_CONTENT_LENGTH, key_size))) { /* do not check value of the header here for simplicity */ param->found_header_cl++; } else if ((strlen (MHD_HTTP_HEADER_TRANSFER_ENCODING) == key_size) && (0 == memcmp (key, MHD_HTTP_HEADER_TRANSFER_ENCODING, key_size))) { if ((strlen ("chunked") == value_size) && (0 == memcmp (value, "chunked", value_size))) param->found_header_te++; else fprintf (stderr, "Unexpected header value: '%.*s', expected: '%s'\n", (int) value_size, value, "chunked"); } return MHD_YES; } struct ahc_cls_type { const char *volatile rp_data; volatile size_t rp_data_size; const char *volatile rq_method; const char *volatile rq_url; const char *volatile req_body; volatile unsigned int cb_called; /* Non-zero indicates that callback was called at least one time */ size_t req_body_size; /**< The number of bytes in @a req_body */ size_t req_body_uploaded; /* Updated by callback */ }; static enum MHD_Result ahcCheck (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker; enum MHD_Result ret; struct mhd_header_checker_param header_check_param; struct ahc_cls_type *const param = (struct ahc_cls_type *) cls; if (NULL == param) mhdErrorExitDesc ("cls parameter is NULL"); param->cb_called++; if (0 != strcmp (version, MHD_HTTP_VERSION_1_1)) mhdErrorExitDesc ("Unexpected HTTP version"); if (0 != strcmp (url, param->rq_url)) mhdErrorExitDesc ("Unexpected URI"); if (0 != strcmp (param->rq_method, method)) mhdErrorExitDesc ("Unexpected request method"); if (NULL == upload_data_size) mhdErrorExitDesc ("'upload_data_size' pointer is NULL"); if (0 != *upload_data_size) { const char *const upload_body = param->req_body; if (NULL == upload_data) mhdErrorExitDesc ("'upload_data' is NULL while " \ "'*upload_data_size' value is not zero"); if (NULL == upload_body) mhdErrorExitDesc ("'*upload_data_size' value is not zero " \ "while no request body is expected"); if (param->req_body_uploaded + *upload_data_size > param->req_body_size) { fprintf (stderr, "Too large upload body received. Got %u, expected %u", (unsigned int) (param->req_body_uploaded + *upload_data_size), (unsigned int) param->req_body_size); mhdErrorExit (); } if (0 != memcmp (upload_data, upload_body + param->req_body_uploaded, *upload_data_size)) { fprintf (stderr, "Unexpected request body at offset %u: " \ "'%.*s', expected: '%.*s'\n", (unsigned int) param->req_body_uploaded, (int) *upload_data_size, upload_data, (int) *upload_data_size, upload_body + param->req_body_uploaded); mhdErrorExit (); } param->req_body_uploaded += *upload_data_size; *upload_data_size = 0; } if (&marker != *req_cls) { /* The first call of the callback for this connection */ mhd_assert (NULL == upload_data); param->req_body_uploaded = 0; *req_cls = ▮ return MHD_YES; } memset (&header_check_param, 0, sizeof(header_check_param)); if (1 > MHD_get_connection_values_n (connection, MHD_HEADER_KIND, &headerCheckerInterator, &header_check_param)) mhdErrorExitDesc ("Wrong number of headers in the request"); if (1 != header_check_param.found_header_host) mhdErrorExitDesc ("'Host' header has not been detected in request"); if (1 != header_check_param.found_header_ua) mhdErrorExitDesc ("'User-Agent' header has not been detected in request"); if (1 != header_check_param.found_header_ct) mhdErrorExitDesc ("'Content-Type' header has not been detected in request"); if (! upl_chunked && (1 != header_check_param.found_header_cl)) mhdErrorExitDesc ("'Content-Length' header has not been detected " "in request"); if (upl_chunked && (1 != header_check_param.found_header_te)) mhdErrorExitDesc ("'Transfer-Encoding' header has not been detected " "in request"); if (NULL != upload_data) return MHD_YES; /* Full request has not been received so far */ #if 0 /* Code unused in this test */ struct MHD_Response *response; response = MHD_create_response_from_buffer (param->rp_data_size, (void *) param->rp_data, MHD_RESPMEM_MUST_COPY); if (NULL == response) mhdErrorExitDesc ("Failed to create response"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (MHD_YES != ret) mhdErrorExitDesc ("Failed to queue response"); #else if (NULL == upload_data) mhdErrorExitDesc ("Full request received, " \ "while incomplete request expected"); ret = MHD_NO; #endif return ret; } struct simpleQueryParams { /* Destination path for HTTP query */ const char *queryPath; /* Custom query method, NULL for default */ const char *method; /* Destination port for HTTP query */ uint16_t queryPort; /* Additional request headers, static */ const char *headers; /* NULL for request without body */ const uint8_t *req_body; size_t req_body_size; /* Non-zero to use chunked encoding for request body */ int chunked; /* Max size of data for single 'send()' call */ size_t step_size; /* Limit for total amount of sent data */ size_t total_send_max; /* HTTP query result error flag */ volatile int queryError; /* Response HTTP code, zero if no response */ volatile int responseCode; }; /* returns non-zero if timed-out */ static int performQueryExternal (struct MHD_Daemon *d, struct _MHD_dumbClient *clnt) { time_t start; struct timeval tv; int ret; const union MHD_DaemonInfo *di; MHD_socket lstn_sk; int client_accepted; int full_req_recieved; int full_req_sent; int some_data_recieved; di = MHD_get_daemon_info (d, MHD_DAEMON_INFO_LISTEN_FD); if (NULL == di) mhdErrorExitDesc ("Cannot get lister socket"); lstn_sk = di->listen_fd; ret = 1; /* will be replaced with real result */ client_accepted = 0; _MHD_dumbClient_start_connect (clnt); full_req_recieved = 0; some_data_recieved = 0; start = time (NULL); do { fd_set rs; fd_set ws; fd_set es; MHD_socket maxMhdSk; int num_ready; int do_client; /**< Process data in client */ maxMhdSk = MHD_INVALID_SOCKET; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (NULL == clnt) { /* client has finished, check whether MHD is still * processing any connections */ full_req_sent = 1; do_client = 0; if (client_accepted && (0 > MHD_get_timeout64s (d))) { ret = 0; break; /* MHD finished as well */ } } else { full_req_sent = _MHD_dumbClient_is_req_sent (clnt); if (! full_req_sent) do_client = 1; /* Request hasn't been sent yet, send the data */ else { /* All request data has been sent. * Client will close the socket as the next step. */ if (full_req_recieved) { /* All data has been received by the MHD */ do_client = 1; /* Close the client socket */ } else if (some_data_recieved && (! use_hard_close || ((0 == rate_limiter) && use_stress_os))) { /* No RST rate limiter or no "hard close", no need to avoid extra RST * and at least something was received by the MHD */ /* In case of 'hard close' this can stress the OS, especially * if 'by_step' is enabled as several ACKs (for delivered packets * containing the request) from the server may arrive to the client * when the client has closed port and may be reflected by several * RSTs from the client side to the server side (when ACK received * without active connection then RST packet should be sent). * When listening socket receives RST packets, it may block * the sender preventing the next connection. */ do_client = 1; /* Proceed with the closure of the client socket */ } else { /* When rate limiter is enabled, all sent packets must be received * before client closes connection to avoid RST for every ACK. * When rate limiter is not enabled, the MHD must receive at * least something before closing the connection. */ do_client = 0; /* Do not close the client socket yet */ } } if (do_client) _MHD_dumbClient_get_fdsets (clnt, &maxMhdSk, &rs, &ws, &es); } if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) mhdErrorExitDesc ("MHD_get_fdset() failed"); if (do_client) { tv.tv_sec = 1; tv.tv_usec = 250 * 1000; } else { /* Request completely sent but not yet fully received */ tv.tv_sec = 0; tv.tv_usec = FINAL_PACKETS_MS * 1000; } num_ready = select ((int) maxMhdSk + 1, &rs, &ws, &es, &tv); if (-1 == num_ready) { #ifdef MHD_POSIX_SOCKETS if (EINTR != errno) externalErrorExitDesc ("Unexpected select() error"); #else if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != ws.fd_count) || (0 != es.fd_count) ) externalErrorExitDesc ("Unexpected select() error"); Sleep ((DWORD) (tv.tv_sec * 1000 + tv.tv_usec / 1000)); #endif continue; } if (0 == num_ready) { /* select() finished by timeout, looks like no more packets are pending */ if (do_client) externalErrorExitDesc ("Timeout waiting for sockets"); if (full_req_sent && (! full_req_recieved)) full_req_recieved = 1; } if (MHD_YES != MHD_run_from_select (d, &rs, &ws, &es)) mhdErrorExitDesc ("MHD_run_from_select() failed"); if (! client_accepted) client_accepted = FD_ISSET (lstn_sk, &rs); else { /* Client connection was already accepted by MHD */ if (! some_data_recieved) { if (! do_client) { if (0 != num_ready) { /* Connection was accepted before, "ready" socket means data */ some_data_recieved = 1; } } else { if (2 == num_ready) some_data_recieved = 1; else if ((1 == num_ready) && ((MHD_INVALID_SOCKET == clnt->sckt) || ! FD_ISSET (clnt->sckt, &ws))) some_data_recieved = 1; } } } if (do_client) { if (_MHD_dumbClient_process_from_fdsets (clnt, &rs, &ws, &es)) clnt = NULL; } /* Use double timeout value here so MHD would be able to catch timeout * internally */ } while (time (NULL) - start <= (TIMEOUTS_VAL * 2)); return ret; } /* Returns zero for successful response and non-zero for failed response */ static int doClientQueryInThread (struct MHD_Daemon *d, struct simpleQueryParams *p) { const union MHD_DaemonInfo *dinfo; struct _MHD_dumbClient *c; int errornum; int use_external_poll; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_FLAGS); if (NULL == dinfo) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); use_external_poll = (0 == (dinfo->flags & MHD_USE_INTERNAL_POLLING_THREAD)); if (0 == p->queryPort) externalErrorExit (); c = _MHD_dumbClient_create (p->queryPort, p->method, p->queryPath, p->headers, p->req_body, p->req_body_size, p->chunked); _MHD_dumbClient_set_send_limits (c, p->step_size, p->total_send_max); /* 'internal' polling should not be used in this test */ mhd_assert (use_external_poll); if (! use_external_poll) errornum = _MHD_dumbClient_perform (c); else errornum = performQueryExternal (d, c); if (errornum) fprintf (stderr, "Request timeout out.\n"); _MHD_dumbClient_close (c); return errornum; } static void printTestResults (FILE *stream, struct simpleQueryParams *qParam, struct ahc_cls_type *ahc_param, struct check_uri_cls *uri_cb_param, struct term_notif_cb_param *term_result, struct sckt_notif_cb_param *sckt_result) { if (stderr != stream) fflush (stderr); fprintf (stream, " Request aborted at %u byte%s.", (unsigned int) qParam->total_send_max, 1 == qParam->total_send_max ? "" : "s"); if ((1 == sckt_result->num_started) && (1 == sckt_result->num_finished)) fprintf (stream, " One socket has been accepted and then closed."); else fprintf (stream, " Sockets have been accepted %u time%s" " and closed %u time%s.", sckt_result->num_started, (1 == sckt_result->num_started) ? "" : "s", sckt_result->num_finished, (1 == sckt_result->num_finished) ? "" : "s"); if (0 == uri_cb_param->cb_called) fprintf (stream, " URI callback has NOT been called."); else fprintf (stream, " URI callback has been called %u time%s.", uri_cb_param->cb_called, 1 == uri_cb_param->cb_called ? "" : "s"); if (0 == ahc_param->cb_called) fprintf (stream, " Access handler callback has NOT been called."); else fprintf (stream, " Access handler callback has been called %u time%s.", ahc_param->cb_called, 1 == ahc_param->cb_called ? "" : "s"); if (0 == term_result->num_called) fprintf (stream, " Final notification callback has NOT been called."); else fprintf (stream, " Final notification callback has been called %u time%s " "with %s code.", term_result->num_called, (1 == term_result->num_called) ? "" : "s", term_reason_str ((enum MHD_RequestTerminationCode) term_result->term_reason)); fprintf (stream, "\n"); fflush (stream); } /* Perform test queries, shut down MHD daemon, and free parameters */ static unsigned int performTestQueries (struct MHD_Daemon *d, uint16_t d_port, struct ahc_cls_type *ahc_param, struct check_uri_cls *uri_cb_param, struct term_notif_cb_param *term_result, struct sckt_notif_cb_param *sckt_result) { struct simpleQueryParams qParam; time_t start; unsigned int ret = 0; /* Return value */ size_t req_total_size; size_t limit_send_size; size_t inc_size; int expected_reason; int found_right_reason; /* Common parameters, to be individually overridden by specific test cases * if needed */ qParam.queryPort = d_port; qParam.method = MHD_HTTP_METHOD_PUT; qParam.queryPath = EXPECTED_URI_BASE_PATH; qParam.headers = REQ_HEADER_CT; qParam.req_body = (const uint8_t *) REQ_BODY; qParam.req_body_size = MHD_STATICSTR_LEN_ (REQ_BODY); qParam.chunked = upl_chunked; qParam.step_size = by_step ? 1 : 0; uri_cb_param->uri = EXPECTED_URI_BASE_PATH; ahc_param->rq_url = EXPECTED_URI_BASE_PATH; ahc_param->rq_method = MHD_HTTP_METHOD_PUT; ahc_param->rp_data = "~"; ahc_param->rp_data_size = 1; ahc_param->req_body = (const char *) qParam.req_body; ahc_param->req_body_size = qParam.req_body_size; do { struct _MHD_dumbClient *test_c; struct simpleQueryParams *p = &qParam; test_c = _MHD_dumbClient_create (p->queryPort, p->method, p->queryPath, p->headers, p->req_body, p->req_body_size, p->chunked); req_total_size = test_c->req_size; _MHD_dumbClient_close (test_c); } while (0); expected_reason = use_hard_close ? MHD_REQUEST_TERMINATED_READ_ERROR : MHD_REQUEST_TERMINATED_CLIENT_ABORT; found_right_reason = 0; if (0 != rate_limiter) { if (verbose) { printf ("Pausing for rate limiter..."); fflush (stdout); } _MHD_sleep (1150); /* Just a bit more than one second */ if (verbose) { printf (" OK\n"); fflush (stdout); } inc_size = ((req_total_size - 1) + (rate_limiter - 1)) / rate_limiter; if (0 == inc_size) inc_size = 1; } else inc_size = 1; start = time (NULL); for (limit_send_size = 1; limit_send_size < req_total_size; limit_send_size += inc_size) { int test_succeed; test_succeed = 0; /* Make sure that maximum size is tested */ if (req_total_size - inc_size < limit_send_size) limit_send_size = req_total_size - 1; qParam.total_send_max = limit_send_size; /* To be updated by callbacks */ ahc_param->cb_called = 0; uri_cb_param->cb_called = 0; term_result->num_called = 0; term_result->term_reason = -1; sckt_result->num_started = 0; sckt_result->num_finished = 0; if (0 != doClientQueryInThread (d, &qParam)) fprintf (stderr, "FAILED: connection has NOT been closed by MHD."); else { if ((-1 != term_result->term_reason) && (MHD_REQUEST_TERMINATED_READ_ERROR != term_result->term_reason) && (MHD_REQUEST_TERMINATED_CLIENT_ABORT != term_result->term_reason) ) fprintf (stderr, "FAILED: Wrong termination code."); else if ((0 == term_result->num_called) && ((0 != uri_cb_param->cb_called) || (0 != ahc_param->cb_called))) fprintf (stderr, "FAILED: Missing required call of final notification " "callback."); else if (1 < uri_cb_param->cb_called) fprintf (stderr, "FAILED: Too many URI callbacks."); else if ((0 != ahc_param->cb_called) && (0 == uri_cb_param->cb_called)) fprintf (stderr, "FAILED: URI callback has NOT been called " "while Access Handler callback has been called."); else if (1 < term_result->num_called) fprintf (stderr, "FAILED: Too many final callbacks."); else if (1 != sckt_result->num_started) fprintf (stderr, "FAILED: Wrong number of sockets accepted."); else if (1 != sckt_result->num_finished) fprintf (stderr, "FAILED: Wrong number of sockets closed."); else { test_succeed = 1; if (expected_reason == term_result->term_reason) found_right_reason = 1; } } if (! test_succeed) { ret = 1; printTestResults (stderr, &qParam, ahc_param, uri_cb_param, term_result, sckt_result); } else if (verbose) { printf ("SUCCEED:"); printTestResults (stdout, &qParam, ahc_param, uri_cb_param, term_result, sckt_result); } if (time (NULL) - start > (time_t) ((TIMEOUTS_VAL * 25) + (rate_limiter * FINAL_PACKETS_MS) / 1000 + 1)) { ret |= 1 << 2; fprintf (stderr, "FAILED: Test total time exceeded.\n"); break; } } MHD_stop_daemon (d); free (uri_cb_param); free (ahc_param); free (term_result); free (sckt_result); if (! found_right_reason) { fprintf (stderr, "FAILED: termination callback was not called with " "expected (%s) reason.\n", term_reason_str ((enum MHD_RequestTerminationCode) expected_reason)); fflush (stderr); ret |= 1 << 1; } return ret; } enum testMhdThreadsType { testMhdThreadExternal = 0, testMhdThreadInternal = MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPerConnection = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, testMhdThreadInternalPool }; enum testMhdPollType { testMhdPollBySelect = 0, testMhdPollByPoll = MHD_USE_POLL, testMhdPollByEpoll = MHD_USE_EPOLL, testMhdPollAuto = MHD_USE_AUTO }; /* Get number of threads for thread pool depending * on used poll function and test type. */ static unsigned int testNumThreadsForPool (enum testMhdPollType pollType) { unsigned int numThreads = MHD_CPU_COUNT; (void) pollType; /* Don't care about pollType for this test */ return numThreads; /* No practical limit for non-cleanup test */ } static struct MHD_Daemon * startTestMhdDaemon (enum testMhdThreadsType thrType, enum testMhdPollType pollType, uint16_t *pport, struct ahc_cls_type **ahc_param, struct check_uri_cls **uri_cb_param, struct term_notif_cb_param **term_result, struct sckt_notif_cb_param **sckt_result) { struct MHD_Daemon *d; const union MHD_DaemonInfo *dinfo; if ((NULL == ahc_param) || (NULL == uri_cb_param) || (NULL == term_result)) externalErrorExit (); *ahc_param = (struct ahc_cls_type *) malloc (sizeof(struct ahc_cls_type)); if (NULL == *ahc_param) externalErrorExit (); *uri_cb_param = (struct check_uri_cls *) malloc (sizeof(struct check_uri_cls)); if (NULL == *uri_cb_param) externalErrorExit (); *term_result = (struct term_notif_cb_param *) malloc (sizeof(struct term_notif_cb_param)); if (NULL == *term_result) externalErrorExit (); *sckt_result = (struct sckt_notif_cb_param *) malloc (sizeof(struct sckt_notif_cb_param)); if (NULL == *sckt_result) externalErrorExit (); if ( (0 == *pport) && (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) ) { *pport = 4170; if (use_shutdown) *pport = (uint16_t) (*pport + 0); if (use_close) *pport = (uint16_t) (*pport + 1); if (use_hard_close) *pport = (uint16_t) (*pport + 1); if (by_step) *pport = (uint16_t) (*pport + (1 << 2)); if (upl_chunked) *pport = (uint16_t) (*pport + (1 << 3)); if (! oneone) *pport = (uint16_t) (*pport + (1 << 4)); } if (testMhdThreadExternal == thrType) d = MHD_start_daemon (((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0) | MHD_USE_NO_THREAD_SAFETY, *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_URI_LOG_CALLBACK, &check_uri_cb, *uri_cb_param, MHD_OPTION_NOTIFY_COMPLETED, &term_cb, *term_result, MHD_OPTION_NOTIFY_CONNECTION, &socket_cb, *sckt_result, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned) TIMEOUTS_VAL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); else if (testMhdThreadInternalPool != thrType) d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0), *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_URI_LOG_CALLBACK, &check_uri_cb, *uri_cb_param, MHD_OPTION_NOTIFY_COMPLETED, &term_cb, *term_result, MHD_OPTION_NOTIFY_CONNECTION, &socket_cb, *sckt_result, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned) TIMEOUTS_VAL, MHD_OPTION_END); else d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | ((unsigned int) pollType) | (verbose ? MHD_USE_ERROR_LOG : 0), *pport, NULL, NULL, &ahcCheck, *ahc_param, MHD_OPTION_THREAD_POOL_SIZE, testNumThreadsForPool (pollType), MHD_OPTION_URI_LOG_CALLBACK, &check_uri_cb, *uri_cb_param, MHD_OPTION_NOTIFY_COMPLETED, &term_cb, *term_result, MHD_OPTION_NOTIFY_CONNECTION, &socket_cb, *sckt_result, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned) TIMEOUTS_VAL, MHD_OPTION_END); if (NULL == d) mhdErrorExitDesc ("Failed to start MHD daemon"); if (0 == *pport) { dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if ((NULL == dinfo) || (0 == dinfo->port)) mhdErrorExitDesc ("MHD_get_daemon_info() failed"); *pport = dinfo->port; if (0 == global_port) global_port = *pport; /* Reuse the same port for all tests */ } return d; } /* Test runners */ static unsigned int testExternalGet (void) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; struct term_notif_cb_param *term_result; struct sckt_notif_cb_param *sckt_result; d = startTestMhdDaemon (testMhdThreadExternal, testMhdPollBySelect, &d_port, &ahc_param, &uri_cb_param, &term_result, &sckt_result); return performTestQueries (d, d_port, ahc_param, uri_cb_param, term_result, sckt_result); } #if 0 /* disabled runners, not suitable for this test */ static int testInternalGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; struct term_notif_cb_param *term_result; d = startTestMhdDaemon (testMhdThreadInternal, pollType, &d_port, &ahc_param, &uri_cb_param, &term_result); return performTestQueries (d, d_port, ahc_param, uri_cb_param, term_result); } static int testMultithreadedGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; struct term_notif_cb_param *term_result; d = startTestMhdDaemon (testMhdThreadInternalPerConnection, pollType, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param, term_result); } static int testMultithreadedPoolGet (enum testMhdPollType pollType) { struct MHD_Daemon *d; uint16_t d_port = global_port; /* Daemon's port */ struct ahc_cls_type *ahc_param; struct check_uri_cls *uri_cb_param; struct term_notif_cb_param *term_result; d = startTestMhdDaemon (testMhdThreadInternalPool, pollType, &d_port, &ahc_param, &uri_cb_param); return performTestQueries (d, d_port, ahc_param, uri_cb_param, term_result); } #endif /* disabled runners, not suitable for this test */ int main (int argc, char *const *argv) { unsigned int errorCount = 0; unsigned int test_result = 0; verbose = 0; if ((NULL == argv) || (0 == argv[0])) return 99; oneone = ! has_in_name (argv[0], "10"); use_shutdown = has_in_name (argv[0], "_shutdown") ? 1 : 0; use_close = has_in_name (argv[0], "_close") ? 1 : 0; use_hard_close = has_in_name (argv[0], "_hard_close") ? 1 : 0; use_stress_os = has_in_name (argv[0], "_stress_os") ? 1 : 0; by_step = has_in_name (argv[0], "_steps") ? 1 : 0; upl_chunked = has_in_name (argv[0], "_chunked") ? 1 : 0; #ifndef SO_LINGER if (use_hard_close) { fprintf (stderr, "This test requires SO_LINGER socket option support.\n"); return 77; } #endif /* ! SO_LINGER */ if (1 != use_shutdown + use_close) return 99; verbose = ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet") || has_param (argc, argv, "-s") || has_param (argc, argv, "--silent")); if (use_stress_os && ! use_hard_close) return 99; test_global_init (); /* Could be set to non-zero value to enforce using specific port * in the test */ global_port = 0; test_result = testExternalGet (); if (test_result) fprintf (stderr, "FAILED: testExternalGet (). Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testExternalGet ().\n"); errorCount += test_result; #if 0 /* disabled runners, not suitable for this test */ if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { test_result = testInternalGet (testMhdPollAuto); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollAuto). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollBySelect).\n"); errorCount += test_result; #ifdef _MHD_HEAVY_TESTS /* Actually tests are not heavy, but took too long to complete while * not really provide any additional results. */ test_result = testInternalGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollBySelect). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedPoolGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedPoolGet (testMhdPollBySelect). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedPoolGet (testMhdPollBySelect).\n"); errorCount += test_result; test_result = testMultithreadedGet (testMhdPollBySelect); if (test_result) fprintf (stderr, "FAILED: testMultithreadedGet (testMhdPollBySelect). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testMultithreadedGet (testMhdPollBySelect).\n"); errorCount += test_result; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { test_result = testInternalGet (testMhdPollByPoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByPoll). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByPoll).\n"); errorCount += test_result; } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { test_result = testInternalGet (testMhdPollByEpoll); if (test_result) fprintf (stderr, "FAILED: testInternalGet (testMhdPollByEpoll). " "Result: %u.\n", test_result); else if (verbose) printf ("PASSED: testInternalGet (testMhdPollByEpoll).\n"); errorCount += test_result; } #else /* Mute compiler warnings */ (void) testMultithreadedGet; (void) testMultithreadedPoolGet; #endif /* _MHD_HEAVY_TESTS */ } #endif /* disabled runners, not suitable for this test */ if (0 != errorCount) fprintf (stderr, "Error (code: %u)\n", errorCount); else if (verbose) printf ("All tests passed.\n"); test_global_cleanup (); return (errorCount == 0) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/microhttpd/test_mhd_version.c0000644000175000017500000001415114445225054016531 /* This file is part of libmicrohttpd Copyright (C) 2023 Evgeny Grin (Karlson2k) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/test_mhd_version.Ñ * @brief Tests for MHD versions identifiers * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include #ifdef HAVE_INTTYPES_H #include #else /* ! HAVE_INTTYPES_H */ #define PRIX32 "X" #endif /* ! HAVE_INTTYPES_H */ #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include "microhttpd.h" #ifdef PACKAGE_VERSION static const char str_macro_pkg_ver[] = PACKAGE_VERSION; #else /* ! PACKAGE_VERSION */ static const char str_macro_pkg_ver[] = "error!"; #error No PACKAGE_VERSION defined #endif /* ! PACKAGE_VERSION */ #ifdef VERSION static const char str_macro_ver[] = VERSION; #else /* ! VERSION */ static const char str_macro_ver[] = "error!"; #error No PACKAGE_VERSION defined #endif /* ! VERSION */ #ifdef MHD_VERSION static const uint32_t bin_macro = (uint32_t) (MHD_VERSION); #else /* ! MHD_VERSION */ static const uint32_t bin_macro = 0; #error MHD_VERSION is not defined #endif /* ! MHD_VERSION */ /* 0 = success, 1 = failure */ static int test_macro1_vs_macro2_str (void) { printf ("Checking PACKAGE_VERSION macro vs VERSION macro.\n"); if (0 != strcmp (str_macro_pkg_ver, str_macro_ver)) { fprintf (stderr, "'%s' vs '%s' - FAILED.\n", str_macro_pkg_ver, str_macro_ver); return 1; } printf ("'%s' vs '%s' - success.\n", str_macro_pkg_ver, str_macro_ver); return 0; } /* 0 = success, 1 = failure */ static int test_macro2_vs_func_str (void) { const char *str_func = MHD_get_version (); printf ("Checking VERSION macro vs MHD_get_version() function.\n"); if (NULL == str_func) { fprintf (stderr, "MHD_get_version() returned NULL.\n"); return 1; } if (0 != strcmp (str_macro_ver, str_func)) { fprintf (stderr, "'%s' vs '%s' - FAILED.\n", str_macro_ver, str_func); return 1; } printf ("'%s' vs '%s' - success.\n", str_macro_ver, str_func); return 0; } /* 0 = success, 1 = failure */ static int test_func_str_vs_macro_bin (void) { char bin_print[64]; int res; const char *str_func = MHD_get_version (); printf ("Checking MHD_get_version() function vs MHD_VERSION macro.\n"); #ifdef HAVE_SNPRINTF res = snprintf (bin_print, sizeof(bin_print), "%X.%X.%X", (unsigned int) ((bin_macro >> 24) & 0xFF), (unsigned int) ((bin_macro >> 16) & 0xFF), (unsigned int) ((bin_macro >> 8) & 0xFF)); #else /* ! HAVE_SNPRINTF */ res = sprintf (bin_print, "%X.%X.%X", (unsigned int) ((bin_macro >> 24) & 0xFF), (unsigned int) ((bin_macro >> 16) & 0xFF), (unsigned int) ((bin_macro >> 8) & 0xFF)); #endif /* ! HAVE_SNPRINTF */ if ((9 < res) || (0 >= res)) { fprintf (stderr, "snprintf() error.\n"); exit (99); } if (0 != strcmp (str_func, bin_print)) { fprintf (stderr, "'%s' vs '0x%08" PRIX32 "' ('%s') - FAILED.\n", str_func, bin_macro, bin_print); return 1; } fprintf (stderr, "'%s' vs '0x%08" PRIX32 "' ('%s') - success.\n", str_func, bin_macro, bin_print); return 0; } /* 0 = success, 1 = failure */ static int test_macro_vs_func_bin (void) { const uint32_t bin_func = MHD_get_version_bin (); printf ("Checking MHD_VERSION macro vs MHD_get_version_bin() function.\n"); if (bin_macro != bin_func) { fprintf (stderr, "'0x%08" PRIX32 "' vs '0x%08" PRIX32 "' - FAILED.\n", bin_macro, bin_func); return 1; } printf ("'0x%08" PRIX32 "' vs '0x%08" PRIX32 "' - success.\n", bin_macro, bin_func); return 0; } /* 0 = success, 1 = failure */ static int test_func_bin_format (void) { const uint32_t bin_func = MHD_get_version_bin (); unsigned int test_byte; int ret = 0; printf ("Checking format of MHD_get_version_bin() function return value.\n"); test_byte = (unsigned int) ((bin_func >> 24) & 0xFF); if ((0xA <= (test_byte & 0xF)) || (0xA <= (test_byte >> 4))) { fprintf (stderr, "Invalid value in the first (most significant) byte: %02X\n", test_byte); ret = 1; } test_byte = (unsigned int) ((bin_func >> 16) & 0xFF); if ((0xA <= (test_byte & 0xF)) || (0xA <= (test_byte >> 4))) { fprintf (stderr, "Invalid value in the second byte: %02X\n", test_byte); ret = 1; } test_byte = (unsigned int) ((bin_func >> 8) & 0xFF); if ((0xA <= (test_byte & 0xF)) || (0xA <= (test_byte >> 4))) { fprintf (stderr, "Invalid value in the third byte: %02X\n", test_byte); ret = 1; } if (0 != ret) { fprintf (stderr, "The value (0x%08" PRIX32 ") returned by MHD_get_version_bin() " "function is invalid as it cannot be used as packed BCD form " "(its hexadecimal representation has at least one digit in " "A-F range).\n", bin_func); return 1; } printf ("'0x%08" PRIX32 "' - success.\n", bin_func); return 0; } int main (void) { int res; res = test_macro1_vs_macro2_str (); res += test_macro2_vs_func_str (); res += test_func_str_vs_macro_bin (); res += test_macro_vs_func_bin (); res += test_func_bin_format (); if (0 != res) { fprintf (stderr, "Test failed. Number of errors: %d\n", res); return 1; } printf ("Test succeed.\n"); return 0; } libmicrohttpd-1.0.1/src/microhttpd/test_str_base64.c0000644000175000017500000011425514445225034016174 /* This file is part of libmicrohttpd Copyright (C) 2022 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_str_base64.c * @brief Unit tests for base64 strings processing * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include "mhd_str.h" #include "mhd_assert.h" #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ #define TEST_BIN_MAX_SIZE 1024 /* return zero if succeed, one otherwise */ static unsigned int expect_decoded_n (const char *const encoded, const size_t encoded_len, const uint8_t *const decoded, const size_t decoded_size, const unsigned int line_num) { static const char fill_chr = '#'; static uint8_t buf[TEST_BIN_MAX_SIZE]; size_t res_size; unsigned int ret; mhd_assert (NULL != encoded); mhd_assert (NULL != decoded); mhd_assert (TEST_BIN_MAX_SIZE > decoded_size); mhd_assert (encoded_len >= decoded_size); mhd_assert (0 == encoded_len || encoded_len > decoded_size); ret = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_base64_to_bin_n (encoded, encoded_len, buf, decoded_size); if (res_size != decoded_size) { ret = 1; fprintf (stderr, "'MHD_base64_to_bin_n ()' FAILED: Wrong returned value:\n"); } else if ((0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size))) { ret = 1; fprintf (stderr, "'MHD_base64_to_bin_n ()' FAILED: Wrong output binary:\n"); } if (0 != ret) { static char prnt[TEST_BIN_MAX_SIZE * 2 + 1]; size_t prnt_size; if (TEST_BIN_MAX_SIZE <= res_size * 2) { fprintf (stderr, "\tRESULT : MHD_base64_to_bin_n ('%.*s', %u, ->(too long), %u)" " -> %u\n", (int) encoded_len, encoded, (unsigned) encoded_len, (unsigned) decoded_size, (unsigned) res_size); } else { prnt_size = MHD_bin_to_hex_z (buf, res_size, prnt); mhd_assert (2 * res_size == prnt_size); fprintf (stderr, "\tRESULT : MHD_base64_to_bin_n ('%.*s', %u, ->%.*sh, %u)" " -> %u\n", (int) encoded_len, encoded, (unsigned) encoded_len, (int) prnt_size, prnt, (unsigned) decoded_size, (unsigned) res_size); } prnt_size = MHD_bin_to_hex_z (decoded, decoded_size, prnt); mhd_assert (2 * decoded_size == prnt_size); fprintf (stderr, "\tEXPECTED: MHD_base64_to_bin_n ('%.*s', %u, ->%.*sh, %u)" " -> %u\n", (int) encoded_len, encoded, (unsigned) encoded_len, (int) prnt_size, prnt, (unsigned) decoded_size, (unsigned) decoded_size); fprintf (stderr, "The check is at line: %u\n\n", line_num); } return ret; } #define expect_decoded(e,d) \ expect_decoded_n(e,MHD_STATICSTR_LEN_(e),\ (const uint8_t*)(d),MHD_STATICSTR_LEN_(d), \ __LINE__) static unsigned int check_decode_str (void) { unsigned int r = 0; /**< The number of errors */ r += expect_decoded ("", ""); /* Base sequences without padding */ r += expect_decoded ("YWFh", "aaa"); r += expect_decoded ("YmJi", "bbb"); r += expect_decoded ("Y2Nj", "ccc"); r += expect_decoded ("ZGRk", "ddd"); r += expect_decoded ("bGxs", "lll"); r += expect_decoded ("bW1t", "mmm"); r += expect_decoded ("bm5u", "nnn"); r += expect_decoded ("b29v", "ooo"); r += expect_decoded ("d3d3", "www"); r += expect_decoded ("eHh4", "xxx"); r += expect_decoded ("eXl5", "yyy"); r += expect_decoded ("enp6", "zzz"); r += expect_decoded ("QUFB", "AAA"); r += expect_decoded ("R0dH", "GGG"); r += expect_decoded ("TU1N", "MMM"); r += expect_decoded ("VFRU", "TTT"); r += expect_decoded ("Wlpa", "ZZZ"); r += expect_decoded ("MDEy", "012"); r += expect_decoded ("MzQ1", "345"); r += expect_decoded ("Njc4", "678"); r += expect_decoded ("OTAx", "901"); r += expect_decoded ("YWFhYWFh", "aaaaaa"); r += expect_decoded ("YmJiYmJi", "bbbbbb"); r += expect_decoded ("Y2NjY2Nj", "cccccc"); r += expect_decoded ("ZGRkZGRk", "dddddd"); r += expect_decoded ("bGxsbGxs", "llllll"); r += expect_decoded ("bW1tbW1t", "mmmmmm"); r += expect_decoded ("bm5ubm5u", "nnnnnn"); r += expect_decoded ("b29vb29v", "oooooo"); r += expect_decoded ("d3d3d3d3", "wwwwww"); r += expect_decoded ("eHh4eHh4", "xxxxxx"); r += expect_decoded ("eXl5eXl5", "yyyyyy"); r += expect_decoded ("enp6enp6", "zzzzzz"); r += expect_decoded ("QUFBQUFB", "AAAAAA"); r += expect_decoded ("R0dHR0dH", "GGGGGG"); r += expect_decoded ("TU1NTU1N", "MMMMMM"); r += expect_decoded ("VFRUVFRU", "TTTTTT"); r += expect_decoded ("WlpaWlpa", "ZZZZZZ"); r += expect_decoded ("MDEyMDEy", "012012"); r += expect_decoded ("MzQ1MzQ1", "345345"); r += expect_decoded ("Njc4Njc4", "678678"); r += expect_decoded ("OTAxOTAx", "901901"); /* Various lengths */ r += expect_decoded ("YQ==", "a"); r += expect_decoded ("YmM=", "bc"); r += expect_decoded ("REVGRw==", "DEFG"); r += expect_decoded ("MTIzdA==", "123t"); r += expect_decoded ("MTIzNDU=", "12345"); r += expect_decoded ("VGVzdCBTdHI=", "Test Str"); r += expect_decoded ("VGVzdCBzdHJpbmc=", "Test string"); r += expect_decoded ("VGVzdCBzdHJpbmcu", "Test string."); r += expect_decoded ("TG9uZ2VyIHN0cmluZw==", "Longer string"); r += expect_decoded ("TG9uZ2VyIHN0cmluZy4=", "Longer string."); r += expect_decoded ("TG9uZ2VyIHN0cmluZzIu", "Longer string2."); return r; } #define expect_decoded_arr(e,a) \ expect_decoded_n(e,MHD_STATICSTR_LEN_(e),\ a,(sizeof(a)/sizeof(a[0])), \ __LINE__) static unsigned int check_decode_bin (void) { unsigned int r = 0; /**< The number of errors */ if (1) { static const uint8_t bin[256] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; r += expect_decoded_arr ("AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISI" \ "jJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERU" \ "ZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoa" \ "WprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouM" \ "jY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+" \ "wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0t" \ "PU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19" \ "vf4+fr7/P3+/w==", bin); } if (1) { static const uint8_t bin[256] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x0 }; r += expect_decoded_arr ("AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiM" \ "kJSYnKCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4/QEFCQ0RFRk" \ "dISUpLTE1OT1BRUlNUVVZXWFlaW1xdXl9gYWJjZGVmZ2hpa" \ "mtsbW5vcHFyc3R1dnd4eXp7fH1+f4CBgoOEhYaHiImKi4yN" \ "jo+QkZKTlJWWl5iZmpucnZ6foKGio6SlpqeoqaqrrK2ur7C" \ "xsrO0tba3uLm6u7y9vr/AwcLDxMXGx8jJysvMzc7P0NHS09" \ "TV1tfY2drb3N3e3+Dh4uPk5ebn6Onq6+zt7u/w8fLz9PX29" \ "/j5+vv8/f7/AA==", bin); } if (1) { static const uint8_t bin[256] = {0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x0, 0x1 }; r += expect_decoded_arr ("AgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGhscHR4fICEiIyQ" \ "lJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0" \ "hJSktMTU5PUFFSU1RVVldYWVpbXF1eX2BhYmNkZWZnaGlqa" \ "2xtbm9wcXJzdHV2d3h5ent8fX5/gIGCg4SFhoeIiYqLjI2O" \ "j5CRkpOUlZaXmJmam5ydnp+goaKjpKWmp6ipqqusra6vsLG" \ "ys7S1tre4ubq7vL2+v8DBwsPExcbHyMnKy8zNzs/Q0dLT1N" \ "XW19jZ2tvc3d7f4OHi4+Tl5ufo6err7O3u7/Dx8vP09fb3+" \ "Pn6+/z9/v8AAQ==", bin); } if (1) { static const uint8_t bin[256] = {0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x0, 0x1, 0x2 }; r += expect_decoded_arr ("AwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCU" \ "mJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSE" \ "lKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprb" \ "G1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6P" \ "kJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbK" \ "ztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1d" \ "bX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+" \ "fr7/P3+/wABAg==", bin); } if (1) { static const uint8_t bin[256] = {0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xdf, 0xde, 0xdd, 0xdc, 0xdb, 0xda, 0xd9, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0, 0xcf, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc8, 0xc7, 0xc6, 0xc5, 0xc4, 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe, 0xbd, 0xbc, 0xbb, 0xba, 0xb9, 0xb8, 0xb7, 0xb6, 0xb5, 0xb4, 0xb3, 0xb2, 0xb1, 0xb0, 0xaf, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9, 0xa8, 0xa7, 0xa6, 0xa5, 0xa4, 0xa3, 0xa2, 0xa1, 0xa0, 0x9f, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x5c, 0x5b, 0x5a, 0x59, 0x58, 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0 }; r += expect_decoded_arr ("//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3" \ "c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7ur" \ "m4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXl" \ "pWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRz" \ "cnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVB" \ "PTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLS" \ "wrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKC" \ "QgHBgUEAwIBAA==", bin); } if (1) { static const uint8_t bin[256] = {0x0, 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xdf, 0xde, 0xdd, 0xdc, 0xdb, 0xda, 0xd9, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0, 0xcf, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc8, 0xc7, 0xc6, 0xc5, 0xc4, 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe, 0xbd, 0xbc, 0xbb, 0xba, 0xb9, 0xb8, 0xb7, 0xb6, 0xb5, 0xb4, 0xb3, 0xb2, 0xb1, 0xb0, 0xaf, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9, 0xa8, 0xa7, 0xa6, 0xa5, 0xa4, 0xa3, 0xa2, 0xa1, 0xa0, 0x9f, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x5c, 0x5b, 0x5a, 0x59, 0x58, 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1}; r += expect_decoded_arr ("AP/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397" \ "d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7" \ "q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl" \ "5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0" \ "c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlF" \ "QT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi" \ "0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLC" \ "gkIBwYFBAMCAQ==", bin); } if (1) { static const uint8_t bin[256] = {0x1, 0x0, 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xdf, 0xde, 0xdd, 0xdc, 0xdb, 0xda, 0xd9, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0, 0xcf, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc8, 0xc7, 0xc6, 0xc5, 0xc4, 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe, 0xbd, 0xbc, 0xbb, 0xba, 0xb9, 0xb8, 0xb7, 0xb6, 0xb5, 0xb4, 0xb3, 0xb2, 0xb1, 0xb0, 0xaf, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9, 0xa8, 0xa7, 0xa6, 0xa5, 0xa4, 0xa3, 0xa2, 0xa1, 0xa0, 0x9f, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x5c, 0x5b, 0x5a, 0x59, 0x58, 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2}; r += expect_decoded_arr ("AQD//v38+/r5+Pf29fTz8vHw7+7t7Ovq6ejn5uXk4+Lh4N/" \ "e3dzb2tnY19bV1NPS0dDPzs3My8rJyMfGxcTDwsHAv769vL" \ "u6ubi3trW0s7KxsK+urayrqqmop6alpKOioaCfnp2cm5qZm" \ "JeWlZSTkpGQj46NjIuKiYiHhoWEg4KBgH9+fXx7enl4d3Z1" \ "dHNycXBvbm1sa2ppaGdmZWRjYmFgX15dXFtaWVhXVlVUU1J" \ "RUE9OTUxLSklIR0ZFRENCQUA/Pj08Ozo5ODc2NTQzMjEwLy" \ "4tLCsqKSgnJiUkIyIhIB8eHRwbGhkYFxYVFBMSERAPDg0MC" \ "woJCAcGBQQDAg==", bin); } if (1) { static const uint8_t bin[256] = {0x2, 0x1, 0x0, 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xdf, 0xde, 0xdd, 0xdc, 0xdb, 0xda, 0xd9, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0, 0xcf, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc8, 0xc7, 0xc6, 0xc5, 0xc4, 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe, 0xbd, 0xbc, 0xbb, 0xba, 0xb9, 0xb8, 0xb7, 0xb6, 0xb5, 0xb4, 0xb3, 0xb2, 0xb1, 0xb0, 0xaf, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9, 0xa8, 0xa7, 0xa6, 0xa5, 0xa4, 0xa3, 0xa2, 0xa1, 0xa0, 0x9f, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x5c, 0x5b, 0x5a, 0x59, 0x58, 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3}; r += expect_decoded_arr ("AgEA//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eD" \ "f3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vb" \ "y7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuam" \ "ZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2" \ "dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFN" \ "SUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC" \ "8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4ND" \ "AsKCQgHBgUEAw==", bin); } if (1) { static const uint8_t bin[256] = {0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xdf, 0xde, 0xdd, 0xdc, 0xdb, 0xda, 0xd9, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0, 0xcf, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc8, 0xc7, 0xc6, 0xc5, 0xc4, 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe, 0xbd, 0xbc, 0xbb, 0xba, 0xb9, 0xb8, 0xb7, 0xb6, 0xb5, 0xb4, 0xb3, 0xb2, 0xb1, 0xb0, 0xaf, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9, 0xa8, 0xa7, 0xa6, 0xa5, 0xa4, 0xa3, 0xa2, 0xa1, 0xa0, 0x9f, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x5c, 0x5b, 0x5a, 0x59, 0x58, 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0, 0xff}; r += expect_decoded_arr ("/v38+/r5+Pf29fTz8vHw7+7t7Ovq6ejn5uXk4+Lh4N/e3dz" \ "b2tnY19bV1NPS0dDPzs3My8rJyMfGxcTDwsHAv769vLu6ub" \ "i3trW0s7KxsK+urayrqqmop6alpKOioaCfnp2cm5qZmJeWl" \ "ZSTkpGQj46NjIuKiYiHhoWEg4KBgH9+fXx7enl4d3Z1dHNy" \ "cXBvbm1sa2ppaGdmZWRjYmFgX15dXFtaWVhXVlVUU1JRUE9" \ "OTUxLSklIR0ZFRENCQUA/Pj08Ozo5ODc2NTQzMjEwLy4tLC" \ "sqKSgnJiUkIyIhIB8eHRwbGhkYFxYVFBMSERAPDg0MCwoJC" \ "AcGBQQDAgEA/w==", bin); } if (1) { static const uint8_t bin[256] = {0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xdf, 0xde, 0xdd, 0xdc, 0xdb, 0xda, 0xd9, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0, 0xcf, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc8, 0xc7, 0xc6, 0xc5, 0xc4, 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe, 0xbd, 0xbc, 0xbb, 0xba, 0xb9, 0xb8, 0xb7, 0xb6, 0xb5, 0xb4, 0xb3, 0xb2, 0xb1, 0xb0, 0xaf, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9, 0xa8, 0xa7, 0xa6, 0xa5, 0xa4, 0xa3, 0xa2, 0xa1, 0xa0, 0x9f, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x5c, 0x5b, 0x5a, 0x59, 0x58, 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0, 0xff, 0xfe}; r += expect_decoded_arr ("/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nv" \ "a2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uL" \ "e2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVl" \ "JOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3Jx" \ "cG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05" \ "NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKy" \ "opKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIB" \ "wYFBAMCAQD//g==", bin); } if (1) { static const uint8_t bin[256] = {0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xdf, 0xde, 0xdd, 0xdc, 0xdb, 0xda, 0xd9, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0, 0xcf, 0xce, 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc8, 0xc7, 0xc6, 0xc5, 0xc4, 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe, 0xbd, 0xbc, 0xbb, 0xba, 0xb9, 0xb8, 0xb7, 0xb6, 0xb5, 0xb4, 0xb3, 0xb2, 0xb1, 0xb0, 0xaf, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9, 0xa8, 0xa7, 0xa6, 0xa5, 0xa4, 0xa3, 0xa2, 0xa1, 0xa0, 0x9f, 0x9e, 0x9d, 0x9c, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x5c, 0x5b, 0x5a, 0x59, 0x58, 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0, 0xff, 0xfe, 0xfd }; r += expect_decoded_arr ("/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29r" \ "Z2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7" \ "a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk" \ "5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFw" \ "b25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1" \ "MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKi" \ "koJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHB" \ "gUEAwIBAP/+/Q==", bin); } if (1) { static const uint8_t bin[48] = {0x00, 0x10, 0x83, 0x10, 0x51, 0x87, 0x20, 0x92, 0x8b, 0x30, 0xd3, 0x8f, 0x41, 0x14, 0x93, 0x51, 0x55, 0x97, 0x61, 0x96, 0x9b, 0x71, 0xd7, 0x9f, 0x82, 0x18, 0xa3, 0x92, 0x59, 0xa7, 0xa2, 0x9a, 0xab, 0xb2, 0xdb, 0xaf, 0xc3, 0x1c, 0xb3, 0xd3, 0x5d, 0xb7, 0xe3, 0x9e, 0xbb, 0xf3, 0xdf, 0xbf }; r += expect_decoded_arr ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ "abcdefghijklmnopqrstuvwxyz0123456789+/", bin); } if (1) { static const uint8_t bin[49] = {0x00, 0x10, 0x83, 0x10, 0x51, 0x87, 0x20, 0x92, 0x8b, 0x30, 0xd3, 0x8f, 0x41, 0x14, 0x93, 0x51, 0x55, 0x97, 0x61, 0x96, 0x9b, 0x71, 0xd7, 0x9f, 0x82, 0x18, 0xa3, 0x92, 0x59, 0xa7, 0xa2, 0x9a, 0xab, 0xb2, 0xdb, 0xaf, 0xc3, 0x1c, 0xb3, 0xd3, 0x5d, 0xb7, 0xe3, 0x9e, 0xbb, 0xf3, 0xdf, 0xbf, 0x00 }; r += expect_decoded_arr ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ "abcdefghijklmnopqrstuvwxyz0123456789+/" \ "AA==", bin); } if (1) { static const uint8_t bin[48] = {0xff, 0xef, 0x7c, 0xef, 0xae, 0x78, 0xdf, 0x6d, 0x74, 0xcf, 0x2c, 0x70, 0xbe, 0xeb, 0x6c, 0xae, 0xaa, 0x68, 0x9e, 0x69, 0x64, 0x8e, 0x28, 0x60, 0x7d, 0xe7, 0x5c, 0x6d, 0xa6, 0x58, 0x5d, 0x65, 0x54, 0x4d, 0x24, 0x50, 0x3c, 0xe3, 0x4c, 0x2c, 0xa2, 0x48, 0x1c, 0x61, 0x44, 0x0c, 0x20, 0x40 }; r += expect_decoded_arr ("/+9876543210zyxwvutsrqponmlkjihgfedcba" \ "ZYXWVUTSRQPONMLKJIHGFEDCBA", bin); } if (1) { static const uint8_t bin[49] = {0xff, 0xef, 0x7c, 0xef, 0xae, 0x78, 0xdf, 0x6d, 0x74, 0xcf, 0x2c, 0x70, 0xbe, 0xeb, 0x6c, 0xae, 0xaa, 0x68, 0x9e, 0x69, 0x64, 0x8e, 0x28, 0x60, 0x7d, 0xe7, 0x5c, 0x6d, 0xa6, 0x58, 0x5d, 0x65, 0x54, 0x4d, 0x24, 0x50, 0x3c, 0xe3, 0x4c, 0x2c, 0xa2, 0x48, 0x1c, 0x61, 0x44, 0x0c, 0x20, 0x40, 0x00 }; r += expect_decoded_arr ("/+9876543210zyxwvutsrqponmlkjihgfedcba" \ "ZYXWVUTSRQPONMLKJIHGFEDCBAAA==", bin); } return r; } /* return zero if succeed, one otherwise */ static unsigned int expect_fail_n (const char *const encoded, const size_t encoded_len, const unsigned int line_num) { static const char fill_chr = '#'; static uint8_t buf[TEST_BIN_MAX_SIZE]; size_t res_size; unsigned int ret; mhd_assert (NULL != encoded); mhd_assert (TEST_BIN_MAX_SIZE > encoded_len); ret = 0; memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */ res_size = MHD_base64_to_bin_n (encoded, encoded_len, buf, sizeof(buf)); if (res_size != 0) { ret = 1; fprintf (stderr, "'MHD_base64_to_bin_n ()' FAILED: Wrong returned value:\n"); } if (0 != ret) { static char prnt[TEST_BIN_MAX_SIZE * 2 + 1]; size_t prnt_size; if (TEST_BIN_MAX_SIZE <= res_size * 2) { fprintf (stderr, "\tRESULT : MHD_base64_to_bin_n ('%.*s', %u, ->(too long), %u)" " -> %u\n", (int) encoded_len, encoded, (unsigned) encoded_len, (unsigned) sizeof(buf), (unsigned) res_size); } else { prnt_size = MHD_bin_to_hex_z (buf, res_size, prnt); mhd_assert (2 * res_size == prnt_size); fprintf (stderr, "\tRESULT : MHD_base64_to_bin_n ('%.*s', %u, ->%.*sh, %u)" " -> %u\n", (int) encoded_len, encoded, (unsigned) encoded_len, (int) prnt_size, prnt, (unsigned) sizeof(buf), (unsigned) res_size); } fprintf (stderr, "\tEXPECTED: MHD_base64_to_bin_n ('%.*s', %u, ->(empty), %u)" " -> 0\n", (int) encoded_len, encoded, (unsigned) encoded_len, (unsigned) sizeof(buf)); fprintf (stderr, "The check is at line: %u\n\n", line_num); } return ret; } #define expect_fail(e) \ expect_fail_n(e,MHD_STATICSTR_LEN_(e),__LINE__) static unsigned int check_fail (void) { unsigned int r = 0; /**< The number of errors */ /* Base sequences with wrong length */ r += expect_fail ("YWFh/"); r += expect_fail ("YWFh/Q"); r += expect_fail ("YWFhE/Q"); r += expect_fail ("bW1tbW1t/"); r += expect_fail ("bW1tbW1t/Q"); r += expect_fail ("bW1tbW1tE/Q"); /* Base sequences with wrong char */ r += expect_fail ("%mJi"); r += expect_fail ("Y%Nj"); r += expect_fail ("ZG%k"); r += expect_fail ("bGx%"); r += expect_fail ("#W1t"); r += expect_fail ("b#5u"); r += expect_fail ("b2#v"); r += expect_fail ("d3d#"); r += expect_fail ("^Hh4"); r += expect_fail ("e^l5"); r += expect_fail ("en^6"); r += expect_fail ("QUF^"); r += expect_fail ("~0dH"); r += expect_fail ("T~1N"); r += expect_fail ("VF~U"); r += expect_fail ("Wlp~"); r += expect_fail ("*DEy"); r += expect_fail ("M*Q1"); r += expect_fail ("Nj*4"); r += expect_fail ("OTA*"); r += expect_fail ("&WFhYWFh"); r += expect_fail ("Y&JiYmJi"); r += expect_fail ("Y2&jY2Nj"); r += expect_fail ("ZGR&ZGRk"); r += expect_fail ("bGxs&Gxs"); r += expect_fail ("bW1tb&1t"); r += expect_fail ("bm5ubm&u"); r += expect_fail ("b29vb29&"); r += expect_fail ("!3d3d3d3"); r += expect_fail ("e!h4eHh4"); r += expect_fail ("eX!5eXl5"); r += expect_fail ("enp!enp6"); r += expect_fail ("QUFB!UFB"); r += expect_fail ("R0dHR!dH"); r += expect_fail ("TU1NTU!N"); r += expect_fail ("VFRUVFR!"); /* Bad high-ASCII char */ r += expect_fail ("\xff" "WFhYWFh"); r += expect_fail ("Y\xfe" "JiYmJi"); r += expect_fail ("Y2\xfd" "jY2Nj"); r += expect_fail ("ZGR\xfc" "ZGRk"); r += expect_fail ("bGxs\xfb" "Gxs"); r += expect_fail ("bW1tbW\xfa" "1t"); r += expect_fail ("bm5ubm\xf9" "u"); r += expect_fail ("b29vb29\xf8"); r += expect_fail ("d3d3d3d\x80"); r += expect_fail ("eHh4eH\x81" "4"); r += expect_fail ("eXl5e\x82" "l5"); r += expect_fail ("enp6\x83" "np6"); r += expect_fail ("QUF\x84" "QUFB"); r += expect_fail ("TU\x85" "NTU1N"); r += expect_fail ("V\x86" "RUVFRU"); r += expect_fail ("\x87" "lpaWlpa"); /* Base sequences with wrong padding char */ r += expect_fail ("=lpaWlpa"); r += expect_fail ("M=EyMDEy"); r += expect_fail ("Mz=1MzQ1"); r += expect_fail ("Njc=Njc4"); r += expect_fail ("OTAx=TAx"); r += expect_fail ("ZGRkZ=Rk"); r += expect_fail ("bGxsbG=s"); r += expect_fail ("bW1tb==="); r += expect_fail ("bm5u===="); /* Bad last char (valid for Base64, but padding part is not zero */ r += expect_fail ("TG9uZ2VyIHN0cmluZo=="); r += expect_fail ("TG9uZ2VyIHN0cmluZyK="); return r; } int main (int argc, char *argv[]) { unsigned int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errcount += check_decode_str (); errcount += check_decode_bin (); errcount += check_fail (); if (0 == errcount) printf ("All tests were passed without errors.\n"); return errcount == 0 ? 0 : 1; } libmicrohttpd-1.0.1/src/microhttpd/digestauth.c0000644000175000017500000042566614566122702015337 /* This file is part of libmicrohttpd Copyright (C) 2010, 2011, 2012, 2015, 2018 Daniel Pittman and Christian Grothoff Copyright (C) 2014-2024 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file digestauth.c * @brief Implements HTTP digest authentication * @author Amr Ali * @author Matthieu Speder * @author Christian Grothoff (RFC 7616 support) * @author Karlson2k (Evgeny Grin) (fixes, new API, improvements, large rewrite, * many RFC 7616 features implementation, * old RFC 2069 support) */ #include "digestauth.h" #include "gen_auth.h" #include "platform.h" #include "mhd_limits.h" #include "internal.h" #include "response.h" #ifdef MHD_MD5_SUPPORT # include "mhd_md5_wrap.h" #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT # include "mhd_sha256_wrap.h" #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT # include "sha512_256.h" #endif /* MHD_SHA512_256_SUPPORT */ #include "mhd_locks.h" #include "mhd_mono_clock.h" #include "mhd_str.h" #include "mhd_compat.h" #include "mhd_bithelpers.h" #include "mhd_assert.h" /** * Allow re-use of the nonce-nc map array slot after #REUSE_TIMEOUT seconds, * if this slot is needed for the new nonce, while the old nonce was not used * even one time by the client. * Typically clients immediately use generated nonce for new request. */ #define REUSE_TIMEOUT 30 /** * The maximum value of artificial timestamp difference to avoid clashes. * The value must be suitable for bitwise AND operation. */ #define DAUTH_JUMPBACK_MAX (0x7F) /** * 48 bit value in bytes */ #define TIMESTAMP_BIN_SIZE (48 / 8) /** * Trim value to the TIMESTAMP_BIN_SIZE size */ #define TRIM_TO_TIMESTAMP(value) \ ((value) & ((UINT64_C (1) << (TIMESTAMP_BIN_SIZE * 8)) - 1)) /** * The printed timestamp size in chars */ #define TIMESTAMP_CHARS_LEN (TIMESTAMP_BIN_SIZE * 2) /** * Standard server nonce length, not including terminating null, * * @param digest_size digest size */ #define NONCE_STD_LEN(digest_size) \ ((digest_size) * 2 + TIMESTAMP_CHARS_LEN) #ifdef MHD_SHA512_256_SUPPORT /** * Maximum size of any digest hash supported by MHD. * (SHA-512/256 > MD5). */ #define MAX_DIGEST SHA512_256_DIGEST_SIZE /** * The common size of SHA-256 digest and SHA-512/256 digest */ #define SHA256_SHA512_256_DIGEST_SIZE SHA512_256_DIGEST_SIZE #elif defined(MHD_SHA256_SUPPORT) /** * Maximum size of any digest hash supported by MHD. * (SHA-256 > MD5). */ #define MAX_DIGEST SHA256_DIGEST_SIZE /** * The common size of SHA-256 digest and SHA-512/256 digest */ #define SHA256_SHA512_256_DIGEST_SIZE SHA256_DIGEST_SIZE #elif defined(MHD_MD5_SUPPORT) /** * Maximum size of any digest hash supported by MHD. */ #define MAX_DIGEST MD5_DIGEST_SIZE #else /* ! MHD_MD5_SUPPORT */ #error At least one hashing algorithm must be enabled #endif /* ! MHD_MD5_SUPPORT */ /** * Macro to avoid using VLAs if the compiler does not support them. */ #ifndef HAVE_C_VARARRAYS /** * Return #MAX_DIGEST. * * @param n length of the digest to be used for a VLA */ #define VLA_ARRAY_LEN_DIGEST(n) (MAX_DIGEST) #else /** * Return @a n. * * @param n length of the digest to be used for a VLA */ #define VLA_ARRAY_LEN_DIGEST(n) (n) #endif /** * Check that @a n is below #MAX_DIGEST */ #define VLA_CHECK_LEN_DIGEST(n) \ do { if ((n) > MAX_DIGEST) MHD_PANIC (_ ("VLA too big.\n")); } while (0) /** * Maximum length of a username for digest authentication. */ #define MAX_USERNAME_LENGTH 128 /** * Maximum length of a realm for digest authentication. */ #define MAX_REALM_LENGTH 256 /** * Maximum length of the response in digest authentication. */ #define MAX_AUTH_RESPONSE_LENGTH (MAX_DIGEST * 2) /** * The required prefix of parameter with the extended notation */ #define MHD_DAUTH_EXT_PARAM_PREFIX "UTF-8'" /** * The minimal size of the prefix for parameter with the extended notation */ #define MHD_DAUTH_EXT_PARAM_MIN_LEN \ MHD_STATICSTR_LEN_ (MHD_DAUTH_EXT_PARAM_PREFIX "'") /** * The result of nonce-nc map array check. */ enum MHD_CheckNonceNC_ { /** * The nonce and NC are OK (valid and NC was not used before). */ MHD_CHECK_NONCENC_OK = MHD_DAUTH_OK, /** * The 'nonce' was overwritten with newer 'nonce' in the same slot or * NC was already used. * The validity of the 'nonce' was not be checked. */ MHD_CHECK_NONCENC_STALE = MHD_DAUTH_NONCE_STALE, /** * The 'nonce' is wrong, it was not generated before. */ MHD_CHECK_NONCENC_WRONG = MHD_DAUTH_NONCE_WRONG }; /** * Get base hash calculation algorithm from #MHD_DigestAuthAlgo3 value. * @param algo3 the MHD_DigestAuthAlgo3 value * @return the base hash calculation algorithm */ _MHD_static_inline enum MHD_DigestBaseAlgo get_base_digest_algo (enum MHD_DigestAuthAlgo3 algo3) { unsigned int base_algo; base_algo = ((unsigned int) algo3) & ~((unsigned int) (MHD_DIGEST_AUTH_ALGO3_NON_SESSION | MHD_DIGEST_AUTH_ALGO3_NON_SESSION)); return (enum MHD_DigestBaseAlgo) base_algo; } /** * Get digest size for specified algorithm. * * Internal inline version. * @param algo3 the algorithm to check * @return the size of the digest or zero if the input value is not * supported/valid */ _MHD_static_inline size_t digest_get_hash_size (enum MHD_DigestAuthAlgo3 algo3) { #ifdef MHD_MD5_SUPPORT mhd_assert (MHD_MD5_DIGEST_SIZE == MD5_DIGEST_SIZE); #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT mhd_assert (MHD_SHA256_DIGEST_SIZE == SHA256_DIGEST_SIZE); #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT mhd_assert (MHD_SHA512_256_DIGEST_SIZE == SHA512_256_DIGEST_SIZE); #ifdef MHD_SHA256_SUPPORT mhd_assert (SHA256_DIGEST_SIZE == SHA512_256_DIGEST_SIZE); #endif /* MHD_SHA256_SUPPORT */ #endif /* MHD_SHA512_256_SUPPORT */ /* Only one algorithm must be specified */ mhd_assert (1 == \ (((0 != (algo3 & MHD_DIGEST_BASE_ALGO_MD5)) ? 1 : 0) \ + ((0 != (algo3 & MHD_DIGEST_BASE_ALGO_SHA256)) ? 1 : 0) \ + ((0 != (algo3 & MHD_DIGEST_BASE_ALGO_SHA512_256)) ? 1 : 0))); #ifdef MHD_MD5_SUPPORT if (0 != (((unsigned int) algo3) & ((unsigned int) MHD_DIGEST_BASE_ALGO_MD5))) return MHD_MD5_DIGEST_SIZE; else #endif /* MHD_MD5_SUPPORT */ #if defined(MHD_SHA256_SUPPORT) && defined(MHD_SHA512_256_SUPPORT) if (0 != (((unsigned int) algo3) & ( ((unsigned int) MHD_DIGEST_BASE_ALGO_SHA256) | ((unsigned int) MHD_DIGEST_BASE_ALGO_SHA512_256)))) return MHD_SHA256_DIGEST_SIZE; /* The same as SHA512_256_DIGEST_SIZE */ else #elif defined(MHD_SHA256_SUPPORT) if (0 != (((unsigned int) algo3) & ((unsigned int) MHD_DIGEST_BASE_ALGO_SHA256))) return MHD_SHA256_DIGEST_SIZE; else #elif defined(MHD_SHA512_256_SUPPORT) if (0 != (((unsigned int) algo3) & ((unsigned int) MHD_DIGEST_BASE_ALGO_SHA512_256))) return MHD_SHA512_256_DIGEST_SIZE; else #endif /* MHD_SHA512_256_SUPPORT */ (void) 0; /* Unsupported algorithm */ return 0; /* Wrong input or unsupported algorithm */ } /** * Get digest size for specified algorithm. * * The size of the digest specifies the size of the userhash, userdigest * and other parameters which size depends on used hash algorithm. * @param algo3 the algorithm to check * @return the size of the digest (either #MHD_MD5_DIGEST_SIZE or * #MHD_SHA256_DIGEST_SIZE/MHD_SHA512_256_DIGEST_SIZE) * or zero if the input value is not supported or not valid * @sa #MHD_digest_auth_calc_userdigest() * @sa #MHD_digest_auth_calc_userhash(), #MHD_digest_auth_calc_userhash_hex() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN size_t MHD_digest_get_hash_size (enum MHD_DigestAuthAlgo3 algo3) { return digest_get_hash_size (algo3); } /** * Digest context data */ union DigestCtx { #ifdef MHD_MD5_SUPPORT struct Md5CtxWr md5_ctx; #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT struct Sha256CtxWr sha256_ctx; #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT struct Sha512_256Ctx sha512_256_ctx; #endif /* MHD_SHA512_256_SUPPORT */ }; /** * The digest calculation structure. */ struct DigestAlgorithm { /** * A context for the digest algorithm, already initialized to be * useful for @e init, @e update and @e digest. */ union DigestCtx ctx; /** * The hash calculation algorithm. */ enum MHD_DigestBaseAlgo algo; /** * Buffer for hex-print of the final digest. */ #ifdef _DEBUG bool uninitialised; /**< The structure has been not set-up */ bool algo_selected; /**< The algorithm has been selected */ bool ready_for_hashing; /**< The structure is ready to hash data */ bool hashing; /**< Some data has been hashed, but the digest has not finalised yet */ #endif /* _DEBUG */ }; /** * Return the size of the digest. * @param da the digest calculation structure to identify * @return the size of the digest. */ _MHD_static_inline unsigned int digest_get_size (struct DigestAlgorithm *da) { mhd_assert (! da->uninitialised); mhd_assert (da->algo_selected); #ifdef MHD_MD5_SUPPORT if (MHD_DIGEST_BASE_ALGO_MD5 == da->algo) return MD5_DIGEST_SIZE; #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT if (MHD_DIGEST_BASE_ALGO_SHA256 == da->algo) return SHA256_DIGEST_SIZE; #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT if (MHD_DIGEST_BASE_ALGO_SHA512_256 == da->algo) return SHA512_256_DIGEST_SIZE; #endif /* MHD_SHA512_256_SUPPORT */ mhd_assert (0); /* May not happen */ return 0; } #if defined(MHD_MD5_HAS_DEINIT) || defined(MHD_SHA256_HAS_DEINIT) /** * Indicates presence of digest_deinit() function */ #define MHD_DIGEST_HAS_DEINIT 1 #endif /* MHD_MD5_HAS_DEINIT || MHD_SHA256_HAS_DEINIT */ #ifdef MHD_DIGEST_HAS_DEINIT /** * Zero-initialise digest calculation structure. * * This initialisation is enough to safely call #digest_deinit() only. * To make any real digest calculation, #digest_setup_and_init() must be called. * @param da the digest calculation */ _MHD_static_inline void digest_setup_zero (struct DigestAlgorithm *da) { #ifdef _DEBUG da->uninitialised = false; da->algo_selected = false; da->ready_for_hashing = false; da->hashing = false; #endif /* _DEBUG */ da->algo = MHD_DIGEST_BASE_ALGO_INVALID; } /** * De-initialise digest calculation structure. * * This function must be called if #digest_setup_and_init() was called for * @a da. * This function must not be called if @a da was not initialised by * #digest_setup_and_init() or by #digest_setup_zero(). * @param da the digest calculation */ _MHD_static_inline void digest_deinit (struct DigestAlgorithm *da) { mhd_assert (! da->uninitialised); #ifdef MHD_MD5_HAS_DEINIT if (MHD_DIGEST_BASE_ALGO_MD5 == da->algo) MHD_MD5_deinit (&da->ctx.md5_ctx); else #endif /* MHD_MD5_HAS_DEINIT */ #ifdef MHD_SHA256_HAS_DEINIT if (MHD_DIGEST_BASE_ALGO_SHA256 == da->algo) MHD_SHA256_deinit (&da->ctx.sha256_ctx); else #endif /* MHD_SHA256_HAS_DEINIT */ (void) 0; digest_setup_zero (da); } #else /* ! MHD_DIGEST_HAS_DEINIT */ #define digest_setup_zero(da) (void)0 #define digest_deinit(da) (void)0 #endif /* ! MHD_DIGEST_HAS_DEINIT */ /** * Set-up the digest calculation structure and initialise with initial values. * * If @a da was successfully initialised, #digest_deinit() must be called * after finishing using of the @a da. * * This function must not be called more than once for any @a da. * * @param da the structure to set-up * @param algo the algorithm to use for digest calculation * @return boolean 'true' if successfully set-up, * false otherwise. */ _MHD_static_inline bool digest_init_one_time (struct DigestAlgorithm *da, enum MHD_DigestBaseAlgo algo) { #ifdef _DEBUG da->uninitialised = false; da->algo_selected = false; da->ready_for_hashing = false; da->hashing = false; #endif /* _DEBUG */ #ifdef MHD_MD5_SUPPORT if (MHD_DIGEST_BASE_ALGO_MD5 == algo) { da->algo = MHD_DIGEST_BASE_ALGO_MD5; #ifdef _DEBUG da->algo_selected = true; #endif MHD_MD5_init_one_time (&da->ctx.md5_ctx); #ifdef _DEBUG da->ready_for_hashing = true; #endif return true; } #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT if (MHD_DIGEST_BASE_ALGO_SHA256 == algo) { da->algo = MHD_DIGEST_BASE_ALGO_SHA256; #ifdef _DEBUG da->algo_selected = true; #endif MHD_SHA256_init_one_time (&da->ctx.sha256_ctx); #ifdef _DEBUG da->ready_for_hashing = true; #endif return true; } #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT if (MHD_DIGEST_BASE_ALGO_SHA512_256 == algo) { da->algo = MHD_DIGEST_BASE_ALGO_SHA512_256; #ifdef _DEBUG da->algo_selected = true; #endif MHD_SHA512_256_init (&da->ctx.sha512_256_ctx); #ifdef _DEBUG da->ready_for_hashing = true; #endif return true; } #endif /* MHD_SHA512_256_SUPPORT */ da->algo = MHD_DIGEST_BASE_ALGO_INVALID; return false; /* Unsupported or bad algorithm */ } /** * Feed digest calculation with more data. * @param da the digest calculation * @param data the data to process * @param length the size of the @a data in bytes */ _MHD_static_inline void digest_update (struct DigestAlgorithm *da, const void *data, size_t length) { mhd_assert (! da->uninitialised); mhd_assert (da->algo_selected); mhd_assert (da->ready_for_hashing); #ifdef MHD_MD5_SUPPORT if (MHD_DIGEST_BASE_ALGO_MD5 == da->algo) MHD_MD5_update (&da->ctx.md5_ctx, (const uint8_t *) data, length); else #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT if (MHD_DIGEST_BASE_ALGO_SHA256 == da->algo) MHD_SHA256_update (&da->ctx.sha256_ctx, (const uint8_t *) data, length); else #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT if (MHD_DIGEST_BASE_ALGO_SHA512_256 == da->algo) MHD_SHA512_256_update (&da->ctx.sha512_256_ctx, (const uint8_t *) data, length); else #endif /* MHD_SHA512_256_SUPPORT */ mhd_assert (0); /* May not happen */ #ifdef _DEBUG da->hashing = true; #endif } /** * Feed digest calculation with more data from string. * @param da the digest calculation * @param str the zero-terminated string to process */ _MHD_static_inline void digest_update_str (struct DigestAlgorithm *da, const char *str) { const size_t str_len = strlen (str); digest_update (da, (const uint8_t *) str, str_len); } /** * Feed digest calculation with single colon ':' character. * @param da the digest calculation * @param str the zero-terminated string to process */ _MHD_static_inline void digest_update_with_colon (struct DigestAlgorithm *da) { static const uint8_t colon = (uint8_t) ':'; digest_update (da, &colon, 1); } /** * Finally calculate hash (the digest). * @param da the digest calculation * @param[out] digest the pointer to the buffer to put calculated digest, * must be at least digest_get_size(da) bytes large */ _MHD_static_inline void digest_calc_hash (struct DigestAlgorithm *da, uint8_t *digest) { mhd_assert (! da->uninitialised); mhd_assert (da->algo_selected); mhd_assert (da->ready_for_hashing); #ifdef MHD_MD5_SUPPORT if (MHD_DIGEST_BASE_ALGO_MD5 == da->algo) { #ifdef MHD_MD5_HAS_FINISH MHD_MD5_finish (&da->ctx.md5_ctx, digest); #ifdef _DEBUG da->ready_for_hashing = false; #endif /* _DEBUG */ #else /* ! MHD_MD5_HAS_FINISH */ MHD_MD5_finish_reset (&da->ctx.md5_ctx, digest); #ifdef _DEBUG da->ready_for_hashing = true; #endif /* _DEBUG */ #endif /* ! MHD_MD5_HAS_FINISH */ } else #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT if (MHD_DIGEST_BASE_ALGO_SHA256 == da->algo) { #ifdef MHD_SHA256_HAS_FINISH MHD_SHA256_finish (&da->ctx.sha256_ctx, digest); #ifdef _DEBUG da->ready_for_hashing = false; #endif /* _DEBUG */ #else /* ! MHD_SHA256_HAS_FINISH */ MHD_SHA256_finish_reset (&da->ctx.sha256_ctx, digest); #ifdef _DEBUG da->ready_for_hashing = true; #endif /* _DEBUG */ #endif /* ! MHD_SHA256_HAS_FINISH */ } else #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT if (MHD_DIGEST_BASE_ALGO_SHA512_256 == da->algo) { MHD_SHA512_256_finish (&da->ctx.sha512_256_ctx, digest); #ifdef _DEBUG da->ready_for_hashing = false; #endif /* _DEBUG */ } else #endif /* MHD_SHA512_256_SUPPORT */ mhd_assert (0); /* Should not happen */ #ifdef _DEBUG da->hashing = false; #endif /* _DEBUG */ } /** * Reset the digest calculation structure. * * @param da the structure to reset */ _MHD_static_inline void digest_reset (struct DigestAlgorithm *da) { mhd_assert (! da->uninitialised); mhd_assert (da->algo_selected); mhd_assert (! da->hashing); #ifdef MHD_MD5_SUPPORT if (MHD_DIGEST_BASE_ALGO_MD5 == da->algo) { #ifdef MHD_MD5_HAS_FINISH mhd_assert (! da->ready_for_hashing); #else /* ! MHD_MD5_HAS_FINISH */ mhd_assert (da->ready_for_hashing); #endif /* ! MHD_MD5_HAS_FINISH */ MHD_MD5_reset (&da->ctx.md5_ctx); #ifdef _DEBUG da->ready_for_hashing = true; #endif /* _DEBUG */ } else #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT if (MHD_DIGEST_BASE_ALGO_SHA256 == da->algo) { #ifdef MHD_SHA256_HAS_FINISH mhd_assert (! da->ready_for_hashing); #else /* ! MHD_SHA256_HAS_FINISH */ mhd_assert (da->ready_for_hashing); #endif /* ! MHD_SHA256_HAS_FINISH */ MHD_SHA256_reset (&da->ctx.sha256_ctx); #ifdef _DEBUG da->ready_for_hashing = true; #endif /* _DEBUG */ } else #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT if (MHD_DIGEST_BASE_ALGO_SHA512_256 == da->algo) { mhd_assert (! da->ready_for_hashing); MHD_SHA512_256_init (&da->ctx.sha512_256_ctx); #ifdef _DEBUG da->ready_for_hashing = true; #endif } else #endif /* MHD_SHA512_256_SUPPORT */ { #ifdef _DEBUG da->ready_for_hashing = false; #endif mhd_assert (0); /* May not happen, bad algorithm */ } } #if defined(MHD_MD5_HAS_EXT_ERROR) || defined(MHD_SHA256_HAS_EXT_ERROR) /** * Indicates that digest algorithm has external error status */ #define MHD_DIGEST_HAS_EXT_ERROR 1 #endif /* MHD_MD5_HAS_EXT_ERROR || MHD_SHA256_HAS_EXT_ERROR */ #ifdef MHD_DIGEST_HAS_EXT_ERROR /** * Get external error code. * * When external digest calculation used, an error may occur during * initialisation or hashing data. This function checks whether external * error has been reported for digest calculation. * @param da the digest calculation * @return true if external error occurs */ _MHD_static_inline bool digest_ext_error (struct DigestAlgorithm *da) { mhd_assert (! da->uninitialised); mhd_assert (da->algo_selected); #ifdef MHD_MD5_HAS_EXT_ERROR if (MHD_DIGEST_BASE_ALGO_MD5 == da->algo) return 0 != da->ctx.md5_ctx.ext_error; #endif /* MHD_MD5_HAS_EXT_ERROR */ #ifdef MHD_SHA256_HAS_EXT_ERROR if (MHD_DIGEST_BASE_ALGO_SHA256 == da->algo) return 0 != da->ctx.sha256_ctx.ext_error; #endif /* MHD_MD5_HAS_EXT_ERROR */ return false; } #else /* ! MHD_DIGEST_HAS_EXT_ERROR */ #define digest_ext_error(da) (false) #endif /* ! MHD_DIGEST_HAS_EXT_ERROR */ /** * Extract timestamp from the given nonce. * @param nonce the nonce to check * @param noncelen the length of the nonce, zero for autodetect * @param[out] ptimestamp the pointer to store extracted timestamp * @return true if timestamp was extracted, * false if nonce does not have valid timestamp. */ static bool get_nonce_timestamp (const char *const nonce, size_t noncelen, uint64_t *const ptimestamp) { if (0 == noncelen) noncelen = strlen (nonce); if (true #ifdef MHD_MD5_SUPPORT && (NONCE_STD_LEN (MD5_DIGEST_SIZE) != noncelen) #endif /* MHD_MD5_SUPPORT */ #if defined(MHD_SHA256_SUPPORT) || defined(MHD_SHA512_256_SUPPORT) && (NONCE_STD_LEN (SHA256_SHA512_256_DIGEST_SIZE) != noncelen) #endif /* MHD_SHA256_SUPPORT */ ) return false; if (TIMESTAMP_CHARS_LEN != MHD_strx_to_uint64_n_ (nonce + noncelen - TIMESTAMP_CHARS_LEN, TIMESTAMP_CHARS_LEN, ptimestamp)) return false; return true; } MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ /** * Super-fast xor-based "hash" function * * @param data the data to calculate hash for * @param data_size the size of the data in bytes * @return the "hash" */ static uint32_t fast_simple_hash (const uint8_t *data, size_t data_size) { uint32_t hash; if (0 != data_size) { size_t i; hash = data[0]; for (i = 1; i < data_size; i++) hash = _MHD_ROTL32 (hash, 7) ^ data[i]; } else hash = 0; return hash; } MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ /** * Get index of the nonce in the nonce-nc map array. * * @param arr_size the size of nonce_nc array * @param nonce the pointer that referenced a zero-terminated array of nonce * @param noncelen the length of @a nonce, in characters * @return #MHD_YES if successful, #MHD_NO if invalid (or we have no NC array) */ static size_t get_nonce_nc_idx (size_t arr_size, const char *nonce, size_t noncelen) { mhd_assert (0 != arr_size); mhd_assert (0 != noncelen); return fast_simple_hash ((const uint8_t *) nonce, noncelen) % arr_size; } /** * Check nonce-nc map array with the new nonce counter. * * @param connection The MHD connection structure * @param nonce the pointer that referenced hex nonce, does not need to be * zero-terminated * @param noncelen the length of @a nonce, in characters * @param nc The nonce counter * @return #MHD_DAUTH_NONCENC_OK if successful, * #MHD_DAUTH_NONCENC_STALE if nonce is stale (or no nonce-nc array * is available), * #MHD_DAUTH_NONCENC_WRONG if nonce was not recodered in nonce-nc map * array, while it should. */ static enum MHD_CheckNonceNC_ check_nonce_nc (struct MHD_Connection *connection, const char *nonce, size_t noncelen, uint64_t nonce_time, uint64_t nc) { struct MHD_Daemon *daemon = MHD_get_master (connection->daemon); struct MHD_NonceNc *nn; uint32_t mod; enum MHD_CheckNonceNC_ ret; mhd_assert (0 != noncelen); mhd_assert (0 != nc); if (MAX_DIGEST_NONCE_LENGTH < noncelen) return MHD_CHECK_NONCENC_WRONG; /* This should be impossible, but static analysis tools have a hard time with it *and* this also protects against unsafe modifications that may happen in the future... */ mod = daemon->nonce_nc_size; if (0 == mod) return MHD_CHECK_NONCENC_STALE; /* no array! */ if (nc >= UINT32_MAX - 64) return MHD_CHECK_NONCENC_STALE; /* Overflow, unrealistically high value */ nn = &daemon->nnc[get_nonce_nc_idx (mod, nonce, noncelen)]; MHD_mutex_lock_chk_ (&daemon->nnc_lock); mhd_assert (0 == nn->nonce[noncelen]); /* The old value must be valid */ if ( (0 != memcmp (nn->nonce, nonce, noncelen)) || (0 != nn->nonce[noncelen]) ) { /* The nonce in the slot does not match nonce from the client */ if (0 == nn->nonce[0]) { /* The slot was never used, while the client's nonce value should be * recorded when it was generated by MHD */ ret = MHD_CHECK_NONCENC_WRONG; } else if (0 != nn->nonce[noncelen]) { /* The value is the slot is wrong */ ret = MHD_CHECK_NONCENC_STALE; } else { uint64_t slot_ts; /**< The timestamp in the slot */ if (! get_nonce_timestamp (nn->nonce, noncelen, &slot_ts)) { mhd_assert (0); /* The value is the slot is wrong */ ret = MHD_CHECK_NONCENC_STALE; } else { /* Unsigned value, will be large if nonce_time is less than slot_ts */ const uint64_t ts_diff = TRIM_TO_TIMESTAMP (nonce_time - slot_ts); if ((REUSE_TIMEOUT * 1000) >= ts_diff) { /* The nonce from the client may not have been placed in the slot * because another nonce in that slot has not yet expired. */ ret = MHD_CHECK_NONCENC_STALE; } else if (TRIM_TO_TIMESTAMP (UINT64_MAX) / 2 >= ts_diff) { /* Too large value means that nonce_time is less than slot_ts. * The nonce from the client may have been overwritten by the newer * nonce. */ ret = MHD_CHECK_NONCENC_STALE; } else { /* The nonce from the client should be generated after the nonce * in the slot has been expired, the nonce must be recorded, but * it's not. */ ret = MHD_CHECK_NONCENC_WRONG; } } } } else if (nc > nn->nc) { /* 'nc' is larger, shift bitmask and bump limit */ const uint32_t jump_size = (uint32_t) nc - nn->nc; if (64 > jump_size) { /* small jump, less than mask width */ nn->nmask <<= jump_size; /* Set bit for the old 'nc' value */ nn->nmask |= (UINT64_C (1) << (jump_size - 1)); } else if (64 == jump_size) nn->nmask = (UINT64_C (1) << 63); else nn->nmask = 0; /* big jump, unset all bits in the mask */ nn->nc = (uint32_t) nc; ret = MHD_CHECK_NONCENC_OK; } else if (nc < nn->nc) { /* Note that we use 64 here, as we do not store the bit for 'nn->nc' itself in 'nn->nmask' */ if ( (nc + 64 >= nn->nc) && (0 == ((UINT64_C (1) << (nn->nc - nc - 1)) & nn->nmask)) ) { /* Out-of-order nonce, but within 64-bit bitmask, set bit */ nn->nmask |= (UINT64_C (1) << (nn->nc - nc - 1)); ret = MHD_CHECK_NONCENC_OK; } else /* 'nc' was already used or too old (more then 64 values ago) */ ret = MHD_CHECK_NONCENC_STALE; } else /* if (nc == nn->nc) */ /* 'nc' was already used */ ret = MHD_CHECK_NONCENC_STALE; MHD_mutex_unlock_chk_ (&daemon->nnc_lock); return ret; } /** * Get username type used by the client. * This function does not check whether userhash can be decoded or * extended notation (if used) is valid. * @param params the Digest Authorization parameters * @return the type of username */ _MHD_static_inline enum MHD_DigestAuthUsernameType get_rq_uname_type (const struct MHD_RqDAuth *params) { if (NULL != params->username.value.str) { if (NULL == params->username_ext.value.str) return params->userhash ? MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH : MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD; else /* Both 'username' and 'username*' are used */ return MHD_DIGEST_AUTH_UNAME_TYPE_INVALID; } else if (NULL != params->username_ext.value.str) { if (! params->username_ext.quoted && ! params->userhash && (MHD_DAUTH_EXT_PARAM_MIN_LEN <= params->username_ext.value.len) ) return MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED; else return MHD_DIGEST_AUTH_UNAME_TYPE_INVALID; } return MHD_DIGEST_AUTH_UNAME_TYPE_MISSING; } /** * Get total size required for 'username' and 'userhash_bin' * @param params the Digest Authorization parameters * @param uname_type the type of username * @return the total size required for 'username' and * 'userhash_bin' is userhash is used */ _MHD_static_inline size_t get_rq_unames_size (const struct MHD_RqDAuth *params, enum MHD_DigestAuthUsernameType uname_type) { size_t s; mhd_assert (get_rq_uname_type (params) == uname_type); s = 0; if ((MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD == uname_type) || (MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH == uname_type) ) { s += params->username.value.len + 1; /* Add one byte for zero-termination */ if (MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH == uname_type) s += (params->username.value.len + 1) / 2; } else if (MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED == uname_type) s += params->username_ext.value.len - MHD_DAUTH_EXT_PARAM_MIN_LEN + 1; /* Add one byte for zero-termination */ return s; } /** * Get unquoted version of Digest Authorization parameter. * This function automatically zero-teminate the result. * @param param the parameter to extract * @param[out] buf the output buffer, must be enough size to hold the result, * the recommended size is 'param->value.len + 1' * @return the size of the result, not including the terminating zero */ static size_t get_rq_param_unquoted_copy_z (const struct MHD_RqDAuthParam *param, char *buf) { size_t len; mhd_assert (NULL != param->value.str); if (! param->quoted) { memcpy (buf, param->value.str, param->value.len); buf [param->value.len] = 0; return param->value.len; } len = MHD_str_unquote (param->value.str, param->value.len, buf); mhd_assert (0 != len); mhd_assert (len < param->value.len); buf[len] = 0; return len; } /** * Get decoded version of username from extended notation. * This function automatically zero-teminate the result. * @param uname_ext the string of client's 'username*' parameter value * @param uname_ext_len the length of @a uname_ext in chars * @param[out] buf the output buffer to put decoded username value * @param buf_size the size of @a buf * @return the number of characters copied to the output buffer or * -1 if wrong extended notation is used. */ static ssize_t get_rq_extended_uname_copy_z (const char *uname_ext, size_t uname_ext_len, char *buf, size_t buf_size) { size_t r; size_t w; if ((size_t) SSIZE_MAX < uname_ext_len) return -1; /* Too long input string */ if (MHD_DAUTH_EXT_PARAM_MIN_LEN > uname_ext_len) return -1; /* Required prefix is missing */ if (! MHD_str_equal_caseless_bin_n_ (uname_ext, MHD_DAUTH_EXT_PARAM_PREFIX, MHD_STATICSTR_LEN_ ( \ MHD_DAUTH_EXT_PARAM_PREFIX))) return -1; /* Only UTF-8 is supported, as it is implied by RFC 7616 */ r = MHD_STATICSTR_LEN_ (MHD_DAUTH_EXT_PARAM_PREFIX); /* Skip language tag */ while (r < uname_ext_len && '\'' != uname_ext[r]) { const char chr = uname_ext[r]; if ((' ' == chr) || ('\t' == chr) || ('\"' == chr) || (',' == chr) || (';' == chr) ) return -1; /* Wrong char in language tag */ r++; } if (r >= uname_ext_len) return -1; /* The end of the language tag was not found */ r++; /* Advance to the next char */ w = MHD_str_pct_decode_strict_n_ (uname_ext + r, uname_ext_len - r, buf, buf_size); if ((0 == w) && (0 != uname_ext_len - r)) return -1; /* Broken percent encoding */ buf[w] = 0; /* Zero terminate the result */ mhd_assert (SSIZE_MAX > w); return (ssize_t) w; } /** * Get copy of username used by the client. * @param params the Digest Authorization parameters * @param uname_type the type of username * @param[out] uname_info the pointer to the structure to be filled * @param buf the buffer to be used for usernames * @param buf_size the size of the @a buf * @return the size of the @a buf used by pointers in @a unames structure */ static size_t get_rq_uname (const struct MHD_RqDAuth *params, enum MHD_DigestAuthUsernameType uname_type, struct MHD_DigestAuthUsernameInfo *uname_info, uint8_t *buf, size_t buf_size) { size_t buf_used; buf_used = 0; mhd_assert (get_rq_uname_type (params) == uname_type); mhd_assert (MHD_DIGEST_AUTH_UNAME_TYPE_INVALID != uname_type); mhd_assert (MHD_DIGEST_AUTH_UNAME_TYPE_MISSING != uname_type); uname_info->username = NULL; uname_info->username_len = 0; uname_info->userhash_hex = NULL; uname_info->userhash_hex_len = 0; uname_info->userhash_bin = NULL; if (MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD == uname_type) { uname_info->username = (char *) (buf + buf_used); uname_info->username_len = get_rq_param_unquoted_copy_z (¶ms->username, uname_info->username); buf_used += uname_info->username_len + 1; uname_info->uname_type = MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD; } else if (MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH == uname_type) { size_t res; uname_info->userhash_hex = (char *) (buf + buf_used); uname_info->userhash_hex_len = get_rq_param_unquoted_copy_z (¶ms->username, uname_info->userhash_hex); buf_used += uname_info->userhash_hex_len + 1; uname_info->userhash_bin = (uint8_t *) (buf + buf_used); res = MHD_hex_to_bin (uname_info->userhash_hex, uname_info->userhash_hex_len, uname_info->userhash_bin); if (res != uname_info->userhash_hex_len / 2) { uname_info->userhash_bin = NULL; uname_info->uname_type = MHD_DIGEST_AUTH_UNAME_TYPE_INVALID; } else { /* Avoid pointers outside allocated region when the size is zero */ if (0 == res) uname_info->userhash_bin = (uint8_t *) uname_info->username; uname_info->uname_type = MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH; buf_used += res; } } else if (MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED == uname_type) { ssize_t res; res = get_rq_extended_uname_copy_z (params->username_ext.value.str, params->username_ext.value.len, (char *) (buf + buf_used), buf_size - buf_used); if (0 > res) uname_info->uname_type = MHD_DIGEST_AUTH_UNAME_TYPE_INVALID; else { uname_info->username = (char *) (buf + buf_used); uname_info->username_len = (size_t) res; uname_info->uname_type = MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED; buf_used += uname_info->username_len + 1; } } else { mhd_assert (0); uname_info->uname_type = MHD_DIGEST_AUTH_UNAME_TYPE_INVALID; } mhd_assert (buf_size >= buf_used); return buf_used; } /** * Result of request's Digest Authorization 'nc' value extraction */ enum MHD_GetRqNCResult { MHD_GET_RQ_NC_NONE = -1, /**< No 'nc' value */ MHD_GET_RQ_NC_VALID = 0, /**< Readable 'nc' value */ MHD_GET_RQ_NC_TOO_LONG = 1, /**< The 'nc' value is too long */ MHD_GET_RQ_NC_TOO_LARGE = 2,/**< The 'nc' value is too big to fit uint32_t */ MHD_GET_RQ_NC_BROKEN = 3 /**< The 'nc' value is not a number */ }; /** * Get 'nc' value from request's Authorization header * @param params the request digest authentication * @param[out] nc the pointer to put nc value to * @return enum value indicating the result */ static enum MHD_GetRqNCResult get_rq_nc (const struct MHD_RqDAuth *params, uint32_t *nc) { const struct MHD_RqDAuthParam *const nc_param = ¶ms->nc; char unq[16]; const char *val; size_t val_len; size_t res; uint64_t nc_val; if (NULL == nc_param->value.str) return MHD_GET_RQ_NC_NONE; if (0 == nc_param->value.len) return MHD_GET_RQ_NC_BROKEN; if (! nc_param->quoted) { val = nc_param->value.str; val_len = nc_param->value.len; } else { /* Actually no backslashes must be used in 'nc' */ if (sizeof(unq) < params->nc.value.len) return MHD_GET_RQ_NC_TOO_LONG; val_len = MHD_str_unquote (nc_param->value.str, nc_param->value.len, unq); if (0 == val_len) return MHD_GET_RQ_NC_BROKEN; val = unq; } res = MHD_strx_to_uint64_n_ (val, val_len, &nc_val); if (0 == res) { const char f = val[0]; if ( (('9' >= f) && ('0' <= f)) || (('F' >= f) && ('A' <= f)) || (('a' <= f) && ('f' >= f)) ) return MHD_GET_RQ_NC_TOO_LARGE; else return MHD_GET_RQ_NC_BROKEN; } if (val_len != res) return MHD_GET_RQ_NC_BROKEN; if (UINT32_MAX < nc_val) return MHD_GET_RQ_NC_TOO_LARGE; *nc = (uint32_t) nc_val; return MHD_GET_RQ_NC_VALID; } /** * Get information about Digest Authorization client's header. * * @param connection The MHD connection structure * @return NULL no valid Digest Authorization header is used in the request; * a pointer structure with information if the valid request header * found, free using #MHD_free(). * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN struct MHD_DigestAuthInfo * MHD_digest_auth_get_request_info3 (struct MHD_Connection *connection) { const struct MHD_RqDAuth *params; struct MHD_DigestAuthInfo *info; enum MHD_DigestAuthUsernameType uname_type; size_t unif_buf_size; uint8_t *unif_buf_ptr; size_t unif_buf_used; enum MHD_GetRqNCResult nc_res; params = MHD_get_rq_dauth_params_ (connection); if (NULL == params) return NULL; unif_buf_size = 0; uname_type = get_rq_uname_type (params); unif_buf_size += get_rq_unames_size (params, uname_type); if (NULL != params->opaque.value.str) unif_buf_size += params->opaque.value.len + 1; /* Add one for zero-termination */ if (NULL != params->realm.value.str) unif_buf_size += params->realm.value.len + 1; /* Add one for zero-termination */ info = (struct MHD_DigestAuthInfo *) MHD_calloc_ (1, (sizeof(struct MHD_DigestAuthInfo)) + unif_buf_size); unif_buf_ptr = (uint8_t *) (info + 1); unif_buf_used = 0; info->algo3 = params->algo3; if ( (MHD_DIGEST_AUTH_UNAME_TYPE_MISSING != uname_type) && (MHD_DIGEST_AUTH_UNAME_TYPE_INVALID != uname_type) ) unif_buf_used += get_rq_uname (params, uname_type, (struct MHD_DigestAuthUsernameInfo *) info, unif_buf_ptr + unif_buf_used, unif_buf_size - unif_buf_used); else info->uname_type = uname_type; if (NULL != params->opaque.value.str) { info->opaque = (char *) (unif_buf_ptr + unif_buf_used); info->opaque_len = get_rq_param_unquoted_copy_z (¶ms->opaque, info->opaque); unif_buf_used += info->opaque_len + 1; } if (NULL != params->realm.value.str) { info->realm = (char *) (unif_buf_ptr + unif_buf_used); info->realm_len = get_rq_param_unquoted_copy_z (¶ms->realm, info->realm); unif_buf_used += info->realm_len + 1; } mhd_assert (unif_buf_size >= unif_buf_used); info->qop = params->qop; if (NULL != params->cnonce.value.str) info->cnonce_len = params->cnonce.value.len; else info->cnonce_len = 0; nc_res = get_rq_nc (params, &info->nc); if (MHD_GET_RQ_NC_VALID != nc_res) info->nc = MHD_DIGEST_AUTH_INVALID_NC_VALUE; return info; } /** * Get the username from Digest Authorization client's header. * * @param connection The MHD connection structure * @return NULL if no valid Digest Authorization header is used in the request, * or no username parameter is present in the header, or username is * provided incorrectly by client (see description for * #MHD_DIGEST_AUTH_UNAME_TYPE_INVALID); * a pointer structure with information if the valid request header * found, free using #MHD_free(). * @sa MHD_digest_auth_get_request_info3() provides more complete information * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN struct MHD_DigestAuthUsernameInfo * MHD_digest_auth_get_username3 (struct MHD_Connection *connection) { const struct MHD_RqDAuth *params; struct MHD_DigestAuthUsernameInfo *uname_info; enum MHD_DigestAuthUsernameType uname_type; size_t unif_buf_size; uint8_t *unif_buf_ptr; size_t unif_buf_used; params = MHD_get_rq_dauth_params_ (connection); if (NULL == params) return NULL; uname_type = get_rq_uname_type (params); if ( (MHD_DIGEST_AUTH_UNAME_TYPE_MISSING == uname_type) || (MHD_DIGEST_AUTH_UNAME_TYPE_INVALID == uname_type) ) return NULL; unif_buf_size = get_rq_unames_size (params, uname_type); uname_info = (struct MHD_DigestAuthUsernameInfo *) MHD_calloc_ (1, (sizeof(struct MHD_DigestAuthUsernameInfo)) + unif_buf_size); unif_buf_ptr = (uint8_t *) (uname_info + 1); unif_buf_used = get_rq_uname (params, uname_type, uname_info, unif_buf_ptr, unif_buf_size); mhd_assert (unif_buf_size >= unif_buf_used); (void) unif_buf_used; /* Mute compiler warning on non-debug builds */ mhd_assert (MHD_DIGEST_AUTH_UNAME_TYPE_MISSING != uname_info->uname_type); if (MHD_DIGEST_AUTH_UNAME_TYPE_INVALID == uname_info->uname_type) { free (uname_info); return NULL; } mhd_assert (uname_type == uname_info->uname_type); uname_info->algo3 = params->algo3; return uname_info; } /** * Get the username from the authorization header sent by the client * * This function supports username in standard and extended notations. * "userhash" is not supported by this function. * * @param connection The MHD connection structure * @return NULL if no username could be found, username provided as * "userhash", extended notation broken or memory allocation error * occurs; * a pointer to the username if found, free using #MHD_free(). * @warning Returned value must be freed by #MHD_free(). * @sa #MHD_digest_auth_get_username3() * @ingroup authentication */ _MHD_EXTERN char * MHD_digest_auth_get_username (struct MHD_Connection *connection) { const struct MHD_RqDAuth *params; char *username; size_t buf_size; enum MHD_DigestAuthUsernameType uname_type; params = MHD_get_rq_dauth_params_ (connection); if (NULL == params) return NULL; uname_type = get_rq_uname_type (params); if ( (MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD != uname_type) && (MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED != uname_type) ) return NULL; buf_size = get_rq_unames_size (params, uname_type); mhd_assert (0 != buf_size); username = (char *) MHD_calloc_ (1, buf_size); if (NULL == username) return NULL; if (1) { struct MHD_DigestAuthUsernameInfo uname_strct; size_t used; memset (&uname_strct, 0, sizeof(uname_strct)); used = get_rq_uname (params, uname_type, &uname_strct, (uint8_t *) username, buf_size); if (uname_type != uname_strct.uname_type) { /* Broken encoding for extended notation */ free (username); return NULL; } (void) used; /* Mute compiler warning for non-debug builds */ mhd_assert (buf_size >= used); } return username; } /** * Calculate the server nonce so that it mitigates replay attacks * The current format of the nonce is ... * H(timestamp:random data:various parameters) + Hex(timestamp) * * @param nonce_time The amount of time in seconds for a nonce to be invalid * @param mthd_e HTTP method as enum value * @param method HTTP method as a string * @param rnd the pointer to a character array for the random seed * @param rnd_size The size of the random seed array @a rnd * @param saddr the pointer to the socket address structure * @param saddr_size the size of the socket address structure @a saddr * @param uri the HTTP URI (in MHD, without the arguments ("?k=v") * @param uri_len the length of the @a uri * @param first_header the pointer to the first request's header * @param realm A string of characters that describes the realm of auth. * @param realm_len the length of the @a realm. * @param bind_options the nonce bind options (#MHD_DAuthBindNonce values). * @param da digest algorithm to use * @param[out] nonce the pointer to a character array for the nonce to put in, * must provide NONCE_STD_LEN(digest_get_size(da)) bytes, * result is NOT zero-terminated */ static void calculate_nonce (uint64_t nonce_time, enum MHD_HTTP_Method mthd_e, const char *method, const char *rnd, size_t rnd_size, const struct sockaddr_storage *saddr, size_t saddr_size, const char *uri, size_t uri_len, const struct MHD_HTTP_Req_Header *first_header, const char *realm, size_t realm_len, unsigned int bind_options, struct DigestAlgorithm *da, char *nonce) { mhd_assert (! da->hashing); if (1) { /* Add the timestamp to the hash calculation */ uint8_t timestamp[TIMESTAMP_BIN_SIZE]; /* If the nonce_time is milliseconds, then the same 48 bit value will repeat * every 8 919 years, which is more than enough to mitigate a replay attack */ #if TIMESTAMP_BIN_SIZE != 6 #error The code needs to be updated here #endif timestamp[0] = (uint8_t) (nonce_time >> (8 * (TIMESTAMP_BIN_SIZE - 1 - 0))); timestamp[1] = (uint8_t) (nonce_time >> (8 * (TIMESTAMP_BIN_SIZE - 1 - 1))); timestamp[2] = (uint8_t) (nonce_time >> (8 * (TIMESTAMP_BIN_SIZE - 1 - 2))); timestamp[3] = (uint8_t) (nonce_time >> (8 * (TIMESTAMP_BIN_SIZE - 1 - 3))); timestamp[4] = (uint8_t) (nonce_time >> (8 * (TIMESTAMP_BIN_SIZE - 1 - 4))); timestamp[5] = (uint8_t) (nonce_time >> (8 * (TIMESTAMP_BIN_SIZE - 1 - 5))); MHD_bin_to_hex (timestamp, sizeof (timestamp), nonce + digest_get_size (da) * 2); digest_update (da, timestamp, sizeof (timestamp)); } if (rnd_size > 0) { /* Add the unique random value to the hash calculation */ digest_update_with_colon (da); digest_update (da, rnd, rnd_size); } if ( (MHD_DAUTH_BIND_NONCE_NONE == bind_options) && (0 != saddr_size) ) { /* Add full client address including source port to make unique nonces * for requests received exactly at the same time */ digest_update_with_colon (da); digest_update (da, saddr, saddr_size); } if ( (0 != (bind_options & MHD_DAUTH_BIND_NONCE_CLIENT_IP)) && (0 != saddr_size) ) { /* Add the client's IP address to the hash calculation */ digest_update_with_colon (da); if (AF_INET == saddr->ss_family) digest_update (da, &((const struct sockaddr_in *) saddr)->sin_addr, sizeof(((const struct sockaddr_in *) saddr)->sin_addr)); #ifdef HAVE_INET6 else if (AF_INET6 == saddr->ss_family) digest_update (da, &((const struct sockaddr_in6 *) saddr)->sin6_addr, sizeof(((const struct sockaddr_in6 *) saddr)->sin6_addr)); #endif /* HAVE_INET6 */ } if ( (MHD_DAUTH_BIND_NONCE_NONE == bind_options) || (0 != (bind_options & MHD_DAUTH_BIND_NONCE_URI))) { /* Add the request method to the hash calculation */ digest_update_with_colon (da); if (MHD_HTTP_MTHD_OTHER != mthd_e) { uint8_t mthd_for_hash; if (MHD_HTTP_MTHD_HEAD != mthd_e) mthd_for_hash = (uint8_t) mthd_e; else /* Treat HEAD method in the same way as GET method */ mthd_for_hash = (uint8_t) MHD_HTTP_MTHD_GET; digest_update (da, &mthd_for_hash, sizeof(mthd_for_hash)); } else digest_update_str (da, method); } if (0 != (bind_options & MHD_DAUTH_BIND_NONCE_URI)) { /* Add the request URI to the hash calculation */ digest_update_with_colon (da); digest_update (da, uri, uri_len); } if (0 != (bind_options & MHD_DAUTH_BIND_NONCE_URI_PARAMS)) { /* Add the request URI parameters to the hash calculation */ const struct MHD_HTTP_Req_Header *h; digest_update_with_colon (da); for (h = first_header; NULL != h; h = h->next) { if (MHD_GET_ARGUMENT_KIND != h->kind) continue; digest_update (da, "\0", 2); if (0 != h->header_size) digest_update (da, h->header, h->header_size); digest_update (da, "", 1); if (0 != h->value_size) digest_update (da, h->value, h->value_size); } } if ( (MHD_DAUTH_BIND_NONCE_NONE == bind_options) || (0 != (bind_options & MHD_DAUTH_BIND_NONCE_REALM))) { /* Add the realm to the hash calculation */ digest_update_with_colon (da); digest_update (da, realm, realm_len); } if (1) { uint8_t hash[MAX_DIGEST]; digest_calc_hash (da, hash); MHD_bin_to_hex (hash, digest_get_size (da), nonce); } } /** * Check whether it is possible to use slot in nonce-nc map array. * * Should be called with mutex held to avoid external modification of * the slot data. * * @param nn the pointer to the nonce-nc slot * @param now the current time * @param new_nonce the new nonce supposed to be stored in this slot, * zero-terminated * @param new_nonce_len the length of the @a new_nonce in chars, not including * the terminating zero. * @return true if the slot can be used to store the new nonce, * false otherwise. */ static bool is_slot_available (const struct MHD_NonceNc *const nn, const uint64_t now, const char *const new_nonce, size_t new_nonce_len) { uint64_t timestamp; bool timestamp_valid; mhd_assert (new_nonce_len <= NONCE_STD_LEN (MAX_DIGEST)); mhd_assert (NONCE_STD_LEN (MAX_DIGEST) <= MAX_DIGEST_NONCE_LENGTH); if (0 == nn->nonce[0]) return true; /* The slot is empty */ if (0 == memcmp (nn->nonce, new_nonce, new_nonce_len)) { /* The slot has the same nonce already. This nonce cannot be registered * again as it would just clear 'nc' usage history. */ return false; } if (0 != nn->nc) return true; /* Client already used the nonce in this slot at least one time, re-use the slot */ /* The nonce must be zero-terminated */ mhd_assert (0 == nn->nonce[sizeof(nn->nonce) - 1]); if (0 != nn->nonce[sizeof(nn->nonce) - 1]) return true; /* Wrong nonce format in the slot */ timestamp_valid = get_nonce_timestamp (nn->nonce, 0, ×tamp); mhd_assert (timestamp_valid); if (! timestamp_valid) return true; /* Invalid timestamp in nonce-nc, should not be possible */ if ((REUSE_TIMEOUT * 1000) < TRIM_TO_TIMESTAMP (now - timestamp)) return true; return false; } /** * Calculate the server nonce so that it mitigates replay attacks and add * the new nonce to the nonce-nc map array. * * @param connection the MHD connection structure * @param timestamp the current timestamp * @param realm the string of characters that describes the realm of auth * @param realm_len the length of the @a realm * @param da the digest algorithm to use * @param[out] nonce the pointer to a character array for the nonce to put in, * must provide NONCE_STD_LEN(digest_get_size(da)) bytes, * result is NOT zero-terminated * @return true if the new nonce has been added to the nonce-nc map array, * false otherwise. */ static bool calculate_add_nonce (struct MHD_Connection *const connection, uint64_t timestamp, const char *realm, size_t realm_len, struct DigestAlgorithm *da, char *nonce) { struct MHD_Daemon *const daemon = MHD_get_master (connection->daemon); struct MHD_NonceNc *nn; const size_t nonce_size = NONCE_STD_LEN (digest_get_size (da)); bool ret; mhd_assert (! da->hashing); mhd_assert (MAX_DIGEST_NONCE_LENGTH >= nonce_size); mhd_assert (0 != nonce_size); calculate_nonce (timestamp, connection->rq.http_mthd, connection->rq.method, daemon->digest_auth_random, daemon->digest_auth_rand_size, connection->addr, (size_t) connection->addr_len, connection->rq.url, connection->rq.url_len, connection->rq.headers_received, realm, realm_len, daemon->dauth_bind_type, da, nonce); #ifdef MHD_DIGEST_HAS_EXT_ERROR if (digest_ext_error (da)) return false; #endif /* MHD_DIGEST_HAS_EXT_ERROR */ if (0 == daemon->nonce_nc_size) return false; /* Sanity check for values */ mhd_assert (MAX_DIGEST_NONCE_LENGTH == NONCE_STD_LEN (MAX_DIGEST)); nn = daemon->nnc + get_nonce_nc_idx (daemon->nonce_nc_size, nonce, nonce_size); MHD_mutex_lock_chk_ (&daemon->nnc_lock); if (is_slot_available (nn, timestamp, nonce, nonce_size)) { memcpy (nn->nonce, nonce, nonce_size); nn->nonce[nonce_size] = 0; /* With terminating zero */ nn->nc = 0; nn->nmask = 0; ret = true; } else ret = false; MHD_mutex_unlock_chk_ (&daemon->nnc_lock); return ret; } MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ /** * Calculate the server nonce so that it mitigates replay attacks and add * the new nonce to the nonce-nc map array. * * @param connection the MHD connection structure * @param realm A string of characters that describes the realm of auth. * @param da digest algorithm to use * @param[out] nonce the pointer to a character array for the nonce to put in, * must provide NONCE_STD_LEN(digest_get_size(da)) bytes, * result is NOT zero-terminated */ static bool calculate_add_nonce_with_retry (struct MHD_Connection *const connection, const char *realm, struct DigestAlgorithm *da, char *nonce) { const uint64_t timestamp1 = MHD_monotonic_msec_counter (); const size_t realm_len = strlen (realm); mhd_assert (! da->hashing); #ifdef HAVE_MESSAGES if (0 == MHD_get_master (connection->daemon)->digest_auth_rand_size) MHD_DLOG (connection->daemon, _ ("Random value was not initialised by " \ "MHD_OPTION_DIGEST_AUTH_RANDOM or " \ "MHD_OPTION_DIGEST_AUTH_RANDOM_COPY, generated nonces " \ "are predictable.\n")); #endif if (! calculate_add_nonce (connection, timestamp1, realm, realm_len, da, nonce)) { /* Either: * 1. The same nonce was already generated. If it will be used then one * of the clients will fail (as no initial 'nc' value could be given to * the client, the second client which will use 'nc=00000001' will fail). * 2. Another nonce uses the same slot, and this nonce never has been * used by the client and this nonce is still fresh enough. */ const size_t digest_size = digest_get_size (da); char nonce2[NONCE_STD_LEN (MAX_DIGEST) + 1]; uint64_t timestamp2; #ifdef MHD_DIGEST_HAS_EXT_ERROR if (digest_ext_error (da)) return false; /* No need to re-try */ #endif /* MHD_DIGEST_HAS_EXT_ERROR */ if (0 == MHD_get_master (connection->daemon)->nonce_nc_size) return false; /* No need to re-try */ timestamp2 = MHD_monotonic_msec_counter (); if (timestamp1 == timestamp2) { /* The timestamps are equal, need to generate some arbitrary * difference for nonce. */ /* As the number is needed only to differentiate clients, weak * pseudo-random generators could be used. Seeding is not needed. */ uint64_t base1; uint32_t base2; uint16_t base3; uint8_t base4; #ifdef HAVE_RANDOM base1 = ((uint64_t) random ()) ^ UINT64_C (0x54a5acff5be47e63); base4 = 0xb8; #elif defined(HAVE_RAND) base1 = ((uint64_t) rand ()) ^ UINT64_C (0xc4bcf553b12f3965); base4 = 0x92; #else /* Monotonic msec counter alone does not really help here as it is already known that this value is not unique. */ base1 = ((uint64_t) (uintptr_t) nonce2) ^ UINT64_C (0xf2e1b21bc6c92655); base2 = ((uint32_t) (base1 >> 32)) ^ ((uint32_t) base1); base2 = _MHD_ROTR32 (base2, 4); base3 = ((uint16_t) (base2 >> 16)) ^ ((uint16_t) base2); base4 = ((uint8_t) (base3 >> 8)) ^ ((uint8_t) base3); base1 = ((uint64_t) MHD_monotonic_msec_counter ()) ^ UINT64_C (0xccab93f72cf5b15); #endif base2 = ((uint32_t) (base1 >> 32)) ^ ((uint32_t) base1); base2 = _MHD_ROTL32 (base2, (((base4 >> 4) ^ base4) % 32)); base3 = ((uint16_t) (base2 >> 16)) ^ ((uint16_t) base2); base4 = ((uint8_t) (base3 >> 8)) ^ ((uint8_t) base3); /* Use up to 127 ms difference */ timestamp2 -= (base4 & DAUTH_JUMPBACK_MAX); if (timestamp1 == timestamp2) timestamp2 -= 2; /* Fallback value */ } digest_reset (da); if (! calculate_add_nonce (connection, timestamp2, realm, realm_len, da, nonce2)) { /* No free slot has been found. Re-tries are expensive, just use * the generated nonce. As it is not stored in nonce-nc map array, * the next request of the client will be recognized as valid, but 'stale' * so client should re-try automatically. */ return false; } memcpy (nonce, nonce2, NONCE_STD_LEN (digest_size)); } return true; } MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ /** * Calculate userdigest, return it as binary data. * * It is equal to H(A1) for non-session algorithms. * * MHD internal version. * * @param da the digest algorithm * @param username the username to use * @param username_len the length of the @a username * @param realm the realm to use * @param realm_len the length of the @a realm * @param password the password, must be zero-terminated * @param[out] ha1_bin the output buffer, must have at least * #digest_get_size(da) bytes available */ _MHD_static_inline void calc_userdigest (struct DigestAlgorithm *da, const char *username, const size_t username_len, const char *realm, const size_t realm_len, const char *password, uint8_t *ha1_bin) { mhd_assert (! da->hashing); digest_update (da, username, username_len); digest_update_with_colon (da); digest_update (da, realm, realm_len); digest_update_with_colon (da); digest_update_str (da, password); digest_calc_hash (da, ha1_bin); } /** * Calculate userdigest, return it as a binary data. * * The "userdigest" is the hash of the "username:realm:password" string. * * The "userdigest" can be used to avoid storing the password in clear text * in database/files * * This function is designed to improve security of stored credentials, * the "userdigest" does not improve security of the authentication process. * * The results can be used to store username & userdigest pairs instead of * username & password pairs. To further improve security, application may * store username & userhash & userdigest triplets. * * @param algo3 the digest algorithm * @param username the username * @param realm the realm * @param password the password * @param[out] userdigest_bin the output buffer for userdigest; * if this function succeeds, then this buffer has * #MHD_digest_get_hash_size(algo3) bytes of * userdigest upon return * @param bin_buf_size the size of the @a userdigest_bin buffer, must be * at least #MHD_digest_get_hash_size(algo3) bytes long * @return MHD_YES on success, * MHD_NO if @a userdigest_bin is too small or if @a algo3 algorithm is * not supported (or external error has occurred, * see #MHD_FEATURE_EXTERN_HASH). * @sa #MHD_digest_auth_check_digest3() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userdigest (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, const char *password, void *userdigest_bin, size_t bin_buf_size) { struct DigestAlgorithm da; enum MHD_Result ret; if (! digest_init_one_time (&da, get_base_digest_algo (algo3))) return MHD_NO; if (digest_get_size (&da) > bin_buf_size) ret = MHD_NO; else { calc_userdigest (&da, username, strlen (username), realm, strlen (realm), password, userdigest_bin); ret = MHD_YES; #ifdef MHD_DIGEST_HAS_EXT_ERROR if (digest_ext_error (&da)) ret = MHD_NO; #endif /* MHD_DIGEST_HAS_EXT_ERROR */ } digest_deinit (&da); return ret; } /** * Calculate userhash, return it as binary data. * * MHD internal version. * * @param da the digest algorithm * @param username the username to use * @param username_len the length of the @a username * @param realm the realm to use * @param realm_len the length of the @a realm * @param[out] digest_bin the output buffer, must have at least * #MHD_digest_get_hash_size(algo3) bytes available */ _MHD_static_inline void calc_userhash (struct DigestAlgorithm *da, const char *username, const size_t username_len, const char *realm, const size_t realm_len, uint8_t *digest_bin) { mhd_assert (NULL != username); mhd_assert (! da->hashing); digest_update (da, username, username_len); digest_update_with_colon (da); digest_update (da, realm, realm_len); digest_calc_hash (da, digest_bin); } /** * Calculate "userhash", return it as binary data. * * The "userhash" is the hash of the string "username:realm". * * The "userhash" could be used to avoid sending username in cleartext in Digest * Authorization client's header. * * Userhash is not designed to hide the username in local database or files, * as username in cleartext is required for #MHD_digest_auth_check3() function * to check the response, but it can be used to hide username in HTTP headers. * * This function could be used when the new username is added to the username * database to save the "userhash" alongside with the username (preferably) or * when loading list of the usernames to generate the userhash for every loaded * username (this will cause delays at the start with the long lists). * * Once "userhash" is generated it could be used to identify users by clients * with "userhash" support. * Avoid repetitive usage of this function for the same username/realm * combination as it will cause excessive CPU load; save and re-use the result * instead. * * @param algo3 the algorithm for userhash calculations * @param username the username * @param realm the realm * @param[out] userhash_bin the output buffer for userhash as binary data; * if this function succeeds, then this buffer has * #MHD_digest_get_hash_size(algo3) bytes of userhash * upon return * @param bin_buf_size the size of the @a userhash_bin buffer, must be * at least #MHD_digest_get_hash_size(algo3) bytes long * @return MHD_YES on success, * MHD_NO if @a bin_buf_size is too small or if @a algo3 algorithm is * not supported (or external error has occurred, * see #MHD_FEATURE_EXTERN_HASH) * @sa #MHD_digest_auth_calc_userhash_hex() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userhash (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, void *userhash_bin, size_t bin_buf_size) { struct DigestAlgorithm da; enum MHD_Result ret; if (! digest_init_one_time (&da, get_base_digest_algo (algo3))) return MHD_NO; if (digest_get_size (&da) > bin_buf_size) ret = MHD_NO; else { calc_userhash (&da, username, strlen (username), realm, strlen (realm), userhash_bin); ret = MHD_YES; #ifdef MHD_DIGEST_HAS_EXT_ERROR if (digest_ext_error (&da)) ret = MHD_NO; #endif /* MHD_DIGEST_HAS_EXT_ERROR */ } digest_deinit (&da); return ret; } /** * Calculate "userhash", return it as hexadecimal string. * * The "userhash" is the hash of the string "username:realm". * * The "userhash" could be used to avoid sending username in cleartext in Digest * Authorization client's header. * * Userhash is not designed to hide the username in local database or files, * as username in cleartext is required for #MHD_digest_auth_check3() function * to check the response, but it can be used to hide username in HTTP headers. * * This function could be used when the new username is added to the username * database to save the "userhash" alongside with the username (preferably) or * when loading list of the usernames to generate the userhash for every loaded * username (this will cause delays at the start with the long lists). * * Once "userhash" is generated it could be used to identify users by clients * with "userhash" support. * Avoid repetitive usage of this function for the same username/realm * combination as it will cause excessive CPU load; save and re-use the result * instead. * * @param algo3 the algorithm for userhash calculations * @param username the username * @param realm the realm * @param[out] userhash_hex the output buffer for userhash as hex string; * if this function succeeds, then this buffer has * #MHD_digest_get_hash_size(algo3)*2 chars long * userhash zero-terminated string * @param bin_buf_size the size of the @a userhash_bin buffer, must be * at least #MHD_digest_get_hash_size(algo3)*2+1 chars long * @return MHD_YES on success, * MHD_NO if @a bin_buf_size is too small or if @a algo3 algorithm is * not supported (or external error has occurred, * see #MHD_FEATURE_EXTERN_HASH). * @sa #MHD_digest_auth_calc_userhash() * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userhash_hex (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, char *userhash_hex, size_t hex_buf_size) { uint8_t userhash_bin[MAX_DIGEST]; size_t digest_size; digest_size = digest_get_hash_size (algo3); if (digest_size * 2 + 1 > hex_buf_size) return MHD_NO; if (MHD_NO == MHD_digest_auth_calc_userhash (algo3, username, realm, userhash_bin, MAX_DIGEST)) return MHD_NO; MHD_bin_to_hex_z (userhash_bin, digest_size, userhash_hex); return MHD_YES; } struct test_header_param { struct MHD_Connection *connection; size_t num_headers; }; /** * Test if the given key-value pair is in the headers for the * given connection. * * @param cls the test context * @param key the key * @param key_size number of bytes in @a key * @param value the value, can be NULL * @param value_size number of bytes in @a value * @param kind type of the header * @return #MHD_YES if the key-value pair is in the headers, * #MHD_NO if not */ static enum MHD_Result test_header (void *cls, const char *key, size_t key_size, const char *value, size_t value_size, enum MHD_ValueKind kind) { struct test_header_param *const param = (struct test_header_param *) cls; struct MHD_Connection *connection = param->connection; struct MHD_HTTP_Req_Header *pos; size_t i; param->num_headers++; i = 0; for (pos = connection->rq.headers_received; NULL != pos; pos = pos->next) { if (kind != pos->kind) continue; if (++i == param->num_headers) { if (key_size != pos->header_size) return MHD_NO; if (value_size != pos->value_size) return MHD_NO; if (0 != key_size) { mhd_assert (NULL != key); mhd_assert (NULL != pos->header); if (0 != memcmp (key, pos->header, key_size)) return MHD_NO; } if (0 != value_size) { mhd_assert (NULL != value); mhd_assert (NULL != pos->value); if (0 != memcmp (value, pos->value, value_size)) return MHD_NO; } return MHD_YES; } } return MHD_NO; } /** * Check that the arguments given by the client as part * of the authentication header match the arguments we * got as part of the HTTP request URI. * * @param connection connections with headers to compare against * @param args the copy of argument URI string (after "?" in URI), will be * modified by this function * @return boolean true if the arguments match, * boolean false if not */ static bool check_argument_match (struct MHD_Connection *connection, char *args) { struct MHD_HTTP_Req_Header *pos; enum MHD_Result ret; struct test_header_param param; param.connection = connection; param.num_headers = 0; ret = MHD_parse_arguments_ (connection, MHD_GET_ARGUMENT_KIND, args, &test_header, ¶m); if (MHD_NO == ret) { return false; } /* also check that the number of headers matches */ for (pos = connection->rq.headers_received; NULL != pos; pos = pos->next) { if (MHD_GET_ARGUMENT_KIND != pos->kind) continue; param.num_headers--; } if (0 != param.num_headers) { /* argument count mismatch */ return false; } return true; } /** * Check that the URI provided by the client as part * of the authentication header match the real HTTP request URI. * * @param connection connections with headers to compare against * @param uri the copy of URI in the authentication header, should point to * modifiable buffer at least @a uri_len + 1 characters long, * will be modified by this function, not valid upon return * @param uri_len the length of the @a uri string in characters * @return boolean true if the URIs match, * boolean false if not */ static bool check_uri_match (struct MHD_Connection *connection, char *uri, size_t uri_len) { char *qmark; char *args; struct MHD_Daemon *const daemon = connection->daemon; uri[uri_len] = 0; qmark = memchr (uri, '?', uri_len); if (NULL != qmark) *qmark = '\0'; /* Need to unescape URI before comparing with connection->url */ uri_len = daemon->unescape_callback (daemon->unescape_callback_cls, connection, uri); if ((uri_len != connection->rq.url_len) || (0 != memcmp (uri, connection->rq.url, uri_len))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Authentication failed, URI does not match.\n")); #endif return false; } args = (NULL != qmark) ? (qmark + 1) : uri + uri_len; if (! check_argument_match (connection, args) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Authentication failed, arguments do not match.\n")); #endif return false; } return true; } /** * The size of the unquoting buffer in stack */ #define _MHD_STATIC_UNQ_BUFFER_SIZE 128 /** * Get the pointer to buffer with required size * @param tmp1 the first buffer with fixed size * @param ptmp2 the pointer to pointer to malloc'ed buffer * @param ptmp2_size the pointer to the size of the buffer pointed by @a ptmp2 * @param required_size the required size in buffer * @return the pointer to the buffer or NULL if failed to allocate buffer with * requested size */ static char * get_buffer_for_size (char tmp1[_MHD_STATIC_UNQ_BUFFER_SIZE], char **ptmp2, size_t *ptmp2_size, size_t required_size) { mhd_assert ((0 == *ptmp2_size) || (NULL != *ptmp2)); mhd_assert ((NULL != *ptmp2) || (0 == *ptmp2_size)); mhd_assert ((0 == *ptmp2_size) || \ (_MHD_STATIC_UNQ_BUFFER_SIZE < *ptmp2_size)); if (required_size <= _MHD_STATIC_UNQ_BUFFER_SIZE) return tmp1; if (required_size <= *ptmp2_size) return *ptmp2; if (required_size > _MHD_AUTH_DIGEST_MAX_PARAM_SIZE) return NULL; if (NULL != *ptmp2) free (*ptmp2); *ptmp2 = (char *) malloc (required_size); if (NULL == *ptmp2) *ptmp2_size = 0; else *ptmp2_size = required_size; return *ptmp2; } /** * The result of parameter unquoting */ enum _MHD_GetUnqResult { _MHD_UNQ_OK = 0, /**< Got unquoted string */ _MHD_UNQ_TOO_LARGE = -7, /**< The string is too large to unquote */ _MHD_UNQ_OUT_OF_MEM = 3 /**< Out of memory error */ }; /** * Get Digest authorisation parameter as unquoted string. * @param param the parameter to process * @param tmp1 the small buffer in stack * @param ptmp2 the pointer to pointer to malloc'ed buffer * @param ptmp2_size the pointer to the size of the buffer pointed by @a ptmp2 * @param[out] unquoted the pointer to store the result, NOT zero terminated * @return enum code indicating result of the process */ static enum _MHD_GetUnqResult get_unquoted_param (const struct MHD_RqDAuthParam *param, char tmp1[_MHD_STATIC_UNQ_BUFFER_SIZE], char **ptmp2, size_t *ptmp2_size, struct _MHD_str_w_len *unquoted) { char *str; size_t len; mhd_assert (NULL != param->value.str); mhd_assert (0 != param->value.len); if (! param->quoted) { unquoted->str = param->value.str; unquoted->len = param->value.len; return _MHD_UNQ_OK; } /* The value is present and is quoted, needs to be copied and unquoted */ str = get_buffer_for_size (tmp1, ptmp2, ptmp2_size, param->value.len); if (NULL == str) return (param->value.len > _MHD_AUTH_DIGEST_MAX_PARAM_SIZE) ? _MHD_UNQ_TOO_LARGE : _MHD_UNQ_OUT_OF_MEM; len = MHD_str_unquote (param->value.str, param->value.len, str); unquoted->str = str; unquoted->len = len; mhd_assert (0 != unquoted->len); mhd_assert (unquoted->len < param->value.len); return _MHD_UNQ_OK; } /** * Get copy of Digest authorisation parameter as unquoted string. * @param param the parameter to process * @param tmp1 the small buffer in stack * @param ptmp2 the pointer to pointer to malloc'ed buffer * @param ptmp2_size the pointer to the size of the buffer pointed by @a ptmp2 * @param[out] unquoted the pointer to store the result, NOT zero terminated, * but with enough space to zero-terminate * @return enum code indicating result of the process */ static enum _MHD_GetUnqResult get_unquoted_param_copy (const struct MHD_RqDAuthParam *param, char tmp1[_MHD_STATIC_UNQ_BUFFER_SIZE], char **ptmp2, size_t *ptmp2_size, struct _MHD_mstr_w_len *unquoted) { mhd_assert (NULL != param->value.str); mhd_assert (0 != param->value.len); /* The value is present and is quoted, needs to be copied and unquoted */ /* Allocate buffer with one more additional byte for zero-termination */ unquoted->str = get_buffer_for_size (tmp1, ptmp2, ptmp2_size, param->value.len + 1); if (NULL == unquoted->str) return (param->value.len + 1 > _MHD_AUTH_DIGEST_MAX_PARAM_SIZE) ? _MHD_UNQ_TOO_LARGE : _MHD_UNQ_OUT_OF_MEM; if (! param->quoted) { memcpy (unquoted->str, param->value.str, param->value.len); unquoted->len = param->value.len; return _MHD_UNQ_OK; } unquoted->len = MHD_str_unquote (param->value.str, param->value.len, unquoted->str); mhd_assert (0 != unquoted->len); mhd_assert (unquoted->len < param->value.len); return _MHD_UNQ_OK; } /** * Check whether Digest Auth request parameter is equal to given string * @param param the parameter to check * @param str the string to compare with, does not need to be zero-terminated * @param str_len the length of the @a str * @return true is parameter is equal to the given string, * false otherwise */ _MHD_static_inline bool is_param_equal (const struct MHD_RqDAuthParam *param, const char *const str, const size_t str_len) { mhd_assert (NULL != param->value.str); mhd_assert (0 != param->value.len); if (param->quoted) return MHD_str_equal_quoted_bin_n (param->value.str, param->value.len, str, str_len); return (str_len == param->value.len) && (0 == memcmp (str, param->value.str, str_len)); } /** * Check whether Digest Auth request parameter is caseless equal to given string * @param param the parameter to check * @param str the string to compare with, does not need to be zero-terminated * @param str_len the length of the @a str * @return true is parameter is caseless equal to the given string, * false otherwise */ _MHD_static_inline bool is_param_equal_caseless (const struct MHD_RqDAuthParam *param, const char *const str, const size_t str_len) { mhd_assert (NULL != param->value.str); mhd_assert (0 != param->value.len); if (param->quoted) return MHD_str_equal_quoted_bin_n (param->value.str, param->value.len, str, str_len); return (str_len == param->value.len) && (0 == memcmp (str, param->value.str, str_len)); } /** * Authenticates the authorization header sent by the client * * If RFC2069 mode is allowed by setting bit #MHD_DIGEST_AUTH_QOP_NONE in * @a mqop and the client uses this mode, then server generated nonces are * used as one-time nonces because nonce-count is not supported in this old RFC. * Communication in this mode is very inefficient, especially if the client * requests several resources one-by-one as for every request new nonce must be * generated and client repeat all requests twice (the first time to get a new * nonce and the second time to perform an authorised request). * * @param connection the MHD connection structure * @param realm the realm for authorization of the client * @param username the username to be authenticated, must be in clear text * even if userhash is used by the client * @param password the password used in the authentication, * must be NULL if @a userdigest is not NULL * @param userdigest the precalculated binary hash of the string * "username:realm:password", * must be NULL if @a password is not NULL * @param nonce_timeout the period of seconds since nonce generation, when * the nonce is recognised as valid and not stale; * unlike #digest_auth_check_all() zero is used literally * @param max_nc the maximum allowed nc (Nonce Count) value, if client's nc * exceeds the specified value then MHD_DAUTH_NONCE_STALE is * returned; * unlike #digest_auth_check_all() zero is treated as "no limit" * @param mqop the QOP to use * @param malgo3 digest algorithms allowed to use, fail if algorithm specified * by the client is not allowed by this parameter * @param[out] pbuf the pointer to pointer to internally malloc'ed buffer, * to be freed if not NULL upon return * @return #MHD_DAUTH_OK if authenticated, * error code otherwise. * @ingroup authentication */ static enum MHD_DigestAuthResult digest_auth_check_all_inner (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, const uint8_t *userdigest, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3, char **pbuf, struct DigestAlgorithm *da) { struct MHD_Daemon *daemon = MHD_get_master (connection->daemon); enum MHD_DigestAuthAlgo3 c_algo; /**< Client's algorithm */ enum MHD_DigestAuthQOP c_qop; /**< Client's QOP */ unsigned int digest_size; uint8_t hash1_bin[MAX_DIGEST]; uint8_t hash2_bin[MAX_DIGEST]; #if 0 const char *hentity = NULL; /* "auth-int" is not supported */ #endif uint64_t nonce_time; uint64_t nci; const struct MHD_RqDAuth *params; /** * Temporal buffer in stack for unquoting and other needs */ char tmp1[_MHD_STATIC_UNQ_BUFFER_SIZE]; char **const ptmp2 = pbuf; /**< Temporal malloc'ed buffer for unquoting */ size_t tmp2_size; /**< The size of @a tmp2 buffer */ struct _MHD_str_w_len unquoted; struct _MHD_mstr_w_len unq_copy; enum _MHD_GetUnqResult unq_res; size_t username_len; size_t realm_len; mhd_assert ((NULL != password) || (NULL != userdigest)); mhd_assert (! ((NULL != userdigest) && (NULL != password))); tmp2_size = 0; params = MHD_get_rq_dauth_params_ (connection); if (NULL == params) return MHD_DAUTH_WRONG_HEADER; /* ** Initial parameters checks and setup ** */ /* Get client's algorithm */ c_algo = params->algo3; /* Check whether client's algorithm is allowed by function parameter */ if (((unsigned int) c_algo) != (((unsigned int) c_algo) & ((unsigned int) malgo3))) return MHD_DAUTH_WRONG_ALGO; /* Check whether client's algorithm is supported */ if (0 != (((unsigned int) c_algo) & MHD_DIGEST_AUTH_ALGO3_SESSION)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The 'session' algorithms are not supported.\n")); #endif /* HAVE_MESSAGES */ return MHD_DAUTH_WRONG_ALGO; } #ifndef MHD_MD5_SUPPORT if (0 != (((unsigned int) c_algo) & MHD_DIGEST_BASE_ALGO_MD5)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The MD5 algorithm is not supported by this MHD build.\n")); #endif /* HAVE_MESSAGES */ return MHD_DAUTH_WRONG_ALGO; } #endif /* ! MHD_MD5_SUPPORT */ #ifndef MHD_SHA256_SUPPORT if (0 != (((unsigned int) c_algo) & MHD_DIGEST_BASE_ALGO_SHA256)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The SHA-256 algorithm is not supported by " "this MHD build.\n")); #endif /* HAVE_MESSAGES */ return MHD_DAUTH_WRONG_ALGO; } #endif /* ! MHD_SHA256_SUPPORT */ #ifndef MHD_SHA512_256_SUPPORT if (0 != (((unsigned int) c_algo) & MHD_DIGEST_BASE_ALGO_SHA512_256)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The SHA-512/256 algorithm is not supported by " "this MHD build.\n")); #endif /* HAVE_MESSAGES */ return MHD_DAUTH_WRONG_ALGO; } #endif /* ! MHD_SHA512_256_SUPPORT */ if (! digest_init_one_time (da, get_base_digest_algo (c_algo))) MHD_PANIC (_ ("Wrong 'malgo3' value, API violation")); /* Check 'mqop' value */ c_qop = params->qop; /* Check whether client's QOP is allowed by function parameter */ if (((unsigned int) c_qop) != (((unsigned int) c_qop) & ((unsigned int) mqop))) return MHD_DAUTH_WRONG_QOP; if (0 != (((unsigned int) c_qop) & MHD_DIGEST_AUTH_QOP_AUTH_INT)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The 'auth-int' QOP is not supported.\n")); #endif /* HAVE_MESSAGES */ return MHD_DAUTH_WRONG_QOP; } #ifdef HAVE_MESSAGES if ((MHD_DIGEST_AUTH_QOP_NONE == c_qop) && (0 == (((unsigned int) c_algo) & MHD_DIGEST_BASE_ALGO_MD5))) MHD_DLOG (connection->daemon, _ ("RFC2069 with SHA-256 or SHA-512/256 algorithm is " \ "non-standard extension.\n")); #endif /* HAVE_MESSAGES */ digest_size = digest_get_size (da); /* ** A quick check for presence of all required parameters ** */ if ((NULL == params->username.value.str) && (NULL == params->username_ext.value.str)) return MHD_DAUTH_WRONG_USERNAME; else if ((NULL != params->username.value.str) && (NULL != params->username_ext.value.str)) return MHD_DAUTH_WRONG_USERNAME; /* Parameters cannot be used together */ else if ((NULL != params->username_ext.value.str) && (MHD_DAUTH_EXT_PARAM_MIN_LEN > params->username_ext.value.len)) return MHD_DAUTH_WRONG_USERNAME; /* Broken extended notation */ else if (params->userhash && (NULL == params->username.value.str)) return MHD_DAUTH_WRONG_USERNAME; /* Userhash cannot be used with extended notation */ else if (params->userhash && (digest_size * 2 > params->username.value.len)) return MHD_DAUTH_WRONG_USERNAME; /* Too few chars for correct userhash */ else if (params->userhash && (digest_size * 4 < params->username.value.len)) return MHD_DAUTH_WRONG_USERNAME; /* Too many chars for correct userhash */ if (NULL == params->realm.value.str) return MHD_DAUTH_WRONG_REALM; else if (((NULL == userdigest) || params->userhash) && (_MHD_AUTH_DIGEST_MAX_PARAM_SIZE < params->realm.value.len)) return MHD_DAUTH_TOO_LARGE; /* Realm is too large and should be used in hash calculations */ if (MHD_DIGEST_AUTH_QOP_NONE != c_qop) { if (NULL == params->nc.value.str) return MHD_DAUTH_WRONG_HEADER; else if (0 == params->nc.value.len) return MHD_DAUTH_WRONG_HEADER; else if (4 * 8 < params->nc.value.len) /* Four times more than needed */ return MHD_DAUTH_WRONG_HEADER; if (NULL == params->cnonce.value.str) return MHD_DAUTH_WRONG_HEADER; else if (0 == params->cnonce.value.len) return MHD_DAUTH_WRONG_HEADER; else if (_MHD_AUTH_DIGEST_MAX_PARAM_SIZE < params->cnonce.value.len) return MHD_DAUTH_TOO_LARGE; } /* The QOP parameter was checked already */ if (NULL == params->uri.value.str) return MHD_DAUTH_WRONG_URI; else if (0 == params->uri.value.len) return MHD_DAUTH_WRONG_URI; else if (_MHD_AUTH_DIGEST_MAX_PARAM_SIZE < params->uri.value.len) return MHD_DAUTH_TOO_LARGE; if (NULL == params->nonce.value.str) return MHD_DAUTH_NONCE_WRONG; else if (0 == params->nonce.value.len) return MHD_DAUTH_NONCE_WRONG; else if (NONCE_STD_LEN (digest_size) * 2 < params->nonce.value.len) return MHD_DAUTH_NONCE_WRONG; if (NULL == params->response.value.str) return MHD_DAUTH_RESPONSE_WRONG; else if (0 == params->response.value.len) return MHD_DAUTH_RESPONSE_WRONG; else if (digest_size * 4 < params->response.value.len) return MHD_DAUTH_RESPONSE_WRONG; /* ** Check simple parameters match ** */ /* Check 'algorithm' */ /* The 'algorithm' was checked at the start of the function */ /* 'algorithm' valid */ /* Check 'qop' */ /* The 'qop' was checked at the start of the function */ /* 'qop' valid */ /* Check 'realm' */ realm_len = strlen (realm); if (! is_param_equal (¶ms->realm, realm, realm_len)) return MHD_DAUTH_WRONG_REALM; /* 'realm' valid */ /* Check 'username' */ username_len = strlen (username); if (! params->userhash) { if (NULL != params->username.value.str) { /* Username in standard notation */ if (! is_param_equal (¶ms->username, username, username_len)) return MHD_DAUTH_WRONG_USERNAME; } else { /* Username in extended notation */ char *r_uname; size_t buf_size = params->username_ext.value.len; ssize_t res; mhd_assert (NULL != params->username_ext.value.str); mhd_assert (MHD_DAUTH_EXT_PARAM_MIN_LEN <= buf_size); /* It was checked already */ buf_size += 1; /* For zero-termination */ buf_size -= MHD_DAUTH_EXT_PARAM_MIN_LEN; r_uname = get_buffer_for_size (tmp1, ptmp2, &tmp2_size, buf_size); if (NULL == r_uname) return (_MHD_AUTH_DIGEST_MAX_PARAM_SIZE < buf_size) ? MHD_DAUTH_TOO_LARGE : MHD_DAUTH_ERROR; res = get_rq_extended_uname_copy_z (params->username_ext.value.str, params->username_ext.value.len, r_uname, buf_size); if (0 > res) return MHD_DAUTH_WRONG_HEADER; /* Broken extended notation */ if ((username_len != (size_t) res) || (0 != memcmp (username, r_uname, username_len))) return MHD_DAUTH_WRONG_USERNAME; } } else { /* Userhash */ mhd_assert (NULL != params->username.value.str); calc_userhash (da, username, username_len, realm, realm_len, hash1_bin); #ifdef MHD_DIGEST_HAS_EXT_ERROR if (digest_ext_error (da)) return MHD_DAUTH_ERROR; #endif /* MHD_DIGEST_HAS_EXT_ERROR */ mhd_assert (sizeof (tmp1) >= (2 * digest_size)); MHD_bin_to_hex (hash1_bin, digest_size, tmp1); if (! is_param_equal_caseless (¶ms->username, tmp1, 2 * digest_size)) return MHD_DAUTH_WRONG_USERNAME; /* To simplify the logic, the digest is reset here instead of resetting before the next hash calculation. */ digest_reset (da); } /* 'username' valid */ /* ** Do basic nonce and nonce-counter checks (size, timestamp) ** */ /* Get 'nc' digital value */ if (MHD_DIGEST_AUTH_QOP_NONE != c_qop) { unq_res = get_unquoted_param (¶ms->nc, tmp1, ptmp2, &tmp2_size, &unquoted); if (_MHD_UNQ_OK != unq_res) return MHD_DAUTH_ERROR; if (unquoted.len != MHD_strx_to_uint64_n_ (unquoted.str, unquoted.len, &nci)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Authentication failed, invalid nc format.\n")); #endif return MHD_DAUTH_WRONG_HEADER; /* invalid nonce format */ } if (0 == nci) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Authentication failed, invalid 'nc' value.\n")); #endif return MHD_DAUTH_WRONG_HEADER; /* invalid nc value */ } if ((0 != max_nc) && (max_nc < nci)) return MHD_DAUTH_NONCE_STALE; /* Too large 'nc' value */ } else nci = 1; /* Force 'nc' value */ /* Got 'nc' digital value */ /* Get 'nonce' with basic checks */ unq_res = get_unquoted_param (¶ms->nonce, tmp1, ptmp2, &tmp2_size, &unquoted); if (_MHD_UNQ_OK != unq_res) return MHD_DAUTH_ERROR; if ((NONCE_STD_LEN (digest_size) != unquoted.len) || (! get_nonce_timestamp (unquoted.str, unquoted.len, &nonce_time))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Authentication failed, invalid nonce format.\n")); #endif return MHD_DAUTH_NONCE_WRONG; } if (1) { uint64_t t; t = MHD_monotonic_msec_counter (); /* * First level vetting for the nonce validity: if the timestamp * attached to the nonce exceeds `nonce_timeout', then the nonce is * stale. */ if (TRIM_TO_TIMESTAMP (t - nonce_time) > (nonce_timeout * 1000)) return MHD_DAUTH_NONCE_STALE; /* too old */ } if (1) { enum MHD_CheckNonceNC_ nonce_nc_check; /* * Checking if that combination of nonce and nc is sound * and not a replay attack attempt. Refuse if nonce was not * generated previously. */ nonce_nc_check = check_nonce_nc (connection, unquoted.str, NONCE_STD_LEN (digest_size), nonce_time, nci); if (MHD_CHECK_NONCENC_STALE == nonce_nc_check) { #ifdef HAVE_MESSAGES if (MHD_DIGEST_AUTH_QOP_NONE != c_qop) MHD_DLOG (daemon, _ ("Stale nonce received. If this happens a lot, you should " "probably increase the size of the nonce array.\n")); else MHD_DLOG (daemon, _ ("Stale nonce received. This is expected when client " \ "uses RFC2069-compatible mode and makes more than one " \ "request.\n")); #endif return MHD_DAUTH_NONCE_STALE; } else if (MHD_CHECK_NONCENC_WRONG == nonce_nc_check) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Received nonce that was not " "generated by MHD. This may indicate an attack attempt.\n")); #endif return MHD_DAUTH_NONCE_WRONG; } mhd_assert (MHD_CHECK_NONCENC_OK == nonce_nc_check); } /* The nonce was generated by MHD, is not stale and nonce-nc combination was not used before */ /* ** Build H(A2) and check URI match in the header and in the request ** */ /* Get 'uri' */ mhd_assert (! da->hashing); digest_update_str (da, connection->rq.method); digest_update_with_colon (da); #if 0 /* TODO: add support for "auth-int" */ digest_update_str (da, hentity); digest_update_with_colon (da); #endif unq_res = get_unquoted_param_copy (¶ms->uri, tmp1, ptmp2, &tmp2_size, &unq_copy); if (_MHD_UNQ_OK != unq_res) return MHD_DAUTH_ERROR; digest_update (da, unq_copy.str, unq_copy.len); /* The next check will modify copied URI string */ if (! check_uri_match (connection, unq_copy.str, unq_copy.len)) return MHD_DAUTH_WRONG_URI; digest_calc_hash (da, hash2_bin); #ifdef MHD_DIGEST_HAS_EXT_ERROR /* Skip digest calculation external error check, the next one checks both */ #endif /* MHD_DIGEST_HAS_EXT_ERROR */ /* Got H(A2) */ /* ** Build H(A1) ** */ if (NULL == userdigest) { mhd_assert (! da->hashing); digest_reset (da); calc_userdigest (da, username, username_len, realm, realm_len, password, hash1_bin); } /* TODO: support '-sess' versions */ #ifdef MHD_DIGEST_HAS_EXT_ERROR if (digest_ext_error (da)) return MHD_DAUTH_ERROR; #endif /* MHD_DIGEST_HAS_EXT_ERROR */ /* Got H(A1) */ /* ** Check 'response' ** */ mhd_assert (! da->hashing); digest_reset (da); /* Update digest with H(A1) */ mhd_assert (sizeof (tmp1) >= (digest_size * 2)); if (NULL == userdigest) MHD_bin_to_hex (hash1_bin, digest_size, tmp1); else MHD_bin_to_hex (userdigest, digest_size, tmp1); digest_update (da, (const uint8_t *) tmp1, digest_size * 2); /* H(A1) is not needed anymore, reuse the buffer. * Use hash1_bin for the client's 'response' decoded to binary form. */ unq_res = get_unquoted_param (¶ms->response, tmp1, ptmp2, &tmp2_size, &unquoted); if (_MHD_UNQ_OK != unq_res) return MHD_DAUTH_ERROR; if (digest_size != MHD_hex_to_bin (unquoted.str, unquoted.len, hash1_bin)) return MHD_DAUTH_RESPONSE_WRONG; /* Update digest with ':' */ digest_update_with_colon (da); /* Update digest with 'nonce' text value */ unq_res = get_unquoted_param (¶ms->nonce, tmp1, ptmp2, &tmp2_size, &unquoted); if (_MHD_UNQ_OK != unq_res) return MHD_DAUTH_ERROR; digest_update (da, (const uint8_t *) unquoted.str, unquoted.len); /* Update digest with ':' */ digest_update_with_colon (da); if (MHD_DIGEST_AUTH_QOP_NONE != c_qop) { /* Update digest with 'nc' text value */ unq_res = get_unquoted_param (¶ms->nc, tmp1, ptmp2, &tmp2_size, &unquoted); if (_MHD_UNQ_OK != unq_res) return MHD_DAUTH_ERROR; digest_update (da, (const uint8_t *) unquoted.str, unquoted.len); /* Update digest with ':' */ digest_update_with_colon (da); /* Update digest with 'cnonce' value */ unq_res = get_unquoted_param (¶ms->cnonce, tmp1, ptmp2, &tmp2_size, &unquoted); if (_MHD_UNQ_OK != unq_res) return MHD_DAUTH_ERROR; digest_update (da, (const uint8_t *) unquoted.str, unquoted.len); /* Update digest with ':' */ digest_update_with_colon (da); /* Update digest with 'qop' value */ unq_res = get_unquoted_param (¶ms->qop_raw, tmp1, ptmp2, &tmp2_size, &unquoted); if (_MHD_UNQ_OK != unq_res) return MHD_DAUTH_ERROR; digest_update (da, (const uint8_t *) unquoted.str, unquoted.len); /* Update digest with ':' */ digest_update_with_colon (da); } /* Update digest with H(A2) */ MHD_bin_to_hex (hash2_bin, digest_size, tmp1); digest_update (da, (const uint8_t *) tmp1, digest_size * 2); /* H(A2) is not needed anymore, reuse the buffer. * Use hash2_bin for the calculated response in binary form */ digest_calc_hash (da, hash2_bin); #ifdef MHD_DIGEST_HAS_EXT_ERROR if (digest_ext_error (da)) return MHD_DAUTH_ERROR; #endif /* MHD_DIGEST_HAS_EXT_ERROR */ if (0 != memcmp (hash1_bin, hash2_bin, digest_size)) return MHD_DAUTH_RESPONSE_WRONG; if (MHD_DAUTH_BIND_NONCE_NONE != daemon->dauth_bind_type) { mhd_assert (sizeof(tmp1) >= (NONCE_STD_LEN (digest_size) + 1)); /* It was already checked that 'nonce' (including timestamp) was generated by MHD. */ mhd_assert (! da->hashing); digest_reset (da); calculate_nonce (nonce_time, connection->rq.http_mthd, connection->rq.method, daemon->digest_auth_random, daemon->digest_auth_rand_size, connection->addr, (size_t) connection->addr_len, connection->rq.url, connection->rq.url_len, connection->rq.headers_received, realm, realm_len, daemon->dauth_bind_type, da, tmp1); #ifdef MHD_DIGEST_HAS_EXT_ERROR if (digest_ext_error (da)) return MHD_DAUTH_ERROR; #endif /* MHD_DIGEST_HAS_EXT_ERROR */ if (! is_param_equal (¶ms->nonce, tmp1, NONCE_STD_LEN (digest_size))) return MHD_DAUTH_NONCE_OTHER_COND; /* The 'nonce' was generated in the same conditions */ } return MHD_DAUTH_OK; } /** * Authenticates the authorization header sent by the client * * If RFC2069 mode is allowed by setting bit #MHD_DIGEST_AUTH_QOP_NONE in * @a mqop and the client uses this mode, then server generated nonces are * used as one-time nonces because nonce-count is not supported in this old RFC. * Communication in this mode is very inefficient, especially if the client * requests several resources one-by-one as for every request new nonce must be * generated and client repeat all requests twice (the first time to get a new * nonce and the second time to perform an authorised request). * * @param connection the MHD connection structure * @param realm the realm for authorization of the client * @param username the username to be authenticated, must be in clear text * even if userhash is used by the client * @param password the password used in the authentication, * must be NULL if @a userdigest is not NULL * @param userdigest the precalculated binary hash of the string * "username:realm:password", * must be NULL if @a password is not NULL * @param nonce_timeout the period of seconds since nonce generation, when * the nonce is recognised as valid and not stale; * if set to zero then daemon's default value is used * @param max_nc the maximum allowed nc (Nonce Count) value, if client's nc * exceeds the specified value then MHD_DAUTH_NONCE_STALE is * returned; * if set to zero then daemon's default value is used * @param mqop the QOP to use * @param malgo3 digest algorithms allowed to use, fail if algorithm specified * by the client is not allowed by this parameter * @return #MHD_DAUTH_OK if authenticated, * error code otherwise. * @ingroup authentication */ static enum MHD_DigestAuthResult digest_auth_check_all (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, const uint8_t *userdigest, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3) { enum MHD_DigestAuthResult res; char *buf; struct DigestAlgorithm da; buf = NULL; digest_setup_zero (&da); if (0 == nonce_timeout) nonce_timeout = connection->daemon->dauth_def_nonce_timeout; if (0 == max_nc) max_nc = connection->daemon->dauth_def_max_nc; res = digest_auth_check_all_inner (connection, realm, username, password, userdigest, nonce_timeout, max_nc, mqop, malgo3, &buf, &da); digest_deinit (&da); if (NULL != buf) free (buf); return res; } /** * Authenticates the authorization header sent by the client. * Uses #MHD_DIGEST_ALG_MD5 (for now, for backwards-compatibility). * Note that this MAY change to #MHD_DIGEST_ALG_AUTO in the future. * If you want to be sure you get MD5, use #MHD_digest_auth_check2() * and specify MD5 explicitly. * * @param connection The MHD connection structure * @param realm The realm presented to the client * @param username The username needs to be authenticated * @param password The password used in the authentication * @param nonce_timeout The amount of time for a nonce to be * invalid in seconds * @return #MHD_YES if authenticated, #MHD_NO if not, * #MHD_INVALID_NONCE if nonce is invalid or stale * @deprecated use MHD_digest_auth_check3() * @ingroup authentication */ _MHD_EXTERN int MHD_digest_auth_check (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout) { return MHD_digest_auth_check2 (connection, realm, username, password, nonce_timeout, MHD_DIGEST_ALG_MD5); } /** * Authenticates the authorization header sent by the client. * * If RFC2069 mode is allowed by setting bit #MHD_DIGEST_AUTH_QOP_NONE in * @a mqop and the client uses this mode, then server generated nonces are * used as one-time nonces because nonce-count is not supported in this old RFC. * Communication in this mode is very inefficient, especially if the client * requests several resources one-by-one as for every request a new nonce must * be generated and client repeats all requests twice (first time to get a new * nonce and second time to perform an authorised request). * * @param connection the MHD connection structure * @param realm the realm for authorization of the client * @param username the username to be authenticated, must be in clear text * even if userhash is used by the client * @param password the password matching the @a username (and the @a realm) * @param nonce_timeout the period of seconds since nonce generation, when * the nonce is recognised as valid and not stale; * if zero is specified then daemon default value is used. * @param max_nc the maximum allowed nc (Nonce Count) value, if client's nc * exceeds the specified value then MHD_DAUTH_NONCE_STALE is * returned; * if zero is specified then daemon default value is used. * @param mqop the QOP to use * @param malgo3 digest algorithms allowed to use, fail if algorithm used * by the client is not allowed by this parameter * @return #MHD_DAUTH_OK if authenticated, * the error code otherwise * @note Available since #MHD_VERSION 0x00097708 * @ingroup authentication */ _MHD_EXTERN enum MHD_DigestAuthResult MHD_digest_auth_check3 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3) { mhd_assert (NULL != password); return digest_auth_check_all (connection, realm, username, password, NULL, nonce_timeout, max_nc, mqop, malgo3); } /** * Authenticates the authorization header sent by the client by using * hash of "username:realm:password". * * If RFC2069 mode is allowed by setting bit #MHD_DIGEST_AUTH_QOP_NONE in * @a mqop and the client uses this mode, then server generated nonces are * used as one-time nonces because nonce-count is not supported in this old RFC. * Communication in this mode is very inefficient, especially if the client * requests several resources one-by-one as for every request a new nonce must * be generated and client repeats all requests twice (first time to get a new * nonce and second time to perform an authorised request). * * @param connection the MHD connection structure * @param realm the realm for authorization of the client * @param username the username to be authenticated, must be in clear text * even if userhash is used by the client * @param userdigest the precalculated binary hash of the string * "username:realm:password", * see #MHD_digest_auth_calc_userdigest() * @param userdigest_size the size of the @a userdigest in bytes, must match the * hashing algorithm (see #MHD_MD5_DIGEST_SIZE, * #MHD_SHA256_DIGEST_SIZE, #MHD_SHA512_256_DIGEST_SIZE, * #MHD_digest_get_hash_size()) * @param nonce_timeout the period of seconds since nonce generation, when * the nonce is recognised as valid and not stale; * if zero is specified then daemon default value is used. * @param max_nc the maximum allowed nc (Nonce Count) value, if client's nc * exceeds the specified value then MHD_DAUTH_NONCE_STALE is * returned; * if zero is specified then daemon default value is used. * @param mqop the QOP to use * @param malgo3 digest algorithms allowed to use, fail if algorithm used * by the client is not allowed by this parameter; * more than one base algorithms (MD5, SHA-256, SHA-512/256) * cannot be used at the same time for this function * as @a userdigest must match specified algorithm * @return #MHD_DAUTH_OK if authenticated, * the error code otherwise * @sa #MHD_digest_auth_calc_userdigest() * @note Available since #MHD_VERSION 0x00097708 * @ingroup authentication */ _MHD_EXTERN enum MHD_DigestAuthResult MHD_digest_auth_check_digest3 (struct MHD_Connection *connection, const char *realm, const char *username, const void *userdigest, size_t userdigest_size, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3) { if (1 != (((0 != (malgo3 & MHD_DIGEST_BASE_ALGO_MD5)) ? 1 : 0) + ((0 != (malgo3 & MHD_DIGEST_BASE_ALGO_SHA256)) ? 1 : 0) + ((0 != (malgo3 & MHD_DIGEST_BASE_ALGO_SHA512_256)) ? 1 : 0))) MHD_PANIC (_ ("Wrong 'malgo3' value, only one base hashing algorithm " \ "(MD5, SHA-256 or SHA-512/256) must be specified, " \ "API violation")); #ifndef MHD_MD5_SUPPORT if (0 != (((unsigned int) malgo3) & MHD_DIGEST_BASE_ALGO_MD5)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The MD5 algorithm is not supported by this MHD build.\n")); #endif /* HAVE_MESSAGES */ return MHD_DAUTH_WRONG_ALGO; } #endif /* ! MHD_MD5_SUPPORT */ #ifndef MHD_SHA256_SUPPORT if (0 != (((unsigned int) malgo3) & MHD_DIGEST_BASE_ALGO_SHA256)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The SHA-256 algorithm is not supported by " "this MHD build.\n")); #endif /* HAVE_MESSAGES */ return MHD_DAUTH_WRONG_ALGO; } #endif /* ! MHD_SHA256_SUPPORT */ #ifndef MHD_SHA512_256_SUPPORT if (0 != (((unsigned int) malgo3) & MHD_DIGEST_BASE_ALGO_SHA512_256)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The SHA-512/256 algorithm is not supported by " "this MHD build.\n")); #endif /* HAVE_MESSAGES */ return MHD_DAUTH_WRONG_ALGO; } #endif /* ! MHD_SHA512_256_SUPPORT */ if (digest_get_hash_size ((enum MHD_DigestAuthAlgo3) malgo3) != userdigest_size) MHD_PANIC (_ ("Wrong 'userdigest_size' value, does not match 'malgo3', " "API violation")); return digest_auth_check_all (connection, realm, username, NULL, (const uint8_t *) userdigest, nonce_timeout, max_nc, mqop, malgo3); } /** * Authenticates the authorization header sent by the client. * * @param connection The MHD connection structure * @param realm The realm presented to the client * @param username The username needs to be authenticated * @param password The password used in the authentication * @param nonce_timeout The amount of time for a nonce to be * invalid in seconds * @param algo digest algorithms allowed for verification * @return #MHD_YES if authenticated, #MHD_NO if not, * #MHD_INVALID_NONCE if nonce is invalid or stale * @note Available since #MHD_VERSION 0x00096200 * @deprecated use MHD_digest_auth_check3() * @ingroup authentication */ _MHD_EXTERN int MHD_digest_auth_check2 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo) { enum MHD_DigestAuthResult res; enum MHD_DigestAuthMultiAlgo3 malgo3; if (MHD_DIGEST_ALG_AUTO == algo) malgo3 = MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION; else if (MHD_DIGEST_ALG_MD5 == algo) malgo3 = MHD_DIGEST_AUTH_MULT_ALGO3_MD5; else if (MHD_DIGEST_ALG_SHA256 == algo) malgo3 = MHD_DIGEST_AUTH_MULT_ALGO3_SHA256; else MHD_PANIC (_ ("Wrong 'algo' value, API violation")); res = MHD_digest_auth_check3 (connection, realm, username, password, nonce_timeout, 0, MHD_DIGEST_AUTH_MULT_QOP_AUTH, malgo3); if (MHD_DAUTH_OK == res) return MHD_YES; else if ((MHD_DAUTH_NONCE_STALE == res) || (MHD_DAUTH_NONCE_WRONG == res) || (MHD_DAUTH_NONCE_OTHER_COND == res) ) return MHD_INVALID_NONCE; return MHD_NO; } /** * Authenticates the authorization header sent by the client. * * @param connection The MHD connection structure * @param realm The realm presented to the client * @param username The username needs to be authenticated * @param digest An `unsigned char *' pointer to the binary MD5 sum * for the precalculated hash value "username:realm:password" * of @a digest_size bytes * @param digest_size number of bytes in @a digest (size must match @a algo!) * @param nonce_timeout The amount of time for a nonce to be * invalid in seconds * @param algo digest algorithms allowed for verification * @return #MHD_YES if authenticated, #MHD_NO if not, * #MHD_INVALID_NONCE if nonce is invalid or stale * @note Available since #MHD_VERSION 0x00096200 * @deprecated use MHD_digest_auth_check_digest3() * @ingroup authentication */ _MHD_EXTERN int MHD_digest_auth_check_digest2 (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t *digest, size_t digest_size, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo) { enum MHD_DigestAuthResult res; enum MHD_DigestAuthMultiAlgo3 malgo3; if (MHD_DIGEST_ALG_AUTO == algo) malgo3 = MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION; else if (MHD_DIGEST_ALG_MD5 == algo) malgo3 = MHD_DIGEST_AUTH_MULT_ALGO3_MD5; else if (MHD_DIGEST_ALG_SHA256 == algo) malgo3 = MHD_DIGEST_AUTH_MULT_ALGO3_SHA256; else MHD_PANIC (_ ("Wrong 'algo' value, API violation")); res = MHD_digest_auth_check_digest3 (connection, realm, username, digest, digest_size, nonce_timeout, 0, MHD_DIGEST_AUTH_MULT_QOP_AUTH, malgo3); if (MHD_DAUTH_OK == res) return MHD_YES; else if ((MHD_DAUTH_NONCE_STALE == res) || (MHD_DAUTH_NONCE_WRONG == res) || (MHD_DAUTH_NONCE_OTHER_COND == res) ) return MHD_INVALID_NONCE; return MHD_NO; } /** * Authenticates the authorization header sent by the client * Uses #MHD_DIGEST_ALG_MD5 (required, as @a digest is of fixed * size). * * @param connection The MHD connection structure * @param realm The realm presented to the client * @param username The username needs to be authenticated * @param digest An `unsigned char *' pointer to the binary hash * for the precalculated hash value "username:realm:password"; * length must be #MHD_MD5_DIGEST_SIZE bytes * @param nonce_timeout The amount of time for a nonce to be * invalid in seconds * @return #MHD_YES if authenticated, #MHD_NO if not, * #MHD_INVALID_NONCE if nonce is invalid or stale * @note Available since #MHD_VERSION 0x00096000 * @deprecated use #MHD_digest_auth_check_digest3() * @ingroup authentication */ _MHD_EXTERN int MHD_digest_auth_check_digest (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t digest[MHD_MD5_DIGEST_SIZE], unsigned int nonce_timeout) { return MHD_digest_auth_check_digest2 (connection, realm, username, digest, MHD_MD5_DIGEST_SIZE, nonce_timeout, MHD_DIGEST_ALG_MD5); } /** * Internal version of #MHD_queue_auth_required_response3() to simplify * cleanups. * * @param connection the MHD connection structure * @param realm the realm presented to the client * @param opaque the string for opaque value, can be NULL, but NULL is * not recommended for better compatibility with clients; * the recommended format is hex or Base64 encoded string * @param domain the optional space-separated list of URIs for which the * same authorisation could be used, URIs can be in form * "path-absolute" (the path for the same host with initial slash) * or in form "absolute-URI" (the full path with protocol), in * any case client may assume that URI is in the same "protection * space" if it starts with any of values specified here; * could be NULL (clients typically assume that the same * credentials could be used for any URI on the same host) * @param response the reply to send; should contain the "access denied" * body; note that this function sets the "WWW Authenticate" * header and that the caller should not do this; * the NULL is tolerated * @param signal_stale set to #MHD_YES if the nonce is stale to add 'stale=true' * to the authentication header, this instructs the client * to retry immediately with the new nonce and the same * credentials, without asking user for the new password * @param mqop the QOP to use * @param malgo3 digest algorithm to use, MHD selects; if several algorithms * are allowed then MD5 is preferred (currently, may be changed * in next versions) * @param userhash_support if set to non-zero value (#MHD_YES) then support of * userhash is indicated, the client may provide * hash("username:realm") instead of username in * clear text; * note that clients are allowed to provide the username * in cleartext even if this parameter set to non-zero; * when userhash is used, application must be ready to * identify users by provided userhash value instead of * username; see #MHD_digest_auth_calc_userhash() and * #MHD_digest_auth_calc_userhash_hex() * @param prefer_utf8 if not set to #MHD_NO, parameter 'charset=UTF-8' is * added, indicating for the client that UTF-8 encoding * is preferred * @param prefer_utf8 if not set to #MHD_NO, parameter 'charset=UTF-8' is * added, indicating for the client that UTF-8 encoding * is preferred * @return #MHD_YES on success, #MHD_NO otherwise * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ static enum MHD_Result queue_auth_required_response3_inner (struct MHD_Connection *connection, const char *realm, const char *opaque, const char *domain, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3, int userhash_support, int prefer_utf8, char **buf_ptr, struct DigestAlgorithm *da) { static const char prefix_realm[] = "realm=\""; static const char prefix_qop[] = "qop=\""; static const char prefix_algo[] = "algorithm="; static const char prefix_nonce[] = "nonce=\""; static const char prefix_opaque[] = "opaque=\""; static const char prefix_domain[] = "domain=\""; static const char str_charset[] = "charset=UTF-8"; static const char str_userhash[] = "userhash=true"; static const char str_stale[] = "stale=true"; enum MHD_DigestAuthAlgo3 s_algo; /**< Selected algorithm */ size_t realm_len; size_t opaque_len; size_t domain_len; size_t buf_size; char *buf; size_t p; /* The position in the buffer */ char *hdr_name; if (0 == (((unsigned int) malgo3) & MHD_DIGEST_AUTH_ALGO3_NON_SESSION)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Only non-'session' algorithms are supported.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } malgo3 = (enum MHD_DigestAuthMultiAlgo3) (malgo3 & (~((enum MHD_DigestAuthMultiAlgo3) MHD_DIGEST_AUTH_ALGO3_NON_SESSION))); #ifdef MHD_MD5_SUPPORT if (0 != (((unsigned int) malgo3) & MHD_DIGEST_BASE_ALGO_MD5)) s_algo = MHD_DIGEST_AUTH_ALGO3_MD5; else #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT if (0 != (((unsigned int) malgo3) & MHD_DIGEST_BASE_ALGO_SHA256)) s_algo = MHD_DIGEST_AUTH_ALGO3_SHA256; else #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT if (0 != (((unsigned int) malgo3) & MHD_DIGEST_BASE_ALGO_SHA512_256)) s_algo = MHD_DIGEST_AUTH_ALGO3_SHA512_256; else #endif /* MHD_SHA512_256_SUPPORT */ { if (0 == (((unsigned int) malgo3) & (MHD_DIGEST_BASE_ALGO_MD5 | MHD_DIGEST_BASE_ALGO_SHA512_256 | MHD_DIGEST_BASE_ALGO_SHA512_256))) MHD_PANIC (_ ("Wrong 'malgo3' value, API violation")); else { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("No requested algorithm is supported by this MHD build.\n")); #endif /* HAVE_MESSAGES */ } return MHD_NO; } if (MHD_DIGEST_AUTH_MULT_QOP_AUTH_INT == mqop) MHD_PANIC (_ ("Wrong 'mqop' value, API violation")); mqop = (enum MHD_DigestAuthMultiQOP) (mqop & (~((enum MHD_DigestAuthMultiQOP) MHD_DIGEST_AUTH_QOP_AUTH_INT))); if (! digest_init_one_time (da, get_base_digest_algo (s_algo))) MHD_PANIC (_ ("Wrong 'algo' value, API violation")); if (MHD_DIGEST_AUTH_MULT_QOP_NONE == mqop) { #ifdef HAVE_MESSAGES if ((0 != userhash_support) || (0 != prefer_utf8)) MHD_DLOG (connection->daemon, _ ("The 'userhash' and 'charset' ('prefer_utf8') parameters " \ "are not compatible with RFC2069 and ignored.\n")); if (0 == (((unsigned int) s_algo) & MHD_DIGEST_BASE_ALGO_MD5)) MHD_DLOG (connection->daemon, _ ("RFC2069 with SHA-256 or SHA-512/256 algorithm is " \ "non-standard extension.\n")); #endif userhash_support = 0; prefer_utf8 = 0; } if (0 == MHD_get_master (connection->daemon)->nonce_nc_size) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The nonce array size is zero.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } /* Calculate required size */ buf_size = 0; /* 'Digest ' */ buf_size += MHD_STATICSTR_LEN_ (_MHD_AUTH_DIGEST_BASE) + 1; /* 1 for ' ' */ buf_size += MHD_STATICSTR_LEN_ (prefix_realm) + 3; /* 3 for '", ' */ /* 'realm="xxxx", ' */ realm_len = strlen (realm); if (_MHD_AUTH_DIGEST_MAX_PARAM_SIZE < realm_len) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The 'realm' is too large.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } if ((NULL != memchr (realm, '\r', realm_len)) || (NULL != memchr (realm, '\n', realm_len))) return MHD_NO; buf_size += realm_len * 2; /* Quoting may double the size */ /* 'qop="xxxx", ' */ if (MHD_DIGEST_AUTH_MULT_QOP_NONE != mqop) { buf_size += MHD_STATICSTR_LEN_ (prefix_qop) + 3; /* 3 for '", ' */ buf_size += MHD_STATICSTR_LEN_ (MHD_TOKEN_AUTH_); } /* 'algorithm="xxxx", ' */ if (((MHD_DIGEST_AUTH_MULT_QOP_NONE) != mqop) || (0 == (((unsigned int) s_algo) & MHD_DIGEST_BASE_ALGO_MD5))) { buf_size += MHD_STATICSTR_LEN_ (prefix_algo) + 2; /* 2 for ', ' */ #ifdef MHD_MD5_SUPPORT if (MHD_DIGEST_AUTH_ALGO3_MD5 == s_algo) buf_size += MHD_STATICSTR_LEN_ (_MHD_MD5_TOKEN); else #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT if (MHD_DIGEST_AUTH_ALGO3_SHA256 == s_algo) buf_size += MHD_STATICSTR_LEN_ (_MHD_SHA256_TOKEN); else #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT if (MHD_DIGEST_AUTH_ALGO3_SHA512_256 == s_algo) buf_size += MHD_STATICSTR_LEN_ (_MHD_SHA512_256_TOKEN); else #endif /* MHD_SHA512_256_SUPPORT */ mhd_assert (0); } /* 'nonce="xxxx", ' */ buf_size += MHD_STATICSTR_LEN_ (prefix_nonce) + 3; /* 3 for '", ' */ buf_size += NONCE_STD_LEN (digest_get_size (da)); /* Escaping not needed */ /* 'opaque="xxxx", ' */ if (NULL != opaque) { buf_size += MHD_STATICSTR_LEN_ (prefix_opaque) + 3; /* 3 for '", ' */ opaque_len = strlen (opaque); if ((NULL != memchr (opaque, '\r', opaque_len)) || (NULL != memchr (opaque, '\n', opaque_len))) return MHD_NO; buf_size += opaque_len * 2; /* Quoting may double the size */ } else opaque_len = 0; /* 'domain="xxxx", ' */ if (NULL != domain) { buf_size += MHD_STATICSTR_LEN_ (prefix_domain) + 3; /* 3 for '", ' */ domain_len = strlen (domain); if ((NULL != memchr (domain, '\r', domain_len)) || (NULL != memchr (domain, '\n', domain_len))) return MHD_NO; buf_size += domain_len * 2; /* Quoting may double the size */ } else domain_len = 0; /* 'charset=UTF-8' */ if (MHD_NO != prefer_utf8) buf_size += MHD_STATICSTR_LEN_ (str_charset) + 2; /* 2 for ', ' */ /* 'userhash=true' */ if (MHD_NO != userhash_support) buf_size += MHD_STATICSTR_LEN_ (str_userhash) + 2; /* 2 for ', ' */ /* 'stale=true' */ if (MHD_NO != signal_stale) buf_size += MHD_STATICSTR_LEN_ (str_stale) + 2; /* 2 for ', ' */ /* The calculated length is for string ended with ", ". One character will * be used for zero-termination, the last one will not be used. */ /* Allocate the buffer */ buf = malloc (buf_size); if (NULL == buf) return MHD_NO; *buf_ptr = buf; /* Build the challenge string */ p = 0; /* 'Digest: ' */ memcpy (buf + p, _MHD_AUTH_DIGEST_BASE, MHD_STATICSTR_LEN_ (_MHD_AUTH_DIGEST_BASE)); p += MHD_STATICSTR_LEN_ (_MHD_AUTH_DIGEST_BASE); buf[p++] = ' '; /* 'realm="xxxx", ' */ memcpy (buf + p, prefix_realm, MHD_STATICSTR_LEN_ (prefix_realm)); p += MHD_STATICSTR_LEN_ (prefix_realm); mhd_assert ((buf_size - p) >= (realm_len * 2)); if (1) { size_t quoted_size; quoted_size = MHD_str_quote (realm, realm_len, buf + p, buf_size - p); if (_MHD_AUTH_DIGEST_MAX_PARAM_SIZE < quoted_size) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The 'realm' is too large after 'quoting'.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } p += quoted_size; } buf[p++] = '\"'; buf[p++] = ','; buf[p++] = ' '; /* 'qop="xxxx", ' */ if (MHD_DIGEST_AUTH_MULT_QOP_NONE != mqop) { memcpy (buf + p, prefix_qop, MHD_STATICSTR_LEN_ (prefix_qop)); p += MHD_STATICSTR_LEN_ (prefix_qop); memcpy (buf + p, MHD_TOKEN_AUTH_, MHD_STATICSTR_LEN_ (MHD_TOKEN_AUTH_)); p += MHD_STATICSTR_LEN_ (MHD_TOKEN_AUTH_); buf[p++] = '\"'; buf[p++] = ','; buf[p++] = ' '; } /* 'algorithm="xxxx", ' */ if (((MHD_DIGEST_AUTH_MULT_QOP_NONE) != mqop) || (0 == (((unsigned int) s_algo) & MHD_DIGEST_BASE_ALGO_MD5))) { memcpy (buf + p, prefix_algo, MHD_STATICSTR_LEN_ (prefix_algo)); p += MHD_STATICSTR_LEN_ (prefix_algo); #ifdef MHD_MD5_SUPPORT if (MHD_DIGEST_AUTH_ALGO3_MD5 == s_algo) { memcpy (buf + p, _MHD_MD5_TOKEN, MHD_STATICSTR_LEN_ (_MHD_MD5_TOKEN)); p += MHD_STATICSTR_LEN_ (_MHD_MD5_TOKEN); } else #endif /* MHD_MD5_SUPPORT */ #ifdef MHD_SHA256_SUPPORT if (MHD_DIGEST_AUTH_ALGO3_SHA256 == s_algo) { memcpy (buf + p, _MHD_SHA256_TOKEN, MHD_STATICSTR_LEN_ (_MHD_SHA256_TOKEN)); p += MHD_STATICSTR_LEN_ (_MHD_SHA256_TOKEN); } else #endif /* MHD_SHA256_SUPPORT */ #ifdef MHD_SHA512_256_SUPPORT if (MHD_DIGEST_AUTH_ALGO3_SHA512_256 == s_algo) { memcpy (buf + p, _MHD_SHA512_256_TOKEN, MHD_STATICSTR_LEN_ (_MHD_SHA512_256_TOKEN)); p += MHD_STATICSTR_LEN_ (_MHD_SHA512_256_TOKEN); } else #endif /* MHD_SHA512_256_SUPPORT */ mhd_assert (0); buf[p++] = ','; buf[p++] = ' '; } /* 'nonce="xxxx", ' */ memcpy (buf + p, prefix_nonce, MHD_STATICSTR_LEN_ (prefix_nonce)); p += MHD_STATICSTR_LEN_ (prefix_nonce); mhd_assert ((buf_size - p) >= (NONCE_STD_LEN (digest_get_size (da)))); if (! calculate_add_nonce_with_retry (connection, realm, da, buf + p)) { #ifdef MHD_DIGEST_HAS_EXT_ERROR if (digest_ext_error (da)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("TLS library reported hash calculation error, nonce could " "not be generated.\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } #endif /* MHD_DIGEST_HAS_EXT_ERROR */ #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Could not register nonce. Client's requests with this " "nonce will be always 'stale'. Probably clients' requests " "are too intensive.\n")); #endif /* HAVE_MESSAGES */ (void) 0; /* Mute compiler warning for builds without messages */ } p += NONCE_STD_LEN (digest_get_size (da)); buf[p++] = '\"'; buf[p++] = ','; buf[p++] = ' '; /* 'opaque="xxxx", ' */ if (NULL != opaque) { memcpy (buf + p, prefix_opaque, MHD_STATICSTR_LEN_ (prefix_opaque)); p += MHD_STATICSTR_LEN_ (prefix_opaque); mhd_assert ((buf_size - p) >= (opaque_len * 2)); p += MHD_str_quote (opaque, opaque_len, buf + p, buf_size - p); buf[p++] = '\"'; buf[p++] = ','; buf[p++] = ' '; } /* 'domain="xxxx", ' */ if (NULL != domain) { memcpy (buf + p, prefix_domain, MHD_STATICSTR_LEN_ (prefix_domain)); p += MHD_STATICSTR_LEN_ (prefix_domain); mhd_assert ((buf_size - p) >= (domain_len * 2)); p += MHD_str_quote (domain, domain_len, buf + p, buf_size - p); buf[p++] = '\"'; buf[p++] = ','; buf[p++] = ' '; } /* 'charset=UTF-8' */ if (MHD_NO != prefer_utf8) { memcpy (buf + p, str_charset, MHD_STATICSTR_LEN_ (str_charset)); p += MHD_STATICSTR_LEN_ (str_charset); buf[p++] = ','; buf[p++] = ' '; } /* 'userhash=true' */ if (MHD_NO != userhash_support) { memcpy (buf + p, str_userhash, MHD_STATICSTR_LEN_ (str_userhash)); p += MHD_STATICSTR_LEN_ (str_userhash); buf[p++] = ','; buf[p++] = ' '; } /* 'stale=true' */ if (MHD_NO != signal_stale) { memcpy (buf + p, str_stale, MHD_STATICSTR_LEN_ (str_stale)); p += MHD_STATICSTR_LEN_ (str_stale); buf[p++] = ','; buf[p++] = ' '; } mhd_assert (buf_size >= p); /* The built string ends with ", ". Replace comma with zero-termination. */ --p; buf[--p] = 0; hdr_name = malloc (MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_WWW_AUTHENTICATE) + 1); if (NULL != hdr_name) { memcpy (hdr_name, MHD_HTTP_HEADER_WWW_AUTHENTICATE, MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_WWW_AUTHENTICATE) + 1); if (MHD_add_response_entry_no_alloc_ (response, MHD_HEADER_KIND, hdr_name, MHD_STATICSTR_LEN_ ( \ MHD_HTTP_HEADER_WWW_AUTHENTICATE), buf, p)) { *buf_ptr = NULL; /* The buffer will be free()ed when the response is destroyed */ return MHD_queue_response (connection, MHD_HTTP_UNAUTHORIZED, response); } #ifdef HAVE_MESSAGES else { MHD_DLOG (connection->daemon, _ ("Failed to add Digest auth header.\n")); } #endif /* HAVE_MESSAGES */ free (hdr_name); } return MHD_NO; } /** * Queues a response to request authentication from the client * * This function modifies provided @a response. The @a response must not be * reused and should be destroyed (by #MHD_destroy_response()) after call of * this function. * * If @a mqop allows both RFC 2069 (MHD_DIGEST_AUTH_QOP_NONE) and QOP with * value, then response is formed like if MHD_DIGEST_AUTH_QOP_NONE bit was * not set, because such response should be backward-compatible with RFC 2069. * * If @a mqop allows only MHD_DIGEST_AUTH_MULT_QOP_NONE, then the response is * formed in strict accordance with RFC 2069 (no 'qop', no 'userhash', no * 'charset'). For better compatibility with clients, it is recommended (but * not required) to set @a domain to NULL in this mode. * * @param connection the MHD connection structure * @param realm the realm presented to the client * @param opaque the string for opaque value, can be NULL, but NULL is * not recommended for better compatibility with clients; * the recommended format is hex or Base64 encoded string * @param domain the optional space-separated list of URIs for which the * same authorisation could be used, URIs can be in form * "path-absolute" (the path for the same host with initial slash) * or in form "absolute-URI" (the full path with protocol), in * any case client may assume that URI is in the same "protection * space" if it starts with any of values specified here; * could be NULL (clients typically assume that the same * credentials could be used for any URI on the same host); * this list provides information for the client only and does * not actually restrict anything on the server side * @param response the reply to send; should contain the "access denied" * body; * note: this function sets the "WWW Authenticate" header and * the caller should not set this header; * the NULL is tolerated * @param signal_stale if set to #MHD_YES then indication of stale nonce used in * the client's request is signalled by adding 'stale=true' * to the authentication header, this instructs the client * to retry immediately with the new nonce and the same * credentials, without asking user for the new password * @param mqop the QOP to use * @param malgo3 digest algorithm to use; if several algorithms are allowed * then MD5 is preferred (currently, may be changed in next * versions) * @param userhash_support if set to non-zero value (#MHD_YES) then support of * userhash is indicated, allowing client to provide * hash("username:realm") instead of the username in * clear text; * note that clients are allowed to provide the username * in cleartext even if this parameter set to non-zero; * when userhash is used, application must be ready to * identify users by provided userhash value instead of * username; see #MHD_digest_auth_calc_userhash() and * #MHD_digest_auth_calc_userhash_hex() * @param prefer_utf8 if not set to #MHD_NO, parameter 'charset=UTF-8' is * added, indicating for the client that UTF-8 encoding for * the username is preferred * @return #MHD_YES on success, #MHD_NO otherwise * @note Available since #MHD_VERSION 0x00097701 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_queue_auth_required_response3 (struct MHD_Connection *connection, const char *realm, const char *opaque, const char *domain, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3, int userhash_support, int prefer_utf8) { struct DigestAlgorithm da; char *buf_ptr; enum MHD_Result ret; buf_ptr = NULL; digest_setup_zero (&da); ret = queue_auth_required_response3_inner (connection, realm, opaque, domain, response, signal_stale, mqop, malgo3, userhash_support, prefer_utf8, &buf_ptr, &da); digest_deinit (&da); if (NULL != buf_ptr) free (buf_ptr); return ret; } /** * Queues a response to request authentication from the client * * @param connection The MHD connection structure * @param realm the realm presented to the client * @param opaque string to user for opaque value * @param response reply to send; should contain the "access denied" * body; note that this function will set the "WWW Authenticate" * header and that the caller should not do this; the NULL is tolerated * @param signal_stale #MHD_YES if the nonce is stale to add * 'stale=true' to the authentication header * @param algo digest algorithm to use * @return #MHD_YES on success, #MHD_NO otherwise * @note Available since #MHD_VERSION 0x00096200 * @ingroup authentication */ _MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response2 (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthAlgorithm algo) { enum MHD_DigestAuthMultiAlgo3 algo3; if (MHD_DIGEST_ALG_MD5 == algo) algo3 = MHD_DIGEST_AUTH_MULT_ALGO3_MD5; else if (MHD_DIGEST_ALG_SHA256 == algo) algo3 = MHD_DIGEST_AUTH_MULT_ALGO3_SHA256; else if (MHD_DIGEST_ALG_AUTO == algo) algo3 = MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION; else MHD_PANIC (_ ("Wrong algo value.\n")); /* API violation! */ return MHD_queue_auth_required_response3 (connection, realm, opaque, NULL, response, signal_stale, MHD_DIGEST_AUTH_MULT_QOP_AUTH, algo3, 0, 0); } /** * Queues a response to request authentication from the client. * For now uses MD5 (for backwards-compatibility). Still, if you * need to be sure, use #MHD_queue_auth_fail_response2(). * * @param connection The MHD connection structure * @param realm the realm presented to the client * @param opaque string to user for opaque value * @param response reply to send; should contain the "access denied" * body; note that this function will set the "WWW Authenticate" * header and that the caller should not do this; the NULL is tolerated * @param signal_stale #MHD_YES if the nonce is stale to add * 'stale=true' to the authentication header * @return #MHD_YES on success, #MHD_NO otherwise * @ingroup authentication * @deprecated use MHD_queue_auth_fail_response2() */ _MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale) { return MHD_queue_auth_fail_response2 (connection, realm, opaque, response, signal_stale, MHD_DIGEST_ALG_MD5); } /* end of digestauth.c */ libmicrohttpd-1.0.1/src/microhttpd/postprocessor.c0000644000175000017500000011263014556705750016114 /* This file is part of libmicrohttpd Copyright (C) 2007-2021 Daniel Pittman and Christian Grothoff Copyright (C) 2014-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file postprocessor.c * @brief Methods for parsing POST data * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "postprocessor.h" #include "internal.h" #include "mhd_str.h" #include "mhd_compat.h" #include "mhd_assert.h" /** * Size of on-stack buffer that we use for un-escaping of the value. * We use a pretty small value to be nice to the stack on embedded * systems. */ #define XBUF_SIZE 512 _MHD_EXTERN struct MHD_PostProcessor * MHD_create_post_processor (struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iter, void *iter_cls) { struct MHD_PostProcessor *ret; const char *encoding; const char *boundary; size_t blen; if ( (buffer_size < 256) || (NULL == connection) || (NULL == iter)) MHD_PANIC (_ ("libmicrohttpd API violation.\n")); encoding = NULL; if (MHD_NO == MHD_lookup_connection_value_n (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE, MHD_STATICSTR_LEN_ ( MHD_HTTP_HEADER_CONTENT_TYPE), &encoding, NULL)) return NULL; mhd_assert (NULL != encoding); boundary = NULL; if (! MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED, encoding, MHD_STATICSTR_LEN_ ( MHD_HTTP_POST_ENCODING_FORM_URLENCODED))) { if (! MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA, encoding, MHD_STATICSTR_LEN_ ( MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA))) return NULL; boundary = &encoding[MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA)]; /* Q: should this be "strcasestr"? */ boundary = strstr (boundary, "boundary="); if (NULL == boundary) return NULL; /* failed to determine boundary */ boundary += MHD_STATICSTR_LEN_ ("boundary="); blen = strlen (boundary); if ( (blen < 2) || (blen * 2 + 2 > buffer_size) ) return NULL; /* (will be) out of memory or invalid boundary */ if ( (boundary[0] == '"') && (boundary[blen - 1] == '"') ) { /* remove enclosing quotes */ ++boundary; blen -= 2; } } else blen = 0; buffer_size += 4; /* round up to get nice block sizes despite boundary search */ /* add +1 to ensure we ALWAYS have a zero-termination at the end */ if (NULL == (ret = MHD_calloc_ (1, sizeof (struct MHD_PostProcessor) + buffer_size + 1))) return NULL; ret->connection = connection; ret->ikvi = iter; ret->cls = iter_cls; ret->encoding = encoding; ret->buffer_size = buffer_size; ret->state = PP_Init; ret->blen = blen; ret->boundary = boundary; ret->skip_rn = RN_Inactive; return ret; } /** * Give a (possibly partial) value to the application callback. We have some * part of the value in the 'pp->xbuf', the rest is between @a value_start and * @a value_end. If @a last_escape is non-NULL, there may be an incomplete * escape sequence at at @a value_escape between @a value_start and @a * value_end which we should preserve in 'pp->xbuf' for the future. * * Unescapes the value and calls the iterator together with the key. The key * must already be in the key buffer allocated and 0-terminated at the end of * @a pp at the time of the call. * * @param[in,out] pp post processor to act upon * @param value_start where in memory is the value * @param value_end where does the value end * @param last_escape last '%'-sign in value range, * if relevant, or NULL */ static void process_value (struct MHD_PostProcessor *pp, const char *value_start, const char *value_end, const char *last_escape) { char xbuf[XBUF_SIZE + 1]; size_t xoff; mhd_assert (pp->xbuf_pos < sizeof (xbuf)); /* 'value_start' and 'value_end' must be either both non-NULL or both NULL */ mhd_assert ( (NULL == value_start) || (NULL != value_end) ); mhd_assert ( (NULL != value_start) || (NULL == value_end) ); mhd_assert ( (NULL == last_escape) || (NULL != value_start) ); /* move remaining input from previous round into processing buffer */ if (0 != pp->xbuf_pos) memcpy (xbuf, pp->xbuf, pp->xbuf_pos); xoff = pp->xbuf_pos; pp->xbuf_pos = 0; if ( (NULL != last_escape) && (((size_t) (value_end - last_escape)) < sizeof (pp->xbuf)) ) { mhd_assert (value_end >= last_escape); pp->xbuf_pos = (size_t) (value_end - last_escape); memcpy (pp->xbuf, last_escape, (size_t) (value_end - last_escape)); value_end = last_escape; } while ( (value_start != value_end) || (pp->must_ikvi) || (xoff > 0) ) { size_t delta = (size_t) (value_end - value_start); bool cut = false; size_t clen = 0; mhd_assert (value_end >= value_start); if (delta > XBUF_SIZE - xoff) delta = XBUF_SIZE - xoff; /* move (additional) input into processing buffer */ if (0 != delta) { memcpy (&xbuf[xoff], value_start, delta); xoff += delta; value_start += delta; } /* find if escape sequence is at the end of the processing buffer; if so, exclude those from processing (reduce delta to point at end of processed region) */ if ( (xoff > 0) && ('%' == xbuf[xoff - 1]) ) { cut = (xoff != XBUF_SIZE); xoff--; if (cut) { /* move escape sequence into buffer for next function invocation */ pp->xbuf[0] = '%'; pp->xbuf_pos = 1; } else { /* just skip escape sequence for next loop iteration */ delta = xoff; clen = 1; } } else if ( (xoff > 1) && ('%' == xbuf[xoff - 2]) ) { cut = (xoff != XBUF_SIZE); xoff -= 2; if (cut) { /* move escape sequence into buffer for next function invocation */ memcpy (pp->xbuf, &xbuf[xoff], 2); pp->xbuf_pos = 2; } else { /* just skip escape sequence for next loop iteration */ delta = xoff; clen = 2; } } mhd_assert (xoff < sizeof (xbuf)); /* unescape */ xbuf[xoff] = '\0'; /* 0-terminate in preparation */ if (0 != xoff) { MHD_unescape_plus (xbuf); xoff = MHD_http_unescape (xbuf); } /* finally: call application! */ if (pp->must_ikvi || (0 != xoff) ) { pp->must_ikvi = false; if (MHD_NO == pp->ikvi (pp->cls, MHD_POSTDATA_KIND, (const char *) &pp[1], /* key */ NULL, NULL, NULL, xbuf, pp->value_offset, xoff)) { pp->state = PP_Error; return; } } pp->value_offset += xoff; if (cut) break; if (0 != clen) { xbuf[delta] = '%'; /* undo 0-termination */ memmove (xbuf, &xbuf[delta], clen); } xoff = clen; } } /** * Process url-encoded POST data. * * @param pp post processor context * @param post_data upload data * @param post_data_len number of bytes in @a post_data * @return #MHD_YES on success, #MHD_NO if there was an error processing the data */ static enum MHD_Result post_process_urlencoded (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len) { char *kbuf = (char *) &pp[1]; size_t poff; const char *start_key = NULL; const char *end_key = NULL; const char *start_value = NULL; const char *end_value = NULL; const char *last_escape = NULL; mhd_assert (PP_Callback != pp->state); poff = 0; while ( ( (poff < post_data_len) || (pp->state == PP_Callback) ) && (pp->state != PP_Error) ) { switch (pp->state) { case PP_Error: /* clearly impossible as per while loop invariant */ abort (); break; /* Unreachable */ case PP_Init: /* initial phase */ mhd_assert (NULL == start_key); mhd_assert (NULL == end_key); mhd_assert (NULL == start_value); mhd_assert (NULL == end_value); switch (post_data[poff]) { case '=': /* Case: (no key)'=' */ /* Empty key with value */ pp->state = PP_Error; continue; case '&': /* Case: (no key)'&' */ /* Empty key without value */ poff++; continue; case '\n': case '\r': /* Case: (no key)'\n' or (no key)'\r' */ pp->state = PP_Done; poff++; break; default: /* normal character, key start, advance! */ pp->state = PP_ProcessKey; start_key = &post_data[poff]; pp->must_ikvi = true; poff++; continue; } break; /* end PP_Init */ case PP_ProcessKey: /* key phase */ mhd_assert (NULL == start_value); mhd_assert (NULL == end_value); mhd_assert (NULL != start_key || 0 == poff); mhd_assert (0 != poff || NULL == start_key); mhd_assert (NULL == end_key); switch (post_data[poff]) { case '=': /* Case: 'key=' */ if (0 != poff) end_key = &post_data[poff]; poff++; pp->state = PP_ProcessValue; break; case '&': /* Case: 'key&' */ if (0 != poff) end_key = &post_data[poff]; poff++; pp->state = PP_Callback; break; case '\n': case '\r': /* Case: 'key\n' or 'key\r' */ if (0 != poff) end_key = &post_data[poff]; /* No advance here, 'PP_Done' will be selected by next 'PP_Init' phase */ pp->state = PP_Callback; break; default: /* normal character, advance! */ if (0 == poff) start_key = post_data; poff++; break; } mhd_assert (NULL == end_key || NULL != start_key); break; /* end PP_ProcessKey */ case PP_ProcessValue: if (NULL == start_value) start_value = &post_data[poff]; switch (post_data[poff]) { case '=': /* case 'key==' */ pp->state = PP_Error; continue; case '&': /* case 'value&' */ end_value = &post_data[poff]; poff++; if (pp->must_ikvi || (start_value != end_value) ) { pp->state = PP_Callback; } else { pp->buffer_pos = 0; pp->value_offset = 0; pp->state = PP_Init; start_value = NULL; end_value = NULL; } continue; case '\n': case '\r': /* Case: 'value\n' or 'value\r' */ end_value = &post_data[poff]; if (pp->must_ikvi || (start_value != end_value) ) pp->state = PP_Callback; /* No poff advance here to set PP_Done in the next iteration */ else { poff++; pp->state = PP_Done; } break; case '%': last_escape = &post_data[poff]; poff++; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* character, may be part of escaping */ poff++; continue; default: /* normal character, no more escaping! */ last_escape = NULL; poff++; continue; } break; /* end PP_ProcessValue */ case PP_Done: switch (post_data[poff]) { case '\n': case '\r': poff++; continue; } /* unexpected data at the end, fail! */ pp->state = PP_Error; break; case PP_Callback: mhd_assert ((NULL != end_key) || (NULL == start_key)); if (1) { const size_t key_len = (size_t) (end_key - start_key); mhd_assert (end_key >= start_key); if (0 != key_len) { if ( (pp->buffer_pos + key_len >= pp->buffer_size) || (pp->buffer_pos + key_len < pp->buffer_pos) ) { /* key too long, cannot parse! */ pp->state = PP_Error; continue; } /* compute key, if we have not already */ memcpy (&kbuf[pp->buffer_pos], start_key, key_len); pp->buffer_pos += key_len; start_key = NULL; end_key = NULL; pp->must_unescape_key = true; } } #ifdef _DEBUG else mhd_assert (0 != pp->buffer_pos); #endif /* _DEBUG */ if (pp->must_unescape_key) { kbuf[pp->buffer_pos] = '\0'; /* 0-terminate key */ MHD_unescape_plus (kbuf); MHD_http_unescape (kbuf); pp->must_unescape_key = false; } process_value (pp, start_value, end_value, NULL); if (PP_Error == pp->state) continue; pp->value_offset = 0; start_value = NULL; end_value = NULL; pp->buffer_pos = 0; pp->state = PP_Init; break; case PP_NextBoundary: case PP_ProcessEntryHeaders: case PP_PerformCheckMultipart: case PP_ProcessValueToBoundary: case PP_PerformCleanup: case PP_Nested_Init: case PP_Nested_PerformMarking: case PP_Nested_ProcessEntryHeaders: case PP_Nested_ProcessValueToBoundary: case PP_Nested_PerformCleanup: default: MHD_PANIC (_ ("internal error.\n")); /* should never happen! */ } mhd_assert ((end_key == NULL) || (start_key != NULL)); mhd_assert ((end_value == NULL) || (start_value != NULL)); } mhd_assert (PP_Callback != pp->state); if (PP_Error == pp->state) { /* State in error, returning failure */ return MHD_NO; } /* save remaining data for next iteration */ if (NULL != start_key) { size_t key_len; mhd_assert ((PP_ProcessKey == pp->state) || (NULL != end_key)); if (NULL == end_key) end_key = &post_data[poff]; mhd_assert (end_key >= start_key); key_len = (size_t) (end_key - start_key); mhd_assert (0 != key_len); /* it must be always non-zero here */ if (pp->buffer_pos + key_len >= pp->buffer_size) { pp->state = PP_Error; return MHD_NO; } memcpy (&kbuf[pp->buffer_pos], start_key, key_len); pp->buffer_pos += key_len; pp->must_unescape_key = true; start_key = NULL; end_key = NULL; } if ( (NULL != start_value) && (PP_ProcessValue == pp->state) ) { /* compute key, if we have not already */ if (pp->must_unescape_key) { kbuf[pp->buffer_pos] = '\0'; /* 0-terminate key */ MHD_unescape_plus (kbuf); MHD_http_unescape (kbuf); pp->must_unescape_key = false; } if (NULL == end_value) end_value = &post_data[poff]; if ( (NULL != last_escape) && (2 < (end_value - last_escape)) ) last_escape = NULL; process_value (pp, start_value, end_value, last_escape); pp->must_ikvi = false; } if (PP_Error == pp->state) { /* State in error, returning failure */ return MHD_NO; } return MHD_YES; } /** * If the given line matches the prefix, strdup the * rest of the line into the suffix ptr. * * @param prefix prefix to match * @param prefix_len length of @a prefix * @param line line to match prefix in * @param suffix set to a copy of the rest of the line, starting at the end of the match * @return #MHD_YES if there was a match, #MHD_NO if not */ static int try_match_header (const char *prefix, size_t prefix_len, char *line, char **suffix) { if (NULL != *suffix) return MHD_NO; while (0 != *line) { if (MHD_str_equal_caseless_n_ (prefix, line, prefix_len)) { *suffix = strdup (&line[prefix_len]); return MHD_YES; } ++line; } return MHD_NO; } /** * * @param pp post processor context * @param boundary boundary to look for * @param blen number of bytes in boundary * @param ioffptr set to the end of the boundary if found, * otherwise incremented by one (FIXME: quirky API!) * @param next_state state to which we should advance the post processor * if the boundary is found * @param next_dash_state dash_state to which we should advance the * post processor if the boundary is found * @return #MHD_NO if the boundary is not found, #MHD_YES if we did find it */ static int find_boundary (struct MHD_PostProcessor *pp, const char *boundary, size_t blen, size_t *ioffptr, enum PP_State next_state, enum PP_State next_dash_state) { char *buf = (char *) &pp[1]; const char *dash; if (pp->buffer_pos < 2 + blen) { if (pp->buffer_pos == pp->buffer_size) pp->state = PP_Error; /* out of memory */ /* ++(*ioffptr); */ return MHD_NO; /* not enough data */ } if ( (0 != memcmp ("--", buf, 2)) || (0 != memcmp (&buf[2], boundary, blen))) { if (pp->state != PP_Init) { /* garbage not allowed */ pp->state = PP_Error; } else { /* skip over garbage (RFC 2046, 5.1.1) */ dash = memchr (buf, '-', pp->buffer_pos); if (NULL == dash) (*ioffptr) += pp->buffer_pos; /* skip entire buffer */ else if (dash == buf) (*ioffptr)++; /* at least skip one byte */ else (*ioffptr) += (size_t) (dash - buf); /* skip to first possible boundary */ } return MHD_NO; /* expected boundary */ } /* remove boundary from buffer */ (*ioffptr) += 2 + blen; /* next: start with headers */ pp->skip_rn = RN_Dash; pp->state = next_state; pp->dash_state = next_dash_state; return MHD_YES; } /** * In buf, there maybe an expression '$key="$value"'. If that is the * case, copy a copy of $value to destination. * * If destination is already non-NULL, do nothing. */ static void try_get_value (const char *buf, const char *key, char **destination) { const char *spos; const char *bpos; const char *endv; size_t klen; size_t vlen; if (NULL != *destination) return; bpos = buf; klen = strlen (key); while (NULL != (spos = strstr (bpos, key))) { if ( (spos[klen] != '=') || ( (spos != buf) && (spos[-1] != ' ') ) ) { /* no match */ bpos = spos + 1; continue; } if (spos[klen + 1] != '"') return; /* not quoted */ if (NULL == (endv = strchr (&spos[klen + 2], '\"'))) return; /* no end-quote */ vlen = (size_t) (endv - spos) - klen - 1; *destination = malloc (vlen); if (NULL == *destination) return; /* out of memory */ (*destination)[vlen - 1] = '\0'; memcpy (*destination, &spos[klen + 2], vlen - 1); return; /* success */ } } /** * Go over the headers of the part and update * the fields in "pp" according to what we find. * If we are at the end of the headers (as indicated * by an empty line), transition into next_state. * * @param pp post processor context * @param ioffptr set to how many bytes have been * processed * @param next_state state to which the post processor should * be advanced if we find the end of the headers * @return #MHD_YES if we can continue processing, * #MHD_NO on error or if we do not have * enough data yet */ static int process_multipart_headers (struct MHD_PostProcessor *pp, size_t *ioffptr, enum PP_State next_state) { char *buf = (char *) &pp[1]; size_t newline; newline = 0; while ( (newline < pp->buffer_pos) && (buf[newline] != '\r') && (buf[newline] != '\n') ) newline++; if (newline == pp->buffer_size) { pp->state = PP_Error; return MHD_NO; /* out of memory */ } if (newline == pp->buffer_pos) return MHD_NO; /* will need more data */ if (0 == newline) { /* empty line - end of headers */ pp->skip_rn = RN_Full; pp->state = next_state; return MHD_YES; } /* got an actual header */ if (buf[newline] == '\r') pp->skip_rn = RN_OptN; buf[newline] = '\0'; if (MHD_str_equal_caseless_n_ ("Content-disposition: ", buf, MHD_STATICSTR_LEN_ ("Content-disposition: "))) { try_get_value (&buf[MHD_STATICSTR_LEN_ ("Content-disposition: ")], "name", &pp->content_name); try_get_value (&buf[MHD_STATICSTR_LEN_ ("Content-disposition: ")], "filename", &pp->content_filename); } else { try_match_header ("Content-type: ", MHD_STATICSTR_LEN_ ("Content-type: "), buf, &pp->content_type); try_match_header ("Content-Transfer-Encoding: ", MHD_STATICSTR_LEN_ ("Content-Transfer-Encoding: "), buf, &pp->content_transfer_encoding); } (*ioffptr) += newline + 1; return MHD_YES; } /** * We have the value until we hit the given boundary; * process accordingly. * * @param pp post processor context * @param ioffptr incremented based on the number of bytes processed * @param boundary the boundary to look for * @param blen strlen(boundary) * @param next_state what state to go into after the * boundary was found * @param next_dash_state state to go into if the next * boundary ends with "--" * @return #MHD_YES if we can continue processing, * #MHD_NO on error or if we do not have * enough data yet */ static int process_value_to_boundary (struct MHD_PostProcessor *pp, size_t *ioffptr, const char *boundary, size_t blen, enum PP_State next_state, enum PP_State next_dash_state) { char *buf = (char *) &pp[1]; size_t newline; const char *r; /* all data in buf until the boundary (\r\n--+boundary) is part of the value */ newline = 0; while (1) { while (newline + 4 < pp->buffer_pos) { r = memchr (&buf[newline], '\r', pp->buffer_pos - newline - 4); if (NULL == r) { newline = pp->buffer_pos - 4; break; } newline = (size_t) (r - buf); if (0 == memcmp ("\r\n--", &buf[newline], 4)) break; newline++; } if (newline + blen + 4 <= pp->buffer_pos) { /* can check boundary */ if (0 != memcmp (&buf[newline + 4], boundary, blen)) { /* no boundary, "\r\n--" is part of content, skip */ newline += 4; continue; } else { /* boundary found, process until newline then skip boundary and go back to init */ pp->skip_rn = RN_Dash; pp->state = next_state; pp->dash_state = next_dash_state; (*ioffptr) += blen + 4; /* skip boundary as well */ buf[newline] = '\0'; break; } } else { /* cannot check for boundary, process content that we have and check again later; except, if we have no content, abort (out of memory) */ if ( (0 == newline) && (pp->buffer_pos == pp->buffer_size) ) { pp->state = PP_Error; return MHD_NO; } break; } } /* newline is either at beginning of boundary or at least at the last character that we are sure is not part of the boundary */ if ( ( (pp->must_ikvi) || (0 != newline) ) && (MHD_NO == pp->ikvi (pp->cls, MHD_POSTDATA_KIND, pp->content_name, pp->content_filename, pp->content_type, pp->content_transfer_encoding, buf, pp->value_offset, newline)) ) { pp->state = PP_Error; return MHD_NO; } pp->must_ikvi = false; pp->value_offset += newline; (*ioffptr) += newline; return MHD_YES; } /** * * @param pp post processor context */ static void free_unmarked (struct MHD_PostProcessor *pp) { if ( (NULL != pp->content_name) && (0 == (pp->have & NE_content_name)) ) { free (pp->content_name); pp->content_name = NULL; } if ( (NULL != pp->content_type) && (0 == (pp->have & NE_content_type)) ) { free (pp->content_type); pp->content_type = NULL; } if ( (NULL != pp->content_filename) && (0 == (pp->have & NE_content_filename)) ) { free (pp->content_filename); pp->content_filename = NULL; } if ( (NULL != pp->content_transfer_encoding) && (0 == (pp->have & NE_content_transfer_encoding)) ) { free (pp->content_transfer_encoding); pp->content_transfer_encoding = NULL; } } /** * Decode multipart POST data. * * @param pp post processor context * @param post_data data to decode * @param post_data_len number of bytes in @a post_data * @return #MHD_NO on error, */ static enum MHD_Result post_process_multipart (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len) { char *buf; size_t max; size_t ioff; size_t poff; int state_changed; buf = (char *) &pp[1]; ioff = 0; poff = 0; state_changed = 1; while ( (poff < post_data_len) || ( (pp->buffer_pos > 0) && (0 != state_changed) ) ) { /* first, move as much input data as possible to our internal buffer */ max = pp->buffer_size - pp->buffer_pos; if (max > post_data_len - poff) max = post_data_len - poff; memcpy (&buf[pp->buffer_pos], &post_data[poff], max); poff += max; pp->buffer_pos += max; if ( (0 == max) && (0 == state_changed) && (poff < post_data_len) ) { pp->state = PP_Error; return MHD_NO; /* out of memory */ } state_changed = 0; /* first state machine for '\r'-'\n' and '--' handling */ switch (pp->skip_rn) { case RN_Inactive: break; case RN_OptN: if (buf[0] == '\n') { ioff++; pp->skip_rn = RN_Inactive; goto AGAIN; } /* fall-through! */ case RN_Dash: if (buf[0] == '-') { ioff++; pp->skip_rn = RN_Dash2; goto AGAIN; } pp->skip_rn = RN_Full; /* fall-through! */ case RN_Full: if (buf[0] == '\r') { if ( (pp->buffer_pos > 1) && ('\n' == buf[1]) ) { pp->skip_rn = RN_Inactive; ioff += 2; } else { pp->skip_rn = RN_OptN; ioff++; } goto AGAIN; } if (buf[0] == '\n') { ioff++; pp->skip_rn = RN_Inactive; goto AGAIN; } pp->skip_rn = RN_Inactive; pp->state = PP_Error; return MHD_NO; /* no '\r\n' */ case RN_Dash2: if (buf[0] == '-') { ioff++; pp->skip_rn = RN_Full; pp->state = pp->dash_state; goto AGAIN; } pp->state = PP_Error; break; } /* main state engine */ switch (pp->state) { case PP_Error: return MHD_NO; case PP_Done: /* did not expect to receive more data */ pp->state = PP_Error; return MHD_NO; case PP_Init: /** * Per RFC2046 5.1.1 NOTE TO IMPLEMENTORS, consume anything * prior to the first multipart boundary: * * > There appears to be room for additional information prior * > to the first boundary delimiter line and following the * > final boundary delimiter line. These areas should * > generally be left blank, and implementations must ignore * > anything that appears before the first boundary delimiter * > line or after the last one. */ (void) find_boundary (pp, pp->boundary, pp->blen, &ioff, PP_ProcessEntryHeaders, PP_Done); break; case PP_NextBoundary: if (MHD_NO == find_boundary (pp, pp->boundary, pp->blen, &ioff, PP_ProcessEntryHeaders, PP_Done)) { if (pp->state == PP_Error) return MHD_NO; goto END; } break; case PP_ProcessEntryHeaders: pp->must_ikvi = true; if (MHD_NO == process_multipart_headers (pp, &ioff, PP_PerformCheckMultipart)) { if (pp->state == PP_Error) return MHD_NO; else goto END; } state_changed = 1; break; case PP_PerformCheckMultipart: if ( (NULL != pp->content_type) && (MHD_str_equal_caseless_n_ (pp->content_type, "multipart/mixed", MHD_STATICSTR_LEN_ ("multipart/mixed")))) { pp->nested_boundary = strstr (pp->content_type, "boundary="); if (NULL == pp->nested_boundary) { pp->state = PP_Error; return MHD_NO; } pp->nested_boundary = strdup (&pp->nested_boundary[MHD_STATICSTR_LEN_ ("boundary=")]); if (NULL == pp->nested_boundary) { /* out of memory */ pp->state = PP_Error; return MHD_NO; } /* free old content type, we will need that field for the content type of the nested elements */ free (pp->content_type); pp->content_type = NULL; pp->nlen = strlen (pp->nested_boundary); pp->state = PP_Nested_Init; state_changed = 1; break; } pp->state = PP_ProcessValueToBoundary; pp->value_offset = 0; state_changed = 1; break; case PP_ProcessValueToBoundary: if (MHD_NO == process_value_to_boundary (pp, &ioff, pp->boundary, pp->blen, PP_PerformCleanup, PP_Done)) { if (pp->state == PP_Error) return MHD_NO; break; } break; case PP_PerformCleanup: /* clean up state of one multipart form-data element! */ pp->have = NE_none; free_unmarked (pp); if (NULL != pp->nested_boundary) { free (pp->nested_boundary); pp->nested_boundary = NULL; } pp->state = PP_ProcessEntryHeaders; state_changed = 1; break; case PP_Nested_Init: if (NULL == pp->nested_boundary) { pp->state = PP_Error; return MHD_NO; } if (MHD_NO == find_boundary (pp, pp->nested_boundary, pp->nlen, &ioff, PP_Nested_PerformMarking, PP_NextBoundary /* or PP_Error? */)) { if (pp->state == PP_Error) return MHD_NO; goto END; } break; case PP_Nested_PerformMarking: /* remember what headers were given globally */ pp->have = NE_none; if (NULL != pp->content_name) pp->have |= NE_content_name; if (NULL != pp->content_type) pp->have |= NE_content_type; if (NULL != pp->content_filename) pp->have |= NE_content_filename; if (NULL != pp->content_transfer_encoding) pp->have |= NE_content_transfer_encoding; pp->state = PP_Nested_ProcessEntryHeaders; state_changed = 1; break; case PP_Nested_ProcessEntryHeaders: pp->value_offset = 0; if (MHD_NO == process_multipart_headers (pp, &ioff, PP_Nested_ProcessValueToBoundary)) { if (pp->state == PP_Error) return MHD_NO; else goto END; } state_changed = 1; break; case PP_Nested_ProcessValueToBoundary: if (MHD_NO == process_value_to_boundary (pp, &ioff, pp->nested_boundary, pp->nlen, PP_Nested_PerformCleanup, PP_NextBoundary)) { if (pp->state == PP_Error) return MHD_NO; break; } break; case PP_Nested_PerformCleanup: free_unmarked (pp); pp->state = PP_Nested_ProcessEntryHeaders; state_changed = 1; break; case PP_ProcessKey: case PP_ProcessValue: case PP_Callback: default: MHD_PANIC (_ ("internal error.\n")); /* should never happen! */ } AGAIN: if (ioff > 0) { memmove (buf, &buf[ioff], pp->buffer_pos - ioff); pp->buffer_pos -= ioff; ioff = 0; state_changed = 1; } } END: if (0 != ioff) { memmove (buf, &buf[ioff], pp->buffer_pos - ioff); pp->buffer_pos -= ioff; } if (poff < post_data_len) { pp->state = PP_Error; return MHD_NO; /* serious error */ } return MHD_YES; } _MHD_EXTERN enum MHD_Result MHD_post_process (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len) { if (0 == post_data_len) return MHD_YES; if (NULL == pp) return MHD_NO; if (MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED, pp->encoding, MHD_STATICSTR_LEN_ ( MHD_HTTP_POST_ENCODING_FORM_URLENCODED))) return post_process_urlencoded (pp, post_data, post_data_len); if (MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA, pp->encoding, MHD_STATICSTR_LEN_ ( MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA))) return post_process_multipart (pp, post_data, post_data_len); /* this should never be reached */ return MHD_NO; } _MHD_EXTERN enum MHD_Result MHD_destroy_post_processor (struct MHD_PostProcessor *pp) { enum MHD_Result ret; if (NULL == pp) return MHD_YES; if (PP_ProcessValue == pp->state) { /* key without terminated value left at the end of the buffer; fake receiving a termination character to ensure it is also processed */ post_process_urlencoded (pp, "\n", 1); } /* These internal strings need cleaning up since the post-processing may have been interrupted at any stage */ if ( (pp->xbuf_pos > 0) || ( (pp->state != PP_Done) && (pp->state != PP_Init) ) ) ret = MHD_NO; else ret = MHD_YES; pp->have = NE_none; free_unmarked (pp); if (NULL != pp->nested_boundary) free (pp->nested_boundary); free (pp); return ret; } /* end of postprocessor.c */ libmicrohttpd-1.0.1/src/microhttpd/test_sha1.c0000644000175000017500000003750114445225034015052 /* This file is part of libmicrohttpd Copyright (C) 2019-2021 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_sha1.h * @brief Unit tests for SHA-1 functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "sha1.h" #include "test_helpers.h" #include #include #include static int verbose = 0; /* verbose level (0-1)*/ struct str_with_len { const char *const str; const size_t len; }; #define D_STR_W_LEN(s) {(s), (sizeof((s)) / sizeof(char)) - 1} struct data_unit1 { const struct str_with_len str_l; const uint8_t digest[SHA1_DIGEST_SIZE]; }; static const struct data_unit1 data_units1[] = { {D_STR_W_LEN ("abc"), {0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D}}, {D_STR_W_LEN ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"), {0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1}}, {D_STR_W_LEN (""), {0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09}}, {D_STR_W_LEN ("The quick brown fox jumps over the lazy dog"), {0x2f, 0xd4, 0xe1, 0xc6, 0x7a, 0x2d, 0x28, 0xfc, 0xed, 0x84, 0x9e, 0xe1, 0xbb, 0x76, 0xe7, 0x39, 0x1b, 0x93, 0xeb, 0x12}}, {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."), {0xa7, 0x08, 0x9e, 0x3d, 0xe1, 0x6b, 0x63, 0xa3, 0x2a, 0x43, 0xa5, 0xe7, 0xf3, 0xb5, 0x4f, 0x80, 0x6a, 0xc8, 0x4f, 0x53}}, {D_STR_W_LEN ("Simple string."), {0x6c, 0x6c, 0x9c, 0xef, 0x53, 0xff, 0x22, 0x39, 0x0c, 0x54, 0xc7, 0xba, 0x6d, 0x98, 0xe0, 0xd5, 0x6c, 0x24, 0x0d, 0x55}}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"), {0x32, 0xd1, 0x0c, 0x7b, 0x8c, 0xf9, 0x65, 0x70, 0xca, 0x04, 0xce, 0x37, 0xf2, 0xa1, 0x9d, 0x84, 0x24, 0x0d, 0x3a, 0x89}}, {D_STR_W_LEN ("zyxwvutsrqponMLKJIHGFEDCBA"), {0x59, 0x0f, 0xc8, 0xea, 0xde, 0xa2, 0x78, 0x65, 0x5a, 0xf2, 0xa1, 0xe5, 0xb4, 0xc9, 0x61, 0xa4, 0x3a, 0xc3, 0x6a, 0x83}}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA" "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"), {0xa7, 0x87, 0x4c, 0x16, 0xc0, 0x4e, 0xd6, 0x24, 0x5f, 0x25, 0xbe, 0x06, 0x7b, 0x1b, 0x6b, 0xaf, 0xf4, 0x0e, 0x74, 0x0b}}, }; static const size_t units1_num = sizeof(data_units1) / sizeof(data_units1[0]); struct bin_with_len { const uint8_t bin[512]; const size_t len; }; struct data_unit2 { const struct bin_with_len bin_l; const uint8_t digest[SHA1_DIGEST_SIZE]; }; /* Size must be less than 512 bytes! */ static const struct data_unit2 data_units2[] = { { { {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}, 26}, /* a..z ASCII sequence */ {0x32, 0xd1, 0x0c, 0x7b, 0x8c, 0xf9, 0x65, 0x70, 0xca, 0x04, 0xce, 0x37, 0xf2, 0xa1, 0x9d, 0x84, 0x24, 0x0d, 0x3a, 0x89}}, { { {65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65}, 72 }, /* 'A' x 72 times */ {0x41, 0xf9, 0x07, 0x05, 0x04, 0xf9, 0xc8, 0x1a, 0xbf, 0xbb, 0x61, 0x4d, 0xaa, 0xec, 0x3b, 0x26, 0xa2, 0xf9, 0x23, 0x7e}}, { { {19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,43, 44, 45, 46, 47, 48, 49, 50, 51, 52,53, 54, 55, 56, 57, 58, 59, 60,61, 62, 63, 64, 65, 66, 67,68, 69, 70, 71, 72, 73}, 55}, /* 19..73 sequence */ {0xf2, 0x50, 0xb2, 0x79, 0x62, 0xcc, 0xff, 0x4b, 0x1b, 0x61, 0x4a, 0x6f, 0x80, 0xec, 0x9b, 0x4d, 0xd0, 0xc0, 0xfb, 0x7b}}, { { {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,32, 33, 34, 35, 36, 37, 38, 39, 40, 41,42, 43, 44, 45, 46, 47, 48, 49,50, 51, 52, 53, 54, 55, 56,57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69}, 63}, /* 7..69 sequence */ {0xf0, 0xa3, 0xfc, 0x4b, 0x90, 0x6f, 0x1b, 0x41, 0x68, 0xc8, 0x3e, 0x05, 0xb0, 0xc5, 0xac, 0xb7, 0x3d, 0xcd, 0x6b, 0x0f}}, { { {38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,62, 63, 64, 65, 66, 67, 68, 69, 70, 71,72, 73, 74, 75, 76, 77, 78, 79,80, 81, 82, 83, 84, 85, 86,87, 88, 89, 90, 91, 92}, 55}, /* 38..92 sequence */ {0x93, 0xa4, 0x9c, 0x5f, 0xda, 0x22, 0x63, 0x73, 0x85, 0xeb, 0x70, 0xd2, 0x00, 0x52, 0x0c, 0xb0, 0x2e, 0x86, 0x9b, 0xa0 }}, { { {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,37, 38, 39, 40, 41, 42, 43, 44, 45,46, 47, 48, 49, 50, 51, 52,53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,71, 72},72}, /* 1..72 sequence */ {0x8b, 0x30, 0xd3, 0x41, 0x89, 0xb6, 0x1b, 0x66, 0x5a, 0x1a, 0x9a, 0x51, 0x64, 0x93, 0xab, 0x5e, 0x78, 0x81, 0x52, 0xb5}}, { { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220,221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234,235, 236, 237, 238, 239, 240,241, 242, 243, 244, 245, 246, 247,248, 249, 250, 251, 252, 253, 254, 255}, 256}, /* 0..255 sequence */ {0x49, 0x16, 0xd6, 0xbd, 0xb7, 0xf7, 0x8e, 0x68, 0x03, 0x69, 0x8c, 0xab, 0x32, 0xd1, 0x58, 0x6e, 0xa4, 0x57, 0xdf, 0xc8}}, { { {199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186,185, 184, 183, 182, 181, 180,179, 178, 177, 176, 175, 174, 173,172, 171, 170, 169, 168, 167, 166,165, 164, 163, 162, 161, 160,159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146,145, 144, 143, 142, 141, 140,139}, 61}, /* 199..139 sequence */ {0xb3, 0xec, 0x61, 0x3c, 0xf7, 0x36, 0x57, 0x94, 0x61, 0xdb, 0xb2, 0x16, 0x75, 0xfe, 0x34, 0x60, 0x99, 0x94, 0xb5, 0xfc}}, { { {255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, 255}, /* 255..1 sequence */ {0x99, 0x1d, 0xc6, 0x95, 0xe1, 0xaa, 0xcc, 0xc9, 0x35, 0x60, 0xbe, 0xe3, 0xe2, 0x41, 0x2b, 0xa7, 0xab, 0x49, 0x32, 0xf7}}, { { {41, 35, 190, 132, 225, 108, 214, 174, 82, 144, 73, 241, 241, 187, 233, 235, 179, 166, 219, 60, 135, 12, 62, 153, 36, 94, 13, 28, 6, 183, 71, 222, 179, 18, 77, 200, 67, 187, 139, 166, 31, 3, 90, 125, 9, 56, 37, 31, 93, 212, 203, 252, 150, 245, 69, 59, 19, 13, 137, 10, 28, 219, 174, 50, 32, 154, 80, 238, 64, 120, 54, 253, 18, 73, 50, 246, 158, 125, 73, 220, 173, 79, 20, 242, 68, 64, 102, 208, 107, 196, 48, 183, 50, 59, 161, 34, 246, 34, 145, 157, 225, 139, 31, 218, 176, 202, 153, 2, 185, 114, 157, 73, 44, 128, 126, 197, 153, 213, 233, 128, 178, 234, 201, 204, 83, 191, 103, 214, 191, 20, 214, 126, 45, 220, 142, 102, 131, 239, 87, 73, 97, 255, 105, 143, 97, 205, 209, 30, 157, 156, 22, 114, 114, 230, 29, 240, 132, 79, 74, 119, 2, 215, 232, 57, 44, 83, 203, 201, 18, 30, 51, 116, 158, 12, 244, 213, 212, 159, 212, 164, 89, 126, 53, 207, 50, 34, 244, 204, 207, 211, 144, 45, 72, 211, 143, 117, 230, 217, 29, 42, 229, 192, 247, 43, 120, 129, 135, 68, 14, 95, 80, 0, 212, 97, 141, 190, 123, 5, 21, 7, 59, 51, 130, 31, 24, 112, 146, 218, 100, 84, 206, 177, 133, 62, 105, 21, 248, 70, 106, 4, 150, 115, 14, 217, 22, 47, 103, 104, 212, 247, 74, 74, 208, 87, 104}, 255}, /* pseudo-random data */ {0x9e, 0xb6, 0xce, 0x48, 0xf4, 0x6e, 0x9c, 0xf4, 0x1b, 0x4f, 0x9f, 0x66, 0xdd, 0xe8, 0x41, 0x01, 0x71, 0xf6, 0xf5, 0xd6}} }; static const size_t units2_num = sizeof(data_units2) / sizeof(data_units2[0]); /* * Helper functions */ /** * Print bin as hex * * @param bin binary data * @param len number of bytes in bin * @param hex pointer to len*2+1 bytes buffer */ static void bin2hex (const uint8_t *bin, size_t len, char *hex) { while (len-- > 0) { unsigned int b1, b2; b1 = (*bin >> 4) & 0xf; *hex++ = (char) ((b1 > 9) ? (b1 + 'A' - 10) : (b1 + '0')); b2 = *bin++ & 0xf; *hex++ = (char) ((b2 > 9) ? (b2 + 'A' - 10) : (b2 + '0')); } *hex = 0; } static int check_result (const char *test_name, unsigned int check_num, const uint8_t calculated[SHA1_DIGEST_SIZE], const uint8_t expected[SHA1_DIGEST_SIZE]) { int failed = memcmp (calculated, expected, SHA1_DIGEST_SIZE); check_num++; /* Print 1-based numbers */ if (failed) { char calc_str[SHA1_DIGEST_STRING_SIZE]; char expc_str[SHA1_DIGEST_STRING_SIZE]; bin2hex (calculated, SHA1_DIGEST_SIZE, calc_str); bin2hex (expected, SHA1_DIGEST_SIZE, expc_str); fprintf (stderr, "FAILED: %s check %u: calculated digest %s, expected digest %s.\n", test_name, check_num, calc_str, expc_str); fflush (stderr); } else if (verbose) { char calc_str[SHA1_DIGEST_STRING_SIZE]; bin2hex (calculated, SHA1_DIGEST_SIZE, calc_str); printf ("PASSED: %s check %u: calculated digest %s matches " \ "expected digest.\n", test_name, check_num, calc_str); fflush (stdout); } return failed ? 1 : 0; } /* * Tests */ /* Calculated SHA-256 as one pass for whole data */ static int test1_str (void) { int num_failed = 0; unsigned int i; for (i = 0; i < units1_num; i++) { struct sha1_ctx ctx; uint8_t digest[SHA1_DIGEST_SIZE]; MHD_SHA1_init (&ctx); MHD_SHA1_update (&ctx, (const uint8_t *) data_units1[i].str_l.str, data_units1[i].str_l.len); MHD_SHA1_finish (&ctx, digest); num_failed += check_result (MHD_FUNC_, i, digest, data_units1[i].digest); } return num_failed; } static int test1_bin (void) { int num_failed = 0; unsigned int i; for (i = 0; i < units2_num; i++) { struct sha1_ctx ctx; uint8_t digest[SHA1_DIGEST_SIZE]; MHD_SHA1_init (&ctx); MHD_SHA1_update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len); MHD_SHA1_finish (&ctx, digest); num_failed += check_result (MHD_FUNC_, i, digest, data_units2[i].digest); } return num_failed; } /* Calculated SHA-256 as two iterations for whole data */ static int test2_str (void) { int num_failed = 0; unsigned int i; for (i = 0; i < units1_num; i++) { struct sha1_ctx ctx; uint8_t digest[SHA1_DIGEST_SIZE]; size_t part_s = data_units1[i].str_l.len / 4; MHD_SHA1_init (&ctx); MHD_SHA1_update (&ctx, (const uint8_t *) data_units1[i].str_l.str, part_s); MHD_SHA1_update (&ctx, (const uint8_t *) data_units1[i].str_l.str + part_s, data_units1[i].str_l.len - part_s); MHD_SHA1_finish (&ctx, digest); num_failed += check_result (MHD_FUNC_, i, digest, data_units1[i].digest); } return num_failed; } static int test2_bin (void) { int num_failed = 0; unsigned int i; for (i = 0; i < units2_num; i++) { struct sha1_ctx ctx; uint8_t digest[SHA1_DIGEST_SIZE]; size_t part_s = data_units2[i].bin_l.len * 2 / 3; MHD_SHA1_init (&ctx); MHD_SHA1_update (&ctx, data_units2[i].bin_l.bin, part_s); MHD_SHA1_update (&ctx, data_units2[i].bin_l.bin + part_s, data_units2[i].bin_l.len - part_s); MHD_SHA1_finish (&ctx, digest); num_failed += check_result (MHD_FUNC_, i, digest, data_units2[i].digest); } return num_failed; } /* Use data set number 7 as it has the longest sequence */ #define DATA_POS 6 #define MAX_OFFSET 31 static int test_unaligned (void) { int num_failed = 0; unsigned int offset; uint8_t *buf; uint8_t *digest_buf; const struct data_unit2 *const tdata = data_units2 + DATA_POS; buf = malloc (tdata->bin_l.len + MAX_OFFSET); digest_buf = malloc (SHA1_DIGEST_SIZE + MAX_OFFSET); if ((NULL == buf) || (NULL == digest_buf)) exit (99); for (offset = MAX_OFFSET; offset >= 1; --offset) { struct sha1_ctx ctx; uint8_t *unaligned_digest; uint8_t *unaligned_buf; unaligned_buf = buf + offset; memcpy (unaligned_buf, tdata->bin_l.bin, tdata->bin_l.len); unaligned_digest = digest_buf + MAX_OFFSET - offset; memset (unaligned_digest, 0, SHA1_DIGEST_SIZE); MHD_SHA1_init (&ctx); MHD_SHA1_update (&ctx, unaligned_buf, tdata->bin_l.len); MHD_SHA1_finish (&ctx, unaligned_digest); num_failed += check_result (MHD_FUNC_, MAX_OFFSET - offset, unaligned_digest, tdata->digest); } free (digest_buf); free (buf); return num_failed; } int main (int argc, char *argv[]) { int num_failed = 0; (void) has_in_name; /* Mute compiler warning. */ if (has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose")) verbose = 1; num_failed += test1_str (); num_failed += test1_bin (); num_failed += test2_str (); num_failed += test2_bin (); num_failed += test_unaligned (); return num_failed ? 1 : 0; } libmicrohttpd-1.0.1/src/microhttpd/digestauth.h0000644000175000017500000000437214441373361015330 /* This file is part of libmicrohttpd Copyright (C) 2010, 2011, 2012, 2015, 2018 Daniel Pittman and Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file digestauth.c * @brief Implements HTTP digest authentication * @author Amr Ali * @author Matthieu Speder * @author Christian Grothoff (RFC 7616 support) * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_DIGESTAUTH_H #define MHD_DIGESTAUTH_H 1 #include "mhd_options.h" #include "mhd_str.h" #ifdef HAVE_STDBOOL_H #include #endif /* HAVE_STDBOOL_H */ /** * The maximum supported size for Digest Auth parameters, like "real", * "username" etc. This limitation is used only for quoted parameters. * Parameters without quoted backslash character will be processed as long * as they fit connection pool (buffer) size. */ #define _MHD_AUTH_DIGEST_MAX_PARAM_SIZE (65535) /** * Beginning string for any valid Digest Authentication header. */ #define _MHD_AUTH_DIGEST_BASE "Digest" /** * The token for MD5 algorithm. */ #define _MHD_MD5_TOKEN "MD5" /** * The token for SHA-256 algorithm. */ #define _MHD_SHA256_TOKEN "SHA-256" /** * The token for SHA-512/256 algorithm. */ #define _MHD_SHA512_256_TOKEN "SHA-512-256" /** * The suffix token for "session" algorithms. */ #define _MHD_SESS_TOKEN "-sess" /** * The "auth" token for QOP */ #define MHD_TOKEN_AUTH_ "auth" /** * The "auth-int" token for QOP */ #define MHD_TOKEN_AUTH_INT_ "auth-int" #endif /* ! MHD_DIGESTAUTH_H */ /* end of digestauth.h */ libmicrohttpd-1.0.1/src/microhttpd/mhd_compat.h0000644000175000017500000000545514556705750015315 /* This file is part of libmicrohttpd Copyright (C) 2014-2021 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_compat.h * @brief Header for platform missing functions. * @author Karlson2k (Evgeny Grin) * * Provides compatibility for platforms with some missing * functionality. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid * variable modification in function parameters. */ #ifndef MHD_COMPAT_H #define MHD_COMPAT_H 1 #include "mhd_options.h" #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #ifdef HAVE_STRING_H /* for strerror() */ #include #endif /* HAVE_STRING_H */ /* MHD_strerror_ is strerror */ #define MHD_strerror_(errnum) strerror ((errnum)) /* Platform-independent snprintf name */ #if defined(HAVE_SNPRINTF) #define MHD_snprintf_ snprintf #else /* ! HAVE_SNPRINTF */ #if defined(_WIN32) && ! defined(__CYGWIN__) /* Emulate snprintf function on W32 */ int W32_snprintf (char *__restrict s, size_t n, const char *__restrict format, ...); #define MHD_snprintf_ W32_snprintf #else /* ! _WIN32 || __CYGWIN__ */ #error \ Your platform does not support snprintf() and MHD does not know how to emulate it on your platform. #endif /* ! _WIN32 || __CYGWIN__ */ #endif /* ! HAVE_SNPRINTF */ #ifdef HAVE_RANDOM /** * Generate pseudo random number at least 30-bit wide. * @return pseudo random number at least 30-bit wide. */ #define MHD_random_() random () #else /* HAVE_RANDOM */ #ifdef HAVE_RAND /** * Generate pseudo random number at least 30-bit wide. * @return pseudo random number at least 30-bit wide. */ #define MHD_random_() ( (((long) rand ()) << 15) + (long) rand () ) #endif /* HAVE_RAND */ #endif /* HAVE_RANDOM */ #ifdef HAVE_CALLOC /** * MHD_calloc_ is platform-independent calloc() */ #define MHD_calloc_(n,s) calloc ((n),(s)) #else /* ! HAVE_CALLOC */ /** * MHD_calloc_ is platform-independent calloc() */ void *MHD_calloc_ (size_t nelem, size_t elsize); #endif /* ! HAVE_CALLOC */ #endif /* MHD_COMPAT_H */ libmicrohttpd-1.0.1/src/microhttpd/test_start_stop.c0000644000175000017500000001117314530120375016412 /* This file is part of libmicrohttpd Copyright (C) 2011 Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_start_stop.c * @brief test for #1901 (start+stop) * @author Christian Grothoff */ #include "mhd_options.h" #include "platform.h" #include #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { (void) cls; (void) connection; (void) url; /* Unused. Silent compiler warning. */ (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; (void) req_cls; /* Unused. Silent compiler warning. */ return MHD_NO; } #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) static unsigned int testInternalGet (unsigned int poll_flag) { struct MHD_Daemon *d; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; MHD_stop_daemon (d); return 0; } static unsigned int testMultithreadedGet (unsigned int poll_flag) { struct MHD_Daemon *d; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 2; MHD_stop_daemon (d); return 0; } static unsigned int testMultithreadedPoolGet (unsigned int poll_flag) { struct MHD_Daemon *d; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_THREAD_POOL_SIZE, MHD_CPU_COUNT, MHD_OPTION_END); if (d == NULL) return 4; MHD_stop_daemon (d); return 0; } static unsigned int testExternalGet (void) { struct MHD_Daemon *d; d = MHD_start_daemon (MHD_USE_ERROR_LOG, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (NULL == d) return 8; MHD_stop_daemon (d); return 0; } #endif static unsigned int testExternalGetSingleThread (void) { struct MHD_Daemon *d; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (NULL == d) return 8; MHD_stop_daemon (d); return 0; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silence compiler warning. */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) errorCount += testInternalGet (0); errorCount += testMultithreadedGet (0); errorCount += testMultithreadedPoolGet (0); errorCount += testExternalGet (); #endif errorCount += testExternalGetSingleThread (); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) { errorCount += testInternalGet (MHD_USE_POLL); errorCount += testMultithreadedGet (MHD_USE_POLL); errorCount += testMultithreadedPoolGet (MHD_USE_POLL); } if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { errorCount += testInternalGet (MHD_USE_EPOLL); errorCount += testMultithreadedPoolGet (MHD_USE_EPOLL); } #endif if (0 != errorCount) fprintf (stderr, "Error (code: %u)\n", errorCount); return (errorCount == 0) ? 0 : 1; /* 0 == pass */ } libmicrohttpd-1.0.1/src/microhttpd/gen_auth.c0000644000175000017500000005632414556705750014770 /* This file is part of libmicrohttpd Copyright (C) 2022-2023 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/gen_auth.c * @brief HTTP authorisation general functions * @author Karlson2k (Evgeny Grin) */ #include "gen_auth.h" #include "internal.h" #include "connection.h" #include "mhd_str.h" #include "mhd_assert.h" #ifdef BAUTH_SUPPORT #include "basicauth.h" #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT #include "digestauth.h" #endif /* DAUTH_SUPPORT */ #if ! defined(BAUTH_SUPPORT) && ! defined(DAUTH_SUPPORT) #error This file requires Basic or Digest authentication support #endif /** * Type of authorisation */ enum MHD_AuthType { MHD_AUTHTYPE_NONE = 0,/**< No authorisation, unused */ MHD_AUTHTYPE_BASIC, /**< Basic Authorisation, RFC 7617 */ MHD_AUTHTYPE_DIGEST, /**< Digest Authorisation, RFC 7616 */ MHD_AUTHTYPE_UNKNOWN, /**< Unknown/Unsupported authorisation type, unused */ MHD_AUTHTYPE_INVALID /**< Wrong/broken authorisation header, unused */ }; /** * Find required "Authorization" request header * @param c the connection with request * @param type the type of the authorisation: basic or digest * @param[out] auth_value will be set to the remaining of header value after * authorisation token (after "Basic " or "Digest ") * @return true if requested header is found, * false otherwise */ static bool find_auth_rq_header_ (const struct MHD_Connection *c, enum MHD_AuthType type, struct _MHD_str_w_len *auth_value) { const struct MHD_HTTP_Req_Header *h; const char *token; size_t token_len; mhd_assert (MHD_CONNECTION_HEADERS_PROCESSED <= c->state); if (MHD_CONNECTION_HEADERS_PROCESSED > c->state) return false; #ifdef DAUTH_SUPPORT if (MHD_AUTHTYPE_DIGEST == type) { token = _MHD_AUTH_DIGEST_BASE; token_len = MHD_STATICSTR_LEN_ (_MHD_AUTH_DIGEST_BASE); } else /* combined with the next line */ #endif /* DAUTH_SUPPORT */ #ifdef BAUTH_SUPPORT if (MHD_AUTHTYPE_BASIC == type) { token = _MHD_AUTH_BASIC_BASE; token_len = MHD_STATICSTR_LEN_ (_MHD_AUTH_BASIC_BASE); } else /* combined with the next line */ #endif /* BAUTH_SUPPORT */ { mhd_assert (0); return false; } for (h = c->rq.headers_received; NULL != h; h = h->next) { if (MHD_HEADER_KIND != h->kind) continue; if (MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_AUTHORIZATION) != h->header_size) continue; if (token_len > h->value_size) continue; if (! MHD_str_equal_caseless_bin_n_ (MHD_HTTP_HEADER_AUTHORIZATION, h->header, MHD_STATICSTR_LEN_ ( \ MHD_HTTP_HEADER_AUTHORIZATION))) continue; if (! MHD_str_equal_caseless_bin_n_ (h->value, token, token_len)) continue; /* Match only if token string is full header value or token is * followed by space or tab * Note: RFC 9110 (and RFC 7234) allows only space character, but * tab is supported here as well for additional flexibility and uniformity * as tabs are supported as separators between parameters. */ if ((token_len == h->value_size) || (' ' == h->value[token_len]) || ('\t' == h->value[token_len])) { if (token_len != h->value_size) { /* Skip whitespace */ auth_value->str = h->value + token_len + 1; auth_value->len = h->value_size - (token_len + 1); } else { /* No whitespace to skip */ auth_value->str = h->value + token_len; auth_value->len = h->value_size - token_len; } return true; /* Found a match */ } } return false; /* No matching header has been found */ } #ifdef BAUTH_SUPPORT /** * Parse request Authorization header parameters for Basic Authentication * @param str the header string, everything after "Basic " substring * @param str_len the length of @a str in characters * @param[out] pbauth the pointer to the structure with Basic Authentication * parameters * @return true if parameters has been successfully parsed, * false if format of the @a str is invalid */ static bool parse_bauth_params (const char *str, size_t str_len, struct MHD_RqBAuth *pbauth) { size_t i; i = 0; /* Skip all whitespaces at start */ while (i < str_len && (' ' == str[i] || '\t' == str[i])) i++; if (str_len > i) { size_t token68_start; size_t token68_len; /* 'i' points to the first non-whitespace char after scheme token */ token68_start = i; /* Find end of the token. Token cannot contain whitespace. */ while (i < str_len && ' ' != str[i] && '\t' != str[i]) { if (0 == str[i]) return false; /* Binary zero is not allowed */ if ((',' == str[i]) || (';' == str[i])) return false; /* Only single token68 is allowed */ i++; } token68_len = i - token68_start; mhd_assert (0 != token68_len); /* Skip all whitespaces */ while (i < str_len && (' ' == str[i] || '\t' == str[i])) i++; /* Check whether any garbage is present at the end of the string */ if (str_len != i) return false; else { /* No more data in the string, only single token68. */ pbauth->token68.str = str + token68_start; pbauth->token68.len = token68_len; } } return true; } /** * Return request's Basic Authorisation parameters. * * Function return result of parsing of the request's "Authorization" header or * returns cached parsing result if the header was already parsed for * the current request. * @param connection the connection to process * @return the pointer to structure with Authentication parameters, * NULL if no memory in memory pool, if called too early (before * header has been received) or if no valid Basic Authorisation header * found. */ const struct MHD_RqBAuth * MHD_get_rq_bauth_params_ (struct MHD_Connection *connection) { struct _MHD_str_w_len h_auth_value; struct MHD_RqBAuth *bauth; mhd_assert (MHD_CONNECTION_HEADERS_PROCESSED <= connection->state); if (connection->rq.bauth_tried) return connection->rq.bauth; if (MHD_CONNECTION_HEADERS_PROCESSED > connection->state) return NULL; if (! find_auth_rq_header_ (connection, MHD_AUTHTYPE_BASIC, &h_auth_value)) { connection->rq.bauth_tried = true; connection->rq.bauth = NULL; return NULL; } bauth = (struct MHD_RqBAuth *) MHD_connection_alloc_memory_ (connection, sizeof (struct MHD_RqBAuth)); if (NULL == bauth) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Not enough memory in the connection's pool to allocate " \ "for Basic Authorization header parsing.\n")); #endif /* HAVE_MESSAGES */ return NULL; } memset (bauth, 0, sizeof(struct MHD_RqBAuth)); if (parse_bauth_params (h_auth_value.str, h_auth_value.len, bauth)) connection->rq.bauth = bauth; else { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The Basic Authorization client's header has " "incorrect format.\n")); #endif /* HAVE_MESSAGES */ connection->rq.bauth = NULL; /* Memory in the pool remains allocated until next request */ } connection->rq.bauth_tried = true; return connection->rq.bauth; } #endif /* BAUTH_SUPPORT */ #ifdef DAUTH_SUPPORT /** * Get client's Digest Authorization algorithm type. * If no algorithm is specified by client, MD5 is assumed. * @param params the Digest Authorization 'algorithm' parameter * @return the algorithm type */ static enum MHD_DigestAuthAlgo3 get_rq_dauth_algo (const struct MHD_RqDAuthParam *const algo_param) { if (NULL == algo_param->value.str) return MHD_DIGEST_AUTH_ALGO3_MD5; /* Assume MD5 by default */ if (algo_param->quoted) { if (MHD_str_equal_caseless_quoted_s_bin_n (algo_param->value.str, \ algo_param->value.len, \ _MHD_MD5_TOKEN)) return MHD_DIGEST_AUTH_ALGO3_MD5; if (MHD_str_equal_caseless_quoted_s_bin_n (algo_param->value.str, \ algo_param->value.len, \ _MHD_SHA256_TOKEN)) return MHD_DIGEST_AUTH_ALGO3_SHA256; if (MHD_str_equal_caseless_quoted_s_bin_n (algo_param->value.str, \ algo_param->value.len, \ _MHD_MD5_TOKEN _MHD_SESS_TOKEN)) return MHD_DIGEST_AUTH_ALGO3_SHA512_256; if (MHD_str_equal_caseless_quoted_s_bin_n (algo_param->value.str, \ algo_param->value.len, \ _MHD_SHA512_256_TOKEN \ _MHD_SESS_TOKEN)) /* Algorithms below are not supported by MHD for authentication */ return MHD_DIGEST_AUTH_ALGO3_MD5_SESSION; if (MHD_str_equal_caseless_quoted_s_bin_n (algo_param->value.str, \ algo_param->value.len, \ _MHD_SHA256_TOKEN \ _MHD_SESS_TOKEN)) return MHD_DIGEST_AUTH_ALGO3_SHA256_SESSION; if (MHD_str_equal_caseless_quoted_s_bin_n (algo_param->value.str, \ algo_param->value.len, \ _MHD_SHA512_256_TOKEN)) return MHD_DIGEST_AUTH_ALGO3_SHA512_256_SESSION; /* No known algorithm has been detected */ return MHD_DIGEST_AUTH_ALGO3_INVALID; } /* The algorithm value is not quoted */ if (MHD_str_equal_caseless_s_bin_n_ (_MHD_MD5_TOKEN, \ algo_param->value.str, \ algo_param->value.len)) return MHD_DIGEST_AUTH_ALGO3_MD5; if (MHD_str_equal_caseless_s_bin_n_ (_MHD_SHA256_TOKEN, \ algo_param->value.str, \ algo_param->value.len)) return MHD_DIGEST_AUTH_ALGO3_SHA256; if (MHD_str_equal_caseless_s_bin_n_ (_MHD_SHA512_256_TOKEN, \ algo_param->value.str, \ algo_param->value.len)) return MHD_DIGEST_AUTH_ALGO3_SHA512_256; /* Algorithms below are not supported by MHD for authentication */ if (MHD_str_equal_caseless_s_bin_n_ (_MHD_MD5_TOKEN _MHD_SESS_TOKEN, \ algo_param->value.str, \ algo_param->value.len)) return MHD_DIGEST_AUTH_ALGO3_MD5_SESSION; if (MHD_str_equal_caseless_s_bin_n_ (_MHD_SHA256_TOKEN _MHD_SESS_TOKEN, \ algo_param->value.str, \ algo_param->value.len)) return MHD_DIGEST_AUTH_ALGO3_SHA256_SESSION; if (MHD_str_equal_caseless_s_bin_n_ (_MHD_SHA512_256_TOKEN _MHD_SESS_TOKEN, \ algo_param->value.str, \ algo_param->value.len)) return MHD_DIGEST_AUTH_ALGO3_SHA512_256_SESSION; /* No known algorithm has been detected */ return MHD_DIGEST_AUTH_ALGO3_INVALID; } /** * Get QOP ('quality of protection') type. * @param qop_param the Digest Authorization 'QOP' parameter * @return detected QOP ('quality of protection') type. */ static enum MHD_DigestAuthQOP get_rq_dauth_qop (const struct MHD_RqDAuthParam *const qop_param) { if (NULL == qop_param->value.str) return MHD_DIGEST_AUTH_QOP_NONE; if (qop_param->quoted) { if (MHD_str_equal_caseless_quoted_s_bin_n (qop_param->value.str, \ qop_param->value.len, \ MHD_TOKEN_AUTH_)) return MHD_DIGEST_AUTH_QOP_AUTH; if (MHD_str_equal_caseless_quoted_s_bin_n (qop_param->value.str, \ qop_param->value.len, \ MHD_TOKEN_AUTH_INT_)) return MHD_DIGEST_AUTH_QOP_AUTH_INT; } else { if (MHD_str_equal_caseless_s_bin_n_ (MHD_TOKEN_AUTH_, \ qop_param->value.str, \ qop_param->value.len)) return MHD_DIGEST_AUTH_QOP_AUTH; if (MHD_str_equal_caseless_s_bin_n_ (MHD_TOKEN_AUTH_INT_, \ qop_param->value.str, \ qop_param->value.len)) return MHD_DIGEST_AUTH_QOP_AUTH_INT; } /* No know QOP has been detected */ return MHD_DIGEST_AUTH_QOP_INVALID; } /** * Parse request Authorization header parameters for Digest Authentication * @param str the header string, everything after "Digest " substring * @param str_len the length of @a str in characters * @param[out] pdauth the pointer to the structure with Digest Authentication * parameters * @return true if parameters has been successfully parsed, * false if format of the @a str is invalid */ static bool parse_dauth_params (const char *str, const size_t str_len, struct MHD_RqDAuth *pdauth) { /* The tokens */ static const struct _MHD_cstr_w_len nonce_tk = _MHD_S_STR_W_LEN ("nonce"); static const struct _MHD_cstr_w_len opaque_tk = _MHD_S_STR_W_LEN ("opaque"); static const struct _MHD_cstr_w_len algorithm_tk = _MHD_S_STR_W_LEN ("algorithm"); static const struct _MHD_cstr_w_len response_tk = _MHD_S_STR_W_LEN ("response"); static const struct _MHD_cstr_w_len username_tk = _MHD_S_STR_W_LEN ("username"); static const struct _MHD_cstr_w_len username_ext_tk = _MHD_S_STR_W_LEN ("username*"); static const struct _MHD_cstr_w_len realm_tk = _MHD_S_STR_W_LEN ("realm"); static const struct _MHD_cstr_w_len uri_tk = _MHD_S_STR_W_LEN ("uri"); static const struct _MHD_cstr_w_len qop_tk = _MHD_S_STR_W_LEN ("qop"); static const struct _MHD_cstr_w_len cnonce_tk = _MHD_S_STR_W_LEN ("cnonce"); static const struct _MHD_cstr_w_len nc_tk = _MHD_S_STR_W_LEN ("nc"); static const struct _MHD_cstr_w_len userhash_tk = _MHD_S_STR_W_LEN ("userhash"); /* The locally processed parameters */ struct MHD_RqDAuthParam userhash; struct MHD_RqDAuthParam algorithm; /* Indexes */ size_t i; size_t p; /* The list of the tokens. The order of the elements matches the next array. */ static const struct _MHD_cstr_w_len *const tk_names[] = { &nonce_tk, /* 0 */ &opaque_tk, /* 1 */ &algorithm_tk, /* 2 */ &response_tk, /* 3 */ &username_tk, /* 4 */ &username_ext_tk, /* 5 */ &realm_tk, /* 6 */ &uri_tk, /* 7 */ &qop_tk, /* 8 */ &cnonce_tk, /* 9 */ &nc_tk, /* 10 */ &userhash_tk /* 11 */ }; /* The list of the parameters. The order of the elements matches the previous array. */ struct MHD_RqDAuthParam *params[sizeof(tk_names) / sizeof(tk_names[0])]; params[0 ] = &(pdauth->nonce); /* 0 */ params[1 ] = &(pdauth->opaque); /* 1 */ params[2 ] = &algorithm; /* 2 */ params[3 ] = &(pdauth->response); /* 3 */ params[4 ] = &(pdauth->username); /* 4 */ params[5 ] = &(pdauth->username_ext); /* 5 */ params[6 ] = &(pdauth->realm); /* 6 */ params[7 ] = &(pdauth->uri); /* 7 */ params[8 ] = &(pdauth->qop_raw); /* 8 */ params[9 ] = &(pdauth->cnonce); /* 9 */ params[10] = &(pdauth->nc); /* 10 */ params[11] = &userhash; /* 11 */ mhd_assert ((sizeof(tk_names) / sizeof(tk_names[0])) == \ (sizeof(params) / sizeof(params[0]))); memset (&userhash, 0, sizeof(userhash)); memset (&algorithm, 0, sizeof(algorithm)); i = 0; /* Skip all whitespaces at start */ while (i < str_len && (' ' == str[i] || '\t' == str[i])) i++; while (str_len > i) { size_t left; mhd_assert (' ' != str[i]); mhd_assert ('\t' != str[i]); left = str_len - i; if ('=' == str[i]) return false; /* The equal sign is not allowed as the first character */ for (p = 0; p < (sizeof(tk_names) / sizeof(tk_names[0])); ++p) { const struct _MHD_cstr_w_len *const tk_name = tk_names[p]; struct MHD_RqDAuthParam *const param = params[p]; if ( (tk_name->len <= left) && MHD_str_equal_caseless_bin_n_ (str + i, tk_name->str, tk_name->len) && ((tk_name->len == left) || ('=' == str[i + tk_name->len]) || (' ' == str[i + tk_name->len]) || ('\t' == str[i + tk_name->len]) || (',' == str[i + tk_name->len]) || (';' == str[i + tk_name->len])) ) { size_t value_start; size_t value_len; bool quoted; /* Only mark as "quoted" if backslash-escape used */ if (tk_name->len == left) return false; /* No equal sign after parameter name, broken data */ quoted = false; i += tk_name->len; /* Skip all whitespaces before '=' */ while (str_len > i && (' ' == str[i] || '\t' == str[i])) i++; if ((i == str_len) || ('=' != str[i])) return false; /* No equal sign, broken data */ i++; /* Skip all whitespaces after '=' */ while (str_len > i && (' ' == str[i] || '\t' == str[i])) i++; if ((str_len > i) && ('"' == str[i])) { /* Value is in quotation marks */ i++; /* Advance after the opening quote */ value_start = i; while (str_len > i && '"' != str[i]) { if ('\\' == str[i]) { i++; quoted = true; /* Have escaped chars */ } if (0 == str[i]) return false; /* Binary zero in parameter value */ i++; } if (str_len <= i) return false; /* No closing quote */ mhd_assert ('"' == str[i]); value_len = i - value_start; i++; /* Advance after the closing quote */ } else { value_start = i; while (str_len > i && ',' != str[i] && ' ' != str[i] && '\t' != str[i] && ';' != str[i]) { if (0 == str[i]) return false; /* Binary zero in parameter value */ i++; } if (';' == str[i]) return false; /* Semicolon in parameter value */ value_len = i - value_start; } /* Skip all whitespaces after parameter value */ while (str_len > i && (' ' == str[i] || '\t' == str[i])) i++; if ((str_len > i) && (',' != str[i])) return false; /* Garbage after parameter value */ /* Have valid parameter name and value */ mhd_assert (! quoted || 0 != value_len); param->value.str = str + value_start; param->value.len = value_len; param->quoted = quoted; break; /* Found matching parameter name */ } } if (p == (sizeof(tk_names) / sizeof(tk_names[0]))) { /* No matching parameter name */ while (str_len > i && ',' != str[i]) { if ((0 == str[i]) || (';' == str[i])) return false; /* Not allowed characters */ if ('"' == str[i]) { /* Skip quoted part */ i++; /* Advance after the opening quote */ while (str_len > i && '"' != str[i]) { if (0 == str[i]) return false; /* Binary zero is not allowed */ if ('\\' == str[i]) i++; /* Skip escaped char */ i++; } if (str_len <= i) return false; /* No closing quote */ mhd_assert ('"' == str[i]); } i++; } } mhd_assert (str_len == i || ',' == str[i]); if (str_len > i) i++; /* Advance after ',' */ /* Skip all whitespaces before next parameter name */ while (i < str_len && (' ' == str[i] || '\t' == str[i])) i++; } /* Postprocess values */ if (NULL != userhash.value.str) { if (userhash.quoted) pdauth->userhash = MHD_str_equal_caseless_quoted_s_bin_n (userhash.value.str, \ userhash.value.len, \ "true"); else pdauth->userhash = MHD_str_equal_caseless_s_bin_n_ ("true", userhash.value.str, \ userhash.value.len); } else pdauth->userhash = false; pdauth->algo3 = get_rq_dauth_algo (&algorithm); pdauth->qop = get_rq_dauth_qop (&pdauth->qop_raw); return true; } /** * Return request's Digest Authorisation parameters. * * Function return result of parsing of the request's "Authorization" header or * returns cached parsing result if the header was already parsed for * the current request. * @param connection the connection to process * @return the pointer to structure with Authentication parameters, * NULL if no memory in memory pool, if called too early (before * header has been received) or if no valid Basic Authorisation header * found. */ const struct MHD_RqDAuth * MHD_get_rq_dauth_params_ (struct MHD_Connection *connection) { struct _MHD_str_w_len h_auth_value; struct MHD_RqDAuth *dauth; mhd_assert (MHD_CONNECTION_HEADERS_PROCESSED <= connection->state); if (connection->rq.dauth_tried) return connection->rq.dauth; if (MHD_CONNECTION_HEADERS_PROCESSED > connection->state) return NULL; if (! find_auth_rq_header_ (connection, MHD_AUTHTYPE_DIGEST, &h_auth_value)) { connection->rq.dauth_tried = true; connection->rq.dauth = NULL; return NULL; } dauth = (struct MHD_RqDAuth *) MHD_connection_alloc_memory_ (connection, sizeof (struct MHD_RqDAuth)); if (NULL == dauth) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Not enough memory in the connection's pool to allocate " \ "for Digest Authorization header parsing.\n")); #endif /* HAVE_MESSAGES */ return NULL; } memset (dauth, 0, sizeof(struct MHD_RqDAuth)); if (parse_dauth_params (h_auth_value.str, h_auth_value.len, dauth)) connection->rq.dauth = dauth; else { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The Digest Authorization client's header has " "incorrect format.\n")); #endif /* HAVE_MESSAGES */ connection->rq.dauth = NULL; /* Memory in the pool remains allocated until next request */ } connection->rq.dauth_tried = true; return connection->rq.dauth; } #endif /* DAUTH_SUPPORT */ libmicrohttpd-1.0.1/src/microhttpd/basicauth.h0000644000175000017500000000256614441373361015135 /* This file is part of libmicrohttpd Copyright (C) 2010, 2011, 2012 Daniel Pittman and Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file basicauth.c * @brief Implements HTTP basic authentication methods * @author Amr Ali * @author Matthieu Speder * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_BASICAUTH_H #define MHD_BASICAUTH_H 1 #include "mhd_str.h" /** * Beginning string for any valid Basic authentication header. */ #define _MHD_AUTH_BASIC_BASE "Basic" struct MHD_RqBAuth { struct _MHD_str_w_len token68; }; #endif /* ! MHD_BASICAUTH_H */ /* end of basicauth.h */ libmicrohttpd-1.0.1/src/microhttpd/md5.c0000644000175000017500000005076514556705750013666 /* This file is part of GNU libmicrohttpd Copyright (C) 2022-2023 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/md5.c * @brief Calculation of MD5 digest as defined in RFC 1321 * @author Karlson2k (Evgeny Grin) */ #include "md5.h" #include #ifdef HAVE_MEMORY_H #include #endif /* HAVE_MEMORY_H */ #include "mhd_bithelpers.h" #include "mhd_assert.h" /** * Initialise structure for MD5 calculation. * * @param ctx the calculation context */ void MHD_MD5_init (struct Md5Ctx *ctx) { /* Initial hash values, see RFC 1321, Clause 3.3 (step 3). */ /* Note: values specified in RFC by bytes and should be loaded in little-endian mode, therefore hash values here are initialised with original bytes used in little-endian order. */ ctx->H[0] = UINT32_C (0x67452301); ctx->H[1] = UINT32_C (0xefcdab89); ctx->H[2] = UINT32_C (0x98badcfe); ctx->H[3] = UINT32_C (0x10325476); /* Initialise the number of bytes. */ ctx->count = 0; } MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ /** * Base of MD5 transformation. * Gets full 64 bytes block of data and updates hash values; * @param H hash values * @param M the data buffer with #MD5_BLOCK_SIZE bytes block */ static void md5_transform (uint32_t H[MD5_HASH_SIZE_WORDS], const void *M) { /* Working variables, See RFC 1321, Clause 3.4 (step 4). */ uint32_t A = H[0]; uint32_t B = H[1]; uint32_t C = H[2]; uint32_t D = H[3]; /* The data buffer. See RFC 1321, Clause 3.4 (step 4). */ uint32_t X[16]; #ifndef _MHD_GET_32BIT_LE_UNALIGNED if (0 != (((uintptr_t) M) % _MHD_UINT32_ALIGN)) { /* The input data is unaligned. */ /* Copy the unaligned input data to the aligned buffer. */ memcpy (X, M, sizeof(X)); /* The X[] buffer itself will be used as the source of the data, * but the data will be reloaded in correct bytes order on * the next steps. */ M = (const void *) X; } #endif /* _MHD_GET_32BIT_LE_UNALIGNED */ /* Four auxiliary functions, see RFC 1321, Clause 3.4 (step 4). */ /* Some optimisations used. */ /* #define F_FUNC(x,y,z) (((x)&(y)) | ((~(x))&(z))) */ /* Original version */ #define F_FUNC(x,y,z) ((((y) ^ (z)) & (x)) ^ (z)) /* #define G_FUNC_1(x,y,z) (((x)&(z)) | ((y)&(~(z)))) */ /* Original version */ /* #define G_FUNC_2(x,y,z) UINT32_C(0) */ /* Original version */ #ifndef MHD_FAVOR_SMALL_CODE # define G_FUNC_1(x,y,z) ((~(z)) & (y)) # define G_FUNC_2(x,y,z) ((z) & (x)) #else /* MHD_FAVOR_SMALL_CODE */ # define G_FUNC_1(x,y,z) ((((x) ^ (y)) & (z)) ^ (y)) # define G_FUNC_2(x,y,z) UINT32_C(0) #endif /* MHD_FAVOR_SMALL_CODE */ #define H_FUNC(x,y,z) ((x) ^ (y) ^ (z)) /* Original version */ /* #define I_FUNC(x,y,z) ((y) ^ ((x) | (~(z)))) */ /* Original version */ #define I_FUNC(x,y,z) (((~(z)) | (x)) ^ (y)) /* One step of round 1 of MD5 computation, see RFC 1321, Clause 3.4 (step 4). The original function was modified to use X[k] and T[i] as direct inputs. */ #define MD5STEP_R1(va,vb,vc,vd,vX,vs,vT) do { \ (va) += (vX) + (vT); \ (va) += F_FUNC((vb),(vc),(vd)); \ (va) = _MHD_ROTL32((va),(vs)) + (vb); } while (0) /* Get value of X(k) from input data buffer. See RFC 1321 Clause 3.4 (step 4). */ #define GET_X_FROM_DATA(buf,t) \ _MHD_GET_32BIT_LE (((const uint32_t*) (buf)) + (t)) /* One step of round 2 of MD5 computation, see RFC 1321, Clause 3.4 (step 4). The original function was modified to use X[k] and T[i] as direct inputs. */ #define MD5STEP_R2(va,vb,vc,vd,vX,vs,vT) do { \ (va) += (vX) + (vT); \ (va) += G_FUNC_1((vb),(vc),(vd)); \ (va) += G_FUNC_2((vb),(vc),(vd)); \ (va) = _MHD_ROTL32((va),(vs)) + (vb); } while (0) /* One step of round 3 of MD5 computation, see RFC 1321, Clause 3.4 (step 4). The original function was modified to use X[k] and T[i] as direct inputs. */ #define MD5STEP_R3(va,vb,vc,vd,vX,vs,vT) do { \ (va) += (vX) + (vT); \ (va) += H_FUNC((vb),(vc),(vd)); \ (va) = _MHD_ROTL32((va),(vs)) + (vb); } while (0) /* One step of round 4 of MD5 computation, see RFC 1321, Clause 3.4 (step 4). The original function was modified to use X[k] and T[i] as direct inputs. */ #define MD5STEP_R4(va,vb,vc,vd,vX,vs,vT) do { \ (va) += (vX) + (vT); \ (va) += I_FUNC((vb),(vc),(vd)); \ (va) = _MHD_ROTL32((va),(vs)) + (vb); } while (0) #if ! defined(MHD_FAVOR_SMALL_CODE) /* Round 1. */ #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN if ((const void *) X == M) { /* The input data is already in the data buffer X[] in correct bytes order. */ MD5STEP_R1 (A, B, C, D, X[0], 7, UINT32_C (0xd76aa478)); MD5STEP_R1 (D, A, B, C, X[1], 12, UINT32_C (0xe8c7b756)); MD5STEP_R1 (C, D, A, B, X[2], 17, UINT32_C (0x242070db)); MD5STEP_R1 (B, C, D, A, X[3], 22, UINT32_C (0xc1bdceee)); MD5STEP_R1 (A, B, C, D, X[4], 7, UINT32_C (0xf57c0faf)); MD5STEP_R1 (D, A, B, C, X[5], 12, UINT32_C (0x4787c62a)); MD5STEP_R1 (C, D, A, B, X[6], 17, UINT32_C (0xa8304613)); MD5STEP_R1 (B, C, D, A, X[7], 22, UINT32_C (0xfd469501)); MD5STEP_R1 (A, B, C, D, X[8], 7, UINT32_C (0x698098d8)); MD5STEP_R1 (D, A, B, C, X[9], 12, UINT32_C (0x8b44f7af)); MD5STEP_R1 (C, D, A, B, X[10], 17, UINT32_C (0xffff5bb1)); MD5STEP_R1 (B, C, D, A, X[11], 22, UINT32_C (0x895cd7be)); MD5STEP_R1 (A, B, C, D, X[12], 7, UINT32_C (0x6b901122)); MD5STEP_R1 (D, A, B, C, X[13], 12, UINT32_C (0xfd987193)); MD5STEP_R1 (C, D, A, B, X[14], 17, UINT32_C (0xa679438e)); MD5STEP_R1 (B, C, D, A, X[15], 22, UINT32_C (0x49b40821)); } else /* Combined with the next 'if' */ #endif /* _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN */ if (1) { /* The input data is loaded in correct (little-endian) format before calculations on each step. */ MD5STEP_R1 (A, B, C, D, X[0] = GET_X_FROM_DATA (M, 0), 7, \ UINT32_C (0xd76aa478)); MD5STEP_R1 (D, A, B, C, X[1] = GET_X_FROM_DATA (M, 1), 12, \ UINT32_C (0xe8c7b756)); MD5STEP_R1 (C, D, A, B, X[2] = GET_X_FROM_DATA (M, 2), 17, \ UINT32_C (0x242070db)); MD5STEP_R1 (B, C, D, A, X[3] = GET_X_FROM_DATA (M, 3), 22, \ UINT32_C (0xc1bdceee)); MD5STEP_R1 (A, B, C, D, X[4] = GET_X_FROM_DATA (M, 4), 7, \ UINT32_C (0xf57c0faf)); MD5STEP_R1 (D, A, B, C, X[5] = GET_X_FROM_DATA (M, 5), 12, \ UINT32_C (0x4787c62a)); MD5STEP_R1 (C, D, A, B, X[6] = GET_X_FROM_DATA (M, 6), 17, \ UINT32_C (0xa8304613)); MD5STEP_R1 (B, C, D, A, X[7] = GET_X_FROM_DATA (M, 7), 22, \ UINT32_C (0xfd469501)); MD5STEP_R1 (A, B, C, D, X[8] = GET_X_FROM_DATA (M, 8), 7, \ UINT32_C (0x698098d8)); MD5STEP_R1 (D, A, B, C, X[9] = GET_X_FROM_DATA (M, 9), 12, \ UINT32_C (0x8b44f7af)); MD5STEP_R1 (C, D, A, B, X[10] = GET_X_FROM_DATA (M, 10), 17, \ UINT32_C (0xffff5bb1)); MD5STEP_R1 (B, C, D, A, X[11] = GET_X_FROM_DATA (M, 11), 22, \ UINT32_C (0x895cd7be)); MD5STEP_R1 (A, B, C, D, X[12] = GET_X_FROM_DATA (M, 12), 7, \ UINT32_C (0x6b901122)); MD5STEP_R1 (D, A, B, C, X[13] = GET_X_FROM_DATA (M, 13), 12, \ UINT32_C (0xfd987193)); MD5STEP_R1 (C, D, A, B, X[14] = GET_X_FROM_DATA (M, 14), 17, \ UINT32_C (0xa679438e)); MD5STEP_R1 (B, C, D, A, X[15] = GET_X_FROM_DATA (M, 15), 22, \ UINT32_C (0x49b40821)); } /* Round 2. */ MD5STEP_R2 (A, B, C, D, X[1], 5, UINT32_C (0xf61e2562)); MD5STEP_R2 (D, A, B, C, X[6], 9, UINT32_C (0xc040b340)); MD5STEP_R2 (C, D, A, B, X[11], 14, UINT32_C (0x265e5a51)); MD5STEP_R2 (B, C, D, A, X[0], 20, UINT32_C (0xe9b6c7aa)); MD5STEP_R2 (A, B, C, D, X[5], 5, UINT32_C (0xd62f105d)); MD5STEP_R2 (D, A, B, C, X[10], 9, UINT32_C (0x02441453)); MD5STEP_R2 (C, D, A, B, X[15], 14, UINT32_C (0xd8a1e681)); MD5STEP_R2 (B, C, D, A, X[4], 20, UINT32_C (0xe7d3fbc8)); MD5STEP_R2 (A, B, C, D, X[9], 5, UINT32_C (0x21e1cde6)); MD5STEP_R2 (D, A, B, C, X[14], 9, UINT32_C (0xc33707d6)); MD5STEP_R2 (C, D, A, B, X[3], 14, UINT32_C (0xf4d50d87)); MD5STEP_R2 (B, C, D, A, X[8], 20, UINT32_C (0x455a14ed)); MD5STEP_R2 (A, B, C, D, X[13], 5, UINT32_C (0xa9e3e905)); MD5STEP_R2 (D, A, B, C, X[2], 9, UINT32_C (0xfcefa3f8)); MD5STEP_R2 (C, D, A, B, X[7], 14, UINT32_C (0x676f02d9)); MD5STEP_R2 (B, C, D, A, X[12], 20, UINT32_C (0x8d2a4c8a)); /* Round 3. */ MD5STEP_R3 (A, B, C, D, X[5], 4, UINT32_C (0xfffa3942)); MD5STEP_R3 (D, A, B, C, X[8], 11, UINT32_C (0x8771f681)); MD5STEP_R3 (C, D, A, B, X[11], 16, UINT32_C (0x6d9d6122)); MD5STEP_R3 (B, C, D, A, X[14], 23, UINT32_C (0xfde5380c)); MD5STEP_R3 (A, B, C, D, X[1], 4, UINT32_C (0xa4beea44)); MD5STEP_R3 (D, A, B, C, X[4], 11, UINT32_C (0x4bdecfa9)); MD5STEP_R3 (C, D, A, B, X[7], 16, UINT32_C (0xf6bb4b60)); MD5STEP_R3 (B, C, D, A, X[10], 23, UINT32_C (0xbebfbc70)); MD5STEP_R3 (A, B, C, D, X[13], 4, UINT32_C (0x289b7ec6)); MD5STEP_R3 (D, A, B, C, X[0], 11, UINT32_C (0xeaa127fa)); MD5STEP_R3 (C, D, A, B, X[3], 16, UINT32_C (0xd4ef3085)); MD5STEP_R3 (B, C, D, A, X[6], 23, UINT32_C (0x04881d05)); MD5STEP_R3 (A, B, C, D, X[9], 4, UINT32_C (0xd9d4d039)); MD5STEP_R3 (D, A, B, C, X[12], 11, UINT32_C (0xe6db99e5)); MD5STEP_R3 (C, D, A, B, X[15], 16, UINT32_C (0x1fa27cf8)); MD5STEP_R3 (B, C, D, A, X[2], 23, UINT32_C (0xc4ac5665)); /* Round 4. */ MD5STEP_R4 (A, B, C, D, X[0], 6, UINT32_C (0xf4292244)); MD5STEP_R4 (D, A, B, C, X[7], 10, UINT32_C (0x432aff97)); MD5STEP_R4 (C, D, A, B, X[14], 15, UINT32_C (0xab9423a7)); MD5STEP_R4 (B, C, D, A, X[5], 21, UINT32_C (0xfc93a039)); MD5STEP_R4 (A, B, C, D, X[12], 6, UINT32_C (0x655b59c3)); MD5STEP_R4 (D, A, B, C, X[3], 10, UINT32_C (0x8f0ccc92)); MD5STEP_R4 (C, D, A, B, X[10], 15, UINT32_C (0xffeff47d)); MD5STEP_R4 (B, C, D, A, X[1], 21, UINT32_C (0x85845dd1)); MD5STEP_R4 (A, B, C, D, X[8], 6, UINT32_C (0x6fa87e4f)); MD5STEP_R4 (D, A, B, C, X[15], 10, UINT32_C (0xfe2ce6e0)); MD5STEP_R4 (C, D, A, B, X[6], 15, UINT32_C (0xa3014314)); MD5STEP_R4 (B, C, D, A, X[13], 21, UINT32_C (0x4e0811a1)); MD5STEP_R4 (A, B, C, D, X[4], 6, UINT32_C (0xf7537e82)); MD5STEP_R4 (D, A, B, C, X[11], 10, UINT32_C (0xbd3af235)); MD5STEP_R4 (C, D, A, B, X[2], 15, UINT32_C (0x2ad7d2bb)); MD5STEP_R4 (B, C, D, A, X[9], 21, UINT32_C (0xeb86d391)); #else /* MHD_FAVOR_SMALL_CODE */ if (1) { static const uint32_t T[64] = { UINT32_C (0xd76aa478), UINT32_C (0xe8c7b756), UINT32_C (0x242070db), UINT32_C (0xc1bdceee), UINT32_C (0xf57c0faf), UINT32_C (0x4787c62a), UINT32_C (0xa8304613), UINT32_C (0xfd469501), UINT32_C (0x698098d8), UINT32_C (0x8b44f7af), UINT32_C (0xffff5bb1), UINT32_C (0x895cd7be), UINT32_C (0x6b901122), UINT32_C (0xfd987193), UINT32_C (0xa679438e), UINT32_C (0x49b40821), UINT32_C (0xf61e2562), UINT32_C (0xc040b340), UINT32_C (0x265e5a51), UINT32_C (0xe9b6c7aa), UINT32_C (0xd62f105d), UINT32_C (0x02441453), UINT32_C (0xd8a1e681), UINT32_C (0xe7d3fbc8), UINT32_C (0x21e1cde6), UINT32_C (0xc33707d6), UINT32_C (0xf4d50d87), UINT32_C (0x455a14ed), UINT32_C (0xa9e3e905), UINT32_C (0xfcefa3f8), UINT32_C (0x676f02d9), UINT32_C (0x8d2a4c8a), UINT32_C (0xfffa3942), UINT32_C (0x8771f681), UINT32_C (0x6d9d6122), UINT32_C (0xfde5380c), UINT32_C (0xa4beea44), UINT32_C (0x4bdecfa9), UINT32_C (0xf6bb4b60), UINT32_C (0xbebfbc70), UINT32_C (0x289b7ec6), UINT32_C (0xeaa127fa), UINT32_C (0xd4ef3085), UINT32_C (0x04881d05), UINT32_C (0xd9d4d039), UINT32_C (0xe6db99e5), UINT32_C (0x1fa27cf8), UINT32_C (0xc4ac5665), UINT32_C (0xf4292244), UINT32_C (0x432aff97), UINT32_C (0xab9423a7), UINT32_C (0xfc93a039), UINT32_C (0x655b59c3), UINT32_C (0x8f0ccc92), UINT32_C (0xffeff47d), UINT32_C (0x85845dd1), UINT32_C (0x6fa87e4f), UINT32_C (0xfe2ce6e0), UINT32_C (0xa3014314), UINT32_C (0x4e0811a1), UINT32_C (0xf7537e82), UINT32_C (0xbd3af235), UINT32_C (0x2ad7d2bb), UINT32_C (0xeb86d391) }; unsigned int i; /**< Zero-based index */ /* Round 1. */ i = 0; do { /* The input data is loaded in correct (little-endian) format before calculations on each step. */ MD5STEP_R1 (A, B, C, D, X[i] = GET_X_FROM_DATA (M, i), 7, T[i]); ++i; MD5STEP_R1 (D, A, B, C, X[i] = GET_X_FROM_DATA (M, i), 12, T[i]); ++i; MD5STEP_R1 (C, D, A, B, X[i] = GET_X_FROM_DATA (M, i), 17, T[i]); ++i; MD5STEP_R1 (B, C, D, A, X[i] = GET_X_FROM_DATA (M, i), 22, T[i]); ++i; } while (i < 16); /* Round 2. */ do { const unsigned int idx_add = i; MD5STEP_R2 (A, B, C, D, X[(1U + idx_add) & 15U], 5, T[i]); ++i; MD5STEP_R2 (D, A, B, C, X[(6U + idx_add) & 15U], 9, T[i]); ++i; MD5STEP_R2 (C, D, A, B, X[(11U + idx_add) & 15U], 14, T[i]); ++i; MD5STEP_R2 (B, C, D, A, X[(0U + idx_add) & 15U], 20, T[i]); ++i; } while (i < 32); /* Round 3. */ do { const unsigned int idx_add = i; MD5STEP_R3 (A, B, C, D, X[(5U + 64U - idx_add) & 15U], 4, T[i]); ++i; MD5STEP_R3 (D, A, B, C, X[(8U + 64U - idx_add) & 15U], 11, T[i]); ++i; MD5STEP_R3 (C, D, A, B, X[(11U + 64U - idx_add) & 15U], 16, T[i]); ++i; MD5STEP_R3 (B, C, D, A, X[(14U + 64U - idx_add) & 15U], 23, T[i]); ++i; } while (i < 48); /* Round 4. */ do { const unsigned int idx_add = i; MD5STEP_R4 (A, B, C, D, X[(0U + 64U - idx_add) & 15U], 6, T[i]); ++i; MD5STEP_R4 (D, A, B, C, X[(7U + 64U - idx_add) & 15U], 10, T[i]); ++i; MD5STEP_R4 (C, D, A, B, X[(14U + 64U - idx_add) & 15U], 15, T[i]); ++i; MD5STEP_R4 (B, C, D, A, X[(5U + 64U - idx_add) & 15U], 21, T[i]); ++i; } while (i < 64); } #endif /* MHD_FAVOR_SMALL_CODE */ /* Finally increment and store working variables. See RFC 1321, end of Clause 3.4 (step 4). */ H[0] += A; H[1] += B; H[2] += C; H[3] += D; } /** * Process portion of bytes. * * @param ctx the calculation context * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_MD5_update (struct Md5Ctx *ctx, const uint8_t *data, size_t length) { unsigned int bytes_have; /**< Number of bytes in the context buffer */ mhd_assert ((data != NULL) || (length == 0)); #ifndef MHD_FAVOR_SMALL_CODE if (0 == length) return; /* Shortcut, do nothing */ #endif /* MHD_FAVOR_SMALL_CODE */ /* Note: (count & (MD5_BLOCK_SIZE-1)) equals (count % MD5_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned int) (ctx->count & (MD5_BLOCK_SIZE - 1)); ctx->count += length; if (0 != bytes_have) { unsigned int bytes_left = MD5_BLOCK_SIZE - bytes_have; if (length >= bytes_left) { /* Combine new data with data in the buffer and process the full block. */ memcpy (((uint8_t *) ctx->buffer) + bytes_have, data, bytes_left); data += bytes_left; length -= bytes_left; md5_transform (ctx->H, ctx->buffer); bytes_have = 0; } } while (MD5_BLOCK_SIZE <= length) { /* Process any full blocks of new data directly, without copying to the buffer. */ md5_transform (ctx->H, data); data += MD5_BLOCK_SIZE; length -= MD5_BLOCK_SIZE; } if (0 != length) { /* Copy incomplete block of new data (if any) to the buffer. */ memcpy (((uint8_t *) ctx->buffer) + bytes_have, data, length); } } /** * Size of "length" insertion in bits. * See RFC 1321, end of Clause 3.2 (step 2). */ #define MD5_SIZE_OF_LEN_ADD_BITS 64 /** * Size of "length" insertion in bytes. */ #define MD5_SIZE_OF_LEN_ADD (MD5_SIZE_OF_LEN_ADD_BITS / 8) /** * Finalise MD5 calculation, return digest. * * @param ctx the calculation context * @param[out] digest set to the hash, must be #MD5_DIGEST_SIZE bytes */ void MHD_MD5_finish (struct Md5Ctx *ctx, uint8_t digest[MD5_DIGEST_SIZE]) { uint64_t num_bits; /**< Number of processed bits */ unsigned int bytes_have; /**< Number of bytes in the context buffer */ /* Memorise the number of processed bits. The padding and other data added here during the postprocessing must not change the amount of hashed data. */ num_bits = ctx->count << 3; /* Note: (count & (MD5_BLOCK_SIZE-1)) equals (count % MD5_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned int) (ctx->count & (MD5_BLOCK_SIZE - 1)); /* Input data must be padded with a single bit "1", then with zeros and the finally the length of data in bits must be added as the final bytes of the last block. See RFC 1321, Clauses 3.1 and 3.2 (steps 1 and 2). */ /* Data is always processed in form of bytes (not by individual bits), therefore position of the first padding bit in byte is always predefined (0x80). */ /* Buffer always have space for one byte at least (as full buffers are processed immediately). */ ((uint8_t *) ctx->buffer)[bytes_have++] = 0x80; if (MD5_BLOCK_SIZE - bytes_have < MD5_SIZE_OF_LEN_ADD) { /* No space in the current block to put the total length of message. Pad the current block with zeros and process it. */ if (bytes_have < MD5_BLOCK_SIZE) memset (((uint8_t *) ctx->buffer) + bytes_have, 0, MD5_BLOCK_SIZE - bytes_have); /* Process the full block. */ md5_transform (ctx->H, ctx->buffer); /* Start the new block. */ bytes_have = 0; } /* Pad the rest of the buffer with zeros. */ memset (((uint8_t *) ctx->buffer) + bytes_have, 0, MD5_BLOCK_SIZE - MD5_SIZE_OF_LEN_ADD - bytes_have); /* Put the number of bits in processed data as little-endian value. See RFC 1321, clauses 2 and 3.2 (step 2). */ _MHD_PUT_64BIT_LE_SAFE (ctx->buffer + MD5_BLOCK_SIZE_WORDS - 2, num_bits); /* Process the full final block. */ md5_transform (ctx->H, ctx->buffer); /* Put in LE mode the hash as the final digest. See RFC 1321, clauses 2 and 3.5 (step 5). */ #ifndef _MHD_PUT_32BIT_LE_UNALIGNED if (1 #ifndef MHD_FAVOR_SMALL_CODE && (0 != ((uintptr_t) digest) % _MHD_UINT32_ALIGN) #endif /* MHD_FAVOR_SMALL_CODE */ ) { /* If storing of the final result requires aligned address and the destination address is not aligned or compact code is used, store the final digest in aligned temporary buffer first, then copy it to the destination. */ uint32_t alig_dgst[MD5_DIGEST_SIZE_WORDS]; _MHD_PUT_32BIT_LE (alig_dgst + 0, ctx->H[0]); _MHD_PUT_32BIT_LE (alig_dgst + 1, ctx->H[1]); _MHD_PUT_32BIT_LE (alig_dgst + 2, ctx->H[2]); _MHD_PUT_32BIT_LE (alig_dgst + 3, ctx->H[3]); /* Copy result to the unaligned destination address. */ memcpy (digest, alig_dgst, MD5_DIGEST_SIZE); } #ifndef MHD_FAVOR_SMALL_CODE else /* Combined with the next 'if' */ #endif /* MHD_FAVOR_SMALL_CODE */ #endif /* ! _MHD_PUT_32BIT_LE_UNALIGNED */ #if ! defined(MHD_FAVOR_SMALL_CODE) || defined(_MHD_PUT_32BIT_LE_UNALIGNED) if (1) { /* Use cast to (void*) here to mute compiler alignment warnings. * Compilers are not smart enough to see that alignment has been checked. */ _MHD_PUT_32BIT_LE ((void *) (digest + 0 * MD5_BYTES_IN_WORD), ctx->H[0]); _MHD_PUT_32BIT_LE ((void *) (digest + 1 * MD5_BYTES_IN_WORD), ctx->H[1]); _MHD_PUT_32BIT_LE ((void *) (digest + 2 * MD5_BYTES_IN_WORD), ctx->H[2]); _MHD_PUT_32BIT_LE ((void *) (digest + 3 * MD5_BYTES_IN_WORD), ctx->H[3]); } #endif /* ! MHD_FAVOR_SMALL_CODE || _MHD_PUT_32BIT_LE_UNALIGNED */ /* Erase potentially sensitive data. */ memset (ctx, 0, sizeof(struct Md5Ctx)); } MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ libmicrohttpd-1.0.1/src/microhttpd/mhd_locks.h0000644000175000017500000001375414556705750015146 /* This file is part of libmicrohttpd Copyright (C) 2016-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_locks.h * @brief Header for platform-independent locks abstraction * @author Karlson2k (Evgeny Grin) * @author Christian Grothoff * * Provides basic abstraction for locks/mutex. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid * variable modification in function parameters. * * @warning Unlike pthread functions, most of functions return * nonzero on success. */ #ifndef MHD_LOCKS_H #define MHD_LOCKS_H 1 #include "mhd_options.h" #ifdef MHD_USE_THREADS #if defined(MHD_USE_W32_THREADS) # define MHD_W32_MUTEX_ 1 # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif /* !WIN32_LEAN_AND_MEAN */ # include #elif defined(HAVE_PTHREAD_H) && defined(MHD_USE_POSIX_THREADS) # define MHD_PTHREAD_MUTEX_ 1 # undef HAVE_CONFIG_H # include # define HAVE_CONFIG_H 1 #else # error No base mutex API is available. #endif #ifndef MHD_PANIC # include # ifdef HAVE_STDLIB_H # include # endif /* HAVE_STDLIB_H */ /* Simple implementation of MHD_PANIC, to be used outside lib */ # define MHD_PANIC(msg) \ do { fprintf (stderr, \ "Abnormal termination at %d line in file %s: %s\n", \ (int) __LINE__, __FILE__, msg); abort (); \ } while (0) #endif /* ! MHD_PANIC */ #if defined(MHD_PTHREAD_MUTEX_) typedef pthread_mutex_t MHD_mutex_; #elif defined(MHD_W32_MUTEX_) typedef CRITICAL_SECTION MHD_mutex_; #endif #if defined(MHD_PTHREAD_MUTEX_) /** * Initialise new mutex. * @param pmutex pointer to the mutex * @return nonzero on success, zero otherwise */ #define MHD_mutex_init_(pmutex) (! (pthread_mutex_init ((pmutex), NULL))) #elif defined(MHD_W32_MUTEX_) /** * Initialise new mutex. * @param pmutex pointer to mutex * @return nonzero on success, zero otherwise */ #define MHD_mutex_init_(pmutex) \ (InitializeCriticalSectionAndSpinCount ((pmutex),16)) #endif #if defined(MHD_PTHREAD_MUTEX_) # if defined(PTHREAD_MUTEX_INITIALIZER) /** * Define static mutex and statically initialise it. */ # define MHD_MUTEX_STATIC_DEFN_INIT_(m) \ static MHD_mutex_ m = PTHREAD_MUTEX_INITIALIZER # endif /* PTHREAD_MUTEX_INITIALIZER */ #endif #if defined(MHD_PTHREAD_MUTEX_) /** * Destroy previously initialised mutex. * @param pmutex pointer to mutex * @return nonzero on success, zero otherwise */ #define MHD_mutex_destroy_(pmutex) (! (pthread_mutex_destroy ((pmutex)))) #elif defined(MHD_W32_MUTEX_) /** * Destroy previously initialised mutex. * @param pmutex pointer to mutex * @return Always nonzero */ #define MHD_mutex_destroy_(pmutex) (DeleteCriticalSection ((pmutex)), ! 0) #endif /** * Destroy previously initialised mutex and abort execution * if error is detected. * @param pmutex pointer to mutex */ #define MHD_mutex_destroy_chk_(pmutex) do { \ if (! MHD_mutex_destroy_ (pmutex)) \ MHD_PANIC (_ ("Failed to destroy mutex.\n")); \ } while (0) #if defined(MHD_PTHREAD_MUTEX_) /** * Acquire lock on previously initialised mutex. * If mutex was already locked by other thread, function * blocks until mutex becomes available. * @param pmutex pointer to mutex * @return nonzero on success, zero otherwise */ #define MHD_mutex_lock_(pmutex) (! (pthread_mutex_lock ((pmutex)))) #elif defined(MHD_W32_MUTEX_) /** * Acquire lock on previously initialised mutex. * If mutex was already locked by other thread, function * blocks until mutex becomes available. * @param pmutex pointer to mutex * @return Always nonzero */ #define MHD_mutex_lock_(pmutex) (EnterCriticalSection ((pmutex)), ! 0) #endif /** * Acquire lock on previously initialised mutex. * If mutex was already locked by other thread, function * blocks until mutex becomes available. * If error is detected, execution will be aborted. * @param pmutex pointer to mutex */ #define MHD_mutex_lock_chk_(pmutex) do { \ if (! MHD_mutex_lock_ (pmutex)) \ MHD_PANIC (_ ("Failed to lock mutex.\n")); \ } while (0) #if defined(MHD_PTHREAD_MUTEX_) /** * Unlock previously initialised and locked mutex. * @param pmutex pointer to mutex * @return nonzero on success, zero otherwise */ #define MHD_mutex_unlock_(pmutex) (! (pthread_mutex_unlock ((pmutex)))) #elif defined(MHD_W32_MUTEX_) /** * Unlock previously initialised and locked mutex. * @param pmutex pointer to mutex * @return Always nonzero */ #define MHD_mutex_unlock_(pmutex) (LeaveCriticalSection ((pmutex)), ! 0) #endif /** * Unlock previously initialised and locked mutex. * If error is detected, execution will be aborted. * @param pmutex pointer to mutex */ #define MHD_mutex_unlock_chk_(pmutex) do { \ if (! MHD_mutex_unlock_ (pmutex)) \ MHD_PANIC (_ ("Failed to unlock mutex.\n")); \ } while (0) #else /* ! MHD_USE_THREADS */ #define MHD_mutex_init_(ignore) (! 0) #define MHD_mutex_destroy_(ignore) (! 0) #define MHD_mutex_destroy_chk_(ignore) (void)0 #define MHD_mutex_lock_(ignore) (! 0) #define MHD_mutex_lock_chk_(ignore) (void)0 #define MHD_mutex_unlock_(ignore) (! 0) #define MHD_mutex_unlock_chk_(ignore) (void)0 #endif /* ! MHD_USE_THREADS */ #endif /* ! MHD_LOCKS_H */ libmicrohttpd-1.0.1/src/microhttpd/sha1.h0000644000175000017500000000527014441373361014021 /* This file is part of libmicrohttpd Copyright (C) 2019-2021 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/sha1.h * @brief Calculation of SHA-1 digest * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_SHA1_H #define MHD_SHA1_H 1 #include "mhd_options.h" #include #ifdef HAVE_STDDEF_H #include /* for size_t */ #endif /* HAVE_STDDEF_H */ /** * SHA-1 digest is kept internally as 5 32-bit words. */ #define _SHA1_DIGEST_LENGTH 5 /** * Number of bits in single SHA-1 word */ #define SHA1_WORD_SIZE_BITS 32 /** * Number of bytes in single SHA-1 word */ #define SHA1_BYTES_IN_WORD (SHA1_WORD_SIZE_BITS / 8) /** * Size of SHA-1 digest in bytes */ #define SHA1_DIGEST_SIZE (_SHA1_DIGEST_LENGTH * SHA1_BYTES_IN_WORD) /** * Size of SHA-1 digest string in chars including termination NUL */ #define SHA1_DIGEST_STRING_SIZE ((SHA1_DIGEST_SIZE) * 2 + 1) /** * Size of single processing block in bits */ #define SHA1_BLOCK_SIZE_BITS 512 /** * Size of single processing block in bytes */ #define SHA1_BLOCK_SIZE (SHA1_BLOCK_SIZE_BITS / 8) struct sha1_ctx { uint32_t H[_SHA1_DIGEST_LENGTH]; /**< Intermediate hash value / digest at end of calculation */ uint8_t buffer[SHA1_BLOCK_SIZE]; /**< SHA256 input data buffer */ uint64_t count; /**< number of bytes, mod 2^64 */ }; /** * Initialise structure for SHA-1 calculation. * * @param ctx_ must be a `struct sha1_ctx *` */ void MHD_SHA1_init (void *ctx_); /** * Process portion of bytes. * * @param ctx_ must be a `struct sha1_ctx *` * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_SHA1_update (void *ctx_, const uint8_t *data, size_t length); /** * Finalise SHA-1 calculation, return digest. * * @param ctx_ must be a `struct sha1_ctx *` * @param[out] digest set to the hash, must be #SHA1_DIGEST_SIZE bytes */ void MHD_SHA1_finish (void *ctx_, uint8_t digest[SHA1_DIGEST_SIZE]); #endif /* MHD_SHA1_H */ libmicrohttpd-1.0.1/src/microhttpd/sha256_ext.c0000644000175000017500000000551114556705750015056 /* This file is part of GNU libmicrohttpd Copyright (C) 2022-2023 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GNU libmicrohttpd. If not, see . */ /** * @file microhttpd/sha256_ext.h * @brief Wrapper for SHA-256 calculation performed by TLS library * @author Karlson2k (Evgeny Grin) */ #include #include "sha256_ext.h" #include "mhd_assert.h" /** * Initialise structure for SHA-256 calculation, allocate resources. * * This function must not be called more than one time for @a ctx. * * @param ctx the calculation context */ void MHD_SHA256_init_one_time (struct Sha256CtxExt *ctx) { ctx->handle = NULL; ctx->ext_error = gnutls_hash_init (&ctx->handle, GNUTLS_DIG_SHA256); if ((0 != ctx->ext_error) && (NULL != ctx->handle)) { /* GnuTLS may return initialisation error and set the handle at the same time. Such handle cannot be used for calculations. Note: GnuTLS may also return an error and NOT set the handle. */ gnutls_free (ctx->handle); ctx->handle = NULL; } /* If handle is NULL, the error must be set */ mhd_assert ((NULL != ctx->handle) || (0 != ctx->ext_error)); /* If error is set, the handle must be NULL */ mhd_assert ((0 == ctx->ext_error) || (NULL == ctx->handle)); } /** * Process portion of bytes. * * @param ctx the calculation context * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_SHA256_update (struct Sha256CtxExt *ctx, const uint8_t *data, size_t length) { if (0 == ctx->ext_error) ctx->ext_error = gnutls_hash (ctx->handle, data, length); } /** * Finalise SHA-256 calculation, return digest, reset hash calculation. * * @param ctx the calculation context * @param[out] digest set to the hash, must be #SHA256_DIGEST_SIZE bytes */ void MHD_SHA256_finish_reset (struct Sha256CtxExt *ctx, uint8_t digest[SHA256_DIGEST_SIZE]) { if (0 == ctx->ext_error) gnutls_hash_output (ctx->handle, digest); } /** * Free allocated resources. * * @param ctx the calculation context */ void MHD_SHA256_deinit (struct Sha256CtxExt *ctx) { if (NULL != ctx->handle) gnutls_hash_deinit (ctx->handle, NULL); } libmicrohttpd-1.0.1/src/microhttpd/mhd_threads.h0000644000175000017500000004536514556705750015470 /* This file is part of libmicrohttpd Copyright (C) 2016-2023 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_threads.h * @brief Header for platform-independent threads abstraction * @author Karlson2k (Evgeny Grin) * * Provides basic abstraction for threads. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid * variable modification in function parameters. * * @warning Unlike pthread functions, most of functions return * nonzero on success. */ #ifndef MHD_THREADS_H #define MHD_THREADS_H 1 #include "mhd_options.h" #ifdef HAVE_STDDEF_H # include /* for size_t */ #elif defined(HAVE_STDLIB_H) # include /* for size_t */ #else /* ! HAVE_STDLIB_H */ # include /* for size_t */ #endif /* ! HAVE_STDLIB_H */ #if defined(MHD_USE_POSIX_THREADS) # undef HAVE_CONFIG_H # include # define HAVE_CONFIG_H 1 # ifndef MHD_USE_THREADS # define MHD_USE_THREADS 1 # endif #elif defined(MHD_USE_W32_THREADS) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif /* !WIN32_LEAN_AND_MEAN */ # include # ifndef MHD_USE_THREADS # define MHD_USE_THREADS 1 # endif #else # error No threading API is available. #endif #ifdef HAVE_STDBOOL_H # include #endif /* HAVE_STDBOOL_H */ #if defined(MHD_USE_POSIX_THREADS) && defined(MHD_USE_W32_THREADS) # error Both MHD_USE_POSIX_THREADS and MHD_USE_W32_THREADS are defined #endif /* MHD_USE_POSIX_THREADS && MHD_USE_W32_THREADS */ #ifndef MHD_NO_THREAD_NAMES # if defined(MHD_USE_POSIX_THREADS) # if defined(HAVE_PTHREAD_SETNAME_NP_GNU) || \ defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || \ defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || \ defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) || \ defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || \ defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) # define MHD_USE_THREAD_NAME_ # endif /* HAVE_PTHREAD_SETNAME_NP */ # elif defined(MHD_USE_W32_THREADS) # ifdef _MSC_FULL_VER /* Thread names only available with VC compiler */ # define MHD_USE_THREAD_NAME_ # endif /* _MSC_FULL_VER */ # endif #endif /* ** Thread handle - used to control the thread ** */ #if defined(MHD_USE_POSIX_THREADS) /** * Wait until specified thread is ended and free thread handle on success. * @param thread handle to watch * @return nonzero on success, zero otherwise */ # define MHD_join_thread_(native_handle) \ (! pthread_join ((native_handle), NULL)) #elif defined(MHD_USE_W32_THREADS) /** * Wait until specified thread is ended and free thread handle on success. * @param thread handle to watch * @return nonzero on success, zero otherwise */ # define MHD_join_thread_(native_handle) \ ( (WAIT_OBJECT_0 == WaitForSingleObject ( (native_handle), INFINITE)) ? \ (CloseHandle ( (native_handle)), ! 0) : 0 ) #endif #if defined(MHD_USE_POSIX_THREADS) /** * The native type to control the thread from other threads */ typedef pthread_t MHD_thread_handle_native_; #elif defined(MHD_USE_W32_THREADS) /** * The native type to control the thread from other threads */ typedef HANDLE MHD_thread_handle_native_; #endif #if defined(MHD_USE_POSIX_THREADS) # if defined(__gnu_linux__) || \ (defined(__linux__) && defined(__GLIBC__)) /* The next part of code is disabled because it relies on undocumented behaviour. It could be enabled for neglectable performance and size improvements. */ # if 0 /* Disabled code */ /** * The native invalid value for native thread handle */ # define MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_ \ ((MHD_thread_handle_native_) 0) # endif /* Disabled code */ # endif /* __gnu_linux__ || (__linux__ && __GLIBC__) */ #elif defined(MHD_USE_W32_THREADS) /** * The native invalid value for native thread handle */ # define MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_ \ ((MHD_thread_handle_native_) NULL) #endif /* MHD_USE_W32_THREADS */ #if ! defined(MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_) /** * Structure with thread handle and validity flag */ struct MHD_thread_handle_struct_ { bool valid; /**< true if native handle is set */ MHD_thread_handle_native_ native; /**< the native thread handle */ }; /** * Type with thread handle that can be set to invalid value */ typedef struct MHD_thread_handle_struct_ MHD_thread_handle_; /** * Set variable pointed by @a handle_ptr to invalid (unset) value */ # define MHD_thread_handle_set_invalid_(handle_ptr) \ ((handle_ptr)->valid = false) /** * Set native handle in variable pointed by @a handle_ptr * to @a native_val value */ # define MHD_thread_handle_set_native_(handle_ptr,native_val) \ ((handle_ptr)->valid = true, (handle_ptr)->native = native_val) /** * Check whether native handle value is set in @a handle_var variable */ # define MHD_thread_handle_is_valid_(handle_var) \ ((handle_var).valid) /** * Get native handle value from @a handle_var variable */ # define MHD_thread_handle_get_native_(handle_var) \ ((handle_var).native) #else /* MHD_THREAD_HANDLE_NATIVE_INVALID_ */ /** * Type with thread handle that can be set to invalid value */ typedef MHD_thread_handle_native_ MHD_thread_handle_; /** * Set variable pointed by @a handle_ptr to invalid (unset) value */ # define MHD_thread_handle_set_invalid_(handle_ptr) \ ((*(handle_ptr)) = MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_) /** * Set native handle in the variable pointed by @a handle_ptr * to @a native_val value */ # define MHD_thread_handle_set_native_(handle_ptr,native_val) \ ((*(handle_ptr)) = native_val) /** * Check whether native handle value is set in @a handle_var variable */ # define MHD_thread_handle_is_valid_(handle_var) \ (MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_ != handle_var) /** * Get native handle value from @a handle_var variable */ # define MHD_thread_handle_get_native_(handle_var) \ (handle_var) /** * Get pointer to native handle stored the variable pointed by @a handle_ptr * @note This macro could not available if direct manipulation of * the native handle is not possible */ # define MHD_thread_handle_get_native_ptr_(handle_ptr) \ (handle_ptr) #endif /* MHD_THREAD_HANDLE_NATIVE_INVALID_ */ /* ** Thread ID - used to check threads match ** */ #if defined(MHD_USE_POSIX_THREADS) /** * The native type used to check whether current thread matches expected thread */ typedef pthread_t MHD_thread_ID_native_; /** * Function to get the current thread native ID. */ # define MHD_thread_ID_native_current_ pthread_self /** * Check whether two native thread IDs are equal. * @return non-zero if equal, zero if not equal */ # define MHD_thread_ID_native_equal_(id1,id2) \ (pthread_equal(id1,id2)) #elif defined(MHD_USE_W32_THREADS) /** * The native type used to check whether current thread matches expected thread */ typedef DWORD MHD_thread_ID_native_; /** * Function to get the current thread native ID. */ # define MHD_thread_ID_native_current_ GetCurrentThreadId /** * Check whether two native thread IDs are equal. * @return non-zero if equal, zero if not equal */ # define MHD_thread_ID_native_equal_(id1,id2) \ ((id1) == (id2)) #endif /** * Check whether specified thread ID matches current thread. * @param id the thread ID to match * @return nonzero on match, zero otherwise */ #define MHD_thread_ID_native_is_current_thread_(id) \ MHD_thread_ID_native_equal_(id, MHD_thread_ID_native_current_()) #if defined(MHD_USE_POSIX_THREADS) # if defined(MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_) /** * The native invalid value for native thread ID */ # define MHD_THREAD_ID_NATIVE_VALUE_INVALID_ \ MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_ # endif /* MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_ */ #elif defined(MHD_USE_W32_THREADS) /** * The native invalid value for native thread ID */ # define MHD_THREAD_ID_NATIVE_VALUE_INVALID_ \ ((MHD_thread_ID_native_) 0) #endif /* MHD_USE_W32_THREADS */ #if ! defined(MHD_THREAD_ID_NATIVE_VALUE_INVALID_) /** * Structure with thread id and validity flag */ struct MHD_thread_ID_struct_ { bool valid; /**< true if native ID is set */ MHD_thread_ID_native_ native; /**< the native thread ID */ }; /** * Type with thread ID that can be set to invalid value */ typedef struct MHD_thread_ID_struct_ MHD_thread_ID_; /** * Set variable pointed by @a ID_ptr to invalid (unset) value */ # define MHD_thread_ID_set_invalid_(ID_ptr) \ ((ID_ptr)->valid = false) /** * Set native ID in variable pointed by @a ID_ptr * to @a native_val value */ # define MHD_thread_ID_set_native_(ID_ptr,native_val) \ ((ID_ptr)->valid = true, (ID_ptr)->native = native_val) /** * Check whether native ID value is set in @a ID_var variable */ # define MHD_thread_ID_is_valid_(ID_var) \ ((ID_var).valid) /** * Get native ID value from @a ID_var variable */ # define MHD_thread_ID_get_native_(ID_var) \ ((ID_var).native) /** * Check whether @a ID_var variable is equal current thread */ # define MHD_thread_ID_is_current_thread_(ID_var) \ (MHD_thread_ID_is_valid_(ID_var) && \ MHD_thread_ID_native_is_current_thread_((ID_var).native)) #else /* MHD_THREAD_ID_NATIVE_INVALID_ */ /** * Type with thread ID that can be set to invalid value */ typedef MHD_thread_ID_native_ MHD_thread_ID_; /** * Set variable pointed by @a ID_ptr to invalid (unset) value */ # define MHD_thread_ID_set_invalid_(ID_ptr) \ ((*(ID_ptr)) = MHD_THREAD_ID_NATIVE_VALUE_INVALID_) /** * Set native ID in variable pointed by @a ID_ptr * to @a native_val value */ # define MHD_thread_ID_set_native_(ID_ptr,native_val) \ ((*(ID_ptr)) = native_val) /** * Check whether native ID value is set in @a ID_var variable */ # define MHD_thread_ID_is_valid_(ID_var) \ (MHD_THREAD_ID_NATIVE_VALUE_INVALID_ != ID_var) /** * Get native ID value from @a ID_var variable */ # define MHD_thread_ID_get_native_(ID_var) \ (ID_var) /** * Check whether @a ID_var variable is equal current thread */ # define MHD_thread_ID_is_current_thread_(ID_var) \ MHD_thread_ID_native_is_current_thread_(ID_var) #endif /* MHD_THREAD_ID_NATIVE_INVALID_ */ /** * Set current thread ID in variable pointed by @a ID_ptr */ # define MHD_thread_ID_set_current_thread_(ID_ptr) \ MHD_thread_ID_set_native_(ID_ptr,MHD_thread_ID_native_current_()) #if defined(MHD_USE_POSIX_THREADS) # if defined(MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_) && \ ! defined(MHD_THREAD_ID_NATIVE_VALUE_INVALID_) # error \ MHD_THREAD_ID_NATIVE_VALUE_INVALID_ is defined, but MHD_THREAD_ID_NATIVE_VALUE_INVALID_ is not defined # elif ! defined(MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_) && \ defined(MHD_THREAD_ID_NATIVE_VALUE_INVALID_) # error \ MHD_THREAD_ID_NATIVE_VALUE_INVALID_ is not defined, but MHD_THREAD_ID_NATIVE_VALUE_INVALID_ is defined # endif #endif /* MHD_USE_POSIX_THREADS */ /* When staring a new thread, the kernel (and thread implementation) may * pause the calling (initial) thread and start the new thread. * If thread identifier is assigned to variable in the initial thread then * the value of the identifier variable will be undefined in the new thread * until the initial thread continue processing. * However, it is also possible that the new thread created, but not executed * for some time while the initial thread continue execution. In this case any * variable assigned in the new thread will be undefined for some time until * they really processed by the new thread. * To avoid data races, a special structure MHD_thread_handle_ID_ is used. * The "handle" is assigned by calling (initial) thread and should be always * defined when checked in the initial thread. * The "ID" is assigned by the new thread and should be always defined when * checked inside the new thread. */ /* Depending on implementation, pthread_create() MAY set thread ID into * provided pointer and after it start thread OR start thread and after * it set thread ID. In the latter case, to avoid data races, additional * pthread_self() call is required in thread routine. If some platform * is known for setting thread ID BEFORE starting thread macro * MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD could be defined * to save some resources. */ /* #define MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD 1 */ /* * handle - must be valid when other thread knows that particular thread is started. * ID - must be valid when code is executed inside thread */ #if defined(MHD_USE_POSIX_THREADS) && \ defined(MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD) && \ defined(MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_) && \ defined(MHD_THREAD_ID_NATIVE_VALUE_INVALID_) && \ defined(MHD_thread_handle_get_native_ptr_) union _MHD_thread_handle_ID_ { MHD_thread_handle_ handle; /**< To be used in other threads */ MHD_thread_ID_ ID; /**< To be used in the thread itself */ }; typedef union _MHD_thread_handle_ID_ MHD_thread_handle_ID_; # define MHD_THREAD_HANDLE_ID_IS_UNION 1 #else /* !MHD_USE_POSIX_THREADS || !MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD || !MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_ || !MHD_THREAD_ID_NATIVE_VALUE_INVALID_ || !MHD_thread_handle_get_native_ptr_ */ struct _MHD_thread_handle_ID_ { MHD_thread_handle_ handle; /**< To be used in other threads */ MHD_thread_ID_ ID; /**< To be used in the thread itself */ }; typedef struct _MHD_thread_handle_ID_ MHD_thread_handle_ID_; #endif /* !MHD_USE_POSIX_THREADS || !MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD || !MHD_THREAD_HANDLE_NATIVE_VALUE_INVALID_ || !MHD_THREAD_ID_NATIVE_VALUE_INVALID_ || !MHD_thread_handle_get_native_ptr_ */ /** * Set MHD_thread_handle_ID_ to invalid value */ #define MHD_thread_handle_ID_set_invalid_(hndl_id_ptr) \ (MHD_thread_handle_set_invalid_(&((hndl_id_ptr)->handle)), \ MHD_thread_ID_set_invalid_(&((hndl_id_ptr)->ID))) /** * Check whether thread handle is valid. * To be used in threads other then the thread specified by @a hndl_id. */ #define MHD_thread_handle_ID_is_valid_handle_(hndl_id) \ MHD_thread_handle_is_valid_((hndl_id).handle) /** * Set native handle in variable pointed by @a hndl_id_ptr * to @a native_val value */ #define MHD_thread_handle_ID_set_native_handle_(hndl_id_ptr,native_val) \ MHD_thread_handle_set_native_(&((hndl_id_ptr)->handle),native_val) #if defined(MHD_thread_handle_get_native_ptr_) /** * Get pointer to native handle stored the variable pointed by @a hndl_id_ptr * @note This macro could not available if direct manipulation of * the native handle is not possible */ # define MHD_thread_handle_ID_get_native_handle_ptr_(hndl_id_ptr) \ MHD_thread_handle_get_native_ptr_(&((hndl_id_ptr)->handle)) #endif /* MHD_thread_handle_get_native_ptr_ */ /** * Get native thread handle from MHD_thread_handle_ID_ variable. */ #define MHD_thread_handle_ID_get_native_handle_(hndl_id) \ MHD_thread_handle_get_native_((hndl_id).handle) /** * Check whether thread ID is valid. * To be used in the thread itself. */ #define MHD_thread_handle_ID_is_valid_ID_(hndl_id) \ MHD_thread_ID_is_valid_((hndl_id).ID) #if defined(MHD_THREAD_HANDLE_ID_IS_UNION) # if defined(MHD_USE_W32_THREADS) # error MHD_thread_handle_ID_ cannot be a union with W32 threads # endif /* MHD_USE_W32_THREADS */ /** * Set current thread ID in the variable pointed by @a hndl_id_ptr */ # define MHD_thread_handle_ID_set_current_thread_ID_(hndl_id_ptr) (void) 0 #else /* ! MHD_THREAD_HANDLE_ID_IS_UNION */ /** * Set current thread ID in the variable pointed by @a hndl_id_ptr */ # define MHD_thread_handle_ID_set_current_thread_ID_(hndl_id_ptr) \ MHD_thread_ID_set_current_thread_(&((hndl_id_ptr)->ID)) #endif /* ! MHD_THREAD_HANDLE_ID_IS_UNION */ /** * Check whether provided thread ID matches current thread. * @param ID thread ID to match * @return nonzero on match, zero otherwise */ #define MHD_thread_handle_ID_is_current_thread_(hndl_id) \ MHD_thread_ID_is_current_thread_((hndl_id).ID) /** * Wait until specified thread is ended and free thread handle on success. * @param hndl_id_ handle with ID to watch * @return nonzero on success, zero otherwise */ #define MHD_thread_handle_ID_join_thread_(hndl_id) \ MHD_join_thread_(MHD_thread_handle_ID_get_native_handle_(hndl_id)) #if defined(MHD_USE_POSIX_THREADS) # define MHD_THRD_RTRN_TYPE_ void* # define MHD_THRD_CALL_SPEC_ #elif defined(MHD_USE_W32_THREADS) # define MHD_THRD_RTRN_TYPE_ unsigned # define MHD_THRD_CALL_SPEC_ __stdcall #endif /** * Signature of main function for a thread. * * @param cls closure argument for the function * @return termination code from the thread */ typedef MHD_THRD_RTRN_TYPE_ (MHD_THRD_CALL_SPEC_ *MHD_THREAD_START_ROUTINE_)(void *cls); /** * Create a thread and set the attributes according to our options. * * If thread is created, thread handle must be freed by MHD_join_thread_(). * * @param handle_id handle to initialise * @param stack_size size of stack for new thread, 0 for default * @param start_routine main function of thread * @param arg argument for start_routine * @return non-zero on success; zero otherwise (with errno set) */ int MHD_create_thread_ (MHD_thread_handle_ID_ *handle_id, size_t stack_size, MHD_THREAD_START_ROUTINE_ start_routine, void *arg); #ifndef MHD_USE_THREAD_NAME_ #define MHD_create_named_thread_(t,n,s,r,a) MHD_create_thread_ ((t),(s),(r),(a)) #else /* MHD_USE_THREAD_NAME_ */ /** * Create a named thread and set the attributes according to our options. * * @param handle_id handle to initialise * @param thread_name name for new thread * @param stack_size size of stack for new thread, 0 for default * @param start_routine main function of thread * @param arg argument for start_routine * @return non-zero on success; zero otherwise */ int MHD_create_named_thread_ (MHD_thread_handle_ID_ *handle_id, const char *thread_name, size_t stack_size, MHD_THREAD_START_ROUTINE_ start_routine, void *arg); #endif /* MHD_USE_THREAD_NAME_ */ #endif /* ! MHD_THREADS_H */ libmicrohttpd-1.0.1/src/microhttpd/sha512_256.c0000644000175000017500000007027714566122702014567 /* This file is part of GNU libmicrohttpd Copyright (C) 2022-2023 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/sha512_256.c * @brief Calculation of SHA-512/256 digest as defined in FIPS PUB 180-4 (2015) * @author Karlson2k (Evgeny Grin) */ #include "sha512_256.h" #include #ifdef HAVE_MEMORY_H #include #endif /* HAVE_MEMORY_H */ #include "mhd_bithelpers.h" #include "mhd_assert.h" /** * Initialise structure for SHA-512/256 calculation. * * @param ctx the calculation context */ void MHD_SHA512_256_init (struct Sha512_256Ctx *ctx) { /* Initial hash values, see FIPS PUB 180-4 clause 5.3.6.2 */ /* Values generated by "IV Generation Function" as described in * clause 5.3.6 */ ctx->H[0] = UINT64_C (0x22312194FC2BF72C); ctx->H[1] = UINT64_C (0x9F555FA3C84C64C2); ctx->H[2] = UINT64_C (0x2393B86B6F53B151); ctx->H[3] = UINT64_C (0x963877195940EABD); ctx->H[4] = UINT64_C (0x96283EE2A88EFFE3); ctx->H[5] = UINT64_C (0xBE5E1E2553863992); ctx->H[6] = UINT64_C (0x2B0199FC2C85B8AA); ctx->H[7] = UINT64_C (0x0EB72DDC81C52CA2); /* Initialise number of bytes and high part of number of bits. */ ctx->count = 0; ctx->count_bits_hi = 0; } MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ /** * Base of SHA-512/256 transformation. * Gets full 128 bytes block of data and updates hash values; * @param H hash values * @param data the data buffer with #SHA512_256_BLOCK_SIZE bytes block */ static void sha512_256_transform (uint64_t H[SHA512_256_HASH_SIZE_WORDS], const void *data) { /* Working variables, see FIPS PUB 180-4 clause 6.7, 6.4. */ uint64_t a = H[0]; uint64_t b = H[1]; uint64_t c = H[2]; uint64_t d = H[3]; uint64_t e = H[4]; uint64_t f = H[5]; uint64_t g = H[6]; uint64_t h = H[7]; /* Data buffer, used as a cyclic buffer. See FIPS PUB 180-4 clause 5.2.2, 6.7, 6.4. */ uint64_t W[16]; #ifndef _MHD_GET_64BIT_BE_ALLOW_UNALIGNED if (0 != (((uintptr_t) data) % _MHD_UINT64_ALIGN)) { /* The input data is unaligned */ /* Copy the unaligned input data to the aligned buffer */ memcpy (W, data, sizeof(W)); /* The W[] buffer itself will be used as the source of the data, * but the data will be reloaded in correct bytes order on * the next steps */ data = (const void *) W; } #endif /* _MHD_GET_64BIT_BE_ALLOW_UNALIGNED */ /* 'Ch' and 'Maj' macro functions are defined with widely-used optimisation. See FIPS PUB 180-4 formulae 4.8, 4.9. */ #define Ch(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) ) #define Maj(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) /* Unoptimized (original) versions: */ /* #define Ch(x,y,z) ( ( (x) & (y) ) ^ ( ~(x) & (z) ) ) */ /* #define Maj(x,y,z) ( ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) ) */ /* Four 'Sigma' macro functions. See FIPS PUB 180-4 formulae 4.10, 4.11, 4.12, 4.13. */ #define SIG0(x) \ ( _MHD_ROTR64 ((x), 28) ^ _MHD_ROTR64 ((x), 34) ^ _MHD_ROTR64 ((x), 39) ) #define SIG1(x) \ ( _MHD_ROTR64 ((x), 14) ^ _MHD_ROTR64 ((x), 18) ^ _MHD_ROTR64 ((x), 41) ) #define sig0(x) \ ( _MHD_ROTR64 ((x), 1) ^ _MHD_ROTR64 ((x), 8) ^ ((x) >> 7) ) #define sig1(x) \ ( _MHD_ROTR64 ((x), 19) ^ _MHD_ROTR64 ((x), 61) ^ ((x) >> 6) ) /* One step of SHA-512/256 computation, see FIPS PUB 180-4 clause 6.4.2 step 3. * Note: this macro updates working variables in-place, without rotation. * Note: the first (vH += SIG1(vE) + Ch(vE,vF,vG) + kt + wt) equals T1 in FIPS PUB 180-4 clause 6.4.2 step 3. the second (vH += SIG0(vA) + Maj(vE,vF,vC) equals T1 + T2 in FIPS PUB 180-4 clause 6.4.2 step 3. * Note: 'wt' must be used exactly one time in this macro as it change other data as well every time when used. */ #define SHA2STEP64(vA,vB,vC,vD,vE,vF,vG,vH,kt,wt) do { \ (vD) += ((vH) += SIG1 ((vE)) + Ch ((vE),(vF),(vG)) + (kt) + (wt)); \ (vH) += SIG0 ((vA)) + Maj ((vA),(vB),(vC)); } while (0) /* Get value of W(t) from input data buffer for 0 <= t <= 15, See FIPS PUB 180-4 clause 6.2. Input data must be read in big-endian bytes order, see FIPS PUB 180-4 clause 3.1.2. */ #define GET_W_FROM_DATA(buf,t) \ _MHD_GET_64BIT_BE (((const uint64_t*) (buf)) + (t)) /* 'W' generation and assignment for 16 <= t <= 79. See FIPS PUB 180-4 clause 6.4.2. As only last 16 'W' are used in calculations, it is possible to use 16 elements array of W as a cyclic buffer. * Note: ((t-16) & 15) have same value as (t & 15) */ #define Wgen(w,t) ( (w)[(t - 16) & 15] + sig1 ((w)[((t) - 2) & 15]) \ + (w)[((t) - 7) & 15] + sig0 ((w)[((t) - 15) & 15]) ) #ifndef MHD_FAVOR_SMALL_CODE /* Note: instead of using K constants as array, all K values are specified individually for each step, see FIPS PUB 180-4 clause 4.2.3 for K values. */ /* Note: instead of reassigning all working variables on each step, variables are rotated for each step: SHA2STEP64(a, b, c, d, e, f, g, h, K[0], data[0]); SHA2STEP64(h, a, b, c, d, e, f, g, K[1], data[1]); so current 'vD' will be used as 'vE' on next step, current 'vH' will be used as 'vA' on next step. */ #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN if ((const void *) W == data) { /* The input data is already in the cyclic data buffer W[] in correct bytes order. */ SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0x428a2f98d728ae22), W[0]); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0x7137449123ef65cd), W[1]); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0xb5c0fbcfec4d3b2f), W[2]); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0xe9b5dba58189dbbc), W[3]); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0x3956c25bf348b538), W[4]); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0x59f111f1b605d019), W[5]); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0x923f82a4af194f9b), W[6]); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0xab1c5ed5da6d8118), W[7]); SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0xd807aa98a3030242), W[8]); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0x12835b0145706fbe), W[9]); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0x243185be4ee4b28c), W[10]); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0x550c7dc3d5ffb4e2), W[11]); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0x72be5d74f27b896f), W[12]); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0x80deb1fe3b1696b1), W[13]); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0x9bdc06a725c71235), W[14]); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0xc19bf174cf692694), W[15]); } else /* Combined with the next 'if' */ #endif /* _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN */ if (1) { /* During first 16 steps, before making any calculations on each step, the W element is read from the input data buffer as big-endian value and stored in the array of W elements. */ SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0x428a2f98d728ae22), \ W[0] = GET_W_FROM_DATA (data, 0)); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0x7137449123ef65cd), \ W[1] = GET_W_FROM_DATA (data, 1)); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0xb5c0fbcfec4d3b2f), \ W[2] = GET_W_FROM_DATA (data, 2)); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0xe9b5dba58189dbbc), \ W[3] = GET_W_FROM_DATA (data, 3)); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0x3956c25bf348b538), \ W[4] = GET_W_FROM_DATA (data, 4)); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0x59f111f1b605d019), \ W[5] = GET_W_FROM_DATA (data, 5)); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0x923f82a4af194f9b), \ W[6] = GET_W_FROM_DATA (data, 6)); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0xab1c5ed5da6d8118), \ W[7] = GET_W_FROM_DATA (data, 7)); SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0xd807aa98a3030242), \ W[8] = GET_W_FROM_DATA (data, 8)); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0x12835b0145706fbe), \ W[9] = GET_W_FROM_DATA (data, 9)); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0x243185be4ee4b28c), \ W[10] = GET_W_FROM_DATA (data, 10)); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0x550c7dc3d5ffb4e2), \ W[11] = GET_W_FROM_DATA (data, 11)); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0x72be5d74f27b896f), \ W[12] = GET_W_FROM_DATA (data, 12)); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0x80deb1fe3b1696b1), \ W[13] = GET_W_FROM_DATA (data, 13)); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0x9bdc06a725c71235), \ W[14] = GET_W_FROM_DATA (data, 14)); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0xc19bf174cf692694), \ W[15] = GET_W_FROM_DATA (data, 15)); } /* During last 64 steps, before making any calculations on each step, current W element is generated from other W elements of the cyclic buffer and the generated value is stored back in the cyclic buffer. */ /* Note: instead of using K constants as array, all K values are specified individually for each step, see FIPS PUB 180-4 clause 4.2.3 for K values. */ SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0xe49b69c19ef14ad2), \ W[16 & 15] = Wgen (W,16)); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0xefbe4786384f25e3), \ W[17 & 15] = Wgen (W,17)); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0x0fc19dc68b8cd5b5), \ W[18 & 15] = Wgen (W,18)); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0x240ca1cc77ac9c65), \ W[19 & 15] = Wgen (W,19)); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0x2de92c6f592b0275), \ W[20 & 15] = Wgen (W,20)); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0x4a7484aa6ea6e483), \ W[21 & 15] = Wgen (W,21)); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0x5cb0a9dcbd41fbd4), \ W[22 & 15] = Wgen (W,22)); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0x76f988da831153b5), \ W[23 & 15] = Wgen (W,23)); SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0x983e5152ee66dfab), \ W[24 & 15] = Wgen (W,24)); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0xa831c66d2db43210), \ W[25 & 15] = Wgen (W,25)); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0xb00327c898fb213f), \ W[26 & 15] = Wgen (W,26)); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0xbf597fc7beef0ee4), \ W[27 & 15] = Wgen (W,27)); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0xc6e00bf33da88fc2), \ W[28 & 15] = Wgen (W,28)); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0xd5a79147930aa725), \ W[29 & 15] = Wgen (W,29)); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0x06ca6351e003826f), \ W[30 & 15] = Wgen (W,30)); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0x142929670a0e6e70), \ W[31 & 15] = Wgen (W,31)); SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0x27b70a8546d22ffc), \ W[32 & 15] = Wgen (W,32)); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0x2e1b21385c26c926), \ W[33 & 15] = Wgen (W,33)); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0x4d2c6dfc5ac42aed), \ W[34 & 15] = Wgen (W,34)); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0x53380d139d95b3df), \ W[35 & 15] = Wgen (W,35)); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0x650a73548baf63de), \ W[36 & 15] = Wgen (W,36)); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0x766a0abb3c77b2a8), \ W[37 & 15] = Wgen (W,37)); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0x81c2c92e47edaee6), \ W[38 & 15] = Wgen (W,38)); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0x92722c851482353b), \ W[39 & 15] = Wgen (W,39)); SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0xa2bfe8a14cf10364), \ W[40 & 15] = Wgen (W,40)); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0xa81a664bbc423001), \ W[41 & 15] = Wgen (W,41)); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0xc24b8b70d0f89791), \ W[42 & 15] = Wgen (W,42)); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0xc76c51a30654be30), \ W[43 & 15] = Wgen (W,43)); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0xd192e819d6ef5218), \ W[44 & 15] = Wgen (W,44)); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0xd69906245565a910), \ W[45 & 15] = Wgen (W,45)); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0xf40e35855771202a), \ W[46 & 15] = Wgen (W,46)); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0x106aa07032bbd1b8), \ W[47 & 15] = Wgen (W,47)); SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0x19a4c116b8d2d0c8), \ W[48 & 15] = Wgen (W,48)); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0x1e376c085141ab53), \ W[49 & 15] = Wgen (W,49)); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0x2748774cdf8eeb99), \ W[50 & 15] = Wgen (W,50)); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0x34b0bcb5e19b48a8), \ W[51 & 15] = Wgen (W,51)); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0x391c0cb3c5c95a63), \ W[52 & 15] = Wgen (W,52)); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0x4ed8aa4ae3418acb), \ W[53 & 15] = Wgen (W,53)); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0x5b9cca4f7763e373), \ W[54 & 15] = Wgen (W,54)); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0x682e6ff3d6b2b8a3), \ W[55 & 15] = Wgen (W,55)); SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0x748f82ee5defb2fc), \ W[56 & 15] = Wgen (W,56)); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0x78a5636f43172f60), \ W[57 & 15] = Wgen (W,57)); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0x84c87814a1f0ab72), \ W[58 & 15] = Wgen (W,58)); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0x8cc702081a6439ec), \ W[59 & 15] = Wgen (W,59)); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0x90befffa23631e28), \ W[60 & 15] = Wgen (W,60)); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0xa4506cebde82bde9), \ W[61 & 15] = Wgen (W,61)); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0xbef9a3f7b2c67915), \ W[62 & 15] = Wgen (W,62)); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0xc67178f2e372532b), \ W[63 & 15] = Wgen (W,63)); SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0xca273eceea26619c), \ W[64 & 15] = Wgen (W,64)); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0xd186b8c721c0c207), \ W[65 & 15] = Wgen (W,65)); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0xeada7dd6cde0eb1e), \ W[66 & 15] = Wgen (W,66)); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0xf57d4f7fee6ed178), \ W[67 & 15] = Wgen (W,67)); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0x06f067aa72176fba), \ W[68 & 15] = Wgen (W,68)); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0x0a637dc5a2c898a6), \ W[69 & 15] = Wgen (W,69)); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0x113f9804bef90dae), \ W[70 & 15] = Wgen (W,70)); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0x1b710b35131c471b), \ W[71 & 15] = Wgen (W,71)); SHA2STEP64 (a, b, c, d, e, f, g, h, UINT64_C (0x28db77f523047d84), \ W[72 & 15] = Wgen (W,72)); SHA2STEP64 (h, a, b, c, d, e, f, g, UINT64_C (0x32caab7b40c72493), \ W[73 & 15] = Wgen (W,73)); SHA2STEP64 (g, h, a, b, c, d, e, f, UINT64_C (0x3c9ebe0a15c9bebc), \ W[74 & 15] = Wgen (W,74)); SHA2STEP64 (f, g, h, a, b, c, d, e, UINT64_C (0x431d67c49c100d4c), \ W[75 & 15] = Wgen (W,75)); SHA2STEP64 (e, f, g, h, a, b, c, d, UINT64_C (0x4cc5d4becb3e42b6), \ W[76 & 15] = Wgen (W,76)); SHA2STEP64 (d, e, f, g, h, a, b, c, UINT64_C (0x597f299cfc657e2a), \ W[77 & 15] = Wgen (W,77)); SHA2STEP64 (c, d, e, f, g, h, a, b, UINT64_C (0x5fcb6fab3ad6faec), \ W[78 & 15] = Wgen (W,78)); SHA2STEP64 (b, c, d, e, f, g, h, a, UINT64_C (0x6c44198c4a475817), \ W[79 & 15] = Wgen (W,79)); #else /* MHD_FAVOR_SMALL_CODE */ if (1) { unsigned int t; /* K constants array. See FIPS PUB 180-4 clause 4.2.3 for K values. */ static const uint64_t K[80] = { UINT64_C (0x428a2f98d728ae22), UINT64_C (0x7137449123ef65cd), UINT64_C (0xb5c0fbcfec4d3b2f), UINT64_C (0xe9b5dba58189dbbc), UINT64_C (0x3956c25bf348b538), UINT64_C (0x59f111f1b605d019), UINT64_C (0x923f82a4af194f9b), UINT64_C (0xab1c5ed5da6d8118), UINT64_C (0xd807aa98a3030242), UINT64_C (0x12835b0145706fbe), UINT64_C (0x243185be4ee4b28c), UINT64_C (0x550c7dc3d5ffb4e2), UINT64_C (0x72be5d74f27b896f), UINT64_C (0x80deb1fe3b1696b1), UINT64_C (0x9bdc06a725c71235), UINT64_C (0xc19bf174cf692694), UINT64_C (0xe49b69c19ef14ad2), UINT64_C (0xefbe4786384f25e3), UINT64_C (0x0fc19dc68b8cd5b5), UINT64_C (0x240ca1cc77ac9c65), UINT64_C (0x2de92c6f592b0275), UINT64_C (0x4a7484aa6ea6e483), UINT64_C (0x5cb0a9dcbd41fbd4), UINT64_C (0x76f988da831153b5), UINT64_C (0x983e5152ee66dfab), UINT64_C (0xa831c66d2db43210), UINT64_C (0xb00327c898fb213f), UINT64_C (0xbf597fc7beef0ee4), UINT64_C (0xc6e00bf33da88fc2), UINT64_C (0xd5a79147930aa725), UINT64_C (0x06ca6351e003826f), UINT64_C (0x142929670a0e6e70), UINT64_C (0x27b70a8546d22ffc), UINT64_C (0x2e1b21385c26c926), UINT64_C (0x4d2c6dfc5ac42aed), UINT64_C (0x53380d139d95b3df), UINT64_C (0x650a73548baf63de), UINT64_C (0x766a0abb3c77b2a8), UINT64_C (0x81c2c92e47edaee6), UINT64_C (0x92722c851482353b), UINT64_C (0xa2bfe8a14cf10364), UINT64_C (0xa81a664bbc423001), UINT64_C (0xc24b8b70d0f89791), UINT64_C (0xc76c51a30654be30), UINT64_C (0xd192e819d6ef5218), UINT64_C (0xd69906245565a910), UINT64_C (0xf40e35855771202a), UINT64_C (0x106aa07032bbd1b8), UINT64_C (0x19a4c116b8d2d0c8), UINT64_C (0x1e376c085141ab53), UINT64_C (0x2748774cdf8eeb99), UINT64_C (0x34b0bcb5e19b48a8), UINT64_C (0x391c0cb3c5c95a63), UINT64_C (0x4ed8aa4ae3418acb), UINT64_C (0x5b9cca4f7763e373), UINT64_C (0x682e6ff3d6b2b8a3), UINT64_C (0x748f82ee5defb2fc), UINT64_C (0x78a5636f43172f60), UINT64_C (0x84c87814a1f0ab72), UINT64_C (0x8cc702081a6439ec), UINT64_C (0x90befffa23631e28), UINT64_C (0xa4506cebde82bde9), UINT64_C (0xbef9a3f7b2c67915), UINT64_C (0xc67178f2e372532b), UINT64_C (0xca273eceea26619c), UINT64_C (0xd186b8c721c0c207), UINT64_C (0xeada7dd6cde0eb1e), UINT64_C (0xf57d4f7fee6ed178), UINT64_C (0x06f067aa72176fba), UINT64_C (0x0a637dc5a2c898a6), UINT64_C (0x113f9804bef90dae), UINT64_C (0x1b710b35131c471b), UINT64_C (0x28db77f523047d84), UINT64_C (0x32caab7b40c72493), UINT64_C (0x3c9ebe0a15c9bebc), UINT64_C (0x431d67c49c100d4c), UINT64_C (0x4cc5d4becb3e42b6), UINT64_C (0x597f299cfc657e2a), UINT64_C (0x5fcb6fab3ad6faec), UINT64_C (0x6c44198c4a475817)}; /* One step of SHA-512/256 computation with working variables rotation, see FIPS PUB 180-4 clause 6.4.2 step 3. * Note: this version of macro reassign all working variable on each step. */ #define SHA2STEP64RV(vA,vB,vC,vD,vE,vF,vG,vH,kt,wt) do { \ uint64_t tmp_h_ = (vH); \ SHA2STEP64((vA),(vB),(vC),(vD),(vE),(vF),(vG),tmp_h_,(kt),(wt)); \ (vH) = (vG); \ (vG) = (vF); \ (vF) = (vE); \ (vE) = (vD); \ (vD) = (vC); \ (vC) = (vB); \ (vB) = (vA); \ (vA) = tmp_h_; } while (0) /* During first 16 steps, before making any calculations on each step, the W element is read from the input data buffer as big-endian value and stored in the array of W elements. */ for (t = 0; t < 16; ++t) { SHA2STEP64RV (a, b, c, d, e, f, g, h, K[t], \ W[t] = GET_W_FROM_DATA (data, t)); } /* During last 64 steps, before making any calculations on each step, current W element is generated from other W elements of the cyclic buffer and the generated value is stored back in the cyclic buffer. */ for (t = 16; t < 80; ++t) { SHA2STEP64RV (a, b, c, d, e, f, g, h, K[t], \ W[t & 15] = Wgen (W,t)); } } #endif /* MHD_FAVOR_SMALL_CODE */ /* Compute and store the intermediate hash. See FIPS PUB 180-4 clause 6.4.2 step 4. */ H[0] += a; H[1] += b; H[2] += c; H[3] += d; H[4] += e; H[5] += f; H[6] += g; H[7] += h; } /** * Process portion of bytes. * * @param ctx the calculation context * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_SHA512_256_update (struct Sha512_256Ctx *ctx, const uint8_t *data, size_t length) { unsigned int bytes_have; /**< Number of bytes in the context buffer */ uint64_t count_hi; /**< The high part to be moved to another variable */ mhd_assert ((data != NULL) || (length == 0)); #ifndef MHD_FAVOR_SMALL_CODE if (0 == length) return; /* Shortcut, do nothing */ #endif /* ! MHD_FAVOR_SMALL_CODE */ /* Note: (count & (SHA512_256_BLOCK_SIZE-1)) equals (count % SHA512_256_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned int) (ctx->count & (SHA512_256_BLOCK_SIZE - 1)); ctx->count += length; #if SIZEOF_SIZE_T > 7 if (length > ctx->count) ctx->count_bits_hi += 1U << 3; /* Value wrap */ #endif /* SIZEOF_SIZE_T > 7 */ count_hi = ctx->count >> 61; if (0 != count_hi) { ctx->count_bits_hi += count_hi; ctx->count &= UINT64_C (0x1FFFFFFFFFFFFFFF); } if (0 != bytes_have) { unsigned int bytes_left = SHA512_256_BLOCK_SIZE - bytes_have; if (length >= bytes_left) { /* Combine new data with data in the buffer and process the full block. */ memcpy (((uint8_t *) ctx->buffer) + bytes_have, data, bytes_left); data += bytes_left; length -= bytes_left; sha512_256_transform (ctx->H, ctx->buffer); bytes_have = 0; } } while (SHA512_256_BLOCK_SIZE <= length) { /* Process any full blocks of new data directly, without copying to the buffer. */ sha512_256_transform (ctx->H, data); data += SHA512_256_BLOCK_SIZE; length -= SHA512_256_BLOCK_SIZE; } if (0 != length) { /* Copy incomplete block of new data (if any) to the buffer. */ memcpy (((uint8_t *) ctx->buffer) + bytes_have, data, length); } } /** * Size of "length" insertion in bits. * See FIPS PUB 180-4 clause 5.1.2. */ #define SHA512_256_SIZE_OF_LEN_ADD_BITS 128 /** * Size of "length" insertion in bytes. */ #define SHA512_256_SIZE_OF_LEN_ADD (SHA512_256_SIZE_OF_LEN_ADD_BITS / 8) /** * Finalise SHA-512/256 calculation, return digest. * * @param ctx the calculation context * @param[out] digest set to the hash, must be #SHA512_256_DIGEST_SIZE bytes */ void MHD_SHA512_256_finish (struct Sha512_256Ctx *ctx, uint8_t digest[SHA512_256_DIGEST_SIZE]) { uint64_t num_bits; /**< Number of processed bits */ unsigned int bytes_have; /**< Number of bytes in the context buffer */ /* Memorise the number of processed bits. The padding and other data added here during the postprocessing must not change the amount of hashed data. */ num_bits = ctx->count << 3; /* Note: (count & (SHA512_256_BLOCK_SIZE-1)) equals (count % SHA512_256_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned int) (ctx->count & (SHA512_256_BLOCK_SIZE - 1)); /* Input data must be padded with a single bit "1", then with zeros and the finally the length of data in bits must be added as the final bytes of the last block. See FIPS PUB 180-4 clause 5.1.2. */ /* Data is always processed in form of bytes (not by individual bits), therefore position of the first padding bit in byte is always predefined (0x80). */ /* Buffer always have space for one byte at least (as full buffers are processed immediately). */ ((uint8_t *) ctx->buffer)[bytes_have++] = 0x80; if (SHA512_256_BLOCK_SIZE - bytes_have < SHA512_256_SIZE_OF_LEN_ADD) { /* No space in the current block to put the total length of message. Pad the current block with zeros and process it. */ if (bytes_have < SHA512_256_BLOCK_SIZE) memset (((uint8_t *) ctx->buffer) + bytes_have, 0, SHA512_256_BLOCK_SIZE - bytes_have); /* Process the full block. */ sha512_256_transform (ctx->H, ctx->buffer); /* Start the new block. */ bytes_have = 0; } /* Pad the rest of the buffer with zeros. */ memset (((uint8_t *) ctx->buffer) + bytes_have, 0, SHA512_256_BLOCK_SIZE - SHA512_256_SIZE_OF_LEN_ADD - bytes_have); /* Put high part of number of bits in processed message and then lower part of number of bits as big-endian values. See FIPS PUB 180-4 clause 5.1.2. */ /* Note: the target location is predefined and buffer is always aligned */ _MHD_PUT_64BIT_BE (ctx->buffer + SHA512_256_BLOCK_SIZE_WORDS - 2, ctx->count_bits_hi); _MHD_PUT_64BIT_BE (ctx->buffer + SHA512_256_BLOCK_SIZE_WORDS - 1, num_bits); /* Process the full final block. */ sha512_256_transform (ctx->H, ctx->buffer); /* Put in BE mode the leftmost part of the hash as the final digest. See FIPS PUB 180-4 clause 6.7. */ #ifndef _MHD_PUT_64BIT_BE_UNALIGNED if (1 #ifndef MHD_FAVOR_SMALL_CODE && (0 != ((uintptr_t) digest) % _MHD_UINT64_ALIGN) #endif /* MHD_FAVOR_SMALL_CODE */ ) { /* If storing of the final result requires aligned address and the destination address is not aligned or compact code is used, store the final digest in aligned temporary buffer first, then copy it to the destination. */ uint64_t alig_dgst[SHA512_256_DIGEST_SIZE_WORDS]; _MHD_PUT_64BIT_BE (alig_dgst + 0, ctx->H[0]); _MHD_PUT_64BIT_BE (alig_dgst + 1, ctx->H[1]); _MHD_PUT_64BIT_BE (alig_dgst + 2, ctx->H[2]); _MHD_PUT_64BIT_BE (alig_dgst + 3, ctx->H[3]); /* Copy result to the unaligned destination address */ memcpy (digest, alig_dgst, SHA512_256_DIGEST_SIZE); } #ifndef MHD_FAVOR_SMALL_CODE else /* Combined with the next 'if' */ #endif /* MHD_FAVOR_SMALL_CODE */ #endif /* ! _MHD_PUT_64BIT_BE_UNALIGNED */ #if ! defined(MHD_FAVOR_SMALL_CODE) || defined(_MHD_PUT_64BIT_BE_UNALIGNED) if (1) { /* Use cast to (void*) here to mute compiler alignment warnings. * Compilers are not smart enough to see that alignment has been checked. */ _MHD_PUT_64BIT_BE ((void *) (digest + 0 * SHA512_256_BYTES_IN_WORD), \ ctx->H[0]); _MHD_PUT_64BIT_BE ((void *) (digest + 1 * SHA512_256_BYTES_IN_WORD), \ ctx->H[1]); _MHD_PUT_64BIT_BE ((void *) (digest + 2 * SHA512_256_BYTES_IN_WORD), \ ctx->H[2]); _MHD_PUT_64BIT_BE ((void *) (digest + 3 * SHA512_256_BYTES_IN_WORD), \ ctx->H[3]); } #endif /* ! MHD_FAVOR_SMALL_CODE || _MHD_PUT_64BIT_BE_UNALIGNED */ /* Erase potentially sensitive data. */ memset (ctx, 0, sizeof(struct Sha512_256Ctx)); } MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ libmicrohttpd-1.0.1/src/microhttpd/connection_https.c0000644000175000017500000001542614556705750016555 /* This file is part of libmicrohttpd Copyright (C) 2007, 2008, 2010 Daniel Pittman and Christian Grothoff Copyright (C) 2015-2022 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file connection_https.c * @brief Methods for managing SSL/TLS connections. This file is only * compiled if ENABLE_HTTPS is set. * @author Sagie Amir * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "internal.h" #include "connection.h" #include "connection_https.h" #include "memorypool.h" #include "response.h" #include "mhd_mono_clock.h" #include #include "mhd_send.h" /** * Callback for receiving data from the socket. * * @param connection the MHD_Connection structure * @param other where to write received data to * @param i maximum size of other (in bytes) * @return positive value for number of bytes actually received or * negative value for error number MHD_ERR_xxx_ */ static ssize_t recv_tls_adapter (struct MHD_Connection *connection, void *other, size_t i) { ssize_t res; if (i > SSIZE_MAX) i = SSIZE_MAX; res = gnutls_record_recv (connection->tls_session, other, i); if ( (GNUTLS_E_AGAIN == res) || (GNUTLS_E_INTERRUPTED == res) ) { #ifdef EPOLL_SUPPORT if (GNUTLS_E_AGAIN == res) connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); #endif /* Any network errors means that buffer is empty. */ connection->tls_read_ready = false; return MHD_ERR_AGAIN_; } if (res < 0) { connection->tls_read_ready = false; if ( (GNUTLS_E_DECRYPTION_FAILED == res) || (GNUTLS_E_INVALID_SESSION == res) || (GNUTLS_E_DECOMPRESSION_FAILED == res) || (GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER == res) || (GNUTLS_E_UNSUPPORTED_VERSION_PACKET == res) || (GNUTLS_E_UNEXPECTED_PACKET_LENGTH == res) || (GNUTLS_E_UNEXPECTED_PACKET == res) || (GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET == res) || (GNUTLS_E_EXPIRED == res) || (GNUTLS_E_REHANDSHAKE == res) ) return MHD_ERR_TLS_; if ( (GNUTLS_E_PULL_ERROR == res) || (GNUTLS_E_INTERNAL_ERROR == res) || (GNUTLS_E_CRYPTODEV_IOCTL_ERROR == res) || (GNUTLS_E_CRYPTODEV_DEVICE_ERROR == res) ) return MHD_ERR_PIPE_; #if defined(GNUTLS_E_PREMATURE_TERMINATION) if (GNUTLS_E_PREMATURE_TERMINATION == res) return MHD_ERR_CONNRESET_; #elif defined(GNUTLS_E_UNEXPECTED_PACKET_LENGTH) if (GNUTLS_E_UNEXPECTED_PACKET_LENGTH == res) return MHD_ERR_CONNRESET_; #endif /* GNUTLS_E_UNEXPECTED_PACKET_LENGTH */ if (GNUTLS_E_MEMORY_ERROR == res) return MHD_ERR_NOMEM_; /* Treat any other error as a hard error. */ return MHD_ERR_NOTCONN_; } #ifdef EPOLL_SUPPORT /* Unlike non-TLS connections, do not reset "read-ready" if * received amount smaller than provided amount, as TLS * connections may receive data by fixed-size chunks. */ #endif /* EPOLL_SUPPORT */ /* Check whether TLS buffers still have some unread data. */ connection->tls_read_ready = ( ((size_t) res == i) && (0 != gnutls_record_check_pending (connection->tls_session)) ); return res; } /** * Give gnuTLS chance to work on the TLS handshake. * * @param connection connection to handshake on * @return true if the handshake has completed successfully * and we should start to read/write data, * false is handshake in progress or in case * of error */ bool MHD_run_tls_handshake_ (struct MHD_Connection *connection) { int ret; if ((MHD_TLS_CONN_INIT == connection->tls_state) || (MHD_TLS_CONN_HANDSHAKING == connection->tls_state)) { #if 0 /* According to real-live testing, Nagel's Algorithm is not blocking * partial packets on just connected sockets on modern OSes. As TLS setup * is performed as the fist action upon socket connection, the next * optimisation typically is not required. If any specific OS will * require this optimization, it could be enabled by allowing the next * lines for this specific OS. */ if (_MHD_ON != connection->sk_nodelay) MHD_connection_set_nodelay_state_ (connection, true); #endif ret = gnutls_handshake (connection->tls_session); if (ret == GNUTLS_E_SUCCESS) { /* set connection TLS state to enable HTTP processing */ connection->tls_state = MHD_TLS_CONN_CONNECTED; MHD_update_last_activity_ (connection); return true; } if ( (GNUTLS_E_AGAIN == ret) || (GNUTLS_E_INTERRUPTED == ret) ) { connection->tls_state = MHD_TLS_CONN_HANDSHAKING; /* handshake not done */ return false; } /* handshake failed */ connection->tls_state = MHD_TLS_CONN_TLS_FAILED; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Error: received handshake message out of context.\n")); #endif MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_WITH_ERROR); return false; } return true; } /** * Set connection callback function to be used through out * the processing of this secure connection. * * @param connection which callbacks should be modified */ void MHD_set_https_callbacks (struct MHD_Connection *connection) { connection->recv_cls = &recv_tls_adapter; } /** * Initiate shutdown of TLS layer of connection. * * @param connection to use * @return true if succeed, false otherwise. */ bool MHD_tls_connection_shutdown (struct MHD_Connection *connection) { if (MHD_TLS_CONN_WR_CLOSED > connection->tls_state) { const int res = gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR); if (GNUTLS_E_SUCCESS == res) { connection->tls_state = MHD_TLS_CONN_WR_CLOSED; return true; } if ((GNUTLS_E_AGAIN == res) || (GNUTLS_E_INTERRUPTED == res)) { connection->tls_state = MHD_TLS_CONN_WR_CLOSING; return true; } else connection->tls_state = MHD_TLS_CONN_TLS_FAILED; } return false; } /* end of connection_https.c */ libmicrohttpd-1.0.1/src/microhttpd/mhd_mono_clock.h0000644000175000017500000000373514556705750016154 /* This file is part of libmicrohttpd Copyright (C) 2015-2021 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_mono_clock.h * @brief internal monotonic clock functions declarations * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_MONO_CLOCK_H #define MHD_MONO_CLOCK_H 1 #include "mhd_options.h" #if defined(HAVE_TIME_H) #include #elif defined(HAVE_SYS_TYPES_H) #include #endif #include /** * Initialise monotonic seconds and milliseconds counters. */ void MHD_monotonic_sec_counter_init (void); /** * Deinitialise monotonic seconds and milliseconds counters by freeing * any allocated resources */ void MHD_monotonic_sec_counter_finish (void); /** * Monotonic seconds counter. * Tries to be not affected by manually setting the system real time * clock or adjustments by NTP synchronization. * * @return number of seconds from some fixed moment */ time_t MHD_monotonic_sec_counter (void); /** * Monotonic milliseconds counter, useful for timeout calculation. * Tries to be not affected by manually setting the system real time * clock or adjustments by NTP synchronization. * * @return number of microseconds from some fixed moment */ uint64_t MHD_monotonic_msec_counter (void); #endif /* MHD_MONO_CLOCK_H */ libmicrohttpd-1.0.1/src/microhttpd/test_postprocessor_amp.c0000644000175000017500000001175714441373361020010 #include "platform.h" #include "microhttpd.h" #include "internal.h" #include #include #include static uint64_t num_errors; static enum MHD_Result check_post (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *content_encoding, const char *data, uint64_t off, size_t size) { (void) cls; (void) kind; (void) filename; (void) content_type; /* Unused. Silent compiler warning. */ (void) content_encoding; (void) data; (void) off; (void) size; /* Unused. Silent compiler warning. */ if ((0 != strcmp (key, "a")) && (0 != strcmp (key, "b"))) { printf ("ERROR: got unexpected '%s'\n", key); num_errors++; } return MHD_YES; } int main (int argc, char *const *argv) { struct MHD_Connection connection; struct MHD_HTTP_Req_Header header; struct MHD_PostProcessor *pp; const char *post = "a=xx+xx+xxx+xxxxx+xxxx+xxxxxxxx+xxx+xxxxxx+xxx+xxx+xxxxxxx+xxxxx%0A+++" "++++xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxx%0A+++++++--%3E%0A++++++++++++++%3Cxxxxx+xxxxx%3D%22xxx%" "25%22%3E%0A+++++++++++%3Cxx%3E%0A+++++++++++++++%3Cxx+xxxxxxx%3D%22x%2" "2+xxxxx%3D%22xxxxx%22%3E%0A+++++++++++++++++++%3Cxxxxx+xxxxx%3D%22xxx%" "25%22%3E%0A+++++++++++++++++++++++%3Cxx%3E%0A+++++++++++++++++++++++++" "++%3Cxx+xxxxx%3D%22xxxx%22%3E%0A+++++++++++++++++++++++++++++++%3Cx+xx" "xxx%3D%22xxxx-xxxxx%3Axxxxx%22%3Exxxxx%3A%3C%2Fx%3E%0A%0A+++++++++++++" "++++++++++++++++++%3Cx+xxxxx%3D%22xxxx-xxxxx%3Axxxxx%22%3Exxx%3A%3C%2F" "x%3E%0A%0A+++++++++++++++++++++++++++++++%3Cx+xxxxx%3D%22xxxx-xxxxx%3A" "xxxxx%3B+xxxx-xxxxxx%3A+xxxx%3B%22%3Exxxxx+xxxxx%3A%3C%2Fx%3E%0A++++++" "+++++++++++++++++++++%3C%2Fxx%3E%0A+++++++++++++++++++++++%3C%2Fxx%3E%" "0A+++++++++++++++++++%3C%2Fxxxxx%3E%0A+++++++++++++++%3C%2Fxx%3E%0A+++" "++++++++++++%3Cxx+xxxxx%3D%22xxxx-xxxxx%3A+xxxxx%3B+xxxxx%3A+xxxx%22%3" "E%26xxxxx%3B+%3Cxxxx%0A+++++++++++++++++++++++xxxxx%3D%22xxxxxxxxxxxxx" "xx%22%3Exxxx.xx%3C%2Fxxxx%3E%0A+++++++++++++++%3C%2Fxx%3E%0A++++++++++" "+%3C%2Fxx%3E%0A++++++++++++++++++++++++++%3Cxx%3E%0A++++++++++++++++++" "+%3Cxx+xxxxx%3D%22xxxx-xxxxx%3A+xxxxx%3B+xxxxx%3A+xxxx%22%3E%26xxxxx%3" "B+%3Cxxxx%0A+++++++++++++++++++++++++++xxxxx%3D%22xxxxxxxxxxxxxxx%22%3" "Exxx.xx%3C%2Fxxxx%3E%0A+++++++++++++++++++%3C%2Fxx%3E%0A++++++++++++++" "+%3C%2Fxx%3E%0A++++++++++++++++++++++%3Cxx%3E%0A+++++++++++++++%3Cxx+x" "xxxx%3D%22xxxx-xxxxx%3A+xxxxx%3Bxxxx-xxxxxx%3A+xxxx%3B+xxxxx%3A+xxxx%2" "2%3E%26xxxxx%3B+%3Cxxxx%0A+++++++++++++++++++++++xxxxx%3D%22xxxxxxxxxx" "xxxxx%22%3Exxxx.xx%3C%2Fxxxx%3E%3C%2Fxx%3E%0A+++++++++++%3C%2Fxx%3E%0A" "+++++++%3C%2Fxxxxx%3E%0A+++++++%3C%21--%0A+++++++xxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%0A+++++++x" "xx+xx+xxxxx+xxxxxxx+xxxxxxx%0A+++++++xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%0A+++++++--%3E%0A+++%3" "C%2Fxxx%3E%0A%0A%0A%0A+++%3Cxxx+xxxxx%3D%22xxxxxxxxx%22+xx%3D%22xxxxxx" "xxx%22%3E%3C%2Fxxx%3E%0A%0A+++%3Cxxx+xx%3D%22xxxx%22+xxxxx%3D%22xxxx%2" "2%3E%0A+++++++%3Cxxxxx+xxxxx%3D%22xxxxxxxxx%22%3E%0A+++++++++++%3Cxx%3" "E%0A+++++++++++++++%3Cxx+xxxxxxx%3D%22x%22+xx%3D%22xxxxxxxxxxxxx%22+xx" "xxx%3D%22xxxxxxxxxxxxx%22%3E%0A+++++++++++++++++++%3Cxxx+xx%3D%22xxxxx" "x%22%3E%3C%2Fxxx%3E%0A+++++++++++++++%3C%2Fxx%3E%0A+++++++++++%3C%2Fxx" "%3E%0A+++++++++++%3Cxx%3E%0A+++++++++++++++%3Cxx+xx%3D%22xxxxxxxxxxxxx" "xxxx%22+xxxxx%3D%22xxxxxxxxxxxxxxxxx%22%3E%3C%2Fxx%3E%0A++++++++++++++" "+%3Cxx+xx%3D%22xxxxxxxxxxxxxx%22+xxxxx%3D%22xxxxxxxxxxxxxx%22%3E%0A+++" "++++++++++++++++%3Cxxx+xx%3D%22xxxxxxx%22%3E%3C%2Fxxx%3E%0A+++++++++++" "++++%3C%2Fxx%3E%0A+++++++++++%3C%2Fxx%3E%0A+++++++++++%3Cxx%3E%0A+++++" "++++++++++%3Cxx+xxxxxxx%3D%22x%22+xx%3D%22xxxxxxxxxxxxx%22+xxxxx%3D%22" "xxxxxxxxxxxxx%22%3E%0A+++++++++++++++++++%3Cxxx+xx%3D%22xxxxxx%22%3E%3" "C%2Fxxx%3E%0A+++++++++++++++%3C%2Fxx%3E%0A+++++++++++%3C%2Fxx%3E%0A+++" "++++%3C%2Fxxxxx%3E%0A+++%3C%2Fxxx%3E%0A%3C%2Fxxx%3E%0A%0A%3Cxxx+xx%3D%" "22xxxxxx%22%3E%3C%2Fxxx%3E%0A%0A%3C%2Fxxxx%3E%0A%3C%2Fxxxx%3E+&b=value"; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ num_errors = 0; memset (&connection, 0, sizeof (struct MHD_Connection)); memset (&header, 0, sizeof (struct MHD_HTTP_Res_Header)); connection.rq.headers_received = &header; header.header = MHD_HTTP_HEADER_CONTENT_TYPE; header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED; header.header_size = strlen (header.header); header.value_size = strlen (header.value); header.kind = MHD_HEADER_KIND; pp = MHD_create_post_processor (&connection, 4096, &check_post, NULL); if (NULL == pp) return 1; if (MHD_YES != MHD_post_process (pp, post, strlen (post))) num_errors++; MHD_destroy_post_processor (pp); return num_errors == 0 ? 0 : 2; } libmicrohttpd-1.0.1/src/microhttpd/mhd_bithelpers.h0000644000175000017500000004023614556705750016167 /* This file is part of libmicrohttpd Copyright (C) 2019-2023 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/mhd_bithelpers.h * @brief macros for bits manipulations * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_BITHELPERS_H #define MHD_BITHELPERS_H 1 #include "mhd_options.h" #include #if defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ defined(__OPTIMIZE__))) /* Declarations for VC & Clang/C2 built-ins */ #include #endif /* _MSC_FULL_VER */ #include "mhd_byteorder.h" #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN || _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN #include "mhd_align.h" #endif /* _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN || _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN */ #ifndef __has_builtin /* Avoid precompiler errors with non-clang */ # define __has_builtin(x) 0 # define _MHD_has_builtin_dummy 1 #endif MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ #ifdef MHD_HAVE___BUILTIN_BSWAP32 #define _MHD_BYTES_SWAP32(value32) \ ((uint32_t) __builtin_bswap32 ((uint32_t) value32)) #elif defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ defined(__OPTIMIZE__))) /* Clang/C2 may not inline this function if optimizations are turned off. */ #ifndef __clang__ #pragma intrinsic(_byteswap_ulong) #endif /* ! __clang__ */ #define _MHD_BYTES_SWAP32(value32) \ ((uint32_t) _byteswap_ulong ((uint32_t) value32)) #elif \ __has_builtin (__builtin_bswap32) #define _MHD_BYTES_SWAP32(value32) \ ((uint32_t) __builtin_bswap32 ((uint32_t) value32)) #else /* ! __has_builtin(__builtin_bswap32) */ #define _MHD_BYTES_SWAP32(value32) \ ( (((uint32_t) (value32)) << 24) \ | ((((uint32_t) (value32)) & ((uint32_t) 0x0000FF00)) << 8) \ | ((((uint32_t) (value32)) & ((uint32_t) 0x00FF0000)) >> 8) \ | (((uint32_t) (value32)) >> 24) ) #endif /* ! __has_builtin(__builtin_bswap32) */ #ifdef MHD_HAVE___BUILTIN_BSWAP64 #define _MHD_BYTES_SWAP64(value64) \ ((uint64_t) __builtin_bswap64 ((uint64_t) value64)) #elif defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ defined(__OPTIMIZE__))) /* Clang/C2 may not inline this function if optimizations are turned off. */ #ifndef __clang__ #pragma intrinsic(_byteswap_uint64) #endif /* ! __clang__ */ #define _MHD_BYTES_SWAP64(value64) \ ((uint64_t) _byteswap_uint64 ((uint64_t) value64)) #elif \ __has_builtin (__builtin_bswap64) #define _MHD_BYTES_SWAP64(value64) \ ((uint64_t) __builtin_bswap64 ((uint64_t) value64)) #else /* ! __has_builtin(__builtin_bswap64) */ #define _MHD_BYTES_SWAP64(value64) \ ( (((uint64_t) (value64)) << 56) \ | ((((uint64_t) (value64)) & ((uint64_t) 0x000000000000FF00)) << 40) \ | ((((uint64_t) (value64)) & ((uint64_t) 0x0000000000FF0000)) << 24) \ | ((((uint64_t) (value64)) & ((uint64_t) 0x00000000FF000000)) << 8) \ | ((((uint64_t) (value64)) & ((uint64_t) 0x000000FF00000000)) >> 8) \ | ((((uint64_t) (value64)) & ((uint64_t) 0x0000FF0000000000)) >> 24) \ | ((((uint64_t) (value64)) & ((uint64_t) 0x00FF000000000000)) >> 40) \ | (((uint64_t) (value64)) >> 56) ) #endif /* ! __has_builtin(__builtin_bswap64) */ /* _MHD_PUT_64BIT_LE (addr, value64) * put native-endian 64-bit value64 to addr * in little-endian mode. */ /* Slow version that works with unaligned addr and with any bytes order */ #define _MHD_PUT_64BIT_LE_SLOW(addr, value64) do { \ ((uint8_t*) (addr))[0] = (uint8_t) ((uint64_t) (value64)); \ ((uint8_t*) (addr))[1] = (uint8_t) (((uint64_t) (value64)) >> 8); \ ((uint8_t*) (addr))[2] = (uint8_t) (((uint64_t) (value64)) >> 16); \ ((uint8_t*) (addr))[3] = (uint8_t) (((uint64_t) (value64)) >> 24); \ ((uint8_t*) (addr))[4] = (uint8_t) (((uint64_t) (value64)) >> 32); \ ((uint8_t*) (addr))[5] = (uint8_t) (((uint64_t) (value64)) >> 40); \ ((uint8_t*) (addr))[6] = (uint8_t) (((uint64_t) (value64)) >> 48); \ ((uint8_t*) (addr))[7] = (uint8_t) (((uint64_t) (value64)) >> 56); \ } while (0) #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN #define _MHD_PUT_64BIT_LE(addr, value64) \ ((*(uint64_t*) (addr)) = (uint64_t) (value64)) #elif _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN #define _MHD_PUT_64BIT_LE(addr, value64) \ ((*(uint64_t*) (addr)) = _MHD_BYTES_SWAP64 (value64)) #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ /* Endianness was not detected or non-standard like PDP-endian */ #define _MHD_PUT_64BIT_LE(addr, value64) do { \ ((uint8_t*) (addr))[0] = (uint8_t) ((uint64_t) (value64)); \ ((uint8_t*) (addr))[1] = (uint8_t) (((uint64_t) (value64)) >> 8); \ ((uint8_t*) (addr))[2] = (uint8_t) (((uint64_t) (value64)) >> 16); \ ((uint8_t*) (addr))[3] = (uint8_t) (((uint64_t) (value64)) >> 24); \ ((uint8_t*) (addr))[4] = (uint8_t) (((uint64_t) (value64)) >> 32); \ ((uint8_t*) (addr))[5] = (uint8_t) (((uint64_t) (value64)) >> 40); \ ((uint8_t*) (addr))[6] = (uint8_t) (((uint64_t) (value64)) >> 48); \ ((uint8_t*) (addr))[7] = (uint8_t) (((uint64_t) (value64)) >> 56); \ } while (0) /* Indicate that _MHD_PUT_64BIT_LE does not need aligned pointer */ #define _MHD_PUT_64BIT_LE_UNALIGNED 1 #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ /* Put result safely to unaligned address */ _MHD_static_inline void _MHD_PUT_64BIT_LE_SAFE (void *dst, uint64_t value) { #ifndef _MHD_PUT_64BIT_LE_UNALIGNED if (0 != ((uintptr_t) dst) % (_MHD_UINT64_ALIGN)) _MHD_PUT_64BIT_LE_SLOW (dst, value); else #endif /* ! _MHD_PUT_64BIT_LE_UNALIGNED */ _MHD_PUT_64BIT_LE (dst, value); } /* _MHD_PUT_32BIT_LE (addr, value32) * put native-endian 32-bit value32 to addr * in little-endian mode. */ #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN #define _MHD_PUT_32BIT_LE(addr,value32) \ ((*(uint32_t*) (addr)) = (uint32_t) (value32)) #elif _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN #define _MHD_PUT_32BIT_LE(addr, value32) \ ((*(uint32_t*) (addr)) = _MHD_BYTES_SWAP32 (value32)) #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ /* Endianness was not detected or non-standard like PDP-endian */ #define _MHD_PUT_32BIT_LE(addr, value32) do { \ ((uint8_t*) (addr))[0] = (uint8_t) ((uint32_t) (value32)); \ ((uint8_t*) (addr))[1] = (uint8_t) (((uint32_t) (value32)) >> 8); \ ((uint8_t*) (addr))[2] = (uint8_t) (((uint32_t) (value32)) >> 16); \ ((uint8_t*) (addr))[3] = (uint8_t) (((uint32_t) (value32)) >> 24); \ } while (0) /* Indicate that _MHD_PUT_32BIT_LE does not need aligned pointer */ #define _MHD_PUT_32BIT_LE_UNALIGNED 1 #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ /* _MHD_GET_32BIT_LE (addr) * get little-endian 32-bit value storied at addr * and return it in native-endian mode. */ #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN #define _MHD_GET_32BIT_LE(addr) \ (*(const uint32_t*) (addr)) #elif _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN #define _MHD_GET_32BIT_LE(addr) \ _MHD_BYTES_SWAP32 (*(const uint32_t*) (addr)) #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ /* Endianness was not detected or non-standard like PDP-endian */ #define _MHD_GET_32BIT_LE(addr) \ ( ( (uint32_t) (((const uint8_t*) addr)[0])) \ | (((uint32_t) (((const uint8_t*) addr)[1])) << 8) \ | (((uint32_t) (((const uint8_t*) addr)[2])) << 16) \ | (((uint32_t) (((const uint8_t*) addr)[3])) << 24) ) /* Indicate that _MHD_GET_32BIT_LE does not need aligned pointer */ #define _MHD_GET_32BIT_LE_UNALIGNED 1 #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ /* _MHD_PUT_64BIT_BE (addr, value64) * put native-endian 64-bit value64 to addr * in big-endian mode. */ /* Slow version that works with unaligned addr and with any bytes order */ #define _MHD_PUT_64BIT_BE_SLOW(addr, value64) do { \ ((uint8_t*) (addr))[7] = (uint8_t) ((uint64_t) (value64)); \ ((uint8_t*) (addr))[6] = (uint8_t) (((uint64_t) (value64)) >> 8); \ ((uint8_t*) (addr))[5] = (uint8_t) (((uint64_t) (value64)) >> 16); \ ((uint8_t*) (addr))[4] = (uint8_t) (((uint64_t) (value64)) >> 24); \ ((uint8_t*) (addr))[3] = (uint8_t) (((uint64_t) (value64)) >> 32); \ ((uint8_t*) (addr))[2] = (uint8_t) (((uint64_t) (value64)) >> 40); \ ((uint8_t*) (addr))[1] = (uint8_t) (((uint64_t) (value64)) >> 48); \ ((uint8_t*) (addr))[0] = (uint8_t) (((uint64_t) (value64)) >> 56); \ } while (0) #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN #define _MHD_PUT_64BIT_BE(addr, value64) \ ((*(uint64_t*) (addr)) = (uint64_t) (value64)) #elif _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN #define _MHD_PUT_64BIT_BE(addr, value64) \ ((*(uint64_t*) (addr)) = _MHD_BYTES_SWAP64 (value64)) #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ /* Endianness was not detected or non-standard like PDP-endian */ #define _MHD_PUT_64BIT_BE(addr, value64) _MHD_PUT_64BIT_BE_SLOW(addr, value64) /* Indicate that _MHD_PUT_64BIT_BE does not need aligned pointer */ #define _MHD_PUT_64BIT_BE_UNALIGNED 1 #endif /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ /* Put result safely to unaligned address */ _MHD_static_inline void _MHD_PUT_64BIT_BE_SAFE (void *dst, uint64_t value) { #ifndef _MHD_PUT_64BIT_BE_UNALIGNED if (0 != ((uintptr_t) dst) % (_MHD_UINT64_ALIGN)) _MHD_PUT_64BIT_BE_SLOW (dst, value); else #endif /* ! _MHD_PUT_64BIT_BE_UNALIGNED */ _MHD_PUT_64BIT_BE (dst, value); } /* _MHD_GET_64BIT_BE (addr) * load 64-bit value located at addr in big endian mode. */ #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN #define _MHD_GET_64BIT_BE(addr) \ (*(const uint64_t*) (addr)) #elif _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN #define _MHD_GET_64BIT_BE(addr) \ _MHD_BYTES_SWAP64 (*(const uint64_t*) (addr)) #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ /* Endianness was not detected or non-standard like PDP-endian */ #define _MHD_GET_64BIT_BE(addr) \ ( (((uint64_t) (((const uint8_t*) addr)[0])) << 56) \ | (((uint64_t) (((const uint8_t*) addr)[1])) << 48) \ | (((uint64_t) (((const uint8_t*) addr)[2])) << 40) \ | (((uint64_t) (((const uint8_t*) addr)[3])) << 32) \ | (((uint64_t) (((const uint8_t*) addr)[4])) << 24) \ | (((uint64_t) (((const uint8_t*) addr)[5])) << 16) \ | (((uint64_t) (((const uint8_t*) addr)[6])) << 8) \ | ((uint64_t) (((const uint8_t*) addr)[7])) ) /* Indicate that _MHD_GET_64BIT_BE does not need aligned pointer */ #define _MHD_GET_64BIT_BE_ALLOW_UNALIGNED 1 #endif /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ /* _MHD_PUT_32BIT_BE (addr, value32) * put native-endian 32-bit value32 to addr * in big-endian mode. */ #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN #define _MHD_PUT_32BIT_BE(addr, value32) \ ((*(uint32_t*) (addr)) = (uint32_t) (value32)) #elif _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN #define _MHD_PUT_32BIT_BE(addr, value32) \ ((*(uint32_t*) (addr)) = _MHD_BYTES_SWAP32 (value32)) #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ /* Endianness was not detected or non-standard like PDP-endian */ #define _MHD_PUT_32BIT_BE(addr, value32) do { \ ((uint8_t*) (addr))[3] = (uint8_t) ((uint32_t) (value32)); \ ((uint8_t*) (addr))[2] = (uint8_t) (((uint32_t) (value32)) >> 8); \ ((uint8_t*) (addr))[1] = (uint8_t) (((uint32_t) (value32)) >> 16); \ ((uint8_t*) (addr))[0] = (uint8_t) (((uint32_t) (value32)) >> 24); \ } while (0) /* Indicate that _MHD_PUT_32BIT_BE does not need aligned pointer */ #define _MHD_PUT_32BIT_BE_UNALIGNED 1 #endif /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ /* _MHD_GET_32BIT_BE (addr) * get big-endian 32-bit value storied at addr * and return it in native-endian mode. */ #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN #define _MHD_GET_32BIT_BE(addr) \ (*(const uint32_t*) (addr)) #elif _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN #define _MHD_GET_32BIT_BE(addr) \ _MHD_BYTES_SWAP32 (*(const uint32_t*) (addr)) #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ /* Endianness was not detected or non-standard like PDP-endian */ #define _MHD_GET_32BIT_BE(addr) \ ( (((uint32_t) (((const uint8_t*) addr)[0])) << 24) \ | (((uint32_t) (((const uint8_t*) addr)[1])) << 16) \ | (((uint32_t) (((const uint8_t*) addr)[2])) << 8) \ | ((uint32_t) (((const uint8_t*) addr)[3])) ) /* Indicate that _MHD_GET_32BIT_BE does not need aligned pointer */ #define _MHD_GET_32BIT_BE_UNALIGNED 1 #endif /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ /** * Rotate right 32-bit value by number of bits. * bits parameter must be more than zero and must be less than 32. */ #if defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ defined(__OPTIMIZE__))) /* Clang/C2 do not inline this function if optimizations are turned off. */ #ifndef __clang__ #pragma intrinsic(_rotr) #endif /* ! __clang__ */ #define _MHD_ROTR32(value32, bits) \ ((uint32_t) _rotr ((uint32_t) (value32),(bits))) #elif __has_builtin (__builtin_rotateright32) #define _MHD_ROTR32(value32, bits) \ ((uint32_t) __builtin_rotateright32 ((value32), (bits))) #else /* ! __builtin_rotateright32 */ _MHD_static_inline uint32_t _MHD_ROTR32 (uint32_t value32, int bits) { bits %= 32; if (0 == bits) return value32; /* Defined in form which modern compiler could optimize. */ return (value32 >> bits) | (value32 << (32 - bits)); } #endif /* ! __builtin_rotateright32 */ /** * Rotate left 32-bit value by number of bits. * bits parameter must be more than zero and must be less than 32. */ #if defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ defined(__OPTIMIZE__))) /* Clang/C2 do not inline this function if optimizations are turned off. */ #ifndef __clang__ #pragma intrinsic(_rotl) #endif /* ! __clang__ */ #define _MHD_ROTL32(value32, bits) \ ((uint32_t) _rotl ((uint32_t) (value32),(bits))) #elif __has_builtin (__builtin_rotateleft32) #define _MHD_ROTL32(value32, bits) \ ((uint32_t) __builtin_rotateleft32 ((value32), (bits))) #else /* ! __builtin_rotateleft32 */ _MHD_static_inline uint32_t _MHD_ROTL32 (uint32_t value32, int bits) { bits %= 32; if (0 == bits) return value32; /* Defined in form which modern compiler could optimize. */ return (value32 << bits) | (value32 >> (32 - bits)); } #endif /* ! __builtin_rotateleft32 */ /** * Rotate right 64-bit value by number of bits. * bits parameter must be more than zero and must be less than 64. */ #if defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ defined(__OPTIMIZE__))) /* Clang/C2 do not inline this function if optimisations are turned off. */ #ifndef __clang__ #pragma intrinsic(_rotr64) #endif /* ! __clang__ */ #define _MHD_ROTR64(value64, bits) \ ((uint64_t) _rotr64 ((uint64_t) (value64),(bits))) #elif __has_builtin (__builtin_rotateright64) #define _MHD_ROTR64(value64, bits) \ ((uint64_t) __builtin_rotateright64 ((value64), (bits))) #else /* ! __builtin_rotateright64 */ _MHD_static_inline uint64_t _MHD_ROTR64 (uint64_t value64, int bits) { bits %= 64; if (0 == bits) return value64; /* Defined in form which modern compiler could optimise. */ return (value64 >> bits) | (value64 << (64 - bits)); } #endif /* ! __builtin_rotateright64 */ MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ #ifdef _MHD_has_builtin_dummy /* Remove macro function replacement to avoid misdetection in files which * include this header */ # undef __has_builtin #endif #endif /* ! MHD_BITHELPERS_H */ libmicrohttpd-1.0.1/src/microhttpd/response.c0000644000175000017500000022724214556705750015033 /* This file is part of libmicrohttpd Copyright (C) 2007-2021 Daniel Pittman and Christian Grothoff Copyright (C) 2015-2023 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file response.c * @brief Methods for managing response objects * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #define MHD_NO_DEPRECATION 1 #include "mhd_options.h" #ifdef HAVE_SYS_IOCTL_H #include #endif /* HAVE_SYS_IOCTL_H */ #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif /* _WIN32 && !__CYGWIN__ */ #include "internal.h" #include "response.h" #include "mhd_limits.h" #include "mhd_sockets.h" #include "mhd_itc.h" #include "mhd_str.h" #include "connection.h" #include "memorypool.h" #include "mhd_send.h" #include "mhd_compat.h" #include "mhd_assert.h" #if defined(MHD_W32_MUTEX_) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif /* MHD_W32_MUTEX_ */ #if defined(_WIN32) #include /* for lseek(), read() */ #endif /* _WIN32 */ /** * Size of single file read operation for * file-backed responses. */ #ifndef MHD_FILE_READ_BLOCK_SIZE #ifdef _WIN32 #define MHD_FILE_READ_BLOCK_SIZE 16384 /* 16k */ #else /* _WIN32 */ #define MHD_FILE_READ_BLOCK_SIZE 4096 /* 4k */ #endif /* _WIN32 */ #endif /* !MHD_FD_BLOCK_SIZE */ /** * Insert a new header at the first position of the response */ #define _MHD_insert_header_first(presponse, phdr) do { \ mhd_assert (NULL == phdr->next); \ mhd_assert (NULL == phdr->prev); \ if (NULL == presponse->first_header) \ { \ mhd_assert (NULL == presponse->last_header); \ presponse->first_header = phdr; \ presponse->last_header = phdr; \ } \ else \ { \ mhd_assert (NULL != presponse->last_header); \ presponse->first_header->prev = phdr; \ phdr->next = presponse->first_header; \ presponse->first_header = phdr; \ } \ } while (0) /** * Insert a new header at the last position of the response */ #define _MHD_insert_header_last(presponse, phdr) do { \ mhd_assert (NULL == phdr->next); \ mhd_assert (NULL == phdr->prev); \ if (NULL == presponse->last_header) \ { \ mhd_assert (NULL == presponse->first_header); \ presponse->last_header = phdr; \ presponse->first_header = phdr; \ } \ else \ { \ mhd_assert (NULL != presponse->first_header); \ presponse->last_header->next = phdr; \ phdr->prev = presponse->last_header; \ presponse->last_header = phdr; \ } \ } while (0) /** * Remove a header from the response */ #define _MHD_remove_header(presponse, phdr) do { \ mhd_assert (NULL != presponse->first_header); \ mhd_assert (NULL != presponse->last_header); \ if (NULL == phdr->prev) \ { \ mhd_assert (phdr == presponse->first_header); \ presponse->first_header = phdr->next; \ } \ else \ { \ mhd_assert (phdr != presponse->first_header); \ mhd_assert (phdr == phdr->prev->next); \ phdr->prev->next = phdr->next; \ } \ if (NULL == phdr->next) \ { \ mhd_assert (phdr == presponse->last_header); \ presponse->last_header = phdr->prev; \ } \ else \ { \ mhd_assert (phdr != presponse->last_header); \ mhd_assert (phdr == phdr->next->prev); \ phdr->next->prev = phdr->prev; \ } \ } while (0) /** * Add preallocated strings a header or footer line to the response without * checking. * * Header/footer strings are not checked and assumed to be correct. * * The string must not be statically allocated! * The strings must be malloc()'ed and zero terminated. The strings will * be free()'ed when the response is destroyed. * * @param response response to add a header to * @param kind header or footer * @param header the header string to add, must be malloc()'ed and * zero-terminated * @param header_len the length of the @a header * @param content the value string to add, must be malloc()'ed and * zero-terminated * @param content_len the length of the @a content */ bool MHD_add_response_entry_no_alloc_ (struct MHD_Response *response, enum MHD_ValueKind kind, char *header, size_t header_len, char *content, size_t content_len) { struct MHD_HTTP_Res_Header *hdr; mhd_assert (0 != header_len); mhd_assert (0 != content_len); if (NULL == (hdr = MHD_calloc_ (1, sizeof (struct MHD_HTTP_Res_Header)))) return false; hdr->header = header; hdr->header_size = header_len; hdr->value = content; hdr->value_size = content_len; hdr->kind = kind; _MHD_insert_header_last (response, hdr); return true; /* Success exit point */ } /** * Add a header or footer line to the response without checking. * * It is assumed that parameters are correct. * * @param response response to add a header to * @param kind header or footer * @param header the header to add, does not need to be zero-terminated * @param header_len the length of the @a header * @param content value to add, does not need to be zero-terminated * @param content_len the length of the @a content * @return false on error (like out-of-memory), * true if succeed */ bool MHD_add_response_entry_no_check_ (struct MHD_Response *response, enum MHD_ValueKind kind, const char *header, size_t header_len, const char *content, size_t content_len) { char *header_malloced; char *value_malloced; mhd_assert (0 != header_len); mhd_assert (0 != content_len); header_malloced = malloc (header_len + 1); if (NULL == header_malloced) return false; memcpy (header_malloced, header, header_len); header_malloced[header_len] = 0; value_malloced = malloc (content_len + 1); if (NULL != value_malloced) { memcpy (value_malloced, content, content_len); value_malloced[content_len] = 0; if (MHD_add_response_entry_no_alloc_ (response, kind, header_malloced, header_len, value_malloced, content_len)) return true; /* Success exit point */ free (value_malloced); } free (header_malloced); return false; /* Failure exit point */ } /** * Add a header or footer line to the response. * * @param header the header to add, does not need to be zero-terminated * @param header_len the length of the @a header * @param content value to add, does not need to be zero-terminated * @param content_len the length of the @a content * @return false on error (out-of-memory, invalid header or content), * true if succeed */ static bool add_response_entry_n (struct MHD_Response *response, enum MHD_ValueKind kind, const char *header, size_t header_len, const char *content, size_t content_len) { if (NULL == response) return false; if (0 == header_len) return false; if (0 == content_len) return false; if (NULL != memchr (header, '\t', header_len)) return false; if (NULL != memchr (header, ' ', header_len)) return false; if (NULL != memchr (header, '\r', header_len)) return false; if (NULL != memchr (header, '\n', header_len)) return false; if (NULL != memchr (content, '\r', content_len)) return false; if (NULL != memchr (content, '\n', content_len)) return false; return MHD_add_response_entry_no_check_ (response, kind, header, header_len, content, content_len); } /** * Add a header or footer line to the response. * * @param response response to add a header to * @param kind header or footer * @param header the header to add * @param content value to add * @return #MHD_NO on error (i.e. invalid header or content format). */ static enum MHD_Result add_response_entry (struct MHD_Response *response, enum MHD_ValueKind kind, const char *header, const char *content) { size_t header_len; size_t content_len; if (NULL == content) return MHD_NO; header_len = strlen (header); content_len = strlen (content); return add_response_entry_n (response, kind, header, header_len, content, content_len) ? MHD_YES : MHD_NO; } /** * Add "Connection:" header to the response with special processing. * * "Connection:" header value will be combined with any existing "Connection:" * header, "close" token (if any) will be de-duplicated and moved to the first * position. * * @param response the response to add a header to * @param value the value to add * @return #MHD_NO on error (no memory). */ static enum MHD_Result add_response_header_connection (struct MHD_Response *response, const char *value) { static const char *key = MHD_HTTP_HEADER_CONNECTION; /** the length of the "Connection" key */ static const size_t key_len = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONNECTION); size_t value_len; /**< the length of the @a value */ size_t old_value_len; /**< the length of the existing "Connection" value */ size_t buf_size; /**< the size of the buffer */ size_t norm_len; /**< the length of the normalised value */ char *buf; /**< the temporal buffer */ struct MHD_HTTP_Res_Header *hdr; /**< existing "Connection" header */ bool value_has_close; /**< the @a value has "close" token */ bool already_has_close; /**< existing "Connection" header has "close" token */ size_t pos = 0; /**< position of addition in the @a buf */ if ( (NULL != strchr (value, '\r')) || (NULL != strchr (value, '\n')) ) return MHD_NO; if (0 != (response->flags_auto & MHD_RAF_HAS_CONNECTION_HDR)) { hdr = MHD_get_response_element_n_ (response, MHD_HEADER_KIND, key, key_len); already_has_close = (0 != (response->flags_auto & MHD_RAF_HAS_CONNECTION_CLOSE)); mhd_assert (already_has_close == (0 == memcmp (hdr->value, "close", 5))); mhd_assert (NULL != hdr); } else { hdr = NULL; already_has_close = false; mhd_assert (NULL == MHD_get_response_element_n_ (response, MHD_HEADER_KIND, key, key_len)); mhd_assert (0 == (response->flags_auto & MHD_RAF_HAS_CONNECTION_CLOSE)); } if (NULL != hdr) old_value_len = hdr->value_size + 2; /* additional size for ", " */ else old_value_len = 0; value_len = strlen (value); if (value_len >= SSIZE_MAX) return MHD_NO; /* Additional space for normalisation and zero-termination */ norm_len = value_len + value_len / 2 + 1; if (norm_len >= SSIZE_MAX) return MHD_NO; buf_size = old_value_len + (size_t) norm_len; buf = malloc (buf_size); if (NULL == buf) return MHD_NO; if (1) { /* local scope */ ssize_t norm_len_s = (ssize_t) norm_len; /* Remove "close" token (if any), it will be moved to the front */ value_has_close = MHD_str_remove_token_caseless_ (value, value_len, "close", MHD_STATICSTR_LEN_ ( \ "close"), buf + old_value_len, &norm_len_s); mhd_assert (0 <= norm_len_s); if (0 > norm_len_s) { /* Must never happen with realistic sizes */ free (buf); return MHD_NO; } else norm_len = (size_t) norm_len_s; } #ifdef UPGRADE_SUPPORT if ( (NULL != response->upgrade_handler) && value_has_close) { /* The "close" token cannot be used with connection "upgrade" */ free (buf); return MHD_NO; } #endif /* UPGRADE_SUPPORT */ if (0 != norm_len) MHD_str_remove_tokens_caseless_ (buf + old_value_len, &norm_len, "keep-alive", MHD_STATICSTR_LEN_ ("keep-alive")); if (0 == norm_len) { /* New value is empty after normalisation */ if (! value_has_close) { /* The new value had no tokens */ free (buf); return MHD_NO; } if (already_has_close) { /* The "close" token is already present, nothing to modify */ free (buf); return MHD_YES; } } /* Add "close" token if required */ if (value_has_close && ! already_has_close) { /* Need to insert "close" token at the first position */ mhd_assert (buf_size >= old_value_len + norm_len \ + MHD_STATICSTR_LEN_ ("close, ") + 1); if (0 != norm_len) memmove (buf + MHD_STATICSTR_LEN_ ("close, ") + old_value_len, buf + old_value_len, norm_len + 1); memcpy (buf, "close", MHD_STATICSTR_LEN_ ("close")); pos += MHD_STATICSTR_LEN_ ("close"); } /* Add old value tokens (if any) */ if (0 != old_value_len) { if (0 != pos) { buf[pos++] = ','; buf[pos++] = ' '; } memcpy (buf + pos, hdr->value, hdr->value_size); pos += hdr->value_size; } /* Add new value token (if any) */ if (0 != norm_len) { if (0 != pos) { buf[pos++] = ','; buf[pos++] = ' '; } /* The new value tokens must be already at the correct position */ mhd_assert ((value_has_close && ! already_has_close) ? \ (MHD_STATICSTR_LEN_ ("close, ") + old_value_len == pos) : \ (old_value_len == pos)); pos += norm_len; } mhd_assert (buf_size > pos); buf[pos] = 0; /* Null terminate the result */ if (NULL == hdr) { struct MHD_HTTP_Res_Header *new_hdr; /**< new "Connection" header */ /* Create new response header entry */ new_hdr = MHD_calloc_ (1, sizeof (struct MHD_HTTP_Res_Header)); if (NULL != new_hdr) { new_hdr->header = malloc (key_len + 1); if (NULL != new_hdr->header) { memcpy (new_hdr->header, key, key_len + 1); new_hdr->header_size = key_len; new_hdr->value = buf; new_hdr->value_size = pos; new_hdr->kind = MHD_HEADER_KIND; if (value_has_close) response->flags_auto = (MHD_RAF_HAS_CONNECTION_HDR | MHD_RAF_HAS_CONNECTION_CLOSE); else response->flags_auto = MHD_RAF_HAS_CONNECTION_HDR; _MHD_insert_header_first (response, new_hdr); return MHD_YES; } free (new_hdr); } free (buf); return MHD_NO; } /* Update existing header entry */ free (hdr->value); hdr->value = buf; hdr->value_size = pos; if (value_has_close && ! already_has_close) response->flags_auto |= MHD_RAF_HAS_CONNECTION_CLOSE; return MHD_YES; } /** * Remove tokens from "Connection:" header of the response. * * Provided tokens will be removed from "Connection:" header value. * * @param response the response to manipulate "Connection:" header * @param value the tokens to remove * @return #MHD_NO on error (no headers or tokens found). */ static enum MHD_Result del_response_header_connection (struct MHD_Response *response, const char *value) { struct MHD_HTTP_Res_Header *hdr; /**< existing "Connection" header */ hdr = MHD_get_response_element_n_ (response, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONNECTION, MHD_STATICSTR_LEN_ ( \ MHD_HTTP_HEADER_CONNECTION)); if (NULL == hdr) return MHD_NO; if (! MHD_str_remove_tokens_caseless_ (hdr->value, &hdr->value_size, value, strlen (value))) return MHD_NO; if (0 == hdr->value_size) { _MHD_remove_header (response, hdr); free (hdr->value); free (hdr->header); free (hdr); response->flags_auto &= ~((enum MHD_ResponseAutoFlags) MHD_RAF_HAS_CONNECTION_HDR | (enum MHD_ResponseAutoFlags) MHD_RAF_HAS_CONNECTION_CLOSE); } else { hdr->value[hdr->value_size] = 0; /* Null-terminate the result */ if (0 != (response->flags_auto & ~((enum MHD_ResponseAutoFlags) MHD_RAF_HAS_CONNECTION_CLOSE))) { if (MHD_STATICSTR_LEN_ ("close") == hdr->value_size) { if (0 != memcmp (hdr->value, "close", MHD_STATICSTR_LEN_ ("close"))) response->flags_auto &= ~((enum MHD_ResponseAutoFlags) MHD_RAF_HAS_CONNECTION_CLOSE); } else if (MHD_STATICSTR_LEN_ ("close, ") < hdr->value_size) { if (0 != memcmp (hdr->value, "close, ", MHD_STATICSTR_LEN_ ("close, "))) response->flags_auto &= ~((enum MHD_ResponseAutoFlags) MHD_RAF_HAS_CONNECTION_CLOSE); } else response->flags_auto &= ~((enum MHD_ResponseAutoFlags) MHD_RAF_HAS_CONNECTION_CLOSE); } } return MHD_YES; } /** * Add a header line to the response. * * When reply is generated with queued response, some headers are generated * automatically. Automatically generated headers are only sent to the client, * but not added back to the response object. * * The list of automatic headers: * + "Date" header is added automatically unless already set by * this function * @see #MHD_USE_SUPPRESS_DATE_NO_CLOCK * + "Content-Length" is added automatically when required, attempt to set * it manually by this function is ignored. * @see #MHD_RF_INSANITY_HEADER_CONTENT_LENGTH * + "Transfer-Encoding" with value "chunked" is added automatically, * when chunked transfer encoding is used automatically. Same header with * the same value can be set manually by this function to enforce chunked * encoding, however for HTTP/1.0 clients chunked encoding will not be used * and manually set "Transfer-Encoding" header is automatically removed * for HTTP/1.0 clients * + "Connection" may be added automatically with value "Keep-Alive" (only * for HTTP/1.0 clients) or "Close". The header "Connection" with value * "Close" could be set by this function to enforce closure of * the connection after sending this response. "Keep-Alive" cannot be * enforced and will be removed automatically. * @see #MHD_RF_SEND_KEEP_ALIVE_HEADER * * Some headers are pre-processed by this function: * * "Connection" headers are combined into single header entry, value is * normilised, "Keep-Alive" tokens are removed. * * "Transfer-Encoding" header: the only one header is allowed, the only * allowed value is "chunked". * * "Date" header: the only one header is allowed, the second added header * replaces the first one. * * "Content-Length" application-defined header is not allowed. * @see #MHD_RF_INSANITY_HEADER_CONTENT_LENGTH * * Headers are used in order as they were added. * * @param response the response to add a header to * @param header the header name to add, no need to be static, an internal copy * will be created automatically * @param content the header value to add, no need to be static, an internal * copy will be created automatically * @return #MHD_YES on success, * #MHD_NO on error (i.e. invalid header or content format), * or out of memory * @ingroup response */ _MHD_EXTERN enum MHD_Result MHD_add_response_header (struct MHD_Response *response, const char *header, const char *content) { if (MHD_str_equal_caseless_ (header, MHD_HTTP_HEADER_CONNECTION)) return add_response_header_connection (response, content); if (MHD_str_equal_caseless_ (header, MHD_HTTP_HEADER_TRANSFER_ENCODING)) { if (! MHD_str_equal_caseless_ (content, "chunked")) return MHD_NO; /* Only "chunked" encoding is allowed */ if (0 != (response->flags_auto & MHD_RAF_HAS_TRANS_ENC_CHUNKED)) return MHD_YES; /* Already has "chunked" encoding header */ if ( (0 != (response->flags_auto & MHD_RAF_HAS_CONTENT_LENGTH)) && (0 == (MHD_RF_INSANITY_HEADER_CONTENT_LENGTH & response->flags)) ) return MHD_NO; /* Has "Content-Length" header and no "Insanity" flag */ if (MHD_NO != add_response_entry (response, MHD_HEADER_KIND, header, content)) { response->flags_auto |= MHD_RAF_HAS_TRANS_ENC_CHUNKED; return MHD_YES; } return MHD_NO; } if (MHD_str_equal_caseless_ (header, MHD_HTTP_HEADER_DATE)) { if (0 != (response->flags_auto & MHD_RAF_HAS_DATE_HDR)) { struct MHD_HTTP_Res_Header *hdr; hdr = MHD_get_response_element_n_ (response, MHD_HEADER_KIND, MHD_HTTP_HEADER_DATE, MHD_STATICSTR_LEN_ ( \ MHD_HTTP_HEADER_DATE)); mhd_assert (NULL != hdr); _MHD_remove_header (response, hdr); if (NULL != hdr->value) free (hdr->value); free (hdr->header); free (hdr); } if (MHD_NO != add_response_entry (response, MHD_HEADER_KIND, header, content)) { response->flags_auto |= MHD_RAF_HAS_DATE_HDR; return MHD_YES; } return MHD_NO; } if (MHD_str_equal_caseless_ (header, MHD_HTTP_HEADER_CONTENT_LENGTH)) { /* Generally MHD sets automatically correct "Content-Length" always when * needed. * Custom "Content-Length" header is allowed only in special cases. */ if ( (0 != (MHD_RF_INSANITY_HEADER_CONTENT_LENGTH & response->flags)) || ((0 != (MHD_RF_HEAD_ONLY_RESPONSE & response->flags)) && (0 == (response->flags_auto & (MHD_RAF_HAS_TRANS_ENC_CHUNKED | MHD_RAF_HAS_CONTENT_LENGTH)))) ) { if (MHD_NO != add_response_entry (response, MHD_HEADER_KIND, header, content)) { response->flags_auto |= MHD_RAF_HAS_CONTENT_LENGTH; return MHD_YES; } } return MHD_NO; } return add_response_entry (response, MHD_HEADER_KIND, header, content); } /** * Add a footer line to the response. * * @param response response to remove a header from * @param footer the footer to delete * @param content value to delete * @return #MHD_NO on error (i.e. invalid footer or content format). * @ingroup response */ _MHD_EXTERN enum MHD_Result MHD_add_response_footer (struct MHD_Response *response, const char *footer, const char *content) { return add_response_entry (response, MHD_FOOTER_KIND, footer, content); } /** * Delete a header (or footer) line from the response. * * For "Connection" headers this function remove all tokens from existing * value. Successful result means that at least one token has been removed. * If all tokens are removed from "Connection" header, the empty "Connection" * header removed. * * @param response response to remove a header from * @param header the header to delete * @param content value to delete * @return #MHD_NO on error (no such header known) * @ingroup response */ _MHD_EXTERN enum MHD_Result MHD_del_response_header (struct MHD_Response *response, const char *header, const char *content) { struct MHD_HTTP_Res_Header *pos; size_t header_len; size_t content_len; if ( (NULL == header) || (NULL == content) ) return MHD_NO; header_len = strlen (header); if ((0 != (response->flags_auto & MHD_RAF_HAS_CONNECTION_HDR)) && (MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONNECTION) == header_len) && MHD_str_equal_caseless_bin_n_ (header, MHD_HTTP_HEADER_CONNECTION, header_len)) return del_response_header_connection (response, content); content_len = strlen (content); pos = response->first_header; while (NULL != pos) { if ((header_len == pos->header_size) && (content_len == pos->value_size) && (0 == memcmp (header, pos->header, header_len)) && (0 == memcmp (content, pos->value, content_len))) { _MHD_remove_header (response, pos); free (pos->header); free (pos->value); free (pos); if ( (MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_TRANSFER_ENCODING) == header_len) && MHD_str_equal_caseless_bin_n_ (header, MHD_HTTP_HEADER_TRANSFER_ENCODING, header_len) ) response->flags_auto &= ~((enum MHD_ResponseAutoFlags) MHD_RAF_HAS_TRANS_ENC_CHUNKED); else if ( (MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_DATE) == header_len) && MHD_str_equal_caseless_bin_n_ (header, MHD_HTTP_HEADER_DATE, header_len) ) response->flags_auto &= ~((enum MHD_ResponseAutoFlags) MHD_RAF_HAS_DATE_HDR); else if ( (MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH) == header_len) && MHD_str_equal_caseless_bin_n_ (header, MHD_HTTP_HEADER_CONTENT_LENGTH, header_len) ) { if (NULL == MHD_get_response_element_n_ (response, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_LENGTH, header_len)) response->flags_auto &= ~((enum MHD_ResponseAutoFlags) MHD_RAF_HAS_CONTENT_LENGTH); } return MHD_YES; } pos = pos->next; } return MHD_NO; } /** * Get all of the headers (and footers) added to a response. * * @param response response to query * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator * @return number of entries iterated over * @ingroup response */ _MHD_EXTERN int MHD_get_response_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls) { int numHeaders = 0; struct MHD_HTTP_Res_Header *pos; for (pos = response->first_header; NULL != pos; pos = pos->next) { numHeaders++; if ((NULL != iterator) && (MHD_NO == iterator (iterator_cls, pos->kind, pos->header, pos->value))) break; } return numHeaders; } /** * Get a particular header (or footer) from the response. * * @param response response to query * @param key which header to get * @return NULL if header does not exist * @ingroup response */ _MHD_EXTERN const char * MHD_get_response_header (struct MHD_Response *response, const char *key) { struct MHD_HTTP_Res_Header *pos; size_t key_size; if (NULL == key) return NULL; key_size = strlen (key); for (pos = response->first_header; NULL != pos; pos = pos->next) { if ((pos->header_size == key_size) && (MHD_str_equal_caseless_bin_n_ (pos->header, key, pos->header_size))) return pos->value; } return NULL; } /** * Get a particular header (or footer) element from the response. * * Function returns the first found element. * @param response response to query * @param kind the kind of element: header or footer * @param key the key which header to get * @param key_len the length of the @a key * @return NULL if header element does not exist * @ingroup response */ struct MHD_HTTP_Res_Header * MHD_get_response_element_n_ (struct MHD_Response *response, enum MHD_ValueKind kind, const char *key, size_t key_len) { struct MHD_HTTP_Res_Header *pos; mhd_assert (NULL != key); mhd_assert (0 != key[0]); mhd_assert (0 != key_len); for (pos = response->first_header; NULL != pos; pos = pos->next) { if ((pos->header_size == key_len) && (kind == pos->kind) && (MHD_str_equal_caseless_bin_n_ (pos->header, key, pos->header_size))) return pos; } return NULL; } /** * Check whether response header contains particular token. * * Token could be surrounded by spaces and tabs and delimited by comma. * Case-insensitive match used for header names and tokens. * * @param response the response to query * @param key header name * @param key_len the length of @a key, not including optional * terminating null-character. * @param token the token to find * @param token_len the length of @a token, not including optional * terminating null-character. * @return true if token is found in specified header, * false otherwise */ bool MHD_check_response_header_token_ci (const struct MHD_Response *response, const char *key, size_t key_len, const char *token, size_t token_len) { struct MHD_HTTP_Res_Header *pos; if ( (NULL == key) || ('\0' == key[0]) || (NULL == token) || ('\0' == token[0]) ) return false; /* Token must not contain binary zero! */ mhd_assert (strlen (token) == token_len); for (pos = response->first_header; NULL != pos; pos = pos->next) { if ( (pos->kind == MHD_HEADER_KIND) && (key_len == pos->header_size) && MHD_str_equal_caseless_bin_n_ (pos->header, key, key_len) && MHD_str_has_token_caseless_ (pos->value, token, token_len) ) return true; } return false; } /** * Create a response object. * The response object can be extended with header information and then be used * any number of times. * * If response object is used to answer HEAD request then the body of the * response is not used, while all headers (including automatic headers) are * used. * * @param size size of the data portion of the response, #MHD_SIZE_UNKNOWN for unknown * @param block_size preferred block size for querying crc (advisory only, * MHD may still call @a crc using smaller chunks); this * is essentially the buffer size used for IO, clients * should pick a value that is appropriate for IO and * memory performance requirements * @param crc callback to use to obtain response data * @param crc_cls extra argument to @a crc * @param crfc callback to call to free @a crc_cls resources * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_callback (uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc) { struct MHD_Response *response; if ((NULL == crc) || (0 == block_size)) return NULL; if (NULL == (response = MHD_calloc_ (1, sizeof (struct MHD_Response) + block_size))) return NULL; response->fd = -1; response->data = (void *) &response[1]; response->data_buffer_size = block_size; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (! MHD_mutex_init_ (&response->mutex)) { free (response); return NULL; } #endif response->crc = crc; response->crfc = crfc; response->crc_cls = crc_cls; response->reference_count = 1; response->total_size = size; return response; } /** * Set special flags and options for a response. * * @param response the response to modify * @param flags to set for the response * @param ... #MHD_RO_END terminated list of options * @return #MHD_YES on success, #MHD_NO on error */ _MHD_EXTERN enum MHD_Result MHD_set_response_options (struct MHD_Response *response, enum MHD_ResponseFlags flags, ...) { va_list ap; enum MHD_Result ret; enum MHD_ResponseOptions ro; if (0 != (response->flags_auto & MHD_RAF_HAS_CONTENT_LENGTH)) { /* Response has custom "Content-Lengh" header */ if ( (0 != (response->flags & MHD_RF_INSANITY_HEADER_CONTENT_LENGTH)) && (0 == (flags & MHD_RF_INSANITY_HEADER_CONTENT_LENGTH))) { /* Request to remove MHD_RF_INSANITY_HEADER_CONTENT_LENGTH flag */ return MHD_NO; } if ( (0 != (response->flags & MHD_RF_HEAD_ONLY_RESPONSE)) && (0 == (flags & MHD_RF_HEAD_ONLY_RESPONSE))) { /* Request to remove MHD_RF_HEAD_ONLY_RESPONSE flag */ if (0 == (flags & MHD_RF_INSANITY_HEADER_CONTENT_LENGTH)) return MHD_NO; } } if ( (0 != (flags & MHD_RF_HEAD_ONLY_RESPONSE)) && (0 != response->total_size) ) return MHD_NO; ret = MHD_YES; response->flags = flags; va_start (ap, flags); while (MHD_RO_END != (ro = va_arg (ap, enum MHD_ResponseOptions))) { switch (ro) { case MHD_RO_END: /* Not possible */ break; default: ret = MHD_NO; break; } } va_end (ap); return ret; } /** * Given a file descriptor, read data from the file * to generate the response. * * @param cls pointer to the response * @param pos offset in the file to access * @param buf where to write the data * @param max number of bytes to write at most * @return number of bytes written */ static ssize_t file_reader (void *cls, uint64_t pos, char *buf, size_t max) { struct MHD_Response *response = cls; #if ! defined(_WIN32) || defined(__CYGWIN__) ssize_t n; #else /* _WIN32 && !__CYGWIN__ */ const HANDLE fh = (HANDLE) (uintptr_t) _get_osfhandle (response->fd); #endif /* _WIN32 && !__CYGWIN__ */ const int64_t offset64 = (int64_t) (pos + response->fd_off); if (offset64 < 0) return MHD_CONTENT_READER_END_WITH_ERROR; /* seek to required position is not possible */ #if ! defined(_WIN32) || defined(__CYGWIN__) if (max > SSIZE_MAX) max = SSIZE_MAX; /* Clamp to maximum return value. */ #if defined(HAVE_PREAD64) n = pread64 (response->fd, buf, max, offset64); #elif defined(HAVE_PREAD) if ( (sizeof(off_t) < sizeof (uint64_t)) && (offset64 > (uint64_t) INT32_MAX) ) return MHD_CONTENT_READER_END_WITH_ERROR; /* Read at required position is not possible. */ n = pread (response->fd, buf, max, (off_t) offset64); #else /* ! HAVE_PREAD */ #if defined(HAVE_LSEEK64) if (lseek64 (response->fd, offset64, SEEK_SET) != offset64) return MHD_CONTENT_READER_END_WITH_ERROR; /* can't seek to required position */ #else /* ! HAVE_LSEEK64 */ if ( (sizeof(off_t) < sizeof (uint64_t)) && (offset64 > (uint64_t) INT32_MAX) ) return MHD_CONTENT_READER_END_WITH_ERROR; /* seek to required position is not possible */ if (lseek (response->fd, (off_t) offset64, SEEK_SET) != (off_t) offset64) return MHD_CONTENT_READER_END_WITH_ERROR; /* can't seek to required position */ #endif /* ! HAVE_LSEEK64 */ n = read (response->fd, buf, max); #endif /* ! HAVE_PREAD */ if (0 == n) return MHD_CONTENT_READER_END_OF_STREAM; if (n < 0) return MHD_CONTENT_READER_END_WITH_ERROR; return n; #else /* _WIN32 && !__CYGWIN__ */ if (INVALID_HANDLE_VALUE == fh) return MHD_CONTENT_READER_END_WITH_ERROR; /* Value of 'response->fd' is not valid. */ else { OVERLAPPED f_ol = {0, 0, {{0, 0}}, 0}; /* Initialize to zero. */ ULARGE_INTEGER pos_uli; DWORD toRead = (max > INT32_MAX) ? INT32_MAX : (DWORD) max; DWORD resRead; pos_uli.QuadPart = (uint64_t) offset64; /* Simple transformation 64bit -> 2x32bit. */ f_ol.Offset = pos_uli.LowPart; f_ol.OffsetHigh = pos_uli.HighPart; if (! ReadFile (fh, (void *) buf, toRead, &resRead, &f_ol)) return MHD_CONTENT_READER_END_WITH_ERROR; /* Read error. */ if (0 == resRead) return MHD_CONTENT_READER_END_OF_STREAM; return (ssize_t) resRead; } #endif /* _WIN32 && !__CYGWIN__ */ } /** * Given a pipe descriptor, read data from the pipe * to generate the response. * * @param cls pointer to the response * @param pos offset in the pipe to access (ignored) * @param buf where to write the data * @param max number of bytes to write at most * @return number of bytes written */ static ssize_t pipe_reader (void *cls, uint64_t pos, char *buf, size_t max) { struct MHD_Response *response = cls; ssize_t n; (void) pos; #ifndef _WIN32 if (SSIZE_MAX < max) max = SSIZE_MAX; n = read (response->fd, buf, (MHD_SCKT_SEND_SIZE_) max); #else /* _WIN32 */ if (UINT_MAX < max) max = INT_MAX; n = read (response->fd, buf, (unsigned int) max); #endif /* _WIN32 */ if (0 == n) return MHD_CONTENT_READER_END_OF_STREAM; if (n < 0) return MHD_CONTENT_READER_END_WITH_ERROR; return n; } /** * Destroy file reader context. Closes the file * descriptor. * * @param cls pointer to file descriptor */ static void free_callback (void *cls) { struct MHD_Response *response = cls; (void) close (response->fd); response->fd = -1; } #undef MHD_create_response_from_fd_at_offset /** * Create a response object with the content of provided file with * specified offset used as the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response * @param fd file descriptor referring to a file on disk with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @param offset offset to start reading from in the file; * Be careful! `off_t` may have been compiled to be a * 64-bit variable for MHD, in which case your application * also has to be compiled using the same options! Read * the MHD manual for more details. * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd_at_offset (size_t size, int fd, off_t offset) { if (0 > offset) return NULL; return MHD_create_response_from_fd_at_offset64 (size, fd, (uint64_t) offset); } /** * Create a response object with the content of provided file with * specified offset used as the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response; * sizes larger than 2 GiB may be not supported by OS or * MHD build; see ::MHD_FEATURE_LARGE_FILE * @param fd file descriptor referring to a file on disk with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @param offset offset to start reading from in the file; * reading file beyond 2 GiB may be not supported by OS or * MHD build; see ::MHD_FEATURE_LARGE_FILE * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd_at_offset64 (uint64_t size, int fd, uint64_t offset) { struct MHD_Response *response; #if ! defined(HAVE___LSEEKI64) && ! defined(HAVE_LSEEK64) if ( (sizeof(uint64_t) > sizeof(off_t)) && ( (size > (uint64_t) INT32_MAX) || (offset > (uint64_t) INT32_MAX) || ((size + offset) >= (uint64_t) INT32_MAX) ) ) return NULL; #endif if ( ((int64_t) size < 0) || ((int64_t) offset < 0) || ((int64_t) (size + offset) < 0) ) return NULL; response = MHD_create_response_from_callback (size, MHD_FILE_READ_BLOCK_SIZE, &file_reader, NULL, &free_callback); if (NULL == response) return NULL; response->fd = fd; response->is_pipe = false; response->fd_off = offset; response->crc_cls = response; return response; } /** * Create a response object with the response body created by reading * the provided pipe. * * The response object can be extended with header information and * then be used ONLY ONCE. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param fd file descriptor referring to a read-end of a pipe with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_pipe (int fd) { struct MHD_Response *response; response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, MHD_FILE_READ_BLOCK_SIZE, &pipe_reader, NULL, &free_callback); if (NULL == response) return NULL; response->fd = fd; response->is_pipe = true; response->crc_cls = response; return response; } /** * Create a response object with the content of provided file used as * the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response * @param fd file descriptor referring to a file on disk with the data * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd (size_t size, int fd) { return MHD_create_response_from_fd_at_offset64 (size, fd, 0); } /** * Create a response object with the content of provided file used as * the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response; * sizes larger than 2 GiB may be not supported by OS or * MHD build; see ::MHD_FEATURE_LARGE_FILE * @param fd file descriptor referring to a file on disk with the * data; will be closed when response is destroyed; * fd should be in 'blocking' mode * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd64 (uint64_t size, int fd) { return MHD_create_response_from_fd_at_offset64 (size, fd, 0); } /** * Create a response object. * The response object can be extended with header information and then be used * any number of times. * * If response object is used to answer HEAD request then the body of the * response is not used, while all headers (including automatic headers) are * used. * * @param size size of the @a data portion of the response * @param data the data itself * @param must_free libmicrohttpd should free data when done * @param must_copy libmicrohttpd must make a copy of @a data * right away, the data may be released anytime after * this call returns * @return NULL on error (i.e. invalid arguments, out of memory) * @deprecated use #MHD_create_response_from_buffer instead * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy) { enum MHD_ResponseMemoryMode mode; if (0 != must_copy) mode = MHD_RESPMEM_MUST_COPY; else if (0 != must_free) mode = MHD_RESPMEM_MUST_FREE; else mode = MHD_RESPMEM_PERSISTENT; return MHD_create_response_from_buffer (size, data, mode); } /** * Create a response object with the content of provided buffer used as * the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response * @param buffer size bytes containing the response's data portion * @param mode flags for buffer management * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer (size_t size, void *buffer, enum MHD_ResponseMemoryMode mode) { if (MHD_RESPMEM_MUST_FREE == mode) return MHD_create_response_from_buffer_with_free_callback_cls (size, buffer, &free, buffer); if (MHD_RESPMEM_MUST_COPY == mode) return MHD_create_response_from_buffer_copy (size, buffer); return MHD_create_response_from_buffer_with_free_callback_cls (size, buffer, NULL, NULL); } /** * Create a response object with the content of provided statically allocated * buffer used as the response body. * * The buffer must be valid for the lifetime of the response. The easiest way * to achieve this is to use a statically allocated buffer. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size the size of the data in @a buffer, can be zero * @param buffer the buffer with the data for the response body, can be NULL * if @a size is zero * @return NULL on error (i.e. invalid arguments, out of memory) * @note Available since #MHD_VERSION 0x00097701 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer_static (size_t size, const void *buffer) { return MHD_create_response_from_buffer_with_free_callback_cls (size, buffer, NULL, NULL); } /** * Create a response object with the content of provided temporal buffer * used as the response body. * * An internal copy of the buffer will be made automatically, so buffer have * to be valid only during the call of this function (as a typical example: * buffer is a local (non-static) array). * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size the size of the data in @a buffer, can be zero * @param buffer the buffer with the data for the response body, can be NULL * if @a size is zero * @return NULL on error (i.e. invalid arguments, out of memory) * @note Available since #MHD_VERSION 0x00097701 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer_copy (size_t size, const void *buffer) { struct MHD_Response *r; void *mhd_copy; if (0 == size) return MHD_create_response_from_buffer_with_free_callback_cls (0, NULL, NULL, NULL); if (NULL == buffer) return NULL; mhd_copy = malloc (size); if (NULL == mhd_copy) return NULL; memcpy (mhd_copy, buffer, size); r = MHD_create_response_from_buffer_with_free_callback_cls (size, mhd_copy, &free, mhd_copy); if (NULL == r) free (mhd_copy); else { /* TODO: remove the next assignment, the buffer should not be modifiable */ r->data_buffer_size = size; } return r; } /** * Create a response object with the content of provided buffer used as * the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response * @param buffer size bytes containing the response's data portion * @param crfc function to call to free the @a buffer * @return NULL on error (i.e. invalid arguments, out of memory) * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer_with_free_callback (size_t size, void *buffer, MHD_ContentReaderFreeCallback crfc) { return MHD_create_response_from_buffer_with_free_callback_cls (size, buffer, crfc, buffer); } /** * Create a response object with the content of provided buffer used as * the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param size size of the data portion of the response * @param buffer size bytes containing the response's data portion * @param crfc function to call to cleanup, if set to NULL then callback * is not called * @param crfc_cls an argument for @a crfc * @return NULL on error (i.e. invalid arguments, out of memory) * @note Available since #MHD_VERSION 0x00097302 * @note 'const' qualifier is used for @a buffer since #MHD_VERSION 0x00097701 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer_with_free_callback_cls (size_t size, const void *buffer, MHD_ContentReaderFreeCallback crfc, void *crfc_cls) { struct MHD_Response *r; if ((NULL == buffer) && (size > 0)) return NULL; #if SIZEOF_SIZE_T >= SIZEOF_UINT64_T if (MHD_SIZE_UNKNOWN == size) return NULL; #endif /* SIZEOF_SIZE_T >= SIZEOF_UINT64_T */ r = MHD_calloc_ (1, sizeof (struct MHD_Response)); if (NULL == r) return NULL; #if defined(MHD_USE_THREADS) if (! MHD_mutex_init_ (&r->mutex)) { free (r); return NULL; } #endif r->fd = -1; r->reference_count = 1; r->total_size = size; r->data = buffer; r->data_size = size; r->crfc = crfc; r->crc_cls = crfc_cls; return r; } /** * Create a response object with an array of memory buffers * used as the response body. * * The response object can be extended with header information and then * be used any number of times. * * If response object is used to answer HEAD request then the body * of the response is not used, while all headers (including automatic * headers) are used. * * @param iov the array for response data buffers, an internal copy of this * will be made * @param iovcnt the number of elements in @a iov * @param free_cb the callback to clean up any data associated with @a iov when * the response is destroyed. * @param cls the argument passed to @a free_cb * @return NULL on error (i.e. invalid arguments, out of memory) */ _MHD_EXTERN struct MHD_Response * MHD_create_response_from_iovec (const struct MHD_IoVec *iov, unsigned int iovcnt, MHD_ContentReaderFreeCallback free_cb, void *cls) { struct MHD_Response *response; unsigned int i; int i_cp = 0; /**< Index in the copy of iov */ uint64_t total_size = 0; const void *last_valid_buffer = NULL; if ((NULL == iov) && (0 < iovcnt)) return NULL; response = MHD_calloc_ (1, sizeof (struct MHD_Response)); if (NULL == response) return NULL; if (! MHD_mutex_init_ (&response->mutex)) { free (response); return NULL; } /* Calculate final size, number of valid elements, and check 'iov' */ for (i = 0; i < iovcnt; ++i) { if (0 == iov[i].iov_len) continue; /* skip zero-sized elements */ if (NULL == iov[i].iov_base) { i_cp = -1; /* error */ break; } if ( (total_size > (total_size + iov[i].iov_len)) || (INT_MAX == i_cp) || (SSIZE_MAX < (total_size + iov[i].iov_len)) ) { i_cp = -1; /* overflow */ break; } last_valid_buffer = iov[i].iov_base; total_size += iov[i].iov_len; #if defined(MHD_POSIX_SOCKETS) || ! defined(_WIN64) i_cp++; #else /* ! MHD_POSIX_SOCKETS && _WIN64 */ { int64_t i_add; i_add = (int64_t) (iov[i].iov_len / ULONG_MAX); if (0 != iov[i].iov_len % ULONG_MAX) i_add++; if (INT_MAX < (i_add + i_cp)) { i_cp = -1; /* overflow */ break; } i_cp += (int) i_add; } #endif /* ! MHD_POSIX_SOCKETS && _WIN64 */ } if (-1 == i_cp) { /* Some error condition */ MHD_mutex_destroy_chk_ (&response->mutex); free (response); return NULL; } response->fd = -1; response->reference_count = 1; response->total_size = total_size; response->crc_cls = cls; response->crfc = free_cb; if (0 == i_cp) { mhd_assert (0 == total_size); return response; } if (1 == i_cp) { mhd_assert (NULL != last_valid_buffer); response->data = last_valid_buffer; response->data_size = (size_t) total_size; return response; } mhd_assert (1 < i_cp); if (1) { /* for local variables local scope only */ MHD_iovec_ *iov_copy; int num_copy_elements = i_cp; iov_copy = MHD_calloc_ ((size_t) num_copy_elements, \ sizeof(MHD_iovec_)); if (NULL == iov_copy) { MHD_mutex_destroy_chk_ (&response->mutex); free (response); return NULL; } i_cp = 0; for (i = 0; i < iovcnt; ++i) { size_t element_size = iov[i].iov_len; const uint8_t *buf = (const uint8_t *) iov[i].iov_base; if (0 == element_size) continue; /* skip zero-sized elements */ #if defined(MHD_WINSOCK_SOCKETS) && defined(_WIN64) while (MHD_IOV_ELMN_MAX_SIZE < element_size) { iov_copy[i_cp].iov_base = (char *) _MHD_DROP_CONST (buf); iov_copy[i_cp].iov_len = ULONG_MAX; buf += ULONG_MAX; element_size -= ULONG_MAX; i_cp++; } #endif /* MHD_WINSOCK_SOCKETS && _WIN64 */ iov_copy[i_cp].iov_base = _MHD_DROP_CONST (buf); iov_copy[i_cp].iov_len = (MHD_iov_size_) element_size; i_cp++; } mhd_assert (num_copy_elements == i_cp); mhd_assert (0 <= i_cp); response->data_iov = iov_copy; response->data_iovcnt = (unsigned int) i_cp; } return response; } /** * Create a response object with empty (zero size) body. * * The response object can be extended with header information and then be used * any number of times. * * This function is a faster equivalent of #MHD_create_response_from_buffer call * with zero size combined with call of #MHD_set_response_options. * * @param flags the flags for the new response object * @return NULL on error (i.e. invalid arguments, out of memory), * the pointer to the created response object otherwise * @note Available since #MHD_VERSION 0x00097701 * @ingroup response */ _MHD_EXTERN struct MHD_Response * MHD_create_response_empty (enum MHD_ResponseFlags flags) { struct MHD_Response *r; r = (struct MHD_Response *) MHD_calloc_ (1, sizeof (struct MHD_Response)); if (NULL != r) { if (MHD_mutex_init_ (&r->mutex)) { r->fd = -1; r->reference_count = 1; /* If any flags combination will be not allowed, replace the next * assignment with MHD_set_response_options() call. */ r->flags = flags; return r; /* Successful result */ } free (r); } return NULL; /* Something failed */ } #ifdef UPGRADE_SUPPORT /** * This connection-specific callback is provided by MHD to * applications (unusual) during the #MHD_UpgradeHandler. * It allows applications to perform 'special' actions on * the underlying socket from the upgrade. * * @param urh the handle identifying the connection to perform * the upgrade @a action on. * @param action which action should be performed * @param ... arguments to the action (depends on the action) * @return #MHD_NO on error, #MHD_YES on success */ _MHD_EXTERN enum MHD_Result MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, enum MHD_UpgradeAction action, ...) { struct MHD_Connection *connection; struct MHD_Daemon *daemon; if (NULL == urh) return MHD_NO; connection = urh->connection; /* Precaution checks on external data. */ if (NULL == connection) return MHD_NO; daemon = connection->daemon; if (NULL == daemon) return MHD_NO; switch (action) { case MHD_UPGRADE_ACTION_CLOSE: if (urh->was_closed) return MHD_NO; /* Already closed. */ /* transition to special 'closed' state for start of cleanup */ #ifdef HTTPS_SUPPORT if (0 != (daemon->options & MHD_USE_TLS) ) { /* signal that app is done by shutdown() of 'app' socket */ /* Application will not use anyway this socket after this command. */ shutdown (urh->app.socket, SHUT_RDWR); } #endif /* HTTPS_SUPPORT */ mhd_assert (MHD_CONNECTION_UPGRADE == connection->state); /* The next function will mark the connection as closed by application * by setting 'urh->was_closed'. * As soon as connection will be marked with BOTH * 'urh->was_closed' AND 'urh->clean_ready', it will * be moved to cleanup list by MHD_resume_connection(). */ MHD_upgraded_connection_mark_app_closed_ (connection); return MHD_YES; case MHD_UPGRADE_ACTION_CORK_ON: /* Unportable API. TODO: replace with portable action. */ return MHD_connection_set_cork_state_ (connection, true) ? MHD_YES : MHD_NO; case MHD_UPGRADE_ACTION_CORK_OFF: /* Unportable API. TODO: replace with portable action. */ return MHD_connection_set_cork_state_ (connection, false) ? MHD_YES : MHD_NO; default: /* we don't understand this one */ return MHD_NO; } } /** * We are done sending the header of a given response to the client. * Now it is time to perform the upgrade and hand over the connection * to the application. * @remark To be called only from thread that process connection's * recv(), send() and response. Must be called right after sending * response headers. * * @param response the response that was created for an upgrade * @param connection the specific connection we are upgrading * @return #MHD_YES on success, #MHD_NO on failure (will cause * connection to be closed) */ enum MHD_Result MHD_response_execute_upgrade_ (struct MHD_Response *response, struct MHD_Connection *connection) { #if defined(HTTPS_SUPPORT) || defined(_DEBUG) || defined(HAVE_MESSAGES) struct MHD_Daemon *const daemon = connection->daemon; #endif /* HTTPS_SUPPORT || _DEBUG || HAVE_MESSAGES */ struct MHD_UpgradeResponseHandle *urh; size_t rbo; #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); #endif /* MHD_USE_THREADS */ /* "Upgrade" responses accepted only if MHD_ALLOW_UPGRADE is enabled */ mhd_assert (0 != (daemon->options & MHD_ALLOW_UPGRADE)); /* The header was checked when response queued */ mhd_assert (NULL != \ MHD_get_response_element_n_ (response, MHD_HEADER_KIND, MHD_HTTP_HEADER_UPGRADE, MHD_STATICSTR_LEN_ ( \ MHD_HTTP_HEADER_UPGRADE))); if (! connection->sk_nonblck) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Cannot execute \"upgrade\" as the socket is in " \ "the blocking mode.\n")); #endif return MHD_NO; } urh = MHD_calloc_ (1, sizeof (struct MHD_UpgradeResponseHandle)); if (NULL == urh) return MHD_NO; urh->connection = connection; rbo = connection->read_buffer_offset; connection->read_buffer_offset = 0; MHD_connection_set_nodelay_state_ (connection, false); MHD_connection_set_cork_state_ (connection, false); #ifdef HTTPS_SUPPORT if (0 != (daemon->options & MHD_USE_TLS) ) { MHD_socket sv[2]; #if defined(MHD_socket_nosignal_) || ! defined(MHD_socket_pair_nblk_) int res1; int res2; #endif /* MHD_socket_nosignal_ || !MHD_socket_pair_nblk_ */ #ifdef MHD_socket_pair_nblk_ if (! MHD_socket_pair_nblk_ (sv)) { free (urh); return MHD_NO; } #else /* !MHD_socket_pair_nblk_ */ if (! MHD_socket_pair_ (sv)) { free (urh); return MHD_NO; } res1 = MHD_socket_nonblocking_ (sv[0]); res2 = MHD_socket_nonblocking_ (sv[1]); if ( (! res1) || (! res2) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to make loopback sockets non-blocking.\n")); #endif if (! res2) { /* Socketpair cannot be used. */ MHD_socket_close_chk_ (sv[0]); MHD_socket_close_chk_ (sv[1]); free (urh); return MHD_NO; } } #endif /* !MHD_socket_pair_nblk_ */ #ifdef MHD_socket_nosignal_ res1 = MHD_socket_nosignal_ (sv[0]); res2 = MHD_socket_nosignal_ (sv[1]); if ( (! res1) || (! res2) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to set SO_NOSIGPIPE on loopback sockets.\n")); #endif #ifndef MSG_NOSIGNAL if (! res2) { /* Socketpair cannot be used. */ MHD_socket_close_chk_ (sv[0]); MHD_socket_close_chk_ (sv[1]); free (urh); return MHD_NO; } #endif /* ! MSG_NOSIGNAL */ } #endif /* MHD_socket_nosignal_ */ if (MHD_D_IS_USING_SELECT_ (daemon) && (! MHD_D_DOES_SCKT_FIT_FDSET_ (sv[1], daemon)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Socketpair descriptor is not less than FD_SETSIZE: " \ "%d >= %d\n"), (int) sv[1], (int) MHD_D_GET_FD_SETSIZE_ (daemon)); #endif MHD_socket_close_chk_ (sv[0]); MHD_socket_close_chk_ (sv[1]); free (urh); return MHD_NO; } urh->app.socket = sv[0]; urh->app.urh = urh; urh->app.celi = MHD_EPOLL_STATE_UNREADY; urh->mhd.socket = sv[1]; urh->mhd.urh = urh; urh->mhd.celi = MHD_EPOLL_STATE_UNREADY; #ifdef EPOLL_SUPPORT /* Launch IO processing by the event loop */ if (MHD_D_IS_USING_EPOLL_ (daemon)) { /* We're running with epoll(), need to add the sockets to the event set of the daemon's `epoll_upgrade_fd` */ struct epoll_event event; mhd_assert (-1 != daemon->epoll_upgrade_fd); /* First, add network socket */ event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET; event.data.ptr = &urh->app; if (0 != epoll_ctl (daemon->epoll_upgrade_fd, EPOLL_CTL_ADD, connection->socket_fd, &event)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif MHD_socket_close_chk_ (sv[0]); MHD_socket_close_chk_ (sv[1]); free (urh); return MHD_NO; } /* Second, add our end of the UNIX socketpair() */ event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET; event.data.ptr = &urh->mhd; if (0 != epoll_ctl (daemon->epoll_upgrade_fd, EPOLL_CTL_ADD, urh->mhd.socket, &event)) { event.events = EPOLLIN | EPOLLOUT | EPOLLPRI; event.data.ptr = &urh->app; if (0 != epoll_ctl (daemon->epoll_upgrade_fd, EPOLL_CTL_DEL, connection->socket_fd, &event)) MHD_PANIC (_ ("Error cleaning up while handling epoll error.\n")); #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif MHD_socket_close_chk_ (sv[0]); MHD_socket_close_chk_ (sv[1]); free (urh); return MHD_NO; } EDLL_insert (daemon->eready_urh_head, daemon->eready_urh_tail, urh); urh->in_eready_list = true; } #endif /* EPOLL_SUPPORT */ if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { /* This takes care of further processing for most event loops: simply add to DLL for bi-direcitonal processing */ DLL_insert (daemon->urh_head, daemon->urh_tail, urh); } /* In thread-per-connection mode, thread will switch to forwarding once * connection.urh is not NULL and connection.state == MHD_CONNECTION_UPGRADE. */ } else { urh->app.socket = MHD_INVALID_SOCKET; urh->mhd.socket = MHD_INVALID_SOCKET; /* Non-TLS connection do not hold any additional resources. */ urh->clean_ready = true; } #else /* ! HTTPS_SUPPORT */ urh->clean_ready = true; #endif /* ! HTTPS_SUPPORT */ connection->urh = urh; /* As far as MHD's event loops are concerned, this connection is suspended; it will be resumed once application is done by the #MHD_upgrade_action() function */ internal_suspend_connection_ (connection); /* hand over socket to application */ response->upgrade_handler (response->upgrade_handler_cls, connection, connection->rq.client_context, connection->read_buffer, rbo, #ifdef HTTPS_SUPPORT (0 == (daemon->options & MHD_USE_TLS) ) ? connection->socket_fd : urh->app.socket, #else /* ! HTTPS_SUPPORT */ connection->socket_fd, #endif /* ! HTTPS_SUPPORT */ urh); #ifdef HTTPS_SUPPORT if (0 != (daemon->options & MHD_USE_TLS)) { struct MemoryPool *const pool = connection->pool; size_t avail; char *buf; /* All data should be sent already */ mhd_assert (connection->write_buffer_send_offset == \ connection->write_buffer_append_offset); MHD_pool_deallocate (pool, connection->write_buffer, connection->write_buffer_size); connection->write_buffer_append_offset = 0; connection->write_buffer_send_offset = 0; connection->write_buffer_size = 0; connection->write_buffer = NULL; /* Extra read data should be processed already by the application */ MHD_pool_deallocate (pool, connection->read_buffer, connection->read_buffer_size); connection->read_buffer_offset = 0; connection->read_buffer_size = 0; connection->read_buffer = NULL; avail = MHD_pool_get_free (pool); if (avail < RESERVE_EBUF_SIZE) { /* connection's pool is totally at the limit, use our 'emergency' buffer of #RESERVE_EBUF_SIZE bytes. */ avail = RESERVE_EBUF_SIZE; buf = urh->e_buf; #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Memory shortage in connection's memory pool. " \ "The \"upgraded\" communication will be inefficient.\n")); #endif } else { /* Normal case: grab all remaining memory from the connection's pool for the IO buffers; the connection certainly won't need it anymore as we've upgraded to another protocol. */ buf = MHD_pool_allocate (pool, avail, false); } /* use half the buffer for inbound, half for outbound */ urh->in_buffer_size = avail / 2; urh->out_buffer_size = avail - urh->in_buffer_size; urh->in_buffer = buf; urh->out_buffer = buf + urh->in_buffer_size; } #endif /* HTTPS_SUPPORT */ return MHD_YES; } /** * Create a response object that can be used for 101 UPGRADE * responses, for example to implement WebSockets. After sending the * response, control over the data stream is given to the callback (which * can then, for example, start some bi-directional communication). * If the response is queued for multiple connections, the callback * will be called for each connection. The callback * will ONLY be called after the response header was successfully passed * to the OS; if there are communication errors before, the usual MHD * connection error handling code will be performed. * * Setting the correct HTTP code (i.e. MHD_HTTP_SWITCHING_PROTOCOLS) * and setting correct HTTP headers for the upgrade must be done * manually (this way, it is possible to implement most existing * WebSocket versions using this API; in fact, this API might be useful * for any protocol switch, not just WebSockets). Note that * draft-ietf-hybi-thewebsocketprotocol-00 cannot be implemented this * way as the header "HTTP/1.1 101 WebSocket Protocol Handshake" * cannot be generated; instead, MHD will always produce "HTTP/1.1 101 * Switching Protocols" (if the response code 101 is used). * * As usual, the response object can be extended with header * information and then be used any number of times (as long as the * header information is not connection-specific). * * @param upgrade_handler function to call with the 'upgraded' socket * @param upgrade_handler_cls closure for @a upgrade_handler * @return NULL on error (i.e. invalid arguments, out of memory) */ _MHD_EXTERN struct MHD_Response * MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, void *upgrade_handler_cls) { struct MHD_Response *response; if (NULL == upgrade_handler) return NULL; /* invalid request */ response = MHD_calloc_ (1, sizeof (struct MHD_Response)); if (NULL == response) return NULL; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (! MHD_mutex_init_ (&response->mutex)) { free (response); return NULL; } #endif response->upgrade_handler = upgrade_handler; response->upgrade_handler_cls = upgrade_handler_cls; response->total_size = 0; response->reference_count = 1; if (MHD_NO == MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "Upgrade")) { MHD_destroy_response (response); return NULL; } return response; } #endif /* UPGRADE_SUPPORT */ /** * Destroy a response object and associated resources. Note that * libmicrohttpd may keep some of the resources around if the response * is still in the queue for some clients, so the memory may not * necessarily be freed immediately. * * @param response response to destroy * @ingroup response */ _MHD_EXTERN void MHD_destroy_response (struct MHD_Response *response) { struct MHD_HTTP_Res_Header *pos; if (NULL == response) return; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&response->mutex); #endif if (0 != --(response->reference_count)) { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&response->mutex); #endif return; } #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&response->mutex); MHD_mutex_destroy_chk_ (&response->mutex); #endif if (NULL != response->crfc) response->crfc (response->crc_cls); if (NULL != response->data_iov) { free (response->data_iov); } while (NULL != response->first_header) { pos = response->first_header; response->first_header = pos->next; free (pos->header); free (pos->value); free (pos); } free (response); } /** * Increments the reference counter for the @a response. * * @param response object to modify */ void MHD_increment_response_rc (struct MHD_Response *response) { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&response->mutex); #endif (response->reference_count)++; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&response->mutex); #endif } /* end of response.c */ libmicrohttpd-1.0.1/src/microhttpd/connection_https.h0000644000175000017500000000444214417460232016543 /* This file is part of libmicrohttpd Copyright (C) 2008 Daniel Pittman and Christian Grothoff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file connection_https.h * @brief Methods for managing connections * @author Christian Grothoff */ #ifndef CONNECTION_HTTPS_H #define CONNECTION_HTTPS_H #include "internal.h" #ifdef HTTPS_SUPPORT /** * Set connection callback function to be used through out * the processing of this secure connection. * * @param connection which callbacks should be modified */ void MHD_set_https_callbacks (struct MHD_Connection *connection); /** * Give gnuTLS chance to work on the TLS handshake. * * @param connection connection to handshake on * @return true if the handshake has completed successfully * and we should start to read/write data, * false is handshake in progress or in case * of error */ bool MHD_run_tls_handshake_ (struct MHD_Connection *connection); /** * Initiate shutdown of TLS layer of connection. * * @param connection to use * @return true if succeed, false otherwise. */ bool MHD_tls_connection_shutdown (struct MHD_Connection *connection); /** * Callback for writing data to the socket. * * @param connection the MHD connection structure * @param other data to write * @param i number of bytes to write * @return positive value for number of bytes actually sent or * negative value for error number MHD_ERR_xxx_ */ ssize_t send_tls_adapter (struct MHD_Connection *connection, const void *other, size_t i); #endif /* HTTPS_SUPPORT */ #endif libmicrohttpd-1.0.1/src/microhttpd/sha256.h0000644000175000017500000000610414441373361014172 /* This file is part of libmicrohttpd Copyright (C) 2019-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/sha256.h * @brief Calculation of SHA-256 digest * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_SHA256_H #define MHD_SHA256_H 1 #include "mhd_options.h" #include #ifdef HAVE_STDDEF_H #include /* for size_t */ #endif /* HAVE_STDDEF_H */ /** * Digest is kept internally as 8 32-bit words. */ #define SHA256_DIGEST_SIZE_WORDS 8 /** * Number of bits in single SHA-256 word */ #define SHA256_WORD_SIZE_BITS 32 /** * Number of bytes in single SHA-256 word * used to process data */ #define SHA256_BYTES_IN_WORD (SHA256_WORD_SIZE_BITS / 8) /** * Size of SHA-256 digest in bytes */ #define SHA256_DIGEST_SIZE (SHA256_DIGEST_SIZE_WORDS * SHA256_BYTES_IN_WORD) /** * Size of SHA-256 digest string in chars including termination NUL */ #define SHA256_DIGEST_STRING_SIZE ((SHA256_DIGEST_SIZE) * 2 + 1) /** * Size of single processing block in bits */ #define SHA256_BLOCK_SIZE_BITS 512 /** * Size of single processing block in bytes */ #define SHA256_BLOCK_SIZE (SHA256_BLOCK_SIZE_BITS / 8) /** * Size of single processing block in bytes */ #define SHA256_BLOCK_SIZE_WORDS (SHA256_BLOCK_SIZE_BITS / SHA256_WORD_SIZE_BITS) struct Sha256Ctx { uint32_t H[SHA256_DIGEST_SIZE_WORDS]; /**< Intermediate hash value / digest at end of calculation */ uint32_t buffer[SHA256_BLOCK_SIZE_WORDS]; /**< SHA256 input data buffer */ uint64_t count; /**< number of bytes, mod 2^64 */ }; /** * Initialise structure for SHA256 calculation. * * @param ctx must be a `struct Sha256Ctx *` */ void MHD_SHA256_init (struct Sha256Ctx *ctx); /** * Process portion of bytes. * * @param ctx must be a `struct Sha256Ctx *` * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_SHA256_update (struct Sha256Ctx *ctx, const uint8_t *data, size_t length); /** * Finalise SHA256 calculation, return digest. * * @param ctx must be a `struct Sha256Ctx *` * @param[out] digest set to the hash, must be #SHA256_DIGEST_SIZE bytes */ void MHD_SHA256_finish (struct Sha256Ctx *ctx, uint8_t digest[SHA256_DIGEST_SIZE]); /** * Indicates that function MHD_SHA256_finish() (without context reset) is available */ #define MHD_SHA256_HAS_FINISH 1 #endif /* MHD_SHA256_H */ libmicrohttpd-1.0.1/src/microhttpd/test_md5.c0000644000175000017500000004415414445225034014705 /* This file is part of libmicrohttpd Copyright (C) 2019-2023 Evgeny Grin (Karlson2k) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/test_md5.h * @brief Unit tests for md5 functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "mhd_md5_wrap.h" #include "test_helpers.h" #include #include #if defined(MHD_MD5_TLSLIB) && defined(MHD_HTTPS_REQUIRE_GCRYPT) #define NEED_GCRYP_INIT 1 #include #endif /* MHD_MD5_TLSLIB && MHD_HTTPS_REQUIRE_GCRYPT */ static int verbose = 0; /* verbose level (0-1)*/ struct str_with_len { const char *const str; const size_t len; }; #define D_STR_W_LEN(s) {(s), (sizeof((s)) / sizeof(char)) - 1} struct data_unit1 { const struct str_with_len str_l; const uint8_t digest[MD5_DIGEST_SIZE]; }; static const struct data_unit1 data_units1[] = { {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."), {0x1c, 0x68, 0xc2, 0xe5, 0x1f, 0x63, 0xc9, 0x5f, 0x17, 0xab, 0x1f, 0x20, 0x8b, 0x86, 0x39, 0x57}}, {D_STR_W_LEN ("Simple string."), {0xf1, 0x2b, 0x7c, 0xad, 0xa0, 0x41, 0xfe, 0xde, 0x4e, 0x68, 0x16, 0x63, 0xb4, 0x60, 0x5d, 0x78}}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"), {0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b}}, {D_STR_W_LEN ("zyxwvutsrqponMLKJIHGFEDCBA"), {0x05, 0x61, 0x3a, 0x6b, 0xde, 0x75, 0x3a, 0x45, 0x91, 0xa8, 0x81, 0xb0, 0xa7, 0xe2, 0xe2, 0x0e}}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA" \ "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"), {0xaf, 0xab, 0xc7, 0xe9, 0xe7, 0x17, 0xbe, 0xd6, 0xc0, 0x0f, 0x78, 0x8c, 0xde, 0xdd, 0x11, 0xd1}}, {D_STR_W_LEN ("/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/long/long/long/long/long/long/long" \ "/long/long/long/long/path?with%20some=parameters"), {0x7e, 0xe6, 0xdb, 0xe2, 0x76, 0x49, 0x1a, 0xd8, 0xaf, 0xf3, 0x52, 0x2d, 0xd8, 0xfc, 0x89, 0x1e}}, {D_STR_W_LEN (""), {0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e}}, {D_STR_W_LEN ("a"), {0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61}}, {D_STR_W_LEN ("abc"), {0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72}}, {D_STR_W_LEN ("message digest"), {0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0}}, {D_STR_W_LEN ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" \ "0123456789"), {0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f}}, {D_STR_W_LEN ("12345678901234567890123456789012345678901234567890" \ "123456789012345678901234567890"), {0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a}} }; static const size_t units1_num = sizeof(data_units1) / sizeof(data_units1[0]); struct bin_with_len { const uint8_t bin[512]; const size_t len; }; struct data_unit2 { const struct bin_with_len bin_l; const uint8_t digest[MD5_DIGEST_SIZE]; }; static const struct data_unit2 data_units2[] = { { { {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}, 26}, /* a..z ASCII sequence */ {0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b}}, { { {65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65}, 72 },/* 'A' x 72 times */ {0x24, 0xa5, 0xef, 0x36, 0x82, 0x80, 0x3a, 0x06, 0x2f, 0xea, 0xad, 0xad, 0x76, 0xda, 0xbd, 0xa8}}, { { {19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73}, 55}, /* 19..73 sequence */ {0x6d, 0x2e, 0x6e, 0xde, 0x5d, 0x64, 0x6a, 0x17, 0xf1, 0x09, 0x2c, 0xac, 0x19, 0x10, 0xe3, 0xd6}}, { { {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69}, 63}, /* 7..69 sequence */ {0x88, 0x13, 0x48, 0x47, 0x73, 0xaa, 0x92, 0xf2, 0xc9, 0xdd, 0x69, 0xb3, 0xac, 0xf4, 0xba, 0x6e}}, { { {38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92}, 55}, /* 38..92 sequence */ {0x80, 0xf0, 0x05, 0x7e, 0xa2, 0xf7, 0xc8, 0x43, 0x12, 0xd3, 0xb1, 0x61, 0xab, 0x52, 0x3b, 0xaf}}, { { {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72}, 72},/* 1..72 sequence */ {0xc3, 0x28, 0xc5, 0xad, 0xc9, 0x26, 0xa9, 0x99, 0x95, 0x4a, 0x5e, 0x25, 0x50, 0x34, 0x51, 0x73}}, { { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}, 256}, /* 0..255 sequence */ {0xe2, 0xc8, 0x65, 0xdb, 0x41, 0x62, 0xbe, 0xd9, 0x63, 0xbf, 0xaa, 0x9e, 0xf6, 0xac, 0x18, 0xf0}}, { { {199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139}, 61}, /* 199..139 sequence */ {0xbb, 0x3f, 0xdb, 0x4a, 0x96, 0x03, 0x36, 0x37, 0x38, 0x78, 0x5e, 0x44, 0xbf, 0x3a, 0x85, 0x51}}, { { {255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, 255}, /* 255..1 sequence */ {0x52, 0x21, 0xa5, 0x83, 0x4f, 0x38, 0x7c, 0x73, 0xba, 0x18, 0x22, 0xb1, 0xf9, 0x7e, 0xae, 0x8b}}, { { {41, 35, 190, 132, 225, 108, 214, 174, 82, 144, 73, 241, 241, 187, 233, 235, 179, 166, 219, 60, 135, 12, 62, 153, 36, 94, 13, 28, 6, 183, 71, 222, 179, 18, 77, 200, 67, 187, 139, 166, 31, 3, 90, 125, 9, 56, 37, 31, 93, 212, 203, 252, 150, 245, 69, 59, 19, 13, 137, 10, 28, 219, 174, 50, 32, 154, 80, 238, 64, 120, 54, 253, 18, 73, 50, 246, 158, 125, 73, 220, 173, 79, 20, 242, 68, 64, 102, 208, 107, 196, 48, 183, 50, 59, 161, 34, 246, 34, 145, 157, 225, 139, 31, 218, 176, 202, 153, 2, 185, 114, 157, 73, 44, 128, 126, 197, 153, 213, 233, 128, 178, 234, 201, 204, 83, 191, 103, 214, 191, 20, 214, 126, 45, 220, 142, 102, 131, 239, 87, 73, 97, 255, 105, 143, 97, 205, 209, 30, 157, 156, 22, 114, 114, 230, 29, 240, 132, 79, 74, 119, 2, 215, 232, 57, 44, 83, 203, 201, 18, 30, 51, 116, 158, 12, 244, 213, 212, 159, 212, 164, 89, 126, 53, 207, 50, 34, 244, 204, 207, 211, 144, 45, 72, 211, 143, 117, 230, 217, 29, 42, 229, 192, 247, 43, 120, 129, 135, 68, 14, 95, 80, 0, 212, 97, 141, 190, 123, 5, 21, 7, 59, 51, 130, 31, 24, 112, 146, 218, 100, 84, 206, 177, 133, 62, 105, 21, 248, 70, 106, 4, 150, 115, 14, 217, 22, 47, 103, 104, 212, 247, 74, 74, 208, 87, 104}, 255}, /* pseudo-random data */ {0x55, 0x61, 0x2c, 0xeb, 0x29, 0xee, 0xa8, 0xb2, 0xf6, 0x10, 0x7b, 0xc1, 0x5b, 0x0f, 0x01, 0x95}} }; static const size_t units2_num = sizeof(data_units2) / sizeof(data_units2[0]); /* * Helper functions */ /** * Print bin as hex * * @param bin binary data * @param len number of bytes in bin * @param hex pointer to len*2+1 bytes buffer */ static void bin2hex (const uint8_t *bin, size_t len, char *hex) { while (len-- > 0) { unsigned int b1, b2; b1 = (*bin >> 4) & 0xf; *hex++ = (char) ((b1 > 9) ? (b1 + 'A' - 10) : (b1 + '0')); b2 = *bin++ & 0xf; *hex++ = (char) ((b2 > 9) ? (b2 + 'A' - 10) : (b2 + '0')); } *hex = 0; } static int check_result (const char *test_name, unsigned int check_num, const uint8_t calculated[MD5_DIGEST_SIZE], const uint8_t expected[MD5_DIGEST_SIZE]) { int failed = memcmp (calculated, expected, MD5_DIGEST_SIZE); check_num++; /* Print 1-based numbers */ if (failed) { char calc_str[MD5_DIGEST_STRING_SIZE]; char expc_str[MD5_DIGEST_STRING_SIZE]; bin2hex (calculated, MD5_DIGEST_SIZE, calc_str); bin2hex (expected, MD5_DIGEST_SIZE, expc_str); fprintf (stderr, "FAILED: %s check %u: calculated digest %s, expected digest %s.\n", test_name, check_num, calc_str, expc_str); fflush (stderr); } else if (verbose) { char calc_str[MD5_DIGEST_STRING_SIZE]; bin2hex (calculated, MD5_DIGEST_SIZE, calc_str); printf ("PASSED: %s check %u: calculated digest %s " "matches expected digest.\n", test_name, check_num, calc_str); fflush (stdout); } return failed ? 1 : 0; } /* * Tests */ /* Calculated MD5 as one pass for whole data */ static int test1_str (void) { unsigned int i; int num_failed = 0; struct Md5CtxWr ctx; MHD_MD5_init_one_time (&ctx); for (i = 0; i < units1_num; i++) { uint8_t digest[MD5_DIGEST_SIZE]; MHD_MD5_update (&ctx, (const uint8_t *) data_units1[i].str_l.str, data_units1[i].str_l.len); MHD_MD5_finish_reset (&ctx, digest); #ifdef MHD_MD5_HAS_EXT_ERROR if (0 != ctx.ext_error) { fprintf (stderr, "External hashing error: %d.\n", ctx.ext_error); exit (99); } #endif num_failed += check_result (MHD_FUNC_, i, digest, data_units1[i].digest); } MHD_MD5_deinit (&ctx); return num_failed; } static int test1_bin (void) { unsigned int i; int num_failed = 0; struct Md5CtxWr ctx; MHD_MD5_init_one_time (&ctx); for (i = 0; i < units2_num; i++) { uint8_t digest[MD5_DIGEST_SIZE]; MHD_MD5_update (&ctx, data_units2[i].bin_l.bin, data_units2[i].bin_l.len); MHD_MD5_finish_reset (&ctx, digest); #ifdef MHD_MD5_HAS_EXT_ERROR if (0 != ctx.ext_error) { fprintf (stderr, "External hashing error: %d.\n", ctx.ext_error); exit (99); } #endif num_failed += check_result (MHD_FUNC_, i, digest, data_units2[i].digest); } MHD_MD5_deinit (&ctx); return num_failed; } /* Calculated MD5 as two iterations for whole data */ static int test2_str (void) { unsigned int i; int num_failed = 0; struct Md5CtxWr ctx; MHD_MD5_init_one_time (&ctx); for (i = 0; i < units1_num; i++) { uint8_t digest[MD5_DIGEST_SIZE]; size_t part_s = data_units1[i].str_l.len / 4; MHD_MD5_update (&ctx, (const uint8_t *) "", 0); MHD_MD5_update (&ctx, (const uint8_t *) data_units1[i].str_l.str, part_s); MHD_MD5_update (&ctx, (const uint8_t *) "", 0); MHD_MD5_update (&ctx, (const uint8_t *) data_units1[i].str_l.str + part_s, data_units1[i].str_l.len - part_s); MHD_MD5_update (&ctx, (const uint8_t *) "", 0); MHD_MD5_finish_reset (&ctx, digest); #ifdef MHD_MD5_HAS_EXT_ERROR if (0 != ctx.ext_error) { fprintf (stderr, "External hashing error: %d.\n", ctx.ext_error); exit (99); } #endif num_failed += check_result (MHD_FUNC_, i, digest, data_units1[i].digest); } MHD_MD5_deinit (&ctx); return num_failed; } static int test2_bin (void) { unsigned int i; int num_failed = 0; struct Md5CtxWr ctx; MHD_MD5_init_one_time (&ctx); for (i = 0; i < units2_num; i++) { uint8_t digest[MD5_DIGEST_SIZE]; size_t part_s = data_units2[i].bin_l.len * 2 / 3; MHD_MD5_update (&ctx, data_units2[i].bin_l.bin, part_s); MHD_MD5_update (&ctx, (const uint8_t *) "", 0); MHD_MD5_update (&ctx, data_units2[i].bin_l.bin + part_s, data_units2[i].bin_l.len - part_s); MHD_MD5_finish_reset (&ctx, digest); #ifdef MHD_MD5_HAS_EXT_ERROR if (0 != ctx.ext_error) { fprintf (stderr, "External hashing error: %d.\n", ctx.ext_error); exit (99); } #endif num_failed += check_result (MHD_FUNC_, i, digest, data_units2[i].digest); } MHD_MD5_deinit (&ctx); return num_failed; } /* Use data set number 7 as it has the longest sequence */ #define DATA_POS 6 #define MAX_OFFSET 31 static int test_unaligned (void) { int num_failed = 0; unsigned int offset; uint8_t *buf; uint8_t *digest_buf; struct Md5CtxWr ctx; const struct data_unit2 *const tdata = data_units2 + DATA_POS; buf = malloc (tdata->bin_l.len + MAX_OFFSET); digest_buf = malloc (MD5_DIGEST_SIZE + MAX_OFFSET); if ((NULL == buf) || (NULL == digest_buf)) exit (99); MHD_MD5_init_one_time (&ctx); for (offset = MAX_OFFSET; offset >= 1; --offset) { uint8_t *unaligned_digest; uint8_t *unaligned_buf; unaligned_buf = buf + offset; memcpy (unaligned_buf, tdata->bin_l.bin, tdata->bin_l.len); unaligned_digest = digest_buf + MAX_OFFSET - offset; memset (unaligned_digest, 0, MD5_DIGEST_SIZE); MHD_MD5_update (&ctx, unaligned_buf, tdata->bin_l.len); MHD_MD5_finish_reset (&ctx, unaligned_digest); #ifdef MHD_MD5_HAS_EXT_ERROR if (0 != ctx.ext_error) { fprintf (stderr, "External hashing error: %d.\n", ctx.ext_error); exit (99); } #endif num_failed += check_result (MHD_FUNC_, MAX_OFFSET - offset, unaligned_digest, tdata->digest); } MHD_MD5_deinit (&ctx); free (digest_buf); free (buf); return num_failed; } int main (int argc, char *argv[]) { int num_failed = 0; (void) has_in_name; /* Mute compiler warning. */ if (has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose")) verbose = 1; #ifdef NEED_GCRYP_INIT gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* GCRYCTL_INITIALIZATION_FINISHED */ #endif /* NEED_GCRYP_INIT */ num_failed += test1_str (); num_failed += test1_bin (); num_failed += test2_str (); num_failed += test2_bin (); num_failed += test_unaligned (); return num_failed ? 1 : 0; } libmicrohttpd-1.0.1/src/microhttpd/connection.c0000644000175000017500000104333014566122702015316 /* This file is part of libmicrohttpd Copyright (C) 2007-2020 Daniel Pittman and Christian Grothoff Copyright (C) 2015-2024 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file connection.c * @brief Methods for managing connections * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "internal.h" #include "mhd_limits.h" #include "connection.h" #include "memorypool.h" #include "response.h" #include "mhd_mono_clock.h" #include "mhd_str.h" #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) #include "mhd_locks.h" #endif #include "mhd_sockets.h" #include "mhd_compat.h" #include "mhd_itc.h" #ifdef MHD_LINUX_SOLARIS_SENDFILE #include #endif /* MHD_LINUX_SOLARIS_SENDFILE */ #if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_DARWIN_SENDFILE) #include #include #include #endif /* HAVE_FREEBSD_SENDFILE || HAVE_DARWIN_SENDFILE */ #ifdef HTTPS_SUPPORT #include "connection_https.h" #endif /* HTTPS_SUPPORT */ #ifdef HAVE_SYS_PARAM_H /* For FreeBSD version identification */ #include #endif /* HAVE_SYS_PARAM_H */ #include "mhd_send.h" #include "mhd_assert.h" /** * Get whether bare LF in HTTP header and other protocol elements * should be treated as the line termination depending on the configured * strictness level. * RFC 9112, section 2.2 */ #define MHD_ALLOW_BARE_LF_AS_CRLF_(discp_lvl) (0 >= discp_lvl) /** * The reasonable length of the upload chunk "header" (the size specifier * with optional chunk extension). * MHD tries to keep the space in the read buffer large enough to read * the chunk "header" in one step. * The real "header" could be much larger, it will be handled correctly * anyway, however it may require several rounds of buffer grow. */ #define MHD_CHUNK_HEADER_REASONABLE_LEN 24 /** * Message to transmit when http 1.1 request is received */ #define HTTP_100_CONTINUE "HTTP/1.1 100 Continue\r\n\r\n" /** * Response text used when the request (http header) is too big to * be processed. */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_TOO_BIG \ "" \ "Request too big" \ "Request HTTP header is too big for the memory constraints " \ "of this webserver." \ "" #else #define ERR_MSG_REQUEST_TOO_BIG "" #endif /** * Response text used when the request header is too big to be processed. */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_HEADER_TOO_BIG \ "" \ "Request too big" \ "

The total size of the request headers, which includes the " \ "request target and the request field lines, exceeds the memory " \ "constraints of this web server.

" \ "

The request could be re-tried with shorter field lines, a shorter " \ "request target or a shorter request method token.

" \ "" #else #define ERR_MSG_REQUEST_HEADER_TOO_BIG "" #endif /** * Response text used when the request cookie header is too big to be processed. */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG \ "" \ "Request too big" \ "

The total size of the request headers, which includes the " \ "request target and the request field lines, exceeds the memory " \ "constraints of this web server.

" \ "

The request could be re-tried with smaller " \ ""Cookie:" field value, shorter other field lines, " \ "a shorter request target or a shorter request method token.

" \ "" #else #define ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG "" #endif /** * Response text used when the request chunk size line with chunk extension * cannot fit the buffer. */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG \ "" \ "Request too big" \ "

The total size of the request target, the request field lines " \ "and the chunk size line exceeds the memory constraints of this web " \ "server.

" \ "

The request could be re-tried without chunk extensions, with a smaller " \ "chunk size, shorter field lines, a shorter request target or a shorter " \ "request method token.

" \ "" #else #define ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG "" #endif /** * Response text used when the request chunk size line without chunk extension * cannot fit the buffer. */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG \ "" \ "Request too big" \ "

The total size of the request target, the request field lines " \ "and the chunk size line exceeds the memory constraints of this web " \ "server.

" \ "

The request could be re-tried with a smaller " \ "chunk size, shorter field lines, a shorter request target or a shorter " \ "request method token.

" \ "" #else #define ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG "" #endif /** * Response text used when the request header is too big to be processed. */ #ifdef HAVE_MESSAGES #define ERR_MSG_REQUEST_FOOTER_TOO_BIG \ "" \ "Request too big" \ "

The total size of the request headers, which includes the " \ "request target, the request field lines and the chunked trailer " \ "section exceeds the memory constraints of this web server.

" \ "

The request could be re-tried with a shorter chunked trailer " \ "section, shorter field lines, a shorter request target or " \ "a shorter request method token.

" \ "" #else #define ERR_MSG_REQUEST_FOOTER_TOO_BIG "" #endif /** * Response text used when the request line has more then two whitespaces. */ #ifdef HAVE_MESSAGES #define RQ_LINE_TOO_MANY_WSP \ "" \ "Request broken" \ "The request line has more then two whitespaces." \ "" #else #define RQ_LINE_TOO_MANY_WSP "" #endif /** * Response text used when the request HTTP header has bare CR character * without LF character (and CR is not allowed to be treated as whitespace). */ #ifdef HAVE_MESSAGES #define BARE_CR_IN_HEADER \ "" \ "Request broken" \ "Request HTTP header has bare CR character without " \ "following LF character." \ "" #else #define BARE_CR_IN_HEADER "" #endif /** * Response text used when the request HTTP footer has bare CR character * without LF character (and CR is not allowed to be treated as whitespace). */ #ifdef HAVE_MESSAGES #define BARE_CR_IN_FOOTER \ "" \ "Request broken" \ "Request HTTP footer has bare CR character without " \ "following LF character." \ "" #else #define BARE_CR_IN_FOOTER "" #endif /** * Response text used when the request HTTP header has bare LF character * without CR character. */ #ifdef HAVE_MESSAGES #define BARE_LF_IN_HEADER \ "" \ "Request broken" \ "Request HTTP header has bare LF character without " \ "preceding CR character." \ "" #else #define BARE_LF_IN_HEADER "" #endif /** * Response text used when the request HTTP footer has bare LF character * without CR character. */ #ifdef HAVE_MESSAGES #define BARE_LF_IN_FOOTER \ "" \ "Request broken" \ "Request HTTP footer has bare LF character without " \ "preceding CR character." \ "" #else #define BARE_LF_IN_FOOTER "" #endif /** * Response text used when the request line has invalid characters in URI. */ #ifdef HAVE_MESSAGES #define RQ_TARGET_INVALID_CHAR \ "" \ "Request broken" \ "HTTP request has invalid characters in " \ "the request-target." \ "" #else #define RQ_TARGET_INVALID_CHAR "" #endif /** * Response text used when line folding is used in request headers. */ #ifdef HAVE_MESSAGES #define ERR_RSP_OBS_FOLD \ "" \ "Request broken" \ "Obsolete line folding is used in HTTP request header." \ "" #else #define ERR_RSP_OBS_FOLD "" #endif /** * Response text used when line folding is used in request footers. */ #ifdef HAVE_MESSAGES #define ERR_RSP_OBS_FOLD_FOOTER \ "" \ "Request broken" \ "Obsolete line folding is used in HTTP request footer." \ "" #else #define ERR_RSP_OBS_FOLD_FOOTER "" #endif /** * Response text used when the request has whitespace at the start * of the first header line. */ #ifdef HAVE_MESSAGES #define ERR_RSP_WSP_BEFORE_HEADER \ "" \ "Request broken" \ "HTTP request has whitespace between the request line and " \ "the first header." \ "" #else #define ERR_RSP_WSP_BEFORE_HEADER "" #endif /** * Response text used when the request has whitespace at the start * of the first footer line. */ #ifdef HAVE_MESSAGES #define ERR_RSP_WSP_BEFORE_FOOTER \ "" \ "Request broken" \ "First HTTP footer line has whitespace at the first " \ "position." \ "" #else #define ERR_RSP_WSP_BEFORE_FOOTER "" #endif /** * Response text used when the whitespace found before colon (inside header * name or between header name and colon). */ #ifdef HAVE_MESSAGES #define ERR_RSP_WSP_IN_HEADER_NAME \ "" \ "Request broken" \ "HTTP request has whitespace before the first colon " \ "in header line." \ "" #else #define ERR_RSP_WSP_IN_HEADER_NAME "" #endif /** * Response text used when the whitespace found before colon (inside header * name or between header name and colon). */ #ifdef HAVE_MESSAGES #define ERR_RSP_WSP_IN_FOOTER_NAME \ "" \ "Request broken" \ "HTTP request has whitespace before the first colon " \ "in footer line." \ "" #else #define ERR_RSP_WSP_IN_FOOTER_NAME "" #endif /** * Response text used when request header has invalid character. */ #ifdef HAVE_MESSAGES #define ERR_RSP_INVALID_CHR_IN_HEADER \ "" \ "Request broken" \ "HTTP request has invalid character in header." \ "" #else #define ERR_RSP_INVALID_CHR_IN_HEADER "" #endif /** * Response text used when request header has invalid character. */ #ifdef HAVE_MESSAGES #define ERR_RSP_INVALID_CHR_IN_FOOTER \ "" \ "Request broken" \ "HTTP request has invalid character in footer." \ "" #else #define ERR_RSP_INVALID_CHR_IN_FOOTER "" #endif /** * Response text used when request header has no colon character. */ #ifdef HAVE_MESSAGES #define ERR_RSP_HEADER_WITHOUT_COLON \ "" \ "Request broken" \ "HTTP request header line has no colon character." \ "" #else #define ERR_RSP_HEADER_WITHOUT_COLON "" #endif /** * Response text used when request footer has no colon character. */ #ifdef HAVE_MESSAGES #define ERR_RSP_FOOTER_WITHOUT_COLON \ "" \ "Request broken" \ "HTTP request footer line has no colon character." \ "" #else #define ERR_RSP_FOOTER_WITHOUT_COLON "" #endif /** * Response text used when request header has zero-length header (filed) name. */ #ifdef HAVE_MESSAGES #define ERR_RSP_EMPTY_HEADER_NAME \ "" \ "Request broken" \ "HTTP request header has empty header name." \ "" #else #define ERR_RSP_EMPTY_HEADER_NAME "" #endif /** * Response text used when request header has zero-length header (filed) name. */ #ifdef HAVE_MESSAGES #define ERR_RSP_EMPTY_FOOTER_NAME \ "" \ "Request broken" \ "HTTP request footer has empty footer name." \ "" #else #define ERR_RSP_EMPTY_FOOTER_NAME "" #endif /** * Response text used when the request (http header) does not * contain a "Host:" header and still claims to be HTTP 1.1. * * Intentionally empty here to keep our memory footprint * minimal. */ #ifdef HAVE_MESSAGES #define REQUEST_LACKS_HOST \ "" \ ""Host:" header required" \ "HTTP/1.1 request without "Host:"." \ "" #else #define REQUEST_LACKS_HOST "" #endif /** * Response text used when the request has unsupported "Transfer-Encoding:". */ #ifdef HAVE_MESSAGES #define REQUEST_UNSUPPORTED_TR_ENCODING \ "" \ "Unsupported Transfer-Encoding" \ "The Transfer-Encoding used in request is not supported." \ "" #else #define REQUEST_UNSUPPORTED_TR_ENCODING "" #endif /** * Response text used when the request has unsupported both headers: * "Transfer-Encoding:" and "Content-Length:" */ #ifdef HAVE_MESSAGES #define REQUEST_LENGTH_WITH_TR_ENCODING \ "" \ "Malformed request" \ "Wrong combination of the request headers: both Transfer-Encoding " \ "and Content-Length headers are used at the same time." \ "" #else #define REQUEST_LENGTH_WITH_TR_ENCODING "" #endif /** * Response text used when the request (http header) is * malformed. * * Intentionally empty here to keep our memory footprint * minimal. */ #ifdef HAVE_MESSAGES #define REQUEST_MALFORMED \ "Request malformed" \ "HTTP request is syntactically incorrect." #else #define REQUEST_MALFORMED "" #endif /** * Response text used when the request HTTP chunked encoding is * malformed. */ #ifdef HAVE_MESSAGES #define REQUEST_CHUNKED_MALFORMED \ "Request malformed" \ "HTTP chunked encoding is syntactically incorrect." #else #define REQUEST_CHUNKED_MALFORMED "" #endif /** * Response text used when the request HTTP chunk is too large. */ #ifdef HAVE_MESSAGES #define REQUEST_CHUNK_TOO_LARGE \ "Request content too large" \ "The chunk size used in HTTP chunked encoded " \ "request is too large." #else #define REQUEST_CHUNK_TOO_LARGE "" #endif /** * Response text used when the request HTTP content is too large. */ #ifdef HAVE_MESSAGES #define REQUEST_CONTENTLENGTH_TOOLARGE \ "Request content too large" \ "HTTP request has too large value for " \ "Content-Length header." #else #define REQUEST_CONTENTLENGTH_TOOLARGE "" #endif /** * Response text used when the request HTTP chunked encoding is * malformed. */ #ifdef HAVE_MESSAGES #define REQUEST_CONTENTLENGTH_MALFORMED \ "Request malformed" \ "HTTP request has wrong value for " \ "Content-Length header." #else #define REQUEST_CONTENTLENGTH_MALFORMED "" #endif /** * Response text used when there is an internal server error. * * Intentionally empty here to keep our memory footprint * minimal. */ #ifdef HAVE_MESSAGES #define ERROR_MSG_DATA_NOT_HANDLED_BY_APP \ "Internal server error" \ "Please ask the developer of this Web server to carefully " \ "read the GNU libmicrohttpd documentation about connection " \ "management and blocking." #else #define ERROR_MSG_DATA_NOT_HANDLED_BY_APP "" #endif /** * Response text used when the request HTTP version is too old. */ #ifdef HAVE_MESSAGES #define REQ_HTTP_VER_IS_TOO_OLD \ "Requested HTTP version is not supported" \ "Requested HTTP version is too old and not " \ "supported." #else #define REQ_HTTP_VER_IS_TOO_OLD "" #endif /** * Response text used when the request HTTP version is not supported. */ #ifdef HAVE_MESSAGES #define REQ_HTTP_VER_IS_NOT_SUPPORTED \ "Requested HTTP version is not supported" \ "Requested HTTP version is not supported." #else #define REQ_HTTP_VER_IS_NOT_SUPPORTED "" #endif /** * sendfile() chuck size */ #define MHD_SENFILE_CHUNK_ (0x20000) /** * sendfile() chuck size for thread-per-connection */ #define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000) #ifdef HAVE_MESSAGES /** * Return text description for MHD_ERR_*_ codes * @param mhd_err_code the error code * @return pointer to static string with error description */ static const char * str_conn_error_ (ssize_t mhd_err_code) { switch (mhd_err_code) { case MHD_ERR_AGAIN_: return _ ("The operation would block, retry later"); case MHD_ERR_CONNRESET_: return _ ("The connection was forcibly closed by remote peer"); case MHD_ERR_NOTCONN_: return _ ("The socket is not connected"); case MHD_ERR_NOMEM_: return _ ("Not enough system resources to serve the request"); case MHD_ERR_BADF_: return _ ("Bad FD value"); case MHD_ERR_INVAL_: return _ ("Argument value is invalid"); case MHD_ERR_OPNOTSUPP_: return _ ("Argument value is not supported"); case MHD_ERR_PIPE_: return _ ("The socket is no longer available for sending"); case MHD_ERR_TLS_: return _ ("TLS encryption or decryption error"); default: break; /* Mute compiler warning */ } if (0 <= mhd_err_code) return _ ("Not an error code"); mhd_assert (0); /* Should never be reachable */ return _ ("Wrong error code value"); } #endif /* HAVE_MESSAGES */ /** * Allocate memory from connection's memory pool. * If memory pool doesn't have enough free memory but read or write buffer * have some unused memory, the size of the buffer will be reduced as needed. * @param connection the connection to use * @param size the size of allocated memory area * @return pointer to allocated memory region in the pool or * NULL if no memory is available */ void * MHD_connection_alloc_memory_ (struct MHD_Connection *connection, size_t size) { struct MHD_Connection *const c = connection; /* a short alias */ struct MemoryPool *const pool = c->pool; /* a short alias */ size_t need_to_be_freed = 0; /**< The required amount of additional free memory */ void *res; res = MHD_pool_try_alloc (pool, size, &need_to_be_freed); if (NULL != res) return res; if (MHD_pool_is_resizable_inplace (pool, c->write_buffer, c->write_buffer_size)) { if (c->write_buffer_size - c->write_buffer_append_offset >= need_to_be_freed) { char *buf; const size_t new_buf_size = c->write_buffer_size - need_to_be_freed; buf = MHD_pool_reallocate (pool, c->write_buffer, c->write_buffer_size, new_buf_size); mhd_assert (c->write_buffer == buf); mhd_assert (c->write_buffer_append_offset <= new_buf_size); mhd_assert (c->write_buffer_send_offset <= new_buf_size); c->write_buffer_size = new_buf_size; c->write_buffer = buf; } else return NULL; } else if (MHD_pool_is_resizable_inplace (pool, c->read_buffer, c->read_buffer_size)) { if (c->read_buffer_size - c->read_buffer_offset >= need_to_be_freed) { char *buf; const size_t new_buf_size = c->read_buffer_size - need_to_be_freed; buf = MHD_pool_reallocate (pool, c->read_buffer, c->read_buffer_size, new_buf_size); mhd_assert (c->read_buffer == buf); mhd_assert (c->read_buffer_offset <= new_buf_size); c->read_buffer_size = new_buf_size; c->read_buffer = buf; } else return NULL; } else return NULL; res = MHD_pool_allocate (pool, size, true); mhd_assert (NULL != res); /* It has been checked that pool has enough space */ return res; } /** * Callback for receiving data from the socket. * * @param connection the MHD connection structure * @param other where to write received data to * @param i maximum size of other (in bytes) * @return positive value for number of bytes actually received or * negative value for error number MHD_ERR_xxx_ */ static ssize_t recv_param_adapter (struct MHD_Connection *connection, void *other, size_t i) { ssize_t ret; if ( (MHD_INVALID_SOCKET == connection->socket_fd) || (MHD_CONNECTION_CLOSED == connection->state) ) { return MHD_ERR_NOTCONN_; } if (i > MHD_SCKT_SEND_MAX_SIZE_) i = MHD_SCKT_SEND_MAX_SIZE_; /* return value limit */ ret = MHD_recv_ (connection->socket_fd, other, i); if (0 > ret) { const int err = MHD_socket_get_error_ (); if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) { #ifdef EPOLL_SUPPORT /* Got EAGAIN --- no longer read-ready */ connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); #endif /* EPOLL_SUPPORT */ return MHD_ERR_AGAIN_; } if (MHD_SCKT_ERR_IS_EINTR_ (err)) return MHD_ERR_AGAIN_; if (MHD_SCKT_ERR_IS_REMOTE_DISCNN_ (err)) return MHD_ERR_CONNRESET_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EOPNOTSUPP_)) return MHD_ERR_OPNOTSUPP_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ENOTCONN_)) return MHD_ERR_NOTCONN_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINVAL_)) return MHD_ERR_INVAL_; if (MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err)) return MHD_ERR_NOMEM_; if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EBADF_)) return MHD_ERR_BADF_; /* Treat any other error as a hard error. */ return MHD_ERR_NOTCONN_; } #ifdef EPOLL_SUPPORT else if (i > (size_t) ret) connection->epoll_state &= ~((enum MHD_EpollState) MHD_EPOLL_STATE_READ_READY); #endif /* EPOLL_SUPPORT */ return ret; } /** * Get all of the headers from the request. * * @param connection connection to get values from * @param kind types of values to iterate over, can be a bitmask * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator * @return number of entries iterated over * -1 if connection is NULL. * @ingroup request */ _MHD_EXTERN int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) { int ret; struct MHD_HTTP_Req_Header *pos; if (NULL == connection) return -1; ret = 0; for (pos = connection->rq.headers_received; NULL != pos; pos = pos->next) if (0 != (pos->kind & kind)) { ret++; if ( (NULL != iterator) && (MHD_NO == iterator (iterator_cls, pos->kind, pos->header, pos->value)) ) return ret; } return ret; } /** * Get all of the headers from the request. * * @param connection connection to get values from * @param kind types of values to iterate over, can be a bitmask * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator * @return number of entries iterated over, * -1 if connection is NULL. * @ingroup request */ _MHD_EXTERN int MHD_get_connection_values_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIteratorN iterator, void *iterator_cls) { int ret; struct MHD_HTTP_Req_Header *pos; if (NULL == connection) return -1; ret = 0; if (NULL == iterator) for (pos = connection->rq.headers_received; NULL != pos; pos = pos->next) { if (0 != (kind & pos->kind)) ret++; } else for (pos = connection->rq.headers_received; NULL != pos; pos = pos->next) if (0 != (kind & pos->kind)) { ret++; if (MHD_NO == iterator (iterator_cls, pos->kind, pos->header, pos->header_size, pos->value, pos->value_size)) return ret; } return ret; } /** * This function can be used to add an arbitrary entry to connection. * Internal version of #MHD_set_connection_value_n() without checking * of arguments values. * * @param connection the connection for which a * value should be set * @param kind kind of the value * @param key key for the value, must be zero-terminated * @param key_size number of bytes in @a key (excluding 0-terminator) * @param value the value itself, must be zero-terminated * @param value_size number of bytes in @a value (excluding 0-terminator) * @return #MHD_NO if the operation could not be * performed due to insufficient memory; * #MHD_YES on success * @ingroup request */ static enum MHD_Result MHD_set_connection_value_n_nocheck_ (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size) { struct MHD_HTTP_Req_Header *pos; pos = MHD_connection_alloc_memory_ (connection, sizeof (struct MHD_HTTP_Res_Header)); if (NULL == pos) return MHD_NO; pos->header = key; pos->header_size = key_size; pos->value = value; pos->value_size = value_size; pos->kind = kind; pos->next = NULL; /* append 'pos' to the linked list of headers */ if (NULL == connection->rq.headers_received_tail) { connection->rq.headers_received = pos; connection->rq.headers_received_tail = pos; } else { connection->rq.headers_received_tail->next = pos; connection->rq.headers_received_tail = pos; } return MHD_YES; } /** * This function can be used to add an arbitrary entry to connection. * This function could add entry with binary zero, which is allowed * for #MHD_GET_ARGUMENT_KIND. For other kind on entries it is * recommended to use #MHD_set_connection_value. * * This function MUST only be called from within the * #MHD_AccessHandlerCallback (otherwise, access maybe improperly * synchronized). Furthermore, the client must guarantee that the key * and value arguments are 0-terminated strings that are NOT freed * until the connection is closed. (The easiest way to do this is by * passing only arguments to permanently allocated strings.). * * @param connection the connection for which a * value should be set * @param kind kind of the value * @param key key for the value, must be zero-terminated * @param key_size number of bytes in @a key (excluding 0-terminator) * @param value the value itself, must be zero-terminated * @param value_size number of bytes in @a value (excluding 0-terminator) * @return #MHD_NO if the operation could not be * performed due to insufficient memory; * #MHD_YES on success * @ingroup request */ _MHD_EXTERN enum MHD_Result MHD_set_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char *value, size_t value_size) { if ( (MHD_GET_ARGUMENT_KIND != kind) && ( ((key ? strlen (key) : 0) != key_size) || ((value ? strlen (value) : 0) != value_size) ) ) return MHD_NO; /* binary zero is allowed only in GET arguments */ return MHD_set_connection_value_n_nocheck_ (connection, kind, key, key_size, value, value_size); } /** * This function can be used to add an entry to the HTTP headers of a * connection (so that the #MHD_get_connection_values function will * return them -- and the `struct MHD_PostProcessor` will also see * them). This maybe required in certain situations (see Mantis * #1399) where (broken) HTTP implementations fail to supply values * needed by the post processor (or other parts of the application). * * This function MUST only be called from within the * #MHD_AccessHandlerCallback (otherwise, access maybe improperly * synchronized). Furthermore, the client must guarantee that the key * and value arguments are 0-terminated strings that are NOT freed * until the connection is closed. (The easiest way to do this is by * passing only arguments to permanently allocated strings.). * * @param connection the connection for which a * value should be set * @param kind kind of the value * @param key key for the value * @param value the value itself * @return #MHD_NO if the operation could not be * performed due to insufficient memory; * #MHD_YES on success * @ingroup request */ _MHD_EXTERN enum MHD_Result MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value) { return MHD_set_connection_value_n_nocheck_ (connection, kind, key, NULL != key ? strlen (key) : 0, value, NULL != value ? strlen (value) : 0); } /** * Get a particular header value. If multiple * values match the kind, return any one of them. * * @param connection connection to get values from * @param kind what kind of value are we looking for * @param key the header to look for, NULL to lookup 'trailing' value without a key * @return NULL if no such item was found * @ingroup request */ _MHD_EXTERN const char * MHD_lookup_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key) { const char *value; value = NULL; (void) MHD_lookup_connection_value_n (connection, kind, key, (NULL == key) ? 0 : strlen (key), &value, NULL); return value; } /** * Get a particular header value. If multiple * values match the kind, return any one of them. * @note Since MHD_VERSION 0x00096304 * * @param connection connection to get values from * @param kind what kind of value are we looking for * @param key the header to look for, NULL to lookup 'trailing' value without a key * @param key_size the length of @a key in bytes * @param[out] value_ptr the pointer to variable, which will be set to found value, * will not be updated if key not found, * could be NULL to just check for presence of @a key * @param[out] value_size_ptr the pointer variable, which will set to found value, * will not be updated if key not found, * could be NULL * @return #MHD_YES if key is found, * #MHD_NO otherwise. * @ingroup request */ _MHD_EXTERN enum MHD_Result MHD_lookup_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr) { struct MHD_HTTP_Req_Header *pos; if (NULL == connection) return MHD_NO; if (NULL == key) { for (pos = connection->rq.headers_received; NULL != pos; pos = pos->next) { if ( (0 != (kind & pos->kind)) && (NULL == pos->header) ) break; } } else { for (pos = connection->rq.headers_received; NULL != pos; pos = pos->next) { if ( (0 != (kind & pos->kind)) && (key_size == pos->header_size) && ( (key == pos->header) || (MHD_str_equal_caseless_bin_n_ (key, pos->header, key_size) ) ) ) break; } } if (NULL == pos) return MHD_NO; if (NULL != value_ptr) *value_ptr = pos->value; if (NULL != value_size_ptr) *value_size_ptr = pos->value_size; return MHD_YES; } /** * Check whether request header contains particular token. * * Token could be surrounded by spaces and tabs and delimited by comma. * Case-insensitive match used for header names and tokens. * @param connection the connection to get values from * @param header the header name * @param header_len the length of header, not including optional * terminating null-character * @param token the token to find * @param token_len the length of token, not including optional * terminating null-character. * @return true if token is found in specified header, * false otherwise */ static bool MHD_lookup_header_token_ci (const struct MHD_Connection *connection, const char *header, size_t header_len, const char *token, size_t token_len) { struct MHD_HTTP_Req_Header *pos; if ((NULL == connection) || (NULL == header) || (0 == header[0]) || (NULL == token) || (0 == token[0])) return false; for (pos = connection->rq.headers_received; NULL != pos; pos = pos->next) { if ((0 != (pos->kind & MHD_HEADER_KIND)) && (header_len == pos->header_size) && ( (header == pos->header) || (MHD_str_equal_caseless_bin_n_ (header, pos->header, header_len)) ) && (MHD_str_has_token_caseless_ (pos->value, token, token_len))) return true; } return false; } /** * Check whether request header contains particular static @a tkn. * * Token could be surrounded by spaces and tabs and delimited by comma. * Case-insensitive match used for header names and tokens. * @param c the connection to get values from * @param h the static string of header name * @param tkn the static string of token to find * @return true if token is found in specified header, * false otherwise */ #define MHD_lookup_header_s_token_ci(c,h,tkn) \ MHD_lookup_header_token_ci ((c),(h),MHD_STATICSTR_LEN_ (h), \ (tkn),MHD_STATICSTR_LEN_ (tkn)) /** * Do we (still) need to send a 100 continue * message for this connection? * * @param connection connection to test * @return false if we don't need 100 CONTINUE, true if we do */ static bool need_100_continue (struct MHD_Connection *connection) { const char *expect; if (! MHD_IS_HTTP_VER_1_1_COMPAT (connection->rq.http_ver)) return false; if (0 == connection->rq.remaining_upload_size) return false; if (MHD_NO == MHD_lookup_connection_value_n (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_EXPECT, MHD_STATICSTR_LEN_ ( \ MHD_HTTP_HEADER_EXPECT), &expect, NULL)) return false; if (MHD_str_equal_caseless_ (expect, "100-continue")) return true; return false; } /** * Mark connection as "closed". * @remark To be called from any thread. * * @param connection connection to close */ void MHD_connection_mark_closed_ (struct MHD_Connection *connection) { const struct MHD_Daemon *daemon = connection->daemon; if (0 == (daemon->options & MHD_USE_TURBO)) { #ifdef HTTPS_SUPPORT /* For TLS connection use shutdown of TLS layer * and do not shutdown TCP socket. This give more * chances to send TLS closure data to remote side. * Closure of TLS layer will be interpreted by * remote side as end of transmission. */ if (0 != (daemon->options & MHD_USE_TLS)) { if (! MHD_tls_connection_shutdown (connection)) shutdown (connection->socket_fd, SHUT_WR); } else /* Combined with next 'shutdown()'. */ #endif /* HTTPS_SUPPORT */ shutdown (connection->socket_fd, SHUT_WR); } connection->state = MHD_CONNECTION_CLOSED; connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; } /** * Close the given connection and give the * specified termination code to the user. * @remark To be called only from thread that * process connection's recv(), send() and response. * * @param connection connection to close * @param termination_code termination reason to give */ void MHD_connection_close_ (struct MHD_Connection *connection, enum MHD_RequestTerminationCode termination_code) { struct MHD_Daemon *daemon = connection->daemon; struct MHD_Response *resp = connection->rp.response; mhd_assert (! connection->suspended); #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); #endif /* MHD_USE_THREADS */ if ( (NULL != daemon->notify_completed) && (connection->rq.client_aware) ) daemon->notify_completed (daemon->notify_completed_cls, connection, &connection->rq.client_context, termination_code); connection->rq.client_aware = false; if (NULL != resp) { connection->rp.response = NULL; MHD_destroy_response (resp); } if (NULL != connection->pool) { MHD_pool_destroy (connection->pool); connection->pool = NULL; } MHD_connection_mark_closed_ (connection); } #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Stop TLS forwarding on upgraded connection and * reflect remote disconnect state to socketpair. * @remark In thread-per-connection mode this function * can be called from any thread, in other modes this * function must be called only from thread that process * daemon's select()/poll()/etc. * * @param connection the upgraded connection */ void MHD_connection_finish_forward_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; struct MHD_UpgradeResponseHandle *urh = connection->urh; #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) || \ MHD_thread_handle_ID_is_current_thread_ (daemon->tid) ); #endif /* MHD_USE_THREADS */ if (0 == (daemon->options & MHD_USE_TLS)) return; /* Nothing to do with non-TLS connection. */ if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) DLL_remove (daemon->urh_head, daemon->urh_tail, urh); #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon) && (0 != epoll_ctl (daemon->epoll_upgrade_fd, EPOLL_CTL_DEL, connection->socket_fd, NULL)) ) { MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); } if (urh->in_eready_list) { EDLL_remove (daemon->eready_urh_head, daemon->eready_urh_tail, urh); urh->in_eready_list = false; } #endif /* EPOLL_SUPPORT */ if (MHD_INVALID_SOCKET != urh->mhd.socket) { #ifdef EPOLL_SUPPORT if (MHD_D_IS_USING_EPOLL_ (daemon) && (0 != epoll_ctl (daemon->epoll_upgrade_fd, EPOLL_CTL_DEL, urh->mhd.socket, NULL)) ) { MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); } #endif /* EPOLL_SUPPORT */ /* Reflect remote disconnect to application by breaking * socketpair connection. */ shutdown (urh->mhd.socket, SHUT_RDWR); } /* Socketpair sockets will remain open as they will be * used with MHD_UPGRADE_ACTION_CLOSE. They will be * closed by cleanup_upgraded_connection() during * connection's final cleanup. */ } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT*/ /** * A serious error occurred, close the * connection (and notify the application). * * @param connection connection to close with error * @param emsg error message (can be NULL) */ static void connection_close_error (struct MHD_Connection *connection, const char *emsg) { connection->stop_with_error = true; connection->discard_request = true; #ifdef HAVE_MESSAGES if (NULL != emsg) MHD_DLOG (connection->daemon, "%s\n", emsg); #else /* ! HAVE_MESSAGES */ (void) emsg; /* Mute compiler warning. */ #endif /* ! HAVE_MESSAGES */ MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_WITH_ERROR); } /** * Macro to only include error message in call to * #connection_close_error() if we have HAVE_MESSAGES. */ #ifdef HAVE_MESSAGES #define CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, emsg) #else #define CONNECTION_CLOSE_ERROR(c, emsg) connection_close_error (c, NULL) #endif /** * Prepare the response buffer of this connection for * sending. Assumes that the response mutex is * already held. If the transmission is complete, * this function may close the socket (and return * #MHD_NO). * * @param connection the connection * @return #MHD_NO if readying the response failed (the * lock on the response will have been released already * in this case). */ static enum MHD_Result try_ready_normal_body (struct MHD_Connection *connection) { ssize_t ret; struct MHD_Response *response; response = connection->rp.response; mhd_assert (connection->rp.props.send_reply_body); if ( (0 == response->total_size) || /* TODO: replace the next check with assert */ (connection->rp.rsp_write_position == response->total_size) ) return MHD_YES; /* 0-byte response is always ready */ if (NULL != response->data_iov) { size_t copy_size; if (NULL != connection->rp.resp_iov.iov) return MHD_YES; copy_size = response->data_iovcnt * sizeof(MHD_iovec_); connection->rp.resp_iov.iov = MHD_connection_alloc_memory_ (connection, copy_size); if (NULL == connection->rp.resp_iov.iov) { MHD_mutex_unlock_chk_ (&response->mutex); /* not enough memory */ CONNECTION_CLOSE_ERROR (connection, _ ("Closing connection (out of memory).")); return MHD_NO; } memcpy (connection->rp.resp_iov.iov, response->data_iov, copy_size); connection->rp.resp_iov.cnt = response->data_iovcnt; connection->rp.resp_iov.sent = 0; return MHD_YES; } if (NULL == response->crc) return MHD_YES; if ( (response->data_start <= connection->rp.rsp_write_position) && (response->data_size + response->data_start > connection->rp.rsp_write_position) ) return MHD_YES; /* response already ready */ #if defined(_MHD_HAVE_SENDFILE) if (MHD_resp_sender_sendfile == connection->rp.resp_sender) { /* will use sendfile, no need to bother response crc */ return MHD_YES; } #endif /* _MHD_HAVE_SENDFILE */ ret = response->crc (response->crc_cls, connection->rp.rsp_write_position, (char *) response->data, (size_t) MHD_MIN ((uint64_t) response->data_buffer_size, response->total_size - connection->rp.rsp_write_position)); if (0 > ret) { /* either error or http 1.0 transfer, close socket! */ /* TODO: do not update total size, check whether response * was really with unknown size */ response->total_size = connection->rp.rsp_write_position; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&response->mutex); #endif if (MHD_CONTENT_READER_END_OF_STREAM == ret) MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_COMPLETED_OK); else CONNECTION_CLOSE_ERROR (connection, _ ("Closing connection (application reported " \ "error generating data).")); return MHD_NO; } response->data_start = connection->rp.rsp_write_position; response->data_size = (size_t) ret; if (0 == ret) { connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&response->mutex); #endif return MHD_NO; } return MHD_YES; } /** * Prepare the response buffer of this connection for sending. * Assumes that the response mutex is already held. If the * transmission is complete, this function may close the socket (and * return #MHD_NO). * * @param connection the connection * @param[out] p_finished the pointer to variable that will be set to "true" * when application returned indication of the end * of the stream * @return #MHD_NO if readying the response failed */ static enum MHD_Result try_ready_chunked_body (struct MHD_Connection *connection, bool *p_finished) { ssize_t ret; struct MHD_Response *response; static const size_t max_chunk = 0xFFFFFF; char chunk_hdr[6]; /* 6: max strlen of "FFFFFF" */ /* "FFFFFF" + "\r\n" */ static const size_t max_chunk_hdr_len = sizeof(chunk_hdr) + 2; /* "FFFFFF" + "\r\n" + "\r\n" (chunk termination) */ static const size_t max_chunk_overhead = sizeof(chunk_hdr) + 2 + 2; size_t chunk_hdr_len; uint64_t left_to_send; size_t size_to_fill; response = connection->rp.response; mhd_assert (NULL != response->crc || NULL != response->data); mhd_assert (0 == connection->write_buffer_append_offset); /* The buffer must be reasonably large enough */ if (128 > connection->write_buffer_size) { size_t size; size = connection->write_buffer_size + MHD_pool_get_free (connection->pool); if (128 > size) { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&response->mutex); #endif /* not enough memory */ CONNECTION_CLOSE_ERROR (connection, _ ("Closing connection (out of memory).")); return MHD_NO; } /* Limit the buffer size to the largest usable size for chunks */ if ( (max_chunk + max_chunk_overhead) < size) size = max_chunk + max_chunk_overhead; mhd_assert ((NULL == connection->write_buffer) || \ MHD_pool_is_resizable_inplace (connection->pool, \ connection->write_buffer, \ connection->write_buffer_size)); connection->write_buffer = MHD_pool_reallocate (connection->pool, connection->write_buffer, connection->write_buffer_size, size); mhd_assert (NULL != connection->write_buffer); connection->write_buffer_size = size; } mhd_assert (max_chunk_overhead < connection->write_buffer_size); if (MHD_SIZE_UNKNOWN == response->total_size) left_to_send = MHD_SIZE_UNKNOWN; else left_to_send = response->total_size - connection->rp.rsp_write_position; size_to_fill = connection->write_buffer_size - max_chunk_overhead; /* Limit size for the callback to the max usable size */ if (max_chunk < size_to_fill) size_to_fill = max_chunk; if (left_to_send < size_to_fill) size_to_fill = (size_t) left_to_send; if (0 == left_to_send) /* nothing to send, don't bother calling crc */ ret = MHD_CONTENT_READER_END_OF_STREAM; else if ( (response->data_start <= connection->rp.rsp_write_position) && (response->data_start + response->data_size > connection->rp.rsp_write_position) ) { /* difference between rsp_write_position and data_start is less than data_size which is size_t type, no need to check for overflow */ const size_t data_write_offset = (size_t) (connection->rp.rsp_write_position - response->data_start); /* buffer already ready, use what is there for the chunk */ mhd_assert (SSIZE_MAX >= (response->data_size - data_write_offset)); mhd_assert (response->data_size >= data_write_offset); ret = (ssize_t) (response->data_size - data_write_offset); if ( ((size_t) ret) > size_to_fill) ret = (ssize_t) size_to_fill; memcpy (&connection->write_buffer[max_chunk_hdr_len], &response->data[data_write_offset], (size_t) ret); } else { if (NULL == response->crc) { /* There is no way to reach this code */ #if defined(MHD_USE_THREADS) MHD_mutex_unlock_chk_ (&response->mutex); #endif CONNECTION_CLOSE_ERROR (connection, _ ("No callback for the chunked data.")); return MHD_NO; } ret = response->crc (response->crc_cls, connection->rp.rsp_write_position, &connection->write_buffer[max_chunk_hdr_len], size_to_fill); } if (MHD_CONTENT_READER_END_WITH_ERROR == ret) { /* error, close socket! */ /* TODO: remove update of the response size */ response->total_size = connection->rp.rsp_write_position; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&response->mutex); #endif CONNECTION_CLOSE_ERROR (connection, _ ("Closing connection (application error " \ "generating response).")); return MHD_NO; } if (MHD_CONTENT_READER_END_OF_STREAM == ret) { *p_finished = true; /* TODO: remove update of the response size */ response->total_size = connection->rp.rsp_write_position; return MHD_YES; } if (0 == ret) { connection->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&response->mutex); #endif return MHD_NO; } if (size_to_fill < (size_t) ret) { #if defined(MHD_USE_THREADS) MHD_mutex_unlock_chk_ (&response->mutex); #endif CONNECTION_CLOSE_ERROR (connection, _ ("Closing connection (application returned " \ "more data than requested).")); return MHD_NO; } chunk_hdr_len = MHD_uint32_to_strx ((uint32_t) ret, chunk_hdr, sizeof(chunk_hdr)); mhd_assert (chunk_hdr_len != 0); mhd_assert (chunk_hdr_len < sizeof(chunk_hdr)); *p_finished = false; connection->write_buffer_send_offset = (max_chunk_hdr_len - (chunk_hdr_len + 2)); memcpy (connection->write_buffer + connection->write_buffer_send_offset, chunk_hdr, chunk_hdr_len); connection->write_buffer[max_chunk_hdr_len - 2] = '\r'; connection->write_buffer[max_chunk_hdr_len - 1] = '\n'; connection->write_buffer[max_chunk_hdr_len + (size_t) ret] = '\r'; connection->write_buffer[max_chunk_hdr_len + (size_t) ret + 1] = '\n'; connection->rp.rsp_write_position += (size_t) ret; connection->write_buffer_append_offset = max_chunk_hdr_len + (size_t) ret + 2; return MHD_YES; } /** * Are we allowed to keep the given connection alive? * We can use the TCP stream for a second request if the connection * is HTTP 1.1 and the "Connection" header either does not exist or * is not set to "close", or if the connection is HTTP 1.0 and the * "Connection" header is explicitly set to "keep-alive". * If no HTTP version is specified (or if it is not 1.0 or 1.1), we * definitively close the connection. If the "Connection" header is * not exactly "close" or "keep-alive", we proceed to use the default * for the respective HTTP version. * If response has HTTP/1.0 flag or has "Connection: close" header * then connection must be closed. * If full request has not been read then connection must be closed * as well. * * @param connection the connection to check for keepalive * @return MHD_CONN_USE_KEEPALIVE if (based on the request and the response), * a keepalive is legal, * MHD_CONN_MUST_CLOSE if connection must be closed after sending * complete reply, * MHD_CONN_MUST_UPGRADE if connection must be upgraded. */ static enum MHD_ConnKeepAlive keepalive_possible (struct MHD_Connection *connection) { struct MHD_Connection *const c = connection; /**< a short alias */ struct MHD_Response *const r = c->rp.response; /**< a short alias */ mhd_assert (NULL != r); if (MHD_CONN_MUST_CLOSE == c->keepalive) return MHD_CONN_MUST_CLOSE; #ifdef UPGRADE_SUPPORT /* TODO: Move below the next check when MHD stops closing connections * when response is queued in first callback */ if (NULL != r->upgrade_handler) { /* No "close" token is enforced by 'add_response_header_connection()' */ mhd_assert (0 == (r->flags_auto & MHD_RAF_HAS_CONNECTION_CLOSE)); /* Valid HTTP version is enforced by 'MHD_queue_response()' */ mhd_assert (MHD_IS_HTTP_VER_SUPPORTED (c->rq.http_ver)); mhd_assert (! c->stop_with_error); return MHD_CONN_MUST_UPGRADE; } #endif /* UPGRADE_SUPPORT */ mhd_assert ( (! c->stop_with_error) || (c->discard_request)); if ((c->read_closed) || (c->discard_request)) return MHD_CONN_MUST_CLOSE; if (0 != (r->flags & MHD_RF_HTTP_1_0_COMPATIBLE_STRICT)) return MHD_CONN_MUST_CLOSE; if (0 != (r->flags_auto & MHD_RAF_HAS_CONNECTION_CLOSE)) return MHD_CONN_MUST_CLOSE; if (! MHD_IS_HTTP_VER_SUPPORTED (c->rq.http_ver)) return MHD_CONN_MUST_CLOSE; if (MHD_lookup_header_s_token_ci (c, MHD_HTTP_HEADER_CONNECTION, "close")) return MHD_CONN_MUST_CLOSE; if ((MHD_HTTP_VER_1_0 == connection->rq.http_ver) || (0 != (connection->rp.response->flags & MHD_RF_HTTP_1_0_SERVER))) { if (MHD_lookup_header_s_token_ci (connection, MHD_HTTP_HEADER_CONNECTION, "Keep-Alive")) return MHD_CONN_USE_KEEPALIVE; return MHD_CONN_MUST_CLOSE; } if (MHD_IS_HTTP_VER_1_1_COMPAT (c->rq.http_ver)) return MHD_CONN_USE_KEEPALIVE; return MHD_CONN_MUST_CLOSE; } /** * Produce time stamp. * * Result is NOT null-terminated. * Result is always 29 bytes long. * * @param[out] date where to write the time stamp, with * at least 29 bytes available space. */ static bool get_date_str (char *date) { static const char *const days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static const char *const mons[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; static const size_t buf_len = 29; struct tm now; time_t t; const char *src; #if ! defined(HAVE_C11_GMTIME_S) && ! defined(HAVE_W32_GMTIME_S) && \ ! defined(HAVE_GMTIME_R) struct tm *pNow; #endif if ((time_t) -1 == time (&t)) return false; #if defined(HAVE_C11_GMTIME_S) if (NULL == gmtime_s (&t, &now)) return false; #elif defined(HAVE_W32_GMTIME_S) if (0 != gmtime_s (&now, &t)) return false; #elif defined(HAVE_GMTIME_R) if (NULL == gmtime_r (&t, &now)) return false; #else pNow = gmtime (&t); if (NULL == pNow) return false; now = *pNow; #endif /* Day of the week */ src = days[now.tm_wday % 7]; date[0] = src[0]; date[1] = src[1]; date[2] = src[2]; date[3] = ','; date[4] = ' '; /* Day of the month */ if (2 != MHD_uint8_to_str_pad ((uint8_t) now.tm_mday, 2, date + 5, buf_len - 5)) return false; date[7] = ' '; /* Month */ src = mons[now.tm_mon % 12]; date[8] = src[0]; date[9] = src[1]; date[10] = src[2]; date[11] = ' '; /* Year */ if (4 != MHD_uint16_to_str ((uint16_t) (1900 + now.tm_year), date + 12, buf_len - 12)) return false; date[16] = ' '; /* Time */ MHD_uint8_to_str_pad ((uint8_t) now.tm_hour, 2, date + 17, buf_len - 17); date[19] = ':'; MHD_uint8_to_str_pad ((uint8_t) now.tm_min, 2, date + 20, buf_len - 20); date[22] = ':'; MHD_uint8_to_str_pad ((uint8_t) now.tm_sec, 2, date + 23, buf_len - 23); date[25] = ' '; date[26] = 'G'; date[27] = 'M'; date[28] = 'T'; return true; } /** * Produce HTTP DATE header. * Result is always 37 bytes long (plus one terminating null). * * @param[out] header where to write the header, with * at least 38 bytes available space. */ static bool get_date_header (char *header) { if (! get_date_str (header + 6)) { header[0] = 0; return false; } header[0] = 'D'; header[1] = 'a'; header[2] = 't'; header[3] = 'e'; header[4] = ':'; header[5] = ' '; header[35] = '\r'; header[36] = '\n'; header[37] = 0; return true; } /** * Try growing the read buffer. We initially claim half the available * buffer space for the read buffer (the other half being left for * management data structures; the write buffer can in the end take * virtually everything as the read buffer can be reduced to the * minimum necessary at that point. * * @param connection the connection * @param required set to 'true' if grow is required, i.e. connection * will fail if no additional space is granted * @return 'true' on success, 'false' on failure */ static bool try_grow_read_buffer (struct MHD_Connection *connection, bool required) { size_t new_size; size_t avail_size; const size_t def_grow_size = connection->daemon->pool_increment; void *rb; avail_size = MHD_pool_get_free (connection->pool); if (0 == avail_size) return false; /* No more space available */ if (0 == connection->read_buffer_size) new_size = avail_size / 2; /* Use half of available buffer for reading */ else { size_t grow_size; grow_size = avail_size / 8; if (def_grow_size > grow_size) { /* Shortage of space */ const size_t left_free = connection->read_buffer_size - connection->read_buffer_offset; mhd_assert (connection->read_buffer_size >= \ connection->read_buffer_offset); if ((def_grow_size <= grow_size + left_free) && (left_free < def_grow_size)) grow_size = def_grow_size - left_free; /* Use precise 'def_grow_size' for new free space */ else if (! required) return false; /* Grow is not mandatory, leave some space in pool */ else { /* Shortage of space, but grow is mandatory */ const size_t small_inc = ((MHD_BUF_INC_SIZE > def_grow_size) ? def_grow_size : MHD_BUF_INC_SIZE) / 8; if (small_inc < avail_size) grow_size = small_inc; else grow_size = avail_size; } } new_size = connection->read_buffer_size + grow_size; } /* Make sure that read buffer will not be moved */ if ((NULL != connection->read_buffer) && ! MHD_pool_is_resizable_inplace (connection->pool, connection->read_buffer, connection->read_buffer_size)) { mhd_assert (0); return false; } /* we can actually grow the buffer, do it! */ rb = MHD_pool_reallocate (connection->pool, connection->read_buffer, connection->read_buffer_size, new_size); if (NULL == rb) { /* This should NOT be possible: we just computed 'new_size' so that it should fit. If it happens, somehow our read buffer is not in the right position in the pool, say because someone called MHD_pool_allocate() without 'from_end' set to 'true'? Anyway, should be investigated! (Ideally provide all data from *pool and connection->read_buffer and new_size for debugging). */ mhd_assert (0); return false; } mhd_assert (connection->read_buffer == rb); connection->read_buffer = rb; mhd_assert (NULL != connection->read_buffer); connection->read_buffer_size = new_size; return true; } /** * Shrink connection read buffer to the zero size of free space in the buffer * @param connection the connection whose read buffer is being manipulated */ static void connection_shrink_read_buffer (struct MHD_Connection *connection) { struct MHD_Connection *const c = connection; /**< a short alias */ void *new_buf; if ((NULL == c->read_buffer) || (0 == c->read_buffer_size)) { mhd_assert (0 == c->read_buffer_size); mhd_assert (0 == c->read_buffer_offset); return; } mhd_assert (c->read_buffer_offset <= c->read_buffer_size); if (0 == c->read_buffer_offset) { MHD_pool_deallocate (c->pool, c->read_buffer, c->read_buffer_size); c->read_buffer = NULL; c->read_buffer_size = 0; } else { mhd_assert (MHD_pool_is_resizable_inplace (c->pool, c->read_buffer, \ c->read_buffer_size)); new_buf = MHD_pool_reallocate (c->pool, c->read_buffer, c->read_buffer_size, c->read_buffer_offset); mhd_assert (c->read_buffer == new_buf); c->read_buffer = new_buf; c->read_buffer_size = c->read_buffer_offset; } } /** * Allocate the maximum available amount of memory from MemoryPool * for write buffer. * @param connection the connection whose write buffer is being manipulated * @return the size of the free space in the write buffer */ static size_t connection_maximize_write_buffer (struct MHD_Connection *connection) { struct MHD_Connection *const c = connection; /**< a short alias */ struct MemoryPool *const pool = connection->pool; void *new_buf; size_t new_size; size_t free_size; mhd_assert ((NULL != c->write_buffer) || (0 == c->write_buffer_size)); mhd_assert (c->write_buffer_append_offset >= c->write_buffer_send_offset); mhd_assert (c->write_buffer_size >= c->write_buffer_append_offset); free_size = MHD_pool_get_free (pool); if (0 != free_size) { new_size = c->write_buffer_size + free_size; /* This function must not move the buffer position. * MHD_pool_reallocate () may return the new position only if buffer was * allocated 'from_end' or is not the last allocation, * which should not happen. */ mhd_assert ((NULL == c->write_buffer) || \ MHD_pool_is_resizable_inplace (pool, c->write_buffer, \ c->write_buffer_size)); new_buf = MHD_pool_reallocate (pool, c->write_buffer, c->write_buffer_size, new_size); mhd_assert ((c->write_buffer == new_buf) || (NULL == c->write_buffer)); c->write_buffer = new_buf; c->write_buffer_size = new_size; if (c->write_buffer_send_offset == c->write_buffer_append_offset) { /* All data have been sent, reset offsets to zero. */ c->write_buffer_send_offset = 0; c->write_buffer_append_offset = 0; } } return c->write_buffer_size - c->write_buffer_append_offset; } #if 0 /* disable unused function */ /** * Shrink connection write buffer to the size of unsent data. * * @note: The number of calls of this function should be limited to avoid extra * zeroing of the memory. * @param connection the connection whose write buffer is being manipulated * @param connection the connection to manipulate write buffer */ static void connection_shrink_write_buffer (struct MHD_Connection *connection) { struct MHD_Connection *const c = connection; /**< a short alias */ struct MemoryPool *const pool = connection->pool; void *new_buf; mhd_assert ((NULL != c->write_buffer) || (0 == c->write_buffer_size)); mhd_assert (c->write_buffer_append_offset >= c->write_buffer_send_offset); mhd_assert (c->write_buffer_size >= c->write_buffer_append_offset); if ( (NULL == c->write_buffer) || (0 == c->write_buffer_size)) { mhd_assert (0 == c->write_buffer_append_offset); mhd_assert (0 == c->write_buffer_send_offset); c->write_buffer = NULL; return; } if (c->write_buffer_append_offset == c->write_buffer_size) return; new_buf = MHD_pool_reallocate (pool, c->write_buffer, c->write_buffer_size, c->write_buffer_append_offset); mhd_assert ((c->write_buffer == new_buf) || \ (0 == c->write_buffer_append_offset)); c->write_buffer_size = c->write_buffer_append_offset; if (0 == c->write_buffer_size) c->write_buffer = NULL; else c->write_buffer = new_buf; } #endif /* unused function */ /** * Switch connection from recv mode to send mode. * * Current request header or body will not be read anymore, * response must be assigned to connection. * @param connection the connection to prepare for sending. */ static void connection_switch_from_recv_to_send (struct MHD_Connection *connection) { /* Read buffer is not needed for this request, shrink it.*/ connection_shrink_read_buffer (connection); } /** * This enum type describes requirements for reply body and reply bode-specific * headers (namely Content-Length, Transfer-Encoding). */ enum replyBodyUse { /** * No reply body allowed. * Reply body headers 'Content-Length:' or 'Transfer-Encoding: chunked' are * not allowed as well. */ RP_BODY_NONE = 0, /** * Do not send reply body. * Reply body headers 'Content-Length:' or 'Transfer-Encoding: chunked' are * allowed, but optional. */ RP_BODY_HEADERS_ONLY = 1, /** * Send reply body and * reply body headers 'Content-Length:' or 'Transfer-Encoding: chunked'. * Reply body headers are required. */ RP_BODY_SEND = 2 }; /** * Check whether reply body must be used. * * If reply body is needed, it could be zero-sized. * * @param connection the connection to check * @param rcode the response code * @return enum value indicating whether response body can be used and * whether response body length headers are allowed or required. * @sa is_reply_body_header_needed() */ static enum replyBodyUse is_reply_body_needed (struct MHD_Connection *connection, unsigned int rcode) { struct MHD_Connection *const c = connection; /**< a short alias */ mhd_assert (100 <= rcode); mhd_assert (999 >= rcode); if (199 >= rcode) return RP_BODY_NONE; if (MHD_HTTP_NO_CONTENT == rcode) return RP_BODY_NONE; #if 0 /* This check is not needed as upgrade handler is used only with code 101 */ #ifdef UPGRADE_SUPPORT if (NULL != rp.response->upgrade_handler) return RP_BODY_NONE; #endif /* UPGRADE_SUPPORT */ #endif #if 0 /* CONNECT is not supported by MHD */ /* Successful responses for connect requests are filtered by * MHD_queue_response() */ if ( (MHD_HTTP_MTHD_CONNECT == c->rq.http_mthd) && (2 == rcode / 100) ) return false; /* Actually pass-through CONNECT is not supported by MHD */ #endif /* Reply body headers could be used. * Check whether reply body itself must be used. */ if (MHD_HTTP_MTHD_HEAD == c->rq.http_mthd) return RP_BODY_HEADERS_ONLY; if (MHD_HTTP_NOT_MODIFIED == rcode) return RP_BODY_HEADERS_ONLY; /* Reply body must be sent. The body may have zero length, but body size * must be indicated by headers ('Content-Length:' or * 'Transfer-Encoding: chunked'). */ return RP_BODY_SEND; } /** * Setup connection reply properties. * * Reply properties include presence of reply body, transfer-encoding * type and other. * * @param connection to connection to process */ static void setup_reply_properties (struct MHD_Connection *connection) { struct MHD_Connection *const c = connection; /**< a short alias */ struct MHD_Response *const r = c->rp.response; /**< a short alias */ enum replyBodyUse use_rp_body; bool use_chunked; mhd_assert (NULL != r); /* ** Adjust reply properties ** */ c->keepalive = keepalive_possible (c); use_rp_body = is_reply_body_needed (c, c->rp.responseCode); c->rp.props.send_reply_body = (use_rp_body > RP_BODY_HEADERS_ONLY); c->rp.props.use_reply_body_headers = (use_rp_body >= RP_BODY_HEADERS_ONLY); #ifdef UPGRADE_SUPPORT mhd_assert ( (NULL == r->upgrade_handler) || (RP_BODY_NONE == use_rp_body) ); #endif /* UPGRADE_SUPPORT */ if (c->rp.props.use_reply_body_headers) { if ((MHD_SIZE_UNKNOWN == r->total_size) || (0 != (r->flags_auto & MHD_RAF_HAS_TRANS_ENC_CHUNKED))) { /* Use chunked reply encoding if possible */ /* Check whether chunked encoding is supported by the client */ if (! MHD_IS_HTTP_VER_1_1_COMPAT (c->rq.http_ver)) use_chunked = false; /* Check whether chunked encoding is allowed for the reply */ else if (0 != (r->flags & (MHD_RF_HTTP_1_0_COMPATIBLE_STRICT | MHD_RF_HTTP_1_0_SERVER))) use_chunked = false; else /* If chunked encoding is supported and allowed, and response size * is unknown, use chunked even for non-Keep-Alive connections. * See https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.3 * Also use chunked if it is enforced by application and supported by * the client. */ use_chunked = true; } else use_chunked = false; if ( (MHD_SIZE_UNKNOWN == r->total_size) && (! use_chunked) ) { /* End of the stream is indicated by closure */ c->keepalive = MHD_CONN_MUST_CLOSE; } } else use_chunked = false; /* chunked encoding cannot be used without body */ c->rp.props.chunked = use_chunked; #ifdef _DEBUG c->rp.props.set = true; #endif /* _DEBUG */ } /** * Check whether queued response is suitable for @a connection. * @param connection to connection to check */ static void check_connection_reply (struct MHD_Connection *connection) { struct MHD_Connection *const c = connection; /**< a short alias */ struct MHD_Response *const r = c->rp.response; /**< a short alias */ mhd_assert (c->rp.props.set); #ifdef HAVE_MESSAGES if ( (! c->rp.props.use_reply_body_headers) && (0 != r->total_size) ) { MHD_DLOG (c->daemon, _ ("This reply with response code %u cannot use reply body. " "Non-empty response body is ignored and not used.\n"), (unsigned) (c->rp.responseCode)); } if ( (! c->rp.props.use_reply_body_headers) && (0 != (r->flags_auto & MHD_RAF_HAS_CONTENT_LENGTH)) ) { MHD_DLOG (c->daemon, _ ("This reply with response code %u cannot use reply body. " "Application defined \"Content-Length\" header violates" "HTTP specification.\n"), (unsigned) (c->rp.responseCode)); } #else (void) c; /* Mute compiler warning */ (void) r; /* Mute compiler warning */ #endif } /** * Append data to the buffer if enough space is available, * update position. * @param[out] buf the buffer to append data to * @param[in,out] ppos the pointer to position in the @a buffer * @param buf_size the size of the @a buffer * @param append the data to append * @param append_size the size of the @a append * @return true if data has been added and position has been updated, * false if not enough space is available */ static bool buffer_append (char *buf, size_t *ppos, size_t buf_size, const char *append, size_t append_size) { mhd_assert (NULL != buf); /* Mute static analyzer */ if (buf_size < *ppos + append_size) return false; memcpy (buf + *ppos, append, append_size); *ppos += append_size; return true; } /** * Append static string to the buffer if enough space is available, * update position. * @param[out] buf the buffer to append data to * @param[in,out] ppos the pointer to position in the @a buffer * @param buf_size the size of the @a buffer * @param str the static string to append * @return true if data has been added and position has been updated, * false if not enough space is available */ #define buffer_append_s(buf,ppos,buf_size,str) \ buffer_append (buf,ppos,buf_size,str, MHD_STATICSTR_LEN_ (str)) /** * Add user-defined headers from response object to * the text buffer. * * @param buf the buffer to add headers to * @param ppos the pointer to the position in the @a buf * @param buf_size the size of the @a buf * @param response the response * @param filter_transf_enc skip "Transfer-Encoding" header if any * @param filter_content_len skip "Content-Length" header if any * @param add_close add "close" token to the * "Connection:" header (if any), ignored if no "Connection:" * header was added by user or if "close" token is already * present in "Connection:" header * @param add_keep_alive add "Keep-Alive" token to the * "Connection:" header (if any) * @return true if succeed, * false if buffer is too small */ static bool add_user_headers (char *buf, size_t *ppos, size_t buf_size, struct MHD_Response *response, bool filter_transf_enc, bool filter_content_len, bool add_close, bool add_keep_alive) { struct MHD_Response *const r = response; /**< a short alias */ struct MHD_HTTP_Res_Header *hdr; /**< Iterates through User-specified headers */ size_t el_size; /**< the size of current element to be added to the @a buf */ mhd_assert (! add_close || ! add_keep_alive); if (0 == (r->flags_auto & MHD_RAF_HAS_TRANS_ENC_CHUNKED)) filter_transf_enc = false; /* No such header */ if (0 == (r->flags_auto & MHD_RAF_HAS_CONTENT_LENGTH)) filter_content_len = false; /* No such header */ if (0 == (r->flags_auto & MHD_RAF_HAS_CONNECTION_HDR)) { add_close = false; /* No such header */ add_keep_alive = false; /* No such header */ } else if (0 != (r->flags_auto & MHD_RAF_HAS_CONNECTION_CLOSE)) add_close = false; /* "close" token was already set */ for (hdr = r->first_header; NULL != hdr; hdr = hdr->next) { size_t initial_pos = *ppos; if (MHD_HEADER_KIND != hdr->kind) continue; if (filter_transf_enc) { /* Need to filter-out "Transfer-Encoding" */ if ((MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_TRANSFER_ENCODING) == hdr->header_size) && (MHD_str_equal_caseless_bin_n_ (MHD_HTTP_HEADER_TRANSFER_ENCODING, hdr->header, hdr->header_size)) ) { filter_transf_enc = false; /* There is the only one such header */ continue; /* Skip "Transfer-Encoding" header */ } } if (filter_content_len) { /* Need to filter-out "Content-Length" */ if ((MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_LENGTH) == hdr->header_size) && (MHD_str_equal_caseless_bin_n_ (MHD_HTTP_HEADER_CONTENT_LENGTH, hdr->header, hdr->header_size)) ) { /* Reset filter flag if only one header is allowed */ filter_transf_enc = (0 == (r->flags & MHD_RF_INSANITY_HEADER_CONTENT_LENGTH)); continue; /* Skip "Content-Length" header */ } } /* Add user header */ el_size = hdr->header_size + 2 + hdr->value_size + 2; if (buf_size < *ppos + el_size) return false; memcpy (buf + *ppos, hdr->header, hdr->header_size); (*ppos) += hdr->header_size; buf[(*ppos)++] = ':'; buf[(*ppos)++] = ' '; if (add_close || add_keep_alive) { /* "Connection:" header must be always the first one */ mhd_assert (MHD_str_equal_caseless_n_ (hdr->header, \ MHD_HTTP_HEADER_CONNECTION, \ hdr->header_size)); if (add_close) { el_size += MHD_STATICSTR_LEN_ ("close, "); if (buf_size < initial_pos + el_size) return false; memcpy (buf + *ppos, "close, ", MHD_STATICSTR_LEN_ ("close, ")); *ppos += MHD_STATICSTR_LEN_ ("close, "); } else { el_size += MHD_STATICSTR_LEN_ ("Keep-Alive, "); if (buf_size < initial_pos + el_size) return false; memcpy (buf + *ppos, "Keep-Alive, ", MHD_STATICSTR_LEN_ ("Keep-Alive, ")); *ppos += MHD_STATICSTR_LEN_ ("Keep-Alive, "); } add_close = false; add_keep_alive = false; } if (0 != hdr->value_size) memcpy (buf + *ppos, hdr->value, hdr->value_size); *ppos += hdr->value_size; buf[(*ppos)++] = '\r'; buf[(*ppos)++] = '\n'; mhd_assert (initial_pos + el_size == (*ppos)); } return true; } /** * Allocate the connection's write buffer and fill it with all of the * headers from the response. * Required headers are added here. * * @param connection the connection * @return #MHD_YES on success, #MHD_NO on failure (out of memory) */ static enum MHD_Result build_header_response (struct MHD_Connection *connection) { struct MHD_Connection *const c = connection; /**< a short alias */ struct MHD_Response *const r = c->rp.response; /**< a short alias */ char *buf; /**< the output buffer */ size_t pos; /**< append offset in the @a buf */ size_t buf_size; /**< the size of the @a buf */ size_t el_size; /**< the size of current element to be added to the @a buf */ unsigned rcode; /**< the response code */ bool use_conn_close; /**< Use "Connection: close" header */ bool use_conn_k_alive; /**< Use "Connection: Keep-Alive" header */ mhd_assert (NULL != r); /* ** Adjust response properties ** */ setup_reply_properties (c); mhd_assert (c->rp.props.set); mhd_assert ((MHD_CONN_MUST_CLOSE == c->keepalive) || \ (MHD_CONN_USE_KEEPALIVE == c->keepalive) || \ (MHD_CONN_MUST_UPGRADE == c->keepalive)); #ifdef UPGRADE_SUPPORT mhd_assert ((NULL == r->upgrade_handler) || \ (MHD_CONN_MUST_UPGRADE == c->keepalive)); #else /* ! UPGRADE_SUPPORT */ mhd_assert (MHD_CONN_MUST_UPGRADE != c->keepalive); #endif /* ! UPGRADE_SUPPORT */ mhd_assert ((! c->rp.props.chunked) || c->rp.props.use_reply_body_headers); mhd_assert ((! c->rp.props.send_reply_body) || \ c->rp.props.use_reply_body_headers); #ifdef UPGRADE_SUPPORT mhd_assert (NULL == r->upgrade_handler || \ ! c->rp.props.use_reply_body_headers); #endif /* UPGRADE_SUPPORT */ check_connection_reply (c); rcode = (unsigned) c->rp.responseCode; if (MHD_CONN_MUST_CLOSE == c->keepalive) { /* The closure of connection must be always indicated by header * to avoid hung connections */ use_conn_close = true; use_conn_k_alive = false; } else if (MHD_CONN_USE_KEEPALIVE == c->keepalive) { use_conn_close = false; /* Add "Connection: keep-alive" if request is HTTP/1.0 or * if reply is HTTP/1.0 * For HTTP/1.1 add header only if explicitly requested by app * (by response flag), as "Keep-Alive" is default for HTTP/1.1. */ if ((0 != (r->flags & MHD_RF_SEND_KEEP_ALIVE_HEADER)) || (MHD_HTTP_VER_1_0 == c->rq.http_ver) || (0 != (r->flags & MHD_RF_HTTP_1_0_SERVER))) use_conn_k_alive = true; else use_conn_k_alive = false; } else { use_conn_close = false; use_conn_k_alive = false; } /* ** Actually build the response header ** */ /* Get all space available */ connection_maximize_write_buffer (c); buf = c->write_buffer; pos = c->write_buffer_append_offset; buf_size = c->write_buffer_size; if (0 == buf_size) return MHD_NO; mhd_assert (NULL != buf); /* * The status line * */ /* The HTTP version */ if (! c->rp.responseIcy) { /* HTTP reply */ if (0 == (r->flags & MHD_RF_HTTP_1_0_SERVER)) { /* HTTP/1.1 reply */ /* Use HTTP/1.1 responses for HTTP/1.0 clients. * See https://datatracker.ietf.org/doc/html/rfc7230#section-2.6 */ if (! buffer_append_s (buf, &pos, buf_size, MHD_HTTP_VERSION_1_1)) return MHD_NO; } else { /* HTTP/1.0 reply */ if (! buffer_append_s (buf, &pos, buf_size, MHD_HTTP_VERSION_1_0)) return MHD_NO; } } else { /* ICY reply */ if (! buffer_append_s (buf, &pos, buf_size, "ICY")) return MHD_NO; } /* The response code */ if (buf_size < pos + 5) /* space + code + space */ return MHD_NO; buf[pos++] = ' '; pos += MHD_uint16_to_str ((uint16_t) rcode, buf + pos, buf_size - pos); buf[pos++] = ' '; /* The reason phrase */ el_size = MHD_get_reason_phrase_len_for (rcode); if (0 == el_size) { if (! buffer_append_s (buf, &pos, buf_size, "Non-Standard Status")) return MHD_NO; } else if (! buffer_append (buf, &pos, buf_size, MHD_get_reason_phrase_for (rcode), el_size)) return MHD_NO; /* The linefeed */ if (buf_size < pos + 2) return MHD_NO; buf[pos++] = '\r'; buf[pos++] = '\n'; /* * The headers * */ /* Main automatic headers */ /* The "Date:" header */ if ( (0 == (r->flags_auto & MHD_RAF_HAS_DATE_HDR)) && (0 == (c->daemon->options & MHD_USE_SUPPRESS_DATE_NO_CLOCK)) ) { /* Additional byte for unused zero-termination */ if (buf_size < pos + 38) return MHD_NO; if (get_date_header (buf + pos)) pos += 37; } /* The "Connection:" header */ mhd_assert (! use_conn_close || ! use_conn_k_alive); mhd_assert (! use_conn_k_alive || ! use_conn_close); if (0 == (r->flags_auto & MHD_RAF_HAS_CONNECTION_HDR)) { if (use_conn_close) { if (! buffer_append_s (buf, &pos, buf_size, MHD_HTTP_HEADER_CONNECTION ": close\r\n")) return MHD_NO; } else if (use_conn_k_alive) { if (! buffer_append_s (buf, &pos, buf_size, MHD_HTTP_HEADER_CONNECTION ": Keep-Alive\r\n")) return MHD_NO; } } /* User-defined headers */ if (! add_user_headers (buf, &pos, buf_size, r, ! c->rp.props.chunked, (! c->rp.props.use_reply_body_headers) && (0 == (r->flags & MHD_RF_INSANITY_HEADER_CONTENT_LENGTH)), use_conn_close, use_conn_k_alive)) return MHD_NO; /* Other automatic headers */ if ( (c->rp.props.use_reply_body_headers) && (0 == (r->flags & MHD_RF_HEAD_ONLY_RESPONSE)) ) { /* Body-specific headers */ if (c->rp.props.chunked) { /* Chunked encoding is used */ if (0 == (r->flags_auto & MHD_RAF_HAS_TRANS_ENC_CHUNKED)) { /* No chunked encoding header set by user */ if (! buffer_append_s (buf, &pos, buf_size, MHD_HTTP_HEADER_TRANSFER_ENCODING ": " \ "chunked\r\n")) return MHD_NO; } } else /* Chunked encoding is not used */ { if (MHD_SIZE_UNKNOWN != r->total_size) { /* The size is known */ if (0 == (r->flags_auto & MHD_RAF_HAS_CONTENT_LENGTH)) { /* The response does not have "Content-Length" header */ if (! buffer_append_s (buf, &pos, buf_size, MHD_HTTP_HEADER_CONTENT_LENGTH ": ")) return MHD_NO; el_size = MHD_uint64_to_str (r->total_size, buf + pos, buf_size - pos); if (0 == el_size) return MHD_NO; pos += el_size; if (buf_size < pos + 2) return MHD_NO; buf[pos++] = '\r'; buf[pos++] = '\n'; } } } } /* * Header termination * */ if (buf_size < pos + 2) return MHD_NO; buf[pos++] = '\r'; buf[pos++] = '\n'; c->write_buffer_append_offset = pos; return MHD_YES; } /** * Allocate the connection's write buffer (if necessary) and fill it * with response footers. * Works only for chunked responses as other responses do not need * and do not support any kind of footers. * * @param connection the connection * @return #MHD_YES on success, #MHD_NO on failure (out of memory) */ static enum MHD_Result build_connection_chunked_response_footer (struct MHD_Connection *connection) { char *buf; /**< the buffer to write footers to */ size_t buf_size; /**< the size of the @a buf */ size_t used_size; /**< the used size of the @a buf */ struct MHD_Connection *const c = connection; /**< a short alias */ struct MHD_HTTP_Res_Header *pos; mhd_assert (connection->rp.props.chunked); /* TODO: allow combining of the final footer with the last chunk, * modify the next assert. */ mhd_assert (MHD_CONNECTION_CHUNKED_BODY_SENT == connection->state); mhd_assert (NULL != c->rp.response); buf_size = connection_maximize_write_buffer (c); /* '5' is the minimal size of chunked footer ("0\r\n\r\n") */ if (buf_size < 5) return MHD_NO; mhd_assert (NULL != c->write_buffer); buf = c->write_buffer + c->write_buffer_append_offset; mhd_assert (NULL != buf); used_size = 0; buf[used_size++] = '0'; buf[used_size++] = '\r'; buf[used_size++] = '\n'; for (pos = c->rp.response->first_header; NULL != pos; pos = pos->next) { if (MHD_FOOTER_KIND == pos->kind) { size_t new_used_size; /* resulting size with this header */ /* '4' is colon, space, linefeeds */ new_used_size = used_size + pos->header_size + pos->value_size + 4; if (new_used_size > buf_size) return MHD_NO; memcpy (buf + used_size, pos->header, pos->header_size); used_size += pos->header_size; buf[used_size++] = ':'; buf[used_size++] = ' '; memcpy (buf + used_size, pos->value, pos->value_size); used_size += pos->value_size; buf[used_size++] = '\r'; buf[used_size++] = '\n'; mhd_assert (used_size == new_used_size); } } if (used_size + 2 > buf_size) return MHD_NO; buf[used_size++] = '\r'; buf[used_size++] = '\n'; c->write_buffer_append_offset += used_size; mhd_assert (c->write_buffer_append_offset <= c->write_buffer_size); return MHD_YES; } /** * We encountered an error processing the request. * Handle it properly by stopping to read data * and sending the indicated response code and message. * * @param connection the connection * @param status_code the response code to send (400, 413 or 414) * @param message the error message to send * @param message_len the length of the @a message * @param header_name the name of the header, malloc()ed by the caller, * free() by this function, optional, can be NULL * @param header_name_len the length of the @a header_name * @param header_value the value of the header, malloc()ed by the caller, * free() by this function, optional, can be NULL * @param header_value_len the length of the @a header_value */ static void transmit_error_response_len (struct MHD_Connection *connection, unsigned int status_code, const char *message, size_t message_len, char *header_name, size_t header_name_len, char *header_value, size_t header_value_len) { struct MHD_Response *response; enum MHD_Result iret; mhd_assert (! connection->stop_with_error); /* Do not send error twice */ if (connection->stop_with_error) { /* Should not happen */ if (MHD_CONNECTION_CLOSED > connection->state) connection->state = MHD_CONNECTION_CLOSED; free (header_name); free (header_value); return; } connection->stop_with_error = true; connection->discard_request = true; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Error processing request (HTTP response code is %u ('%s')). " \ "Closing connection.\n"), status_code, message); #endif if (MHD_CONNECTION_START_REPLY < connection->state) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Too late to send an error response, " \ "response is being sent already.\n"), status_code, message); #endif CONNECTION_CLOSE_ERROR (connection, _ ("Too late for error response.")); free (header_name); free (header_value); return; } /* TODO: remove when special error queue function is implemented */ connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED; if (0 != connection->read_buffer_size) { /* Read buffer is not needed anymore, discard it * to free some space for error response. */ MHD_pool_deallocate (connection->pool, connection->read_buffer, connection->read_buffer_size); connection->read_buffer = NULL; connection->read_buffer_size = 0; connection->read_buffer_offset = 0; } if (NULL != connection->rp.response) { MHD_destroy_response (connection->rp.response); connection->rp.response = NULL; } response = MHD_create_response_from_buffer_static (message_len, message); if (NULL == response) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Failed to create error response.\n"), status_code, message); #endif /* can't even send a reply, at least close the connection */ connection->state = MHD_CONNECTION_CLOSED; free (header_name); free (header_value); return; } mhd_assert ((0 == header_name_len) || (NULL != header_name)); mhd_assert ((NULL == header_name) || (0 != header_name_len)); mhd_assert ((0 == header_value_len) || (NULL != header_value)); mhd_assert ((NULL == header_value) || (0 != header_value_len)); mhd_assert ((NULL == header_name) || (NULL != header_value)); mhd_assert ((NULL != header_value) || (NULL == header_name)); if (NULL != header_name) { iret = MHD_add_response_entry_no_alloc_ (response, MHD_HEADER_KIND, header_name, header_name_len, header_value, header_value_len); if (MHD_NO == iret) { free (header_name); free (header_value); } } else iret = MHD_YES; if (MHD_NO != iret) { bool before = connection->in_access_handler; /* Fake the flag for the internal call */ connection->in_access_handler = true; iret = MHD_queue_response (connection, status_code, response); connection->in_access_handler = before; } MHD_destroy_response (response); if (MHD_NO == iret) { /* can't even send a reply, at least close the connection */ CONNECTION_CLOSE_ERROR (connection, _ ("Closing connection " \ "(failed to queue error response).")); return; } mhd_assert (NULL != connection->rp.response); /* Do not reuse this connection. */ connection->keepalive = MHD_CONN_MUST_CLOSE; if (MHD_NO == build_header_response (connection)) { /* No memory. Release everything. */ connection->rq.version = NULL; connection->rq.method = NULL; connection->rq.url = NULL; connection->rq.url_len = 0; connection->rq.headers_received = NULL; connection->rq.headers_received_tail = NULL; connection->write_buffer = NULL; connection->write_buffer_size = 0; connection->write_buffer_send_offset = 0; connection->write_buffer_append_offset = 0; connection->read_buffer = MHD_pool_reset (connection->pool, NULL, 0, 0); connection->read_buffer_size = 0; /* Retry with empty buffer */ if (MHD_NO == build_header_response (connection)) { CONNECTION_CLOSE_ERROR (connection, _ ("Closing connection " \ "(failed to create error response header).")); return; } } connection->state = MHD_CONNECTION_HEADERS_SENDING; } /** * Transmit static string as error response */ #define transmit_error_response_static(c, code, msg) \ transmit_error_response_len (c, code, \ msg, MHD_STATICSTR_LEN_ (msg), \ NULL, 0, NULL, 0) /** * Transmit static string as error response and add specified header */ #define transmit_error_response_header(c, code, m, hd_n, hd_n_l, hd_v, hd_v_l) \ transmit_error_response_len (c, code, \ m, MHD_STATICSTR_LEN_ (m), \ hd_n, hd_n_l, \ hd_v, hd_v_l) /** * Check whether the read buffer has any upload body data ready to * be processed. * Must be called only when connection is in MHD_CONNECTION_BODY_RECEIVING * state. * * @param c the connection to check * @return 'true' if upload body data is already in the read buffer, * 'false' if no upload data is received and not processed. */ static bool has_unprocessed_upload_body_data_in_buffer (struct MHD_Connection *c) { mhd_assert (MHD_CONNECTION_BODY_RECEIVING == c->state); if (! c->rq.have_chunked_upload) return 0 != c->read_buffer_offset; /* Chunked upload */ mhd_assert (0 != c->rq.remaining_upload_size); /* Must not be possible in MHD_CONNECTION_BODY_RECEIVING state */ if (c->rq.current_chunk_offset == c->rq.current_chunk_size) { /* 0 == c->rq.current_chunk_size: Waiting the chunk size (chunk header). 0 != c->rq.current_chunk_size: Waiting for chunk-closing CRLF. */ return false; } return 0 != c->read_buffer_offset; /* Chunk payload data in the read buffer */ } /** * The stage of input data processing. * Used for out-of-memory (in the pool) handling. */ enum MHD_ProcRecvDataStage { MHD_PROC_RECV_INIT, /**< No data HTTP request data have been processed yet */ MHD_PROC_RECV_METHOD, /**< Processing/receiving the request HTTP method */ MHD_PROC_RECV_URI, /**< Processing/receiving the request URI */ MHD_PROC_RECV_HTTPVER, /**< Processing/receiving the request HTTP version string */ MHD_PROC_RECV_HEADERS, /**< Processing/receiving the request HTTP headers */ MHD_PROC_RECV_COOKIE, /**< Processing the received request cookie header */ MHD_PROC_RECV_BODY_NORMAL, /**< Processing/receiving the request non-chunked body */ MHD_PROC_RECV_BODY_CHUNKED,/**< Processing/receiving the request chunked body */ MHD_PROC_RECV_FOOTERS /**< Processing/receiving the request footers */ }; #ifndef MHD_MAX_REASONABLE_HEADERS_SIZE_ /** * A reasonable headers size (excluding request line) that should be sufficient * for most requests. * If incoming data buffer free space is not enough to process the complete * header (the request line and all headers) and the headers size is larger than * this size then the status code 431 "Request Header Fields Too Large" is * returned to the client. * The larger headers are processed by MHD if enough space is available. */ # define MHD_MAX_REASONABLE_HEADERS_SIZE_ (6 * 1024) #endif /* ! MHD_MAX_REASONABLE_HEADERS_SIZE_ */ #ifndef MHD_MAX_REASONABLE_REQ_TARGET_SIZE_ /** * A reasonable request target (the request URI) size that should be sufficient * for most requests. * If incoming data buffer free space is not enough to process the complete * header (the request line and all headers) and the request target size is * larger than this size then the status code 414 "URI Too Long" is * returned to the client. * The larger request targets are processed by MHD if enough space is available. * The value chosen according to RFC 9112 Section 3, paragraph 5 */ # define MHD_MAX_REASONABLE_REQ_TARGET_SIZE_ 8000 #endif /* ! MHD_MAX_REASONABLE_REQ_TARGET_SIZE_ */ #ifndef MHD_MIN_REASONABLE_HEADERS_SIZE_ /** * A reasonable headers size (excluding request line) that should be sufficient * for basic simple requests. * When no space left in the receiving buffer try to avoid replying with * the status code 431 "Request Header Fields Too Large" if headers size * is smaller then this value. */ # define MHD_MIN_REASONABLE_HEADERS_SIZE_ 26 #endif /* ! MHD_MIN_REASONABLE_HEADERS_SIZE_ */ #ifndef MHD_MIN_REASONABLE_REQ_TARGET_SIZE_ /** * A reasonable request target (the request URI) size that should be sufficient * for basic simple requests. * When no space left in the receiving buffer try to avoid replying with * the status code 414 "URI Too Long" if the request target size is smaller then * this value. */ # define MHD_MIN_REASONABLE_REQ_TARGET_SIZE_ 40 #endif /* ! MHD_MIN_REASONABLE_REQ_TARGET_SIZE_ */ #ifndef MHD_MIN_REASONABLE_REQ_METHOD_SIZE_ /** * A reasonable request method string size that should be sufficient * for basic simple requests. * When no space left in the receiving buffer try to avoid replying with * the status code 501 "Not Implemented" if the request method size is * smaller then this value. */ # define MHD_MIN_REASONABLE_REQ_METHOD_SIZE_ 16 #endif /* ! MHD_MIN_REASONABLE_REQ_METHOD_SIZE_ */ #ifndef MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_ /** * A reasonable minimal chunk line length. * When no space left in the receiving buffer reply with 413 "Content Too Large" * if the chunk line length is larger than this value. */ # define MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_ 4 #endif /* ! MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_ */ /** * Select the HTTP error status code for "out of receive buffer space" error. * @param c the connection to process * @param stage the current stage of request receiving * @param add_element the optional pointer to the element failed to be processed * or added, the meaning of the element depends on * the @a stage. Could be not zero-terminated and can * contain binary zeros. Can be NULL. * @param add_element_size the size of the @a add_element * @return the HTTP error code to use in the error reply */ static unsigned int get_no_space_err_status_code (struct MHD_Connection *c, enum MHD_ProcRecvDataStage stage, const char *add_element, size_t add_element_size) { size_t method_size; size_t uri_size; size_t opt_headers_size; size_t host_field_line_size; mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVED < c->state); mhd_assert (MHD_PROC_RECV_HEADERS <= stage); mhd_assert ((0 == add_element_size) || (NULL != add_element)); if (MHD_CONNECTION_HEADERS_RECEIVED > c->state) { mhd_assert (NULL != c->rq.field_lines.start); opt_headers_size = (size_t) ((c->read_buffer + c->read_buffer_offset) - c->rq.field_lines.start); } else opt_headers_size = c->rq.field_lines.size; /* The read buffer is fully used by the request line, the field lines (headers) and internal information. The return status code works as a suggestion for the client to reduce one of the request elements. */ if ((MHD_PROC_RECV_BODY_CHUNKED == stage) && (MHD_MIN_REASONABLE_REQ_CHUNK_LINE_LENGTH_ < add_element_size)) { /* Request could be re-tried easily with smaller chunk sizes */ return MHD_HTTP_CONTENT_TOO_LARGE; } host_field_line_size = 0; /* The "Host:" field line is mandatory. The total size of the field lines (headers) cannot be smaller than the size of the "Host:" field line. */ if ((MHD_PROC_RECV_HEADERS == stage) && (0 != add_element_size)) { static const size_t header_host_key_len = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_HOST); const bool is_host_header = (header_host_key_len + 1 <= add_element_size) && ( (0 == add_element[header_host_key_len]) || (':' == add_element[header_host_key_len]) ) && MHD_str_equal_caseless_bin_n_ (MHD_HTTP_HEADER_HOST, add_element, header_host_key_len); if (is_host_header) { const bool is_parsed = ! ( (MHD_CONNECTION_HEADERS_RECEIVED > c->state) && (add_element_size == c->read_buffer_offset) && (c->read_buffer == add_element) ); size_t actual_element_size; mhd_assert (! is_parsed || (0 == add_element[header_host_key_len])); /* The actual size should be larger due to CRLF or LF chars, however the exact termination sequence is not known here and as perfect precision is not required, to simplify the code assume the minimal length. */ if (is_parsed) actual_element_size = add_element_size + 1; /* "1" for LF */ else actual_element_size = add_element_size; host_field_line_size = actual_element_size; mhd_assert (opt_headers_size >= actual_element_size); opt_headers_size -= actual_element_size; } } if (0 == host_field_line_size) { static const size_t host_field_name_len = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_HOST); size_t host_field_name_value_len; if (MHD_NO != MHD_lookup_connection_value_n (c, MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST, host_field_name_len, NULL, &host_field_name_value_len)) { /* Calculate the minimal size of the field line: no space between colon and the field value, line terminated by LR */ host_field_line_size = host_field_name_len + host_field_name_value_len + 2; /* "2" for ':' and LF */ /* The "Host:" field could be added by application */ if (opt_headers_size >= host_field_line_size) { opt_headers_size -= host_field_line_size; /* Take into account typical space after colon and CR at the end of the line */ if (opt_headers_size >= 2) opt_headers_size -= 2; } else host_field_line_size = 0; /* No "Host:" field line set by the client */ } } uri_size = c->rq.req_target_len; if (MHD_HTTP_MTHD_OTHER != c->rq.http_mthd) method_size = 0; /* Do not recommend shorter request method */ else { mhd_assert (NULL != c->rq.method); method_size = strlen (c->rq.method); } if ((size_t) MHD_MAX_REASONABLE_HEADERS_SIZE_ < opt_headers_size) { /* Typically the easiest way to reduce request header size is a removal of some optional headers. */ if (opt_headers_size > (uri_size / 8)) { if ((opt_headers_size / 2) > method_size) return MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE; else return MHD_HTTP_NOT_IMPLEMENTED; /* The length of the HTTP request method is unreasonably large */ } else { /* Request target is MUCH larger than headers */ if ((uri_size / 16) > method_size) return MHD_HTTP_URI_TOO_LONG; else return MHD_HTTP_NOT_IMPLEMENTED; /* The length of the HTTP request method is unreasonably large */ } } if ((size_t) MHD_MAX_REASONABLE_REQ_TARGET_SIZE_ < uri_size) { /* If request target size if larger than maximum reasonable size recommend client to reduce the request target size (length). */ if ((uri_size / 16) > method_size) return MHD_HTTP_URI_TOO_LONG; /* Request target is MUCH larger than headers */ else return MHD_HTTP_NOT_IMPLEMENTED; /* The length of the HTTP request method is unreasonably large */ } /* The read buffer is too small to handle reasonably large requests */ if ((size_t) MHD_MIN_REASONABLE_HEADERS_SIZE_ < opt_headers_size) { /* Recommend application to retry with minimal headers */ if ((opt_headers_size * 4) > uri_size) { if (opt_headers_size > method_size) return MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE; else return MHD_HTTP_NOT_IMPLEMENTED; /* The length of the HTTP request method is unreasonably large */ } else { /* Request target is significantly larger than headers */ if (uri_size > method_size * 4) return MHD_HTTP_URI_TOO_LONG; else return MHD_HTTP_NOT_IMPLEMENTED; /* The length of the HTTP request method is unreasonably large */ } } if ((size_t) MHD_MIN_REASONABLE_REQ_TARGET_SIZE_ < uri_size) { /* Recommend application to retry with a shorter request target */ if (uri_size > method_size * 4) return MHD_HTTP_URI_TOO_LONG; else return MHD_HTTP_NOT_IMPLEMENTED; /* The length of the HTTP request method is unreasonably large */ } if ((size_t) MHD_MIN_REASONABLE_REQ_METHOD_SIZE_ < method_size) { /* The request target (URI) and headers are (reasonably) very small. Some non-standard long request method is used. */ /* The last resort response as it means "the method is not supported by the server for any URI". */ return MHD_HTTP_NOT_IMPLEMENTED; } /* The almost impossible situation: all elements are small, but cannot fit the buffer. The application set the buffer size to critically low value? */ if ((1 < opt_headers_size) || (1 < uri_size)) { if (opt_headers_size >= uri_size) return MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE; else return MHD_HTTP_URI_TOO_LONG; } /* Nothing to reduce in the request. Reply with some status. */ if (0 != host_field_line_size) return MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE; return MHD_HTTP_URI_TOO_LONG; } /** * Send error reply when receive buffer space exhausted while receiving or * storing the request headers * @param c the connection to handle * @param add_header the optional pointer to the current header string being * processed or the header failed to be added. * Could be not zero-terminated and can contain binary zeros. * Can be NULL. * @param add_header_size the size of the @a add_header */ static void handle_req_headers_no_space (struct MHD_Connection *c, const char *add_header, size_t add_header_size) { unsigned int err_code; err_code = get_no_space_err_status_code (c, MHD_PROC_RECV_HEADERS, add_header, add_header_size); transmit_error_response_static (c, err_code, ERR_MSG_REQUEST_HEADER_TOO_BIG); } #ifdef COOKIE_SUPPORT /** * Send error reply when the pool has no space to store 'cookie' header * parsing results. * @param c the connection to handle */ static void handle_req_cookie_no_space (struct MHD_Connection *c) { unsigned int err_code; err_code = get_no_space_err_status_code (c, MHD_PROC_RECV_COOKIE, NULL, 0); transmit_error_response_static (c, err_code, ERR_MSG_REQUEST_HEADER_WITH_COOKIES_TOO_BIG); } #endif /* COOKIE_SUPPORT */ /** * Send error reply when receive buffer space exhausted while receiving * the chunk size line. * @param c the connection to handle * @param add_header the optional pointer to the partially received * the current chunk size line. * Could be not zero-terminated and can contain binary zeros. * Can be NULL. * @param add_header_size the size of the @a add_header */ static void handle_req_chunk_size_line_no_space (struct MHD_Connection *c, const char *chunk_size_line, size_t chunk_size_line_size) { unsigned int err_code; if (NULL != chunk_size_line) { const char *semicol; /* Check for chunk extension */ semicol = memchr (chunk_size_line, ';', chunk_size_line_size); if (NULL != semicol) { /* Chunk extension present. It could be removed without any loss of the details of the request. */ transmit_error_response_static (c, MHD_HTTP_CONTENT_TOO_LARGE, ERR_MSG_REQUEST_CHUNK_LINE_EXT_TOO_BIG); } } err_code = get_no_space_err_status_code (c, MHD_PROC_RECV_BODY_CHUNKED, chunk_size_line, chunk_size_line_size); transmit_error_response_static (c, err_code, ERR_MSG_REQUEST_CHUNK_LINE_TOO_BIG); } /** * Send error reply when receive buffer space exhausted while receiving or * storing the request footers (for chunked requests). * @param c the connection to handle * @param add_footer the optional pointer to the current footer string being * processed or the footer failed to be added. * Could be not zero-terminated and can contain binary zeros. * Can be NULL. * @param add_footer_size the size of the @a add_footer */ static void handle_req_footers_no_space (struct MHD_Connection *c, const char *add_footer, size_t add_footer_size) { (void) add_footer; (void) add_footer_size; /* Unused */ mhd_assert (c->rq.have_chunked_upload); /* Footers should be optional */ transmit_error_response_static (c, MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, ERR_MSG_REQUEST_FOOTER_TOO_BIG); } /** * Handle situation with read buffer exhaustion. * Must be called when no more space left in the read buffer, no more * space left in the memory pool to grow the read buffer, but more data * need to be received from the client. * Could be called when the result of received data processing cannot be * stored in the memory pool (like some header). * @param c the connection to process * @param stage the receive stage where the exhaustion happens. */ static void handle_recv_no_space (struct MHD_Connection *c, enum MHD_ProcRecvDataStage stage) { mhd_assert (MHD_PROC_RECV_INIT <= stage); mhd_assert (MHD_PROC_RECV_FOOTERS >= stage); mhd_assert (MHD_CONNECTION_FULL_REQ_RECEIVED > c->state); mhd_assert ((MHD_PROC_RECV_INIT != stage) || \ (MHD_CONNECTION_INIT == c->state)); mhd_assert ((MHD_PROC_RECV_METHOD != stage) || \ (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state)); mhd_assert ((MHD_PROC_RECV_URI != stage) || \ (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state)); mhd_assert ((MHD_PROC_RECV_HTTPVER != stage) || \ (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state)); mhd_assert ((MHD_PROC_RECV_HEADERS != stage) || \ (MHD_CONNECTION_REQ_HEADERS_RECEIVING == c->state)); mhd_assert (MHD_PROC_RECV_COOKIE != stage); /* handle_req_cookie_no_space() must be called directly */ mhd_assert ((MHD_PROC_RECV_BODY_NORMAL != stage) || \ (MHD_CONNECTION_BODY_RECEIVING == c->state)); mhd_assert ((MHD_PROC_RECV_BODY_CHUNKED != stage) || \ (MHD_CONNECTION_BODY_RECEIVING == c->state)); mhd_assert ((MHD_PROC_RECV_FOOTERS != stage) || \ (MHD_CONNECTION_FOOTERS_RECEIVING == c->state)); mhd_assert ((MHD_PROC_RECV_BODY_NORMAL != stage) || \ (! c->rq.have_chunked_upload)); mhd_assert ((MHD_PROC_RECV_BODY_CHUNKED != stage) || \ (c->rq.have_chunked_upload)); switch (stage) { case MHD_PROC_RECV_INIT: case MHD_PROC_RECV_METHOD: /* Some data has been received, but it is not clear yet whether * the received data is an valid HTTP request */ connection_close_error (c, _ ("No space left in the read buffer when " \ "receiving the initial part of " \ "the request line.")); return; case MHD_PROC_RECV_URI: case MHD_PROC_RECV_HTTPVER: /* Some data has been received, but the request line is incomplete */ mhd_assert (MHD_HTTP_MTHD_NO_METHOD != c->rq.http_mthd); mhd_assert (MHD_HTTP_VER_UNKNOWN == c->rq.http_ver); /* A quick simple check whether the incomplete line looks * like an HTTP request */ if ((MHD_HTTP_MTHD_GET <= c->rq.http_mthd) && (MHD_HTTP_MTHD_DELETE >= c->rq.http_mthd)) { transmit_error_response_static (c, MHD_HTTP_URI_TOO_LONG, ERR_MSG_REQUEST_TOO_BIG); return; } connection_close_error (c, _ ("No space left in the read buffer when " \ "receiving the URI in " \ "the request line. " \ "The request uses non-standard HTTP request " \ "method token.")); return; case MHD_PROC_RECV_HEADERS: handle_req_headers_no_space (c, c->read_buffer, c->read_buffer_offset); return; case MHD_PROC_RECV_BODY_NORMAL: case MHD_PROC_RECV_BODY_CHUNKED: mhd_assert ((MHD_PROC_RECV_BODY_CHUNKED != stage) || \ ! c->rq.some_payload_processed); if (has_unprocessed_upload_body_data_in_buffer (c)) { /* The connection must not be in MHD_EVENT_LOOP_INFO_READ state when external polling is used and some data left unprocessed. */ mhd_assert (MHD_D_IS_USING_THREADS_ (c->daemon)); /* failed to grow the read buffer, and the client which is supposed to handle the received data in a *blocking* fashion (in this mode) did not handle the data as it was supposed to! => we would either have to do busy-waiting (on the client, which would likely fail), or if we do nothing, we would just timeout on the connection (if a timeout is even set!). Solution: we kill the connection with an error */ transmit_error_response_static (c, MHD_HTTP_INTERNAL_SERVER_ERROR, ERROR_MSG_DATA_NOT_HANDLED_BY_APP); } else { if (MHD_PROC_RECV_BODY_NORMAL == stage) { /* A header probably has been added to a suspended connection and it took precisely all the space in the buffer. Very low probability. */ mhd_assert (! c->rq.have_chunked_upload); handle_req_headers_no_space (c, NULL, 0); } else { mhd_assert (c->rq.have_chunked_upload); if (c->rq.current_chunk_offset != c->rq.current_chunk_size) { /* Receiving content of the chunk */ /* A header probably has been added to a suspended connection and it took precisely all the space in the buffer. Very low probability. */ handle_req_headers_no_space (c, NULL, 0); } else { if (0 != c->rq.current_chunk_size) { /* Waiting for chunk-closing CRLF */ /* Not really possible as some payload should be processed and the space used by payload should be available. */ handle_req_headers_no_space (c, NULL, 0); } else { /* Reading the line with the chunk size */ handle_req_chunk_size_line_no_space (c, c->read_buffer, c->read_buffer_offset); } } } } return; case MHD_PROC_RECV_FOOTERS: handle_req_footers_no_space (c, c->read_buffer, c->read_buffer_offset); return; /* The next cases should not be possible */ case MHD_PROC_RECV_COOKIE: default: break; } mhd_assert (0); } /** * Check whether enough space is available in the read buffer for the next * operation. * Handles grow of the buffer if required and error conditions (when buffer * grow is required but not possible). * Must be called only when processing the event loop states and when * reading is required for the next phase. * @param c the connection to check * @return true if connection handled successfully and enough buffer * is available, * false if not enough buffer is available and the loop's states * must be processed again as connection is in the error state. */ static bool check_and_grow_read_buffer_space (struct MHD_Connection *c) { /** * The increase of read buffer size is desirable. */ bool rbuff_grow_desired; /** * The increase of read buffer size is a hard requirement. */ bool rbuff_grow_required; mhd_assert (0 != (MHD_EVENT_LOOP_INFO_READ & c->event_loop_info)); mhd_assert (! c->discard_request); rbuff_grow_required = (c->read_buffer_offset == c->read_buffer_size); if (rbuff_grow_required) rbuff_grow_desired = true; else { rbuff_grow_desired = (c->read_buffer_offset + c->daemon->pool_increment > c->read_buffer_size); if ((rbuff_grow_desired) && (MHD_CONNECTION_BODY_RECEIVING == c->state)) { if (! c->rq.have_chunked_upload) { mhd_assert (MHD_SIZE_UNKNOWN != c->rq.remaining_upload_size); /* Do not grow read buffer more than necessary to process the current request. */ rbuff_grow_desired = (c->rq.remaining_upload_size > c->read_buffer_size); } else { mhd_assert (MHD_SIZE_UNKNOWN == c->rq.remaining_upload_size); if (0 == c->rq.current_chunk_size) rbuff_grow_desired = /* Reading value of the next chunk size */ (MHD_CHUNK_HEADER_REASONABLE_LEN > c->read_buffer_size); else { const uint64_t cur_chunk_left = c->rq.current_chunk_size - c->rq.current_chunk_offset; /* Do not grow read buffer more than necessary to process the current chunk with terminating CRLF. */ mhd_assert (c->rq.current_chunk_offset <= c->rq.current_chunk_size); rbuff_grow_desired = ((cur_chunk_left + 2) > (uint64_t) (c->read_buffer_size)); } } } } if (! rbuff_grow_desired) return true; /* No need to increase the buffer */ if (try_grow_read_buffer (c, rbuff_grow_required)) return true; /* Buffer increase succeed */ if (! rbuff_grow_required) return true; /* Can continue without buffer increase */ /* Failed to increase the read buffer size, but need to read the data from the network. No more space left in the buffer, no more space to increase the buffer. */ /* 'PROCESS_READ' event state flag must be set only if the last application callback has processed some data. If any data is processed then some space in the read buffer must be available. */ mhd_assert (0 == (MHD_EVENT_LOOP_INFO_PROCESS & c->event_loop_info)); if ((! MHD_D_IS_USING_THREADS_ (c->daemon)) && (MHD_CONNECTION_BODY_RECEIVING == c->state) && has_unprocessed_upload_body_data_in_buffer (c)) { /* The application is handling processing cycles. The data could be processed later. */ c->event_loop_info = MHD_EVENT_LOOP_INFO_PROCESS; return true; } else { enum MHD_ProcRecvDataStage stage; switch (c->state) { case MHD_CONNECTION_INIT: stage = MHD_PROC_RECV_INIT; break; case MHD_CONNECTION_REQ_LINE_RECEIVING: if (MHD_HTTP_MTHD_NO_METHOD == c->rq.http_mthd) stage = MHD_PROC_RECV_METHOD; else if (0 == c->rq.req_target_len) stage = MHD_PROC_RECV_URI; else stage = MHD_PROC_RECV_HTTPVER; break; case MHD_CONNECTION_REQ_HEADERS_RECEIVING: stage = MHD_PROC_RECV_HEADERS; break; case MHD_CONNECTION_BODY_RECEIVING: stage = c->rq.have_chunked_upload ? MHD_PROC_RECV_BODY_CHUNKED : MHD_PROC_RECV_BODY_NORMAL; break; case MHD_CONNECTION_FOOTERS_RECEIVING: stage = MHD_PROC_RECV_FOOTERS; break; case MHD_CONNECTION_REQ_LINE_RECEIVED: case MHD_CONNECTION_HEADERS_RECEIVED: case MHD_CONNECTION_HEADERS_PROCESSED: case MHD_CONNECTION_CONTINUE_SENDING: case MHD_CONNECTION_BODY_RECEIVED: case MHD_CONNECTION_FOOTERS_RECEIVED: case MHD_CONNECTION_FULL_REQ_RECEIVED: case MHD_CONNECTION_START_REPLY: case MHD_CONNECTION_HEADERS_SENDING: case MHD_CONNECTION_HEADERS_SENT: case MHD_CONNECTION_NORMAL_BODY_UNREADY: case MHD_CONNECTION_NORMAL_BODY_READY: case MHD_CONNECTION_CHUNKED_BODY_UNREADY: case MHD_CONNECTION_CHUNKED_BODY_READY: case MHD_CONNECTION_CHUNKED_BODY_SENT: case MHD_CONNECTION_FOOTERS_SENDING: case MHD_CONNECTION_FULL_REPLY_SENT: case MHD_CONNECTION_CLOSED: #ifdef UPGRADE_SUPPORT case MHD_CONNECTION_UPGRADE: #endif default: stage = MHD_PROC_RECV_BODY_NORMAL; mhd_assert (0); } handle_recv_no_space (c, stage); } return false; } /** * Update the 'event_loop_info' field of this connection based on the state * that the connection is now in. May also close the connection or * perform other updates to the connection if needed to prepare for * the next round of the event loop. * * @param connection connection to get poll set for */ static void MHD_connection_update_event_loop_info (struct MHD_Connection *connection) { /* Do not update states of suspended connection */ if (connection->suspended) return; /* States will be updated after resume. */ #ifdef HTTPS_SUPPORT if (MHD_TLS_CONN_NO_TLS != connection->tls_state) { /* HTTPS connection. */ switch (connection->tls_state) { case MHD_TLS_CONN_INIT: connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ; return; case MHD_TLS_CONN_HANDSHAKING: case MHD_TLS_CONN_WR_CLOSING: if (0 == gnutls_record_get_direction (connection->tls_session)) connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ; else connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; return; case MHD_TLS_CONN_CONNECTED: break; /* Do normal processing */ case MHD_TLS_CONN_WR_CLOSED: case MHD_TLS_CONN_TLS_FAILED: connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; return; case MHD_TLS_CONN_TLS_CLOSING: /* Not implemented yet */ case MHD_TLS_CONN_TLS_CLOSED: /* Not implemented yet */ case MHD_TLS_CONN_INVALID_STATE: case MHD_TLS_CONN_NO_TLS: /* Not possible */ default: MHD_PANIC (_ ("Invalid TLS state value.\n")); } } #endif /* HTTPS_SUPPORT */ while (1) { #if DEBUG_STATES MHD_DLOG (connection->daemon, _ ("In function %s handling connection at state: %s\n"), MHD_FUNC_, MHD_state_to_string (connection->state)); #endif switch (connection->state) { case MHD_CONNECTION_INIT: case MHD_CONNECTION_REQ_LINE_RECEIVING: connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ; break; case MHD_CONNECTION_REQ_LINE_RECEIVED: mhd_assert (0); break; case MHD_CONNECTION_REQ_HEADERS_RECEIVING: connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ; break; case MHD_CONNECTION_HEADERS_RECEIVED: case MHD_CONNECTION_HEADERS_PROCESSED: mhd_assert (0); break; case MHD_CONNECTION_CONTINUE_SENDING: connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; break; case MHD_CONNECTION_BODY_RECEIVING: if ((connection->rq.some_payload_processed) && has_unprocessed_upload_body_data_in_buffer (connection)) { /* Some data was processed, the buffer must have some free space */ mhd_assert (connection->read_buffer_offset < \ connection->read_buffer_size); if (! connection->rq.have_chunked_upload) { /* Not a chunked upload. Do not read more than necessary to process the current request. */ if (connection->rq.remaining_upload_size >= connection->read_buffer_offset) connection->event_loop_info = MHD_EVENT_LOOP_INFO_PROCESS; else connection->event_loop_info = MHD_EVENT_LOOP_INFO_PROCESS_READ; } else { /* Chunked upload. The size of the current request is unknown. Continue reading as the space in the read buffer is available. */ connection->event_loop_info = MHD_EVENT_LOOP_INFO_PROCESS_READ; } } else connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ; break; case MHD_CONNECTION_BODY_RECEIVED: mhd_assert (0); break; case MHD_CONNECTION_FOOTERS_RECEIVING: connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ; break; case MHD_CONNECTION_FOOTERS_RECEIVED: mhd_assert (0); break; case MHD_CONNECTION_FULL_REQ_RECEIVED: connection->event_loop_info = MHD_EVENT_LOOP_INFO_PROCESS; break; case MHD_CONNECTION_START_REPLY: mhd_assert (0); break; case MHD_CONNECTION_HEADERS_SENDING: /* headers in buffer, keep writing */ connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; break; case MHD_CONNECTION_HEADERS_SENT: mhd_assert (0); break; case MHD_CONNECTION_NORMAL_BODY_UNREADY: connection->event_loop_info = MHD_EVENT_LOOP_INFO_PROCESS; break; case MHD_CONNECTION_NORMAL_BODY_READY: connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; break; case MHD_CONNECTION_CHUNKED_BODY_UNREADY: connection->event_loop_info = MHD_EVENT_LOOP_INFO_PROCESS; break; case MHD_CONNECTION_CHUNKED_BODY_READY: connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; break; case MHD_CONNECTION_CHUNKED_BODY_SENT: mhd_assert (0); break; case MHD_CONNECTION_FOOTERS_SENDING: connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE; break; case MHD_CONNECTION_FULL_REPLY_SENT: mhd_assert (0); break; case MHD_CONNECTION_CLOSED: connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; return; /* do nothing, not even reading */ #ifdef UPGRADE_SUPPORT case MHD_CONNECTION_UPGRADE: mhd_assert (0); break; #endif /* UPGRADE_SUPPORT */ default: mhd_assert (0); } if (0 != (MHD_EVENT_LOOP_INFO_READ & connection->event_loop_info)) { /* Check whether the space is available to receive data */ if (! check_and_grow_read_buffer_space (connection)) { mhd_assert (connection->discard_request); continue; } } break; /* Everything was processed. */ } } /** * Add an entry to the HTTP headers of a connection. If this fails, * transmit an error response (request too big). * * @param cls the context (connection) * @param kind kind of the value * @param key key for the value * @param key_size number of bytes in @a key * @param value the value itself * @param value_size number of bytes in @a value * @return #MHD_NO on failure (out of memory), #MHD_YES for success */ static enum MHD_Result connection_add_header (void *cls, const char *key, size_t key_size, const char *value, size_t value_size, enum MHD_ValueKind kind) { struct MHD_Connection *connection = (struct MHD_Connection *) cls; if (MHD_NO == MHD_set_connection_value_n (connection, kind, key, key_size, value, value_size)) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Not enough memory in pool to allocate header record!\n")); #endif transmit_error_response_static (connection, MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, ERR_MSG_REQUEST_TOO_BIG); return MHD_NO; } return MHD_YES; } #ifdef COOKIE_SUPPORT /** * Cookie parsing result */ enum _MHD_ParseCookie { MHD_PARSE_COOKIE_OK = MHD_YES, /**< Success or no cookies in headers */ MHD_PARSE_COOKIE_OK_LAX = 2, /**< Cookies parsed, but workarounds used */ MHD_PARSE_COOKIE_MALFORMED = -1, /**< Invalid cookie header */ MHD_PARSE_COOKIE_NO_MEMORY = MHD_NO /**< Not enough memory in the pool */ }; /** * Parse the cookies string (see RFC 6265). * * Try to parse the cookies string even if it is not strictly formed * as specified by RFC 6265. * * @param str the string to parse, without leading whitespaces * @param str_len the size of the @a str, not including mandatory * zero-termination * @param connection the connection to add parsed cookies * @return #MHD_PARSE_COOKIE_OK for success, error code otherwise */ static enum _MHD_ParseCookie parse_cookies_string (char *str, const size_t str_len, struct MHD_Connection *connection) { size_t i; bool non_strict; /* Skip extra whitespaces and empty cookies */ const bool allow_wsp_empty = (0 >= connection->daemon->client_discipline); /* Allow whitespaces around '=' character */ const bool wsp_around_eq = (-3 >= connection->daemon->client_discipline); /* Allow whitespaces in quoted cookie value */ const bool wsp_in_quoted = (-2 >= connection->daemon->client_discipline); /* Allow tab as space after semicolon between cookies */ const bool tab_as_sp = (0 >= connection->daemon->client_discipline); /* Allow no space after semicolon between cookies */ const bool allow_no_space = (0 >= connection->daemon->client_discipline); non_strict = false; i = 0; while (i < str_len) { size_t name_start; size_t name_len; size_t value_start; size_t value_len; bool val_quoted; /* Skip any whitespaces and empty cookies */ while (' ' == str[i] || '\t' == str[i] || ';' == str[i]) { if (! allow_wsp_empty) return MHD_PARSE_COOKIE_MALFORMED; non_strict = true; i++; if (i == str_len) return non_strict? MHD_PARSE_COOKIE_OK_LAX : MHD_PARSE_COOKIE_OK; } /* 'i' must point to the first char of cookie-name */ name_start = i; /* Find the end of the cookie-name */ do { const char l = str[i]; if (('=' == l) || (' ' == l) || ('\t' == l) || ('"' == l) || (',' == l) || (';' == l) || (0 == l)) break; } while (str_len > ++i); name_len = i - name_start; /* Skip any whitespaces */ while (str_len > i && (' ' == str[i] || '\t' == str[i])) { if (! wsp_around_eq) return MHD_PARSE_COOKIE_MALFORMED; non_strict = true; i++; } if ((str_len == i) || ('=' != str[i]) || (0 == name_len)) return MHD_PARSE_COOKIE_MALFORMED; /* Incomplete cookie name */ /* 'i' must point to the '=' char */ mhd_assert ('=' == str[i]); i++; /* Skip any whitespaces */ while (str_len > i && (' ' == str[i] || '\t' == str[i])) { if (! wsp_around_eq) return MHD_PARSE_COOKIE_MALFORMED; non_strict = true; i++; } /* 'i' must point to the first char of cookie-value */ if (str_len == i) { value_start = 0; value_len = 0; #ifdef _DEBUG val_quoted = false; /* This assignment used in assert */ #endif } else { bool valid_cookie; val_quoted = ('"' == str[i]); if (val_quoted) i++; value_start = i; /* Find the end of the cookie-value */ while (str_len > i) { const char l = str[i]; if ((';' == l) || ('"' == l) || (',' == l) || (';' == l) || ('\\' == l) || (0 == l)) break; if ((' ' == l) || ('\t' == l)) { if (! val_quoted) break; if (! wsp_in_quoted) return MHD_PARSE_COOKIE_MALFORMED; non_strict = true; } i++; } value_len = i - value_start; if (val_quoted) { if ((str_len == i) || ('"' != str[i])) return MHD_PARSE_COOKIE_MALFORMED; /* Incomplete cookie value, no closing quote */ i++; } /* Skip any whitespaces */ if ((str_len > i) && ((' ' == str[i]) || ('\t' == str[i]))) { do { i++; } while (str_len > i && (' ' == str[i] || '\t' == str[i])); /* Whitespace at the end? */ if (str_len > i) { if (! allow_wsp_empty) return MHD_PARSE_COOKIE_MALFORMED; non_strict = true; } } if (str_len == i) valid_cookie = true; else if (';' == str[i]) valid_cookie = true; else valid_cookie = false; if (! valid_cookie) return MHD_PARSE_COOKIE_MALFORMED; /* Garbage at the end of the cookie value */ } mhd_assert (0 != name_len); str[name_start + name_len] = 0; /* Zero-terminate the name */ if (0 != value_len) { mhd_assert (value_start + value_len <= str_len); str[value_start + value_len] = 0; /* Zero-terminate the value */ if (MHD_NO == MHD_set_connection_value_n_nocheck_ (connection, MHD_COOKIE_KIND, str + name_start, name_len, str + value_start, value_len)) return MHD_PARSE_COOKIE_NO_MEMORY; } else { if (MHD_NO == MHD_set_connection_value_n_nocheck_ (connection, MHD_COOKIE_KIND, str + name_start, name_len, "", 0)) return MHD_PARSE_COOKIE_NO_MEMORY; } if (str_len > i) { mhd_assert (0 == str[i] || ';' == str[i]); mhd_assert (! val_quoted || ';' == str[i]); mhd_assert (';' != str[i] || val_quoted || non_strict || 0 == value_len); i++; if (str_len == i) { /* No next cookie after semicolon */ if (! allow_wsp_empty) return MHD_PARSE_COOKIE_MALFORMED; non_strict = true; } else if (' ' != str[i]) {/* No space after semicolon */ if (('\t' == str[i]) && tab_as_sp) i++; else if (! allow_no_space) return MHD_PARSE_COOKIE_MALFORMED; non_strict = true; } else { i++; if (str_len == i) { if (! allow_wsp_empty) return MHD_PARSE_COOKIE_MALFORMED; non_strict = true; } } } } return non_strict? MHD_PARSE_COOKIE_OK_LAX : MHD_PARSE_COOKIE_OK; } /** * Parse the cookie header (see RFC 6265). * * @param connection connection to parse header of * @return #MHD_PARSE_COOKIE_OK for success, error code otherwise */ static enum _MHD_ParseCookie parse_cookie_header (struct MHD_Connection *connection) { const char *hdr; size_t hdr_len; char *cpy; size_t i; enum _MHD_ParseCookie parse_res; struct MHD_HTTP_Req_Header *const saved_tail = connection->rq.headers_received_tail; const bool allow_partially_correct_cookie = (1 >= connection->daemon->client_discipline); if (MHD_NO == MHD_lookup_connection_value_n (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_COOKIE, MHD_STATICSTR_LEN_ ( MHD_HTTP_HEADER_COOKIE), &hdr, &hdr_len)) return MHD_PARSE_COOKIE_OK; if (0 == hdr_len) return MHD_PARSE_COOKIE_OK; cpy = MHD_connection_alloc_memory_ (connection, hdr_len + 1); if (NULL == cpy) parse_res = MHD_PARSE_COOKIE_NO_MEMORY; else { memcpy (cpy, hdr, hdr_len); cpy[hdr_len] = '\0'; i = 0; /* Skip all initial whitespaces */ while (i < hdr_len && (' ' == cpy[i] || '\t' == cpy[i])) i++; parse_res = parse_cookies_string (cpy + i, hdr_len - i, connection); } switch (parse_res) { case MHD_PARSE_COOKIE_OK: break; case MHD_PARSE_COOKIE_OK_LAX: #ifdef HAVE_MESSAGES if (saved_tail != connection->rq.headers_received_tail) MHD_DLOG (connection->daemon, _ ("The Cookie header has been parsed, but it is not fully " "compliant with the standard.\n")); #endif /* HAVE_MESSAGES */ break; case MHD_PARSE_COOKIE_MALFORMED: if (saved_tail != connection->rq.headers_received_tail) { if (! allow_partially_correct_cookie) { /* Remove extracted values from partially broken cookie */ /* Memory remains allocated until the end of the request processing */ connection->rq.headers_received_tail = saved_tail; saved_tail->next = NULL; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The Cookie header has been ignored as it contains " "malformed data.\n")); #endif /* HAVE_MESSAGES */ } #ifdef HAVE_MESSAGES else MHD_DLOG (connection->daemon, _ ("The Cookie header has been only partially parsed as it " "contains malformed data.\n")); #endif /* HAVE_MESSAGES */ } #ifdef HAVE_MESSAGES else MHD_DLOG (connection->daemon, _ ("The Cookie header has malformed data.\n")); #endif /* HAVE_MESSAGES */ break; case MHD_PARSE_COOKIE_NO_MEMORY: #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Not enough memory in the connection pool to " "parse client cookies!\n")); #endif /* HAVE_MESSAGES */ break; default: mhd_assert (0); break; } #ifndef HAVE_MESSAGES (void) saved_tail; /* Mute compiler warning */ #endif /* ! HAVE_MESSAGES */ return parse_res; } #endif /* COOKIE_SUPPORT */ /** * The valid length of any HTTP version string */ #define HTTP_VER_LEN (MHD_STATICSTR_LEN_ (MHD_HTTP_VERSION_1_1)) /** * Detect HTTP version, send error response if version is not supported * * @param connection the connection * @param http_string the pointer to HTTP version string * @param len the length of @a http_string in bytes * @return true if HTTP version is correct and supported, * false if HTTP version is not correct or unsupported. */ static bool parse_http_version (struct MHD_Connection *connection, const char *http_string, size_t len) { const char *const h = http_string; /**< short alias */ mhd_assert (NULL != http_string); /* String must start with 'HTTP/d.d', case-sensetive match. * See https://www.rfc-editor.org/rfc/rfc9112#name-http-version */ if ((HTTP_VER_LEN != len) || ('H' != h[0]) || ('T' != h[1]) || ('T' != h[2]) || ('P' != h[3]) || ('/' != h[4]) || ('.' != h[6]) || (('0' > h[5]) || ('9' < h[5])) || (('0' > h[7]) || ('9' < h[7]))) { connection->rq.http_ver = MHD_HTTP_VER_INVALID; transmit_error_response_static (connection, MHD_HTTP_BAD_REQUEST, REQUEST_MALFORMED); return false; } if (1 == h[5] - '0') { /* HTTP/1.x */ if (1 == h[7] - '0') connection->rq.http_ver = MHD_HTTP_VER_1_1; else if (0 == h[7] - '0') connection->rq.http_ver = MHD_HTTP_VER_1_0; else connection->rq.http_ver = MHD_HTTP_VER_1_2__1_9; return true; } if (0 == h[5] - '0') { /* Too old major version */ connection->rq.http_ver = MHD_HTTP_VER_TOO_OLD; transmit_error_response_static (connection, MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED, REQ_HTTP_VER_IS_TOO_OLD); return false; } connection->rq.http_ver = MHD_HTTP_VER_FUTURE; transmit_error_response_static (connection, MHD_HTTP_HTTP_VERSION_NOT_SUPPORTED, REQ_HTTP_VER_IS_NOT_SUPPORTED); return false; } /** * Detect standard HTTP request method * * @param connection the connection * @param method the pointer to HTTP request method string * @param len the length of @a method in bytes */ static void parse_http_std_method (struct MHD_Connection *connection, const char *method, size_t len) { const char *const m = method; /**< short alias */ mhd_assert (NULL != m); mhd_assert (0 != len); if ((MHD_STATICSTR_LEN_ (MHD_HTTP_METHOD_GET) == len) && (0 == memcmp (m, MHD_HTTP_METHOD_GET, len))) connection->rq.http_mthd = MHD_HTTP_MTHD_GET; else if ((MHD_STATICSTR_LEN_ (MHD_HTTP_METHOD_HEAD) == len) && (0 == memcmp (m, MHD_HTTP_METHOD_HEAD, len))) connection->rq.http_mthd = MHD_HTTP_MTHD_HEAD; else if ((MHD_STATICSTR_LEN_ (MHD_HTTP_METHOD_POST) == len) && (0 == memcmp (m, MHD_HTTP_METHOD_POST, len))) connection->rq.http_mthd = MHD_HTTP_MTHD_POST; else if ((MHD_STATICSTR_LEN_ (MHD_HTTP_METHOD_PUT) == len) && (0 == memcmp (m, MHD_HTTP_METHOD_PUT, len))) connection->rq.http_mthd = MHD_HTTP_MTHD_PUT; else if ((MHD_STATICSTR_LEN_ (MHD_HTTP_METHOD_DELETE) == len) && (0 == memcmp (m, MHD_HTTP_METHOD_DELETE, len))) connection->rq.http_mthd = MHD_HTTP_MTHD_DELETE; else if ((MHD_STATICSTR_LEN_ (MHD_HTTP_METHOD_CONNECT) == len) && (0 == memcmp (m, MHD_HTTP_METHOD_CONNECT, len))) connection->rq.http_mthd = MHD_HTTP_MTHD_CONNECT; else if ((MHD_STATICSTR_LEN_ (MHD_HTTP_METHOD_OPTIONS) == len) && (0 == memcmp (m, MHD_HTTP_METHOD_OPTIONS, len))) connection->rq.http_mthd = MHD_HTTP_MTHD_OPTIONS; else if ((MHD_STATICSTR_LEN_ (MHD_HTTP_METHOD_TRACE) == len) && (0 == memcmp (m, MHD_HTTP_METHOD_TRACE, len))) connection->rq.http_mthd = MHD_HTTP_MTHD_TRACE; else connection->rq.http_mthd = MHD_HTTP_MTHD_OTHER; } /** * Call the handler of the application for this * connection. Handles chunking of the upload * as well as normal uploads. * * @param connection connection we're processing */ static void call_connection_handler (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; size_t processed; if (NULL != connection->rp.response) return; /* already queued a response */ processed = 0; connection->rq.client_aware = true; connection->in_access_handler = true; if (MHD_NO == daemon->default_handler (daemon->default_handler_cls, connection, connection->rq.url, connection->rq.method, connection->rq.version, NULL, &processed, &connection->rq.client_context)) { connection->in_access_handler = false; /* serious internal error, close connection */ CONNECTION_CLOSE_ERROR (connection, _ ("Application reported internal error, " \ "closing connection.")); return; } connection->in_access_handler = false; } /** * Call the handler of the application for this * connection. Handles chunking of the upload * as well as normal uploads. * * @param connection connection we're processing */ static void process_request_body (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; size_t available; bool instant_retry; char *buffer_head; const int discp_lvl = daemon->client_discipline; /* Treat bare LF as the end of the line. RFC 9112, section 2.2-3 Note: MHD never replaces bare LF with space (RFC 9110, section 5.5-5). Bare LF is processed as end of the line or rejected as broken request. */ const bool bare_lf_as_crlf = MHD_ALLOW_BARE_LF_AS_CRLF_ (discp_lvl); /* Allow "Bad WhiteSpace" in chunk extension. RFC 9112, Section 7.1.1, Paragraph 2 */ const bool allow_bws = (2 < discp_lvl); mhd_assert (NULL == connection->rp.response); buffer_head = connection->read_buffer; available = connection->read_buffer_offset; do { size_t to_be_processed; size_t left_unprocessed; size_t processed_size; instant_retry = false; if (connection->rq.have_chunked_upload) { mhd_assert (MHD_SIZE_UNKNOWN == connection->rq.remaining_upload_size); if ( (connection->rq.current_chunk_offset == connection->rq.current_chunk_size) && (0 != connection->rq.current_chunk_size) ) { size_t i; mhd_assert (0 != available); /* skip new line at the *end* of a chunk */ i = 0; if ( (2 <= available) && ('\r' == buffer_head[0]) && ('\n' == buffer_head[1]) ) i += 2; /* skip CRLF */ else if (bare_lf_as_crlf && ('\n' == buffer_head[0])) i++; /* skip bare LF */ else if (2 > available) break; /* need more upload data */ if (0 == i) { /* malformed encoding */ transmit_error_response_static (connection, MHD_HTTP_BAD_REQUEST, REQUEST_CHUNKED_MALFORMED); return; } available -= i; buffer_head += i; connection->rq.current_chunk_offset = 0; connection->rq.current_chunk_size = 0; if (0 == available) break; } if (0 != connection->rq.current_chunk_size) { uint64_t cur_chunk_left; mhd_assert (connection->rq.current_chunk_offset < \ connection->rq.current_chunk_size); /* we are in the middle of a chunk, give as much as possible to the client (without crossing chunk boundaries) */ cur_chunk_left = connection->rq.current_chunk_size - connection->rq.current_chunk_offset; if (cur_chunk_left > available) to_be_processed = available; else { /* cur_chunk_left <= (size_t)available */ to_be_processed = (size_t) cur_chunk_left; if (available > to_be_processed) instant_retry = true; } } else { /* Need the parse the chunk size line */ /** The number of found digits in the chunk size number */ size_t num_dig; uint64_t chunk_size; bool broken; bool overflow; mhd_assert (0 != available); overflow = false; chunk_size = 0; /* Mute possible compiler warning. The real value will be set later. */ num_dig = MHD_strx_to_uint64_n_ (buffer_head, available, &chunk_size); mhd_assert (num_dig <= available); if (num_dig == available) continue; /* Need line delimiter */ broken = (0 == num_dig); if (broken) /* Check whether result is invalid due to uint64_t overflow */ overflow = ((('0' <= buffer_head[0]) && ('9' >= buffer_head[0])) || (('A' <= buffer_head[0]) && ('F' >= buffer_head[0])) || (('a' <= buffer_head[0]) && ('f' >= buffer_head[0]))); else { /** * The length of the string with the number of the chunk size, * including chunk extension */ size_t chunk_size_line_len; chunk_size_line_len = 0; if ((';' == buffer_head[num_dig]) || (allow_bws && ((' ' == buffer_head[num_dig]) || ('\t' == buffer_head[num_dig])))) { /* Chunk extension */ size_t i; /* Skip bad whitespaces (if any) */ for (i = num_dig; i < available; ++i) { if ((' ' != buffer_head[i]) && ('\t' != buffer_head[i])) break; } if (i == available) break; /* need more data */ if (';' == buffer_head[i]) { for (++i; i < available; ++i) { if ('\n' == buffer_head[i]) break; } if (i == available) break; /* need more data */ mhd_assert (i > num_dig); mhd_assert (1 <= i); /* Found LF position */ if (bare_lf_as_crlf) chunk_size_line_len = i; /* Don't care about CR before LF */ else if ('\r' == buffer_head[i - 1]) chunk_size_line_len = i; } else { /* No ';' after "bad whitespace" */ mhd_assert (allow_bws); mhd_assert (0 == chunk_size_line_len); } } else { mhd_assert (available >= num_dig); if ((2 <= (available - num_dig)) && ('\r' == buffer_head[num_dig]) && ('\n' == buffer_head[num_dig + 1])) chunk_size_line_len = num_dig + 2; else if (bare_lf_as_crlf && ('\n' == buffer_head[num_dig])) chunk_size_line_len = num_dig + 1; else if (2 > (available - num_dig)) break; /* need more data */ } if (0 != chunk_size_line_len) { /* Valid termination of the chunk size line */ mhd_assert (chunk_size_line_len <= available); /* Start reading payload data of the chunk */ connection->rq.current_chunk_offset = 0; connection->rq.current_chunk_size = chunk_size; available -= chunk_size_line_len; buffer_head += chunk_size_line_len; if (0 == chunk_size) { /* The final (termination) chunk */ connection->rq.remaining_upload_size = 0; break; } if (available > 0) instant_retry = true; continue; } /* Invalid chunk size line */ } if (! overflow) transmit_error_response_static (connection, MHD_HTTP_BAD_REQUEST, REQUEST_CHUNKED_MALFORMED); else transmit_error_response_static (connection, MHD_HTTP_CONTENT_TOO_LARGE, REQUEST_CHUNK_TOO_LARGE); return; } } else { /* no chunked encoding, give all to the client */ mhd_assert (MHD_SIZE_UNKNOWN != connection->rq.remaining_upload_size); mhd_assert (0 != connection->rq.remaining_upload_size); if (connection->rq.remaining_upload_size < available) to_be_processed = (size_t) connection->rq.remaining_upload_size; else to_be_processed = available; } left_unprocessed = to_be_processed; connection->rq.client_aware = true; connection->in_access_handler = true; if (MHD_NO == daemon->default_handler (daemon->default_handler_cls, connection, connection->rq.url, connection->rq.method, connection->rq.version, buffer_head, &left_unprocessed, &connection->rq.client_context)) { connection->in_access_handler = false; /* serious internal error, close connection */ CONNECTION_CLOSE_ERROR (connection, _ ("Application reported internal error, " \ "closing connection.")); return; } connection->in_access_handler = false; if (left_unprocessed > to_be_processed) MHD_PANIC (_ ("libmicrohttpd API violation.\n")); connection->rq.some_payload_processed = (left_unprocessed != to_be_processed); if (0 != left_unprocessed) { instant_retry = false; /* client did not process everything */ #ifdef HAVE_MESSAGES if ((! connection->rq.some_payload_processed) && (! connection->suspended)) { /* client did not process any upload data, complain if the setup was incorrect, which may prevent us from handling the rest of the request */ if (MHD_D_IS_USING_THREADS_ (daemon)) MHD_DLOG (daemon, _ ("WARNING: Access Handler Callback has not processed " \ "any upload data and connection is not suspended. " \ "This may result in hung connection.\n")); } #endif /* HAVE_MESSAGES */ } processed_size = to_be_processed - left_unprocessed; /* dh left "processed" bytes in buffer for next time... */ buffer_head += processed_size; available -= processed_size; if (! connection->rq.have_chunked_upload) { mhd_assert (MHD_SIZE_UNKNOWN != connection->rq.remaining_upload_size); connection->rq.remaining_upload_size -= processed_size; } else { mhd_assert (MHD_SIZE_UNKNOWN == connection->rq.remaining_upload_size); connection->rq.current_chunk_offset += processed_size; } } while (instant_retry); /* TODO: zero out reused memory region */ if ( (available > 0) && (buffer_head != connection->read_buffer) ) memmove (connection->read_buffer, buffer_head, available); else mhd_assert ((0 == available) || \ (connection->read_buffer_offset == available)); connection->read_buffer_offset = available; } /** * Check if we are done sending the write-buffer. * If so, transition into "next_state". * * @param connection connection to check write status for * @param next_state the next state to transition to * @return #MHD_NO if we are not done, #MHD_YES if we are */ static enum MHD_Result check_write_done (struct MHD_Connection *connection, enum MHD_CONNECTION_STATE next_state) { if ( (connection->write_buffer_append_offset != connection->write_buffer_send_offset) /* || data_in_tls_buffers == true */ ) return MHD_NO; connection->write_buffer_append_offset = 0; connection->write_buffer_send_offset = 0; connection->state = next_state; return MHD_YES; } /** * Parse the various headers; figure out the size * of the upload and make sure the headers follow * the protocol. Advance to the appropriate state. * * @param connection connection we're processing */ static void parse_connection_headers (struct MHD_Connection *connection) { const char *clen; const char *enc; size_t val_len; #ifdef COOKIE_SUPPORT if (MHD_PARSE_COOKIE_NO_MEMORY == parse_cookie_header (connection)) { handle_req_cookie_no_space (connection); return; } #endif /* COOKIE_SUPPORT */ if ( (-3 < connection->daemon->client_discipline) && (MHD_IS_HTTP_VER_1_1_COMPAT (connection->rq.http_ver)) && (MHD_NO == MHD_lookup_connection_value_n (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST, MHD_STATICSTR_LEN_ ( MHD_HTTP_HEADER_HOST), NULL, NULL)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Received HTTP/1.1 request without `Host' header.\n")); #endif transmit_error_response_static (connection, MHD_HTTP_BAD_REQUEST, REQUEST_LACKS_HOST); return; } /* The presence of the request body is indicated by "Content-Length:" or "Transfer-Encoding:" request headers. Unless one of these two headers is used, the request has no request body. See RFC9112, Section 6, paragraph 4. */ connection->rq.remaining_upload_size = 0; if (MHD_NO != MHD_lookup_connection_value_n (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_TRANSFER_ENCODING, MHD_STATICSTR_LEN_ ( MHD_HTTP_HEADER_TRANSFER_ENCODING), &enc, NULL)) { if (! MHD_str_equal_caseless_ (enc, "chunked")) { transmit_error_response_static (connection, MHD_HTTP_BAD_REQUEST, REQUEST_UNSUPPORTED_TR_ENCODING); return; } else if (MHD_NO != MHD_lookup_connection_value_n (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_LENGTH, MHD_STATICSTR_LEN_ ( \ MHD_HTTP_HEADER_CONTENT_LENGTH), NULL, NULL)) { /* TODO: add individual settings */ if (1 <= connection->daemon->client_discipline) { transmit_error_response_static (connection, MHD_HTTP_BAD_REQUEST, REQUEST_LENGTH_WITH_TR_ENCODING); return; } else { /* Must close connection after reply to prevent potential attack */ connection->keepalive = MHD_CONN_MUST_CLOSE; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The 'Content-Length' request header is ignored " "as chunked Transfer-Encoding is used " "for this request.\n")); #endif /* HAVE_MESSAGES */ } } connection->rq.have_chunked_upload = true; connection->rq.remaining_upload_size = MHD_SIZE_UNKNOWN; } else if (MHD_NO != MHD_lookup_connection_value_n (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_LENGTH, MHD_STATICSTR_LEN_ ( MHD_HTTP_HEADER_CONTENT_LENGTH), &clen, &val_len)) { size_t num_digits; num_digits = MHD_str_to_uint64_n_ (clen, val_len, &connection->rq.remaining_upload_size); if (((0 == num_digits) && (0 != val_len) && ('0' <= clen[0]) && ('9' >= clen[0])) || (MHD_SIZE_UNKNOWN == connection->rq.remaining_upload_size)) { connection->rq.remaining_upload_size = 0; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Too large value of 'Content-Length' header. " \ "Closing connection.\n")); #endif transmit_error_response_static (connection, MHD_HTTP_CONTENT_TOO_LARGE, REQUEST_CONTENTLENGTH_TOOLARGE); } else if ((val_len != num_digits) || (0 == num_digits)) { connection->rq.remaining_upload_size = 0; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Failed to parse 'Content-Length' header. " \ "Closing connection.\n")); #endif transmit_error_response_static (connection, MHD_HTTP_BAD_REQUEST, REQUEST_CONTENTLENGTH_MALFORMED); } } } /** * Reset request header processing state. * * This function resets the processing state before processing the next header * (or footer) line. * @param c the connection to process */ _MHD_static_inline void reset_rq_header_processing_state (struct MHD_Connection *c) { memset (&c->rq.hdrs.hdr, 0, sizeof(c->rq.hdrs.hdr)); } /** * Switch to request headers (field lines) processing state. * @param c the connection to process */ _MHD_static_inline void switch_to_rq_headers_processing (struct MHD_Connection *c) { c->rq.field_lines.start = c->read_buffer; memset (&c->rq.hdrs.hdr, 0, sizeof(c->rq.hdrs.hdr)); c->state = MHD_CONNECTION_REQ_HEADERS_RECEIVING; } #ifndef MHD_MAX_EMPTY_LINES_SKIP /** * The maximum number of ignored empty line before the request line * at default "strictness" level. */ #define MHD_MAX_EMPTY_LINES_SKIP 1024 #endif /* ! MHD_MAX_EMPTY_LINES_SKIP */ /** * Find and parse the request line. * @param c the connection to process * @return true if request line completely processed (or unrecoverable error * found) and state is changed, * false if not enough data yet in the receive buffer */ static bool get_request_line_inner (struct MHD_Connection *c) { size_t p; /**< The current processing position */ const int discp_lvl = c->daemon->client_discipline; /* Allow to skip one or more empty lines before the request line. RFC 9112, section 2.2 */ const bool skip_empty_lines = (1 >= discp_lvl); /* Allow to skip more then one empty line before the request line. RFC 9112, section 2.2 */ const bool skip_several_empty_lines = (skip_empty_lines && (0 >= discp_lvl)); /* Allow to skip number of unlimited empty lines before the request line. RFC 9112, section 2.2 */ const bool skip_unlimited_empty_lines = (skip_empty_lines && (-3 >= discp_lvl)); /* Treat bare LF as the end of the line. RFC 9112, section 2.2 */ const bool bare_lf_as_crlf = MHD_ALLOW_BARE_LF_AS_CRLF_ (discp_lvl); /* Treat tab as whitespace delimiter. RFC 9112, section 3 */ const bool tab_as_wsp = (0 >= discp_lvl); /* Treat VT (vertical tab) and FF (form feed) as whitespace delimiters. RFC 9112, section 3 */ const bool other_wsp_as_wsp = (-1 >= discp_lvl); /* Treat continuous whitespace block as a single space. RFC 9112, section 3 */ const bool wsp_blocks = (-1 >= discp_lvl); /* Parse whitespace in URI, special parsing of the request line. RFC 9112, section 3.2 */ const bool wsp_in_uri = (0 >= discp_lvl); /* Keep whitespace in URI, give app URI with whitespace instead of automatic redirect to fixed URI. Violates RFC 9112, section 3.2 */ const bool wsp_in_uri_keep = (-2 >= discp_lvl); /* Keep bare CR character as is. Violates RFC 9112, section 2.2 */ const bool bare_cr_keep = (wsp_in_uri_keep && (-3 >= discp_lvl)); /* Treat bare CR as space; replace it with space before processing. RFC 9112, section 2.2 */ const bool bare_cr_as_sp = ((! bare_cr_keep) && (-1 >= discp_lvl)); mhd_assert (MHD_CONNECTION_INIT == c->state || \ MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); mhd_assert (NULL == c->rq.method || \ MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); mhd_assert (MHD_HTTP_MTHD_NO_METHOD == c->rq.http_mthd || \ MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); mhd_assert (MHD_HTTP_MTHD_NO_METHOD == c->rq.http_mthd || \ 0 != c->rq.hdrs.rq_line.proc_pos); if (0 == c->read_buffer_offset) { mhd_assert (MHD_CONNECTION_INIT == c->state); return false; /* No data to process */ } p = c->rq.hdrs.rq_line.proc_pos; mhd_assert (p <= c->read_buffer_offset); /* Skip empty lines, if any (and if allowed) */ /* See RFC 9112, section 2.2 */ if ((0 == p) && (skip_empty_lines)) { /* Skip empty lines before the request line. See RFC 9112, section 2.2 */ bool is_empty_line; mhd_assert (MHD_CONNECTION_INIT == c->state); mhd_assert (NULL == c->rq.method); mhd_assert (NULL == c->rq.url); mhd_assert (0 == c->rq.url_len); mhd_assert (NULL == c->rq.hdrs.rq_line.rq_tgt); mhd_assert (0 == c->rq.req_target_len); mhd_assert (NULL == c->rq.version); do { is_empty_line = false; if ('\r' == c->read_buffer[0]) { if (1 == c->read_buffer_offset) return false; /* Not enough data yet */ if ('\n' == c->read_buffer[1]) { is_empty_line = true; c->read_buffer += 2; c->read_buffer_size -= 2; c->read_buffer_offset -= 2; c->rq.hdrs.rq_line.skipped_empty_lines++; } } else if (('\n' == c->read_buffer[0]) && (bare_lf_as_crlf)) { is_empty_line = true; c->read_buffer += 1; c->read_buffer_size -= 1; c->read_buffer_offset -= 1; c->rq.hdrs.rq_line.skipped_empty_lines++; } if (is_empty_line) { if ((! skip_unlimited_empty_lines) && (((unsigned int) ((skip_several_empty_lines) ? MHD_MAX_EMPTY_LINES_SKIP : 1)) < c->rq.hdrs.rq_line.skipped_empty_lines)) { connection_close_error (c, _ ("Too many meaningless extra empty lines " \ "received before the request")); return true; /* Process connection closure */ } if (0 == c->read_buffer_offset) return false; /* No more data to process */ } } while (is_empty_line); } /* All empty lines are skipped */ c->state = MHD_CONNECTION_REQ_LINE_RECEIVING; /* Read and parse the request line */ mhd_assert (1 <= c->read_buffer_offset); while (p < c->read_buffer_offset) { const char chr = c->read_buffer[p]; bool end_of_line; /* The processing logic is different depending on the configured strictness: When whitespace BLOCKS are NOT ALLOWED, the end of the whitespace is processed BEFORE processing of the current character. When whitespace BLOCKS are ALLOWED, the end of the whitespace is processed AFTER processing of the current character. When space char in the URI is ALLOWED, the delimiter between the URI and the HTTP version string is processed only at the END of the line. When space in the URI is NOT ALLOWED, the delimiter between the URI and the HTTP version string is processed as soon as the FIRST whitespace is found after URI start. */ end_of_line = false; mhd_assert ((0 == c->rq.hdrs.rq_line.last_ws_end) || \ (c->rq.hdrs.rq_line.last_ws_end > \ c->rq.hdrs.rq_line.last_ws_start)); mhd_assert ((0 == c->rq.hdrs.rq_line.last_ws_start) || \ (0 != c->rq.hdrs.rq_line.last_ws_end)); /* Check for the end of the line */ if ('\r' == chr) { if (p + 1 == c->read_buffer_offset) { c->rq.hdrs.rq_line.proc_pos = p; return false; /* Not enough data yet */ } else if ('\n' == c->read_buffer[p + 1]) end_of_line = true; else { /* Bare CR alone */ /* Must be rejected or replaced with space char. See RFC 9112, section 2.2 */ if (bare_cr_as_sp) { c->read_buffer[p] = ' '; c->rq.num_cr_sp_replaced++; continue; /* Re-start processing of the current character */ } else if (! bare_cr_keep) { /* A quick simple check whether this line looks like an HTTP request */ if ((MHD_HTTP_MTHD_GET <= c->rq.http_mthd) && (MHD_HTTP_MTHD_DELETE >= c->rq.http_mthd)) { transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, BARE_CR_IN_HEADER); } else connection_close_error (c, _ ("Bare CR characters are not allowed " \ "in the request line.\n")); return true; /* Error in the request */ } } } else if ('\n' == chr) { /* Bare LF may be recognised as a line delimiter. See RFC 9112, section 2.2 */ if (bare_lf_as_crlf) end_of_line = true; else { /* While RFC does not enforce error for bare LF character, if this char is not treated as a line delimiter, it should be rejected to avoid any security weakness due to request smuggling. */ /* A quick simple check whether this line looks like an HTTP request */ if ((MHD_HTTP_MTHD_GET <= c->rq.http_mthd) && (MHD_HTTP_MTHD_DELETE >= c->rq.http_mthd)) { transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, BARE_LF_IN_HEADER); } else connection_close_error (c, _ ("Bare LF characters are not allowed " \ "in the request line.\n")); return true; /* Error in the request */ } } if (end_of_line) { /* Handle the end of the request line */ if (NULL != c->rq.method) { if (wsp_in_uri) { /* The end of the URI and the start of the HTTP version string should be determined now. */ mhd_assert (NULL == c->rq.version); mhd_assert (0 == c->rq.req_target_len); if (0 != c->rq.hdrs.rq_line.last_ws_end) { /* Determine the end and the length of the URI */ if (NULL != c->rq.hdrs.rq_line.rq_tgt) { c->read_buffer [c->rq.hdrs.rq_line.last_ws_start] = 0; /* Zero terminate the URI */ c->rq.req_target_len = c->rq.hdrs.rq_line.last_ws_start - (size_t) (c->rq.hdrs.rq_line.rq_tgt - c->read_buffer); } else if ((c->rq.hdrs.rq_line.last_ws_start + 1 < c->rq.hdrs.rq_line.last_ws_end) && (HTTP_VER_LEN == (p - c->rq.hdrs.rq_line.last_ws_end))) { /* Found only HTTP method and HTTP version and more than one whitespace between them. Assume zero-length URI. */ mhd_assert (wsp_blocks); c->rq.hdrs.rq_line.last_ws_start++; c->read_buffer[c->rq.hdrs.rq_line.last_ws_start] = 0; /* Zero terminate the URI */ c->rq.hdrs.rq_line.rq_tgt = c->read_buffer + c->rq.hdrs.rq_line.last_ws_start; c->rq.req_target_len = 0; c->rq.hdrs.rq_line.num_ws_in_uri = 0; c->rq.hdrs.rq_line.rq_tgt_qmark = NULL; } /* Determine the start of the HTTP version string */ if (NULL != c->rq.hdrs.rq_line.rq_tgt) { c->rq.version = c->read_buffer + c->rq.hdrs.rq_line.last_ws_end; } } } else { /* The end of the URI and the start of the HTTP version string should be already known. */ if ((NULL == c->rq.version) && (NULL != c->rq.hdrs.rq_line.rq_tgt) && (HTTP_VER_LEN == p - (size_t) (c->rq.hdrs.rq_line.rq_tgt - c->read_buffer)) && (0 != c->read_buffer[(size_t) (c->rq.hdrs.rq_line.rq_tgt - c->read_buffer) - 1])) { /* Found only HTTP method and HTTP version and more than one whitespace between them. Assume zero-length URI. */ size_t uri_pos; mhd_assert (wsp_blocks); mhd_assert (0 == c->rq.req_target_len); uri_pos = (size_t) (c->rq.hdrs.rq_line.rq_tgt - c->read_buffer) - 1; mhd_assert (uri_pos < p); c->rq.version = c->rq.hdrs.rq_line.rq_tgt; c->read_buffer[uri_pos] = 0; /* Zero terminate the URI */ c->rq.hdrs.rq_line.rq_tgt = c->read_buffer + uri_pos; c->rq.req_target_len = 0; c->rq.hdrs.rq_line.num_ws_in_uri = 0; c->rq.hdrs.rq_line.rq_tgt_qmark = NULL; } } if (NULL != c->rq.version) { mhd_assert (NULL != c->rq.hdrs.rq_line.rq_tgt); if (! parse_http_version (c, c->rq.version, p - (size_t) (c->rq.version - c->read_buffer))) { mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING < c->state); return true; /* Unsupported / broken HTTP version */ } c->read_buffer[p] = 0; /* Zero terminate the HTTP version strings */ if ('\r' == chr) { p++; /* Consume CR */ mhd_assert (p < c->read_buffer_offset); /* The next character has been already checked */ } p++; /* Consume LF */ c->read_buffer += p; c->read_buffer_size -= p; c->read_buffer_offset -= p; mhd_assert (c->rq.hdrs.rq_line.num_ws_in_uri <= \ c->rq.req_target_len); mhd_assert ((NULL == c->rq.hdrs.rq_line.rq_tgt_qmark) || \ (0 != c->rq.req_target_len)); mhd_assert ((NULL == c->rq.hdrs.rq_line.rq_tgt_qmark) || \ ((size_t) (c->rq.hdrs.rq_line.rq_tgt_qmark \ - c->rq.hdrs.rq_line.rq_tgt) < \ c->rq.req_target_len)); mhd_assert ((NULL == c->rq.hdrs.rq_line.rq_tgt_qmark) || \ (c->rq.hdrs.rq_line.rq_tgt_qmark >= \ c->rq.hdrs.rq_line.rq_tgt)); return true; /* The request line is successfully parsed */ } } /* Error in the request line */ /* A quick simple check whether this line looks like an HTTP request */ if ((MHD_HTTP_MTHD_GET <= c->rq.http_mthd) && (MHD_HTTP_MTHD_DELETE >= c->rq.http_mthd)) { transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, REQUEST_MALFORMED); } else connection_close_error (c, _ ("The request line is malformed.\n")); return true; } /* Process possible end of the previously found whitespace delimiter */ if ((! wsp_blocks) && (p == c->rq.hdrs.rq_line.last_ws_end) && (0 != c->rq.hdrs.rq_line.last_ws_end)) { /* Previous character was a whitespace char and whitespace blocks are not allowed. */ /* The current position is the next character after a whitespace delimiter */ if (NULL == c->rq.hdrs.rq_line.rq_tgt) { /* The current position is the start of the URI */ mhd_assert (0 == c->rq.req_target_len); mhd_assert (NULL == c->rq.version); c->rq.hdrs.rq_line.rq_tgt = c->read_buffer + p; /* Reset the whitespace marker */ c->rq.hdrs.rq_line.last_ws_start = 0; c->rq.hdrs.rq_line.last_ws_end = 0; } else { /* It was a whitespace after the start of the URI */ if (! wsp_in_uri) { mhd_assert ((0 != c->rq.req_target_len) || \ (c->rq.hdrs.rq_line.rq_tgt + 1 == c->read_buffer + p)); mhd_assert (NULL == c->rq.version); /* Too many whitespaces? This error is handled at whitespace start */ c->rq.version = c->read_buffer + p; /* Reset the whitespace marker */ c->rq.hdrs.rq_line.last_ws_start = 0; c->rq.hdrs.rq_line.last_ws_end = 0; } } } /* Process the current character. Is it not the end of the line. */ if ((' ' == chr) || (('\t' == chr) && (tab_as_wsp)) || ((other_wsp_as_wsp) && ((0xb == chr) || (0xc == chr)))) { /* A whitespace character */ if ((0 == c->rq.hdrs.rq_line.last_ws_end) || (p != c->rq.hdrs.rq_line.last_ws_end) || (! wsp_blocks)) { /* Found first whitespace char of the new whitespace block */ if (NULL == c->rq.method) { /* Found the end of the HTTP method string */ mhd_assert (0 == c->rq.hdrs.rq_line.last_ws_start); mhd_assert (0 == c->rq.hdrs.rq_line.last_ws_end); mhd_assert (NULL == c->rq.hdrs.rq_line.rq_tgt); mhd_assert (0 == c->rq.req_target_len); mhd_assert (NULL == c->rq.version); if (0 == p) { connection_close_error (c, _ ("The request line starts with " "a whitespace.\n")); return true; /* Error in the request */ } c->read_buffer[p] = 0; /* Zero-terminate the request method string */ c->rq.method = c->read_buffer; parse_http_std_method (c, c->rq.method, p); } else { /* A whitespace after the start of the URI */ if (! wsp_in_uri) { /* Whitespace in URI is not allowed to be parsed */ if (NULL == c->rq.version) { mhd_assert (NULL != c->rq.hdrs.rq_line.rq_tgt); /* This is a delimiter between URI and HTTP version string */ c->read_buffer[p] = 0; /* Zero-terminate request URI string */ mhd_assert (((size_t) (c->rq.hdrs.rq_line.rq_tgt \ - c->read_buffer)) <= p); c->rq.req_target_len = p - (size_t) (c->rq.hdrs.rq_line.rq_tgt - c->read_buffer); } else { /* This is a delimiter AFTER version string */ /* A quick simple check whether this line looks like an HTTP request */ if ((MHD_HTTP_MTHD_GET <= c->rq.http_mthd) && (MHD_HTTP_MTHD_DELETE >= c->rq.http_mthd)) { transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, RQ_LINE_TOO_MANY_WSP); } else connection_close_error (c, _ ("The request line has more than " "two whitespaces.\n")); return true; /* Error in the request */ } } else { /* Whitespace in URI is allowed to be parsed */ if (0 != c->rq.hdrs.rq_line.last_ws_end) { /* The whitespace after the start of the URI has been found already */ c->rq.hdrs.rq_line.num_ws_in_uri += c->rq.hdrs.rq_line.last_ws_end - c->rq.hdrs.rq_line.last_ws_start; } } } c->rq.hdrs.rq_line.last_ws_start = p; c->rq.hdrs.rq_line.last_ws_end = p + 1; /* Will be updated on the next char parsing */ } else { /* Continuation of the whitespace block */ mhd_assert (0 != c->rq.hdrs.rq_line.last_ws_end); mhd_assert (0 != p); c->rq.hdrs.rq_line.last_ws_end = p + 1; } } else { /* Non-whitespace char, not the end of the line */ mhd_assert ((0 == c->rq.hdrs.rq_line.last_ws_end) || \ (c->rq.hdrs.rq_line.last_ws_end == p) || \ wsp_in_uri); if ((p == c->rq.hdrs.rq_line.last_ws_end) && (0 != c->rq.hdrs.rq_line.last_ws_end) && (wsp_blocks)) { /* The end of the whitespace block */ if (NULL == c->rq.hdrs.rq_line.rq_tgt) { /* This is the first character of the URI */ mhd_assert (0 == c->rq.req_target_len); mhd_assert (NULL == c->rq.version); c->rq.hdrs.rq_line.rq_tgt = c->read_buffer + p; /* Reset the whitespace marker */ c->rq.hdrs.rq_line.last_ws_start = 0; c->rq.hdrs.rq_line.last_ws_end = 0; } else { if (! wsp_in_uri) { /* This is the first character of the HTTP version */ mhd_assert (NULL != c->rq.hdrs.rq_line.rq_tgt); mhd_assert ((0 != c->rq.req_target_len) || \ (c->rq.hdrs.rq_line.rq_tgt + 1 == c->read_buffer + p)); mhd_assert (NULL == c->rq.version); /* Handled at whitespace start */ c->rq.version = c->read_buffer + p; /* Reset the whitespace marker */ c->rq.hdrs.rq_line.last_ws_start = 0; c->rq.hdrs.rq_line.last_ws_end = 0; } } } /* Handle other special characters */ if ('?' == chr) { if ((NULL == c->rq.hdrs.rq_line.rq_tgt_qmark) && (NULL != c->rq.hdrs.rq_line.rq_tgt)) { c->rq.hdrs.rq_line.rq_tgt_qmark = c->read_buffer + p; } } else if ((0xb == chr) || (0xc == chr)) { /* VT or LF characters */ mhd_assert (! other_wsp_as_wsp); if ((NULL != c->rq.hdrs.rq_line.rq_tgt) && (NULL == c->rq.version) && (wsp_in_uri)) { c->rq.hdrs.rq_line.num_ws_in_uri++; } else { connection_close_error (c, _ ("Invalid character is in the " "request line.\n")); return true; /* Error in the request */ } } else if (0 == chr) { /* NUL character */ connection_close_error (c, _ ("The NUL character is in the " "request line.\n")); return true; /* Error in the request */ } } p++; } c->rq.hdrs.rq_line.proc_pos = p; return false; /* Not enough data yet */ } #ifndef MHD_MAX_FIXED_URI_LEN /** * The maximum size of the fixed URI for automatic redirection */ #define MHD_MAX_FIXED_URI_LEN (64 * 1024) #endif /* ! MHD_MAX_FIXED_URI_LEN */ /** * Send the automatic redirection to fixed URI when received URI with * whitespaces. * If URI is too large, close connection with error. * * @param c the connection to process */ static void send_redirect_fixed_rq_target (struct MHD_Connection *c) { char *b; size_t fixed_uri_len; size_t i; size_t o; char *hdr_name; size_t hdr_name_len; mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); mhd_assert (0 != c->rq.hdrs.rq_line.num_ws_in_uri); mhd_assert (c->rq.hdrs.rq_line.num_ws_in_uri <= \ c->rq.req_target_len); fixed_uri_len = c->rq.req_target_len + 2 * c->rq.hdrs.rq_line.num_ws_in_uri; if ( (fixed_uri_len + 200 > c->daemon->pool_size) || (fixed_uri_len > MHD_MAX_FIXED_URI_LEN) || (NULL == (b = malloc (fixed_uri_len + 1))) ) { connection_close_error (c, _ ("The request has whitespace character is " \ "in the URI and the URI is too large to " \ "send automatic redirect to fixed URI.\n")); return; } i = 0; o = 0; do { const char chr = c->rq.hdrs.rq_line.rq_tgt[i++]; mhd_assert ('\r' != chr); /* Replaced during request line parsing */ mhd_assert ('\n' != chr); /* Rejected during request line parsing */ mhd_assert (0 != chr); /* Rejected during request line parsing */ switch (chr) { case ' ': b[o++] = '%'; b[o++] = '2'; b[o++] = '0'; break; case '\t': b[o++] = '%'; b[o++] = '0'; b[o++] = '9'; break; case 0x0B: /* VT (vertical tab) */ b[o++] = '%'; b[o++] = '0'; b[o++] = 'B'; break; case 0x0C: /* FF (form feed) */ b[o++] = '%'; b[o++] = '0'; b[o++] = 'C'; break; default: b[o++] = chr; break; } } while (i < c->rq.req_target_len); mhd_assert (fixed_uri_len == o); b[o] = 0; /* Zero-terminate the result */ hdr_name_len = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_LOCATION); hdr_name = malloc (hdr_name_len + 1); if (NULL != hdr_name) { memcpy (hdr_name, MHD_HTTP_HEADER_LOCATION, hdr_name_len + 1); /* hdr_name and b are free()d within this call */ transmit_error_response_header (c, MHD_HTTP_MOVED_PERMANENTLY, RQ_TARGET_INVALID_CHAR, hdr_name, hdr_name_len, b, o); return; } free (b); connection_close_error (c, _ ("The request has whitespace character is in the " \ "URI.\n")); return; } /** * Process request-target string, form URI and URI parameters * @param c the connection to process * @return true if request-target successfully processed, * false if error encountered */ static bool process_request_target (struct MHD_Connection *c) { #ifdef _DEBUG size_t params_len; #endif /* _DEBUG */ mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); mhd_assert (NULL == c->rq.url); mhd_assert (0 == c->rq.url_len); mhd_assert (NULL != c->rq.hdrs.rq_line.rq_tgt); mhd_assert ((NULL == c->rq.hdrs.rq_line.rq_tgt_qmark) || \ (c->rq.hdrs.rq_line.rq_tgt <= c->rq.hdrs.rq_line.rq_tgt_qmark)); mhd_assert ((NULL == c->rq.hdrs.rq_line.rq_tgt_qmark) || \ (c->rq.req_target_len > \ (size_t) (c->rq.hdrs.rq_line.rq_tgt_qmark \ - c->rq.hdrs.rq_line.rq_tgt))); /* Log callback before the request-target is modified/decoded */ if (NULL != c->daemon->uri_log_callback) { c->rq.client_aware = true; c->rq.client_context = c->daemon->uri_log_callback (c->daemon->uri_log_callback_cls, c->rq.hdrs.rq_line.rq_tgt, c); } if (NULL != c->rq.hdrs.rq_line.rq_tgt_qmark) { #ifdef _DEBUG params_len = c->rq.req_target_len - (size_t) (c->rq.hdrs.rq_line.rq_tgt_qmark - c->rq.hdrs.rq_line.rq_tgt); #endif /* _DEBUG */ c->rq.hdrs.rq_line.rq_tgt_qmark[0] = 0; /* Replace '?' with zero termination */ if (MHD_NO == MHD_parse_arguments_ (c, MHD_GET_ARGUMENT_KIND, c->rq.hdrs.rq_line.rq_tgt_qmark + 1, &connection_add_header, c)) { mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING != c->state); return false; } } #ifdef _DEBUG else params_len = 0; #endif /* _DEBUG */ mhd_assert (strlen (c->rq.hdrs.rq_line.rq_tgt) == \ c->rq.req_target_len - params_len); /* Finally unescape URI itself */ c->rq.url_len = c->daemon->unescape_callback (c->daemon->unescape_callback_cls, c, c->rq.hdrs.rq_line.rq_tgt); c->rq.url = c->rq.hdrs.rq_line.rq_tgt; return true; } /** * Find and parse the request line. * Advance to the next state when done, handle errors. * @param c the connection to process * @return true if request line completely processed and state is changed, * false if not enough data yet in the receive buffer */ static bool get_request_line (struct MHD_Connection *c) { const int discp_lvl = c->daemon->client_discipline; /* Parse whitespace in URI, special parsing of the request line */ const bool wsp_in_uri = (0 >= discp_lvl); /* Keep whitespace in URI, give app URI with whitespace instead of automatic redirect to fixed URI */ const bool wsp_in_uri_keep = (-2 >= discp_lvl); if (! get_request_line_inner (c)) { /* End of the request line has not been found yet */ mhd_assert ((! wsp_in_uri) || NULL == c->rq.version); if ((NULL != c->rq.version) && (HTTP_VER_LEN < (c->rq.hdrs.rq_line.proc_pos - (size_t) (c->rq.version - c->read_buffer)))) { c->rq.http_ver = MHD_HTTP_VER_INVALID; transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, REQUEST_MALFORMED); return true; /* Error in the request */ } return false; } if (MHD_CONNECTION_REQ_LINE_RECEIVING < c->state) return true; /* Error in the request */ mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING == c->state); mhd_assert (NULL == c->rq.url); mhd_assert (0 == c->rq.url_len); mhd_assert (NULL != c->rq.hdrs.rq_line.rq_tgt); if (0 != c->rq.hdrs.rq_line.num_ws_in_uri) { if (! wsp_in_uri) { transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, RQ_TARGET_INVALID_CHAR); return true; /* Error in the request */ } if (! wsp_in_uri_keep) { send_redirect_fixed_rq_target (c); return true; /* Error in the request */ } } if (! process_request_target (c)) return true; /* Error in processing */ c->state = MHD_CONNECTION_REQ_LINE_RECEIVED; return true; } /** * Results of header line reading */ enum MHD_HdrLineReadRes_ { /** * Not enough data yet */ MHD_HDR_LINE_READING_NEED_MORE_DATA = 0, /** * New header line has been read */ MHD_HDR_LINE_READING_GOT_HEADER, /** * Error in header data, error response has been queued */ MHD_HDR_LINE_READING_DATA_ERROR, /** * Found the end of the request header (end of field lines) */ MHD_HDR_LINE_READING_GOT_END_OF_HEADER } _MHD_FIXED_ENUM; /** * Find the end of the request header line and make basic header parsing. * Handle errors and header folding. * @param c the connection to process * @param process_footers if true then footers are processed, * if false then headers are processed * @param[out] hdr_name the name of the parsed header (field) * @param[out] hdr_name the value of the parsed header (field) * @return true if request header line completely processed, * false if not enough data yet in the receive buffer */ static enum MHD_HdrLineReadRes_ get_req_header (struct MHD_Connection *c, bool process_footers, struct _MHD_str_w_len *hdr_name, struct _MHD_str_w_len *hdr_value) { const int discp_lvl = c->daemon->client_discipline; /* Treat bare LF as the end of the line. RFC 9112, section 2.2-3 Note: MHD never replaces bare LF with space (RFC 9110, section 5.5-5). Bare LF is processed as end of the line or rejected as broken request. */ const bool bare_lf_as_crlf = MHD_ALLOW_BARE_LF_AS_CRLF_ (discp_lvl); /* Keep bare CR character as is. Violates RFC 9112, section 2.2-4 */ const bool bare_cr_keep = (-3 >= discp_lvl); /* Treat bare CR as space; replace it with space before processing. RFC 9112, section 2.2-4 */ const bool bare_cr_as_sp = ((! bare_cr_keep) && (-1 >= discp_lvl)); /* Treat NUL as space; replace it with space before processing. RFC 9110, section 5.5-5 */ const bool nul_as_sp = (-1 >= discp_lvl); /* Allow folded header lines. RFC 9112, section 5.2-4 */ const bool allow_folded = (0 >= discp_lvl); /* Do not reject headers with the whitespace at the start of the first line. When allowed, the first line with whitespace character at the first position is ignored (as well as all possible line foldings of the first line). RFC 9112, section 2.2-8 */ const bool allow_wsp_at_start = allow_folded && (-1 >= discp_lvl); /* Allow whitespace in header (field) name. Violates RFC 9110, section 5.1-2 */ const bool allow_wsp_in_name = (-2 >= discp_lvl); /* Allow zero-length header (field) name. Violates RFC 9110, section 5.1-2 */ const bool allow_empty_name = (-2 >= discp_lvl); /* Allow whitespace before colon. Violates RFC 9112, section 5.1-2 */ const bool allow_wsp_before_colon = (-3 >= discp_lvl); /* Do not abort the request when header line has no colon, just skip such bad lines. RFC 9112, section 5-1 */ const bool allow_line_without_colon = (-2 >= discp_lvl); size_t p; /**< The position of the currently processed character */ #if ! defined (HAVE_MESSAGES) && ! defined(_DEBUG) (void) process_footers; /* Unused parameter */ #endif /* !HAVE_MESSAGES && !_DEBUG */ mhd_assert ((process_footers ? MHD_CONNECTION_FOOTERS_RECEIVING : \ MHD_CONNECTION_REQ_HEADERS_RECEIVING) == \ c->state); p = c->rq.hdrs.hdr.proc_pos; mhd_assert (p <= c->read_buffer_offset); while (p < c->read_buffer_offset) { const char chr = c->read_buffer[p]; bool end_of_line; mhd_assert ((0 == c->rq.hdrs.hdr.name_len) || \ (c->rq.hdrs.hdr.name_len < p)); mhd_assert ((0 == c->rq.hdrs.hdr.name_len) || (0 != p)); mhd_assert ((0 == c->rq.hdrs.hdr.name_len) || \ (c->rq.hdrs.hdr.name_end_found)); mhd_assert ((0 == c->rq.hdrs.hdr.value_start) || \ (c->rq.hdrs.hdr.name_len < c->rq.hdrs.hdr.value_start)); mhd_assert ((0 == c->rq.hdrs.hdr.value_start) || \ (0 != c->rq.hdrs.hdr.name_len)); mhd_assert ((0 == c->rq.hdrs.hdr.ws_start) || \ (0 == c->rq.hdrs.hdr.name_len) || \ (c->rq.hdrs.hdr.ws_start > c->rq.hdrs.hdr.name_len)); mhd_assert ((0 == c->rq.hdrs.hdr.ws_start) || \ (0 == c->rq.hdrs.hdr.value_start) || \ (c->rq.hdrs.hdr.ws_start > c->rq.hdrs.hdr.value_start)); /* Check for the end of the line */ if ('\r' == chr) { if (0 != p) { /* Line is not empty, need to check for possible line folding */ if (p + 2 >= c->read_buffer_offset) break; /* Not enough data yet to check for folded line */ } else { /* Line is empty, no need to check for possible line folding */ if (p + 2 > c->read_buffer_offset) break; /* Not enough data yet to check for the end of the line */ } if ('\n' == c->read_buffer[p + 1]) end_of_line = true; else { /* Bare CR alone */ /* Must be rejected or replaced with space char. See RFC 9112, section 2.2-4 */ if (bare_cr_as_sp) { c->read_buffer[p] = ' '; c->rq.num_cr_sp_replaced++; continue; /* Re-start processing of the current character */ } else if (! bare_cr_keep) { if (! process_footers) transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, BARE_CR_IN_HEADER); else transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, BARE_CR_IN_FOOTER); return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */ } end_of_line = false; } } else if ('\n' == chr) { /* Bare LF may be recognised as a line delimiter. See RFC 9112, section 2.2-3 */ if (bare_lf_as_crlf) { if (0 != p) { /* Line is not empty, need to check for possible line folding */ if (p + 1 >= c->read_buffer_offset) break; /* Not enough data yet to check for folded line */ } end_of_line = true; } else { if (! process_footers) transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, BARE_LF_IN_HEADER); else transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, BARE_LF_IN_FOOTER); return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */ } } else end_of_line = false; if (end_of_line) { /* Handle the end of the line */ /** * The full length of the line, including CRLF (or bare LF). */ const size_t line_len = p + (('\r' == chr) ? 2 : 1); char next_line_char; mhd_assert (line_len <= c->read_buffer_offset); if (0 == p) { /* Zero-length header line. This is the end of the request header section. RFC 9112, Section 2.1-1 */ mhd_assert (! c->rq.hdrs.hdr.starts_with_ws); mhd_assert (! c->rq.hdrs.hdr.name_end_found); mhd_assert (0 == c->rq.hdrs.hdr.name_len); mhd_assert (0 == c->rq.hdrs.hdr.ws_start); mhd_assert (0 == c->rq.hdrs.hdr.value_start); /* Consume the line with CRLF (or bare LF) */ c->read_buffer += line_len; c->read_buffer_offset -= line_len; c->read_buffer_size -= line_len; return MHD_HDR_LINE_READING_GOT_END_OF_HEADER; } mhd_assert (line_len < c->read_buffer_offset); mhd_assert (0 != line_len); mhd_assert ('\n' == c->read_buffer[line_len - 1]); next_line_char = c->read_buffer[line_len]; if ((' ' == next_line_char) || ('\t' == next_line_char)) { /* Folded line */ if (! allow_folded) { if (! process_footers) transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_OBS_FOLD); else transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_OBS_FOLD_FOOTER); return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */ } /* Replace CRLF (or bare LF) character(s) with space characters. See RFC 9112, Section 5.2-4 */ c->read_buffer[p] = ' '; if ('\r' == chr) c->read_buffer[p + 1] = ' '; continue; /* Re-start processing of the current character */ } else { /* It is not a folded line, it's the real end of the non-empty line */ bool skip_line = false; mhd_assert (0 != p); if (c->rq.hdrs.hdr.starts_with_ws) { /* This is the first line and it starts with whitespace. This line must be discarded completely. See RFC 9112, Section 2.2-8 */ mhd_assert (allow_wsp_at_start); #ifdef HAVE_MESSAGES MHD_DLOG (c->daemon, _ ("Whitespace-prefixed first header line " \ "has been skipped.\n")); #endif /* HAVE_MESSAGES */ skip_line = true; } else if (! c->rq.hdrs.hdr.name_end_found) { if (! allow_line_without_colon) { if (! process_footers) transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_HEADER_WITHOUT_COLON); else transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_FOOTER_WITHOUT_COLON); return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */ } /* Skip broken line completely */ c->rq.skipped_broken_lines++; skip_line = true; } if (skip_line) { /* Skip the entire line */ c->read_buffer += line_len; c->read_buffer_offset -= line_len; c->read_buffer_size -= line_len; p = 0; /* Reset processing state */ memset (&c->rq.hdrs.hdr, 0, sizeof(c->rq.hdrs.hdr)); /* Start processing of the next line */ continue; } else { /* This line should be valid header line */ size_t value_len; mhd_assert ((0 != c->rq.hdrs.hdr.name_len) || allow_empty_name); hdr_name->str = c->read_buffer + 0; /* The name always starts at the first character */ hdr_name->len = c->rq.hdrs.hdr.name_len; mhd_assert (0 == hdr_name->str[hdr_name->len]); if (0 == c->rq.hdrs.hdr.value_start) { c->rq.hdrs.hdr.value_start = p; c->read_buffer[p] = 0; value_len = 0; } else if (0 != c->rq.hdrs.hdr.ws_start) { mhd_assert (p > c->rq.hdrs.hdr.ws_start); mhd_assert (c->rq.hdrs.hdr.ws_start > c->rq.hdrs.hdr.value_start); c->read_buffer[c->rq.hdrs.hdr.ws_start] = 0; value_len = c->rq.hdrs.hdr.ws_start - c->rq.hdrs.hdr.value_start; } else { mhd_assert (p > c->rq.hdrs.hdr.ws_start); c->read_buffer[p] = 0; value_len = p - c->rq.hdrs.hdr.value_start; } hdr_value->str = c->read_buffer + c->rq.hdrs.hdr.value_start; hdr_value->len = value_len; mhd_assert (0 == hdr_value->str[hdr_value->len]); /* Consume the entire line */ c->read_buffer += line_len; c->read_buffer_offset -= line_len; c->read_buffer_size -= line_len; return MHD_HDR_LINE_READING_GOT_HEADER; } } } else if ((' ' == chr) || ('\t' == chr)) { if (0 == p) { if (! allow_wsp_at_start) { if (! process_footers) transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_WSP_BEFORE_HEADER); else transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_WSP_BEFORE_FOOTER); return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */ } c->rq.hdrs.hdr.starts_with_ws = true; } else if ((! c->rq.hdrs.hdr.name_end_found) && (! c->rq.hdrs.hdr.starts_with_ws)) { /* Whitespace in header name / between header name and colon */ if (allow_wsp_in_name || allow_wsp_before_colon) { if (0 == c->rq.hdrs.hdr.ws_start) c->rq.hdrs.hdr.ws_start = p; } else { if (! process_footers) transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_WSP_IN_HEADER_NAME); else transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_WSP_IN_FOOTER_NAME); return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */ } } else { /* Whitespace before/inside/after header (field) value */ if (0 == c->rq.hdrs.hdr.ws_start) c->rq.hdrs.hdr.ws_start = p; } } else if (0 == chr) { if (! nul_as_sp) { if (! process_footers) transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_INVALID_CHR_IN_HEADER); else transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_INVALID_CHR_IN_FOOTER); return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */ } c->read_buffer[p] = ' '; continue; /* Re-start processing of the current character */ } else { /* Not a whitespace, not the end of the header line */ mhd_assert ('\r' != chr); mhd_assert ('\n' != chr); mhd_assert ('\0' != chr); if ((! c->rq.hdrs.hdr.name_end_found) && (! c->rq.hdrs.hdr.starts_with_ws)) { /* Processing the header (field) name */ if (':' == chr) { if (0 == c->rq.hdrs.hdr.ws_start) c->rq.hdrs.hdr.name_len = p; else { mhd_assert (allow_wsp_in_name || allow_wsp_before_colon); if (! allow_wsp_before_colon) { if (! process_footers) transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_WSP_IN_HEADER_NAME); else transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_WSP_IN_FOOTER_NAME); return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */ } c->rq.hdrs.hdr.name_len = c->rq.hdrs.hdr.ws_start; #ifndef MHD_FAVOR_SMALL_CODE c->rq.hdrs.hdr.ws_start = 0; /* Not on whitespace anymore */ #endif /* ! MHD_FAVOR_SMALL_CODE */ } if ((0 == c->rq.hdrs.hdr.name_len) && ! allow_empty_name) { if (! process_footers) transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_EMPTY_HEADER_NAME); else transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_EMPTY_FOOTER_NAME); return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */ } c->rq.hdrs.hdr.name_end_found = true; c->read_buffer[c->rq.hdrs.hdr.name_len] = 0; /* Zero-terminate the name */ } else { if (0 != c->rq.hdrs.hdr.ws_start) { /* End of the whitespace in header (field) name */ mhd_assert (allow_wsp_in_name || allow_wsp_before_colon); if (! allow_wsp_in_name) { if (! process_footers) transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_WSP_IN_HEADER_NAME); else transmit_error_response_static (c, MHD_HTTP_BAD_REQUEST, ERR_RSP_WSP_IN_FOOTER_NAME); return MHD_HDR_LINE_READING_DATA_ERROR; /* Error in the request */ } #ifndef MHD_FAVOR_SMALL_CODE c->rq.hdrs.hdr.ws_start = 0; /* Not on whitespace anymore */ #endif /* ! MHD_FAVOR_SMALL_CODE */ } } } else { /* Processing the header (field) value */ if (0 == c->rq.hdrs.hdr.value_start) c->rq.hdrs.hdr.value_start = p; #ifndef MHD_FAVOR_SMALL_CODE c->rq.hdrs.hdr.ws_start = 0; /* Not on whitespace anymore */ #endif /* ! MHD_FAVOR_SMALL_CODE */ } #ifdef MHD_FAVOR_SMALL_CODE c->rq.hdrs.hdr.ws_start = 0; /* Not on whitespace anymore */ #endif /* MHD_FAVOR_SMALL_CODE */ } p++; } c->rq.hdrs.hdr.proc_pos = p; return MHD_HDR_LINE_READING_NEED_MORE_DATA; /* Not enough data yet */ } /** * Find the end of the request headers and make basic header parsing. * Advance to the next state when done, handle errors. * @param c the connection to process * @param process_footers if true then footers are processed, * if false then headers are processed * @return true if request headers reading finished (either successfully * or with error), * false if not enough data yet in the receive buffer */ static bool get_req_headers (struct MHD_Connection *c, bool process_footers) { do { struct _MHD_str_w_len hdr_name; struct _MHD_str_w_len hdr_value; enum MHD_HdrLineReadRes_ res; mhd_assert ((process_footers ? MHD_CONNECTION_FOOTERS_RECEIVING : \ MHD_CONNECTION_REQ_HEADERS_RECEIVING) == \ c->state); #ifdef _DEBUG hdr_name.str = NULL; hdr_value.str = NULL; #endif /* _DEBUG */ res = get_req_header (c, process_footers, &hdr_name, &hdr_value); if (MHD_HDR_LINE_READING_GOT_HEADER == res) { mhd_assert ((process_footers ? MHD_CONNECTION_FOOTERS_RECEIVING : \ MHD_CONNECTION_REQ_HEADERS_RECEIVING) == \ c->state); mhd_assert (NULL != hdr_name.str); mhd_assert (NULL != hdr_value.str); /* Values must be zero-terminated and must not have binary zeros */ mhd_assert (strlen (hdr_name.str) == hdr_name.len); mhd_assert (strlen (hdr_value.str) == hdr_value.len); /* Values must not have whitespaces at the start or at the end */ mhd_assert ((hdr_name.len == 0) || (hdr_name.str[0] != ' ')); mhd_assert ((hdr_name.len == 0) || (hdr_name.str[0] != '\t')); mhd_assert ((hdr_name.len == 0) || \ (hdr_name.str[hdr_name.len - 1] != ' ')); mhd_assert ((hdr_name.len == 0) || \ (hdr_name.str[hdr_name.len - 1] != '\t')); mhd_assert ((hdr_value.len == 0) || (hdr_value.str[0] != ' ')); mhd_assert ((hdr_value.len == 0) || (hdr_value.str[0] != '\t')); mhd_assert ((hdr_value.len == 0) || \ (hdr_value.str[hdr_value.len - 1] != ' ')); mhd_assert ((hdr_value.len == 0) || \ (hdr_value.str[hdr_value.len - 1] != '\t')); if (MHD_NO == MHD_set_connection_value_n_nocheck_ (c, (! process_footers) ? MHD_HEADER_KIND : MHD_FOOTER_KIND, hdr_name.str, hdr_name.len, hdr_value.str, hdr_value.len)) { size_t add_element_size; mhd_assert (hdr_name.str < hdr_value.str); #ifdef HAVE_MESSAGES MHD_DLOG (c->daemon, _ ("Failed to allocate memory in the connection memory " \ "pool to store %s.\n"), (! process_footers) ? _ ("header") : _ ("footer")); #endif /* HAVE_MESSAGES */ add_element_size = hdr_value.len + (size_t) (hdr_value.str - hdr_name.str); if (! process_footers) handle_req_headers_no_space (c, hdr_name.str, add_element_size); else handle_req_footers_no_space (c, hdr_name.str, add_element_size); mhd_assert (MHD_CONNECTION_FULL_REQ_RECEIVED < c->state); return true; } /* Reset processing state */ reset_rq_header_processing_state (c); mhd_assert ((process_footers ? MHD_CONNECTION_FOOTERS_RECEIVING : \ MHD_CONNECTION_REQ_HEADERS_RECEIVING) == \ c->state); /* Read the next header (field) line */ continue; } else if (MHD_HDR_LINE_READING_NEED_MORE_DATA == res) { mhd_assert ((process_footers ? MHD_CONNECTION_FOOTERS_RECEIVING : \ MHD_CONNECTION_REQ_HEADERS_RECEIVING) == \ c->state); return false; } else if (MHD_HDR_LINE_READING_DATA_ERROR == res) { mhd_assert ((process_footers ? \ MHD_CONNECTION_FOOTERS_RECEIVING : \ MHD_CONNECTION_REQ_HEADERS_RECEIVING) < c->state); mhd_assert (c->stop_with_error); mhd_assert (c->discard_request); return true; } mhd_assert (MHD_HDR_LINE_READING_GOT_END_OF_HEADER == res); break; } while (1); #ifdef HAVE_MESSAGES if (1 == c->rq.num_cr_sp_replaced) { MHD_DLOG (c->daemon, _ ("One bare CR character has been replaced with space " \ "in %s.\n"), (! process_footers) ? _ ("the request line or in the request headers") : _ ("the request footers")); } else if (0 != c->rq.num_cr_sp_replaced) { MHD_DLOG (c->daemon, _ ("%" PRIu64 " bare CR characters have been replaced with " \ "spaces in the request line and/or in the request %s.\n"), (uint64_t) c->rq.num_cr_sp_replaced, (! process_footers) ? _ ("headers") : _ ("footers")); } if (1 == c->rq.skipped_broken_lines) { MHD_DLOG (c->daemon, _ ("One %s line without colon has been skipped.\n"), (! process_footers) ? _ ("header") : _ ("footer")); } else if (0 != c->rq.skipped_broken_lines) { MHD_DLOG (c->daemon, _ ("%" PRIu64 " %s lines without colons has been skipped.\n"), (uint64_t) c->rq.skipped_broken_lines, (! process_footers) ? _ ("header") : _ ("footer")); } #endif /* HAVE_MESSAGES */ mhd_assert (c->rq.method < c->read_buffer); if (! process_footers) { c->rq.header_size = (size_t) (c->read_buffer - c->rq.method); mhd_assert (NULL != c->rq.field_lines.start); c->rq.field_lines.size = (size_t) ((c->read_buffer - c->rq.field_lines.start) - 1); if ('\r' == *(c->read_buffer - 2)) c->rq.field_lines.size--; c->state = MHD_CONNECTION_HEADERS_RECEIVED; if (MHD_BUF_INC_SIZE > c->read_buffer_size) { /* Try to re-use some of the last bytes of the request header */ /* Do this only if space in the read buffer is limited AND amount of read ahead data is small. */ /** * The position of the terminating NUL after the last character of * the last header element. */ const char *last_elmnt_end; size_t shift_back_size; if (NULL != c->rq.headers_received_tail) last_elmnt_end = c->rq.headers_received_tail->value + c->rq.headers_received_tail->value_size; else last_elmnt_end = c->rq.version + HTTP_VER_LEN; mhd_assert ((last_elmnt_end + 1) < c->read_buffer); shift_back_size = (size_t) (c->read_buffer - (last_elmnt_end + 1)); if (0 != c->read_buffer_offset) memmove (c->read_buffer - shift_back_size, c->read_buffer, c->read_buffer_offset); c->read_buffer -= shift_back_size; c->read_buffer_size += shift_back_size; } } else c->state = MHD_CONNECTION_FOOTERS_RECEIVED; return true; } /** * Update the 'last_activity' field of the connection to the current time * and move the connection to the head of the 'normal_timeout' list if * the timeout for the connection uses the default value. * * @param connection the connection that saw some activity */ void MHD_update_last_activity_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; #if defined(MHD_USE_THREADS) mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ if (0 == connection->connection_timeout_ms) return; /* Skip update of activity for connections without timeout timer. */ if (connection->suspended) return; /* no activity on suspended connections */ connection->last_activity = MHD_monotonic_msec_counter (); if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) return; /* each connection has personal timeout */ if (connection->connection_timeout_ms != daemon->connection_timeout_ms) return; /* custom timeout, no need to move it in "normal" DLL */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif /* move connection to head of timeout list (by remove + add operation) */ XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); XDLL_insert (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif } /** * This function handles a particular connection when it has been * determined that there is data to be read off a socket. All * implementations (multithreaded, external polling, internal polling) * call this function to handle reads. * * @param connection connection to handle * @param socket_error set to true if socket error was detected */ void MHD_connection_handle_read (struct MHD_Connection *connection, bool socket_error) { ssize_t bytes_read; if ( (MHD_CONNECTION_CLOSED == connection->state) || (connection->suspended) ) return; #ifdef HTTPS_SUPPORT if (MHD_TLS_CONN_NO_TLS != connection->tls_state) { /* HTTPS connection. */ if (MHD_TLS_CONN_CONNECTED > connection->tls_state) { if (! MHD_run_tls_handshake_ (connection)) return; } } #endif /* HTTPS_SUPPORT */ mhd_assert (NULL != connection->read_buffer); if (connection->read_buffer_size == connection->read_buffer_offset) return; /* No space for receiving data. */ bytes_read = connection->recv_cls (connection, &connection->read_buffer [connection->read_buffer_offset], connection->read_buffer_size - connection->read_buffer_offset); if ((bytes_read < 0) || socket_error) { if ((MHD_ERR_AGAIN_ == bytes_read) && ! socket_error) return; /* No new data to process. */ if ((bytes_read > 0) && connection->sk_nonblck) { /* Try to detect the socket error */ int dummy; bytes_read = connection->recv_cls (connection, &dummy, sizeof (dummy)); } if (MHD_ERR_CONNRESET_ == bytes_read) { if ( (MHD_CONNECTION_INIT < connection->state) && (MHD_CONNECTION_FULL_REQ_RECEIVED > connection->state) ) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Socket has been disconnected when reading request.\n")); #endif connection->discard_request = true; } MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_READ_ERROR); return; } #ifdef HAVE_MESSAGES if (MHD_CONNECTION_INIT != connection->state) MHD_DLOG (connection->daemon, _ ("Connection socket is closed when reading " \ "request due to the error: %s\n"), (bytes_read < 0) ? str_conn_error_ (bytes_read) : "detected connection closure"); #endif CONNECTION_CLOSE_ERROR (connection, NULL); return; } if (0 == bytes_read) { /* Remote side closed connection. */ connection->read_closed = true; if ( (MHD_CONNECTION_INIT < connection->state) && (MHD_CONNECTION_FULL_REQ_RECEIVED > connection->state) ) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Connection was closed by remote side with incomplete " "request.\n")); #endif connection->discard_request = true; MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_CLIENT_ABORT); } else if (MHD_CONNECTION_INIT == connection->state) /* This termination code cannot be reported to the application * because application has not been informed yet about this request */ MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_COMPLETED_OK); else MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_WITH_ERROR); return; } connection->read_buffer_offset += (size_t) bytes_read; MHD_update_last_activity_ (connection); #if DEBUG_STATES MHD_DLOG (connection->daemon, _ ("In function %s handling connection at state: %s\n"), MHD_FUNC_, MHD_state_to_string (connection->state)); #endif /* TODO: check whether the next 'switch()' really needed */ switch (connection->state) { case MHD_CONNECTION_INIT: case MHD_CONNECTION_REQ_LINE_RECEIVING: case MHD_CONNECTION_REQ_HEADERS_RECEIVING: case MHD_CONNECTION_BODY_RECEIVING: case MHD_CONNECTION_FOOTERS_RECEIVING: case MHD_CONNECTION_FULL_REQ_RECEIVED: /* nothing to do but default action */ if (connection->read_closed) { /* TODO: check whether this really needed */ MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_READ_ERROR); } return; case MHD_CONNECTION_CLOSED: return; #ifdef UPGRADE_SUPPORT case MHD_CONNECTION_UPGRADE: mhd_assert (0); return; #endif /* UPGRADE_SUPPORT */ case MHD_CONNECTION_START_REPLY: /* shrink read buffer to how much is actually used */ /* TODO: remove shrink as it handled in special function */ if ((0 != connection->read_buffer_size) && (connection->read_buffer_size != connection->read_buffer_offset)) { mhd_assert (NULL != connection->read_buffer); connection->read_buffer = MHD_pool_reallocate (connection->pool, connection->read_buffer, connection->read_buffer_size, connection->read_buffer_offset); connection->read_buffer_size = connection->read_buffer_offset; } break; case MHD_CONNECTION_REQ_LINE_RECEIVED: case MHD_CONNECTION_HEADERS_RECEIVED: case MHD_CONNECTION_HEADERS_PROCESSED: case MHD_CONNECTION_BODY_RECEIVED: case MHD_CONNECTION_FOOTERS_RECEIVED: /* Milestone state, no data should be read */ mhd_assert (0); /* Should not be possible */ break; case MHD_CONNECTION_CONTINUE_SENDING: case MHD_CONNECTION_HEADERS_SENDING: case MHD_CONNECTION_HEADERS_SENT: case MHD_CONNECTION_NORMAL_BODY_UNREADY: case MHD_CONNECTION_NORMAL_BODY_READY: case MHD_CONNECTION_CHUNKED_BODY_UNREADY: case MHD_CONNECTION_CHUNKED_BODY_READY: case MHD_CONNECTION_CHUNKED_BODY_SENT: case MHD_CONNECTION_FOOTERS_SENDING: case MHD_CONNECTION_FULL_REPLY_SENT: default: mhd_assert (0); /* Should not be possible */ break; } return; } /** * This function was created to handle writes to sockets when it has * been determined that the socket can be written to. All * implementations (multithreaded, external select, internal select) * call this function * * @param connection connection to handle */ void MHD_connection_handle_write (struct MHD_Connection *connection) { struct MHD_Response *response; ssize_t ret; if (connection->suspended) return; #ifdef HTTPS_SUPPORT if (MHD_TLS_CONN_NO_TLS != connection->tls_state) { /* HTTPS connection. */ if (MHD_TLS_CONN_CONNECTED > connection->tls_state) { if (! MHD_run_tls_handshake_ (connection)) return; } } #endif /* HTTPS_SUPPORT */ #if DEBUG_STATES MHD_DLOG (connection->daemon, _ ("In function %s handling connection at state: %s\n"), MHD_FUNC_, MHD_state_to_string (connection->state)); #endif switch (connection->state) { case MHD_CONNECTION_INIT: case MHD_CONNECTION_REQ_LINE_RECEIVING: case MHD_CONNECTION_REQ_LINE_RECEIVED: case MHD_CONNECTION_REQ_HEADERS_RECEIVING: case MHD_CONNECTION_HEADERS_RECEIVED: case MHD_CONNECTION_HEADERS_PROCESSED: mhd_assert (0); return; case MHD_CONNECTION_CONTINUE_SENDING: ret = MHD_send_data_ (connection, &HTTP_100_CONTINUE [connection->continue_message_write_offset], MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE) - connection->continue_message_write_offset, true); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) return; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Failed to send data in request for %s.\n"), connection->rq.url); #endif CONNECTION_CLOSE_ERROR (connection, NULL); return; } #if _MHD_DEBUG_SEND_DATA fprintf (stderr, _ ("Sent 100 continue response: `%.*s'\n"), (int) ret, &HTTP_100_CONTINUE[connection->continue_message_write_offset]); #endif connection->continue_message_write_offset += (size_t) ret; MHD_update_last_activity_ (connection); return; case MHD_CONNECTION_BODY_RECEIVING: case MHD_CONNECTION_BODY_RECEIVED: case MHD_CONNECTION_FOOTERS_RECEIVING: case MHD_CONNECTION_FOOTERS_RECEIVED: case MHD_CONNECTION_FULL_REQ_RECEIVED: mhd_assert (0); return; case MHD_CONNECTION_START_REPLY: mhd_assert (0); return; case MHD_CONNECTION_HEADERS_SENDING: { struct MHD_Response *const resp = connection->rp.response; const size_t wb_ready = connection->write_buffer_append_offset - connection->write_buffer_send_offset; mhd_assert (connection->write_buffer_append_offset >= \ connection->write_buffer_send_offset); mhd_assert (NULL != resp); mhd_assert ( (0 == resp->data_size) || \ (0 == resp->data_start) || \ (NULL != resp->crc) ); mhd_assert ( (0 == connection->rp.rsp_write_position) || \ (resp->total_size == connection->rp.rsp_write_position) ); mhd_assert ((MHD_CONN_MUST_UPGRADE != connection->keepalive) || \ (! connection->rp.props.send_reply_body)); if ( (connection->rp.props.send_reply_body) && (NULL == resp->crc) && (NULL == resp->data_iov) && /* TODO: remove the next check as 'send_reply_body' is used */ (0 == connection->rp.rsp_write_position) && (! connection->rp.props.chunked) ) { mhd_assert (resp->total_size >= resp->data_size); mhd_assert (0 == resp->data_start); /* Send response headers alongside the response body, if the body * data is available. */ ret = MHD_send_hdr_and_body_ (connection, &connection->write_buffer [connection->write_buffer_send_offset], wb_ready, false, resp->data, resp->data_size, (resp->total_size == resp->data_size)); } else { /* This is response for HEAD request or reply body is not allowed * for any other reason or reply body is dynamically generated. */ /* Do not send the body data even if it's available. */ ret = MHD_send_hdr_and_body_ (connection, &connection->write_buffer [connection->write_buffer_send_offset], wb_ready, false, NULL, 0, ((0 == resp->total_size) || (! connection->rp.props.send_reply_body) )); } if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) return; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Failed to send the response headers for the " \ "request for `%s'. Error: %s\n"), connection->rq.url, str_conn_error_ (ret)); #endif CONNECTION_CLOSE_ERROR (connection, NULL); return; } /* 'ret' is not negative, it's safe to cast it to 'size_t'. */ if (((size_t) ret) > wb_ready) { /* The complete header and some response data have been sent, * update both offsets. */ mhd_assert (0 == connection->rp.rsp_write_position); mhd_assert (! connection->rp.props.chunked); mhd_assert (connection->rp.props.send_reply_body); connection->write_buffer_send_offset += wb_ready; connection->rp.rsp_write_position = ((size_t) ret) - wb_ready; } else connection->write_buffer_send_offset += (size_t) ret; MHD_update_last_activity_ (connection); if (MHD_CONNECTION_HEADERS_SENDING != connection->state) return; check_write_done (connection, MHD_CONNECTION_HEADERS_SENT); return; } case MHD_CONNECTION_HEADERS_SENT: return; case MHD_CONNECTION_NORMAL_BODY_READY: response = connection->rp.response; if (connection->rp.rsp_write_position < connection->rp.response->total_size) { uint64_t data_write_offset; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != response->crc) MHD_mutex_lock_chk_ (&response->mutex); #endif if (MHD_NO == try_ready_normal_body (connection)) { /* mutex was already unlocked by try_ready_normal_body */ return; } #if defined(_MHD_HAVE_SENDFILE) if (MHD_resp_sender_sendfile == connection->rp.resp_sender) { mhd_assert (NULL == response->data_iov); ret = MHD_send_sendfile_ (connection); } else /* combined with the next 'if' */ #endif /* _MHD_HAVE_SENDFILE */ if (NULL != response->data_iov) { ret = MHD_send_iovec_ (connection, &connection->rp.resp_iov, true); } else { data_write_offset = connection->rp.rsp_write_position - response->data_start; if (data_write_offset > (uint64_t) SIZE_MAX) MHD_PANIC (_ ("Data offset exceeds limit.\n")); ret = MHD_send_data_ (connection, &response->data [(size_t) data_write_offset], response->data_size - (size_t) data_write_offset, true); #if _MHD_DEBUG_SEND_DATA if (ret > 0) fprintf (stderr, _ ("Sent %d-byte DATA response: `%.*s'\n"), (int) ret, (int) ret, &rp.response->data[connection->rp.rsp_write_position - rp.response->data_start]); #endif } #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != response->crc) MHD_mutex_unlock_chk_ (&response->mutex); #endif if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) return; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Failed to send the response body for the " \ "request for `%s'. Error: %s\n"), connection->rq.url, str_conn_error_ (ret)); #endif CONNECTION_CLOSE_ERROR (connection, NULL); return; } connection->rp.rsp_write_position += (size_t) ret; MHD_update_last_activity_ (connection); } if (connection->rp.rsp_write_position == connection->rp.response->total_size) connection->state = MHD_CONNECTION_FULL_REPLY_SENT; return; case MHD_CONNECTION_NORMAL_BODY_UNREADY: mhd_assert (0); return; case MHD_CONNECTION_CHUNKED_BODY_READY: ret = MHD_send_data_ (connection, &connection->write_buffer [connection->write_buffer_send_offset], connection->write_buffer_append_offset - connection->write_buffer_send_offset, true); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) return; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Failed to send the chunked response body for the " \ "request for `%s'. Error: %s\n"), connection->rq.url, str_conn_error_ (ret)); #endif CONNECTION_CLOSE_ERROR (connection, NULL); return; } connection->write_buffer_send_offset += (size_t) ret; MHD_update_last_activity_ (connection); if (MHD_CONNECTION_CHUNKED_BODY_READY != connection->state) return; check_write_done (connection, (connection->rp.response->total_size == connection->rp.rsp_write_position) ? MHD_CONNECTION_CHUNKED_BODY_SENT : MHD_CONNECTION_CHUNKED_BODY_UNREADY); return; case MHD_CONNECTION_CHUNKED_BODY_UNREADY: case MHD_CONNECTION_CHUNKED_BODY_SENT: mhd_assert (0); return; case MHD_CONNECTION_FOOTERS_SENDING: ret = MHD_send_data_ (connection, &connection->write_buffer [connection->write_buffer_send_offset], connection->write_buffer_append_offset - connection->write_buffer_send_offset, true); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) return; #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("Failed to send the footers for the " \ "request for `%s'. Error: %s\n"), connection->rq.url, str_conn_error_ (ret)); #endif CONNECTION_CLOSE_ERROR (connection, NULL); return; } connection->write_buffer_send_offset += (size_t) ret; MHD_update_last_activity_ (connection); if (MHD_CONNECTION_FOOTERS_SENDING != connection->state) return; check_write_done (connection, MHD_CONNECTION_FULL_REPLY_SENT); return; case MHD_CONNECTION_FULL_REPLY_SENT: mhd_assert (0); return; case MHD_CONNECTION_CLOSED: return; #ifdef UPGRADE_SUPPORT case MHD_CONNECTION_UPGRADE: mhd_assert (0); return; #endif /* UPGRADE_SUPPORT */ default: mhd_assert (0); CONNECTION_CLOSE_ERROR (connection, _ ("Internal error.\n")); break; } return; } /** * Check whether connection has timed out. * @param c the connection to check * @return true if connection has timeout and needs to be closed, * false otherwise. */ static bool connection_check_timedout (struct MHD_Connection *c) { const uint64_t timeout = c->connection_timeout_ms; uint64_t now; uint64_t since_actv; if (c->suspended) return false; if (0 == timeout) return false; now = MHD_monotonic_msec_counter (); since_actv = now - c->last_activity; /* Keep the next lines in sync with #connection_get_wait() to avoid * undesired side-effects like busy-waiting. */ if (timeout < since_actv) { if (UINT64_MAX / 2 < since_actv) { const uint64_t jump_back = c->last_activity - now; /* Very unlikely that it is more than quarter-million years pause. * More likely that system clock jumps back. */ if (5000 >= jump_back) { #ifdef HAVE_MESSAGES MHD_DLOG (c->daemon, _ ("Detected system clock %u milliseconds jump back.\n"), (unsigned int) jump_back); #endif return false; } #ifdef HAVE_MESSAGES MHD_DLOG (c->daemon, _ ("Detected too large system clock %" PRIu64 " milliseconds " "jump back.\n"), jump_back); #endif } return true; } return false; } /** * Clean up the state of the given connection and move it into the * clean up queue for final disposal. * @remark To be called only from thread that process connection's * recv(), send() and response. * * @param connection handle for the connection to clean up */ static void cleanup_connection (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ if (connection->in_cleanup) return; /* Prevent double cleanup. */ connection->in_cleanup = true; if (NULL != connection->rp.response) { MHD_destroy_response (connection->rp.response); connection->rp.response = NULL; } #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif if (connection->suspended) { DLL_remove (daemon->suspended_connections_head, daemon->suspended_connections_tail, connection); connection->suspended = false; } else { if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { if (connection->connection_timeout_ms == daemon->connection_timeout_ms) XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); else XDLL_remove (daemon->manual_timeout_head, daemon->manual_timeout_tail, connection); } DLL_remove (daemon->connections_head, daemon->connections_tail, connection); } DLL_insert (daemon->cleanup_head, daemon->cleanup_tail, connection); connection->resuming = false; connection->in_idle = false; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { /* if we were at the connection limit before and are in thread-per-connection mode, signal the main thread to resume accepting connections */ if ( (MHD_ITC_IS_VALID_ (daemon->itc)) && (! MHD_itc_activate_ (daemon->itc, "c")) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to signal end of connection via inter-thread " \ "communication channel.\n")); #endif } } } /** * Set initial internal states for the connection to start reading and * processing incoming data. * @param c the connection to process */ void MHD_connection_set_initial_state_ (struct MHD_Connection *c) { size_t read_buf_size; #ifdef HTTPS_SUPPORT mhd_assert ( (0 == (c->daemon->options & MHD_USE_TLS)) || \ (MHD_TLS_CONN_INIT == c->tls_state) ); mhd_assert ( (0 != (c->daemon->options & MHD_USE_TLS)) || \ (MHD_TLS_CONN_NO_TLS == c->tls_state) ); #endif /* HTTPS_SUPPORT */ mhd_assert (MHD_CONNECTION_INIT == c->state); c->keepalive = MHD_CONN_KEEPALIVE_UNKOWN; c->event_loop_info = MHD_EVENT_LOOP_INFO_READ; memset (&c->rq, 0, sizeof(c->rq)); memset (&c->rp, 0, sizeof(c->rp)); c->write_buffer = NULL; c->write_buffer_size = 0; c->write_buffer_send_offset = 0; c->write_buffer_append_offset = 0; c->continue_message_write_offset = 0; c->read_buffer_offset = 0; read_buf_size = c->daemon->pool_size / 2; c->read_buffer = MHD_pool_allocate (c->pool, read_buf_size, false); c->read_buffer_size = read_buf_size; } /** * Reset connection after request-reply cycle. * @param connection the connection to process * @param reuse the flag to choose whether to close connection or * prepare connection for the next request processing */ static void connection_reset (struct MHD_Connection *connection, bool reuse) { struct MHD_Connection *const c = connection; /**< a short alias */ struct MHD_Daemon *const d = connection->daemon; if (! reuse) { /* Next function will destroy response, notify client, * destroy memory pool, and set connection state to "CLOSED" */ MHD_connection_close_ (c, c->stop_with_error ? MHD_REQUEST_TERMINATED_WITH_ERROR : MHD_REQUEST_TERMINATED_COMPLETED_OK); c->read_buffer = NULL; c->read_buffer_size = 0; c->read_buffer_offset = 0; c->write_buffer = NULL; c->write_buffer_size = 0; c->write_buffer_send_offset = 0; c->write_buffer_append_offset = 0; } else { /* Reset connection to process the next request */ size_t new_read_buf_size; mhd_assert (! c->stop_with_error); mhd_assert (! c->discard_request); if ( (NULL != d->notify_completed) && (c->rq.client_aware) ) d->notify_completed (d->notify_completed_cls, c, &c->rq.client_context, MHD_REQUEST_TERMINATED_COMPLETED_OK); c->rq.client_aware = false; if (NULL != c->rp.response) MHD_destroy_response (c->rp.response); c->rp.response = NULL; c->keepalive = MHD_CONN_KEEPALIVE_UNKOWN; c->state = MHD_CONNECTION_INIT; c->event_loop_info = (0 == c->read_buffer_offset) ? MHD_EVENT_LOOP_INFO_READ : MHD_EVENT_LOOP_INFO_PROCESS; memset (&c->rq, 0, sizeof(c->rq)); /* iov (if any) will be deallocated by MHD_pool_reset */ memset (&c->rp, 0, sizeof(c->rp)); c->write_buffer = NULL; c->write_buffer_size = 0; c->write_buffer_send_offset = 0; c->write_buffer_append_offset = 0; c->continue_message_write_offset = 0; /* Reset the read buffer to the starting size, preserving the bytes we have already read. */ new_read_buf_size = c->daemon->pool_size / 2; if (c->read_buffer_offset > new_read_buf_size) new_read_buf_size = c->read_buffer_offset; c->read_buffer = MHD_pool_reset (c->pool, c->read_buffer, c->read_buffer_offset, new_read_buf_size); c->read_buffer_size = new_read_buf_size; } c->rq.client_context = NULL; } /** * This function was created to handle per-connection processing that * has to happen even if the socket cannot be read or written to. * All implementations (multithreaded, external select, internal select) * call this function. * @remark To be called only from thread that process connection's * recv(), send() and response. * * @param connection connection to handle * @return #MHD_YES if we should continue to process the * connection (not dead yet), #MHD_NO if it died */ enum MHD_Result MHD_connection_handle_idle (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; enum MHD_Result ret; #ifdef MHD_USE_THREADS mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \ MHD_thread_handle_ID_is_current_thread_ (connection->tid) ); #endif /* MHD_USE_THREADS */ /* 'daemon' is not used if epoll is not available and asserts are disabled */ (void) daemon; /* Mute compiler warning */ connection->in_idle = true; while (! connection->suspended) { #ifdef HTTPS_SUPPORT if (MHD_TLS_CONN_NO_TLS != connection->tls_state) { /* HTTPS connection. */ if ((MHD_TLS_CONN_INIT <= connection->tls_state) && (MHD_TLS_CONN_CONNECTED > connection->tls_state)) break; } #endif /* HTTPS_SUPPORT */ #if DEBUG_STATES MHD_DLOG (daemon, _ ("In function %s handling connection at state: %s\n"), MHD_FUNC_, MHD_state_to_string (connection->state)); #endif switch (connection->state) { case MHD_CONNECTION_INIT: case MHD_CONNECTION_REQ_LINE_RECEIVING: if (get_request_line (connection)) { mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING < connection->state); mhd_assert ((MHD_IS_HTTP_VER_SUPPORTED (connection->rq.http_ver)) \ || (connection->discard_request)); continue; } mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVING >= connection->state); break; case MHD_CONNECTION_REQ_LINE_RECEIVED: switch_to_rq_headers_processing (connection); mhd_assert (MHD_CONNECTION_REQ_LINE_RECEIVED != connection->state); continue; case MHD_CONNECTION_REQ_HEADERS_RECEIVING: if (get_req_headers (connection, false)) { mhd_assert (MHD_CONNECTION_REQ_HEADERS_RECEIVING < connection->state); mhd_assert ((MHD_CONNECTION_HEADERS_RECEIVED == connection->state) || \ (connection->discard_request)); continue; } mhd_assert (MHD_CONNECTION_REQ_HEADERS_RECEIVING == connection->state); break; case MHD_CONNECTION_HEADERS_RECEIVED: parse_connection_headers (connection); if (MHD_CONNECTION_HEADERS_RECEIVED != connection->state) continue; connection->state = MHD_CONNECTION_HEADERS_PROCESSED; if (connection->suspended) break; continue; case MHD_CONNECTION_HEADERS_PROCESSED: call_connection_handler (connection); /* first call */ if (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) continue; if (connection->suspended) continue; if ( (NULL == connection->rp.response) && (need_100_continue (connection)) && /* If the client is already sending the payload (body) there is no need to send "100 Continue" */ (0 == connection->read_buffer_offset) ) { connection->state = MHD_CONNECTION_CONTINUE_SENDING; break; } if ( (NULL != connection->rp.response) && (0 != connection->rq.remaining_upload_size) ) { /* we refused (no upload allowed!) */ connection->rq.remaining_upload_size = 0; /* force close, in case client still tries to upload... */ connection->discard_request = true; } connection->state = (0 == connection->rq.remaining_upload_size) ? MHD_CONNECTION_FULL_REQ_RECEIVED : MHD_CONNECTION_BODY_RECEIVING; if (connection->suspended) break; continue; case MHD_CONNECTION_CONTINUE_SENDING: if (connection->continue_message_write_offset == MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE)) { connection->state = MHD_CONNECTION_BODY_RECEIVING; continue; } break; case MHD_CONNECTION_BODY_RECEIVING: mhd_assert (0 != connection->rq.remaining_upload_size); mhd_assert (! connection->discard_request); mhd_assert (NULL == connection->rp.response); if (0 != connection->read_buffer_offset) { process_request_body (connection); /* loop call */ if (MHD_CONNECTION_BODY_RECEIVING != connection->state) continue; } /* Modify here when queueing of the response during data processing will be supported */ mhd_assert (! connection->discard_request); mhd_assert (NULL == connection->rp.response); if (0 == connection->rq.remaining_upload_size) { connection->state = MHD_CONNECTION_BODY_RECEIVED; continue; } break; case MHD_CONNECTION_BODY_RECEIVED: mhd_assert (! connection->discard_request); mhd_assert (NULL == connection->rp.response); if (0 == connection->rq.remaining_upload_size) { if (connection->rq.have_chunked_upload) { /* Reset counter variables reused for footers */ connection->rq.num_cr_sp_replaced = 0; connection->rq.skipped_broken_lines = 0; reset_rq_header_processing_state (connection); connection->state = MHD_CONNECTION_FOOTERS_RECEIVING; } else connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED; continue; } break; case MHD_CONNECTION_FOOTERS_RECEIVING: if (get_req_headers (connection, true)) { mhd_assert (MHD_CONNECTION_FOOTERS_RECEIVING < connection->state); mhd_assert ((MHD_CONNECTION_FOOTERS_RECEIVED == connection->state) || \ (connection->discard_request)); continue; } mhd_assert (MHD_CONNECTION_FOOTERS_RECEIVING == connection->state); break; case MHD_CONNECTION_FOOTERS_RECEIVED: /* The header, the body, and the footers of the request has been received, * switch to the final processing of the request. */ connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED; continue; case MHD_CONNECTION_FULL_REQ_RECEIVED: call_connection_handler (connection); /* "final" call */ if (connection->state != MHD_CONNECTION_FULL_REQ_RECEIVED) continue; if (NULL == connection->rp.response) break; /* try again next time */ /* Response is ready, start reply */ connection->state = MHD_CONNECTION_START_REPLY; continue; case MHD_CONNECTION_START_REPLY: mhd_assert (NULL != connection->rp.response); connection_switch_from_recv_to_send (connection); if (MHD_NO == build_header_response (connection)) { /* oops - close! */ CONNECTION_CLOSE_ERROR (connection, _ ("Closing connection (failed to create " "response header).\n")); continue; } connection->state = MHD_CONNECTION_HEADERS_SENDING; break; case MHD_CONNECTION_HEADERS_SENDING: /* no default action */ break; case MHD_CONNECTION_HEADERS_SENT: #ifdef UPGRADE_SUPPORT if (NULL != connection->rp.response->upgrade_handler) { connection->state = MHD_CONNECTION_UPGRADE; /* This connection is "upgraded". Pass socket to application. */ if (MHD_NO == MHD_response_execute_upgrade_ (connection->rp.response, connection)) { /* upgrade failed, fail hard */ CONNECTION_CLOSE_ERROR (connection, NULL); continue; } /* Response is not required anymore for this connection. */ if (1) { struct MHD_Response *const resp = connection->rp.response; connection->rp.response = NULL; MHD_destroy_response (resp); } continue; } #endif /* UPGRADE_SUPPORT */ if (connection->rp.props.send_reply_body) { if (connection->rp.props.chunked) connection->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY; else connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY; } else connection->state = MHD_CONNECTION_FULL_REPLY_SENT; continue; case MHD_CONNECTION_NORMAL_BODY_READY: mhd_assert (connection->rp.props.send_reply_body); mhd_assert (! connection->rp.props.chunked); /* nothing to do here */ break; case MHD_CONNECTION_NORMAL_BODY_UNREADY: mhd_assert (connection->rp.props.send_reply_body); mhd_assert (! connection->rp.props.chunked); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != connection->rp.response->crc) MHD_mutex_lock_chk_ (&connection->rp.response->mutex); #endif if (0 == connection->rp.response->total_size) { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != connection->rp.response->crc) MHD_mutex_unlock_chk_ (&connection->rp.response->mutex); #endif if (connection->rp.props.chunked) connection->state = MHD_CONNECTION_CHUNKED_BODY_SENT; else connection->state = MHD_CONNECTION_FULL_REPLY_SENT; continue; } if (MHD_NO != try_ready_normal_body (connection)) { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != connection->rp.response->crc) MHD_mutex_unlock_chk_ (&connection->rp.response->mutex); #endif connection->state = MHD_CONNECTION_NORMAL_BODY_READY; /* Buffering for flushable socket was already enabled*/ break; } /* mutex was already unlocked by "try_ready_normal_body */ /* not ready, no socket action */ break; case MHD_CONNECTION_CHUNKED_BODY_READY: mhd_assert (connection->rp.props.send_reply_body); mhd_assert (connection->rp.props.chunked); /* nothing to do here */ break; case MHD_CONNECTION_CHUNKED_BODY_UNREADY: mhd_assert (connection->rp.props.send_reply_body); mhd_assert (connection->rp.props.chunked); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != connection->rp.response->crc) MHD_mutex_lock_chk_ (&connection->rp.response->mutex); #endif if ( (0 == connection->rp.response->total_size) || (connection->rp.rsp_write_position == connection->rp.response->total_size) ) { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != connection->rp.response->crc) MHD_mutex_unlock_chk_ (&connection->rp.response->mutex); #endif connection->state = MHD_CONNECTION_CHUNKED_BODY_SENT; continue; } if (1) { /* pseudo-branch for local variables scope */ bool finished; if (MHD_NO != try_ready_chunked_body (connection, &finished)) { #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if (NULL != connection->rp.response->crc) MHD_mutex_unlock_chk_ (&connection->rp.response->mutex); #endif connection->state = finished ? MHD_CONNECTION_CHUNKED_BODY_SENT : MHD_CONNECTION_CHUNKED_BODY_READY; continue; } /* mutex was already unlocked by try_ready_chunked_body */ } break; case MHD_CONNECTION_CHUNKED_BODY_SENT: mhd_assert (connection->rp.props.send_reply_body); mhd_assert (connection->rp.props.chunked); mhd_assert (connection->write_buffer_send_offset <= \ connection->write_buffer_append_offset); if (MHD_NO == build_connection_chunked_response_footer (connection)) { /* oops - close! */ CONNECTION_CLOSE_ERROR (connection, _ ("Closing connection (failed to create " \ "response footer).")); continue; } mhd_assert (connection->write_buffer_send_offset < \ connection->write_buffer_append_offset); connection->state = MHD_CONNECTION_FOOTERS_SENDING; continue; case MHD_CONNECTION_FOOTERS_SENDING: mhd_assert (connection->rp.props.send_reply_body); mhd_assert (connection->rp.props.chunked); /* no default action */ break; case MHD_CONNECTION_FULL_REPLY_SENT: if (MHD_HTTP_PROCESSING == connection->rp.responseCode) { /* After this type of response, we allow sending another! */ connection->state = MHD_CONNECTION_HEADERS_PROCESSED; MHD_destroy_response (connection->rp.response); connection->rp.response = NULL; /* FIXME: maybe partially reset memory pool? */ continue; } /* Reset connection after complete reply */ connection_reset (connection, MHD_CONN_USE_KEEPALIVE == connection->keepalive && ! connection->read_closed && ! connection->discard_request); continue; case MHD_CONNECTION_CLOSED: cleanup_connection (connection); connection->in_idle = false; return MHD_NO; #ifdef UPGRADE_SUPPORT case MHD_CONNECTION_UPGRADE: connection->in_idle = false; return MHD_YES; /* keep open */ #endif /* UPGRADE_SUPPORT */ default: mhd_assert (0); break; } break; } if (connection_check_timedout (connection)) { MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); connection->in_idle = false; return MHD_YES; } MHD_connection_update_event_loop_info (connection); ret = MHD_YES; #ifdef EPOLL_SUPPORT if ( (! connection->suspended) && MHD_D_IS_USING_EPOLL_ (daemon) ) { ret = MHD_connection_epoll_update_ (connection); } #endif /* EPOLL_SUPPORT */ connection->in_idle = false; return ret; } #ifdef EPOLL_SUPPORT /** * Perform epoll() processing, possibly moving the connection back into * the epoll() set if needed. * * @param connection connection to process * @return #MHD_YES if we should continue to process the * connection (not dead yet), #MHD_NO if it died */ enum MHD_Result MHD_connection_epoll_update_ (struct MHD_Connection *connection) { struct MHD_Daemon *const daemon = connection->daemon; mhd_assert (MHD_D_IS_USING_EPOLL_ (daemon)); if ((0 != (MHD_EVENT_LOOP_INFO_PROCESS & connection->event_loop_info)) && (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL))) { /* Make sure that connection waiting for processing will be processed */ EDLL_insert (daemon->eready_head, daemon->eready_tail, connection); connection->epoll_state |= MHD_EPOLL_STATE_IN_EREADY_EDLL; } if ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) && (0 == (connection->epoll_state & MHD_EPOLL_STATE_SUSPENDED)) && ( ( (MHD_EVENT_LOOP_INFO_WRITE == connection->event_loop_info) && (0 == (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY))) || ( (0 != (MHD_EVENT_LOOP_INFO_READ & connection->event_loop_info)) && (0 == (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) ) ) ) { /* add to epoll set */ struct epoll_event event; event.events = EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLET; event.data.ptr = connection; if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_ADD, connection->socket_fd, &event)) { #ifdef HAVE_MESSAGES if (0 != (daemon->options & MHD_USE_ERROR_LOG)) MHD_DLOG (daemon, _ ("Call to epoll_ctl failed: %s\n"), MHD_socket_last_strerr_ ()); #endif connection->state = MHD_CONNECTION_CLOSED; cleanup_connection (connection); return MHD_NO; } connection->epoll_state |= MHD_EPOLL_STATE_IN_EPOLL_SET; } return MHD_YES; } #endif /** * Set callbacks for this connection to those for HTTP. * * @param connection connection to initialize */ void MHD_set_http_callbacks_ (struct MHD_Connection *connection) { connection->recv_cls = &recv_param_adapter; } /** * Obtain information about the given connection. * The returned pointer is invalidated with the next call of this function or * when the connection is closed. * * @param connection what connection to get information about * @param info_type what information is desired? * @param ... depends on @a info_type * @return NULL if this information is not available * (or if the @a info_type is unknown) * @ingroup specialized */ _MHD_EXTERN const union MHD_ConnectionInfo * MHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType info_type, ...) { switch (info_type) { #ifdef HTTPS_SUPPORT case MHD_CONNECTION_INFO_CIPHER_ALGO: if (NULL == connection->tls_session) return NULL; if (1) { /* Workaround to mute compiler warning */ gnutls_cipher_algorithm_t res; res = gnutls_cipher_get (connection->tls_session); connection->connection_info_dummy.cipher_algorithm = (int) res; } return &connection->connection_info_dummy; case MHD_CONNECTION_INFO_PROTOCOL: if (NULL == connection->tls_session) return NULL; if (1) { /* Workaround to mute compiler warning */ gnutls_protocol_t res; res = gnutls_protocol_get_version (connection->tls_session); connection->connection_info_dummy.protocol = (int) res; } return &connection->connection_info_dummy; case MHD_CONNECTION_INFO_GNUTLS_SESSION: if (NULL == connection->tls_session) return NULL; connection->connection_info_dummy.tls_session = connection->tls_session; return &connection->connection_info_dummy; #else /* ! HTTPS_SUPPORT */ case MHD_CONNECTION_INFO_CIPHER_ALGO: case MHD_CONNECTION_INFO_PROTOCOL: case MHD_CONNECTION_INFO_GNUTLS_SESSION: #endif /* ! HTTPS_SUPPORT */ case MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT: return NULL; /* Not implemented */ case MHD_CONNECTION_INFO_CLIENT_ADDRESS: if (0 < connection->addr_len) { mhd_assert (sizeof (connection->addr) == \ sizeof (connection->connection_info_dummy.client_addr)); memcpy (&connection->connection_info_dummy.client_addr, &connection->addr, sizeof(connection->addr)); return &connection->connection_info_dummy; } return NULL; case MHD_CONNECTION_INFO_DAEMON: connection->connection_info_dummy.daemon = MHD_get_master (connection->daemon); return &connection->connection_info_dummy; case MHD_CONNECTION_INFO_CONNECTION_FD: connection->connection_info_dummy.connect_fd = connection->socket_fd; return &connection->connection_info_dummy; case MHD_CONNECTION_INFO_SOCKET_CONTEXT: connection->connection_info_dummy.socket_context = connection->socket_context; return &connection->connection_info_dummy; case MHD_CONNECTION_INFO_CONNECTION_SUSPENDED: connection->connection_info_dummy.suspended = connection->suspended ? MHD_YES : MHD_NO; return &connection->connection_info_dummy; case MHD_CONNECTION_INFO_CONNECTION_TIMEOUT: #if SIZEOF_UNSIGNED_INT <= (SIZEOF_UINT64_T - 2) if (UINT_MAX < connection->connection_timeout_ms / 1000) connection->connection_info_dummy.connection_timeout = UINT_MAX; else #endif /* SIZEOF_UNSIGNED_INT <=(SIZEOF_UINT64_T - 2) */ connection->connection_info_dummy.connection_timeout = (unsigned int) (connection->connection_timeout_ms / 1000); return &connection->connection_info_dummy; case MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE: if ( (MHD_CONNECTION_HEADERS_RECEIVED > connection->state) || (MHD_CONNECTION_CLOSED == connection->state) ) return NULL; /* invalid, too early! */ connection->connection_info_dummy.header_size = connection->rq.header_size; return &connection->connection_info_dummy; case MHD_CONNECTION_INFO_HTTP_STATUS: if (NULL == connection->rp.response) return NULL; connection->connection_info_dummy.http_status = connection->rp.responseCode; return &connection->connection_info_dummy; default: return NULL; } } /** * Set a custom option for the given connection, overriding defaults. * * @param connection connection to modify * @param option option to set * @param ... arguments to the option, depending on the option type * @return #MHD_YES on success, #MHD_NO if setting the option failed * @ingroup specialized */ _MHD_EXTERN enum MHD_Result MHD_set_connection_option (struct MHD_Connection *connection, enum MHD_CONNECTION_OPTION option, ...) { va_list ap; struct MHD_Daemon *daemon; unsigned int ui_val; daemon = connection->daemon; switch (option) { case MHD_CONNECTION_OPTION_TIMEOUT: if (0 == connection->connection_timeout_ms) connection->last_activity = MHD_monotonic_msec_counter (); va_start (ap, option); ui_val = va_arg (ap, unsigned int); va_end (ap); #if (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT if ((UINT64_MAX / 4000 - 1) < ui_val) { #ifdef HAVE_MESSAGES MHD_DLOG (connection->daemon, _ ("The specified connection timeout (%u) is too " \ "large. Maximum allowed value (%" PRIu64 ") will be used " \ "instead.\n"), ui_val, (UINT64_MAX / 4000 - 1)); #endif ui_val = UINT64_MAX / 4000 - 1; } #endif /* (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT */ if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) { #if defined(MHD_USE_THREADS) MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif if (! connection->suspended) { if (connection->connection_timeout_ms == daemon->connection_timeout_ms) XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); else XDLL_remove (daemon->manual_timeout_head, daemon->manual_timeout_tail, connection); connection->connection_timeout_ms = ((uint64_t) ui_val) * 1000; if (connection->connection_timeout_ms == daemon->connection_timeout_ms) XDLL_insert (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); else XDLL_insert (daemon->manual_timeout_head, daemon->manual_timeout_tail, connection); } #if defined(MHD_USE_THREADS) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); #endif } return MHD_YES; default: return MHD_NO; } } /** * Queue a response to be transmitted to the client (as soon as * possible but after #MHD_AccessHandlerCallback returns). * * For any active connection this function must be called * only by #MHD_AccessHandlerCallback callback. * * For suspended connection this function can be called at any moment (this * behaviour is deprecated and will be removed!). Response will be sent * as soon as connection is resumed. * * For single thread environment, when MHD is used in "external polling" mode * (without MHD_USE_SELECT_INTERNALLY) this function can be called any * time (this behaviour is deprecated and will be removed!). * * If HTTP specifications require use no body in reply, like @a status_code with * value 1xx, the response body is automatically not sent even if it is present * in the response. No "Content-Length" or "Transfer-Encoding" headers are * generated and added. * * When the response is used to respond HEAD request or used with @a status_code * #MHD_HTTP_NOT_MODIFIED, then response body is not sent, but "Content-Length" * header is added automatically based the size of the body in the response. * If body size it set to #MHD_SIZE_UNKNOWN or chunked encoding is enforced * then "Transfer-Encoding: chunked" header (for HTTP/1.1 only) is added instead * of "Content-Length" header. For example, if response with zero-size body is * used for HEAD request, then "Content-Length: 0" is added automatically to * reply headers. * @sa #MHD_RF_HEAD_ONLY_RESPONSE * * In situations, where reply body is required, like answer for the GET request * with @a status_code #MHD_HTTP_OK, headers "Content-Length" (for known body * size) or "Transfer-Encoding: chunked" (for #MHD_SIZE_UNKNOWN with HTTP/1.1) * are added automatically. * In practice, the same response object can be used to respond to both HEAD and * GET requests. * * @param connection the connection identifying the client * @param status_code HTTP status code (i.e. #MHD_HTTP_OK) * @param response response to transmit, the NULL is tolerated * @return #MHD_NO on error (reply already sent, response is NULL), * #MHD_YES on success or if message has been queued * @ingroup response * @sa #MHD_AccessHandlerCallback */ _MHD_EXTERN enum MHD_Result MHD_queue_response (struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response) { struct MHD_Daemon *daemon; bool reply_icy; if ((NULL == connection) || (NULL == response)) return MHD_NO; daemon = connection->daemon; if ((! connection->in_access_handler) && (! connection->suspended) && MHD_D_IS_USING_THREADS_ (daemon)) return MHD_NO; reply_icy = (0 != (status_code & MHD_ICY_FLAG)); status_code &= ~MHD_ICY_FLAG; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) if ( (! connection->suspended) && MHD_D_IS_USING_THREADS_ (daemon) && (! MHD_thread_handle_ID_is_current_thread_ (connection->tid)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Attempted to queue response on wrong thread!\n")); #endif return MHD_NO; } #endif if (NULL != connection->rp.response) return MHD_NO; /* The response was already set */ if ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) && (MHD_CONNECTION_FULL_REQ_RECEIVED != connection->state) ) return MHD_NO; /* Wrong connection state */ if (daemon->shutdown) return MHD_NO; #ifdef UPGRADE_SUPPORT if (NULL != response->upgrade_handler) { struct MHD_HTTP_Res_Header *conn_header; if (0 == (daemon->options & MHD_ALLOW_UPGRADE)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Attempted 'upgrade' connection on daemon without" \ " MHD_ALLOW_UPGRADE option!\n")); #endif return MHD_NO; } if (MHD_HTTP_SWITCHING_PROTOCOLS != status_code) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Application used invalid status code for" \ " 'upgrade' response!\n")); #endif return MHD_NO; } if (0 == (response->flags_auto & MHD_RAF_HAS_CONNECTION_HDR)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Application used invalid response" \ " without \"Connection\" header!\n")); #endif return MHD_NO; } conn_header = response->first_header; mhd_assert (NULL != conn_header); mhd_assert (MHD_str_equal_caseless_ (conn_header->header, MHD_HTTP_HEADER_CONNECTION)); if (! MHD_str_has_s_token_caseless_ (conn_header->value, "upgrade")) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Application used invalid response" \ " without \"upgrade\" token in" \ " \"Connection\" header!\n")); #endif return MHD_NO; } if (! MHD_IS_HTTP_VER_1_1_COMPAT (connection->rq.http_ver)) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Connection \"Upgrade\" can be used only " \ "with HTTP/1.1 connections!\n")); #endif return MHD_NO; } } #endif /* UPGRADE_SUPPORT */ if (MHD_HTTP_SWITCHING_PROTOCOLS == status_code) { #ifdef UPGRADE_SUPPORT if (NULL == response->upgrade_handler) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Application used status code 101 \"Switching Protocols\" " \ "with non-'upgrade' response!\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; } #else /* ! UPGRADE_SUPPORT */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Application used status code 101 \"Switching Protocols\", " \ "but this MHD was built without \"Upgrade\" support!\n")); #endif /* HAVE_MESSAGES */ return MHD_NO; #endif /* ! UPGRADE_SUPPORT */ } if ( (100 > status_code) || (999 < status_code) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Refused wrong status code (%u). " \ "HTTP requires three digits status code!\n"), status_code); #endif return MHD_NO; } if (200 > status_code) { if (MHD_HTTP_VER_1_0 == connection->rq.http_ver) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Wrong status code (%u) refused. " \ "HTTP/1.0 clients do not support 1xx status codes!\n"), (status_code)); #endif return MHD_NO; } if (0 != (response->flags & (MHD_RF_HTTP_1_0_COMPATIBLE_STRICT | MHD_RF_HTTP_1_0_SERVER))) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Wrong status code (%u) refused. " \ "HTTP/1.0 reply mode does not support 1xx status codes!\n"), (status_code)); #endif return MHD_NO; } } if ( (MHD_HTTP_MTHD_CONNECT == connection->rq.http_mthd) && (2 == status_code / 100) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Successful (%u) response code cannot be used to answer " \ "\"CONNECT\" request!\n"), (status_code)); #endif return MHD_NO; } if ( (0 != (MHD_RF_HEAD_ONLY_RESPONSE & response->flags)) && (RP_BODY_HEADERS_ONLY < is_reply_body_needed (connection, status_code)) ) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("HEAD-only response cannot be used when the request requires " "reply body to be sent!\n")); #endif return MHD_NO; } #ifdef HAVE_MESSAGES if ( (0 != (MHD_RF_INSANITY_HEADER_CONTENT_LENGTH & response->flags)) && (0 != (MHD_RAF_HAS_CONTENT_LENGTH & response->flags_auto)) ) { MHD_DLOG (daemon, _ ("The response has application-defined \"Content-Length\" " \ "header. The reply to the request will be not " \ "HTTP-compliant and may result in hung connection or " \ "other problems!\n")); } #endif MHD_increment_response_rc (response); connection->rp.response = response; connection->rp.responseCode = status_code; connection->rp.responseIcy = reply_icy; #if defined(_MHD_HAVE_SENDFILE) if ( (response->fd == -1) || (response->is_pipe) || (0 != (connection->daemon->options & MHD_USE_TLS)) #if defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) && \ defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) || (! daemon->sigpipe_blocked && ! connection->sk_spipe_suppress) #endif /* MHD_SEND_SPIPE_SUPPRESS_NEEDED && MHD_SEND_SPIPE_SUPPRESS_POSSIBLE */ ) connection->rp.resp_sender = MHD_resp_sender_std; else connection->rp.resp_sender = MHD_resp_sender_sendfile; #endif /* _MHD_HAVE_SENDFILE */ /* FIXME: if 'is_pipe' is set, TLS is off, and we have *splice*, we could use splice() to avoid two user-space copies... */ if ( (MHD_HTTP_MTHD_HEAD == connection->rq.http_mthd) || (MHD_HTTP_OK > status_code) || (MHD_HTTP_NO_CONTENT == status_code) || (MHD_HTTP_NOT_MODIFIED == status_code) ) { /* if this is a "HEAD" request, or a status code for which a body is not allowed, pretend that we have already sent the full message body. */ /* TODO: remove the next assignment, use 'rp_props.send_reply_body' in * checks */ connection->rp.rsp_write_position = response->total_size; } if (MHD_CONNECTION_HEADERS_PROCESSED == connection->state) { /* response was queued "early", refuse to read body / footers or further requests! */ connection->discard_request = true; connection->state = MHD_CONNECTION_START_REPLY; connection->rq.remaining_upload_size = 0; } if (! connection->in_idle) (void) MHD_connection_handle_idle (connection); MHD_update_last_activity_ (connection); return MHD_YES; } /* end of connection.c */ libmicrohttpd-1.0.1/src/microhttpd/test_options.c0000644000175000017500000001743414530120375015711 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_options.c * @brief Testcase for libmicrohttpd HTTPS GET operations * @author Sagie Amir */ #include "platform.h" #include "microhttpd.h" #include "mhd_sockets.h" static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { (void) cls; (void) connection; (void) url; (void) method; (void) version; (void) upload_data; (void) upload_data_size; (void) req_cls; return 0; } static unsigned int test_wrap_loc (const char *test_name, unsigned int (*test)(void)) { unsigned int ret; fprintf (stdout, "running test: %s ", test_name); ret = test (); if (ret == 0) { fprintf (stdout, "[pass]\n"); } else { fprintf (stdout, "[fail]\n"); } return ret; } /** * Test daemon initialization with the MHD_OPTION_SOCK_ADDR or * the MHD_OPTION_SOCK_ADDR_LEN options */ static unsigned int test_ip_addr_option (void) { struct MHD_Daemon *d; const union MHD_DaemonInfo *dinfo; struct sockaddr_in daemon_ip_addr; uint16_t port4; #if defined(HAVE_INET6) && defined(USE_IPV6_TESTING) struct sockaddr_in6 daemon_ip_addr6; uint16_t port6; #endif unsigned int ret; memset (&daemon_ip_addr, 0, sizeof (struct sockaddr_in)); daemon_ip_addr.sin_family = AF_INET; daemon_ip_addr.sin_port = 0; daemon_ip_addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); port4 = 0; #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; daemon_ip_addr6.sin6_addr = in6addr_loopback; port6 = 0; #endif ret = 0; d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR, &daemon_ip_addr, MHD_OPTION_END); if (d == 0) return 1; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if (NULL == dinfo) ret |= 1 << 1; else port4 = dinfo->port; MHD_stop_daemon (d); daemon_ip_addr.sin_port = htons (port4); d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR_LEN, (socklen_t) sizeof(daemon_ip_addr), &daemon_ip_addr, MHD_OPTION_END); if (d == 0) return 1; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if (NULL == dinfo) ret |= 1 << 1; else if (port4 != dinfo->port) ret |= 1 << 2; MHD_stop_daemon (d); d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR_LEN, (socklen_t) (sizeof(daemon_ip_addr) / 2), &daemon_ip_addr, MHD_OPTION_END); if (NULL != d) { MHD_stop_daemon (d); return 1 << 3; } #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN daemon_ip_addr.sin_len = (socklen_t) sizeof(daemon_ip_addr); d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR_LEN, (socklen_t) sizeof(daemon_ip_addr), &daemon_ip_addr, MHD_OPTION_END); if (d == 0) return 1; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if (NULL == dinfo) ret |= 1 << 1; else if (port4 != dinfo->port) ret |= 1 << 2; MHD_stop_daemon (d); daemon_ip_addr.sin_len = (socklen_t) (sizeof(daemon_ip_addr) / 2); d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR_LEN, (socklen_t) sizeof(daemon_ip_addr), &daemon_ip_addr, MHD_OPTION_END); if (NULL != d) { MHD_stop_daemon (d); return 1 << 3; } #endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ #if defined(HAVE_INET6) && defined(USE_IPV6_TESTING) d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_IPv6 | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR, &daemon_ip_addr6, MHD_OPTION_END); if (d == 0) return 1; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if (NULL == dinfo) ret |= 1 << 1; else port6 = dinfo->port; MHD_stop_daemon (d); daemon_ip_addr6.sin6_port = htons (port6); d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR_LEN, (socklen_t) sizeof(daemon_ip_addr6), &daemon_ip_addr6, MHD_OPTION_END); if (d == 0) return 1; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if (NULL == dinfo) ret |= 1 << 1; else if (port6 != dinfo->port) ret |= 1 << 2; MHD_stop_daemon (d); d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR_LEN, (socklen_t) (sizeof(daemon_ip_addr6) / 2), &daemon_ip_addr6, MHD_OPTION_END); if (NULL != d) { MHD_stop_daemon (d); return 1 << 3; } #if defined(HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN) daemon_ip_addr6.sin6_len = (socklen_t) sizeof(daemon_ip_addr6); d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR_LEN, (socklen_t) sizeof(daemon_ip_addr6), &daemon_ip_addr6, MHD_OPTION_END); if (d == 0) return 1; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if (NULL == dinfo) ret |= 1 << 1; else if (port6 != dinfo->port) ret |= 1 << 2; MHD_stop_daemon (d); daemon_ip_addr6.sin6_len = (socklen_t) (sizeof(daemon_ip_addr6) / 2); d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_NO_THREAD_SAFETY, 0, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_SOCK_ADDR_LEN, (socklen_t) sizeof(daemon_ip_addr6), &daemon_ip_addr6, MHD_OPTION_END); if (NULL != d) { MHD_stop_daemon (d); return 1 << 3; } #endif /* HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN */ #endif /* HAVE_INET6 && USE_IPV6_TESTING */ return ret; } /* setup a temporary transfer test file */ int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ errorCount += test_wrap_loc ("ip addr option", &test_ip_addr_option); return errorCount != 0; } libmicrohttpd-1.0.1/src/microhttpd/mhd_panic.h0000644000175000017500000000465714566122702015116 /* This file is part of libmicrohttpd Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_panic.h * @brief Declaration and macros for MHD_panic() * @author Daniel Pittman * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_PANIC_H #define MHD_PANIC_H 1 #include "mhd_options.h" #ifdef MHD_PANIC /* Override any possible defined MHD_PANIC macro with proper one */ #undef MHD_PANIC #endif /* MHD_PANIC */ /* If we have Clang or gcc >= 4.5, use __builtin_unreachable() */ #if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 4) || \ (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 5) #define BUILTIN_NOT_REACHED __builtin_unreachable () #elif defined(_MSC_FULL_VER) #define BUILTIN_NOT_REACHED __assume (0) #else #define BUILTIN_NOT_REACHED #endif /* The MHD_PanicCallback type, but without main header. */ /** * Handler for fatal errors. */ extern void (*mhd_panic) (void *cls, const char *file, unsigned int line, const char *reason); /** * Closure argument for "mhd_panic". */ extern void *mhd_panic_cls; #ifdef HAVE_MESSAGES /** * Trigger 'panic' action based on fatal errors. * * @param msg error message (const char *) */ #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg); \ BUILTIN_NOT_REACHED; } while (0) #else /** * Trigger 'panic' action based on fatal errors. * * @param msg error message (const char *) */ #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, NULL, __LINE__, NULL); \ BUILTIN_NOT_REACHED; } while (0) #endif #endif /* MHD_PANIC_H */ libmicrohttpd-1.0.1/src/microhttpd/test_str.c0000644000175000017500000046242414556230011015026 /* This file is part of libmicrohttpd Copyright (C) 2016 Karlson2k (Evgeny Grin) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This test tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/unit_str_test.h * @brief Unit tests for mhd_str functions * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include #ifdef HAVE_INTTYPES_H #include #else /* ! HAVE_INTTYPES_H */ #define PRIu64 "llu" #define PRIuPTR "u" #define PRIX64 "llX" #endif /* ! HAVE_INTTYPES_H */ #include #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include "mhd_limits.h" #include "mhd_str.h" #include "test_helpers.h" static int verbose = 0; /* verbose level (0-3)*/ /* Locale names to test. * Functions must not depend of current current locale, * so result must be the same in any locale. */ static const char *const locale_names[] = { "C", "", /* System default locale */ #if defined(_WIN32) && ! defined(__CYGWIN__) ".OCP", /* W32 system default OEM code page */ ".ACP", /* W32 system default ANSI code page */ ".65001", /* UTF-8 */ ".437", ".850", ".857", ".866", ".1250", ".1251", ".1252", "en", "english", "French_France", "Turkish_Turkey.1254", "de", "zh-Hans", "ru-RU.1251" #if 0 /* Disabled extra checks */ , ".1254", ".20866", /* number for KOI8-R */ ".28591", /* number for ISO-8859-1 */ ".28595", /* number for ISO-8859-5 */ ".28599", /* number for ISO-8859-9 */ ".28605", /* number for ISO-8859-15 */ "en-US", "English-US", "en-US.437", "English_United States.437", "en-US.1252", "English_United States.1252", "English_United States.28591", "English_United States.65001", "fra", "french", "fr-FR", "fr-FR.850", "french_france.850", "fr-FR.1252", "French_france.1252", "French_france.28605", "French_France.65001", "de-DE", "de-DE.850", "German_Germany.850", "German_Germany.1250", "de-DE.1252", "German_Germany.1252", "German_Germany.28605", "German_Germany.65001", "tr", "trk", "turkish", "tr-TR", "tr-TR.1254", "tr-TR.857", "Turkish_Turkey.857", "Turkish_Turkey.28599", "Turkish_Turkey.65001", "ru", "ru-RU", "Russian", "ru-RU.866", "Russian_Russia.866", "Russian_Russia.1251", "Russian_Russia.20866", "Russian_Russia.28595", "Russian_Russia.65001", "zh-Hans.936", "chinese-simplified" #endif /* Disabled extra checks */ #else /* ! _WIN32 || __CYGWIN__ */ "C.UTF-8", "POSIX", "en", "en_US", "en_US.ISO-8859-1", "en_US.ISO_8859-1", "en_US.ISO8859-1", "en_US.iso88591", "en_US.ISO-8859-15", "en_US.DIS_8859-15", "en_US.ISO8859-15", "en_US.iso885915", "en_US.1252", "en_US.CP1252", "en_US.UTF-8", "en_US.utf8", "fr", "fr_FR", "fr_FR.850", "fr_FR.IBM850", "fr_FR.1252", "fr_FR.CP1252", "fr_FR.ISO-8859-1", "fr_FR.ISO_8859-1", "fr_FR.ISO8859-1", "fr_FR.iso88591", "fr_FR.ISO-8859-15", "fr_FR.DIS_8859-15", "fr_FR.ISO8859-15", "fr_FR.iso8859-15", "fr_FR.UTF-8", "fr_FR.utf8", "de", "de_DE", "de_DE.850", "de_DE.IBM850", "de_DE.1250", "de_DE.CP1250", "de_DE.1252", "de_DE.CP1252", "de_DE.ISO-8859-1", "de_DE.ISO_8859-1", "de_DE.ISO8859-1", "de_DE.iso88591", "de_DE.ISO-8859-15", "de_DE.DIS_8859-15", "de_DE.ISO8859-15", "de_DE.iso885915", "de_DE.UTF-8", "de_DE.utf8", "tr", "tr_TR", "tr_TR.1254", "tr_TR.CP1254", "tr_TR.857", "tr_TR.IBM857", "tr_TR.ISO-8859-9", "tr_TR.ISO8859-9", "tr_TR.iso88599", "tr_TR.UTF-8", "tr_TR.utf8", "ru", "ru_RU", "ru_RU.1251", "ru_RU.CP1251", "ru_RU.866", "ru_RU.IBM866", "ru_RU.KOI8-R", "ru_RU.koi8-r", "ru_RU.KOI8-RU", "ru_RU.ISO-8859-5", "ru_RU.ISO_8859-5", "ru_RU.ISO8859-5", "ru_RU.iso88595", "ru_RU.UTF-8", "zh_CN", "zh_CN.GB2312", "zh_CN.UTF-8", #endif /* ! _WIN32 || __CYGWIN__ */ }; static const unsigned int locale_name_count = sizeof(locale_names) / sizeof(locale_names[0]); /* * Helper functions */ static int set_test_locale (size_t num) { if (num >= locale_name_count) { fprintf (stderr, "Unexpected number of locale.\n"); exit (99); } if (verbose > 2) printf ("Setting locale \"%s\":", locale_names[num]); if (setlocale (LC_ALL, locale_names[num])) { if (verbose > 2) printf (" succeed.\n"); return 1; } if (verbose > 2) printf (" failed.\n"); return 0; } static const char * get_current_locale_str (void) { char const *loc_str = setlocale (LC_ALL, NULL); return loc_str ? loc_str : "unknown"; } static char tmp_bufs[4][4 * 1024]; /* should be enough for testing */ static size_t buf_idx = 0; /* print non-printable chars as char codes */ static char * n_prnt (const char *str) { static char *buf; /* should be enough for testing */ static const size_t buf_size = sizeof(tmp_bufs[0]); const unsigned char *p = (const unsigned char *) str; size_t w_pos = 0; if (++buf_idx > 3) buf_idx = 0; buf = tmp_bufs[buf_idx]; while (*p && w_pos + 1 < buf_size) { const unsigned char c = *p; if ((c == '\\') || (c == '"') ) { if (w_pos + 2 >= buf_size) break; buf[w_pos++] = '\\'; buf[w_pos++] = (char) c; } else if ((c >= 0x20) && (c <= 0x7E) ) buf[w_pos++] = (char) c; else { if (w_pos + 4 >= buf_size) break; if (snprintf (buf + w_pos, buf_size - w_pos, "\\x%02hX", (short unsigned int) c) != 4) break; w_pos += 4; } p++; } if (*p) { /* not full string is printed */ /* enough space for "..." ? */ if (w_pos + 3 > buf_size) w_pos = buf_size - 4; buf[w_pos++] = '.'; buf[w_pos++] = '.'; buf[w_pos++] = '.'; } buf[w_pos] = 0; return buf; } struct str_with_len { const char *const str; const size_t len; }; #define D_STR_W_LEN(s) {(s), (sizeof((s)) / sizeof(char)) - 1} /* * String caseless equality functions tests */ struct two_eq_strs { const struct str_with_len s1; const struct str_with_len s2; }; static const struct two_eq_strs eq_strings[] = { {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."), D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`.")}, {D_STR_W_LEN ("Simple string."), D_STR_W_LEN ("Simple string.")}, {D_STR_W_LEN ("SIMPLE STRING."), D_STR_W_LEN ("SIMPLE STRING.")}, {D_STR_W_LEN ("simple string."), D_STR_W_LEN ("simple string.")}, {D_STR_W_LEN ("simple string."), D_STR_W_LEN ("Simple String.")}, {D_STR_W_LEN ("sImPlE StRiNg."), D_STR_W_LEN ("SiMpLe sTrInG.")}, {D_STR_W_LEN ("SIMPLE STRING."), D_STR_W_LEN ("simple string.")}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"), D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz")}, {D_STR_W_LEN ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), D_STR_W_LEN ("ABCDEFGHIJKLMNOPQRSTUVWXYZ")}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"), D_STR_W_LEN ("ABCDEFGHIJKLMNOPQRSTUVWXYZ")}, {D_STR_W_LEN ("zyxwvutsrqponMLKJIHGFEDCBA"), D_STR_W_LEN ("ZYXWVUTSRQPONmlkjihgfedcba")}, {D_STR_W_LEN ("Cha\x8cne pour le test."), D_STR_W_LEN ("Cha\x8cne pour le test.")}, /* "Chaîne pour le test." in CP850 */ {D_STR_W_LEN ("cha\x8cne pOur Le TEst."), D_STR_W_LEN ("Cha\x8cne poUr Le teST.")}, {D_STR_W_LEN ("Cha\xeene pour le test."), D_STR_W_LEN ("Cha\xeene pour le test.")}, /* "Chaîne pour le test." in CP1252/ISO-8859-1/ISO-8859-15 */ {D_STR_W_LEN ("CHa\xeene POUR le test."), D_STR_W_LEN ("Cha\xeeNe pour lE TEST.")}, {D_STR_W_LEN ("Cha\xc3\xaene pour le Test."), D_STR_W_LEN ("Cha\xc3\xaene pour le Test.")}, /* "Chaîne pour le test." in UTF-8 */ {D_STR_W_LEN ("ChA\xc3\xaene pouR lE TesT."), D_STR_W_LEN ("Cha\xc3\xaeNe Pour le teSt.")}, {D_STR_W_LEN (".Beispiel Zeichenfolge"), D_STR_W_LEN (".Beispiel Zeichenfolge")}, {D_STR_W_LEN (".bEisPiel ZEIchenfoLgE"), D_STR_W_LEN (".BEiSpiEl zeIcheNfolge")}, {D_STR_W_LEN ("Do\xa7rulama \x87izgi!"), D_STR_W_LEN ("Do\xa7rulama \x87izgi!")}, /* "DoÄŸrulama çizgi!" in CP857 */ {D_STR_W_LEN ("Do\xa7rulama \x87IzgI!"), /* Spelling intentionally incorrect here */ D_STR_W_LEN ("Do\xa7rulama \x87izgi!")}, /* Note: 'i' is not caseless equal to 'I' in Turkish */ {D_STR_W_LEN ("Do\xf0rulama \xe7izgi!"), D_STR_W_LEN ("Do\xf0rulama \xe7izgi!")}, /* "DoÄŸrulama çizgi!" in CP1254/ISO-8859-9 */ {D_STR_W_LEN ("Do\xf0rulamA \xe7Izgi!"), D_STR_W_LEN ("do\xf0rulama \xe7izgi!")}, {D_STR_W_LEN ("Do\xc4\x9frulama \xc3\xa7izgi!"), D_STR_W_LEN ("Do\xc4\x9frulama \xc3\xa7izgi!")}, /* "DoÄŸrulama çizgi!" in UTF-8 */ {D_STR_W_LEN ("do\xc4\x9fruLAMA \xc3\xa7Izgi!"), /* Spelling intentionally incorrect here */ D_STR_W_LEN ("DO\xc4\x9frulama \xc3\xa7izgI!")}, /* Spelling intentionally incorrect here */ {D_STR_W_LEN ("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0."), D_STR_W_LEN ("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0.")}, /* "ТеÑÑ‚Ð¾Ð²Ð°Ñ Ð¡Ñ‚Ñ€Ð¾ÐºÐ°." in CP866 */ {D_STR_W_LEN ("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0."), D_STR_W_LEN ("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0.")}, /* "ТеÑÑ‚Ð¾Ð²Ð°Ñ Ð¡Ñ‚Ñ€Ð¾ÐºÐ°." in CP1251 */ {D_STR_W_LEN ("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1."), D_STR_W_LEN ("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1.")}, /* "ТеÑÑ‚Ð¾Ð²Ð°Ñ Ð¡Ñ‚Ñ€Ð¾ÐºÐ°." in KOI8-R */ {D_STR_W_LEN ("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0."), D_STR_W_LEN ("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0.")}, /* "ТеÑÑ‚Ð¾Ð²Ð°Ñ Ð¡Ñ‚Ñ€Ð¾ÐºÐ°." in ISO-8859-5 */ {D_STR_W_LEN ("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1" "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0."), D_STR_W_LEN ("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1" "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0.")}, /* "ТеÑÑ‚Ð¾Ð²Ð°Ñ Ð¡Ñ‚Ñ€Ð¾ÐºÐ°." in UTF-8 */ {D_STR_W_LEN ( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@[\\]" "^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90" "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4" "\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8" "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc" "\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0" "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4" "\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"), D_STR_W_LEN ( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@[\\]" "^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90" "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4" "\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8" "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc" "\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0" "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4" "\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")}, /* Full sequence without a-z */ {D_STR_W_LEN ( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB" "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83" "\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97" "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab" "\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" "\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb" "\xfc\xfd\xfe\xff"), D_STR_W_LEN ( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB" "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83" "\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97" "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab" "\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" "\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb" "\xfc\xfd\xfe\xff")}, /* Full sequence */ {D_STR_W_LEN ( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB" "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89" "\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d" "\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1" "\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5" "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9" "\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed" "\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff") , D_STR_W_LEN ( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ab" "cdefghijklmnopqrstuvwxyz[\\]^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89" "\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d" "\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1" "\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5" "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9" "\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed" "\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff") } /* Full with A/a match */ }; struct two_neq_strs { const struct str_with_len s1; const struct str_with_len s2; const size_t dif_pos; }; static const struct two_neq_strs neq_strings[] = { {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."), D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`"), 27}, {D_STR_W_LEN (".1234567890!@~%&$@#{}[]\\/!?`."), D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`"), 0}, {D_STR_W_LEN ("Simple string."), D_STR_W_LEN ("Simple ctring."), 7}, {D_STR_W_LEN ("simple string."), D_STR_W_LEN ("simple string"), 13}, {D_STR_W_LEN ("simple strings"), D_STR_W_LEN ("Simple String."), 13}, {D_STR_W_LEN ("sImPlE StRiNg."), D_STR_W_LEN ("SYMpLe sTrInG."), 1}, {D_STR_W_LEN ("SIMPLE STRING."), D_STR_W_LEN ("simple string.2"), 14}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz,"), D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz."), 26}, {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz!"), D_STR_W_LEN ("ABCDEFGHIJKLMNOPQRSTUVWXYZ?"), 26}, {D_STR_W_LEN ("zyxwvutsrqponwMLKJIHGFEDCBA"), D_STR_W_LEN ("ZYXWVUTSRQPON%mlkjihgfedcba"), 13}, {D_STR_W_LEN ("S\xbdur veulent plus d'\xbdufs."), /* "SÅ“ur veulent plus d'Å“ufs." in ISO-8859-15 */ D_STR_W_LEN ("S\xbcUR VEULENT PLUS D'\xbcUFS."), 1}, /* "SÅ’UR VEULENT PLUS D'Å’UFS." in ISO-8859-15 */ {D_STR_W_LEN ("S\x9cur veulent plus d'\x9cufs."), /* "SÅ“ur veulent plus d'Å“ufs." in CP1252 */ D_STR_W_LEN ("S\x8cUR VEULENT PLUS D'\x8cUFS."), 1}, /* "SÅ’UR VEULENT PLUS D'Å’UFS." in CP1252 */ {D_STR_W_LEN ("S\xc5\x93ur veulent plus d'\xc5\x93ufs."), /* "SÅ“ur veulent plus d'Å“ufs." in UTF-8 */ D_STR_W_LEN ("S\xc5\x92UR VEULENT PLUS D'\xc5\x92UFS."), 2}, /* "SÅ’UR VEULENT PLUS D'Å’UFS." in UTF-8 */ {D_STR_W_LEN ("Um ein sch\x94nes M\x84" "dchen zu k\x81ssen."), /* "Um ein schönes Mädchen zu küssen." in CP850 */ D_STR_W_LEN ("UM EIN SCH\x99NES M\x8e" "DCHEN ZU K\x9aSSEN."), 10}, /* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in CP850 */ {D_STR_W_LEN ("Um ein sch\xf6nes M\xe4" "dchen zu k\xfcssen."), /* "Um ein schönes Mädchen zu küssen." in ISO-8859-1/ISO-8859-15/CP1250/CP1252 */ D_STR_W_LEN ("UM EIN SCH\xd6NES M\xc4" "DCHEN ZU K\xdcSSEN."), 10}, /* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in ISO-8859-1/ISO-8859-15/CP1250/CP1252 */ {D_STR_W_LEN ("Um ein sch\xc3\xb6nes M\xc3\xa4" "dchen zu k\xc3\xbcssen."), /* "Um ein schönes Mädchen zu küssen." in UTF-8 */ D_STR_W_LEN ("UM EIN SCH\xc3\x96NES M\xc3\x84" "DCHEN ZU K\xc3\x9cSSEN."), 11}, /* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in UTF-8 */ {D_STR_W_LEN ("\x98stanbul"), /* "İstanbul" in CP857 */ D_STR_W_LEN ("istanbul"), 0}, /* "istanbul" in CP857 */ {D_STR_W_LEN ("\xddstanbul"), /* "İstanbul" in ISO-8859-9/CP1254 */ D_STR_W_LEN ("istanbul"), 0}, /* "istanbul" in ISO-8859-9/CP1254 */ {D_STR_W_LEN ("\xc4\xb0stanbul"), /* "İstanbul" in UTF-8 */ D_STR_W_LEN ("istanbul"), 0}, /* "istanbul" in UTF-8 */ {D_STR_W_LEN ("Diyarbak\x8dr"), /* "Diyarbakır" in CP857 */ D_STR_W_LEN ("DiyarbakIR"), 8}, /* "DiyarbakIR" in CP857 */ {D_STR_W_LEN ("Diyarbak\xfdr"), /* "Diyarbakır" in ISO-8859-9/CP1254 */ D_STR_W_LEN ("DiyarbakIR"), 8}, /* "DiyarbakIR" in ISO-8859-9/CP1254 */ {D_STR_W_LEN ("Diyarbak\xc4\xb1r"), /* "Diyarbakır" in UTF-8 */ D_STR_W_LEN ("DiyarbakIR"), 8}, /* "DiyarbakIR" in UTF-8 */ {D_STR_W_LEN ("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0."), /* "ТеÑÑ‚Ð¾Ð²Ð°Ñ Ð¡Ñ‚Ñ€Ð¾ÐºÐ°." in CP866 */ D_STR_W_LEN ("\x92\x85\x91\x92\x8e\x82\x80\x9f \x91\x92\x90\x8e\x8a\x80."), 1}, /* "ТЕСТОВÐЯ СТРОКÐ." in CP866 */ {D_STR_W_LEN ("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0."), /* "ТеÑÑ‚Ð¾Ð²Ð°Ñ Ð¡Ñ‚Ñ€Ð¾ÐºÐ°." in CP1251 */ D_STR_W_LEN ("\xd2\xc5\xd1\xd2\xce\xc2\xc0\xdf \xd1\xd2\xd0\xce\xca\xc0."), 1}, /* "ТЕСТОВÐЯ СТРОКÐ." in CP1251 */ {D_STR_W_LEN ("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1."), /* "ТеÑÑ‚Ð¾Ð²Ð°Ñ Ð¡Ñ‚Ñ€Ð¾ÐºÐ°." in KOI8-R */ D_STR_W_LEN ("\xf4\xe5\xf3\xf4\xef\xf7\xe1\xf1 \xf3\xf4\xf2\xef\xeb\xe1."), 1}, /* "ТЕСТОВÐЯ СТРОКÐ." in KOI8-R */ {D_STR_W_LEN ("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0."), /* "ТеÑÑ‚Ð¾Ð²Ð°Ñ Ð¡Ñ‚Ñ€Ð¾ÐºÐ°." in ISO-8859-5 */ D_STR_W_LEN ("\xc2\xb5\xc1\xc2\xbe\xb2\xb0\xcf \xc1\xc2\xc0\xbe\xba\xb0."), 1}, /* "ТЕСТОВÐЯ СТРОКÐ." in ISO-8859-5 */ {D_STR_W_LEN ("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1" "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0."), /* "ТеÑÑ‚Ð¾Ð²Ð°Ñ Ð¡Ñ‚Ñ€Ð¾ÐºÐ°." in UTF-8 */ D_STR_W_LEN ("\xd0\xa2\xd0\x95\xd0\xa1\xd0\xa2\xd0\x9e\xd0\x92\xd0\x90\xd0" "\xaf \xd0\xa1\xd0\xa2\xd0\xa0\xd0\x9e\xd0\x9a\xd0\x90."), 3} /* "ТЕСТОВÐЯ СТРОКÐ." in UTF-8 */ }; static size_t check_eq_strings (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(eq_strings) / sizeof(eq_strings[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { const struct two_eq_strs *const t = eq_strings + i; if (c_failed[i]) continue; /* skip already failed checks */ if (! MHD_str_equal_caseless_ (t->s1.str, t->s2.str)) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned zero, while expected non-zero." " Locale: %s\n", n_prnt (t->s1.str), n_prnt (t->s2.str), get_current_locale_str ()); } else if (! MHD_str_equal_caseless_ (t->s2.str, t->s1.str)) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned zero, while expected non-zero." " Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str), get_current_locale_str ()); } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_equal_caseless_(\"%s\", \"%s\") != 0 && \\\n" " MHD_str_equal_caseless_(\"%s\", \"%s\") != 0\n", n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str), n_prnt (t->s1.str)); } } return t_failed; } static size_t check_neq_strings (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(neq_strings) / sizeof(neq_strings[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { const struct two_neq_strs *const t = neq_strings + i; if (c_failed[i]) continue; /* skip already failed checks */ if (MHD_str_equal_caseless_ (t->s1.str, t->s2.str)) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned non-zero, while expected zero." " Locale: %s\n", n_prnt (t->s1.str), n_prnt (t->s2.str), get_current_locale_str ()); } else if (MHD_str_equal_caseless_ (t->s2.str, t->s1.str)) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned non-zero, while expected zero." " Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str), get_current_locale_str ()); } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_equal_caseless_(\"%s\", \"%s\") == 0 && \\\n" " MHD_str_equal_caseless_(\"%s\", \"%s\") == 0\n", n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str), n_prnt (t->s1.str)); } } return t_failed; } static size_t check_eq_strings_n (void) { size_t t_failed = 0; size_t i, j, k; int c_failed[sizeof(eq_strings) / sizeof(eq_strings[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t m_len; const struct two_eq_strs *const t = eq_strings + i; m_len = (t->s1.len > t->s2.len) ? t->s1.len : t->s2.len; for (k = 0; k <= m_len + 1 && ! c_failed[i]; k++) { if (! MHD_str_equal_caseless_n_ (t->s1.str, t->s2.str, k)) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," " while expected non-zero. Locale: %s\n", n_prnt (t->s1.str), n_prnt (t->s2.str), (unsigned int) k, get_current_locale_str ()); } else if (! MHD_str_equal_caseless_n_ (t->s2.str, t->s1.str, k)) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," " while expected non-zero. Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) k, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) " \ "!= 0 && \\\n" \ " MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) " \ "!= 0, where N is 0..%u\n", n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) m_len + 1); } } return t_failed; } static size_t check_neq_strings_n (void) { size_t t_failed = 0; size_t i, j, k; int c_failed[sizeof(neq_strings) / sizeof(neq_strings[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t m_len; const struct two_neq_strs *const t = neq_strings + i; m_len = t->s1.len > t->s2.len ? t->s1.len : t->s2.len; if (t->dif_pos >= m_len) { fprintf (stderr, "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less than " "s1.len (%u) or s2.len (%u).\n", (unsigned int) i, (unsigned int) t-> dif_pos, (unsigned int) t->s1.len, (unsigned int) t->s2.len); exit (99); } if (t->dif_pos > t->s1.len) { fprintf (stderr, "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less or " "equal to s1.len (%u).\n", (unsigned int) i, (unsigned int) t->dif_pos, (unsigned int) t->s1.len); exit (99); } if (t->dif_pos > t->s2.len) { fprintf (stderr, "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less or " "equal to s2.len (%u).\n", (unsigned int) i, (unsigned int) t->dif_pos, (unsigned int) t->s2.len); exit (99); } for (k = 0; k <= m_len + 1 && ! c_failed[i]; k++) { if (k <= t->dif_pos) { if (! MHD_str_equal_caseless_n_ (t->s1.str, t->s2.str, k)) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," " while expected non-zero. Locale: %s\n", n_prnt (t->s1.str), n_prnt (t->s2.str), (unsigned int) k, get_current_locale_str ()); } else if (! MHD_str_equal_caseless_n_ (t->s2.str, t->s1.str, k)) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," " while expected non-zero. Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) k, get_current_locale_str ()); } } else { if (MHD_str_equal_caseless_n_ (t->s1.str, t->s2.str, k)) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned non-zero," " while expected zero. Locale: %s\n", n_prnt (t->s1.str), n_prnt (t->s2.str), (unsigned int) k, get_current_locale_str ()); } else if (MHD_str_equal_caseless_n_ (t->s2.str, t->s1.str, k)) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned non-zero," " while expected zero. Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) k, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) { printf ( "PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0 && \\\n" " MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0, where N is 0..%u\n", n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) t->dif_pos); printf ( "PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) == 0 && \\\n" " MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) == 0, where N is %u..%u\n", n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) t->dif_pos + 1, (unsigned int) m_len + 1); } } } return t_failed; } /* * Run eq/neq strings tests */ static int run_eq_neq_str_tests (void) { size_t str_equal_caseless_fails = 0; size_t str_equal_caseless_n_fails = 0; size_t res; res = check_eq_strings (); if (res != 0) { str_equal_caseless_fails += res; fprintf (stderr, "FAILED: testcase check_eq_strings() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_eq_strings() successfully passed.\n\n"); res = check_neq_strings (); if (res != 0) { str_equal_caseless_fails += res; fprintf (stderr, "FAILED: testcase check_neq_strings() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_neq_strings() successfully passed.\n\n"); if (str_equal_caseless_fails) fprintf (stderr, "FAILED: function MHD_str_equal_caseless_() failed %lu time%s.\n\n", (unsigned long) str_equal_caseless_fails, str_equal_caseless_fails == 1 ? "" : "s"); else if (verbose > 0) printf ( "PASSED: function MHD_str_equal_caseless_() successfully passed all checks.\n\n"); res = check_eq_strings_n (); if (res != 0) { str_equal_caseless_n_fails += res; fprintf (stderr, "FAILED: testcase check_eq_strings_n() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_eq_strings_n() successfully passed.\n\n"); res = check_neq_strings_n (); if (res != 0) { str_equal_caseless_n_fails += res; fprintf (stderr, "FAILED: testcase check_neq_strings_n() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_neq_strings_n() successfully passed.\n\n"); if (str_equal_caseless_n_fails) fprintf (stderr, "FAILED: function MHD_str_equal_caseless_n_() failed %lu time%s.\n\n", (unsigned long) str_equal_caseless_n_fails, str_equal_caseless_n_fails == 1 ? "" : "s"); else if (verbose > 0) printf ( "PASSED: function MHD_str_equal_caseless_n_() successfully passed all checks.\n\n"); if (str_equal_caseless_fails || str_equal_caseless_n_fails) { if (verbose > 0) printf ("At least one test failed.\n"); return 1; } if (verbose > 0) printf ("All tests passed successfully.\n"); return 0; } /* * Digits in string -> value tests */ struct str_with_value { const struct str_with_len str; const size_t num_of_digt; const uint64_t val; }; /* valid string for conversion to unsigned integer value */ static const struct str_with_value dstrs_w_values[] = { /* simplest strings */ {D_STR_W_LEN ("1"), 1, 1}, {D_STR_W_LEN ("0"), 1, 0}, {D_STR_W_LEN ("10000"), 5, 10000}, /* all digits */ {D_STR_W_LEN ("1234"), 4, 1234}, {D_STR_W_LEN ("4567"), 4, 4567}, {D_STR_W_LEN ("7890"), 4, 7890}, {D_STR_W_LEN ("8021"), 4, 8021}, {D_STR_W_LEN ("9754"), 4, 9754}, {D_STR_W_LEN ("6392"), 4, 6392}, /* various prefixes */ {D_STR_W_LEN ("00000000"), 8, 0}, {D_STR_W_LEN ("0755"), 4, 755}, /* not to be interpreted as octal value! */ {D_STR_W_LEN ("002"), 3, 2}, {D_STR_W_LEN ("0001"), 4, 1}, {D_STR_W_LEN ("00000000000000000000000031295483"), 32, 31295483}, /* numbers below and above limits */ {D_STR_W_LEN ("127"), 3, 127}, /* 0x7F, SCHAR_MAX */ {D_STR_W_LEN ("128"), 3, 128}, /* 0x80, SCHAR_MAX+1 */ {D_STR_W_LEN ("255"), 3, 255}, /* 0xFF, UCHAR_MAX */ {D_STR_W_LEN ("256"), 3, 256}, /* 0x100, UCHAR_MAX+1 */ {D_STR_W_LEN ("32767"), 5, 32767}, /* 0x7FFF, INT16_MAX */ {D_STR_W_LEN ("32768"), 5, 32768}, /* 0x8000, INT16_MAX+1 */ {D_STR_W_LEN ("65535"), 5, 65535}, /* 0xFFFF, UINT16_MAX */ {D_STR_W_LEN ("65536"), 5, 65536}, /* 0x10000, UINT16_MAX+1 */ {D_STR_W_LEN ("2147483647"), 10, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ {D_STR_W_LEN ("2147483648"), 10, UINT64_C (2147483648)}, /* 0x80000000, INT32_MAX+1 */ {D_STR_W_LEN ("4294967295"), 10, UINT64_C (4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ {D_STR_W_LEN ("4294967296"), 10, UINT64_C (4294967296)}, /* 0x100000000, UINT32_MAX+1 */ {D_STR_W_LEN ("9223372036854775807"), 19, UINT64_C (9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ {D_STR_W_LEN ("9223372036854775808"), 19, UINT64_C (9223372036854775808)}, /* 0x8000000000000000, INT64_MAX+1 */ {D_STR_W_LEN ("18446744073709551615"), 20, UINT64_C (18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ /* random numbers */ {D_STR_W_LEN ("10186753"), 8, 10186753}, {D_STR_W_LEN ("144402566"), 9, 144402566}, {D_STR_W_LEN ("151903144"), 9, 151903144}, {D_STR_W_LEN ("139264621"), 9, 139264621}, {D_STR_W_LEN ("730348"), 6, 730348}, {D_STR_W_LEN ("21584377"), 8, 21584377}, {D_STR_W_LEN ("709"), 3, 709}, {D_STR_W_LEN ("54"), 2, 54}, {D_STR_W_LEN ("8452"), 4, 8452}, {D_STR_W_LEN ("17745098750013624977"), 20, UINT64_C (17745098750013624977)}, {D_STR_W_LEN ("06786878769931678000"), 20, UINT64_C (6786878769931678000)}, /* non-digit suffixes */ {D_STR_W_LEN ("1234oa"), 4, 1234}, {D_STR_W_LEN ("20h"), 2, 20}, /* not to be interpreted as hex value! */ {D_STR_W_LEN ("0x1F"), 1, 0}, /* not to be interpreted as hex value! */ {D_STR_W_LEN ("0564`~}"), 4, 564}, {D_STR_W_LEN ("7240146.724"), 7, 7240146}, {D_STR_W_LEN ("2,9"), 1, 2}, {D_STR_W_LEN ("200+1"), 3, 200}, {D_STR_W_LEN ("1a"), 1, 1}, {D_STR_W_LEN ("2E"), 1, 2}, {D_STR_W_LEN ("6c"), 1, 6}, {D_STR_W_LEN ("8F"), 1, 8}, {D_STR_W_LEN ("287416997! And the not too long string."), 9, 287416997} }; /* strings that should overflow uint64_t */ static const struct str_with_len str_ovflw[] = { D_STR_W_LEN ("18446744073709551616"), /* 0x10000000000000000, UINT64_MAX+1 */ D_STR_W_LEN ("18446744073709551620"), D_STR_W_LEN ("18446744083709551615"), D_STR_W_LEN ("19234761020556472143"), D_STR_W_LEN ("184467440737095516150"), D_STR_W_LEN ("1844674407370955161500"), D_STR_W_LEN ("000018446744073709551616"), /* 0x10000000000000000, UINT64_MAX+1 */ D_STR_W_LEN ("20000000000000000000"), D_STR_W_LEN ("020000000000000000000"), D_STR_W_LEN ("0020000000000000000000"), D_STR_W_LEN ("100000000000000000000"), D_STR_W_LEN ("434532891232591226417"), D_STR_W_LEN ("99999999999999999999"), D_STR_W_LEN ("18446744073709551616abcd"), /* 0x10000000000000000, UINT64_MAX+1 */ D_STR_W_LEN ("20000000000000000000 suffix"), D_STR_W_LEN ("020000000000000000000x") }; /* strings that should not be convertible to numeric value */ static const struct str_with_len str_no_num[] = { D_STR_W_LEN ("zero"), D_STR_W_LEN ("one"), D_STR_W_LEN ("\xb9\xb2\xb3"), /* superscript "123" in ISO-8859-1/CP1252 */ D_STR_W_LEN ("\xc2\xb9\xc2\xb2\xc2\xb3"), /* superscript "123" in UTF-8 */ D_STR_W_LEN ("\xd9\xa1\xd9\xa2\xd9\xa3"), /* Arabic-Indic "١٢٣" in UTF-8 */ D_STR_W_LEN ("\xdb\xb1\xdb\xb2\xdb\xb3"), /* Ext Arabic-Indic "Û±Û²Û³" in UTF-8 */ D_STR_W_LEN ("\xe0\xa5\xa7\xe0\xa5\xa8\xe0\xa5\xa9"), /* Devanagari "१२३" in UTF-8 */ D_STR_W_LEN ("\xe4\xb8\x80\xe4\xba\x8c\xe4\xb8\x89"), /* Chinese "一二三" in UTF-8 */ D_STR_W_LEN ("\xd2\xbb\xb6\xfe\xc8\xfd"), /* Chinese "一二三" in GB2312/CP936 */ D_STR_W_LEN ("\x1B\x24\x29\x41\x0E\x52\x3B\x36\x7E\x48\x7D\x0F") /* Chinese "一二三" in ISO-2022-CN */ }; /* valid hex string for conversion to unsigned integer value */ static const struct str_with_value xdstrs_w_values[] = { /* simplest strings */ {D_STR_W_LEN ("1"), 1, 0x1}, {D_STR_W_LEN ("0"), 1, 0x0}, {D_STR_W_LEN ("10000"), 5, 0x10000}, /* all digits */ {D_STR_W_LEN ("1234"), 4, 0x1234}, {D_STR_W_LEN ("4567"), 4, 0x4567}, {D_STR_W_LEN ("7890"), 4, 0x7890}, {D_STR_W_LEN ("8021"), 4, 0x8021}, {D_STR_W_LEN ("9754"), 4, 0x9754}, {D_STR_W_LEN ("6392"), 4, 0x6392}, {D_STR_W_LEN ("abcd"), 4, 0xABCD}, {D_STR_W_LEN ("cdef"), 4, 0xCDEF}, {D_STR_W_LEN ("FEAB"), 4, 0xFEAB}, {D_STR_W_LEN ("BCED"), 4, 0xBCED}, {D_STR_W_LEN ("bCeD"), 4, 0xBCED}, {D_STR_W_LEN ("1A5F"), 4, 0x1A5F}, {D_STR_W_LEN ("12AB"), 4, 0x12AB}, {D_STR_W_LEN ("CD34"), 4, 0xCD34}, {D_STR_W_LEN ("56EF"), 4, 0x56EF}, {D_STR_W_LEN ("7a9f"), 4, 0x7A9F}, /* various prefixes */ {D_STR_W_LEN ("00000000"), 8, 0x0}, {D_STR_W_LEN ("0755"), 4, 0x755}, /* not to be interpreted as octal value! */ {D_STR_W_LEN ("002"), 3, 0x2}, {D_STR_W_LEN ("0001"), 4, 0x1}, {D_STR_W_LEN ("00a"), 3, 0xA}, {D_STR_W_LEN ("0F"), 2, 0xF}, {D_STR_W_LEN ("0000000000000000000000003A29e4C3"), 32, 0x3A29E4C3}, /* numbers below and above limits */ {D_STR_W_LEN ("7F"), 2, 127}, /* 0x7F, SCHAR_MAX */ {D_STR_W_LEN ("7f"), 2, 127}, /* 0x7F, SCHAR_MAX */ {D_STR_W_LEN ("80"), 2, 128}, /* 0x80, SCHAR_MAX+1 */ {D_STR_W_LEN ("fF"), 2, 255}, /* 0xFF, UCHAR_MAX */ {D_STR_W_LEN ("Ff"), 2, 255}, /* 0xFF, UCHAR_MAX */ {D_STR_W_LEN ("FF"), 2, 255}, /* 0xFF, UCHAR_MAX */ {D_STR_W_LEN ("ff"), 2, 255}, /* 0xFF, UCHAR_MAX */ {D_STR_W_LEN ("100"), 3, 256}, /* 0x100, UCHAR_MAX+1 */ {D_STR_W_LEN ("7fff"), 4, 32767}, /* 0x7FFF, INT16_MAX */ {D_STR_W_LEN ("7FFF"), 4, 32767}, /* 0x7FFF, INT16_MAX */ {D_STR_W_LEN ("7Fff"), 4, 32767}, /* 0x7FFF, INT16_MAX */ {D_STR_W_LEN ("8000"), 4, 32768}, /* 0x8000, INT16_MAX+1 */ {D_STR_W_LEN ("ffff"), 4, 65535}, /* 0xFFFF, UINT16_MAX */ {D_STR_W_LEN ("FFFF"), 4, 65535}, /* 0xFFFF, UINT16_MAX */ {D_STR_W_LEN ("FffF"), 4, 65535}, /* 0xFFFF, UINT16_MAX */ {D_STR_W_LEN ("10000"), 5, 65536}, /* 0x10000, UINT16_MAX+1 */ {D_STR_W_LEN ("7FFFFFFF"), 8, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ {D_STR_W_LEN ("7fffffff"), 8, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ {D_STR_W_LEN ("7FFffFff"), 8, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ {D_STR_W_LEN ("80000000"), 8, UINT64_C (2147483648)}, /* 0x80000000, INT32_MAX+1 */ {D_STR_W_LEN ("FFFFFFFF"), 8, UINT64_C (4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ {D_STR_W_LEN ("ffffffff"), 8, UINT64_C (4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ {D_STR_W_LEN ("FfFfFfFf"), 8, UINT64_C (4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ {D_STR_W_LEN ("100000000"), 9, UINT64_C (4294967296)}, /* 0x100000000, UINT32_MAX+1 */ {D_STR_W_LEN ("7fffffffffffffff"), 16, UINT64_C (9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ {D_STR_W_LEN ("7FFFFFFFFFFFFFFF"), 16, UINT64_C (9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ {D_STR_W_LEN ("7FfffFFFFffFFffF"), 16, UINT64_C (9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ {D_STR_W_LEN ("8000000000000000"), 16, UINT64_C (9223372036854775808)}, /* 0x8000000000000000, INT64_MAX+1 */ {D_STR_W_LEN ("ffffffffffffffff"), 16, UINT64_C (18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ {D_STR_W_LEN ("FFFFFFFFFFFFFFFF"), 16, UINT64_C (18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ {D_STR_W_LEN ("FffFffFFffFFfFFF"), 16, UINT64_C (18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ /* random numbers */ {D_STR_W_LEN ("10186753"), 8, 0x10186753}, {D_STR_W_LEN ("144402566"), 9, 0x144402566}, {D_STR_W_LEN ("151903144"), 9, 0x151903144}, {D_STR_W_LEN ("139264621"), 9, 0x139264621}, {D_STR_W_LEN ("730348"), 6, 0x730348}, {D_STR_W_LEN ("21584377"), 8, 0x21584377}, {D_STR_W_LEN ("709"), 3, 0x709}, {D_STR_W_LEN ("54"), 2, 0x54}, {D_STR_W_LEN ("8452"), 4, 0x8452}, {D_STR_W_LEN ("22353EC6"), 8, 0x22353EC6}, {D_STR_W_LEN ("307F1655"), 8, 0x307F1655}, {D_STR_W_LEN ("1FCB7226"), 8, 0x1FCB7226}, {D_STR_W_LEN ("82480560"), 8, 0x82480560}, {D_STR_W_LEN ("7386D95"), 7, 0x7386D95}, {D_STR_W_LEN ("EC3AB"), 5, 0xEC3AB}, {D_STR_W_LEN ("6DD05"), 5, 0x6DD05}, {D_STR_W_LEN ("C5DF"), 4, 0xC5DF}, {D_STR_W_LEN ("6CE"), 3, 0x6CE}, {D_STR_W_LEN ("CE6"), 3, 0xCE6}, {D_STR_W_LEN ("ce6"), 3, 0xCE6}, {D_STR_W_LEN ("F27"), 3, 0xF27}, {D_STR_W_LEN ("8497D54277D7E1"), 14, UINT64_C (37321639124785121)}, {D_STR_W_LEN ("8497d54277d7e1"), 14, UINT64_C (37321639124785121)}, {D_STR_W_LEN ("8497d54277d7E1"), 14, UINT64_C (37321639124785121)}, {D_STR_W_LEN ("8C8112D0A06"), 11, UINT64_C (9655374645766)}, {D_STR_W_LEN ("8c8112d0a06"), 11, UINT64_C (9655374645766)}, {D_STR_W_LEN ("8c8112d0A06"), 11, UINT64_C (9655374645766)}, {D_STR_W_LEN ("1774509875001362"), 16, UINT64_C (1690064375898968930)}, {D_STR_W_LEN ("0678687876998000"), 16, UINT64_C (466237428027981824)}, /* non-digit suffixes */ {D_STR_W_LEN ("1234oa"), 4, 0x1234}, {D_STR_W_LEN ("20h"), 2, 0x20}, {D_STR_W_LEN ("2CH"), 2, 0x2C}, {D_STR_W_LEN ("2ch"), 2, 0x2C}, {D_STR_W_LEN ("0x1F"), 1, 0x0}, /* not to be interpreted as hex prefix! */ {D_STR_W_LEN ("0564`~}"), 4, 0x564}, {D_STR_W_LEN ("0A64`~}"), 4, 0xA64}, {D_STR_W_LEN ("056c`~}"), 4, 0X56C}, {D_STR_W_LEN ("7240146.724"), 7, 0x7240146}, {D_STR_W_LEN ("7E4c1AB.724"), 7, 0X7E4C1AB}, {D_STR_W_LEN ("F24B1B6.724"), 7, 0xF24B1B6}, {D_STR_W_LEN ("2,9"), 1, 0x2}, {D_STR_W_LEN ("a,9"), 1, 0xA}, {D_STR_W_LEN ("200+1"), 3, 0x200}, {D_STR_W_LEN ("2cc+1"), 3, 0x2CC}, {D_STR_W_LEN ("2cC+1"), 3, 0x2CC}, {D_STR_W_LEN ("27416997! And the not too long string."), 8, 0x27416997}, {D_STR_W_LEN ("27555416997! And the not too long string."), 11, 0x27555416997}, {D_STR_W_LEN ("416997And the not too long string."), 7, 0x416997A}, {D_STR_W_LEN ("0F4C3Dabstract addition to make string even longer"), 8, 0xF4C3DAB} }; /* hex strings that should overflow uint64_t */ static const struct str_with_len strx_ovflw[] = { D_STR_W_LEN ("10000000000000000"), /* 0x10000000000000000, UINT64_MAX+1 */ D_STR_W_LEN ("10000000000000001"), D_STR_W_LEN ("10000000000000002"), D_STR_W_LEN ("1000000000000000A"), D_STR_W_LEN ("11000000000000000"), D_STR_W_LEN ("010000000000000000"), /* 0x10000000000000000, UINT64_MAX+1 */ D_STR_W_LEN ("000010000000000000000"), /* 0x10000000000000000, UINT64_MAX+1 */ D_STR_W_LEN ("20000000000000000000"), D_STR_W_LEN ("020000000000000000000"), D_STR_W_LEN ("0020000000000000000000"), D_STR_W_LEN ("20000000000000000"), D_STR_W_LEN ("A0000000000000000"), D_STR_W_LEN ("F0000000000000000"), D_STR_W_LEN ("a0000000000000000"), D_STR_W_LEN ("11111111111111111"), D_STR_W_LEN ("CcCcCCccCCccCCccC"), D_STR_W_LEN ("f0000000000000000"), D_STR_W_LEN ("100000000000000000000"), D_STR_W_LEN ("434532891232591226417"), D_STR_W_LEN ("10000000000000000a"), D_STR_W_LEN ("10000000000000000E"), D_STR_W_LEN ("100000000000000000 and nothing"), /* 0x10000000000000000, UINT64_MAX+1 */ D_STR_W_LEN ("100000000000000000xx"), /* 0x10000000000000000, UINT64_MAX+1 */ D_STR_W_LEN ("99999999999999999999"), D_STR_W_LEN ("18446744073709551616abcd"), D_STR_W_LEN ("20000000000000000000 suffix"), D_STR_W_LEN ("020000000000000000000x") }; static size_t check_str_to_uint64_valid (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(dstrs_w_values) / sizeof(dstrs_w_values[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { uint64_t rv; size_t rs; const struct str_with_value *const t = dstrs_w_values + i; if (c_failed[i]) continue; /* skip already failed checks */ if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str. len); exit (99); } rv = 9435223; /* some random value */ rs = MHD_str_to_uint64_ (t->str.str, &rv); if (rs != t->num_of_digt) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") returned %" PRIuPTR ", while expecting %d." " Locale: %s\n", n_prnt (t->str.str), rv, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); } if (rv != t->val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") converted string to value %" PRIu64 "," " while expecting result %" PRIu64 ". Locale: %s\n", n_prnt (t->str.str), rv, rv, t->val, get_current_locale_str ()); } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") == %" \ PRIuPTR "\n", n_prnt (t->str.str), rv, rs); } } return t_failed; } static size_t check_str_to_uint64_all_chars (void) { int c_failed[256]; /* from 0 to 255 */ static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); size_t t_failed = 0; size_t j; memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { unsigned int c; uint64_t test_val; set_test_locale (j); /* setlocale() can be slow! */ for (c = 0; c < n_checks; c++) { static const uint64_t rnd_val = 24941852; size_t rs; if ((c >= '0') && (c <= '9') ) continue; /* skip digits */ for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; uint64_t rv = test_val; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ rs = MHD_str_to_uint64_ (test_str, &rv); if (rs != 0) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (test_str), rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_(\"%s\", &ret_val) modified value of ret_val" " (before call: %" PRIu64 ", after call %" PRIu64 "). Locale: %s\n", n_prnt (test_str), test_val, rv, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ printf ("PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (test_str)); } } } return t_failed; } static size_t check_str_to_uint64_overflow (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(str_ovflw) / sizeof(str_ovflw[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; const struct str_with_len *const t = str_ovflw + i; static const uint64_t rnd_val = 2; uint64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint64_t rv = test_val; rs = MHD_str_to_uint64_ (t->str, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_(\"%s\", &ret_val) modified value of ret_val" " (before call: %" PRIu64 ", after call %" PRIu64 "). Locale: %s\n", n_prnt (t->str), test_val, rv, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (t->str)); } } return t_failed; } static size_t check_str_to_uint64_no_val (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(str_no_num) / sizeof(str_no_num[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; const struct str_with_len *const t = str_no_num + i; static const uint64_t rnd_val = 74218431; uint64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint64_t rv = test_val; rs = MHD_str_to_uint64_ (t->str, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_(\"%s\", &ret_val) modified value of ret_val" " (before call: %" PRIu64 ", after call %" PRIu64 "). Locale: %s\n", n_prnt (t->str), test_val, rv, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (t->str)); } } return t_failed; } static size_t check_str_to_uint64_n_valid (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(dstrs_w_values) / sizeof(dstrs_w_values[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { uint64_t rv = 1235572; /* some random value */ size_t rs = 0; size_t len; const struct str_with_value *const t = dstrs_w_values + i; if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str. len); exit (99); } for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++) { rs = MHD_str_to_uint64_n_ (t->str.str, len, &rv); if (rs != t->num_of_digt) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" PRIu64 ")" " returned %" PRIuPTR ", while expecting %d. Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, rv, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); } if (rv != t->val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" PRIu64 ")" " converted string to value %" PRIu64 ", while expecting result %" PRIu64 ". Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, rv, rv, t->val, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->%" PRIu64 ")" " == %" PRIuPTR "\n", n_prnt (t->str.str), (uintptr_t) t->num_of_digt, (uintptr_t) t->str.len + 1, rv, rs); } } return t_failed; } static size_t check_str_to_uint64_n_all_chars (void) { int c_failed[256]; /* from 0 to 255 */ static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); size_t t_failed = 0; size_t j; memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { unsigned int c; uint64_t test_val; set_test_locale (j); /* setlocale() can be slow! */ for (c = 0; c < n_checks; c++) { static const uint64_t rnd_val = 98372558; size_t rs; size_t len; if ((c >= '0') && (c <= '9') ) continue; /* skip digits */ for (len = 0; len <= 5; len++) { for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; uint64_t rv = test_val; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ rs = MHD_str_to_uint64_n_ (test_str, len, &rv); if (rs != 0) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" PRIu64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (test_str), (uintptr_t) len, rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", &ret_val)" " modified value of ret_val (before call: %" PRIu64 ", after call %" PRIu64 ")." " Locale: %s\n", n_prnt (test_str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ printf ("PASSED: MHD_str_to_uint64_n_(\"%s\", 0..5, &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (test_str)); } } } return t_failed; } static size_t check_str_to_uint64_n_overflow (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(str_ovflw) / sizeof(str_ovflw[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; const struct str_with_len *const t = str_ovflw + i; static const uint64_t rnd_val = 3; size_t len; for (len = t->len; len <= t->len + 1; len++) { uint64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint64_t rv = test_val; rs = MHD_str_to_uint64_n_ (t->str, len, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" PRIu64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (t->str), (uintptr_t) len, rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", &ret_val)" " modified value of ret_val (before call: %" PRIu64 ", after call %" PRIu64 ")." " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", &ret_val) == 0," " value of ret_val is unmodified\n", n_prnt (t->str), (uintptr_t) t->len, (uintptr_t) t->len + 1); } } return t_failed; } static size_t check_str_to_uint64_n_no_val (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(str_no_num) / sizeof(str_no_num[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; const struct str_with_len *const t = str_no_num + i; static const uint64_t rnd_val = 43255654342; size_t len; for (len = 0; len <= t->len + 1; len++) { uint64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint64_t rv = test_val; rs = MHD_str_to_uint64_n_ (t->str, len, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" PRIu64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (t->str), (uintptr_t) len, rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", &ret_val)" " modified value of ret_val (before call: %" PRIu64 ", after call %" PRIu64 ")." " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_to_uint64_n_(\"%s\", 0..%" PRIuPTR ", &ret_val) == 0," " value of ret_val is unmodified\n", n_prnt (t->str), (uintptr_t) t->len + 1); } } return t_failed; } static size_t check_strx_to_uint32_valid (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { uint32_t rv; size_t rs; const struct str_with_value *const t = xdstrs_w_values + i; if (t->val > UINT32_MAX) continue; /* number is too high for this function */ if (c_failed[i]) continue; /* skip already failed checks */ if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str. len); exit (99); } rv = 1458532; /* some random value */ rs = MHD_strx_to_uint32_ (t->str.str, &rv); if (rs != t->num_of_digt) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting %d." " Locale: %s\n", n_prnt (t->str.str), (uint64_t) rv, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); } if (rv != t->val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") converted string to value 0x%" PRIX64 "," " while expecting result 0x%" PRIX64 ". Locale: %s\n", n_prnt (t->str.str), (uint64_t) rv, (uint64_t) rv, t->val, get_current_locale_str ()); } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") == %" PRIuPTR "\n", n_prnt (t->str.str), (uint64_t) rv, rs); } } return t_failed; } static size_t check_strx_to_uint32_all_chars (void) { int c_failed[256]; /* from 0 to 255 */ static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); size_t t_failed = 0; size_t j; memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { unsigned int c; uint32_t test_val; set_test_locale (j); /* setlocale() can be slow! */ for (c = 0; c < n_checks; c++) { static const uint32_t rnd_val = 234234; size_t rs; if (( (c >= '0') && (c <= '9') ) || ( (c >= 'A') && (c <= 'F') ) || ( (c >= 'a') && (c <= 'f') )) continue; /* skip xdigits */ for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; uint32_t rv = test_val; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ rs = MHD_strx_to_uint32_ (test_str, &rv); if (rs != 0) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (test_str), (uint64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", &ret_val) modified value of ret_val" " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", n_prnt (test_str), (uint64_t) test_val, (uint64_t) rv, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ printf ("PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (test_str)); } } } return t_failed; } static size_t check_strx_to_uint32_overflow (void) { size_t t_failed = 0; size_t i, j; static const size_t n_checks1 = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]); int c_failed[(sizeof(strx_ovflw) / sizeof(strx_ovflw[0])) + (sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0]))]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; static const uint32_t rnd_val = 74218431; uint32_t test_val; const char *str; if (i < n_checks1) { const struct str_with_len *const t = strx_ovflw + i; str = t->str; } else { const struct str_with_value *const t = xdstrs_w_values + (i - n_checks1); if (t->val <= UINT32_MAX) continue; /* check only strings that should overflow uint32_t */ str = t->str.str; } for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint32_t rv = test_val; rs = MHD_strx_to_uint32_ (str, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (str), (uint64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", &ret_val) modified value of ret_val" " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", n_prnt (str), (uint64_t) test_val, (uint64_t) rv, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (str)); } } return t_failed; } static size_t check_strx_to_uint32_no_val (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(str_no_num) / sizeof(str_no_num[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; const struct str_with_len *const t = str_no_num + i; static const uint32_t rnd_val = 74218431; uint32_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint32_t rv = test_val; rs = MHD_strx_to_uint32_ (t->str, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (t->str), (uint64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", &ret_val) modified value of ret_val" " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", n_prnt (t->str), (uint64_t) test_val, (uint64_t) rv, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (t->str)); } } return t_failed; } static size_t check_strx_to_uint32_n_valid (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { uint32_t rv = 2352932; /* some random value */ size_t rs = 0; size_t len; const struct str_with_value *const t = xdstrs_w_values + i; if (t->val > UINT32_MAX) continue; /* number is too high for this function */ if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str. len); exit (99); } for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++) { rs = MHD_strx_to_uint32_n_ (t->str.str, len, &rv); if (rs != t->num_of_digt) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" " returned %" PRIuPTR ", while expecting %d. Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, (uint64_t) rv, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); } if (rv != t->val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" " converted string to value 0x%" PRIX64 ", while expecting result 0x%" PRIX64 ". Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, (uint64_t) rv, (uint64_t) rv, t->val, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->0x%" PRIX64 ")" " == %" PRIuPTR "\n", n_prnt (t->str.str), (uintptr_t) t->num_of_digt, (uintptr_t) t->str.len + 1, (uint64_t) rv, rs); } } return t_failed; } static size_t check_strx_to_uint32_n_all_chars (void) { int c_failed[256]; /* from 0 to 255 */ static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); size_t t_failed = 0; size_t j; memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { unsigned int c; uint32_t test_val; set_test_locale (j); /* setlocale() can be slow! */ for (c = 0; c < n_checks; c++) { static const uint32_t rnd_val = 98372558; size_t rs; size_t len; if (( (c >= '0') && (c <= '9') ) || ( (c >= 'A') && (c <= 'F') ) || ( (c >= 'a') && (c <= 'f') )) continue; /* skip xdigits */ for (len = 0; len <= 5; len++) { for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; uint32_t rv = test_val; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ rs = MHD_strx_to_uint32_n_ (test_str, len, &rv); if (rs != 0) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (test_str), (uintptr_t) len, (uint64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", &ret_val)" " modified value of ret_val (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 ")." " Locale: %s\n", n_prnt (test_str), (uintptr_t) len, (uint64_t) test_val, (uint64_t) rv, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ printf ("PASSED: MHD_strx_to_uint32_n_(\"%s\", 0..5, &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (test_str)); } } } return t_failed; } static size_t check_strx_to_uint32_n_overflow (void) { size_t t_failed = 0; size_t i, j; static const size_t n_checks1 = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]); int c_failed[(sizeof(strx_ovflw) / sizeof(strx_ovflw[0])) + (sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0]))]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; static const uint32_t rnd_val = 4; size_t len; const char *str; size_t min_len, max_len; if (i < n_checks1) { const struct str_with_len *const t = strx_ovflw + i; str = t->str; min_len = t->len; max_len = t->len + 1; } else { const struct str_with_value *const t = xdstrs_w_values + (i - n_checks1); if (t->val <= UINT32_MAX) continue; /* check only strings that should overflow uint32_t */ if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) (i - n_checks1), (unsigned int) t->num_of_digt, (unsigned int) t->str.len); exit (99); } str = t->str.str; min_len = t->num_of_digt; max_len = t->str.len + 1; } for (len = min_len; len <= max_len; len++) { uint32_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint32_t rv = test_val; rs = MHD_strx_to_uint32_n_ (str, len, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (str), (uintptr_t) len, (uint64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", &ret_val)" " modified value of ret_val (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 ")." " Locale: %s\n", n_prnt (str), (uintptr_t) len, (uint64_t) test_val, (uint64_t) rv, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", &ret_val) == 0," " value of ret_val is unmodified\n", n_prnt (str), (uintptr_t) min_len, (uintptr_t) max_len); } } return t_failed; } static size_t check_strx_to_uint32_n_no_val (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(str_no_num) / sizeof(str_no_num[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; const struct str_with_len *const t = str_no_num + i; static const uint32_t rnd_val = 3214314212UL; size_t len; for (len = 0; len <= t->len + 1; len++) { uint32_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint32_t rv = test_val; rs = MHD_strx_to_uint32_n_ (t->str, len, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (t->str), (uintptr_t) len, (uint64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", &ret_val)" " modified value of ret_val (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 ")." " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, (uint64_t) test_val, (uint64_t) rv, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint32_n_(\"%s\", 0..%" PRIuPTR ", &ret_val) == 0," " value of ret_val is unmodified\n", n_prnt (t->str), (uintptr_t) t->len + 1); } } return t_failed; } static size_t check_strx_to_uint64_valid (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { uint64_t rv; size_t rs; const struct str_with_value *const t = xdstrs_w_values + i; if (c_failed[i]) continue; /* skip already failed checks */ if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str. len); exit (99); } rv = 1458532; /* some random value */ rs = MHD_strx_to_uint64_ (t->str.str, &rv); if (rs != t->num_of_digt) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting %d." " Locale: %s\n", n_prnt (t->str.str), rv, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); } if (rv != t->val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") converted string to value 0x%" PRIX64 "," " while expecting result 0x%" PRIX64 ". Locale: %s\n", n_prnt (t->str.str), rv, rv, t->val, get_current_locale_str ()); } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") == %" PRIuPTR "\n", n_prnt (t->str.str), rv, rs); } } return t_failed; } static size_t check_strx_to_uint64_all_chars (void) { int c_failed[256]; /* from 0 to 255 */ static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); size_t t_failed = 0; size_t j; memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { unsigned int c; uint64_t test_val; set_test_locale (j); /* setlocale() can be slow! */ for (c = 0; c < n_checks; c++) { static const uint64_t rnd_val = 234234; size_t rs; if (( (c >= '0') && (c <= '9') ) || ( (c >= 'A') && (c <= 'F') ) || ( (c >= 'a') && (c <= 'f') )) continue; /* skip xdigits */ for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; uint64_t rv = test_val; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ rs = MHD_strx_to_uint64_ (test_str, &rv); if (rs != 0) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (test_str), rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", &ret_val) modified value of ret_val" " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", n_prnt (test_str), test_val, rv, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ printf ("PASSED: MHD_strx_to_uint64_(\"%s\", &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (test_str)); } } } return t_failed; } static size_t check_strx_to_uint64_overflow (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(strx_ovflw) / sizeof(strx_ovflw[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; const struct str_with_len *const t = strx_ovflw + i; static const uint64_t rnd_val = 74218431; uint64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint64_t rv = test_val; rs = MHD_strx_to_uint64_ (t->str, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", &ret_val) modified value of ret_val" " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", n_prnt (t->str), test_val, rv, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint64_(\"%s\", &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (t->str)); } } return t_failed; } static size_t check_strx_to_uint64_no_val (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(str_no_num) / sizeof(str_no_num[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; const struct str_with_len *const t = str_no_num + i; static const uint64_t rnd_val = 74218431; uint64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint64_t rv = test_val; rs = MHD_strx_to_uint64_ (t->str, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", &ret_val) modified value of ret_val" " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", n_prnt (t->str), test_val, rv, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint64_(\"%s\", &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (t->str)); } } return t_failed; } static size_t check_strx_to_uint64_n_valid (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { uint64_t rv = 2352932; /* some random value */ size_t rs = 0; size_t len; const struct str_with_value *const t = xdstrs_w_values + i; if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str. len); exit (99); } for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++) { rs = MHD_strx_to_uint64_n_ (t->str.str, len, &rv); if (rs != t->num_of_digt) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" " returned %" PRIuPTR ", while expecting %d. Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, rv, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); } if (rv != t->val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" " converted string to value 0x%" PRIX64 ", while expecting result 0x%" PRIX64 ". Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, rv, rv, t->val, get_current_locale_str ()); } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->0x%" PRIX64 ")" " == %" PRIuPTR "\n", n_prnt (t->str.str), (uintptr_t) t->num_of_digt, (uintptr_t) t->str.len + 1, rv, rs); } } return t_failed; } static size_t check_strx_to_uint64_n_all_chars (void) { int c_failed[256]; /* from 0 to 255 */ static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); size_t t_failed = 0; size_t j; memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { unsigned int c; uint64_t test_val; set_test_locale (j); /* setlocale() can be slow! */ for (c = 0; c < n_checks; c++) { static const uint64_t rnd_val = 98372558; size_t rs; size_t len; if (( (c >= '0') && (c <= '9') ) || ( (c >= 'A') && (c <= 'F') ) || ( (c >= 'a') && (c <= 'f') )) continue; /* skip xdigits */ for (len = 0; len <= 5; len++) { for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; uint64_t rv = test_val; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ rs = MHD_strx_to_uint64_n_ (test_str, len, &rv); if (rs != 0) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (test_str), (uintptr_t) len, rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[c] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR ", &ret_val)" " modified value of ret_val (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 ")." " Locale: %s\n", n_prnt (test_str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ printf ("PASSED: MHD_strx_to_uint64_n_(\"%s\", 0..5, &ret_val) == 0, " "value of ret_val is unmodified\n", n_prnt (test_str)); } } } return t_failed; } static size_t check_strx_to_uint64_n_overflow (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(strx_ovflw) / sizeof(strx_ovflw[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; const struct str_with_len *const t = strx_ovflw + i; static const uint64_t rnd_val = 4; size_t len; for (len = t->len; len <= t->len + 1; len++) { uint64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint64_t rv = test_val; rs = MHD_strx_to_uint64_n_ (t->str, len, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (t->str), (uintptr_t) len, rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR ", &ret_val)" " modified value of ret_val (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 ")." " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", &ret_val) == 0," " value of ret_val is unmodified\n", n_prnt (t->str), (uintptr_t) t->len, (uintptr_t) t->len + 1); } } return t_failed; } static size_t check_strx_to_uint64_n_no_val (void) { size_t t_failed = 0; size_t i, j; int c_failed[sizeof(str_no_num) / sizeof(str_no_num[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { size_t rs; const struct str_with_len *const t = str_no_num + i; static const uint64_t rnd_val = 3214314212UL; size_t len; for (len = 0; len <= t->len + 1; len++) { uint64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { uint64_t rv = test_val; rs = MHD_strx_to_uint64_n_ (t->str, len, &rv); if (rs != 0) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (t->str), (uintptr_t) len, rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) { t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR ", &ret_val)" " modified value of ret_val (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 ")." " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_strx_to_uint64_n_(\"%s\", 0..%" PRIuPTR ", &ret_val) == 0," " value of ret_val is unmodified\n", n_prnt (t->str), (uintptr_t) t->len + 1); } } return t_failed; } static int run_str_to_X_tests (void) { size_t str_to_uint64_fails = 0; size_t str_to_uint64_n_fails = 0; size_t strx_to_uint32_fails = 0; size_t strx_to_uint32_n_fails = 0; size_t strx_to_uint64_fails = 0; size_t strx_to_uint64_n_fails = 0; size_t res; res = check_str_to_uint64_valid (); if (res != 0) { str_to_uint64_fails += res; fprintf (stderr, "FAILED: testcase check_str_to_uint64_valid() failed.\n\n"); } else if (verbose > 1) printf ( "PASSED: testcase check_str_to_uint64_valid() successfully passed.\n\n"); res = check_str_to_uint64_all_chars (); if (res != 0) { str_to_uint64_fails += res; fprintf (stderr, "FAILED: testcase check_str_to_uint64_all_chars() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_str_to_uint64_all_chars() " "successfully passed.\n\n"); res = check_str_to_uint64_overflow (); if (res != 0) { str_to_uint64_fails += res; fprintf (stderr, "FAILED: testcase check_str_to_uint64_overflow() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_str_to_uint64_overflow() " "successfully passed.\n\n"); res = check_str_to_uint64_no_val (); if (res != 0) { str_to_uint64_fails += res; fprintf (stderr, "FAILED: testcase check_str_to_uint64_no_val() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_str_to_uint64_no_val() " "successfully passed.\n\n"); if (str_to_uint64_fails) fprintf (stderr, "FAILED: function MHD_str_to_uint64_() failed %lu time%s.\n\n", (unsigned long) str_to_uint64_fails, str_to_uint64_fails == 1 ? "" : "s"); else if (verbose > 0) printf ("PASSED: function MHD_str_to_uint64_() successfully " "passed all checks.\n\n"); res = check_str_to_uint64_n_valid (); if (res != 0) { str_to_uint64_n_fails += res; fprintf (stderr, "FAILED: testcase check_str_to_uint64_n_valid() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_str_to_uint64_n_valid() " "successfully passed.\n\n"); res = check_str_to_uint64_n_all_chars (); if (res != 0) { str_to_uint64_n_fails += res; fprintf (stderr, "FAILED: testcase check_str_to_uint64_n_all_chars() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_str_to_uint64_n_all_chars() " "successfully passed.\n\n"); res = check_str_to_uint64_n_overflow (); if (res != 0) { str_to_uint64_n_fails += res; fprintf (stderr, "FAILED: testcase check_str_to_uint64_n_overflow() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_str_to_uint64_n_overflow() " "successfully passed.\n\n"); res = check_str_to_uint64_n_no_val (); if (res != 0) { str_to_uint64_n_fails += res; fprintf (stderr, "FAILED: testcase check_str_to_uint64_n_no_val() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_str_to_uint64_n_no_val() " "successfully passed.\n\n"); if (str_to_uint64_n_fails) fprintf (stderr, "FAILED: function MHD_str_to_uint64_n_() failed %lu time%s.\n\n", (unsigned long) str_to_uint64_n_fails, str_to_uint64_n_fails == 1 ? "" : "s"); else if (verbose > 0) printf ("PASSED: function MHD_str_to_uint64_n_() successfully " "passed all checks.\n\n"); res = check_strx_to_uint32_valid (); if (res != 0) { strx_to_uint32_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint32_valid() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint32_valid() " "successfully passed.\n\n"); res = check_strx_to_uint32_all_chars (); if (res != 0) { strx_to_uint32_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint32_all_chars() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint32_all_chars() " "successfully passed.\n\n"); res = check_strx_to_uint32_overflow (); if (res != 0) { strx_to_uint32_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint32_overflow() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint32_overflow() " "successfully passed.\n\n"); res = check_strx_to_uint32_no_val (); if (res != 0) { strx_to_uint32_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint32_no_val() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint32_no_val() " "successfully passed.\n\n"); if (strx_to_uint32_fails) fprintf (stderr, "FAILED: function MHD_strx_to_uint32_() failed %lu time%s.\n\n", (unsigned long) strx_to_uint32_fails, strx_to_uint32_fails == 1 ? "" : "s"); else if (verbose > 0) printf ("PASSED: function MHD_strx_to_uint32_() successfully " "passed all checks.\n\n"); res = check_strx_to_uint32_n_valid (); if (res != 0) { strx_to_uint32_n_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint32_n_valid() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint32_n_valid() " "successfully passed.\n\n"); res = check_strx_to_uint32_n_all_chars (); if (res != 0) { strx_to_uint32_n_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint32_n_all_chars() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint32_n_all_chars() " "successfully passed.\n\n"); res = check_strx_to_uint32_n_overflow (); if (res != 0) { strx_to_uint32_n_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint32_n_overflow() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint32_n_overflow() " "successfully passed.\n\n"); res = check_strx_to_uint32_n_no_val (); if (res != 0) { strx_to_uint32_n_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint32_n_no_val() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint32_n_no_val() " "successfully passed.\n\n"); if (strx_to_uint32_n_fails) fprintf (stderr, "FAILED: function MHD_strx_to_uint32_n_() failed %lu time%s.\n\n", (unsigned long) strx_to_uint32_n_fails, strx_to_uint32_n_fails == 1 ? "" : "s"); else if (verbose > 0) printf ("PASSED: function MHD_strx_to_uint32_n_() successfully " "passed all checks.\n\n"); res = check_strx_to_uint64_valid (); if (res != 0) { strx_to_uint64_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint64_valid() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint64_valid() " "successfully passed.\n\n"); res = check_strx_to_uint64_all_chars (); if (res != 0) { strx_to_uint64_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint64_all_chars() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint64_all_chars() " "successfully passed.\n\n"); res = check_strx_to_uint64_overflow (); if (res != 0) { strx_to_uint64_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint64_overflow() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint64_overflow() " "successfully passed.\n\n"); res = check_strx_to_uint64_no_val (); if (res != 0) { strx_to_uint64_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint64_no_val() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint64_no_val() " "successfully passed.\n\n"); if (strx_to_uint64_fails) fprintf (stderr, "FAILED: function MHD_strx_to_uint64_() failed %lu time%s.\n\n", (unsigned long) strx_to_uint64_fails, strx_to_uint64_fails == 1 ? "" : "s"); else if (verbose > 0) printf ("PASSED: function MHD_strx_to_uint64_() successfully " "passed all checks.\n\n"); res = check_strx_to_uint64_n_valid (); if (res != 0) { strx_to_uint64_n_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint64_n_valid() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint64_n_valid() " "successfully passed.\n\n"); res = check_strx_to_uint64_n_all_chars (); if (res != 0) { strx_to_uint64_n_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint64_n_all_chars() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint64_n_all_chars() " "successfully passed.\n\n"); res = check_strx_to_uint64_n_overflow (); if (res != 0) { strx_to_uint64_n_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint64_n_overflow() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint64_n_overflow() " "successfully passed.\n\n"); res = check_strx_to_uint64_n_no_val (); if (res != 0) { strx_to_uint64_n_fails += res; fprintf (stderr, "FAILED: testcase check_strx_to_uint64_n_no_val() failed.\n\n"); } else if (verbose > 1) printf ("PASSED: testcase check_strx_to_uint64_n_no_val() " "successfully passed.\n\n"); if (strx_to_uint64_n_fails) fprintf (stderr, "FAILED: function MHD_strx_to_uint64_n_() failed %lu time%s.\n\n", (unsigned long) strx_to_uint64_n_fails, strx_to_uint64_n_fails == 1 ? "" : "s"); else if (verbose > 0) printf ("PASSED: function MHD_strx_to_uint64_n_() successfully " "passed all checks.\n\n"); if (str_to_uint64_fails || str_to_uint64_n_fails || strx_to_uint32_fails || strx_to_uint32_n_fails || strx_to_uint64_fails || strx_to_uint64_n_fails) { if (verbose > 0) printf ("At least one test failed.\n"); return 1; } if (verbose > 0) printf ("All tests passed successfully.\n"); return 0; } static size_t check_str_from_uint16 (void) { size_t t_failed = 0; size_t i, j; char buf[70]; const char *erase = "-@=sd#+&(pdiren456qwe#@C3S!DAS45AOIPUQWESAdFzxcv1s*()&#$%34`" "32452d098poiden45SADFFDA3S4D3SDFdfgsdfgsSADFzxdvs$*()द`" "adsf##$$@&*^%*^&56qwe#3C@S!DAScFAOIP$#%#$Ad1zs3v1$*()ӌ`"; int c_failed[sizeof(dstrs_w_values) / sizeof(dstrs_w_values[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { const struct str_with_value *const t = dstrs_w_values + i; size_t b_size; size_t rs; if (c_failed[i]) continue; /* skip already failed checks */ if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str. len); exit (99); } if ('0' == t->str.str[0]) continue; /* Skip strings prefixed with zeros */ if (t->num_of_digt != t->str.len) continue; /* Skip strings with suffixes */ if (UINT16_MAX < t->val) continue; /* Too large value to convert */ if (sizeof(buf) < t->str.len + 1) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has too long (%u) string, " "size of 'buf' should be increased.\n", (unsigned int) i, (unsigned int) t->str.len); exit (99); } rs = 0; /* Only to mute compiler warning */ for (b_size = 0; b_size <= t->str.len + 1; ++b_size) { /* fill buffer with pseudo-random values */ memcpy (buf, erase, sizeof(buf)); rs = MHD_uint16_to_str ((uint16_t) t->val, buf, b_size); if (t->num_of_digt > b_size) { /* Must fail, buffer is too small for result */ if (0 != rs) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint16_to_str(%" PRIu64 ", -> buf," " %d) returned %" PRIuPTR ", while expecting 0." " Locale: %s\n", t->val, (int) b_size, (uintptr_t) rs, get_current_locale_str ()); } } else { if (t->num_of_digt != rs) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint16_to_str(%" PRIu64 ", -> buf," " %d) returned %" PRIuPTR ", while expecting %d." " Locale: %s\n", t->val, (int) b_size, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); } else if (0 != memcmp (buf, t->str.str, t->num_of_digt)) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint16_to_str(%" PRIu64 ", -> \"%.*s\"," " %d) returned %" PRIuPTR "." " Locale: %s\n", t->val, (int) rs, buf, (int) b_size, (uintptr_t) rs, get_current_locale_str ()); } else if (0 != memcmp (buf + rs, erase + rs, sizeof(buf) - rs)) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint16_to_str(%" PRIu64 ", -> \"%.*s\"," " %d) returned %" PRIuPTR " and touched data after the resulting string." " Locale: %s\n", t->val, (int) rs, buf, (int) b_size, (uintptr_t) rs, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_uint16_to_str(%" PRIu64 ", -> \"%.*s\", %d) " "== %" PRIuPTR "\n", t->val, (int) rs, buf, (int) b_size - 1, (uintptr_t) rs); } } return t_failed; } static size_t check_str_from_uint64 (void) { size_t t_failed = 0; size_t i, j; char buf[70]; const char *erase = "-@=sd#+&(pdirenDSFGSe#@C&S!DAS*!AOIPUQWESAdFzxcvSs*()&#$%KH`" "32452d098poiden45SADFFDA3S4D3SDFdfgsdfgsSADFzxdvs$*()द`" "adsf##$$@&*^%*^&56qwe#3C@S!DAScFAOIP$#%#$Ad1zs3v1$*()ӌ`"; int c_failed[sizeof(dstrs_w_values) / sizeof(dstrs_w_values[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { const struct str_with_value *const t = dstrs_w_values + i; size_t b_size; size_t rs; if (c_failed[i]) continue; /* skip already failed checks */ if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str. len); exit (99); } if ('0' == t->str.str[0]) continue; /* Skip strings prefixed with zeros */ if (t->num_of_digt != t->str.len) continue; /* Skip strings with suffixes */ if (sizeof(buf) < t->str.len + 1) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has too long (%u) string, " "size of 'buf' should be increased.\n", (unsigned int) i, (unsigned int) t->str.len); exit (99); } rs = 0; /* Only to mute compiler warning */ for (b_size = 0; b_size <= t->str.len + 1; ++b_size) { /* fill buffer with pseudo-random values */ memcpy (buf, erase, sizeof(buf)); rs = MHD_uint64_to_str (t->val, buf, b_size); if (t->num_of_digt > b_size) { /* Must fail, buffer is too small for result */ if (0 != rs) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint64_to_str(%" PRIu64 ", -> buf," " %d) returned %" PRIuPTR ", while expecting 0." " Locale: %s\n", t->val, (int) b_size, (uintptr_t) rs, get_current_locale_str ()); } } else { if (t->num_of_digt != rs) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint64_to_str(%" PRIu64 ", -> buf," " %d) returned %" PRIuPTR ", while expecting %d." " Locale: %s\n", t->val, (int) b_size, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); } else if (0 != memcmp (buf, t->str.str, t->num_of_digt)) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint64_to_str(%" PRIu64 ", -> \"%.*s\"," " %d) returned %" PRIuPTR "." " Locale: %s\n", t->val, (int) rs, buf, (int) b_size, (uintptr_t) rs, get_current_locale_str ()); } else if (0 != memcmp (buf + rs, erase + rs, sizeof(buf) - rs)) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint64_to_str(%" PRIu64 ", -> \"%.*s\"," " %d) returned %" PRIuPTR " and touched data after the resulting string." " Locale: %s\n", t->val, (int) rs, buf, (int) b_size, (uintptr_t) rs, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_uint64_to_str(%" PRIu64 ", -> \"%.*s\", %d) " "== %" PRIuPTR "\n", t->val, (int) rs, buf, (int) b_size - 1, (uintptr_t) rs); } } return t_failed; } static size_t check_strx_from_uint32 (void) { size_t t_failed = 0; size_t i, j; char buf[70]; const char *erase = "jrlkjssfhjfvrjntJHLJ$@%$#adsfdkj;k$##$%#$%FGDF%$#^FDFG%$#$D`" ";skjdhjflsdkjhdjfalskdjhdfalkjdhf$%##%$$#%FSDGFSDDGDFSSDSDF`" "#5#$%#$#$DFSFDDFSGSDFSDF354FDDSGFDFfdssfddfswqemn,.zxih,.sx`"; int c_failed[sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0])]; static const size_t n_checks = sizeof(c_failed) / sizeof(c_failed[0]); memset (c_failed, 0, sizeof(c_failed)); for (j = 0; j < locale_name_count; j++) { set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { const struct str_with_value *const t = xdstrs_w_values + i; size_t b_size; size_t rs; if (c_failed[i]) continue; /* skip already failed checks */ if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str. len); exit (99); } if ('0' == t->str.str[0]) continue; /* Skip strings prefixed with zeros */ if (t->num_of_digt != t->str.len) continue; /* Skip strings with suffixes */ if (UINT32_MAX < t->val) continue; /* Too large value to convert */ if (sizeof(buf) < t->str.len + 1) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has too long (%u) string, " "size of 'buf' should be increased.\n", (unsigned int) i, (unsigned int) t->str.len); exit (99); } rs = 0; /* Only to mute compiler warning */ for (b_size = 0; b_size <= t->str.len + 1; ++b_size) { /* fill buffer with pseudo-random values */ memcpy (buf, erase, sizeof(buf)); rs = MHD_uint32_to_strx ((uint32_t) t->val, buf, b_size); if (t->num_of_digt > b_size) { /* Must fail, buffer is too small for result */ if (0 != rs) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint32_to_strx(0x%" PRIX64 ", -> buf," " %d) returned %" PRIuPTR ", while expecting 0." " Locale: %s\n", t->val, (int) b_size, (uintptr_t) rs, get_current_locale_str ()); } } else { if (t->num_of_digt != rs) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint32_to_strx(0x%" PRIX64 ", -> buf," " %d) returned %" PRIuPTR ", while expecting %d." " Locale: %s\n", t->val, (int) b_size, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); } else if (0 == MHD_str_equal_caseless_bin_n_ (buf, t->str.str, t->num_of_digt)) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint32_to_strx(0x%" PRIX64 ", -> \"%.*s\"," " %d) returned %" PRIuPTR "." " Locale: %s\n", t->val, (int) rs, buf, (int) b_size, (uintptr_t) rs, get_current_locale_str ()); } else if (sizeof(buf) <= rs) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has string with too many" "(%u) digits, size of 'buf' should be increased.\n", (unsigned int) i, (unsigned int) rs); exit (99); } else if (0 != memcmp (buf + rs, erase + rs, sizeof(buf) - rs)) { if (0 == c_failed[i]) t_failed++; c_failed[i] = ! 0; fprintf (stderr, "FAILED: MHD_uint32_to_strx(0x%" PRIX64 ", -> \"%.*s\"," " %d) returned %" PRIuPTR " and touched data after the resulting string." " Locale: %s\n", t->val, (int) rs, buf, (int) b_size, (uintptr_t) rs, get_current_locale_str ()); } } } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_uint32_to_strx(0x%" PRIX64 ", -> \"%.*s\", %d) " "== %" PRIuPTR "\n", t->val, (int) rs, buf, (int) b_size - 1, (uintptr_t) rs); } } return t_failed; } static const struct str_with_value duint8_w_values_p1[] = { {D_STR_W_LEN ("0"), 1, 0}, {D_STR_W_LEN ("1"), 1, 1}, {D_STR_W_LEN ("2"), 1, 2}, {D_STR_W_LEN ("3"), 1, 3}, {D_STR_W_LEN ("4"), 1, 4}, {D_STR_W_LEN ("5"), 1, 5}, {D_STR_W_LEN ("6"), 1, 6}, {D_STR_W_LEN ("7"), 1, 7}, {D_STR_W_LEN ("8"), 1, 8}, {D_STR_W_LEN ("9"), 1, 9}, {D_STR_W_LEN ("10"), 2, 10}, {D_STR_W_LEN ("11"), 2, 11}, {D_STR_W_LEN ("12"), 2, 12}, {D_STR_W_LEN ("13"), 2, 13}, {D_STR_W_LEN ("14"), 2, 14}, {D_STR_W_LEN ("15"), 2, 15}, {D_STR_W_LEN ("16"), 2, 16}, {D_STR_W_LEN ("17"), 2, 17}, {D_STR_W_LEN ("18"), 2, 18}, {D_STR_W_LEN ("19"), 2, 19}, {D_STR_W_LEN ("20"), 2, 20}, {D_STR_W_LEN ("21"), 2, 21}, {D_STR_W_LEN ("22"), 2, 22}, {D_STR_W_LEN ("23"), 2, 23}, {D_STR_W_LEN ("24"), 2, 24}, {D_STR_W_LEN ("25"), 2, 25}, {D_STR_W_LEN ("26"), 2, 26}, {D_STR_W_LEN ("27"), 2, 27}, {D_STR_W_LEN ("28"), 2, 28}, {D_STR_W_LEN ("29"), 2, 29}, {D_STR_W_LEN ("30"), 2, 30}, {D_STR_W_LEN ("31"), 2, 31}, {D_STR_W_LEN ("32"), 2, 32}, {D_STR_W_LEN ("33"), 2, 33}, {D_STR_W_LEN ("34"), 2, 34}, {D_STR_W_LEN ("35"), 2, 35}, {D_STR_W_LEN ("36"), 2, 36}, {D_STR_W_LEN ("37"), 2, 37}, {D_STR_W_LEN ("38"), 2, 38}, {D_STR_W_LEN ("39"), 2, 39}, {D_STR_W_LEN ("40"), 2, 40}, {D_STR_W_LEN ("41"), 2, 41}, {D_STR_W_LEN ("42"), 2, 42}, {D_STR_W_LEN ("43"), 2, 43}, {D_STR_W_LEN ("44"), 2, 44}, {D_STR_W_LEN ("45"), 2, 45}, {D_STR_W_LEN ("46"), 2, 46}, {D_STR_W_LEN ("47"), 2, 47}, {D_STR_W_LEN ("48"), 2, 48}, {D_STR_W_LEN ("49"), 2, 49}, {D_STR_W_LEN ("50"), 2, 50}, {D_STR_W_LEN ("51"), 2, 51}, {D_STR_W_LEN ("52"), 2, 52}, {D_STR_W_LEN ("53"), 2, 53}, {D_STR_W_LEN ("54"), 2, 54}, {D_STR_W_LEN ("55"), 2, 55}, {D_STR_W_LEN ("56"), 2, 56}, {D_STR_W_LEN ("57"), 2, 57}, {D_STR_W_LEN ("58"), 2, 58}, {D_STR_W_LEN ("59"), 2, 59}, {D_STR_W_LEN ("60"), 2, 60}, {D_STR_W_LEN ("61"), 2, 61}, {D_STR_W_LEN ("62"), 2, 62}, {D_STR_W_LEN ("63"), 2, 63}, {D_STR_W_LEN ("64"), 2, 64}, {D_STR_W_LEN ("65"), 2, 65}, {D_STR_W_LEN ("66"), 2, 66}, {D_STR_W_LEN ("67"), 2, 67}, {D_STR_W_LEN ("68"), 2, 68}, {D_STR_W_LEN ("69"), 2, 69}, {D_STR_W_LEN ("70"), 2, 70}, {D_STR_W_LEN ("71"), 2, 71}, {D_STR_W_LEN ("72"), 2, 72}, {D_STR_W_LEN ("73"), 2, 73}, {D_STR_W_LEN ("74"), 2, 74}, {D_STR_W_LEN ("75"), 2, 75}, {D_STR_W_LEN ("76"), 2, 76}, {D_STR_W_LEN ("77"), 2, 77}, {D_STR_W_LEN ("78"), 2, 78}, {D_STR_W_LEN ("79"), 2, 79}, {D_STR_W_LEN ("80"), 2, 80}, {D_STR_W_LEN ("81"), 2, 81}, {D_STR_W_LEN ("82"), 2, 82}, {D_STR_W_LEN ("83"), 2, 83}, {D_STR_W_LEN ("84"), 2, 84}, {D_STR_W_LEN ("85"), 2, 85}, {D_STR_W_LEN ("86"), 2, 86}, {D_STR_W_LEN ("87"), 2, 87}, {D_STR_W_LEN ("88"), 2, 88}, {D_STR_W_LEN ("89"), 2, 89}, {D_STR_W_LEN ("90"), 2, 90}, {D_STR_W_LEN ("91"), 2, 91}, {D_STR_W_LEN ("92"), 2, 92}, {D_STR_W_LEN ("93"), 2, 93}, {D_STR_W_LEN ("94"), 2, 94}, {D_STR_W_LEN ("95"), 2, 95}, {D_STR_W_LEN ("96"), 2, 96}, {D_STR_W_LEN ("97"), 2, 97}, {D_STR_W_LEN ("98"), 2, 98}, {D_STR_W_LEN ("99"), 2, 99}, {D_STR_W_LEN ("100"), 3, 100}, {D_STR_W_LEN ("101"), 3, 101}, {D_STR_W_LEN ("102"), 3, 102}, {D_STR_W_LEN ("103"), 3, 103}, {D_STR_W_LEN ("104"), 3, 104}, {D_STR_W_LEN ("105"), 3, 105}, {D_STR_W_LEN ("106"), 3, 106}, {D_STR_W_LEN ("107"), 3, 107}, {D_STR_W_LEN ("108"), 3, 108}, {D_STR_W_LEN ("109"), 3, 109}, {D_STR_W_LEN ("110"), 3, 110}, {D_STR_W_LEN ("111"), 3, 111}, {D_STR_W_LEN ("112"), 3, 112}, {D_STR_W_LEN ("113"), 3, 113}, {D_STR_W_LEN ("114"), 3, 114}, {D_STR_W_LEN ("115"), 3, 115}, {D_STR_W_LEN ("116"), 3, 116}, {D_STR_W_LEN ("117"), 3, 117}, {D_STR_W_LEN ("118"), 3, 118}, {D_STR_W_LEN ("119"), 3, 119}, {D_STR_W_LEN ("120"), 3, 120}, {D_STR_W_LEN ("121"), 3, 121}, {D_STR_W_LEN ("122"), 3, 122}, {D_STR_W_LEN ("123"), 3, 123}, {D_STR_W_LEN ("124"), 3, 124}, {D_STR_W_LEN ("125"), 3, 125}, {D_STR_W_LEN ("126"), 3, 126}, {D_STR_W_LEN ("127"), 3, 127}, {D_STR_W_LEN ("128"), 3, 128}, {D_STR_W_LEN ("129"), 3, 129}, {D_STR_W_LEN ("130"), 3, 130}, {D_STR_W_LEN ("131"), 3, 131}, {D_STR_W_LEN ("132"), 3, 132}, {D_STR_W_LEN ("133"), 3, 133}, {D_STR_W_LEN ("134"), 3, 134}, {D_STR_W_LEN ("135"), 3, 135}, {D_STR_W_LEN ("136"), 3, 136}, {D_STR_W_LEN ("137"), 3, 137}, {D_STR_W_LEN ("138"), 3, 138}, {D_STR_W_LEN ("139"), 3, 139}, {D_STR_W_LEN ("140"), 3, 140}, {D_STR_W_LEN ("141"), 3, 141}, {D_STR_W_LEN ("142"), 3, 142}, {D_STR_W_LEN ("143"), 3, 143}, {D_STR_W_LEN ("144"), 3, 144}, {D_STR_W_LEN ("145"), 3, 145}, {D_STR_W_LEN ("146"), 3, 146}, {D_STR_W_LEN ("147"), 3, 147}, {D_STR_W_LEN ("148"), 3, 148}, {D_STR_W_LEN ("149"), 3, 149}, {D_STR_W_LEN ("150"), 3, 150}, {D_STR_W_LEN ("151"), 3, 151}, {D_STR_W_LEN ("152"), 3, 152}, {D_STR_W_LEN ("153"), 3, 153}, {D_STR_W_LEN ("154"), 3, 154}, {D_STR_W_LEN ("155"), 3, 155}, {D_STR_W_LEN ("156"), 3, 156}, {D_STR_W_LEN ("157"), 3, 157}, {D_STR_W_LEN ("158"), 3, 158}, {D_STR_W_LEN ("159"), 3, 159}, {D_STR_W_LEN ("160"), 3, 160}, {D_STR_W_LEN ("161"), 3, 161}, {D_STR_W_LEN ("162"), 3, 162}, {D_STR_W_LEN ("163"), 3, 163}, {D_STR_W_LEN ("164"), 3, 164}, {D_STR_W_LEN ("165"), 3, 165}, {D_STR_W_LEN ("166"), 3, 166}, {D_STR_W_LEN ("167"), 3, 167}, {D_STR_W_LEN ("168"), 3, 168}, {D_STR_W_LEN ("169"), 3, 169}, {D_STR_W_LEN ("170"), 3, 170}, {D_STR_W_LEN ("171"), 3, 171}, {D_STR_W_LEN ("172"), 3, 172}, {D_STR_W_LEN ("173"), 3, 173}, {D_STR_W_LEN ("174"), 3, 174}, {D_STR_W_LEN ("175"), 3, 175}, {D_STR_W_LEN ("176"), 3, 176}, {D_STR_W_LEN ("177"), 3, 177}, {D_STR_W_LEN ("178"), 3, 178}, {D_STR_W_LEN ("179"), 3, 179}, {D_STR_W_LEN ("180"), 3, 180}, {D_STR_W_LEN ("181"), 3, 181}, {D_STR_W_LEN ("182"), 3, 182}, {D_STR_W_LEN ("183"), 3, 183}, {D_STR_W_LEN ("184"), 3, 184}, {D_STR_W_LEN ("185"), 3, 185}, {D_STR_W_LEN ("186"), 3, 186}, {D_STR_W_LEN ("187"), 3, 187}, {D_STR_W_LEN ("188"), 3, 188}, {D_STR_W_LEN ("189"), 3, 189}, {D_STR_W_LEN ("190"), 3, 190}, {D_STR_W_LEN ("191"), 3, 191}, {D_STR_W_LEN ("192"), 3, 192}, {D_STR_W_LEN ("193"), 3, 193}, {D_STR_W_LEN ("194"), 3, 194}, {D_STR_W_LEN ("195"), 3, 195}, {D_STR_W_LEN ("196"), 3, 196}, {D_STR_W_LEN ("197"), 3, 197}, {D_STR_W_LEN ("198"), 3, 198}, {D_STR_W_LEN ("199"), 3, 199}, {D_STR_W_LEN ("200"), 3, 200}, {D_STR_W_LEN ("201"), 3, 201}, {D_STR_W_LEN ("202"), 3, 202}, {D_STR_W_LEN ("203"), 3, 203}, {D_STR_W_LEN ("204"), 3, 204}, {D_STR_W_LEN ("205"), 3, 205}, {D_STR_W_LEN ("206"), 3, 206}, {D_STR_W_LEN ("207"), 3, 207}, {D_STR_W_LEN ("208"), 3, 208}, {D_STR_W_LEN ("209"), 3, 209}, {D_STR_W_LEN ("210"), 3, 210}, {D_STR_W_LEN ("211"), 3, 211}, {D_STR_W_LEN ("212"), 3, 212}, {D_STR_W_LEN ("213"), 3, 213}, {D_STR_W_LEN ("214"), 3, 214}, {D_STR_W_LEN ("215"), 3, 215}, {D_STR_W_LEN ("216"), 3, 216}, {D_STR_W_LEN ("217"), 3, 217}, {D_STR_W_LEN ("218"), 3, 218}, {D_STR_W_LEN ("219"), 3, 219}, {D_STR_W_LEN ("220"), 3, 220}, {D_STR_W_LEN ("221"), 3, 221}, {D_STR_W_LEN ("222"), 3, 222}, {D_STR_W_LEN ("223"), 3, 223}, {D_STR_W_LEN ("224"), 3, 224}, {D_STR_W_LEN ("225"), 3, 225}, {D_STR_W_LEN ("226"), 3, 226}, {D_STR_W_LEN ("227"), 3, 227}, {D_STR_W_LEN ("228"), 3, 228}, {D_STR_W_LEN ("229"), 3, 229}, {D_STR_W_LEN ("230"), 3, 230}, {D_STR_W_LEN ("231"), 3, 231}, {D_STR_W_LEN ("232"), 3, 232}, {D_STR_W_LEN ("233"), 3, 233}, {D_STR_W_LEN ("234"), 3, 234}, {D_STR_W_LEN ("235"), 3, 235}, {D_STR_W_LEN ("236"), 3, 236}, {D_STR_W_LEN ("237"), 3, 237}, {D_STR_W_LEN ("238"), 3, 238}, {D_STR_W_LEN ("239"), 3, 239}, {D_STR_W_LEN ("240"), 3, 240}, {D_STR_W_LEN ("241"), 3, 241}, {D_STR_W_LEN ("242"), 3, 242}, {D_STR_W_LEN ("243"), 3, 243}, {D_STR_W_LEN ("244"), 3, 244}, {D_STR_W_LEN ("245"), 3, 245}, {D_STR_W_LEN ("246"), 3, 246}, {D_STR_W_LEN ("247"), 3, 247}, {D_STR_W_LEN ("248"), 3, 248}, {D_STR_W_LEN ("249"), 3, 249}, {D_STR_W_LEN ("250"), 3, 250}, {D_STR_W_LEN ("251"), 3, 251}, {D_STR_W_LEN ("252"), 3, 252}, {D_STR_W_LEN ("253"), 3, 253}, {D_STR_W_LEN ("254"), 3, 254}, {D_STR_W_LEN ("255"), 3, 255}, }; static const struct str_with_value duint8_w_values_p2[] = { {D_STR_W_LEN ("00"), 2, 0}, {D_STR_W_LEN ("01"), 2, 1}, {D_STR_W_LEN ("02"), 2, 2}, {D_STR_W_LEN ("03"), 2, 3}, {D_STR_W_LEN ("04"), 2, 4}, {D_STR_W_LEN ("05"), 2, 5}, {D_STR_W_LEN ("06"), 2, 6}, {D_STR_W_LEN ("07"), 2, 7}, {D_STR_W_LEN ("08"), 2, 8}, {D_STR_W_LEN ("09"), 2, 9}, {D_STR_W_LEN ("10"), 2, 10}, {D_STR_W_LEN ("11"), 2, 11}, {D_STR_W_LEN ("12"), 2, 12}, {D_STR_W_LEN ("13"), 2, 13}, {D_STR_W_LEN ("14"), 2, 14}, {D_STR_W_LEN ("15"), 2, 15}, {D_STR_W_LEN ("16"), 2, 16}, {D_STR_W_LEN ("17"), 2, 17}, {D_STR_W_LEN ("18"), 2, 18}, {D_STR_W_LEN ("19"), 2, 19}, {D_STR_W_LEN ("20"), 2, 20}, {D_STR_W_LEN ("21"), 2, 21}, {D_STR_W_LEN ("22"), 2, 22}, {D_STR_W_LEN ("23"), 2, 23}, {D_STR_W_LEN ("24"), 2, 24}, {D_STR_W_LEN ("25"), 2, 25}, {D_STR_W_LEN ("26"), 2, 26}, {D_STR_W_LEN ("27"), 2, 27}, {D_STR_W_LEN ("28"), 2, 28}, {D_STR_W_LEN ("29"), 2, 29}, {D_STR_W_LEN ("30"), 2, 30}, {D_STR_W_LEN ("31"), 2, 31}, {D_STR_W_LEN ("32"), 2, 32}, {D_STR_W_LEN ("33"), 2, 33}, {D_STR_W_LEN ("34"), 2, 34}, {D_STR_W_LEN ("35"), 2, 35}, {D_STR_W_LEN ("36"), 2, 36}, {D_STR_W_LEN ("37"), 2, 37}, {D_STR_W_LEN ("38"), 2, 38}, {D_STR_W_LEN ("39"), 2, 39}, {D_STR_W_LEN ("40"), 2, 40}, {D_STR_W_LEN ("41"), 2, 41}, {D_STR_W_LEN ("42"), 2, 42}, {D_STR_W_LEN ("43"), 2, 43}, {D_STR_W_LEN ("44"), 2, 44}, {D_STR_W_LEN ("45"), 2, 45}, {D_STR_W_LEN ("46"), 2, 46}, {D_STR_W_LEN ("47"), 2, 47}, {D_STR_W_LEN ("48"), 2, 48}, {D_STR_W_LEN ("49"), 2, 49}, {D_STR_W_LEN ("50"), 2, 50}, {D_STR_W_LEN ("51"), 2, 51}, {D_STR_W_LEN ("52"), 2, 52}, {D_STR_W_LEN ("53"), 2, 53}, {D_STR_W_LEN ("54"), 2, 54}, {D_STR_W_LEN ("55"), 2, 55}, {D_STR_W_LEN ("56"), 2, 56}, {D_STR_W_LEN ("57"), 2, 57}, {D_STR_W_LEN ("58"), 2, 58}, {D_STR_W_LEN ("59"), 2, 59}, {D_STR_W_LEN ("60"), 2, 60}, {D_STR_W_LEN ("61"), 2, 61}, {D_STR_W_LEN ("62"), 2, 62}, {D_STR_W_LEN ("63"), 2, 63}, {D_STR_W_LEN ("64"), 2, 64}, {D_STR_W_LEN ("65"), 2, 65}, {D_STR_W_LEN ("66"), 2, 66}, {D_STR_W_LEN ("67"), 2, 67}, {D_STR_W_LEN ("68"), 2, 68}, {D_STR_W_LEN ("69"), 2, 69}, {D_STR_W_LEN ("70"), 2, 70}, {D_STR_W_LEN ("71"), 2, 71}, {D_STR_W_LEN ("72"), 2, 72}, {D_STR_W_LEN ("73"), 2, 73}, {D_STR_W_LEN ("74"), 2, 74}, {D_STR_W_LEN ("75"), 2, 75}, {D_STR_W_LEN ("76"), 2, 76}, {D_STR_W_LEN ("77"), 2, 77}, {D_STR_W_LEN ("78"), 2, 78}, {D_STR_W_LEN ("79"), 2, 79}, {D_STR_W_LEN ("80"), 2, 80}, {D_STR_W_LEN ("81"), 2, 81}, {D_STR_W_LEN ("82"), 2, 82}, {D_STR_W_LEN ("83"), 2, 83}, {D_STR_W_LEN ("84"), 2, 84}, {D_STR_W_LEN ("85"), 2, 85}, {D_STR_W_LEN ("86"), 2, 86}, {D_STR_W_LEN ("87"), 2, 87}, {D_STR_W_LEN ("88"), 2, 88}, {D_STR_W_LEN ("89"), 2, 89}, {D_STR_W_LEN ("90"), 2, 90}, {D_STR_W_LEN ("91"), 2, 91}, {D_STR_W_LEN ("92"), 2, 92}, {D_STR_W_LEN ("93"), 2, 93}, {D_STR_W_LEN ("94"), 2, 94}, {D_STR_W_LEN ("95"), 2, 95}, {D_STR_W_LEN ("96"), 2, 96}, {D_STR_W_LEN ("97"), 2, 97}, {D_STR_W_LEN ("98"), 2, 98}, {D_STR_W_LEN ("99"), 2, 99}, {D_STR_W_LEN ("100"), 3, 100}, {D_STR_W_LEN ("101"), 3, 101}, {D_STR_W_LEN ("102"), 3, 102}, {D_STR_W_LEN ("103"), 3, 103}, {D_STR_W_LEN ("104"), 3, 104}, {D_STR_W_LEN ("105"), 3, 105}, {D_STR_W_LEN ("106"), 3, 106}, {D_STR_W_LEN ("107"), 3, 107}, {D_STR_W_LEN ("108"), 3, 108}, {D_STR_W_LEN ("109"), 3, 109}, {D_STR_W_LEN ("110"), 3, 110}, {D_STR_W_LEN ("111"), 3, 111}, {D_STR_W_LEN ("112"), 3, 112}, {D_STR_W_LEN ("113"), 3, 113}, {D_STR_W_LEN ("114"), 3, 114}, {D_STR_W_LEN ("115"), 3, 115}, {D_STR_W_LEN ("116"), 3, 116}, {D_STR_W_LEN ("117"), 3, 117}, {D_STR_W_LEN ("118"), 3, 118}, {D_STR_W_LEN ("119"), 3, 119}, {D_STR_W_LEN ("120"), 3, 120}, {D_STR_W_LEN ("121"), 3, 121}, {D_STR_W_LEN ("122"), 3, 122}, {D_STR_W_LEN ("123"), 3, 123}, {D_STR_W_LEN ("124"), 3, 124}, {D_STR_W_LEN ("125"), 3, 125}, {D_STR_W_LEN ("126"), 3, 126}, {D_STR_W_LEN ("127"), 3, 127}, {D_STR_W_LEN ("128"), 3, 128}, {D_STR_W_LEN ("129"), 3, 129}, {D_STR_W_LEN ("130"), 3, 130}, {D_STR_W_LEN ("131"), 3, 131}, {D_STR_W_LEN ("132"), 3, 132}, {D_STR_W_LEN ("133"), 3, 133}, {D_STR_W_LEN ("134"), 3, 134}, {D_STR_W_LEN ("135"), 3, 135}, {D_STR_W_LEN ("136"), 3, 136}, {D_STR_W_LEN ("137"), 3, 137}, {D_STR_W_LEN ("138"), 3, 138}, {D_STR_W_LEN ("139"), 3, 139}, {D_STR_W_LEN ("140"), 3, 140}, {D_STR_W_LEN ("141"), 3, 141}, {D_STR_W_LEN ("142"), 3, 142}, {D_STR_W_LEN ("143"), 3, 143}, {D_STR_W_LEN ("144"), 3, 144}, {D_STR_W_LEN ("145"), 3, 145}, {D_STR_W_LEN ("146"), 3, 146}, {D_STR_W_LEN ("147"), 3, 147}, {D_STR_W_LEN ("148"), 3, 148}, {D_STR_W_LEN ("149"), 3, 149}, {D_STR_W_LEN ("150"), 3, 150}, {D_STR_W_LEN ("151"), 3, 151}, {D_STR_W_LEN ("152"), 3, 152}, {D_STR_W_LEN ("153"), 3, 153}, {D_STR_W_LEN ("154"), 3, 154}, {D_STR_W_LEN ("155"), 3, 155}, {D_STR_W_LEN ("156"), 3, 156}, {D_STR_W_LEN ("157"), 3, 157}, {D_STR_W_LEN ("158"), 3, 158}, {D_STR_W_LEN ("159"), 3, 159}, {D_STR_W_LEN ("160"), 3, 160}, {D_STR_W_LEN ("161"), 3, 161}, {D_STR_W_LEN ("162"), 3, 162}, {D_STR_W_LEN ("163"), 3, 163}, {D_STR_W_LEN ("164"), 3, 164}, {D_STR_W_LEN ("165"), 3, 165}, {D_STR_W_LEN ("166"), 3, 166}, {D_STR_W_LEN ("167"), 3, 167}, {D_STR_W_LEN ("168"), 3, 168}, {D_STR_W_LEN ("169"), 3, 169}, {D_STR_W_LEN ("170"), 3, 170}, {D_STR_W_LEN ("171"), 3, 171}, {D_STR_W_LEN ("172"), 3, 172}, {D_STR_W_LEN ("173"), 3, 173}, {D_STR_W_LEN ("174"), 3, 174}, {D_STR_W_LEN ("175"), 3, 175}, {D_STR_W_LEN ("176"), 3, 176}, {D_STR_W_LEN ("177"), 3, 177}, {D_STR_W_LEN ("178"), 3, 178}, {D_STR_W_LEN ("179"), 3, 179}, {D_STR_W_LEN ("180"), 3, 180}, {D_STR_W_LEN ("181"), 3, 181}, {D_STR_W_LEN ("182"), 3, 182}, {D_STR_W_LEN ("183"), 3, 183}, {D_STR_W_LEN ("184"), 3, 184}, {D_STR_W_LEN ("185"), 3, 185}, {D_STR_W_LEN ("186"), 3, 186}, {D_STR_W_LEN ("187"), 3, 187}, {D_STR_W_LEN ("188"), 3, 188}, {D_STR_W_LEN ("189"), 3, 189}, {D_STR_W_LEN ("190"), 3, 190}, {D_STR_W_LEN ("191"), 3, 191}, {D_STR_W_LEN ("192"), 3, 192}, {D_STR_W_LEN ("193"), 3, 193}, {D_STR_W_LEN ("194"), 3, 194}, {D_STR_W_LEN ("195"), 3, 195}, {D_STR_W_LEN ("196"), 3, 196}, {D_STR_W_LEN ("197"), 3, 197}, {D_STR_W_LEN ("198"), 3, 198}, {D_STR_W_LEN ("199"), 3, 199}, {D_STR_W_LEN ("200"), 3, 200}, {D_STR_W_LEN ("201"), 3, 201}, {D_STR_W_LEN ("202"), 3, 202}, {D_STR_W_LEN ("203"), 3, 203}, {D_STR_W_LEN ("204"), 3, 204}, {D_STR_W_LEN ("205"), 3, 205}, {D_STR_W_LEN ("206"), 3, 206}, {D_STR_W_LEN ("207"), 3, 207}, {D_STR_W_LEN ("208"), 3, 208}, {D_STR_W_LEN ("209"), 3, 209}, {D_STR_W_LEN ("210"), 3, 210}, {D_STR_W_LEN ("211"), 3, 211}, {D_STR_W_LEN ("212"), 3, 212}, {D_STR_W_LEN ("213"), 3, 213}, {D_STR_W_LEN ("214"), 3, 214}, {D_STR_W_LEN ("215"), 3, 215}, {D_STR_W_LEN ("216"), 3, 216}, {D_STR_W_LEN ("217"), 3, 217}, {D_STR_W_LEN ("218"), 3, 218}, {D_STR_W_LEN ("219"), 3, 219}, {D_STR_W_LEN ("220"), 3, 220}, {D_STR_W_LEN ("221"), 3, 221}, {D_STR_W_LEN ("222"), 3, 222}, {D_STR_W_LEN ("223"), 3, 223}, {D_STR_W_LEN ("224"), 3, 224}, {D_STR_W_LEN ("225"), 3, 225}, {D_STR_W_LEN ("226"), 3, 226}, {D_STR_W_LEN ("227"), 3, 227}, {D_STR_W_LEN ("228"), 3, 228}, {D_STR_W_LEN ("229"), 3, 229}, {D_STR_W_LEN ("230"), 3, 230}, {D_STR_W_LEN ("231"), 3, 231}, {D_STR_W_LEN ("232"), 3, 232}, {D_STR_W_LEN ("233"), 3, 233}, {D_STR_W_LEN ("234"), 3, 234}, {D_STR_W_LEN ("235"), 3, 235}, {D_STR_W_LEN ("236"), 3, 236}, {D_STR_W_LEN ("237"), 3, 237}, {D_STR_W_LEN ("238"), 3, 238}, {D_STR_W_LEN ("239"), 3, 239}, {D_STR_W_LEN ("240"), 3, 240}, {D_STR_W_LEN ("241"), 3, 241}, {D_STR_W_LEN ("242"), 3, 242}, {D_STR_W_LEN ("243"), 3, 243}, {D_STR_W_LEN ("244"), 3, 244}, {D_STR_W_LEN ("245"), 3, 245}, {D_STR_W_LEN ("246"), 3, 246}, {D_STR_W_LEN ("247"), 3, 247}, {D_STR_W_LEN ("248"), 3, 248}, {D_STR_W_LEN ("249"), 3, 249}, {D_STR_W_LEN ("250"), 3, 250}, {D_STR_W_LEN ("251"), 3, 251}, {D_STR_W_LEN ("252"), 3, 252}, {D_STR_W_LEN ("253"), 3, 253}, {D_STR_W_LEN ("254"), 3, 254}, {D_STR_W_LEN ("255"), 3, 255} }; static const struct str_with_value duint8_w_values_p3[] = { {D_STR_W_LEN ("000"), 3, 0}, {D_STR_W_LEN ("001"), 3, 1}, {D_STR_W_LEN ("002"), 3, 2}, {D_STR_W_LEN ("003"), 3, 3}, {D_STR_W_LEN ("004"), 3, 4}, {D_STR_W_LEN ("005"), 3, 5}, {D_STR_W_LEN ("006"), 3, 6}, {D_STR_W_LEN ("007"), 3, 7}, {D_STR_W_LEN ("008"), 3, 8}, {D_STR_W_LEN ("009"), 3, 9}, {D_STR_W_LEN ("010"), 3, 10}, {D_STR_W_LEN ("011"), 3, 11}, {D_STR_W_LEN ("012"), 3, 12}, {D_STR_W_LEN ("013"), 3, 13}, {D_STR_W_LEN ("014"), 3, 14}, {D_STR_W_LEN ("015"), 3, 15}, {D_STR_W_LEN ("016"), 3, 16}, {D_STR_W_LEN ("017"), 3, 17}, {D_STR_W_LEN ("018"), 3, 18}, {D_STR_W_LEN ("019"), 3, 19}, {D_STR_W_LEN ("020"), 3, 20}, {D_STR_W_LEN ("021"), 3, 21}, {D_STR_W_LEN ("022"), 3, 22}, {D_STR_W_LEN ("023"), 3, 23}, {D_STR_W_LEN ("024"), 3, 24}, {D_STR_W_LEN ("025"), 3, 25}, {D_STR_W_LEN ("026"), 3, 26}, {D_STR_W_LEN ("027"), 3, 27}, {D_STR_W_LEN ("028"), 3, 28}, {D_STR_W_LEN ("029"), 3, 29}, {D_STR_W_LEN ("030"), 3, 30}, {D_STR_W_LEN ("031"), 3, 31}, {D_STR_W_LEN ("032"), 3, 32}, {D_STR_W_LEN ("033"), 3, 33}, {D_STR_W_LEN ("034"), 3, 34}, {D_STR_W_LEN ("035"), 3, 35}, {D_STR_W_LEN ("036"), 3, 36}, {D_STR_W_LEN ("037"), 3, 37}, {D_STR_W_LEN ("038"), 3, 38}, {D_STR_W_LEN ("039"), 3, 39}, {D_STR_W_LEN ("040"), 3, 40}, {D_STR_W_LEN ("041"), 3, 41}, {D_STR_W_LEN ("042"), 3, 42}, {D_STR_W_LEN ("043"), 3, 43}, {D_STR_W_LEN ("044"), 3, 44}, {D_STR_W_LEN ("045"), 3, 45}, {D_STR_W_LEN ("046"), 3, 46}, {D_STR_W_LEN ("047"), 3, 47}, {D_STR_W_LEN ("048"), 3, 48}, {D_STR_W_LEN ("049"), 3, 49}, {D_STR_W_LEN ("050"), 3, 50}, {D_STR_W_LEN ("051"), 3, 51}, {D_STR_W_LEN ("052"), 3, 52}, {D_STR_W_LEN ("053"), 3, 53}, {D_STR_W_LEN ("054"), 3, 54}, {D_STR_W_LEN ("055"), 3, 55}, {D_STR_W_LEN ("056"), 3, 56}, {D_STR_W_LEN ("057"), 3, 57}, {D_STR_W_LEN ("058"), 3, 58}, {D_STR_W_LEN ("059"), 3, 59}, {D_STR_W_LEN ("060"), 3, 60}, {D_STR_W_LEN ("061"), 3, 61}, {D_STR_W_LEN ("062"), 3, 62}, {D_STR_W_LEN ("063"), 3, 63}, {D_STR_W_LEN ("064"), 3, 64}, {D_STR_W_LEN ("065"), 3, 65}, {D_STR_W_LEN ("066"), 3, 66}, {D_STR_W_LEN ("067"), 3, 67}, {D_STR_W_LEN ("068"), 3, 68}, {D_STR_W_LEN ("069"), 3, 69}, {D_STR_W_LEN ("070"), 3, 70}, {D_STR_W_LEN ("071"), 3, 71}, {D_STR_W_LEN ("072"), 3, 72}, {D_STR_W_LEN ("073"), 3, 73}, {D_STR_W_LEN ("074"), 3, 74}, {D_STR_W_LEN ("075"), 3, 75}, {D_STR_W_LEN ("076"), 3, 76}, {D_STR_W_LEN ("077"), 3, 77}, {D_STR_W_LEN ("078"), 3, 78}, {D_STR_W_LEN ("079"), 3, 79}, {D_STR_W_LEN ("080"), 3, 80}, {D_STR_W_LEN ("081"), 3, 81}, {D_STR_W_LEN ("082"), 3, 82}, {D_STR_W_LEN ("083"), 3, 83}, {D_STR_W_LEN ("084"), 3, 84}, {D_STR_W_LEN ("085"), 3, 85}, {D_STR_W_LEN ("086"), 3, 86}, {D_STR_W_LEN ("087"), 3, 87}, {D_STR_W_LEN ("088"), 3, 88}, {D_STR_W_LEN ("089"), 3, 89}, {D_STR_W_LEN ("090"), 3, 90}, {D_STR_W_LEN ("091"), 3, 91}, {D_STR_W_LEN ("092"), 3, 92}, {D_STR_W_LEN ("093"), 3, 93}, {D_STR_W_LEN ("094"), 3, 94}, {D_STR_W_LEN ("095"), 3, 95}, {D_STR_W_LEN ("096"), 3, 96}, {D_STR_W_LEN ("097"), 3, 97}, {D_STR_W_LEN ("098"), 3, 98}, {D_STR_W_LEN ("099"), 3, 99}, {D_STR_W_LEN ("100"), 3, 100}, {D_STR_W_LEN ("101"), 3, 101}, {D_STR_W_LEN ("102"), 3, 102}, {D_STR_W_LEN ("103"), 3, 103}, {D_STR_W_LEN ("104"), 3, 104}, {D_STR_W_LEN ("105"), 3, 105}, {D_STR_W_LEN ("106"), 3, 106}, {D_STR_W_LEN ("107"), 3, 107}, {D_STR_W_LEN ("108"), 3, 108}, {D_STR_W_LEN ("109"), 3, 109}, {D_STR_W_LEN ("110"), 3, 110}, {D_STR_W_LEN ("111"), 3, 111}, {D_STR_W_LEN ("112"), 3, 112}, {D_STR_W_LEN ("113"), 3, 113}, {D_STR_W_LEN ("114"), 3, 114}, {D_STR_W_LEN ("115"), 3, 115}, {D_STR_W_LEN ("116"), 3, 116}, {D_STR_W_LEN ("117"), 3, 117}, {D_STR_W_LEN ("118"), 3, 118}, {D_STR_W_LEN ("119"), 3, 119}, {D_STR_W_LEN ("120"), 3, 120}, {D_STR_W_LEN ("121"), 3, 121}, {D_STR_W_LEN ("122"), 3, 122}, {D_STR_W_LEN ("123"), 3, 123}, {D_STR_W_LEN ("124"), 3, 124}, {D_STR_W_LEN ("125"), 3, 125}, {D_STR_W_LEN ("126"), 3, 126}, {D_STR_W_LEN ("127"), 3, 127}, {D_STR_W_LEN ("128"), 3, 128}, {D_STR_W_LEN ("129"), 3, 129}, {D_STR_W_LEN ("130"), 3, 130}, {D_STR_W_LEN ("131"), 3, 131}, {D_STR_W_LEN ("132"), 3, 132}, {D_STR_W_LEN ("133"), 3, 133}, {D_STR_W_LEN ("134"), 3, 134}, {D_STR_W_LEN ("135"), 3, 135}, {D_STR_W_LEN ("136"), 3, 136}, {D_STR_W_LEN ("137"), 3, 137}, {D_STR_W_LEN ("138"), 3, 138}, {D_STR_W_LEN ("139"), 3, 139}, {D_STR_W_LEN ("140"), 3, 140}, {D_STR_W_LEN ("141"), 3, 141}, {D_STR_W_LEN ("142"), 3, 142}, {D_STR_W_LEN ("143"), 3, 143}, {D_STR_W_LEN ("144"), 3, 144}, {D_STR_W_LEN ("145"), 3, 145}, {D_STR_W_LEN ("146"), 3, 146}, {D_STR_W_LEN ("147"), 3, 147}, {D_STR_W_LEN ("148"), 3, 148}, {D_STR_W_LEN ("149"), 3, 149}, {D_STR_W_LEN ("150"), 3, 150}, {D_STR_W_LEN ("151"), 3, 151}, {D_STR_W_LEN ("152"), 3, 152}, {D_STR_W_LEN ("153"), 3, 153}, {D_STR_W_LEN ("154"), 3, 154}, {D_STR_W_LEN ("155"), 3, 155}, {D_STR_W_LEN ("156"), 3, 156}, {D_STR_W_LEN ("157"), 3, 157}, {D_STR_W_LEN ("158"), 3, 158}, {D_STR_W_LEN ("159"), 3, 159}, {D_STR_W_LEN ("160"), 3, 160}, {D_STR_W_LEN ("161"), 3, 161}, {D_STR_W_LEN ("162"), 3, 162}, {D_STR_W_LEN ("163"), 3, 163}, {D_STR_W_LEN ("164"), 3, 164}, {D_STR_W_LEN ("165"), 3, 165}, {D_STR_W_LEN ("166"), 3, 166}, {D_STR_W_LEN ("167"), 3, 167}, {D_STR_W_LEN ("168"), 3, 168}, {D_STR_W_LEN ("169"), 3, 169}, {D_STR_W_LEN ("170"), 3, 170}, {D_STR_W_LEN ("171"), 3, 171}, {D_STR_W_LEN ("172"), 3, 172}, {D_STR_W_LEN ("173"), 3, 173}, {D_STR_W_LEN ("174"), 3, 174}, {D_STR_W_LEN ("175"), 3, 175}, {D_STR_W_LEN ("176"), 3, 176}, {D_STR_W_LEN ("177"), 3, 177}, {D_STR_W_LEN ("178"), 3, 178}, {D_STR_W_LEN ("179"), 3, 179}, {D_STR_W_LEN ("180"), 3, 180}, {D_STR_W_LEN ("181"), 3, 181}, {D_STR_W_LEN ("182"), 3, 182}, {D_STR_W_LEN ("183"), 3, 183}, {D_STR_W_LEN ("184"), 3, 184}, {D_STR_W_LEN ("185"), 3, 185}, {D_STR_W_LEN ("186"), 3, 186}, {D_STR_W_LEN ("187"), 3, 187}, {D_STR_W_LEN ("188"), 3, 188}, {D_STR_W_LEN ("189"), 3, 189}, {D_STR_W_LEN ("190"), 3, 190}, {D_STR_W_LEN ("191"), 3, 191}, {D_STR_W_LEN ("192"), 3, 192}, {D_STR_W_LEN ("193"), 3, 193}, {D_STR_W_LEN ("194"), 3, 194}, {D_STR_W_LEN ("195"), 3, 195}, {D_STR_W_LEN ("196"), 3, 196}, {D_STR_W_LEN ("197"), 3, 197}, {D_STR_W_LEN ("198"), 3, 198}, {D_STR_W_LEN ("199"), 3, 199}, {D_STR_W_LEN ("200"), 3, 200}, {D_STR_W_LEN ("201"), 3, 201}, {D_STR_W_LEN ("202"), 3, 202}, {D_STR_W_LEN ("203"), 3, 203}, {D_STR_W_LEN ("204"), 3, 204}, {D_STR_W_LEN ("205"), 3, 205}, {D_STR_W_LEN ("206"), 3, 206}, {D_STR_W_LEN ("207"), 3, 207}, {D_STR_W_LEN ("208"), 3, 208}, {D_STR_W_LEN ("209"), 3, 209}, {D_STR_W_LEN ("210"), 3, 210}, {D_STR_W_LEN ("211"), 3, 211}, {D_STR_W_LEN ("212"), 3, 212}, {D_STR_W_LEN ("213"), 3, 213}, {D_STR_W_LEN ("214"), 3, 214}, {D_STR_W_LEN ("215"), 3, 215}, {D_STR_W_LEN ("216"), 3, 216}, {D_STR_W_LEN ("217"), 3, 217}, {D_STR_W_LEN ("218"), 3, 218}, {D_STR_W_LEN ("219"), 3, 219}, {D_STR_W_LEN ("220"), 3, 220}, {D_STR_W_LEN ("221"), 3, 221}, {D_STR_W_LEN ("222"), 3, 222}, {D_STR_W_LEN ("223"), 3, 223}, {D_STR_W_LEN ("224"), 3, 224}, {D_STR_W_LEN ("225"), 3, 225}, {D_STR_W_LEN ("226"), 3, 226}, {D_STR_W_LEN ("227"), 3, 227}, {D_STR_W_LEN ("228"), 3, 228}, {D_STR_W_LEN ("229"), 3, 229}, {D_STR_W_LEN ("230"), 3, 230}, {D_STR_W_LEN ("231"), 3, 231}, {D_STR_W_LEN ("232"), 3, 232}, {D_STR_W_LEN ("233"), 3, 233}, {D_STR_W_LEN ("234"), 3, 234}, {D_STR_W_LEN ("235"), 3, 235}, {D_STR_W_LEN ("236"), 3, 236}, {D_STR_W_LEN ("237"), 3, 237}, {D_STR_W_LEN ("238"), 3, 238}, {D_STR_W_LEN ("239"), 3, 239}, {D_STR_W_LEN ("240"), 3, 240}, {D_STR_W_LEN ("241"), 3, 241}, {D_STR_W_LEN ("242"), 3, 242}, {D_STR_W_LEN ("243"), 3, 243}, {D_STR_W_LEN ("244"), 3, 244}, {D_STR_W_LEN ("245"), 3, 245}, {D_STR_W_LEN ("246"), 3, 246}, {D_STR_W_LEN ("247"), 3, 247}, {D_STR_W_LEN ("248"), 3, 248}, {D_STR_W_LEN ("249"), 3, 249}, {D_STR_W_LEN ("250"), 3, 250}, {D_STR_W_LEN ("251"), 3, 251}, {D_STR_W_LEN ("252"), 3, 252}, {D_STR_W_LEN ("253"), 3, 253}, {D_STR_W_LEN ("254"), 3, 254}, {D_STR_W_LEN ("255"), 3, 255} }; static const struct str_with_value *duint8_w_values_p[3] = {duint8_w_values_p1, duint8_w_values_p2, duint8_w_values_p3}; static size_t check_str_from_uint8_pad (void) { int i; uint8_t pad; size_t t_failed = 0; if ((256 != sizeof(duint8_w_values_p1) / sizeof(duint8_w_values_p1[0])) || (256 != sizeof(duint8_w_values_p2) / sizeof(duint8_w_values_p2[0])) || (256 != sizeof(duint8_w_values_p3) / sizeof(duint8_w_values_p3[0]))) { fprintf (stderr, "ERROR: wrong number of items in duint8_w_values_p*.\n"); exit (99); } for (pad = 0; pad <= 3; pad++) { size_t table_num; if (0 != pad) table_num = pad - 1; else table_num = 0; for (i = 0; i <= 255; i++) { const struct str_with_value *const t = duint8_w_values_p[table_num] + i; size_t b_size; size_t rs; char buf[8]; if (t->str.len < t->num_of_digt) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" " to be less or equal to str.len (%u).\n", (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str. len); exit (99); } if (sizeof(buf) < t->str.len + 1) { fprintf (stderr, "ERROR: dstrs_w_values[%u] has too long (%u) string, " "size of 'buf' should be increased.\n", (unsigned int) i, (unsigned int) t->str.len); exit (99); } for (b_size = 0; b_size <= t->str.len + 1; ++b_size) { /* fill buffer with pseudo-random values */ memset (buf, '#', sizeof(buf)); rs = MHD_uint8_to_str_pad ((uint8_t) t->val, pad, buf, b_size); if (t->num_of_digt > b_size) { /* Must fail, buffer is too small for result */ if (0 != rs) { t_failed++; fprintf (stderr, "FAILED: MHD_uint8_to_str_pad(%" PRIu64 ", %d, -> buf," " %d) returned %" PRIuPTR ", while expecting 0.\n", t->val, (int) pad, (int) b_size, (uintptr_t) rs); } } else { if (t->num_of_digt != rs) { t_failed++; fprintf (stderr, "FAILED: MHD_uint8_to_str_pad(%" PRIu64 ", %d, -> buf," " %d) returned %" PRIuPTR ", while expecting %d.\n", t->val, (int) pad, (int) b_size, (uintptr_t) rs, (int) t->num_of_digt); } else if (0 != memcmp (buf, t->str.str, t->num_of_digt)) { t_failed++; fprintf (stderr, "FAILED: MHD_uint8_to_str_pad(%" PRIu64 ", %d, " "-> \"%.*s\", %d) returned %" PRIuPTR ".\n", t->val, (int) pad, (int) rs, buf, (int) b_size, (uintptr_t) rs); } else if (0 != memcmp (buf + rs, "########", sizeof(buf) - rs)) { t_failed++; fprintf (stderr, "FAILED: MHD_uint8_to_str_pad(%" PRIu64 ", %d," " -> \"%.*s\", %d) returned %" PRIuPTR " and touched data after the resulting string.\n", t->val, (int) pad, (int) rs, buf, (int) b_size, (uintptr_t) rs); } } } } } if ((verbose > 1) && (0 == t_failed)) printf ("PASSED: MHD_uint8_to_str_pad.\n"); return t_failed; } static int run_str_from_X_tests (void) { size_t str_from_uint16; size_t str_from_uint64; size_t strx_from_uint32; size_t str_from_uint8_pad; size_t failures; failures = 0; str_from_uint16 = check_str_from_uint16 (); if (str_from_uint16 != 0) { fprintf (stderr, "FAILED: testcase check_str_from_uint16() failed.\n\n"); failures += str_from_uint16; } else if (verbose > 1) printf ("PASSED: testcase check_str_from_uint16() successfully " "passed.\n\n"); str_from_uint64 = check_str_from_uint64 (); if (str_from_uint64 != 0) { fprintf (stderr, "FAILED: testcase check_str_from_uint16() failed.\n\n"); failures += str_from_uint64; } else if (verbose > 1) printf ("PASSED: testcase check_str_from_uint16() successfully " "passed.\n\n"); strx_from_uint32 = check_strx_from_uint32 (); if (strx_from_uint32 != 0) { fprintf (stderr, "FAILED: testcase check_strx_from_uint32() failed.\n\n"); failures += strx_from_uint32; } else if (verbose > 1) printf ("PASSED: testcase check_strx_from_uint32() successfully " "passed.\n\n"); str_from_uint8_pad = check_str_from_uint8_pad (); if (str_from_uint8_pad != 0) { fprintf (stderr, "FAILED: testcase check_str_from_uint8_pad() failed.\n\n"); failures += str_from_uint8_pad; } else if (verbose > 1) printf ("PASSED: testcase check_str_from_uint8_pad() successfully " "passed.\n\n"); if (failures) { if (verbose > 0) printf ("At least one test failed.\n"); return 1; } if (verbose > 0) printf ("All tests passed successfully.\n"); return 0; } int main (int argc, char *argv[]) { if (has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose") || has_param (argc, argv, "--verbose1")) verbose = 1; if (has_param (argc, argv, "-vv") || has_param (argc, argv, "--verbose2")) verbose = 2; if (has_param (argc, argv, "-vvv") || has_param (argc, argv, "--verbose3")) verbose = 3; if (has_in_name (argv[0], "_to_value")) return run_str_to_X_tests (); if (has_in_name (argv[0], "_from_value")) return run_str_from_X_tests (); return run_eq_neq_str_tests (); } libmicrohttpd-1.0.1/src/microhttpd/md5_ext.c0000644000175000017500000000546214560002050014512 /* This file is part of GNU libmicrohttpd Copyright (C) 2022-2023 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GNU libmicrohttpd. If not, see . */ /** * @file microhttpd/md5_ext.c * @brief Wrapper for MD5 calculation performed by TLS library * @author Karlson2k (Evgeny Grin) */ #include #include "md5_ext.h" #include "mhd_assert.h" /** * Initialise structure for MD5 calculation, allocate resources. * * This function must not be called more than one time for @a ctx. * * @param ctx the calculation context */ void MHD_MD5_init_one_time (struct Md5CtxExt *ctx) { ctx->handle = NULL; ctx->ext_error = gnutls_hash_init (&ctx->handle, GNUTLS_DIG_MD5); if ((0 != ctx->ext_error) && (NULL != ctx->handle)) { /* GnuTLS may return initialisation error and set the handle at the same time. Such handle cannot be used for calculations. Note: GnuTLS may also return an error and NOT set the handle. */ gnutls_free (ctx->handle); ctx->handle = NULL; } /* If handle is NULL, the error must be set */ mhd_assert ((NULL != ctx->handle) || (0 != ctx->ext_error)); /* If error is set, the handle must be NULL */ mhd_assert ((0 == ctx->ext_error) || (NULL == ctx->handle)); } /** * Process portion of bytes. * * @param ctx the calculation context * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_MD5_update (struct Md5CtxExt *ctx, const uint8_t *data, size_t length) { if (0 == ctx->ext_error) ctx->ext_error = gnutls_hash (ctx->handle, data, length); } /** * Finalise MD5 calculation, return digest, reset hash calculation. * * @param ctx the calculation context * @param[out] digest set to the hash, must be #MD5_DIGEST_SIZE bytes */ void MHD_MD5_finish_reset (struct Md5CtxExt *ctx, uint8_t digest[MD5_DIGEST_SIZE]) { if (0 == ctx->ext_error) gnutls_hash_output (ctx->handle, digest); } /** * Free allocated resources. * * @param ctx the calculation context */ void MHD_MD5_deinit (struct Md5CtxExt *ctx) { if (NULL != ctx->handle) gnutls_hash_deinit (ctx->handle, NULL); } libmicrohttpd-1.0.1/src/microhttpd/mhd_compat.c0000644000175000017500000000545514417460232015275 /* This file is part of libmicrohttpd Copyright (C) 2014-2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd/mhd_compat.c * @brief Implementation of platform missing functions. * @author Karlson2k (Evgeny Grin) */ #include "mhd_compat.h" #if defined(_WIN32) && ! defined(__CYGWIN__) #include #include #ifndef HAVE_SNPRINTF #include #include #endif /* HAVE_SNPRINTF */ #endif /* _WIN32 && !__CYGWIN__ */ #ifndef HAVE_CALLOC #include /* for memset() */ #endif /* ! HAVE_CALLOC */ #if defined(_WIN32) && ! defined(__CYGWIN__) #ifndef HAVE_SNPRINTF /* Emulate snprintf function on W32 */ int W32_snprintf (char *__restrict s, size_t n, const char *__restrict format, ...) { int ret; va_list args; if ( (0 != n) && (NULL != s) ) { va_start (args, format); ret = _vsnprintf (s, n, format, args); va_end (args); if ((int) n == ret) s[n - 1] = 0; if (ret >= 0) return ret; } va_start (args, format); ret = _vscprintf (format, args); va_end (args); if ( (0 <= ret) && (0 != n) && (NULL == s) ) return -1; return ret; } #endif /* HAVE_SNPRINTF */ #endif /* _WIN32 && !__CYGWIN__ */ #ifndef HAVE_CALLOC #ifdef __has_builtin # if __has_builtin (__builtin_mul_overflow) # define MHD_HAVE_NUL_OVERFLOW 1 # endif #elif __GNUC__ + 0 >= 5 # define MHD_HAVE_NUL_OVERFLOW 1 #endif /* __GNUC__ >= 5 */ void * MHD_calloc_ (size_t nelem, size_t elsize) { size_t alloc_size; void *ptr; #ifdef MHD_HAVE_NUL_OVERFLOW if (__builtin_mul_overflow (nelem, elsize, &alloc_size) || (0 == alloc_size)) return NULL; #else /* ! MHD_HAVE_NUL_OVERFLOW */ alloc_size = nelem * elsize; if ((0 == alloc_size) || (elsize != alloc_size / nelem)) return NULL; #endif /* ! MHD_HAVE_NUL_OVERFLOW */ ptr = malloc (alloc_size); if (NULL == ptr) return NULL; memset (ptr, 0, alloc_size); return ptr; } #endif /* ! HAVE_CALLOC */ libmicrohttpd-1.0.1/src/Makefile.in0000644000175000017500000005335014566140140012701 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # This Makefile.am is in the public domain VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @RUN_LIBCURL_TESTS_TRUE@am__append_1 = testcurl @RUN_LIBCURL_TESTS_TRUE@@RUN_ZZUF_TESTS_TRUE@am__append_2 = testzzuf # Finally (last!) also build experimental lib... @HAVE_EXPERIMENTAL_TRUE@am__append_3 = microhttpd_ws lib @BUILD_EXAMPLES_TRUE@am__append_4 = examples @BUILD_TOOLS_TRUE@am__append_5 = tools subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` DIST_SUBDIRS = include microhttpd . testcurl testzzuf microhttpd_ws \ lib examples tools am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = include microhttpd . $(am__append_1) $(am__append_2) \ $(am__append_3) $(am__append_4) $(am__append_5) EXTRA_DIST = \ datadir/cert-and-key.pem \ datadir/cert-and-key-for-wireshark.pem all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile .NOTPARALLEL: # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/src/datadir/0000755000175000017500000000000014566140216012322 5libmicrohttpd-1.0.1/src/datadir/cert-and-key-for-wireshark.pem0000644000175000017500000000325014417460232020007 -----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCff7amw9zNSE+h rOMhBrzbbsJluUP3gmd8nOKY5MUimoPkxmAXfp2L0il+MPZT/ZEmo11q0k6J2jfG UBQ+oZW9ahNZ9gCDjbYlBblo/mqTai+LdeLO3qk53d0zrZKXvCO6sA3uKpG2WR+g +sNKxfYpIHCpanqBU6O+degIV/+WKy3nQ2Fwp7K5HUNj1u0pg0QQ18yf68LTnKFU HFjZmmaaopWki5wKSBieHivzQy6w+04HSTogHHRK/y/UcoJNSG7xnHmoPPo1vLT8 CMRIYnSSgU3wJ43XBJ80WxrC2dcoZjV2XZz+XdQwCD4ZrC1ihykcAmiQA+sauNm7 dztOMkGzAgMBAAECggEAIbKDzlvXDG/YkxnJqrKXt+yAmak4mNQuNP+YSCEdHSBz +SOILa6MbnvqVETX5grOXdFp7SWdfjZiTj2g6VKOJkSA7iKxHRoVf2DkOTB3J8np XZd8YaRdMGKVV1O2guQ20Dxd1RGdU18k9YfFNsj4Jtw5sTFTzHr1P0n9ybV9xCXp znSxVfRg8U6TcMHoRDJR9EMKQMO4W3OQEmreEPoGt2/+kMuiHjclxLtbwDxKXTLP pD0gdg3ibvlufk/ccKl/yAglDmd0dfW22oS7NgvRKUve7tzDxY1Q6O5v8BCnLFSW D+z4hS1PzooYRXRkM0xYudvPkryPyu+1kEpw3fNsoQKBgQDRfXJo82XQvlX8WPdZ Ts3PfBKKMVu3Wf8J3SYpuvYT816qR3ot6e4Ivv5ZCQkdDwzzBKe2jAv6JddMJIhx pkGHc0KKOodd9HoBewOd8Td++hapJAGaGblhL5beIidLKjXDjLqtgoHRGlv5Cojo zHa7Viel1eOPPcBumhp83oJ+mQKBgQDC6PmdETZdrW3QPm7ZXxRzF1vvpC55wmPg pRfTRM059jzRzAk0QiBgVp3yk2a6Ob3mB2MLfQVDgzGf37h2oO07s5nspSFZTFnM KgSjFy0xVOAVDLe+0VpbmLp1YUTYvdCNowaoTE7++5rpePUDu3BjAifx07/yaSB+ W+YPOfOuKwKBgQCGK6g5G5qcJSuBIaHZ6yTZvIdLRu2M8vDral5k3793a6m3uWvB OFAh/eF9ONJDcD5E7zhTLEMHhXDs7YEN+QODMwjs6yuDu27gv97DK5j1lEsrLUpx XgRjAE3KG2m7NF+WzO1K74khWZaKXHrvTvTEaxudlO3X8h7rN3u7ee9uEQKBgQC2 wI1zeTUZhsiFTlTPWfgppchdHPs6zUqq0wFQ5Zzr8Pa72+zxY+NJkU2NqinTCNsG ePykQ/gQgk2gUrt595AYv2De40IuoYk9BlTMuql0LNniwsbykwd/BOgnsSlFdEy8 0RQn70zOhgmNSg2qDzDklJvxghLi7zE5aV9//V1/ewKBgFRHHZN1a8q/v8AAOeoB ROuXfgDDpxNNUKbzLL5MO5odgZGi61PBZlxffrSOqyZoJkzawXycNtoBP47tcVzT QPq5ZOB3kjHTcN7dRLmPWjji9h4O3eHCX67XaPVMSWiMuNtOZIg2an06+jxGFhLE qdJNJ1DkyUc9dN2cliX4R+rG -----END PRIVATE KEY----- libmicrohttpd-1.0.1/src/datadir/cert-and-key.pem0000644000175000017500000000701714417460232015233 -----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCff7amw9zNSE+h rOMhBrzbbsJluUP3gmd8nOKY5MUimoPkxmAXfp2L0il+MPZT/ZEmo11q0k6J2jfG UBQ+oZW9ahNZ9gCDjbYlBblo/mqTai+LdeLO3qk53d0zrZKXvCO6sA3uKpG2WR+g +sNKxfYpIHCpanqBU6O+degIV/+WKy3nQ2Fwp7K5HUNj1u0pg0QQ18yf68LTnKFU HFjZmmaaopWki5wKSBieHivzQy6w+04HSTogHHRK/y/UcoJNSG7xnHmoPPo1vLT8 CMRIYnSSgU3wJ43XBJ80WxrC2dcoZjV2XZz+XdQwCD4ZrC1ihykcAmiQA+sauNm7 dztOMkGzAgMBAAECggEAIbKDzlvXDG/YkxnJqrKXt+yAmak4mNQuNP+YSCEdHSBz +SOILa6MbnvqVETX5grOXdFp7SWdfjZiTj2g6VKOJkSA7iKxHRoVf2DkOTB3J8np XZd8YaRdMGKVV1O2guQ20Dxd1RGdU18k9YfFNsj4Jtw5sTFTzHr1P0n9ybV9xCXp znSxVfRg8U6TcMHoRDJR9EMKQMO4W3OQEmreEPoGt2/+kMuiHjclxLtbwDxKXTLP pD0gdg3ibvlufk/ccKl/yAglDmd0dfW22oS7NgvRKUve7tzDxY1Q6O5v8BCnLFSW D+z4hS1PzooYRXRkM0xYudvPkryPyu+1kEpw3fNsoQKBgQDRfXJo82XQvlX8WPdZ Ts3PfBKKMVu3Wf8J3SYpuvYT816qR3ot6e4Ivv5ZCQkdDwzzBKe2jAv6JddMJIhx pkGHc0KKOodd9HoBewOd8Td++hapJAGaGblhL5beIidLKjXDjLqtgoHRGlv5Cojo zHa7Viel1eOPPcBumhp83oJ+mQKBgQDC6PmdETZdrW3QPm7ZXxRzF1vvpC55wmPg pRfTRM059jzRzAk0QiBgVp3yk2a6Ob3mB2MLfQVDgzGf37h2oO07s5nspSFZTFnM KgSjFy0xVOAVDLe+0VpbmLp1YUTYvdCNowaoTE7++5rpePUDu3BjAifx07/yaSB+ W+YPOfOuKwKBgQCGK6g5G5qcJSuBIaHZ6yTZvIdLRu2M8vDral5k3793a6m3uWvB OFAh/eF9ONJDcD5E7zhTLEMHhXDs7YEN+QODMwjs6yuDu27gv97DK5j1lEsrLUpx XgRjAE3KG2m7NF+WzO1K74khWZaKXHrvTvTEaxudlO3X8h7rN3u7ee9uEQKBgQC2 wI1zeTUZhsiFTlTPWfgppchdHPs6zUqq0wFQ5Zzr8Pa72+zxY+NJkU2NqinTCNsG ePykQ/gQgk2gUrt595AYv2De40IuoYk9BlTMuql0LNniwsbykwd/BOgnsSlFdEy8 0RQn70zOhgmNSg2qDzDklJvxghLi7zE5aV9//V1/ewKBgFRHHZN1a8q/v8AAOeoB ROuXfgDDpxNNUKbzLL5MO5odgZGi61PBZlxffrSOqyZoJkzawXycNtoBP47tcVzT QPq5ZOB3kjHTcN7dRLmPWjji9h4O3eHCX67XaPVMSWiMuNtOZIg2an06+jxGFhLE qdJNJ1DkyUc9dN2cliX4R+rG -----END PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIIFSzCCAzOgAwIBAgIBBDANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx DzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwGTW9zY293MRswGQYDVQQKDBJ0ZXN0 LWxpYm1pY3JvaHR0cGQxITAfBgkqhkiG9w0BCQEWEm5vYm9keUBleGFtcGxlLm9y ZzEQMA4GA1UEAwwHdGVzdC1DQTAgFw0yMjA0MjAxODQzMDJaGA8yMTIyMDMyNjE4 NDMwMlowZTELMAkGA1UEBhMCUlUxDzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwG TW9zY293MRswGQYDVQQKDBJ0ZXN0LWxpYm1pY3JvaHR0cGQxFzAVBgNVBAMMDnRl c3QtbWhkc2VydmVyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn3+2 psPczUhPoazjIQa8227CZblD94JnfJzimOTFIpqD5MZgF36di9IpfjD2U/2RJqNd atJOido3xlAUPqGVvWoTWfYAg422JQW5aP5qk2ovi3Xizt6pOd3dM62Sl7wjurAN 7iqRtlkfoPrDSsX2KSBwqWp6gVOjvnXoCFf/list50NhcKeyuR1DY9btKYNEENfM n+vC05yhVBxY2ZpmmqKVpIucCkgYnh4r80MusPtOB0k6IBx0Sv8v1HKCTUhu8Zx5 qDz6Nby0/AjESGJ0koFN8CeN1wSfNFsawtnXKGY1dl2c/l3UMAg+GawtYocpHAJo kAPrGrjZu3c7TjJBswIDAQABo4HmMIHjMAsGA1UdDwQEAwIFoDAMBgNVHRMBAf8E AjAAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMBMDEGA1UdEQQqMCiCDnRlc3QtbWhk c2VydmVyhwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMB0GA1UdDgQWBBQ57Z06WJae 8fJIHId4QGx/HsRgDDAoBglghkgBhvhCAQ0EGxYZVGVzdCBsaWJtaWNyb2h0dHBk IHNlcnZlcjARBglghkgBhvhCAQEEBAMCBkAwHwYDVR0jBBgwFoAUWHVDwKVqMcOF Nd0arI3/QB3W6SwwDQYJKoZIhvcNAQELBQADggIBAI7Lggm/XzpugV93H5+KV48x X+Ct8unNmPCSzCaI5hAHGeBBJpvD0KME5oiJ5p2wfCtK5Dt9zzf0S0xYdRKqU8+N aKIvPoU1hFixXLwTte1qOp6TviGvA9Xn2Fc4n36dLt6e9aiqDnqPbJgBwcVO82ll HJxVr3WbrAcQTB3irFUMqgAke/Cva9Bw79VZgX4ghb5EnejDzuyup4pHGzV10Myv hdg+VWZbAxpCe0S4eKmstZC7mWsFCLeoRTf/9Pk1kQ6+azbTuV/9QOBNfFi8QNyb 18jUjmm8sc2HKo8miCGqb2sFqaGD918hfkWmR+fFkzQ3DZQrT+eYbKq2un3k0pMy UySy8SRn1eadfab+GwBVb68I9TrPRMrJsIzysNXMX4iKYl2fFE/RSNnaHtPw0C8y B7memyxPRl+H2xg6UjpoKYh3+8e44/XKm0rNIzXjrwA8f8gnw2TbqmMDkj1YqGnC SCj5A27zUzaf2pT/YsnQXIWOJjVvbEI+YKj34wKWyTrXA093y8YI8T3mal7Kr9YM WiIyPts0/aVeziM0Gunglz+8Rj1VesL52FTurobqusPgM/AME82+qb/qnxuPaCKj OT1qAbIblaRuWqCsid8BzP7ZQiAnAWgMRSUg1gzDwSwRhrYQRRWAyn/Qipzec+27 /w0gW9EVWzFhsFeGEssi -----END CERTIFICATE----- libmicrohttpd-1.0.1/src/examples/0000755000175000017500000000000014566140217012531 5libmicrohttpd-1.0.1/src/examples/chunked_example.c0000644000175000017500000001356214556705750015770 /* This file is part of libmicrohttpd Copyright (C) 2015 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file chunked_example.c * @brief example for generating chunked encoding with libmicrohttpd * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include struct ResponseContentCallbackParam { const char *response_data; size_t response_size; }; static ssize_t callback (void *cls, uint64_t pos, char *buf, size_t buf_size) { size_t size_to_copy; struct ResponseContentCallbackParam *const param = (struct ResponseContentCallbackParam *) cls; /* Note: 'pos' will never exceed size of transmitted data. */ /* You can use 'pos == param->response_size' in next check. */ if (pos >= param->response_size) { /* Whole response was sent. Signal end of response. */ return MHD_CONTENT_READER_END_OF_STREAM; } /* Pseudo code. * if (data_not_ready) { // Callback will be called again on next loop. // Consider suspending connection until data will be ready. return 0; } * End of pseudo code. */ if (buf_size < (param->response_size - pos)) size_to_copy = buf_size; else size_to_copy = (size_t) (param->response_size - pos); memcpy (buf, param->response_data + pos, size_to_copy); /* Pseudo code. * if (error_preparing_response) { // Close connection with error. return MHD_CONTENT_READER_END_WITH_ERROR; } * End of pseudo code. */ /* Return amount of data copied to buffer. */ /* The 'buf_size' is always smaller than SSIZE_MAX therefore it's safe * to cast 'size_to_copy' to 'ssize_t'. */ /* assert (size_to_copy <= buf_size); */ return (ssize_t) size_to_copy; } static void free_callback_param (void *cls) { free (cls); } static const char simple_response_text[] = "Simple response" "Simple response text"; static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct ResponseContentCallbackParam *callback_param; struct MHD_Response *response; enum MHD_Result ret; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } callback_param = malloc (sizeof(struct ResponseContentCallbackParam)); if (NULL == callback_param) return MHD_NO; /* Not enough memory. */ callback_param->response_data = simple_response_text; callback_param->response_size = (sizeof(simple_response_text) / sizeof(char)) - 1; *req_cls = NULL; /* reset when done */ response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 1024, &callback, callback_param, &free_callback_param); if (NULL == response) { free (callback_param); return MHD_NO; } /* Enforce chunked response, even for non-keep-alive connection. */ if (MHD_NO == MHD_add_response_header (response, MHD_HTTP_HEADER_TRANSFER_ENCODING, "chunked")) { free (callback_param); MHD_destroy_response (response); return MHD_NO; } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > UINT16_MAX) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } d = MHD_start_daemon (/* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, /* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_END); if (NULL == d) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/https_fileserver_example.c0000644000175000017500000002243014441373361017721 /* This file is part of libmicrohttpd Copyright (C) 2007, 2008 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file https_fileserver_example.c * @brief a simple HTTPS file server using TLS. * * Usage : * * 'http_fileserver_example HTTP-PORT SECONDS-TO-RUN' * * The certificate & key are required by the server to operate, omitting the * path arguments will cause the server to use the hard coded example certificate & key. * * 'certtool' may be used to generate these if required. * * @author Sagie Amir * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #include #define BUF_SIZE 1024 #define MAX_URL_LEN 255 #define EMPTY_PAGE \ "File not foundFile not found" /* test server key */ static const char key_pem[] = "-----BEGIN PRIVATE KEY-----\n\ MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCff7amw9zNSE+h\n\ rOMhBrzbbsJluUP3gmd8nOKY5MUimoPkxmAXfp2L0il+MPZT/ZEmo11q0k6J2jfG\n\ UBQ+oZW9ahNZ9gCDjbYlBblo/mqTai+LdeLO3qk53d0zrZKXvCO6sA3uKpG2WR+g\n\ +sNKxfYpIHCpanqBU6O+degIV/+WKy3nQ2Fwp7K5HUNj1u0pg0QQ18yf68LTnKFU\n\ HFjZmmaaopWki5wKSBieHivzQy6w+04HSTogHHRK/y/UcoJNSG7xnHmoPPo1vLT8\n\ CMRIYnSSgU3wJ43XBJ80WxrC2dcoZjV2XZz+XdQwCD4ZrC1ihykcAmiQA+sauNm7\n\ dztOMkGzAgMBAAECggEAIbKDzlvXDG/YkxnJqrKXt+yAmak4mNQuNP+YSCEdHSBz\n\ +SOILa6MbnvqVETX5grOXdFp7SWdfjZiTj2g6VKOJkSA7iKxHRoVf2DkOTB3J8np\n\ XZd8YaRdMGKVV1O2guQ20Dxd1RGdU18k9YfFNsj4Jtw5sTFTzHr1P0n9ybV9xCXp\n\ znSxVfRg8U6TcMHoRDJR9EMKQMO4W3OQEmreEPoGt2/+kMuiHjclxLtbwDxKXTLP\n\ pD0gdg3ibvlufk/ccKl/yAglDmd0dfW22oS7NgvRKUve7tzDxY1Q6O5v8BCnLFSW\n\ D+z4hS1PzooYRXRkM0xYudvPkryPyu+1kEpw3fNsoQKBgQDRfXJo82XQvlX8WPdZ\n\ Ts3PfBKKMVu3Wf8J3SYpuvYT816qR3ot6e4Ivv5ZCQkdDwzzBKe2jAv6JddMJIhx\n\ pkGHc0KKOodd9HoBewOd8Td++hapJAGaGblhL5beIidLKjXDjLqtgoHRGlv5Cojo\n\ zHa7Viel1eOPPcBumhp83oJ+mQKBgQDC6PmdETZdrW3QPm7ZXxRzF1vvpC55wmPg\n\ pRfTRM059jzRzAk0QiBgVp3yk2a6Ob3mB2MLfQVDgzGf37h2oO07s5nspSFZTFnM\n\ KgSjFy0xVOAVDLe+0VpbmLp1YUTYvdCNowaoTE7++5rpePUDu3BjAifx07/yaSB+\n\ W+YPOfOuKwKBgQCGK6g5G5qcJSuBIaHZ6yTZvIdLRu2M8vDral5k3793a6m3uWvB\n\ OFAh/eF9ONJDcD5E7zhTLEMHhXDs7YEN+QODMwjs6yuDu27gv97DK5j1lEsrLUpx\n\ XgRjAE3KG2m7NF+WzO1K74khWZaKXHrvTvTEaxudlO3X8h7rN3u7ee9uEQKBgQC2\n\ wI1zeTUZhsiFTlTPWfgppchdHPs6zUqq0wFQ5Zzr8Pa72+zxY+NJkU2NqinTCNsG\n\ ePykQ/gQgk2gUrt595AYv2De40IuoYk9BlTMuql0LNniwsbykwd/BOgnsSlFdEy8\n\ 0RQn70zOhgmNSg2qDzDklJvxghLi7zE5aV9//V1/ewKBgFRHHZN1a8q/v8AAOeoB\n\ ROuXfgDDpxNNUKbzLL5MO5odgZGi61PBZlxffrSOqyZoJkzawXycNtoBP47tcVzT\n\ QPq5ZOB3kjHTcN7dRLmPWjji9h4O3eHCX67XaPVMSWiMuNtOZIg2an06+jxGFhLE\n\ qdJNJ1DkyUc9dN2cliX4R+rG\n\ -----END PRIVATE KEY-----"; /* test server CA signed certificates */ static const char cert_pem[] = "-----BEGIN CERTIFICATE-----\n\ MIIFSzCCAzOgAwIBAgIBBDANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx\n\ DzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwGTW9zY293MRswGQYDVQQKDBJ0ZXN0\n\ LWxpYm1pY3JvaHR0cGQxITAfBgkqhkiG9w0BCQEWEm5vYm9keUBleGFtcGxlLm9y\n\ ZzEQMA4GA1UEAwwHdGVzdC1DQTAgFw0yMjA0MjAxODQzMDJaGA8yMTIyMDMyNjE4\n\ NDMwMlowZTELMAkGA1UEBhMCUlUxDzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwG\n\ TW9zY293MRswGQYDVQQKDBJ0ZXN0LWxpYm1pY3JvaHR0cGQxFzAVBgNVBAMMDnRl\n\ c3QtbWhkc2VydmVyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn3+2\n\ psPczUhPoazjIQa8227CZblD94JnfJzimOTFIpqD5MZgF36di9IpfjD2U/2RJqNd\n\ atJOido3xlAUPqGVvWoTWfYAg422JQW5aP5qk2ovi3Xizt6pOd3dM62Sl7wjurAN\n\ 7iqRtlkfoPrDSsX2KSBwqWp6gVOjvnXoCFf/list50NhcKeyuR1DY9btKYNEENfM\n\ n+vC05yhVBxY2ZpmmqKVpIucCkgYnh4r80MusPtOB0k6IBx0Sv8v1HKCTUhu8Zx5\n\ qDz6Nby0/AjESGJ0koFN8CeN1wSfNFsawtnXKGY1dl2c/l3UMAg+GawtYocpHAJo\n\ kAPrGrjZu3c7TjJBswIDAQABo4HmMIHjMAsGA1UdDwQEAwIFoDAMBgNVHRMBAf8E\n\ AjAAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMBMDEGA1UdEQQqMCiCDnRlc3QtbWhk\n\ c2VydmVyhwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMB0GA1UdDgQWBBQ57Z06WJae\n\ 8fJIHId4QGx/HsRgDDAoBglghkgBhvhCAQ0EGxYZVGVzdCBsaWJtaWNyb2h0dHBk\n\ IHNlcnZlcjARBglghkgBhvhCAQEEBAMCBkAwHwYDVR0jBBgwFoAUWHVDwKVqMcOF\n\ Nd0arI3/QB3W6SwwDQYJKoZIhvcNAQELBQADggIBAI7Lggm/XzpugV93H5+KV48x\n\ X+Ct8unNmPCSzCaI5hAHGeBBJpvD0KME5oiJ5p2wfCtK5Dt9zzf0S0xYdRKqU8+N\n\ aKIvPoU1hFixXLwTte1qOp6TviGvA9Xn2Fc4n36dLt6e9aiqDnqPbJgBwcVO82ll\n\ HJxVr3WbrAcQTB3irFUMqgAke/Cva9Bw79VZgX4ghb5EnejDzuyup4pHGzV10Myv\n\ hdg+VWZbAxpCe0S4eKmstZC7mWsFCLeoRTf/9Pk1kQ6+azbTuV/9QOBNfFi8QNyb\n\ 18jUjmm8sc2HKo8miCGqb2sFqaGD918hfkWmR+fFkzQ3DZQrT+eYbKq2un3k0pMy\n\ UySy8SRn1eadfab+GwBVb68I9TrPRMrJsIzysNXMX4iKYl2fFE/RSNnaHtPw0C8y\n\ B7memyxPRl+H2xg6UjpoKYh3+8e44/XKm0rNIzXjrwA8f8gnw2TbqmMDkj1YqGnC\n\ SCj5A27zUzaf2pT/YsnQXIWOJjVvbEI+YKj34wKWyTrXA093y8YI8T3mal7Kr9YM\n\ WiIyPts0/aVeziM0Gunglz+8Rj1VesL52FTurobqusPgM/AME82+qb/qnxuPaCKj\n\ OT1qAbIblaRuWqCsid8BzP7ZQiAnAWgMRSUg1gzDwSwRhrYQRRWAyn/Qipzec+27\n\ /w0gW9EVWzFhsFeGEssi\n\ -----END CERTIFICATE-----"; static ssize_t file_reader (void *cls, uint64_t pos, char *buf, size_t max) { FILE *file = (FILE *) cls; size_t bytes_read; /* 'fseek' may not support files larger 2GiB, depending on platform. * For production code, make sure that 'pos' has valid values, supported by * 'fseek', or use 'fseeko' or similar function. */ if (0 != fseek (file, (long) pos, SEEK_SET)) return MHD_CONTENT_READER_END_WITH_ERROR; bytes_read = fread (buf, 1, max, file); if (0 == bytes_read) return (0 != ferror (file)) ? MHD_CONTENT_READER_END_WITH_ERROR : MHD_CONTENT_READER_END_OF_STREAM; return (ssize_t) bytes_read; } static void file_free_callback (void *cls) { FILE *file = cls; fclose (file); } /* HTTP access handler call back */ static enum MHD_Result http_ahc (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; FILE *file; int fd; struct stat buf; (void) cls; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ file = fopen (&url[1], "rb"); if (NULL != file) { fd = fileno (file); if (-1 == fd) { (void) fclose (file); return MHD_NO; /* internal error */ } if ( (0 != fstat (fd, &buf)) || (! S_ISREG (buf.st_mode)) ) { /* not a regular file, refuse to serve */ fclose (file); file = NULL; } } if (NULL == file) { response = MHD_create_response_from_buffer_static (strlen (EMPTY_PAGE), (const void *) EMPTY_PAGE); ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); MHD_destroy_response (response); } else { response = MHD_create_response_from_callback ((size_t) buf.st_size, 32 * 1024, /* 32k page size */ &file_reader, file, &file_free_callback); if (NULL == response) { fclose (file); return MHD_NO; } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); } return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *TLS_daemon; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > UINT16_MAX) ) { fprintf (stderr, "Port must be a number between 1 and 65535\n"); return 1; } TLS_daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_TLS, (uint16_t) port, NULL, NULL, &http_ahc, NULL, MHD_OPTION_CONNECTION_TIMEOUT, 256, MHD_OPTION_HTTPS_MEM_KEY, key_pem, MHD_OPTION_HTTPS_MEM_CERT, cert_pem, MHD_OPTION_END); if (NULL == TLS_daemon) { fprintf (stderr, "Error: failed to start TLS_daemon.\n"); return 1; } printf ("MHD daemon listening on port %u\n", (unsigned int) port); (void) getc (stdin); MHD_stop_daemon (TLS_daemon); return 0; } libmicrohttpd-1.0.1/src/examples/querystring_example.c0000644000175000017500000000756514441373361016741 /* This file is part of libmicrohttpd Copyright (C) 2007, 2008 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file querystring_example.c * @brief example for how to get the query string from libmicrohttpd * Call with an URI ending with something like "?q=QUERY" * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #define PAGE \ "libmicrohttpd demoQuery string for "%s" was "%s"" static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; const char *val; char *me; struct MHD_Response *response; enum MHD_Result ret; int resp_len; size_t buf_size; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ val = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "q"); if (NULL == val) return MHD_NO; /* No "q" argument was found */ resp_len = snprintf (NULL, 0, PAGE, "q", val); if (0 >= resp_len) return MHD_NO; /* Error calculating response size */ buf_size = (size_t) resp_len + 1; /* Add one byte for zero-termination */ me = malloc (buf_size); if (me == NULL) return MHD_NO; /* Error allocating memory */ if (resp_len != snprintf (me, buf_size, PAGE, "q", val)) { free (me); return MHD_NO; /* Error forming the response body */ } response = MHD_create_response_from_buffer_with_free_callback (buf_size - 1, (void *) me, &free); if (response == NULL) { free (me); return MHD_NO; } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (port < 0) || (port > UINT16_MAX) ) { printf ("%s PORT\n", argv[0]); return 1; } d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (NULL == d) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/demo.c0000644000175000017500000007110114556271671013551 /* This file is part of libmicrohttpd Copyright (C) 2013 Christian Grothoff (and other contributing authors) Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file demo.c * @brief complex demonstration site: create directory index, offer * upload via form and HTTP POST, download with mime type detection * and error reporting (403, etc.) --- and all of this with * high-performance settings (large buffers, thread pool). * If you want to benchmark MHD, this code should be used to * run tests against. Note that the number of threads may need * to be adjusted depending on the number of available cores. * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "MHD_config.h" #include "platform.h" #include #include #include #include #include #include #ifdef MHD_HAVE_LIBMAGIC #include #endif /* MHD_HAVE_LIBMAGIC */ #include #include #include #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #ifndef PATH_MAX /* Some platforms (namely: GNU Hurd) do no define PATH_MAX. As it is only example for MHD, just use reasonable value for PATH_MAX. */ #define PATH_MAX 16384 #endif /** * Number of threads to run in the thread pool. Should (roughly) match * the number of cores on your system. */ #define NUMBER_OF_THREADS MHD_CPU_COUNT #ifdef MHD_HAVE_LIBMAGIC /** * How many bytes of a file do we give to libmagic to determine the mime type? * 16k might be a bit excessive, but ought not hurt performance much anyway, * and should definitively be on the safe side. */ #define MAGIC_HEADER_SIZE (16 * 1024) #endif /* MHD_HAVE_LIBMAGIC */ /** * Page returned for file-not-found. */ #define FILE_NOT_FOUND_PAGE \ "File not foundFile not found" /** * Page returned for internal errors. */ #define INTERNAL_ERROR_PAGE \ "Internal errorInternal error" /** * Page returned for refused requests. */ #define REQUEST_REFUSED_PAGE \ "Request refusedRequest refused (file exists?)" /** * Head of index page. */ #define INDEX_PAGE_HEADER \ "\nWelcome\n\n" \ "

Upload

\n" \ "
\n" \ "
Content type:
" \ "Book" \ "Image" \ "Music" \ "Software" \ "Videos\n" \ "Other
" \ "
Language:
" \ "none" \ "English" \ "German" \ "French" \ "Spanish
\n" \ "
File:
" \ "
" \ "\n" \ "
\n" \ "

Download

\n" \ "
    \n" /** * Footer of index page. */ #define INDEX_PAGE_FOOTER "
\n\n" /** * NULL-terminated array of supported upload categories. Should match HTML * in the form. */ static const char *const categories[] = { "books", "images", "music", "software", "videos", "other", NULL, }; /** * Specification of a supported language. */ struct Language { /** * Directory name for the language. */ const char *dirname; /** * Long name for humans. */ const char *longname; }; /** * NULL-terminated array of supported upload categories. Should match HTML * in the form. */ static const struct Language languages[] = { { "no-lang", "No language specified" }, { "en", "English" }, { "de", "German" }, { "fr", "French" }, { "es", "Spanish" }, { NULL, NULL }, }; /** * Response returned if the requested file does not exist (or is not accessible). */ static struct MHD_Response *file_not_found_response; /** * Response returned for internal errors. */ static struct MHD_Response *internal_error_response; /** * Response returned for '/' (GET) to list the contents of the directory and allow upload. */ static struct MHD_Response *cached_directory_response; /** * Response returned for refused uploads. */ static struct MHD_Response *request_refused_response; /** * Mutex used when we update the cached directory response object. */ static pthread_mutex_t mutex; #ifdef MHD_HAVE_LIBMAGIC /** * Global handle to MAGIC data. */ static magic_t magic; #endif /* MHD_HAVE_LIBMAGIC */ /** * Mark the given response as HTML for the browser. * * @param response response to mark */ static void mark_as_html (struct MHD_Response *response) { (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); } /** * Replace the existing 'cached_directory_response' with the * given response. * * @param response new directory response */ static void update_cached_response (struct MHD_Response *response) { (void) pthread_mutex_lock (&mutex); if (NULL != cached_directory_response) MHD_destroy_response (cached_directory_response); cached_directory_response = response; (void) pthread_mutex_unlock (&mutex); } /** * Context keeping the data for the response we're building. */ struct ResponseDataContext { /** * Response data string. */ char *buf; /** * Number of bytes allocated for 'buf'. */ size_t buf_len; /** * Current position where we append to 'buf'. Must be smaller or equal to 'buf_len'. */ size_t off; }; /** * Create a listing of the files in 'dirname' in HTML. * * @param rdc where to store the list of files * @param dirname name of the directory to list * @return #MHD_YES on success, #MHD_NO on error */ static enum MHD_Result list_directory (struct ResponseDataContext *rdc, const char *dirname) { char fullname[PATH_MAX]; struct stat sbuf; DIR *dir; struct dirent *de; if (NULL == (dir = opendir (dirname))) return MHD_NO; while (NULL != (de = readdir (dir))) { int res; if ('.' == de->d_name[0]) continue; if (sizeof (fullname) <= (unsigned int) snprintf (fullname, sizeof (fullname), "%s/%s", dirname, de->d_name)) continue; /* ugh, file too long? how can this be!? */ if (0 != stat (fullname, &sbuf)) continue; /* ugh, failed to 'stat' */ if (! S_ISREG (sbuf.st_mode)) continue; /* not a regular file, skip */ if (rdc->off + 1024 > rdc->buf_len) { void *r; if ( (2 * rdc->buf_len + 1024) < rdc->buf_len) break; /* more than SIZE_T _index_ size? Too big for us */ rdc->buf_len = 2 * rdc->buf_len + 1024; if (NULL == (r = realloc (rdc->buf, rdc->buf_len))) break; /* out of memory */ rdc->buf = r; } res = snprintf (&rdc->buf[rdc->off], rdc->buf_len - rdc->off, "
  • %s
  • \n", fullname, de->d_name); if (0 >= res) continue; /* snprintf() error */ if (rdc->buf_len - rdc->off <= (size_t) res) continue; /* buffer too small?? */ rdc->off += (size_t) res; } (void) closedir (dir); return MHD_YES; } /** * Re-scan our local directory and re-build the index. */ static void update_directory (void) { static size_t initial_allocation = 32 * 1024; /* initial size for response buffer */ struct MHD_Response *response; struct ResponseDataContext rdc; unsigned int language_idx; unsigned int category_idx; const struct Language *language; const char *category; char dir_name[128]; struct stat sbuf; int res; size_t len; rdc.buf_len = initial_allocation; if (NULL == (rdc.buf = malloc (rdc.buf_len))) { update_cached_response (NULL); return; } len = strlen (INDEX_PAGE_HEADER); if (rdc.buf_len <= len) { /* buffer too small */ free (rdc.buf); update_cached_response (NULL); return; } memcpy (rdc.buf, INDEX_PAGE_HEADER, len); rdc.off = len; for (language_idx = 0; NULL != languages[language_idx].dirname; language_idx++) { language = &languages[language_idx]; if (0 != stat (language->dirname, &sbuf)) continue; /* empty */ /* we ensured always +1k room, filenames are ~256 bytes, so there is always still enough space for the header without need for an additional reallocation check. */ res = snprintf (&rdc.buf[rdc.off], rdc.buf_len - rdc.off, "

    %s

    \n", language->longname); if (0 >= res) continue; /* snprintf() error */ if (rdc.buf_len - rdc.off <= (size_t) res) continue; /* buffer too small?? */ rdc.off += (size_t) res; for (category_idx = 0; NULL != categories[category_idx]; category_idx++) { category = categories[category_idx]; res = snprintf (dir_name, sizeof (dir_name), "%s/%s", language->dirname, category); if ((0 >= res) || (sizeof (dir_name) <= (size_t) res)) continue; /* cannot print dir name */ if (0 != stat (dir_name, &sbuf)) continue; /* empty */ /* we ensured always +1k room, filenames are ~256 bytes, so there is always still enough space for the header without need for an additional reallocation check. */ res = snprintf (&rdc.buf[rdc.off], rdc.buf_len - rdc.off, "

    %s

    \n", category); if (0 >= res) continue; /* snprintf() error */ if (rdc.buf_len - rdc.off <= (size_t) res) continue; /* buffer too small?? */ rdc.off += (size_t) res; if (MHD_NO == list_directory (&rdc, dir_name)) { free (rdc.buf); update_cached_response (NULL); return; } } } /* we ensured always +1k room, filenames are ~256 bytes, so there is always still enough space for the footer without need for a final reallocation check. */ len = strlen (INDEX_PAGE_FOOTER); if (rdc.buf_len - rdc.off <= len) { /* buffer too small */ free (rdc.buf); update_cached_response (NULL); return; } memcpy (rdc.buf, INDEX_PAGE_FOOTER, len); rdc.off += len; initial_allocation = rdc.buf_len; /* remember for next time */ response = MHD_create_response_from_buffer_with_free_callback (rdc.off, rdc.buf, &free); mark_as_html (response); #ifdef FORCE_CLOSE (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "close"); #endif update_cached_response (response); } /** * Context we keep for an upload. */ struct UploadContext { /** * Handle where we write the uploaded file to. */ int fd; /** * Name of the file on disk (used to remove on errors). */ char *filename; /** * Language for the upload. */ char *language; /** * Category for the upload. */ char *category; /** * Post processor we're using to process the upload. */ struct MHD_PostProcessor *pp; /** * Handle to connection that we're processing the upload for. */ struct MHD_Connection *connection; /** * Response to generate, NULL to use directory. */ struct MHD_Response *response; }; /** * Append the 'size' bytes from 'data' to '*ret', adding * 0-termination. If '*ret' is NULL, allocate an empty string first. * * @param ret string to update, NULL or 0-terminated * @param data data to append * @param size number of bytes in 'data' * @return #MHD_NO on allocation failure, #MHD_YES on success */ static enum MHD_Result do_append (char **ret, const char *data, size_t size) { char *buf; size_t old_len; if (NULL == *ret) old_len = 0; else old_len = strlen (*ret); if (NULL == (buf = malloc (old_len + size + 1))) return MHD_NO; if (NULL != *ret) { memcpy (buf, *ret, old_len); free (*ret); } memcpy (&buf[old_len], data, size); buf[old_len + size] = '\0'; *ret = buf; return MHD_YES; } /** * Iterator over key-value pairs where the value * maybe made available in increments and/or may * not be zero-terminated. Used for processing * POST data. * * @param cls user-specified closure * @param kind type of the value, always MHD_POSTDATA_KIND when called from MHD * @param key 0-terminated key for the value * @param filename name of the uploaded file, NULL if not known * @param content_type mime-type of the data, NULL if not known * @param transfer_encoding encoding of the data, NULL if not known * @param data pointer to size bytes of data at the * specified offset * @param off offset of data in the overall value * @param size number of bytes in data available * @return #MHD_YES to continue iterating, * #MHD_NO to abort the iteration */ static enum MHD_Result process_upload_data (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { struct UploadContext *uc = cls; size_t i; int res; (void) kind; /* Unused. Silent compiler warning. */ (void) content_type; /* Unused. Silent compiler warning. */ (void) transfer_encoding; /* Unused. Silent compiler warning. */ (void) off; /* Unused. Silent compiler warning. */ if (0 == strcmp (key, "category")) return do_append (&uc->category, data, size); if (0 == strcmp (key, "language")) return do_append (&uc->language, data, size); if (0 != strcmp (key, "upload")) { fprintf (stderr, "Ignoring unexpected form value `%s'\n", key); return MHD_YES; /* ignore */ } if (NULL == filename) { fprintf (stderr, "No filename, aborting upload.\n"); return MHD_NO; /* no filename, error */ } if ( (NULL == uc->category) || (NULL == uc->language) ) { fprintf (stderr, "Missing form data for upload `%s'\n", filename); uc->response = request_refused_response; return MHD_NO; } if (-1 == uc->fd) { char fn[PATH_MAX]; if ( (NULL != strstr (filename, "..")) || (NULL != strchr (filename, '/')) || (NULL != strchr (filename, '\\')) ) { uc->response = request_refused_response; return MHD_NO; } /* create directories -- if they don't exist already */ #ifdef WINDOWS (void) mkdir (uc->language); #else (void) mkdir (uc->language, S_IRWXU); #endif snprintf (fn, sizeof (fn), "%s/%s", uc->language, uc->category); #ifdef WINDOWS (void) mkdir (fn); #else (void) mkdir (fn, S_IRWXU); #endif /* open file */ res = snprintf (fn, sizeof (fn), "%s/%s/%s", uc->language, uc->category, filename); if ((0 >= res) || (sizeof (fn) <= (size_t) res)) { uc->response = request_refused_response; return MHD_NO; } for (i = 0; i < (size_t) res; i++) if (! isprint ((unsigned char) fn[i])) fn[i] = '_'; uc->fd = open (fn, O_CREAT | O_EXCL #ifdef O_LARGEFILE | O_LARGEFILE #endif | O_WRONLY, S_IRUSR | S_IWUSR); if (-1 == uc->fd) { fprintf (stderr, "Error opening file `%s' for upload: %s\n", fn, strerror (errno)); uc->response = request_refused_response; return MHD_NO; } uc->filename = strdup (fn); } if ( (0 != size) && #if ! defined(_WIN32) || defined(__CYGWIN__) (size != (size_t) write (uc->fd, data, size)) #else /* Native W32 */ (size != (size_t) write (uc->fd, data, (unsigned int) size)) #endif /* Native W32 */ ) { /* write failed; likely: disk full */ fprintf (stderr, "Error writing to file `%s': %s\n", uc->filename, strerror (errno)); uc->response = internal_error_response; (void) close (uc->fd); uc->fd = -1; if (NULL != uc->filename) { unlink (uc->filename); free (uc->filename); uc->filename = NULL; } return MHD_NO; } return MHD_YES; } /** * Function called whenever a request was completed. * Used to clean up 'struct UploadContext' objects. * * @param cls client-defined closure, NULL * @param connection connection handle * @param req_cls value as set by the last call to * the MHD_AccessHandlerCallback, points to NULL if this was * not an upload * @param toe reason for request termination */ static void response_completed_callback (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { struct UploadContext *uc = *req_cls; (void) cls; /* Unused. Silent compiler warning. */ (void) connection; /* Unused. Silent compiler warning. */ (void) toe; /* Unused. Silent compiler warning. */ if (NULL == uc) return; /* this request wasn't an upload request */ if (NULL != uc->pp) { MHD_destroy_post_processor (uc->pp); uc->pp = NULL; } if (-1 != uc->fd) { (void) close (uc->fd); if (NULL != uc->filename) { fprintf (stderr, "Upload of file `%s' failed (incomplete or aborted), removing file.\n", uc->filename); (void) unlink (uc->filename); } } if (NULL != uc->filename) free (uc->filename); free (uc); } /** * Return the current directory listing. * * @param connection connection to return the directory for * @return #MHD_YES on success, #MHD_NO on error */ static enum MHD_Result return_directory_response (struct MHD_Connection *connection) { enum MHD_Result ret; (void) pthread_mutex_lock (&mutex); if (NULL == cached_directory_response) ret = MHD_queue_response (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, internal_error_response); else ret = MHD_queue_response (connection, MHD_HTTP_OK, cached_directory_response); (void) pthread_mutex_unlock (&mutex); return ret; } /** * Main callback from MHD, used to generate the page. * * @param cls NULL * @param connection connection handle * @param url requested URL * @param method GET, PUT, POST, etc. * @param version HTTP version * @param upload_data data from upload (PUT/POST) * @param upload_data_size number of bytes in @a upload_data * @param req_cls our context * @return #MHD_YES on success, #MHD_NO to drop connection */ static enum MHD_Result generate_page (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; int fd; struct stat buf; (void) cls; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ if (0 != strcmp (url, "/")) { /* should be file download */ #ifdef MHD_HAVE_LIBMAGIC char file_data[MAGIC_HEADER_SIZE]; ssize_t got; #endif /* MHD_HAVE_LIBMAGIC */ const char *mime; if ( (0 != strcmp (method, MHD_HTTP_METHOD_GET)) && (0 != strcmp (method, MHD_HTTP_METHOD_HEAD)) ) return MHD_NO; /* unexpected method (we're not polite...) */ fd = -1; if ( (NULL == strstr (&url[1], "..")) && ('/' != url[1]) ) { fd = open (&url[1], O_RDONLY); if ( (-1 != fd) && ( (0 != fstat (fd, &buf)) || (! S_ISREG (buf.st_mode)) ) ) { (void) close (fd); fd = -1; } } if (-1 == fd) return MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, file_not_found_response); #ifdef MHD_HAVE_LIBMAGIC /* read beginning of the file to determine mime type */ got = read (fd, file_data, sizeof (file_data)); (void) lseek (fd, 0, SEEK_SET); if (0 < got) mime = magic_buffer (magic, file_data, (size_t) got); else #endif /* MHD_HAVE_LIBMAGIC */ mime = NULL; { /* Set mime-type by file-extension in some cases */ const char *ldot = strrchr (&url[1], '.'); if (NULL != ldot) { if (0 == strcasecmp (ldot, ".html")) mime = "text/html"; if (0 == strcasecmp (ldot, ".css")) mime = "text/css"; if (0 == strcasecmp (ldot, ".css3")) mime = "text/css"; if (0 == strcasecmp (ldot, ".js")) mime = "application/javascript"; } } if (NULL == (response = MHD_create_response_from_fd ((size_t) buf.st_size, fd))) { /* internal error (i.e. out of memory) */ (void) close (fd); return MHD_NO; } /* add mime type if we had one */ if (NULL != mime) (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, mime); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } if (0 == strcmp (method, MHD_HTTP_METHOD_POST)) { /* upload! */ struct UploadContext *uc = *req_cls; if (NULL == uc) { if (NULL == (uc = malloc (sizeof (struct UploadContext)))) return MHD_NO; /* out of memory, close connection */ memset (uc, 0, sizeof (struct UploadContext)); uc->fd = -1; uc->connection = connection; uc->pp = MHD_create_post_processor (connection, 64 * 1024 /* buffer size */, &process_upload_data, uc); if (NULL == uc->pp) { /* out of memory, close connection */ free (uc); return MHD_NO; } *req_cls = uc; return MHD_YES; } if (0 != *upload_data_size) { if (NULL == uc->response) (void) MHD_post_process (uc->pp, upload_data, *upload_data_size); *upload_data_size = 0; return MHD_YES; } /* end of upload, finish it! */ MHD_destroy_post_processor (uc->pp); uc->pp = NULL; if (-1 != uc->fd) { close (uc->fd); uc->fd = -1; } if (NULL != uc->response) { return MHD_queue_response (connection, MHD_HTTP_FORBIDDEN, uc->response); } else { update_directory (); return return_directory_response (connection); } } if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) || (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) ) { return return_directory_response (connection); } /* unexpected request, refuse */ return MHD_queue_response (connection, MHD_HTTP_FORBIDDEN, request_refused_response); } #ifndef MINGW /** * Function called if we get a SIGPIPE. Does nothing. * * @param sig will be SIGPIPE (ignored) */ static void catcher (int sig) { (void) sig; /* Unused. Silent compiler warning. */ /* do nothing */ } /** * setup handlers to ignore SIGPIPE. */ static void ignore_sigpipe (void) { struct sigaction oldsig; struct sigaction sig; sig.sa_handler = &catcher; sigemptyset (&sig.sa_mask); #ifdef SA_INTERRUPT sig.sa_flags = SA_INTERRUPT; /* SunOS */ #else sig.sa_flags = SA_RESTART; #endif if (0 != sigaction (SIGPIPE, &sig, &oldsig)) fprintf (stderr, "Failed to install SIGPIPE handler: %s\n", strerror (errno)); } #endif /** * Entry point to demo. Note: this HTTP server will make all * files in the current directory and its subdirectories available * to anyone. Press ENTER to stop the server once it has started. * * @param argc number of arguments in argv * @param argv first and only argument should be the port number * @return 0 on success */ int main (int argc, char *const *argv) { struct MHD_Daemon *d; unsigned int port; if ( (argc != 2) || (1 != sscanf (argv[1], "%u", &port)) || (UINT16_MAX < port) ) { fprintf (stderr, "%s PORT\n", argv[0]); return 1; } #ifndef MINGW ignore_sigpipe (); #endif #ifdef MHD_HAVE_LIBMAGIC magic = magic_open (MAGIC_MIME_TYPE); (void) magic_load (magic, NULL); #endif /* MHD_HAVE_LIBMAGIC */ (void) pthread_mutex_init (&mutex, NULL); file_not_found_response = MHD_create_response_from_buffer_static (strlen (FILE_NOT_FOUND_PAGE), (const void *) FILE_NOT_FOUND_PAGE); mark_as_html (file_not_found_response); request_refused_response = MHD_create_response_from_buffer_static (strlen (REQUEST_REFUSED_PAGE), (const void *) REQUEST_REFUSED_PAGE); mark_as_html (request_refused_response); internal_error_response = MHD_create_response_from_buffer_static (strlen (INTERNAL_ERROR_PAGE), (const void *) INTERNAL_ERROR_PAGE); mark_as_html (internal_error_response); update_directory (); d = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &generate_page, NULL, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (256 * 1024), #ifdef PRODUCTION MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) (64), #endif MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) (120 /* seconds */) , MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) NUMBER_OF_THREADS, MHD_OPTION_NOTIFY_COMPLETED, &response_completed_callback, NULL, MHD_OPTION_END); if (NULL == d) return 1; fprintf (stderr, "HTTP server running. Press ENTER to stop the server.\n"); (void) getc (stdin); MHD_stop_daemon (d); MHD_destroy_response (file_not_found_response); MHD_destroy_response (request_refused_response); MHD_destroy_response (internal_error_response); update_cached_response (NULL); (void) pthread_mutex_destroy (&mutex); #ifdef MHD_HAVE_LIBMAGIC magic_close (magic); #endif /* MHD_HAVE_LIBMAGIC */ return 0; } /* end of demo.c */ libmicrohttpd-1.0.1/src/examples/fileserver_example_dirs.c0000644000175000017500000001474014504515253017523 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file fileserver_example_dirs.c * @brief example for how to use libmicrohttpd to serve files (with directory support) * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #include #ifdef HAVE_UNISTD_H #include #endif #include static ssize_t file_reader (void *cls, uint64_t pos, char *buf, size_t max) { FILE *file = (FILE *) cls; size_t bytes_read; /* 'fseek' may not support files larger 2GiB, depending on platform. * For production code, make sure that 'pos' has valid values, supported by * 'fseek', or use 'fseeko' or similar function. */ if (0 != fseek (file, (long) pos, SEEK_SET)) return MHD_CONTENT_READER_END_WITH_ERROR; bytes_read = fread (buf, 1, max, file); if (0 == bytes_read) return (0 != ferror (file)) ? MHD_CONTENT_READER_END_WITH_ERROR : MHD_CONTENT_READER_END_OF_STREAM; return (ssize_t) bytes_read; } static void file_free_callback (void *cls) { FILE *file = cls; fclose (file); } static void dir_free_callback (void *cls) { DIR *dir = cls; if (dir != NULL) closedir (dir); } static ssize_t dir_reader (void *cls, uint64_t pos, char *buf, size_t max) { DIR *dir = cls; struct dirent *e; int res; if (max < 512) return 0; (void) pos; /* 'pos' is ignored as function return next one single entry per call. */ do { e = readdir (dir); if (e == NULL) return MHD_CONTENT_READER_END_OF_STREAM; } while (e->d_name[0] == '.'); res = snprintf (buf, max, "%s
    ", e->d_name, e->d_name); if (0 >= res) return MHD_CONTENT_READER_END_WITH_ERROR; if (max < (size_t) res) return MHD_CONTENT_READER_END_WITH_ERROR; return (ssize_t) res; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; FILE *file; int fd; DIR *dir; struct stat buf; char emsg[1024]; (void) cls; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ file = fopen (&url[1], "rb"); if (NULL != file) { fd = fileno (file); if (-1 == fd) { (void) fclose (file); return MHD_NO; /* internal error */ } if ( (0 != fstat (fd, &buf)) || (! S_ISREG (buf.st_mode)) ) { /* not a regular file, refuse to serve */ fclose (file); file = NULL; } } if (NULL == file) { dir = opendir ("."); if (NULL == dir) { /* most likely cause: more concurrent requests than available file descriptors / 2 */ snprintf (emsg, sizeof (emsg), "Failed to open directory `.': %s\n", strerror (errno)); response = MHD_create_response_from_buffer (strlen (emsg), emsg, MHD_RESPMEM_MUST_COPY); if (NULL == response) return MHD_NO; ret = MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, response); MHD_destroy_response (response); } else { response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 32 * 1024, &dir_reader, dir, &dir_free_callback); if (NULL == response) { closedir (dir); return MHD_NO; } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); } } else { response = MHD_create_response_from_callback ((size_t) buf.st_size, 32 * 1024, /* 32k page size */ &file_reader, file, &file_free_callback); if (NULL == response) { fclose (file); return MHD_NO; } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); } return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (NULL == d) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/http_compression.c0000644000175000017500000001222114441373361016213 /* This file is part of libmicrohttpd Copyright (C) 2019 Christian Grothoff (and other contributing authors) Copyright (C) 2019-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file http_compression.c * @brief minimal example for how to compress HTTP response * @author Silvio Clecio (silvioprog) * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #include #define PAGE \ "HTTP compressionHello, " \ "hello, hello. This is a 'hello world' message for the world, " \ "repeat, for the world." static enum MHD_Result can_compress (struct MHD_Connection *con) { const char *ae; const char *de; ae = MHD_lookup_connection_value (con, MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT_ENCODING); if (NULL == ae) return MHD_NO; if (0 == strcmp (ae, "*")) return MHD_YES; de = strstr (ae, "deflate"); if (NULL == de) return MHD_NO; if (((de == ae) || (de[-1] == ',') || (de[-1] == ' ')) && ((de[strlen ("deflate")] == '\0') || (de[strlen ("deflate")] == ',') || (de[strlen ("deflate")] == ';'))) return MHD_YES; return MHD_NO; } static enum MHD_Result body_compress (void **buf, size_t *buf_size) { Bytef *cbuf; uLongf cbuf_size; int ret; cbuf_size = compressBound ((uLong) * buf_size); cbuf = malloc (cbuf_size); if (NULL == cbuf) return MHD_NO; ret = compress (cbuf, &cbuf_size, (const Bytef *) *buf, (uLong) * buf_size); if ((Z_OK != ret) || (cbuf_size >= *buf_size)) { /* compression failed */ free (cbuf); return MHD_NO; } free (*buf); *buf = (void *) cbuf; *buf_size = (size_t) cbuf_size; return MHD_YES; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; enum MHD_Result comp; size_t body_len; char *body_str; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (! *req_cls) { *req_cls = (void *) 1; return MHD_YES; } *req_cls = NULL; body_str = strdup (PAGE); if (NULL == body_str) { return MHD_NO; } body_len = strlen (body_str); /* try to compress the body */ comp = MHD_NO; if (MHD_YES == can_compress (connection)) comp = body_compress ((void **) &body_str, &body_len); response = MHD_create_response_from_buffer_with_free_callback (body_len, body_str, &free); if (NULL == response) { free (body_str); return MHD_NO; } if (MHD_YES == comp) { /* Need to indicate to client that body is compressed */ if (MHD_NO == MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_ENCODING, "deflate")) { MHD_destroy_response (response); return MHD_NO; } } ret = MHD_queue_response (connection, 200, response); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; unsigned int port; if ( (argc != 2) || (1 != sscanf (argv[1], "%u", &port)) || (65535 < port) ) { printf ("%s PORT\n", argv[0]); return 1; } d = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (NULL == d) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/digest_auth_example.c0000644000175000017500000001401214555767064016643 /* This file is part of libmicrohttpd Copyright (C) 2010 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2024 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file digest_auth_example.c * @brief minimal example for how to use digest auth with libmicrohttpd * @author Amr Ali * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #include #include #include #if defined(_WIN32) && ! defined(__CYGWIN__) # include #endif /* _WIN32 && ! __CYGWIN__ */ #define PAGE \ "libmicrohttpd demo" \ "Access granted" #define DENIED \ "libmicrohttpd demo" \ "Access denied" #define MY_OPAQUE_STR "11733b200778ce33060f31c9af70a870ba96ddd4" static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; /* Only one user has access to the page */ static const char *username = "testuser"; static const char *password = "testpass"; static const char *realm = "test@example.com"; enum MHD_DigestAuthResult res_e; enum MHD_Result ret; static int already_called_marker; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) method; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (&already_called_marker != *req_cls) { /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; } /* No need to call MHD_digest_auth_get_username3() as the only * one user has an access. The username match is checked by * MHD_digest_auth_check3() function. */ res_e = MHD_digest_auth_check3 ( connection, realm, username, password, 0, 0, MHD_DIGEST_AUTH_MULT_QOP_ANY_NON_INT, MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION); if (res_e != MHD_DAUTH_OK) { response = MHD_create_response_from_buffer_static (strlen (DENIED), DENIED); if (NULL == response) return MHD_NO; ret = MHD_queue_auth_required_response3 ( connection, realm, MY_OPAQUE_STR, NULL, response, (res_e == MHD_DAUTH_NONCE_STALE) ? MHD_YES : MHD_NO, MHD_DIGEST_AUTH_MULT_QOP_ANY_NON_INT, MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION, MHD_NO, MHD_YES); MHD_destroy_response (response); return ret; } response = MHD_create_response_from_buffer_static (strlen (PAGE), PAGE); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { char rnd[8]; struct MHD_Daemon *d; unsigned int port; if ( (argc != 2) || (1 != sscanf (argv[1], "%u", &port)) || (65535 < port) ) { fprintf (stderr, "%s PORT\n", argv[0]); return 1; } if (1) { #if ! defined(_WIN32) || defined(__CYGWIN__) int fd; ssize_t len; size_t off; fd = open ("/dev/urandom", O_RDONLY); if (-1 == fd) { fprintf (stderr, "Failed to open `%s': %s\n", "/dev/urandom", strerror (errno)); return 1; } for (off = 0; off < sizeof(rnd); off += (size_t) len) { len = read (fd, rnd, 8); if (0 > len) { fprintf (stderr, "Failed to read `%s': %s\n", "/dev/urandom", strerror (errno)); (void) close (fd); return 1; } } (void) close (fd); #else /* Native W32 */ HCRYPTPROV cc; BOOL b; b = CryptAcquireContext (&cc, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); if (FALSE == b) { fprintf (stderr, "Failed to acquire crypto provider context: %lu\n", (unsigned long) GetLastError ()); return 1; } b = CryptGenRandom (cc, sizeof(rnd), (BYTE *) rnd); if (FALSE == b) { fprintf (stderr, "Failed to generate 8 random bytes: %lu\n", GetLastError ()); } CryptReleaseContext (cc, 0); if (FALSE == b) return 1; #endif /* Native W32 */ } d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof(rnd), rnd, MHD_OPTION_NONCE_NC_SIZE, 300, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_END); if (d == NULL) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } /* end of digest_auth_example.c */ libmicrohttpd-1.0.1/src/examples/http_chunked_compression.c0000644000175000017500000001422614441373361017723 /* This file is part of libmicrohttpd Copyright (C) 2019 Christian Grothoff (and other contributing authors) Copyright (C) 2019-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file http_chunked_compression.c * @brief example for how to compress a chunked HTTP response * @author Silvio Clecio (silvioprog) * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #ifndef ZLIB_CONST /* Correct API with const pointer for input data is required */ #define ZLIB_CONST 1 #endif /* ! ZLIB_CONST */ #include #include #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ #include #include #ifndef SSIZE_MAX #ifdef __SSIZE_MAX__ #define SSIZE_MAX __SSIZE_MAX__ #elif defined(PTRDIFF_MAX) #define SSIZE_MAX PTRDIFF_MAX #elif defined(INTPTR_MAX) #define SSIZE_MAX INTPTR_MAX #else #define SSIZE_MAX ((ssize_t) (((size_t) -1) >> 1)) #endif #endif /* ! SSIZE_MAX */ #define CHUNK 16384 struct Holder { FILE *file; z_stream stream; void *buf; }; static enum MHD_Result compress_buf (z_stream *strm, const void *src, size_t src_size, size_t *offset, void **dest, size_t *dest_size, void *tmp) { unsigned int have; enum MHD_Result ret; int flush; void *tmp_dest; *dest = NULL; *dest_size = 0; do { if (src_size > CHUNK) { strm->avail_in = CHUNK; src_size -= CHUNK; flush = Z_NO_FLUSH; } else { strm->avail_in = (uInt) src_size; flush = Z_SYNC_FLUSH; } *offset += strm->avail_in; strm->next_in = (const Bytef *) src; do { strm->avail_out = CHUNK; strm->next_out = tmp; ret = (Z_OK == deflate (strm, flush)) ? MHD_YES : MHD_NO; have = CHUNK - strm->avail_out; *dest_size += have; tmp_dest = realloc (*dest, *dest_size); if (NULL == tmp_dest) { free (*dest); *dest = NULL; return MHD_NO; } *dest = tmp_dest; memcpy (((uint8_t *) (*dest)) + ((*dest_size) - have), tmp, have); } while (0 == strm->avail_out); } while (flush != Z_SYNC_FLUSH); return ret; } static ssize_t read_cb (void *cls, uint64_t pos, char *mem, size_t size) { struct Holder *holder = cls; void *src; void *buf; ssize_t ret; size_t offset; size_t r_size; if (pos > SSIZE_MAX) return MHD_CONTENT_READER_END_WITH_ERROR; offset = (size_t) pos; src = malloc (size); if (NULL == src) return MHD_CONTENT_READER_END_WITH_ERROR; r_size = fread (src, 1, size, holder->file); if (0 == r_size) { ret = (0 != ferror (holder->file)) ? MHD_CONTENT_READER_END_WITH_ERROR : MHD_CONTENT_READER_END_OF_STREAM; goto done; } if (MHD_YES != compress_buf (&holder->stream, src, r_size, &offset, &buf, &size, holder->buf)) ret = MHD_CONTENT_READER_END_WITH_ERROR; else { memcpy (mem, buf, size); ret = (ssize_t) size; } free (buf); /* Buf may be set even on error return. */ done: free (src); return ret; } static void free_cb (void *cls) { struct Holder *holder = cls; fclose (holder->file); deflateEnd (&holder->stream); free (holder->buf); free (holder); } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *con, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_size, void **req_cls) { struct Holder *holder; struct MHD_Response *res; enum MHD_Result ret; (void) cls; (void) url; (void) method; (void) version; (void) upload_data; (void) upload_size; if (NULL == *req_cls) { *req_cls = (void *) 1; return MHD_YES; } *req_cls = NULL; holder = calloc (1, sizeof (struct Holder)); if (! holder) return MHD_NO; holder->file = fopen (__FILE__, "rb"); if (NULL == holder->file) goto file_error; if (Z_OK != deflateInit (&holder->stream, Z_BEST_COMPRESSION)) goto stream_error; holder->buf = malloc (CHUNK); if (NULL == holder->buf) goto buf_error; res = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 1024, &read_cb, holder, &free_cb); if (NULL == res) goto error; ret = MHD_add_response_header (res, MHD_HTTP_HEADER_CONTENT_ENCODING, "deflate"); if (MHD_YES != ret) goto res_error; ret = MHD_add_response_header (res, MHD_HTTP_HEADER_CONTENT_TYPE, "text/x-c"); if (MHD_YES != ret) goto res_error; ret = MHD_queue_response (con, MHD_HTTP_OK, res); res_error: MHD_destroy_response (res); return ret; error: free (holder->buf); buf_error: deflateEnd (&holder->stream); stream_error: fclose (holder->file); file_error: free (holder); return MHD_NO; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; unsigned int port; if ((argc != 2) || (1 != sscanf (argv[1], "%u", &port)) || (UINT16_MAX < port)) { fprintf (stderr, "%s PORT\n", argv[0]); return 1; } d = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (NULL == d) return 1; if (0 == port) MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT, &port); fprintf (stdout, "HTTP server running at http://localhost:%u\n\nPress ENTER to stop the server ...\n", port); (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/timeout.c0000644000175000017500000000636414504515253014312 /* This file is part of libmicrohttpd Copyright (C) 2016-2017 Christian Grothoff, Silvio Clecio (silvioprog), Evgeny Grin (Karlson2k) Copyright (C) 2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file timeout.c * @brief example for how to use libmicrohttpd request timeout * @author Christian Grothoff, Silvio Clecio (silvioprog), Karlson2k (Evgeny Grin) */ #include #include #include #define PORT 8080 static enum MHD_Result answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { const char *page = "Hello timeout!"; struct MHD_Response *response; enum MHD_Result ret; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) method; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ (void) req_cls; /* Unused. Silent compiler warning. */ response = MHD_create_response_from_buffer_static (strlen (page), (const void *) page); if (MHD_YES != MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html")) { fprintf (stderr, "Failed to set content type header!\n"); } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } int main (void) { struct MHD_Daemon *daemon; daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, PORT, NULL, NULL, &answer_to_connection, NULL, /* 3 seconds */ MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 3, MHD_OPTION_END); if (NULL == daemon) return 1; (void) getchar (); MHD_stop_daemon (daemon); return 0; } libmicrohttpd-1.0.1/src/examples/authorization_example.c0000644000175000017500000001076414520452672017241 /* This file is part of libmicrohttpd Copyright (C) 2008 Christian Grothoff (and other contributing authors) Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file authorization_example.c * @brief example for how to use libmicrohttpd with HTTP authentication * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif /* !WIN32_LEAN_AND_MEAN */ #include #endif #define PAGE \ "libmicrohttpd demolibmicrohttpd demo" #define DENIED \ "Access deniedAccess denied" static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; struct MHD_BasicAuthInfo *auth_info; int fail; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ /* require: "Aladdin" with password "open sesame" */ auth_info = MHD_basic_auth_get_username_password3 (connection); fail = ( (NULL == auth_info) || (strlen ("Aladdin") != auth_info->username_len) || (0 != memcmp (auth_info->username, "Aladdin", auth_info->username_len)) || /* The next check against NULL is optional, * if 'password' is NULL then 'password_len' is always zero. */ (NULL == auth_info->password) || (strlen ("open sesame") != auth_info->password_len) || (0 != memcmp (auth_info->password, "open sesame", auth_info->password_len)) ); if (fail) { response = MHD_create_response_from_buffer_static (strlen (DENIED), (const void *) DENIED); ret = MHD_queue_basic_auth_required_response3 (connection, "TestRealm", MHD_NO, response); } else { response = MHD_create_response_from_buffer_static (strlen (PAGE), (const void *) PAGE); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); } if (NULL != auth_info) MHD_free (auth_info); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; unsigned int port; if ( (argc != 2) || (1 != sscanf (argv[1], "%u", &port)) || (65535 < port) ) { fprintf (stderr, "%s PORT\n", argv[0]); return 1; } d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; fprintf (stderr, "HTTP server running. Press ENTER to stop the server.\n"); (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/Makefile.am0000644000175000017500000001442514555767064014530 # This Makefile.am is in the public domain SUBDIRS = . AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ $(CPPFLAGS_ac) \ -DDATA_DIR=\"$(top_srcdir)/src/datadir/\" AM_CFLAGS = $(CFLAGS_ac) @LIBGCRYPT_CFLAGS@ AM_LDFLAGS = $(LDFLAGS_ac) MHD_CPU_COUNT_DEF = -DMHD_CPU_COUNT=$(CPU_COUNT) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) if USE_COVERAGE AM_CFLAGS += --coverage endif $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la # example programs noinst_PROGRAMS = \ benchmark \ benchmark_https \ chunked_example \ minimal_example \ minimal_example_empty \ dual_stack_example \ minimal_example_comet \ querystring_example \ timeout \ fileserver_example \ fileserver_example_dirs \ fileserver_example_external_select \ refuse_post_example if HAVE_EXPERIMENTAL noinst_PROGRAMS += \ websocket_chatserver_example endif if MHD_HAVE_EPOLL noinst_PROGRAMS += \ suspend_resume_epoll endif EXTRA_DIST = msgs_i18n.c noinst_EXTRA_DIST = msgs_i18n.c if ENABLE_HTTPS noinst_PROGRAMS += \ https_fileserver_example \ minimal_example_empty_tls endif if HAVE_POSTPROCESSOR noinst_PROGRAMS += \ post_example if HAVE_POSIX_THREADS noinst_PROGRAMS += demo if ENABLE_HTTPS noinst_PROGRAMS += demo_https endif endif endif if ENABLE_DAUTH noinst_PROGRAMS += \ digest_auth_example \ digest_auth_example_adv endif if ENABLE_BAUTH noinst_PROGRAMS += \ authorization_example endif if HAVE_POSIX_THREADS if ENABLE_UPGRADE noinst_PROGRAMS += \ upgrade_example \ websocket_threaded_example endif endif if HAVE_ZLIB noinst_PROGRAMS += \ http_compression \ http_chunked_compression endif if HAVE_W32 AM_CFLAGS += -DWINDOWS endif minimal_example_SOURCES = \ minimal_example.c minimal_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la minimal_example_empty_SOURCES = \ minimal_example_empty.c minimal_example_empty_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la minimal_example_empty_tls_SOURCES = \ minimal_example_empty_tls.c minimal_example_empty_tls_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la upgrade_example_SOURCES = \ upgrade_example.c upgrade_example_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) upgrade_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(PTHREAD_LIBS) websocket_threaded_example_SOURCES = \ websocket_threaded_example.c websocket_threaded_example_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) websocket_threaded_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(PTHREAD_LIBS) timeout_SOURCES = \ timeout.c timeout_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la chunked_example_SOURCES = \ chunked_example.c chunked_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la websocket_chatserver_example_SOURCES = \ websocket_chatserver_example.c websocket_chatserver_example_LDADD = \ $(top_builddir)/src/microhttpd_ws/libmicrohttpd_ws.la \ $(top_builddir)/src/microhttpd/libmicrohttpd.la demo_SOURCES = \ demo.c demo_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) demo_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_CPU_COUNT_DEF) demo_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(PTHREAD_LIBS) if MHD_HAVE_LIBMAGIC demo_LDADD += -lmagic endif demo_https_SOURCES = \ demo_https.c demo_https_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) demo_https_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_CPU_COUNT_DEF) demo_https_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(PTHREAD_LIBS) if MHD_HAVE_LIBMAGIC demo_https_LDADD += -lmagic endif benchmark_SOURCES = \ benchmark.c benchmark_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_CPU_COUNT_DEF) benchmark_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la suspend_resume_epoll_SOURCES = \ suspend_resume_epoll.c suspend_resume_epoll_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_CPU_COUNT_DEF) suspend_resume_epoll_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la benchmark_https_SOURCES = \ benchmark_https.c benchmark_https_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_CPU_COUNT_DEF) benchmark_https_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la dual_stack_example_SOURCES = \ dual_stack_example.c dual_stack_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la post_example_SOURCES = \ post_example.c post_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la minimal_example_comet_SOURCES = \ minimal_example_comet.c minimal_example_comet_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la authorization_example_SOURCES = \ authorization_example.c authorization_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la digest_auth_example_SOURCES = \ digest_auth_example.c digest_auth_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la digest_auth_example_adv_SOURCES = \ digest_auth_example_adv.c digest_auth_example_adv_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la refuse_post_example_SOURCES = \ refuse_post_example.c refuse_post_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la querystring_example_SOURCES = \ querystring_example.c querystring_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la fileserver_example_SOURCES = \ fileserver_example.c fileserver_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la fileserver_example_dirs_SOURCES = \ fileserver_example_dirs.c fileserver_example_dirs_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la fileserver_example_external_select_SOURCES = \ fileserver_example_external_select.c fileserver_example_external_select_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la https_fileserver_example_SOURCES = \ https_fileserver_example.c https_fileserver_example_CPPFLAGS = \ $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS) https_fileserver_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la http_compression_SOURCES = \ http_compression.c http_chunked_compression_SOURCES = \ http_chunked_compression.c http_compression_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la http_chunked_compression_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la if HAVE_ZLIB http_compression_LDADD += -lz http_chunked_compression_LDADD += -lz endif libmicrohttpd-1.0.1/src/examples/suspend_resume_epoll.c0000644000175000017500000001310514504515253017047 /* This file is part of libmicrohttpd Copyright (C) 2018 Christian Grothoff (and other contributing authors) Copyright (C) 2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file suspend_resume_epoll.c * @brief example for how to use libmicrohttpd with epoll() and * resume a suspended connection * @author Robert D Kocisko * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #include #include #include #include #define TIMEOUT_INFINITE -1 struct Request { struct MHD_Connection *connection; int timerfd; }; static int epfd; static struct epoll_event evt; static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; struct Request *req; struct itimerspec ts; (void) cls; (void) method; (void) version; /* Unused. Silence compiler warning. */ (void) upload_data; /* Unused. Silence compiler warning. */ (void) upload_data_size; /* Unused. Silence compiler warning. */ req = *req_cls; if (NULL == req) { req = malloc (sizeof(struct Request)); if (NULL == req) return MHD_NO; req->connection = connection; req->timerfd = -1; *req_cls = req; return MHD_YES; } if (-1 != req->timerfd) { /* send response (echo request url) */ response = MHD_create_response_from_buffer_copy (strlen (url), (const void *) url); if (NULL == response) return MHD_NO; ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } /* create timer and suspend connection */ req->timerfd = timerfd_create (CLOCK_MONOTONIC, TFD_NONBLOCK); if (-1 == req->timerfd) { printf ("timerfd_create: %s", strerror (errno)); return MHD_NO; } evt.events = EPOLLIN; evt.data.ptr = req; if (-1 == epoll_ctl (epfd, EPOLL_CTL_ADD, req->timerfd, &evt)) { printf ("epoll_ctl: %s", strerror (errno)); return MHD_NO; } ts.it_value.tv_sec = 1; ts.it_value.tv_nsec = 0; ts.it_interval.tv_sec = 0; ts.it_interval.tv_nsec = 0; if (-1 == timerfd_settime (req->timerfd, 0, &ts, NULL)) { printf ("timerfd_settime: %s", strerror (errno)); return MHD_NO; } MHD_suspend_connection (connection); return MHD_YES; } static void connection_done (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { struct Request *req = *req_cls; (void) cls; (void) connection; (void) toe; if (-1 != req->timerfd) if (0 != close (req->timerfd)) abort (); free (req); } int main (int argc, char *const *argv) { struct MHD_Daemon *d; const union MHD_DaemonInfo *info; int current_event_count; struct epoll_event events_list[1]; struct Request *req; uint64_t timer_expirations; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } d = MHD_start_daemon (MHD_USE_EPOLL | MHD_ALLOW_SUSPEND_RESUME, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_NOTIFY_COMPLETED, &connection_done, NULL, MHD_OPTION_END); if (d == NULL) return 1; info = MHD_get_daemon_info (d, MHD_DAEMON_INFO_EPOLL_FD); if (info == NULL) return 1; epfd = epoll_create1 (EPOLL_CLOEXEC); if (-1 == epfd) return 1; evt.events = EPOLLIN; evt.data.ptr = NULL; if (-1 == epoll_ctl (epfd, EPOLL_CTL_ADD, info->epoll_fd, &evt)) return 1; while (1) { current_event_count = epoll_wait (epfd, events_list, 1, MHD_get_timeout_i (d)); if (1 == current_event_count) { if (events_list[0].data.ptr) { /* A timer has timed out */ req = events_list[0].data.ptr; /* read from the fd so the system knows we heard the notice */ if (-1 == read (req->timerfd, &timer_expirations, sizeof(timer_expirations))) { return 1; } /* Now resume the connection */ MHD_resume_connection (req->connection); } } else if (0 == current_event_count) { /* no events: continue */ } else { /* error */ return 1; } if (! MHD_run (d)) return 1; } return 0; } libmicrohttpd-1.0.1/src/examples/upgrade_example.c0000644000175000017500000002237614504515253015767 /* This file is part of libmicrohttpd Copyright (C) 2016 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file upgrade_example.c * @brief example for how to use libmicrohttpd upgrade * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) * * Telnet to the HTTP server, use this in the request: * GET / http/1.1 * Connection: Upgrade * * After this, whatever you type will be echo'ed back to you. */ #include "platform.h" #include #include #include #define PAGE \ "libmicrohttpd demolibmicrohttpd demo" /** * Change socket to blocking. * * @param fd the socket to manipulate */ static void make_blocking (MHD_socket fd) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (fd, F_GETFL); if (-1 == flags) abort (); if ((flags & ~O_NONBLOCK) != flags) if (-1 == fcntl (fd, F_SETFL, flags & ~O_NONBLOCK)) abort (); #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 0; if (0 != ioctlsocket (fd, (int) FIONBIO, &flags)) abort (); #endif /* MHD_WINSOCK_SOCKETS */ } static void send_all (MHD_socket sock, const char *buf, size_t len) { ssize_t ret; size_t off; make_blocking (sock); for (off = 0; off < len; off += (size_t) ret) { ret = send (sock, &buf[off], #if ! defined(_WIN32) || defined(__CYGWIN__) len - off, #else /* Native W32 */ (int) (len - off), #endif /* Native W32 */ 0); if (0 > ret) { if (EAGAIN == errno) { ret = 0; continue; } break; } if (0 == ret) break; } } struct MyData { struct MHD_UpgradeResponseHandle *urh; char *extra_in; size_t extra_in_size; MHD_socket sock; }; /** * Main function for the thread that runs the interaction with * the upgraded socket. Writes what it reads. * * @param cls the `struct MyData` */ static void * run_usock (void *cls) { struct MyData *md = cls; struct MHD_UpgradeResponseHandle *urh = md->urh; char buf[128]; ssize_t got; make_blocking (md->sock); /* start by sending extra data MHD may have already read, if any */ if (0 != md->extra_in_size) { send_all (md->sock, md->extra_in, md->extra_in_size); free (md->extra_in); } /* now echo in a loop */ while (1) { got = recv (md->sock, buf, sizeof (buf), 0); if (0 >= got) break; send_all (md->sock, buf, (size_t) got); } free (md); MHD_upgrade_action (urh, MHD_UPGRADE_ACTION_CLOSE); return NULL; } /** * Function called after a protocol "upgrade" response was sent * successfully and the socket should now be controlled by some * protocol other than HTTP. * * Any data already received on the socket will be made available in * @e extra_in. This can happen if the application sent extra data * before MHD send the upgrade response. The application should * treat data from @a extra_in as if it had read it from the socket. * * Note that the application must not close() @a sock directly, * but instead use #MHD_upgrade_action() for special operations * on @a sock. * * Data forwarding to "upgraded" @a sock will be started as soon * as this function return. * * Except when in 'thread-per-connection' mode, implementations * of this function should never block (as it will still be called * from within the main event loop). * * @param cls closure, whatever was given to #MHD_create_response_for_upgrade(). * @param connection original HTTP connection handle, * giving the function a last chance * to inspect the original HTTP request * @param req_cls last value left in `req_cls` of the `MHD_AccessHandlerCallback` * @param extra_in if we happened to have read bytes after the * HTTP header already (because the client sent * more than the HTTP header of the request before * we sent the upgrade response), * these are the extra bytes already read from @a sock * by MHD. The application should treat these as if * it had read them from @a sock. * @param extra_in_size number of bytes in @a extra_in * @param sock socket to use for bi-directional communication * with the client. For HTTPS, this may not be a socket * that is directly connected to the client and thus certain * operations (TCP-specific setsockopt(), getsockopt(), etc.) * may not work as expected (as the socket could be from a * socketpair() or a TCP-loopback). The application is expected * to perform read()/recv() and write()/send() calls on the socket. * The application may also call shutdown(), but must not call * close() directly. * @param urh argument for #MHD_upgrade_action()s on this @a connection. * Applications must eventually use this callback to (indirectly) * perform the close() action on the @a sock. */ static void uh_cb (void *cls, struct MHD_Connection *connection, void *req_cls, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh) { struct MyData *md; pthread_t pt; (void) cls; /* Unused. Silent compiler warning. */ (void) connection; /* Unused. Silent compiler warning. */ (void) req_cls; /* Unused. Silent compiler warning. */ md = malloc (sizeof (struct MyData)); if (NULL == md) abort (); memset (md, 0, sizeof (struct MyData)); if (0 != extra_in_size) { md->extra_in = malloc (extra_in_size); if (NULL == md->extra_in) abort (); memcpy (md->extra_in, extra_in, extra_in_size); } md->extra_in_size = extra_in_size; md->sock = sock; md->urh = urh; if (0 != pthread_create (&pt, NULL, &run_usock, md)) abort (); /* Note that by detaching like this we make it impossible to ensure a clean shutdown, as the we stop the daemon even if a worker thread is still running. Alas, this is a simple example... */ pthread_detach (pt); /* This callback must return as soon as possible. */ /* Data forwarding to "upgraded" socket will be started * after return from this callback. */ } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ response = MHD_create_response_for_upgrade (&uh_cb, NULL); MHD_add_response_header (response, MHD_HTTP_HEADER_UPGRADE, "Echo Server"); ret = MHD_queue_response (connection, MHD_HTTP_SWITCHING_PROTOCOLS, response); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; unsigned int port; if ( (argc != 2) || (1 != sscanf (argv[1], "%u", &port)) || (65535 < port) ) { printf ("%s PORT\n", argv[0]); return 1; } d = MHD_start_daemon (MHD_ALLOW_UPGRADE | MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_END); if (d == NULL) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/msgs_i18n.c0000644000175000017500000000603414441373361014430 /* This file is part of libmicrohttpd Copyright (C) 2017 Christian Grothoff, Silvio Clecio (silvioprog) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file msgs_i18n.c * @brief example for how to use translate libmicrohttpd messages * @author Christian Grothoff * @author Silvio Clecio (silvioprog) */ /* * supposing you are in Brazil: * * # generate the PO file * $ msginit --input=po/libmicrohttpd.pot --locale=pt_BR --output=libmicrohttpd.po * # open the generated .po in any program like Poedit and translate the MHD messages; once done, let's go to the test: * mkdir -p src/examples/locale/pt_BR/LC_MESSAGES * mv libmicrohttpd.mo libmicrohttpd.po src/examples/locale/pt_BR/LC_MESSAGES * cd src/examples/ * gcc -o msgs_i18n msgs_i18n.c -lmicrohttpd * export LANGUAGE=pt_BR * ./msgs_i18n * # it may print: Opção inválida 4196490! (Você terminou a lista com MHD_OPTION_END?) */ #include #include #include #include static int ahc_echo (void *cls, struct MHD_Connection *cnc, const char *url, const char *mt, const char *ver, const char *upd, size_t *upsz, void **req_cls) { return MHD_NO; } static void error_handler (void *cls, const char *fm, va_list ap) { /* Here we do the translation using GNU gettext. As the error message is from libmicrohttpd, we specify "libmicrohttpd" as the translation domain here. */ vprintf (dgettext ("libmicrohttpd", fm), ap); } int main (int argc, char **argv) { setlocale (LC_ALL, ""); /* The example uses PO files in the directory "libmicrohttpd/src/examples/locale". This needs to be adapted to match where the MHD PO files are installed. */ bindtextdomain ("libmicrohttpd", "locale"); MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_FEATURE_MESSAGES | MHD_USE_ERROR_LOG, 8080, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_EXTERNAL_LOGGER, &error_handler, NULL, 99999 /* invalid option, to raise the error "Invalid option ..." which we are going to translate */); return 1; /* This program won't "succeed"... */ } libmicrohttpd-1.0.1/src/examples/fileserver_example.c0000644000175000017500000001042714441373361016502 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file fileserver_example.c * @brief minimal example for how to use libmicrohttpd to serve files * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #ifdef HAVE_FCNTL_H #include #endif /* HAVE_FCNTL_H */ #define PAGE \ "File not foundFile not found" #ifndef S_ISREG #define S_ISREG(x) (S_IFREG == (x & S_IFREG)) #endif /* S_ISREG */ static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; int fd; struct stat buf; (void) cls; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if ( (0 != strcmp (method, MHD_HTTP_METHOD_GET)) && (0 != strcmp (method, MHD_HTTP_METHOD_HEAD)) ) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ /* WARNING: direct usage of url as filename is for example only! * NEVER pass received data directly as parameter to file manipulation * functions. Always check validity of data before using. */ if (NULL != strstr (url, "../")) /* Very simplified check! */ fd = -1; /* Do not allow usage of parent directories. */ else fd = open (url + 1, O_RDONLY); if (-1 != fd) { if ( (0 != fstat (fd, &buf)) || (! S_ISREG (buf.st_mode)) ) { /* not a regular file, refuse to serve */ if (0 != close (fd)) abort (); fd = -1; } } if (-1 == fd) { response = MHD_create_response_from_buffer_static (strlen (PAGE), PAGE); ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); MHD_destroy_response (response); } else { response = MHD_create_response_from_fd64 ((uint64_t) buf.st_size, fd); if (NULL == response) { if (0 != close (fd)) abort (); return MHD_NO; } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); } return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/benchmark.c0000644000175000017500000001313014441373361014545 /* This file is part of libmicrohttpd Copyright (C) 2007, 2013 Christian Grothoff (and other contributing authors) Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file benchmark.c * @brief minimal code to benchmark MHD GET performance * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifndef PRIu64 #define PRIu64 "llu" #endif /* ! PRIu64 */ #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #define PAGE \ "libmicrohttpd demolibmicrohttpd demo" #define SMALL (1024 * 128) /** * Number of threads to run in the thread pool. Should (roughly) match * the number of cores on your system. */ #define NUMBER_OF_THREADS MHD_CPU_COUNT static unsigned int small_deltas[SMALL]; static struct MHD_Response *response; /** * Signature of the callback used by MHD to notify the * application about completed requests. * * @param cls client-defined closure * @param connection connection handle * @param req_cls value as set by the last call to * the MHD_AccessHandlerCallback * @param toe reason for request termination * @see MHD_OPTION_NOTIFY_COMPLETED */ static void completed_callback (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { struct timeval *tv = *req_cls; struct timeval tve; uint64_t delta; (void) cls; /* Unused. Silent compiler warning. */ (void) connection; /* Unused. Silent compiler warning. */ (void) toe; /* Unused. Silent compiler warning. */ if (NULL == tv) return; gettimeofday (&tve, NULL); delta = ((uint64_t) (tve.tv_sec - tv->tv_sec)) * 1000000LL + (uint64_t) tve.tv_usec - (uint64_t) tv->tv_usec; if (delta < SMALL) small_deltas[delta]++; else fprintf (stdout, "D: %" PRIu64 " 1\n", delta); free (tv); } static void * uri_logger_cb (void *cls, const char *uri) { struct timeval *tv = malloc (sizeof (struct timeval)); (void) cls; /* Unused. Silent compiler warning. */ (void) uri; /* Unused. Silent compiler warning. */ if (NULL != tv) gettimeofday (tv, NULL); return tv; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ (void) req_cls; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ return MHD_queue_response (connection, MHD_HTTP_OK, response); } int main (int argc, char *const *argv) { struct MHD_Daemon *d; unsigned int i; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } response = MHD_create_response_from_buffer_static (strlen (PAGE), (const void *) PAGE); #if 0 (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "close"); #endif d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_SUPPRESS_DATE_NO_CLOCK #ifdef EPOLL_SUPPORT | MHD_USE_EPOLL | MHD_USE_TURBO #endif , (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) NUMBER_OF_THREADS, MHD_OPTION_URI_LOG_CALLBACK, &uri_logger_cb, NULL, MHD_OPTION_NOTIFY_COMPLETED, &completed_callback, NULL, MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 1000, MHD_OPTION_END); if (d == NULL) return 1; (void) getc (stdin); MHD_stop_daemon (d); MHD_destroy_response (response); for (i = 0; i < SMALL; i++) if (0 != small_deltas[i]) fprintf (stdout, "D: %u %u\n", i, small_deltas[i]); return 0; } libmicrohttpd-1.0.1/src/examples/Makefile.in0000644000175000017500000021647714566140141014533 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @USE_COVERAGE_TRUE@am__append_1 = --coverage noinst_PROGRAMS = benchmark$(EXEEXT) benchmark_https$(EXEEXT) \ chunked_example$(EXEEXT) minimal_example$(EXEEXT) \ minimal_example_empty$(EXEEXT) dual_stack_example$(EXEEXT) \ minimal_example_comet$(EXEEXT) querystring_example$(EXEEXT) \ timeout$(EXEEXT) fileserver_example$(EXEEXT) \ fileserver_example_dirs$(EXEEXT) \ fileserver_example_external_select$(EXEEXT) \ refuse_post_example$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) \ $(am__EXEEXT_3) $(am__EXEEXT_4) $(am__EXEEXT_5) \ $(am__EXEEXT_6) $(am__EXEEXT_7) $(am__EXEEXT_8) \ $(am__EXEEXT_9) $(am__EXEEXT_10) @HAVE_EXPERIMENTAL_TRUE@am__append_2 = \ @HAVE_EXPERIMENTAL_TRUE@ websocket_chatserver_example @MHD_HAVE_EPOLL_TRUE@am__append_3 = \ @MHD_HAVE_EPOLL_TRUE@ suspend_resume_epoll @ENABLE_HTTPS_TRUE@am__append_4 = \ @ENABLE_HTTPS_TRUE@ https_fileserver_example \ @ENABLE_HTTPS_TRUE@ minimal_example_empty_tls @HAVE_POSTPROCESSOR_TRUE@am__append_5 = \ @HAVE_POSTPROCESSOR_TRUE@ post_example @HAVE_POSIX_THREADS_TRUE@@HAVE_POSTPROCESSOR_TRUE@am__append_6 = demo @ENABLE_HTTPS_TRUE@@HAVE_POSIX_THREADS_TRUE@@HAVE_POSTPROCESSOR_TRUE@am__append_7 = demo_https @ENABLE_DAUTH_TRUE@am__append_8 = \ @ENABLE_DAUTH_TRUE@ digest_auth_example \ @ENABLE_DAUTH_TRUE@ digest_auth_example_adv @ENABLE_BAUTH_TRUE@am__append_9 = \ @ENABLE_BAUTH_TRUE@ authorization_example @ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@am__append_10 = \ @ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@ upgrade_example \ @ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@ websocket_threaded_example @HAVE_ZLIB_TRUE@am__append_11 = \ @HAVE_ZLIB_TRUE@ http_compression \ @HAVE_ZLIB_TRUE@ http_chunked_compression @HAVE_W32_TRUE@am__append_12 = -DWINDOWS @MHD_HAVE_LIBMAGIC_TRUE@am__append_13 = -lmagic @MHD_HAVE_LIBMAGIC_TRUE@am__append_14 = -lmagic @HAVE_ZLIB_TRUE@am__append_15 = -lz @HAVE_ZLIB_TRUE@am__append_16 = -lz subdir = src/examples ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @HAVE_EXPERIMENTAL_TRUE@am__EXEEXT_1 = \ @HAVE_EXPERIMENTAL_TRUE@ websocket_chatserver_example$(EXEEXT) @MHD_HAVE_EPOLL_TRUE@am__EXEEXT_2 = suspend_resume_epoll$(EXEEXT) @ENABLE_HTTPS_TRUE@am__EXEEXT_3 = https_fileserver_example$(EXEEXT) \ @ENABLE_HTTPS_TRUE@ minimal_example_empty_tls$(EXEEXT) @HAVE_POSTPROCESSOR_TRUE@am__EXEEXT_4 = post_example$(EXEEXT) @HAVE_POSIX_THREADS_TRUE@@HAVE_POSTPROCESSOR_TRUE@am__EXEEXT_5 = demo$(EXEEXT) @ENABLE_HTTPS_TRUE@@HAVE_POSIX_THREADS_TRUE@@HAVE_POSTPROCESSOR_TRUE@am__EXEEXT_6 = demo_https$(EXEEXT) @ENABLE_DAUTH_TRUE@am__EXEEXT_7 = digest_auth_example$(EXEEXT) \ @ENABLE_DAUTH_TRUE@ digest_auth_example_adv$(EXEEXT) @ENABLE_BAUTH_TRUE@am__EXEEXT_8 = authorization_example$(EXEEXT) @ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@am__EXEEXT_9 = upgrade_example$(EXEEXT) \ @ENABLE_UPGRADE_TRUE@@HAVE_POSIX_THREADS_TRUE@ websocket_threaded_example$(EXEEXT) @HAVE_ZLIB_TRUE@am__EXEEXT_10 = http_compression$(EXEEXT) \ @HAVE_ZLIB_TRUE@ http_chunked_compression$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) am_authorization_example_OBJECTS = authorization_example.$(OBJEXT) authorization_example_OBJECTS = $(am_authorization_example_OBJECTS) authorization_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_benchmark_OBJECTS = benchmark-benchmark.$(OBJEXT) benchmark_OBJECTS = $(am_benchmark_OBJECTS) benchmark_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_benchmark_https_OBJECTS = \ benchmark_https-benchmark_https.$(OBJEXT) benchmark_https_OBJECTS = $(am_benchmark_https_OBJECTS) benchmark_https_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_chunked_example_OBJECTS = chunked_example.$(OBJEXT) chunked_example_OBJECTS = $(am_chunked_example_OBJECTS) chunked_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_demo_OBJECTS = demo-demo.$(OBJEXT) demo_OBJECTS = $(am_demo_OBJECTS) am__DEPENDENCIES_1 = demo_DEPENDENCIES = $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) demo_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(demo_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ am_demo_https_OBJECTS = demo_https-demo_https.$(OBJEXT) demo_https_OBJECTS = $(am_demo_https_OBJECTS) demo_https_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) demo_https_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(demo_https_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ am_digest_auth_example_OBJECTS = digest_auth_example.$(OBJEXT) digest_auth_example_OBJECTS = $(am_digest_auth_example_OBJECTS) digest_auth_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_digest_auth_example_adv_OBJECTS = \ digest_auth_example_adv.$(OBJEXT) digest_auth_example_adv_OBJECTS = \ $(am_digest_auth_example_adv_OBJECTS) digest_auth_example_adv_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_dual_stack_example_OBJECTS = dual_stack_example.$(OBJEXT) dual_stack_example_OBJECTS = $(am_dual_stack_example_OBJECTS) dual_stack_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_fileserver_example_OBJECTS = fileserver_example.$(OBJEXT) fileserver_example_OBJECTS = $(am_fileserver_example_OBJECTS) fileserver_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_fileserver_example_dirs_OBJECTS = \ fileserver_example_dirs.$(OBJEXT) fileserver_example_dirs_OBJECTS = \ $(am_fileserver_example_dirs_OBJECTS) fileserver_example_dirs_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_fileserver_example_external_select_OBJECTS = \ fileserver_example_external_select.$(OBJEXT) fileserver_example_external_select_OBJECTS = \ $(am_fileserver_example_external_select_OBJECTS) fileserver_example_external_select_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_http_chunked_compression_OBJECTS = \ http_chunked_compression.$(OBJEXT) http_chunked_compression_OBJECTS = \ $(am_http_chunked_compression_OBJECTS) http_chunked_compression_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) am_http_compression_OBJECTS = http_compression.$(OBJEXT) http_compression_OBJECTS = $(am_http_compression_OBJECTS) http_compression_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) am_https_fileserver_example_OBJECTS = \ https_fileserver_example-https_fileserver_example.$(OBJEXT) https_fileserver_example_OBJECTS = \ $(am_https_fileserver_example_OBJECTS) https_fileserver_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_minimal_example_OBJECTS = minimal_example.$(OBJEXT) minimal_example_OBJECTS = $(am_minimal_example_OBJECTS) minimal_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_minimal_example_comet_OBJECTS = minimal_example_comet.$(OBJEXT) minimal_example_comet_OBJECTS = $(am_minimal_example_comet_OBJECTS) minimal_example_comet_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_minimal_example_empty_OBJECTS = minimal_example_empty.$(OBJEXT) minimal_example_empty_OBJECTS = $(am_minimal_example_empty_OBJECTS) minimal_example_empty_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_minimal_example_empty_tls_OBJECTS = \ minimal_example_empty_tls.$(OBJEXT) minimal_example_empty_tls_OBJECTS = \ $(am_minimal_example_empty_tls_OBJECTS) minimal_example_empty_tls_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_post_example_OBJECTS = post_example.$(OBJEXT) post_example_OBJECTS = $(am_post_example_OBJECTS) post_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_querystring_example_OBJECTS = querystring_example.$(OBJEXT) querystring_example_OBJECTS = $(am_querystring_example_OBJECTS) querystring_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_refuse_post_example_OBJECTS = refuse_post_example.$(OBJEXT) refuse_post_example_OBJECTS = $(am_refuse_post_example_OBJECTS) refuse_post_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_suspend_resume_epoll_OBJECTS = \ suspend_resume_epoll-suspend_resume_epoll.$(OBJEXT) suspend_resume_epoll_OBJECTS = $(am_suspend_resume_epoll_OBJECTS) suspend_resume_epoll_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_timeout_OBJECTS = timeout.$(OBJEXT) timeout_OBJECTS = $(am_timeout_OBJECTS) timeout_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_upgrade_example_OBJECTS = \ upgrade_example-upgrade_example.$(OBJEXT) upgrade_example_OBJECTS = $(am_upgrade_example_OBJECTS) upgrade_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) upgrade_example_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(upgrade_example_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ am_websocket_chatserver_example_OBJECTS = \ websocket_chatserver_example.$(OBJEXT) websocket_chatserver_example_OBJECTS = \ $(am_websocket_chatserver_example_OBJECTS) websocket_chatserver_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd_ws/libmicrohttpd_ws.la \ $(top_builddir)/src/microhttpd/libmicrohttpd.la am_websocket_threaded_example_OBJECTS = websocket_threaded_example-websocket_threaded_example.$(OBJEXT) websocket_threaded_example_OBJECTS = \ $(am_websocket_threaded_example_OBJECTS) websocket_threaded_example_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__DEPENDENCIES_1) websocket_threaded_example_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(websocket_threaded_example_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/authorization_example.Po \ ./$(DEPDIR)/benchmark-benchmark.Po \ ./$(DEPDIR)/benchmark_https-benchmark_https.Po \ ./$(DEPDIR)/chunked_example.Po ./$(DEPDIR)/demo-demo.Po \ ./$(DEPDIR)/demo_https-demo_https.Po \ ./$(DEPDIR)/digest_auth_example.Po \ ./$(DEPDIR)/digest_auth_example_adv.Po \ ./$(DEPDIR)/dual_stack_example.Po \ ./$(DEPDIR)/fileserver_example.Po \ ./$(DEPDIR)/fileserver_example_dirs.Po \ ./$(DEPDIR)/fileserver_example_external_select.Po \ ./$(DEPDIR)/http_chunked_compression.Po \ ./$(DEPDIR)/http_compression.Po \ ./$(DEPDIR)/https_fileserver_example-https_fileserver_example.Po \ ./$(DEPDIR)/minimal_example.Po \ ./$(DEPDIR)/minimal_example_comet.Po \ ./$(DEPDIR)/minimal_example_empty.Po \ ./$(DEPDIR)/minimal_example_empty_tls.Po \ ./$(DEPDIR)/post_example.Po ./$(DEPDIR)/querystring_example.Po \ ./$(DEPDIR)/refuse_post_example.Po \ ./$(DEPDIR)/suspend_resume_epoll-suspend_resume_epoll.Po \ ./$(DEPDIR)/timeout.Po \ ./$(DEPDIR)/upgrade_example-upgrade_example.Po \ ./$(DEPDIR)/websocket_chatserver_example.Po \ ./$(DEPDIR)/websocket_threaded_example-websocket_threaded_example.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(authorization_example_SOURCES) $(benchmark_SOURCES) \ $(benchmark_https_SOURCES) $(chunked_example_SOURCES) \ $(demo_SOURCES) $(demo_https_SOURCES) \ $(digest_auth_example_SOURCES) \ $(digest_auth_example_adv_SOURCES) \ $(dual_stack_example_SOURCES) $(fileserver_example_SOURCES) \ $(fileserver_example_dirs_SOURCES) \ $(fileserver_example_external_select_SOURCES) \ $(http_chunked_compression_SOURCES) \ $(http_compression_SOURCES) \ $(https_fileserver_example_SOURCES) $(minimal_example_SOURCES) \ $(minimal_example_comet_SOURCES) \ $(minimal_example_empty_SOURCES) \ $(minimal_example_empty_tls_SOURCES) $(post_example_SOURCES) \ $(querystring_example_SOURCES) $(refuse_post_example_SOURCES) \ $(suspend_resume_epoll_SOURCES) $(timeout_SOURCES) \ $(upgrade_example_SOURCES) \ $(websocket_chatserver_example_SOURCES) \ $(websocket_threaded_example_SOURCES) DIST_SOURCES = $(authorization_example_SOURCES) $(benchmark_SOURCES) \ $(benchmark_https_SOURCES) $(chunked_example_SOURCES) \ $(demo_SOURCES) $(demo_https_SOURCES) \ $(digest_auth_example_SOURCES) \ $(digest_auth_example_adv_SOURCES) \ $(dual_stack_example_SOURCES) $(fileserver_example_SOURCES) \ $(fileserver_example_dirs_SOURCES) \ $(fileserver_example_external_select_SOURCES) \ $(http_chunked_compression_SOURCES) \ $(http_compression_SOURCES) \ $(https_fileserver_example_SOURCES) $(minimal_example_SOURCES) \ $(minimal_example_comet_SOURCES) \ $(minimal_example_empty_SOURCES) \ $(minimal_example_empty_tls_SOURCES) $(post_example_SOURCES) \ $(querystring_example_SOURCES) $(refuse_post_example_SOURCES) \ $(suspend_resume_epoll_SOURCES) $(timeout_SOURCES) \ $(upgrade_example_SOURCES) \ $(websocket_chatserver_example_SOURCES) \ $(websocket_threaded_example_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in \ $(top_srcdir)/build-aux/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # This Makefile.am is in the public domain SUBDIRS = . AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ $(CPPFLAGS_ac) \ -DDATA_DIR=\"$(top_srcdir)/src/datadir/\" AM_CFLAGS = $(CFLAGS_ac) @LIBGCRYPT_CFLAGS@ $(am__append_1) \ $(am__append_12) AM_LDFLAGS = $(LDFLAGS_ac) MHD_CPU_COUNT_DEF = -DMHD_CPU_COUNT=$(CPU_COUNT) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) EXTRA_DIST = msgs_i18n.c noinst_EXTRA_DIST = msgs_i18n.c minimal_example_SOURCES = \ minimal_example.c minimal_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la minimal_example_empty_SOURCES = \ minimal_example_empty.c minimal_example_empty_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la minimal_example_empty_tls_SOURCES = \ minimal_example_empty_tls.c minimal_example_empty_tls_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la upgrade_example_SOURCES = \ upgrade_example.c upgrade_example_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) upgrade_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(PTHREAD_LIBS) websocket_threaded_example_SOURCES = \ websocket_threaded_example.c websocket_threaded_example_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) websocket_threaded_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(PTHREAD_LIBS) timeout_SOURCES = \ timeout.c timeout_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la chunked_example_SOURCES = \ chunked_example.c chunked_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la websocket_chatserver_example_SOURCES = \ websocket_chatserver_example.c websocket_chatserver_example_LDADD = \ $(top_builddir)/src/microhttpd_ws/libmicrohttpd_ws.la \ $(top_builddir)/src/microhttpd/libmicrohttpd.la demo_SOURCES = \ demo.c demo_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) demo_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_CPU_COUNT_DEF) demo_LDADD = $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(PTHREAD_LIBS) $(am__append_13) demo_https_SOURCES = \ demo_https.c demo_https_CFLAGS = \ $(PTHREAD_CFLAGS) $(AM_CFLAGS) demo_https_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_CPU_COUNT_DEF) demo_https_LDADD = $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(PTHREAD_LIBS) $(am__append_14) benchmark_SOURCES = \ benchmark.c benchmark_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_CPU_COUNT_DEF) benchmark_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la suspend_resume_epoll_SOURCES = \ suspend_resume_epoll.c suspend_resume_epoll_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_CPU_COUNT_DEF) suspend_resume_epoll_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la benchmark_https_SOURCES = \ benchmark_https.c benchmark_https_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_CPU_COUNT_DEF) benchmark_https_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la dual_stack_example_SOURCES = \ dual_stack_example.c dual_stack_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la post_example_SOURCES = \ post_example.c post_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la minimal_example_comet_SOURCES = \ minimal_example_comet.c minimal_example_comet_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la authorization_example_SOURCES = \ authorization_example.c authorization_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la digest_auth_example_SOURCES = \ digest_auth_example.c digest_auth_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la digest_auth_example_adv_SOURCES = \ digest_auth_example_adv.c digest_auth_example_adv_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la refuse_post_example_SOURCES = \ refuse_post_example.c refuse_post_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la querystring_example_SOURCES = \ querystring_example.c querystring_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la fileserver_example_SOURCES = \ fileserver_example.c fileserver_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la fileserver_example_dirs_SOURCES = \ fileserver_example_dirs.c fileserver_example_dirs_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la fileserver_example_external_select_SOURCES = \ fileserver_example_external_select.c fileserver_example_external_select_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la https_fileserver_example_SOURCES = \ https_fileserver_example.c https_fileserver_example_CPPFLAGS = \ $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS) https_fileserver_example_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la http_compression_SOURCES = \ http_compression.c http_chunked_compression_SOURCES = \ http_chunked_compression.c http_compression_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__append_15) http_chunked_compression_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ $(am__append_16) all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/examples/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/examples/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list authorization_example$(EXEEXT): $(authorization_example_OBJECTS) $(authorization_example_DEPENDENCIES) $(EXTRA_authorization_example_DEPENDENCIES) @rm -f authorization_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(authorization_example_OBJECTS) $(authorization_example_LDADD) $(LIBS) benchmark$(EXEEXT): $(benchmark_OBJECTS) $(benchmark_DEPENDENCIES) $(EXTRA_benchmark_DEPENDENCIES) @rm -f benchmark$(EXEEXT) $(AM_V_CCLD)$(LINK) $(benchmark_OBJECTS) $(benchmark_LDADD) $(LIBS) benchmark_https$(EXEEXT): $(benchmark_https_OBJECTS) $(benchmark_https_DEPENDENCIES) $(EXTRA_benchmark_https_DEPENDENCIES) @rm -f benchmark_https$(EXEEXT) $(AM_V_CCLD)$(LINK) $(benchmark_https_OBJECTS) $(benchmark_https_LDADD) $(LIBS) chunked_example$(EXEEXT): $(chunked_example_OBJECTS) $(chunked_example_DEPENDENCIES) $(EXTRA_chunked_example_DEPENDENCIES) @rm -f chunked_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(chunked_example_OBJECTS) $(chunked_example_LDADD) $(LIBS) demo$(EXEEXT): $(demo_OBJECTS) $(demo_DEPENDENCIES) $(EXTRA_demo_DEPENDENCIES) @rm -f demo$(EXEEXT) $(AM_V_CCLD)$(demo_LINK) $(demo_OBJECTS) $(demo_LDADD) $(LIBS) demo_https$(EXEEXT): $(demo_https_OBJECTS) $(demo_https_DEPENDENCIES) $(EXTRA_demo_https_DEPENDENCIES) @rm -f demo_https$(EXEEXT) $(AM_V_CCLD)$(demo_https_LINK) $(demo_https_OBJECTS) $(demo_https_LDADD) $(LIBS) digest_auth_example$(EXEEXT): $(digest_auth_example_OBJECTS) $(digest_auth_example_DEPENDENCIES) $(EXTRA_digest_auth_example_DEPENDENCIES) @rm -f digest_auth_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(digest_auth_example_OBJECTS) $(digest_auth_example_LDADD) $(LIBS) digest_auth_example_adv$(EXEEXT): $(digest_auth_example_adv_OBJECTS) $(digest_auth_example_adv_DEPENDENCIES) $(EXTRA_digest_auth_example_adv_DEPENDENCIES) @rm -f digest_auth_example_adv$(EXEEXT) $(AM_V_CCLD)$(LINK) $(digest_auth_example_adv_OBJECTS) $(digest_auth_example_adv_LDADD) $(LIBS) dual_stack_example$(EXEEXT): $(dual_stack_example_OBJECTS) $(dual_stack_example_DEPENDENCIES) $(EXTRA_dual_stack_example_DEPENDENCIES) @rm -f dual_stack_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dual_stack_example_OBJECTS) $(dual_stack_example_LDADD) $(LIBS) fileserver_example$(EXEEXT): $(fileserver_example_OBJECTS) $(fileserver_example_DEPENDENCIES) $(EXTRA_fileserver_example_DEPENDENCIES) @rm -f fileserver_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(fileserver_example_OBJECTS) $(fileserver_example_LDADD) $(LIBS) fileserver_example_dirs$(EXEEXT): $(fileserver_example_dirs_OBJECTS) $(fileserver_example_dirs_DEPENDENCIES) $(EXTRA_fileserver_example_dirs_DEPENDENCIES) @rm -f fileserver_example_dirs$(EXEEXT) $(AM_V_CCLD)$(LINK) $(fileserver_example_dirs_OBJECTS) $(fileserver_example_dirs_LDADD) $(LIBS) fileserver_example_external_select$(EXEEXT): $(fileserver_example_external_select_OBJECTS) $(fileserver_example_external_select_DEPENDENCIES) $(EXTRA_fileserver_example_external_select_DEPENDENCIES) @rm -f fileserver_example_external_select$(EXEEXT) $(AM_V_CCLD)$(LINK) $(fileserver_example_external_select_OBJECTS) $(fileserver_example_external_select_LDADD) $(LIBS) http_chunked_compression$(EXEEXT): $(http_chunked_compression_OBJECTS) $(http_chunked_compression_DEPENDENCIES) $(EXTRA_http_chunked_compression_DEPENDENCIES) @rm -f http_chunked_compression$(EXEEXT) $(AM_V_CCLD)$(LINK) $(http_chunked_compression_OBJECTS) $(http_chunked_compression_LDADD) $(LIBS) http_compression$(EXEEXT): $(http_compression_OBJECTS) $(http_compression_DEPENDENCIES) $(EXTRA_http_compression_DEPENDENCIES) @rm -f http_compression$(EXEEXT) $(AM_V_CCLD)$(LINK) $(http_compression_OBJECTS) $(http_compression_LDADD) $(LIBS) https_fileserver_example$(EXEEXT): $(https_fileserver_example_OBJECTS) $(https_fileserver_example_DEPENDENCIES) $(EXTRA_https_fileserver_example_DEPENDENCIES) @rm -f https_fileserver_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(https_fileserver_example_OBJECTS) $(https_fileserver_example_LDADD) $(LIBS) minimal_example$(EXEEXT): $(minimal_example_OBJECTS) $(minimal_example_DEPENDENCIES) $(EXTRA_minimal_example_DEPENDENCIES) @rm -f minimal_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(minimal_example_OBJECTS) $(minimal_example_LDADD) $(LIBS) minimal_example_comet$(EXEEXT): $(minimal_example_comet_OBJECTS) $(minimal_example_comet_DEPENDENCIES) $(EXTRA_minimal_example_comet_DEPENDENCIES) @rm -f minimal_example_comet$(EXEEXT) $(AM_V_CCLD)$(LINK) $(minimal_example_comet_OBJECTS) $(minimal_example_comet_LDADD) $(LIBS) minimal_example_empty$(EXEEXT): $(minimal_example_empty_OBJECTS) $(minimal_example_empty_DEPENDENCIES) $(EXTRA_minimal_example_empty_DEPENDENCIES) @rm -f minimal_example_empty$(EXEEXT) $(AM_V_CCLD)$(LINK) $(minimal_example_empty_OBJECTS) $(minimal_example_empty_LDADD) $(LIBS) minimal_example_empty_tls$(EXEEXT): $(minimal_example_empty_tls_OBJECTS) $(minimal_example_empty_tls_DEPENDENCIES) $(EXTRA_minimal_example_empty_tls_DEPENDENCIES) @rm -f minimal_example_empty_tls$(EXEEXT) $(AM_V_CCLD)$(LINK) $(minimal_example_empty_tls_OBJECTS) $(minimal_example_empty_tls_LDADD) $(LIBS) post_example$(EXEEXT): $(post_example_OBJECTS) $(post_example_DEPENDENCIES) $(EXTRA_post_example_DEPENDENCIES) @rm -f post_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(post_example_OBJECTS) $(post_example_LDADD) $(LIBS) querystring_example$(EXEEXT): $(querystring_example_OBJECTS) $(querystring_example_DEPENDENCIES) $(EXTRA_querystring_example_DEPENDENCIES) @rm -f querystring_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(querystring_example_OBJECTS) $(querystring_example_LDADD) $(LIBS) refuse_post_example$(EXEEXT): $(refuse_post_example_OBJECTS) $(refuse_post_example_DEPENDENCIES) $(EXTRA_refuse_post_example_DEPENDENCIES) @rm -f refuse_post_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(refuse_post_example_OBJECTS) $(refuse_post_example_LDADD) $(LIBS) suspend_resume_epoll$(EXEEXT): $(suspend_resume_epoll_OBJECTS) $(suspend_resume_epoll_DEPENDENCIES) $(EXTRA_suspend_resume_epoll_DEPENDENCIES) @rm -f suspend_resume_epoll$(EXEEXT) $(AM_V_CCLD)$(LINK) $(suspend_resume_epoll_OBJECTS) $(suspend_resume_epoll_LDADD) $(LIBS) timeout$(EXEEXT): $(timeout_OBJECTS) $(timeout_DEPENDENCIES) $(EXTRA_timeout_DEPENDENCIES) @rm -f timeout$(EXEEXT) $(AM_V_CCLD)$(LINK) $(timeout_OBJECTS) $(timeout_LDADD) $(LIBS) upgrade_example$(EXEEXT): $(upgrade_example_OBJECTS) $(upgrade_example_DEPENDENCIES) $(EXTRA_upgrade_example_DEPENDENCIES) @rm -f upgrade_example$(EXEEXT) $(AM_V_CCLD)$(upgrade_example_LINK) $(upgrade_example_OBJECTS) $(upgrade_example_LDADD) $(LIBS) websocket_chatserver_example$(EXEEXT): $(websocket_chatserver_example_OBJECTS) $(websocket_chatserver_example_DEPENDENCIES) $(EXTRA_websocket_chatserver_example_DEPENDENCIES) @rm -f websocket_chatserver_example$(EXEEXT) $(AM_V_CCLD)$(LINK) $(websocket_chatserver_example_OBJECTS) $(websocket_chatserver_example_LDADD) $(LIBS) websocket_threaded_example$(EXEEXT): $(websocket_threaded_example_OBJECTS) $(websocket_threaded_example_DEPENDENCIES) $(EXTRA_websocket_threaded_example_DEPENDENCIES) @rm -f websocket_threaded_example$(EXEEXT) $(AM_V_CCLD)$(websocket_threaded_example_LINK) $(websocket_threaded_example_OBJECTS) $(websocket_threaded_example_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/authorization_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/benchmark-benchmark.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/benchmark_https-benchmark_https.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chunked_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo-demo.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo_https-demo_https.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/digest_auth_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/digest_auth_example_adv.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dual_stack_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileserver_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileserver_example_dirs.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileserver_example_external_select.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http_chunked_compression.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http_compression.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/https_fileserver_example-https_fileserver_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minimal_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minimal_example_comet.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minimal_example_empty.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minimal_example_empty_tls.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/post_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/querystring_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refuse_post_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/suspend_resume_epoll-suspend_resume_epoll.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timeout.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upgrade_example-upgrade_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/websocket_chatserver_example.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/websocket_threaded_example-websocket_threaded_example.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< benchmark-benchmark.o: benchmark.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(benchmark_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT benchmark-benchmark.o -MD -MP -MF $(DEPDIR)/benchmark-benchmark.Tpo -c -o benchmark-benchmark.o `test -f 'benchmark.c' || echo '$(srcdir)/'`benchmark.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/benchmark-benchmark.Tpo $(DEPDIR)/benchmark-benchmark.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='benchmark.c' object='benchmark-benchmark.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(benchmark_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o benchmark-benchmark.o `test -f 'benchmark.c' || echo '$(srcdir)/'`benchmark.c benchmark-benchmark.obj: benchmark.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(benchmark_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT benchmark-benchmark.obj -MD -MP -MF $(DEPDIR)/benchmark-benchmark.Tpo -c -o benchmark-benchmark.obj `if test -f 'benchmark.c'; then $(CYGPATH_W) 'benchmark.c'; else $(CYGPATH_W) '$(srcdir)/benchmark.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/benchmark-benchmark.Tpo $(DEPDIR)/benchmark-benchmark.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='benchmark.c' object='benchmark-benchmark.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(benchmark_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o benchmark-benchmark.obj `if test -f 'benchmark.c'; then $(CYGPATH_W) 'benchmark.c'; else $(CYGPATH_W) '$(srcdir)/benchmark.c'; fi` benchmark_https-benchmark_https.o: benchmark_https.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(benchmark_https_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT benchmark_https-benchmark_https.o -MD -MP -MF $(DEPDIR)/benchmark_https-benchmark_https.Tpo -c -o benchmark_https-benchmark_https.o `test -f 'benchmark_https.c' || echo '$(srcdir)/'`benchmark_https.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/benchmark_https-benchmark_https.Tpo $(DEPDIR)/benchmark_https-benchmark_https.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='benchmark_https.c' object='benchmark_https-benchmark_https.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(benchmark_https_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o benchmark_https-benchmark_https.o `test -f 'benchmark_https.c' || echo '$(srcdir)/'`benchmark_https.c benchmark_https-benchmark_https.obj: benchmark_https.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(benchmark_https_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT benchmark_https-benchmark_https.obj -MD -MP -MF $(DEPDIR)/benchmark_https-benchmark_https.Tpo -c -o benchmark_https-benchmark_https.obj `if test -f 'benchmark_https.c'; then $(CYGPATH_W) 'benchmark_https.c'; else $(CYGPATH_W) '$(srcdir)/benchmark_https.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/benchmark_https-benchmark_https.Tpo $(DEPDIR)/benchmark_https-benchmark_https.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='benchmark_https.c' object='benchmark_https-benchmark_https.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(benchmark_https_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o benchmark_https-benchmark_https.obj `if test -f 'benchmark_https.c'; then $(CYGPATH_W) 'benchmark_https.c'; else $(CYGPATH_W) '$(srcdir)/benchmark_https.c'; fi` demo-demo.o: demo.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(demo_CPPFLAGS) $(CPPFLAGS) $(demo_CFLAGS) $(CFLAGS) -MT demo-demo.o -MD -MP -MF $(DEPDIR)/demo-demo.Tpo -c -o demo-demo.o `test -f 'demo.c' || echo '$(srcdir)/'`demo.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/demo-demo.Tpo $(DEPDIR)/demo-demo.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='demo.c' object='demo-demo.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(demo_CPPFLAGS) $(CPPFLAGS) $(demo_CFLAGS) $(CFLAGS) -c -o demo-demo.o `test -f 'demo.c' || echo '$(srcdir)/'`demo.c demo-demo.obj: demo.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(demo_CPPFLAGS) $(CPPFLAGS) $(demo_CFLAGS) $(CFLAGS) -MT demo-demo.obj -MD -MP -MF $(DEPDIR)/demo-demo.Tpo -c -o demo-demo.obj `if test -f 'demo.c'; then $(CYGPATH_W) 'demo.c'; else $(CYGPATH_W) '$(srcdir)/demo.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/demo-demo.Tpo $(DEPDIR)/demo-demo.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='demo.c' object='demo-demo.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(demo_CPPFLAGS) $(CPPFLAGS) $(demo_CFLAGS) $(CFLAGS) -c -o demo-demo.obj `if test -f 'demo.c'; then $(CYGPATH_W) 'demo.c'; else $(CYGPATH_W) '$(srcdir)/demo.c'; fi` demo_https-demo_https.o: demo_https.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(demo_https_CPPFLAGS) $(CPPFLAGS) $(demo_https_CFLAGS) $(CFLAGS) -MT demo_https-demo_https.o -MD -MP -MF $(DEPDIR)/demo_https-demo_https.Tpo -c -o demo_https-demo_https.o `test -f 'demo_https.c' || echo '$(srcdir)/'`demo_https.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/demo_https-demo_https.Tpo $(DEPDIR)/demo_https-demo_https.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='demo_https.c' object='demo_https-demo_https.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(demo_https_CPPFLAGS) $(CPPFLAGS) $(demo_https_CFLAGS) $(CFLAGS) -c -o demo_https-demo_https.o `test -f 'demo_https.c' || echo '$(srcdir)/'`demo_https.c demo_https-demo_https.obj: demo_https.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(demo_https_CPPFLAGS) $(CPPFLAGS) $(demo_https_CFLAGS) $(CFLAGS) -MT demo_https-demo_https.obj -MD -MP -MF $(DEPDIR)/demo_https-demo_https.Tpo -c -o demo_https-demo_https.obj `if test -f 'demo_https.c'; then $(CYGPATH_W) 'demo_https.c'; else $(CYGPATH_W) '$(srcdir)/demo_https.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/demo_https-demo_https.Tpo $(DEPDIR)/demo_https-demo_https.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='demo_https.c' object='demo_https-demo_https.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(demo_https_CPPFLAGS) $(CPPFLAGS) $(demo_https_CFLAGS) $(CFLAGS) -c -o demo_https-demo_https.obj `if test -f 'demo_https.c'; then $(CYGPATH_W) 'demo_https.c'; else $(CYGPATH_W) '$(srcdir)/demo_https.c'; fi` https_fileserver_example-https_fileserver_example.o: https_fileserver_example.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(https_fileserver_example_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT https_fileserver_example-https_fileserver_example.o -MD -MP -MF $(DEPDIR)/https_fileserver_example-https_fileserver_example.Tpo -c -o https_fileserver_example-https_fileserver_example.o `test -f 'https_fileserver_example.c' || echo '$(srcdir)/'`https_fileserver_example.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/https_fileserver_example-https_fileserver_example.Tpo $(DEPDIR)/https_fileserver_example-https_fileserver_example.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='https_fileserver_example.c' object='https_fileserver_example-https_fileserver_example.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(https_fileserver_example_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o https_fileserver_example-https_fileserver_example.o `test -f 'https_fileserver_example.c' || echo '$(srcdir)/'`https_fileserver_example.c https_fileserver_example-https_fileserver_example.obj: https_fileserver_example.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(https_fileserver_example_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT https_fileserver_example-https_fileserver_example.obj -MD -MP -MF $(DEPDIR)/https_fileserver_example-https_fileserver_example.Tpo -c -o https_fileserver_example-https_fileserver_example.obj `if test -f 'https_fileserver_example.c'; then $(CYGPATH_W) 'https_fileserver_example.c'; else $(CYGPATH_W) '$(srcdir)/https_fileserver_example.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/https_fileserver_example-https_fileserver_example.Tpo $(DEPDIR)/https_fileserver_example-https_fileserver_example.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='https_fileserver_example.c' object='https_fileserver_example-https_fileserver_example.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(https_fileserver_example_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o https_fileserver_example-https_fileserver_example.obj `if test -f 'https_fileserver_example.c'; then $(CYGPATH_W) 'https_fileserver_example.c'; else $(CYGPATH_W) '$(srcdir)/https_fileserver_example.c'; fi` suspend_resume_epoll-suspend_resume_epoll.o: suspend_resume_epoll.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_resume_epoll_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT suspend_resume_epoll-suspend_resume_epoll.o -MD -MP -MF $(DEPDIR)/suspend_resume_epoll-suspend_resume_epoll.Tpo -c -o suspend_resume_epoll-suspend_resume_epoll.o `test -f 'suspend_resume_epoll.c' || echo '$(srcdir)/'`suspend_resume_epoll.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/suspend_resume_epoll-suspend_resume_epoll.Tpo $(DEPDIR)/suspend_resume_epoll-suspend_resume_epoll.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suspend_resume_epoll.c' object='suspend_resume_epoll-suspend_resume_epoll.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_resume_epoll_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o suspend_resume_epoll-suspend_resume_epoll.o `test -f 'suspend_resume_epoll.c' || echo '$(srcdir)/'`suspend_resume_epoll.c suspend_resume_epoll-suspend_resume_epoll.obj: suspend_resume_epoll.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_resume_epoll_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT suspend_resume_epoll-suspend_resume_epoll.obj -MD -MP -MF $(DEPDIR)/suspend_resume_epoll-suspend_resume_epoll.Tpo -c -o suspend_resume_epoll-suspend_resume_epoll.obj `if test -f 'suspend_resume_epoll.c'; then $(CYGPATH_W) 'suspend_resume_epoll.c'; else $(CYGPATH_W) '$(srcdir)/suspend_resume_epoll.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/suspend_resume_epoll-suspend_resume_epoll.Tpo $(DEPDIR)/suspend_resume_epoll-suspend_resume_epoll.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suspend_resume_epoll.c' object='suspend_resume_epoll-suspend_resume_epoll.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(suspend_resume_epoll_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o suspend_resume_epoll-suspend_resume_epoll.obj `if test -f 'suspend_resume_epoll.c'; then $(CYGPATH_W) 'suspend_resume_epoll.c'; else $(CYGPATH_W) '$(srcdir)/suspend_resume_epoll.c'; fi` upgrade_example-upgrade_example.o: upgrade_example.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(upgrade_example_CFLAGS) $(CFLAGS) -MT upgrade_example-upgrade_example.o -MD -MP -MF $(DEPDIR)/upgrade_example-upgrade_example.Tpo -c -o upgrade_example-upgrade_example.o `test -f 'upgrade_example.c' || echo '$(srcdir)/'`upgrade_example.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/upgrade_example-upgrade_example.Tpo $(DEPDIR)/upgrade_example-upgrade_example.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='upgrade_example.c' object='upgrade_example-upgrade_example.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(upgrade_example_CFLAGS) $(CFLAGS) -c -o upgrade_example-upgrade_example.o `test -f 'upgrade_example.c' || echo '$(srcdir)/'`upgrade_example.c upgrade_example-upgrade_example.obj: upgrade_example.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(upgrade_example_CFLAGS) $(CFLAGS) -MT upgrade_example-upgrade_example.obj -MD -MP -MF $(DEPDIR)/upgrade_example-upgrade_example.Tpo -c -o upgrade_example-upgrade_example.obj `if test -f 'upgrade_example.c'; then $(CYGPATH_W) 'upgrade_example.c'; else $(CYGPATH_W) '$(srcdir)/upgrade_example.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/upgrade_example-upgrade_example.Tpo $(DEPDIR)/upgrade_example-upgrade_example.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='upgrade_example.c' object='upgrade_example-upgrade_example.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(upgrade_example_CFLAGS) $(CFLAGS) -c -o upgrade_example-upgrade_example.obj `if test -f 'upgrade_example.c'; then $(CYGPATH_W) 'upgrade_example.c'; else $(CYGPATH_W) '$(srcdir)/upgrade_example.c'; fi` websocket_threaded_example-websocket_threaded_example.o: websocket_threaded_example.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(websocket_threaded_example_CFLAGS) $(CFLAGS) -MT websocket_threaded_example-websocket_threaded_example.o -MD -MP -MF $(DEPDIR)/websocket_threaded_example-websocket_threaded_example.Tpo -c -o websocket_threaded_example-websocket_threaded_example.o `test -f 'websocket_threaded_example.c' || echo '$(srcdir)/'`websocket_threaded_example.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/websocket_threaded_example-websocket_threaded_example.Tpo $(DEPDIR)/websocket_threaded_example-websocket_threaded_example.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='websocket_threaded_example.c' object='websocket_threaded_example-websocket_threaded_example.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(websocket_threaded_example_CFLAGS) $(CFLAGS) -c -o websocket_threaded_example-websocket_threaded_example.o `test -f 'websocket_threaded_example.c' || echo '$(srcdir)/'`websocket_threaded_example.c websocket_threaded_example-websocket_threaded_example.obj: websocket_threaded_example.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(websocket_threaded_example_CFLAGS) $(CFLAGS) -MT websocket_threaded_example-websocket_threaded_example.obj -MD -MP -MF $(DEPDIR)/websocket_threaded_example-websocket_threaded_example.Tpo -c -o websocket_threaded_example-websocket_threaded_example.obj `if test -f 'websocket_threaded_example.c'; then $(CYGPATH_W) 'websocket_threaded_example.c'; else $(CYGPATH_W) '$(srcdir)/websocket_threaded_example.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/websocket_threaded_example-websocket_threaded_example.Tpo $(DEPDIR)/websocket_threaded_example-websocket_threaded_example.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='websocket_threaded_example.c' object='websocket_threaded_example-websocket_threaded_example.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(websocket_threaded_example_CFLAGS) $(CFLAGS) -c -o websocket_threaded_example-websocket_threaded_example.obj `if test -f 'websocket_threaded_example.c'; then $(CYGPATH_W) 'websocket_threaded_example.c'; else $(CYGPATH_W) '$(srcdir)/websocket_threaded_example.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(PROGRAMS) installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ mostlyclean-am distclean: distclean-recursive -rm -f ./$(DEPDIR)/authorization_example.Po -rm -f ./$(DEPDIR)/benchmark-benchmark.Po -rm -f ./$(DEPDIR)/benchmark_https-benchmark_https.Po -rm -f ./$(DEPDIR)/chunked_example.Po -rm -f ./$(DEPDIR)/demo-demo.Po -rm -f ./$(DEPDIR)/demo_https-demo_https.Po -rm -f ./$(DEPDIR)/digest_auth_example.Po -rm -f ./$(DEPDIR)/digest_auth_example_adv.Po -rm -f ./$(DEPDIR)/dual_stack_example.Po -rm -f ./$(DEPDIR)/fileserver_example.Po -rm -f ./$(DEPDIR)/fileserver_example_dirs.Po -rm -f ./$(DEPDIR)/fileserver_example_external_select.Po -rm -f ./$(DEPDIR)/http_chunked_compression.Po -rm -f ./$(DEPDIR)/http_compression.Po -rm -f ./$(DEPDIR)/https_fileserver_example-https_fileserver_example.Po -rm -f ./$(DEPDIR)/minimal_example.Po -rm -f ./$(DEPDIR)/minimal_example_comet.Po -rm -f ./$(DEPDIR)/minimal_example_empty.Po -rm -f ./$(DEPDIR)/minimal_example_empty_tls.Po -rm -f ./$(DEPDIR)/post_example.Po -rm -f ./$(DEPDIR)/querystring_example.Po -rm -f ./$(DEPDIR)/refuse_post_example.Po -rm -f ./$(DEPDIR)/suspend_resume_epoll-suspend_resume_epoll.Po -rm -f ./$(DEPDIR)/timeout.Po -rm -f ./$(DEPDIR)/upgrade_example-upgrade_example.Po -rm -f ./$(DEPDIR)/websocket_chatserver_example.Po -rm -f ./$(DEPDIR)/websocket_threaded_example-websocket_threaded_example.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/authorization_example.Po -rm -f ./$(DEPDIR)/benchmark-benchmark.Po -rm -f ./$(DEPDIR)/benchmark_https-benchmark_https.Po -rm -f ./$(DEPDIR)/chunked_example.Po -rm -f ./$(DEPDIR)/demo-demo.Po -rm -f ./$(DEPDIR)/demo_https-demo_https.Po -rm -f ./$(DEPDIR)/digest_auth_example.Po -rm -f ./$(DEPDIR)/digest_auth_example_adv.Po -rm -f ./$(DEPDIR)/dual_stack_example.Po -rm -f ./$(DEPDIR)/fileserver_example.Po -rm -f ./$(DEPDIR)/fileserver_example_dirs.Po -rm -f ./$(DEPDIR)/fileserver_example_external_select.Po -rm -f ./$(DEPDIR)/http_chunked_compression.Po -rm -f ./$(DEPDIR)/http_compression.Po -rm -f ./$(DEPDIR)/https_fileserver_example-https_fileserver_example.Po -rm -f ./$(DEPDIR)/minimal_example.Po -rm -f ./$(DEPDIR)/minimal_example_comet.Po -rm -f ./$(DEPDIR)/minimal_example_empty.Po -rm -f ./$(DEPDIR)/minimal_example_empty_tls.Po -rm -f ./$(DEPDIR)/post_example.Po -rm -f ./$(DEPDIR)/querystring_example.Po -rm -f ./$(DEPDIR)/refuse_post_example.Po -rm -f ./$(DEPDIR)/suspend_resume_epoll-suspend_resume_epoll.Po -rm -f ./$(DEPDIR)/timeout.Po -rm -f ./$(DEPDIR)/upgrade_example-upgrade_example.Po -rm -f ./$(DEPDIR)/websocket_chatserver_example.Po -rm -f ./$(DEPDIR)/websocket_threaded_example-websocket_threaded_example.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--depfiles check check-am clean clean-generic clean-libtool \ clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am .PRECIOUS: Makefile $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/src/examples/digest_auth_example_adv.c0000644000175000017500000010075114555767064017503 /* This file is part of libmicrohttpd Copyright (C) 2010 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2024 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file digest_auth_example_adv.c * @brief Advanced example for digest auth with libmicrohttpd * @author Karlson2k (Evgeny Grin) */ #include #include #include #include #include #if ! defined(_WIN32) || defined(__CYGWIN__) # include # include # include #else /* Native W32 */ # include #endif /* Native W32 */ #define SEC_AREA1_URL "/secret_page/" #define SEC_AREA2_URL "/super_secret_page/" #define MAIN_PAGE \ "Welcome to the site" \ "

    Restricted Page

    " \ "

    Very Restricted Page

    " #define OPAQUE_DATA "ServerOpaqueData" #define REALM "authenticated_users@thishost" /** * Force select "MD5" algorithm instead of MHD default (currently the same) if non-zero. */ static int force_md5 = 0; /** * Force select "SHA-256" algorithm instead of MHD default (MD5) if non-zero. */ static int force_sha256 = 0; /** * Force select "SHA-512/256" algorithm instead of MHD default (MD5) if non-zero. */ static int force_sha512_256 = 0; /** * Disable fallback to (less secure) RFC2069 if non-zero. */ static int allow_rfc2069 = 0; /** * The daemon's port */ static uint16_t daemon_port = 0; /* *** "Database" of users and "database" functions *** */ /** * User record. * This kind of data (or something similar) should be stored in some database * or file. */ struct UserEntry { /** * The username. * Static data is used in this example. * In real application dynamic buffer or fixed size array could be used. */ const char *username; #if 0 /* Disabled code */ /* The cleartext password is not stored in the database. The more secure "userdigest" is used instead. */ /** * The password. * Static data is used in this example. * In real application dynamic buffer or fixed size array could be used. */ const char *password; #endif /* Disabled code */ /** * The realm for this entry. * Static data is used in this example. * In real application dynamic buffer or fixed size array could be used. */ const char *realm; /** * The MD5 hash of the username together with the realm. * This hash can be used by the client to send the username in encrypted * form. * The purpose of userhash is to hide user identity when transmitting * requests over insecure link. */ uint8_t userhash_md5[MHD_MD5_DIGEST_SIZE]; /** * The MD5 hash of the username with the password and the realm. * It is used to verify that password used by the client matches password * required by the server. * The purpose of userhash is to avoid keeping the password in cleartext * on the server side. */ uint8_t userdigest_md5[MHD_MD5_DIGEST_SIZE]; /** * The SHA-256 hash of the username together with the realm. * This hash can be used by the client to send the username in encrypted * form. * The purpose of userhash is to hide user identity when transmitting * requests over insecure link. */ uint8_t userhash_sha256[MHD_SHA256_DIGEST_SIZE]; /** * The SHA-256 hash of the username with the password and the realm. * It is used to verify that password used by the client matches password * required by the server. * The purpose of userhash is to avoid keeping the password in cleartext * on the server side. */ uint8_t userdigest_sha256[MHD_SHA256_DIGEST_SIZE]; /** * The SHA-512/256 hash of the username together with the realm. * This hash can be used by the client to send the username in encrypted * form. * The purpose of userhash is to hide user identity when transmitting * requests over insecure link. */ uint8_t userhash_sha512_256[MHD_SHA512_256_DIGEST_SIZE]; /** * The SHA-512/256 hash of the username with the password and the realm. * It is used to verify that password used by the client matches password * required by the server. * The purpose of userhash is to avoid keeping the password in cleartext * on the server side. */ uint8_t userdigest_sha512_256[MHD_SHA512_256_DIGEST_SIZE]; /** * User has access to "area 1" if non-zero */ int allow_area_1; /** * User has access to "area 2" if non-zero */ int allow_area_2; }; /** * The array of user entries. * In real application it should be loaded from external sources * at the application startup. */ static struct UserEntry user_ids[2]; /** * The number of entries used in @a user_ids. */ static size_t user_ids_used = 0; /** * Add new user to the users database/array. * * This kind of function must be used only when the new user is introduced. * It must not be used at the every start of the application. The database * of users should be stored somewhere and reloaded when application is * started. * * @param username the username of the new user * @param password the password of the new user * @param realm the realm (the protection space) for which the new user * is added * @param allow_area_1 if non-zero than user has access to the "area 1" * @param allow_area_2 if non-zero than user has access to the "area 2" * @return non-zero on success, * zero on failure (like no more space in the database). */ static int add_new_user_entry (const char *const username, const char *const password, const char *const realm, int allow_area_1, int allow_area_2) { struct UserEntry *entry; enum MHD_Result res; if ((sizeof(user_ids) / sizeof(user_ids[0])) <= user_ids_used) return 0; /* No more space to add new entry */ entry = user_ids + user_ids_used; entry->username = username; entry->realm = realm; res = MHD_YES; if (MHD_NO != res) res = MHD_digest_auth_calc_userhash (MHD_DIGEST_AUTH_ALGO3_MD5, username, realm, entry->userhash_md5, sizeof(entry->userhash_md5)); if (MHD_NO != res) res = MHD_digest_auth_calc_userdigest (MHD_DIGEST_AUTH_ALGO3_MD5, username, realm, password, entry->userdigest_md5, sizeof(entry->userdigest_md5)); if (MHD_NO != res) res = MHD_digest_auth_calc_userhash (MHD_DIGEST_AUTH_ALGO3_SHA256, username, realm, entry->userhash_sha256, sizeof(entry->userhash_sha256)); if (MHD_NO != res) res = MHD_digest_auth_calc_userdigest (MHD_DIGEST_AUTH_ALGO3_SHA256, username, realm, password, entry->userdigest_sha256, sizeof(entry->userdigest_sha256)); if (MHD_NO != res) res = MHD_digest_auth_calc_userhash (MHD_DIGEST_AUTH_ALGO3_SHA512_256, username, realm, entry->userhash_sha512_256, sizeof(entry->userhash_sha512_256)); if (MHD_NO != res) res = MHD_digest_auth_calc_userdigest (MHD_DIGEST_AUTH_ALGO3_SHA512_256, username, realm, password, entry->userdigest_sha512_256, sizeof(entry->userdigest_sha512_256)); if (MHD_NO == res) return 0; /* Failure exit point */ entry->allow_area_1 = allow_area_1; entry->allow_area_2 = allow_area_2; user_ids_used++; return ! 0; } /** * Find the user entry for specified username * @param username the username to find * @return NULL if no entry for specified username is found, * pointer to user entry if found */ static struct UserEntry * find_entry_by_username (const char *const username) { size_t i; for (i = 0; i < (sizeof(user_ids) / sizeof(user_ids[0])); ++i) { struct UserEntry *entry; entry = user_ids + i; if (0 == strcmp (username, entry->username)) return entry; } return NULL; } /** * Find the user entry for specified userhash * @param algo3 the algorithm used for userhash calculation * @param userhash the userhash identifier to find * @param userhash_size the size @a userhash in bytes * @return NULL if no entry for specified userhash is found, * pointer to user entry if found */ static struct UserEntry * find_entry_by_userhash (enum MHD_DigestAuthAlgo3 algo3, const void *userhash, size_t userhash_size) { size_t i; if (MHD_digest_get_hash_size (algo3) != userhash_size) return NULL; /* Wrong length of the userhash */ switch (algo3) { case MHD_DIGEST_AUTH_ALGO3_MD5: case MHD_DIGEST_AUTH_ALGO3_MD5_SESSION: /* An extra case not used currently */ if (sizeof(user_ids[0].userhash_md5) != userhash_size) /* Extra check. The size was checked before */ return NULL; for (i = 0; i < (sizeof(user_ids) / sizeof(user_ids[0])); ++i) { struct UserEntry *entry; entry = user_ids + i; if (0 == memcmp (userhash, entry->userhash_md5, sizeof(entry->userhash_md5))) return entry; } break; case MHD_DIGEST_AUTH_ALGO3_SHA256: case MHD_DIGEST_AUTH_ALGO3_SHA256_SESSION: /* An extra case not used currently */ if (sizeof(user_ids[0].userhash_sha256) != userhash_size) /* Extra check. The size was checked before */ return NULL; for (i = 0; i < (sizeof(user_ids) / sizeof(user_ids[0])); ++i) { struct UserEntry *entry; entry = user_ids + i; if (0 == memcmp (userhash, entry->userhash_sha256, sizeof(entry->userhash_sha256))) return entry; } break; case MHD_DIGEST_AUTH_ALGO3_SHA512_256: case MHD_DIGEST_AUTH_ALGO3_SHA512_256_SESSION: /* An extra case not used currently */ if (sizeof(user_ids[0].userhash_sha512_256) != userhash_size) /* Extra check. The size was checked before */ return NULL; for (i = 0; i < (sizeof(user_ids) / sizeof(user_ids[0])); ++i) { struct UserEntry *entry; entry = user_ids + i; if (0 == memcmp (userhash, entry->userhash_sha512_256, sizeof(entry->userhash_sha512_256))) return entry; } break; case MHD_DIGEST_AUTH_ALGO3_INVALID: /* Mute compiler warning. Impossible value in this context. */ default: break; } return NULL; } /** * Find the user entry for the user specified by provided username info * @param user_info the pointer to the structure username info returned by MHD * @return NULL if no entry for specified username info is found, * pointer to user entry if found */ static struct UserEntry * find_entry_by_userinfo (const struct MHD_DigestAuthUsernameInfo *username_info) { if (MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD <= username_info->uname_type) return find_entry_by_username (username_info->username); if (MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH == username_info->uname_type) return find_entry_by_userhash (username_info->algo3, username_info->userhash_bin, username_info->userhash_hex_len / 2); return NULL; /* Should be unreachable as all cases are covered before */ } /* *** End of "database" of users and "database" functions *** */ /* *** Requests handling *** */ /** * Send "Requested HTTP method is not supported" page * @param c the connection structure * @return MHD_YES if response was successfully queued, * MHD_NO otherwise */ static enum MHD_Result reply_with_page_not_found (struct MHD_Connection *c) { static const char page_content[] = "Page Not Found" \ "The requested page not found."; static const size_t page_content_len = (sizeof(page_content) / sizeof(char)) - 1; struct MHD_Response *resp; enum MHD_Result ret; resp = MHD_create_response_from_buffer_static (page_content_len, page_content); if (NULL == resp) return MHD_NO; /* Ignore possible error when adding the header as the reply will work even without this header. */ (void) MHD_add_response_header (resp, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); ret = MHD_queue_response (c, MHD_HTTP_NOT_FOUND, resp); MHD_destroy_response (resp); return ret; } /** * Get enum MHD_DigestAuthMultiAlgo3 value to be used for authentication. * @return the algorithm number/value */ static enum MHD_DigestAuthMultiAlgo3 get_m_algo (void) { if (force_md5) return MHD_DIGEST_AUTH_MULT_ALGO3_MD5; else if (force_sha256) return MHD_DIGEST_AUTH_MULT_ALGO3_SHA256; else if (force_sha512_256) return MHD_DIGEST_AUTH_MULT_ALGO3_SHA512_256; /* No forced algorithm selection, let MHD to use default */ return MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION; } /** * Get enum MHD_DigestAuthMultiQOP value to be used for authentication. * @return the "Quality Of Protection" number/value */ static enum MHD_DigestAuthMultiQOP get_m_QOP (void) { if (allow_rfc2069) return MHD_DIGEST_AUTH_MULT_QOP_ANY_NON_INT; return MHD_DIGEST_AUTH_MULT_QOP_AUTH; } /** * Send "Authentication required" page * @param c the connection structure * @param stale if non-zero then "nonce stale" is indicated in the reply * @param wrong_cred if non-zero then client is informed the previously * it used wrong credentials * @return MHD_YES if response was successfully queued, * MHD_NO otherwise */ static enum MHD_Result reply_with_auth_required (struct MHD_Connection *c, int stale, int wrong_cred) { static const char auth_required_content[] = "Authentication required" \ "The requested page needs authentication."; static const size_t auth_required_content_len = (sizeof(auth_required_content) / sizeof(char)) - 1; static const char wrong_creds_content[] = "Wrong credentials" \ "The provided credentials are incorrect."; static const size_t wrong_creds_content_len = (sizeof(wrong_creds_content) / sizeof(char)) - 1; struct MHD_Response *resp; enum MHD_Result ret; if (wrong_cred) stale = 0; /* Force client to ask user for username and password */ if (! wrong_cred) resp = MHD_create_response_from_buffer_static (auth_required_content_len, auth_required_content); else resp = MHD_create_response_from_buffer_static (wrong_creds_content_len, wrong_creds_content); if (NULL == resp) return MHD_NO; /* Ignore possible error when adding the header as the reply will work even without this header. */ (void) MHD_add_response_header (resp, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); ret = MHD_queue_auth_required_response3 ( c, REALM, OPAQUE_DATA, /* The "opaque data", not really useful */ SEC_AREA1_URL " " SEC_AREA2_URL, /* Space-separated list of URLs' initial parts */ resp, stale, get_m_QOP (), get_m_algo (), ! 0, /* Userhash support enabled */ ! 0 /* UTF-8 is preferred */); MHD_destroy_response (resp); return ret; } /** * Send "Forbidden" page * @param c the connection structure * @return MHD_YES if response was successfully queued, * MHD_NO otherwise */ static enum MHD_Result reply_with_forbidden (struct MHD_Connection *c) { static const char page_content[] = "Forbidden" \ "You do not have access to this page."; static const size_t page_content_len = (sizeof(page_content) / sizeof(char)) - 1; struct MHD_Response *resp; enum MHD_Result ret; resp = MHD_create_response_from_buffer_static (page_content_len, page_content) ; if (NULL == resp) return MHD_NO; /* Ignore possible error when adding the header as the reply will work even without this header. */ (void) MHD_add_response_header (resp, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); ret = MHD_queue_response (c, MHD_HTTP_FORBIDDEN, resp); MHD_destroy_response (resp); return ret; } /** * Send "Area 1" pages * @param c the connection structure * @param url the requested URL * @return MHD_YES if response was successfully queued, * MHD_NO otherwise */ static enum MHD_Result reply_with_area1_pages (struct MHD_Connection *c, const char *url) { if (0 == strcmp (url, SEC_AREA1_URL "")) { static const char page_content[] = "Restricted secret page" \ "Welcome to the restricted area"; static const size_t page_content_len = (sizeof(page_content) / sizeof(char)) - 1; struct MHD_Response *resp; enum MHD_Result ret; resp = MHD_create_response_from_buffer_static (page_content_len, page_content); if (NULL == resp) return MHD_NO; /* Ignore possible error when adding the header as the reply will work even without this header. */ (void) MHD_add_response_header (resp, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); ret = MHD_queue_response (c, MHD_HTTP_OK, resp); MHD_destroy_response (resp); return ret; } /* If needed: add handlers for other URLs in this area */ #if 0 /* Disabled code */ if (0 == strcmp (url, SEC_AREA1_URL "some_path/some_page")) { /* Add page creation/processing code */ } #endif /* Disabled code */ /* The requested URL is unknown */ return reply_with_page_not_found (c); } /** * Send "Area 2" pages * @param c the connection structure * @param url the requested URL * @return MHD_YES if response was successfully queued, * MHD_NO otherwise */ static enum MHD_Result reply_with_area2_pages (struct MHD_Connection *c, const char *url) { if (0 == strcmp (url, SEC_AREA2_URL "")) { static const char page_content[] = "Very restricted secret page" \ "Welcome to the super restricted area"; static const size_t page_content_len = (sizeof(page_content) / sizeof(char)) - 1; struct MHD_Response *resp; enum MHD_Result ret; resp = MHD_create_response_from_buffer_static (page_content_len, page_content); if (NULL == resp) return MHD_NO; /* Ignore possible error when adding the header as the reply will work even without this header. */ (void) MHD_add_response_header (resp, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); ret = MHD_queue_response (c, MHD_HTTP_OK, resp); MHD_destroy_response (resp); return ret; } /* If needed: add handlers for other URLs in this area */ #if 0 /* Disabled code */ if (0 == strcmp (url, SEC_AREA2_URL "other_path/other_page")) { /* Add page creation/processing code */ } #endif /* Disabled code */ /* The requested URL is unknown */ return reply_with_page_not_found (c); } /** * Handle client's request for secured areas * @param c the connection structure * @param url the URL requested by the client * @param sec_area_num the number of secured area * @return MHD_YES if request was handled (either with "denied" or with * "allowed" result), * MHD_NO if it was an error handling the request. */ static enum MHD_Result handle_sec_areas_req (struct MHD_Connection *c, const char *url, unsigned int sec_area_num) { struct MHD_DigestAuthUsernameInfo *username_info; struct UserEntry *user_entry; void *userdigest; size_t userdigest_size; enum MHD_DigestAuthResult auth_res; username_info = MHD_digest_auth_get_username3 (c); if (NULL == username_info) return reply_with_auth_required (c, 0, 0); user_entry = find_entry_by_userinfo (username_info); if (NULL == user_entry) return reply_with_auth_required (c, 0, 1); switch (username_info->algo3) { case MHD_DIGEST_AUTH_ALGO3_MD5: userdigest = user_entry->userdigest_md5; userdigest_size = sizeof(user_entry->userdigest_md5); break; case MHD_DIGEST_AUTH_ALGO3_SHA256: userdigest = user_entry->userdigest_sha256; userdigest_size = sizeof(user_entry->userdigest_sha256); break; case MHD_DIGEST_AUTH_ALGO3_SHA512_256: userdigest = user_entry->userdigest_sha512_256; userdigest_size = sizeof(user_entry->userdigest_sha512_256); break; case MHD_DIGEST_AUTH_ALGO3_MD5_SESSION: case MHD_DIGEST_AUTH_ALGO3_SHA256_SESSION: case MHD_DIGEST_AUTH_ALGO3_SHA512_256_SESSION: /* Not supported currently and not used by MHD. The client incorrectly used algorithm not advertised by the server. */ return reply_with_auth_required (c, 0, 1); case MHD_DIGEST_AUTH_ALGO3_INVALID: /* Mute compiler warning */ default: return MHD_NO; /* Should be unreachable */ } auth_res = MHD_digest_auth_check_digest3 ( c, REALM, /* Make sure to use the proper realm, not the realm provided by the client and returned by "user_entry" */ user_entry->username, userdigest, userdigest_size, 0, /* Use daemon's default value for nonce_timeout*/ 0, /* Use daemon's default value for max_nc */ get_m_QOP (), (enum MHD_DigestAuthMultiAlgo3) username_info->algo3 /* Direct cast from "single algorithm" to "multi-algorithm" is allowed */ ); if (MHD_DAUTH_OK != auth_res) { int need_just_refresh_nonce; /* Actually MHD_DAUTH_NONCE_OTHER_COND should not be returned as MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE is not used for the daemon. To keep the code universal the MHD_DAUTH_NONCE_OTHER_COND is still checked here. */ need_just_refresh_nonce = (MHD_DAUTH_NONCE_STALE == auth_res) || (MHD_DAUTH_NONCE_OTHER_COND == auth_res); return reply_with_auth_required (c, need_just_refresh_nonce, ! need_just_refresh_nonce); } /* The user successfully authenticated */ /* Check whether access to the request area is allowed for the user */ if (1 == sec_area_num) { if (user_entry->allow_area_1) return reply_with_area1_pages (c, url); else return reply_with_forbidden (c); } else if (2 == sec_area_num) { if (user_entry->allow_area_2) return reply_with_area2_pages (c, url); else return reply_with_forbidden (c); } return MHD_NO; /* Should be unreachable */ } /** * Send the main page * @param c the connection structure * @return MHD_YES if response was successfully queued, * MHD_NO otherwise */ static enum MHD_Result reply_with_main_page (struct MHD_Connection *c) { static const char page_content[] = MAIN_PAGE; static const size_t page_content_len = (sizeof(page_content) / sizeof(char)) - 1; struct MHD_Response *resp; enum MHD_Result ret; resp = MHD_create_response_from_buffer_static (page_content_len, page_content) ; if (NULL == resp) return MHD_NO; /* Ignore possible error when adding the header as the reply will work even without this header. */ (void) MHD_add_response_header (resp, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); ret = MHD_queue_response (c, MHD_HTTP_OK, resp); MHD_destroy_response (resp); return ret; } /** * Send "Requested HTTP method is not supported" page * @param c the connection structure * @return MHD_YES if response was successfully queued, * MHD_NO otherwise */ static enum MHD_Result reply_with_method_not_supported (struct MHD_Connection *c) { static const char page_content[] = "Requested HTTP Method Is Not Supported" \ "The requested HTTP method is not supported."; static const size_t page_content_len = (sizeof(page_content) / sizeof(char)) - 1; struct MHD_Response *resp; enum MHD_Result ret; resp = MHD_create_response_from_buffer_static (page_content_len, page_content) ; if (NULL == resp) return MHD_NO; /* Ignore possible error when adding the header as the reply will work even without this header. */ (void) MHD_add_response_header (resp, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); ret = MHD_queue_response (c, MHD_HTTP_NOT_IMPLEMENTED, resp); MHD_destroy_response (resp); return ret; } static enum MHD_Result ahc_main (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int already_called_marker; size_t url_len; (void) cls; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ if ((0 != strcmp (method, MHD_HTTP_METHOD_GET)) && (0 != strcmp (method, MHD_HTTP_METHOD_HEAD))) return reply_with_method_not_supported (connection); if (0 != *upload_data_size) return MHD_NO; /* No upload expected for GET or HEAD */ if (&already_called_marker != *req_cls) { /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; } if (0 == strcmp (url, "/")) return reply_with_main_page (connection); url_len = strlen (url); if ((strlen (SEC_AREA1_URL) <= url_len) && (0 == memcmp (url, SEC_AREA1_URL, strlen (SEC_AREA1_URL)))) return handle_sec_areas_req (connection, url, 1); /* The requested URL is within SEC_AREA1_URL */ if ((strlen (SEC_AREA2_URL) <= url_len) && (0 == memcmp (url, SEC_AREA2_URL, strlen (SEC_AREA2_URL)))) return handle_sec_areas_req (connection, url, 2); /* The requested URL is within SEC_AREA2_URL */ return reply_with_page_not_found (connection); } /* *** End of requests handling *** */ /** * Add new users to the users "database". * * In real application this kind of function must NOT be called at * the application startup. Instead similar function should be * called only when new user is introduced. The users "database" * should be stored somewhere and reloaded at the application * startup. * * @return non-zero on success, * zero in case of error. */ static int add_new_users (void) { if (! add_new_user_entry ("joepublic", "password", REALM, ! 0, 0)) return 0; if (! add_new_user_entry ("superadmin", "pA$$w0Rd", REALM, ! 0, ! 0)) return 0; return ! 0; } /** * Check and apply application parameters * @param argc the argc of the @a main function * @param argv the argv of the @a main function * @return non-zero on success, * zero in case of any error (like wrong parameters). */ static int check_params (int argc, char *const *const argv) { size_t i; unsigned int port_value; if (2 > argc) return 0; for (i = 1; i < (unsigned int) argc; ++i) { if (0 == strcmp (argv[i], "--md5")) { /* Force use MD5 */ force_md5 = ! 0; force_sha256 = 0; force_sha512_256 = 0; } else if (0 == strcmp (argv[i], "--sha256")) { /* Force use SHA-256 instead of default MD5 */ force_md5 = 0; force_sha256 = ! 0; force_sha512_256 = 0; } else if (0 == strcmp (argv[i], "--sha512-256")) { /* Force use SHA-512/256 instead of default MD5 */ force_md5 = 0; force_sha256 = 0; force_sha512_256 = ! 0; } else if (0 == strcmp (argv[i], "--allow-rfc2069")) allow_rfc2069 = ! 0; /* Allow fallback to RFC2069. Not recommended! */ else if ((1 == sscanf (argv[i], "%u", &port_value)) && (0 < port_value) && (65535 >= port_value)) daemon_port = (uint16_t) port_value; else { fprintf (stderr, "Unrecognized parameter: %s\n", argv[i]); return 0; } } if (force_sha512_256) printf ( "Note: when testing with curl/libcurl do not be surprised with failures as " "libcurl incorrectly implements SHA-512/256 algorithm.\n"); return ! 0; } /** * The cryptographically secure random data */ static uint8_t rand_data[8]; /** * Initialise the random data * @return non-zero if succeed, * zero if failed */ static int init_rand_data (void) { #if ! defined(_WIN32) || defined(__CYGWIN__) int fd; ssize_t len; size_t off; fd = open ("/dev/urandom", O_RDONLY); if (-1 == fd) { fprintf (stderr, "Failed to open '%s': %s\n", "/dev/urandom", strerror (errno)); return 0; } for (off = 0; off < sizeof(rand_data); off += (size_t) len) { len = read (fd, rand_data, 8); if (0 > len) { fprintf (stderr, "Failed to read '%s': %s\n", "/dev/urandom", strerror (errno)); (void) close (fd); return 0; } } (void) close (fd); #else /* Native W32 */ HCRYPTPROV cc; BOOL b; b = CryptAcquireContext (&cc, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); if (FALSE == b) { fprintf (stderr, "Failed to acquire crypto provider context: %lu\n", (unsigned long) GetLastError ()); return 0; } b = CryptGenRandom (cc, sizeof(rand_data), (BYTE *) rand_data); if (FALSE == b) { fprintf (stderr, "Failed to generate 8 random bytes: %lu\n", GetLastError ()); } CryptReleaseContext (cc, 0); if (FALSE == b) return 0; #endif /* Native W32 */ return ! 0; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; if (! check_params (argc, argv)) { fprintf (stderr, "Usage: %s [--md5|--sha256|--sha512-256] " "[--allow-rfc2069] PORT\n", argv[0]); return 1; } if (! add_new_users ()) { fprintf (stderr, "Failed to add new users to the users database.\n"); return 2; } if (! init_rand_data ()) { fprintf (stderr, "Failed to initialise random data.\n"); return 2; } d = MHD_start_daemon ( MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_ERROR_LOG, daemon_port, NULL, NULL, &ahc_main, NULL, MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof(rand_data), rand_data, MHD_OPTION_NONCE_NC_SIZE, 500, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 180, MHD_OPTION_END); if (d == NULL) { fprintf (stderr, "Failed to start the server on port %lu.\n", (unsigned long) daemon_port); return 1; } printf ("Running server on port %lu.\nPress ENTER to stop.\n", (unsigned long) daemon_port); (void) getc (stdin); MHD_stop_daemon (d); return 0; } /* End of digest_auth_example_adv.c */ libmicrohttpd-1.0.1/src/examples/websocket_chatserver_example.c0000644000175000017500000023637314504515253020560 /* This file is part of libmicrohttpd Copyright (C) 2021 David Gausmann (and other contributing authors) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file websocket_chatserver_example.c * @brief example for how to use websockets * @author David Gausmann * * Access the HTTP server with your webbrowser. * The webbrowser must support JavaScript and WebSockets. * The websocket access will be initiated via the JavaScript on the website. * You will get an example chat room, which uses websockets. * For testing with multiple users, just start several instances of your webbrowser. * */ #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) #define _CRT_SECURE_NO_WARNINGS #endif #include "platform.h" #include #include #include #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) /* Workaround for Windows systems, because the NuGet version of pthreads is buggy. This is a simple replacement. It doesn't offer all functions of pthread, but has everything, what is required for this example. See: https://github.com/coapp-packages/pthreads/issues/2 */ #include "pthread_windows.h" /* On Windows we will use stricmp instead of strcasecmp (strcasecmp is undefined there). */ #define strcasecmp stricmp #else /* On Unix systems we can use pthread. */ #include #endif /* * Specify with this constant whether or not to use HTTPS. * 0 means HTTP, 1 means HTTPS. * Please note that you must enter a valid private key/certificate pair * in the main procedure to running this example with HTTPS. */ #define USE_HTTPS 0 /** * This is the main website. * The HTML, CSS and JavaScript code is all in there. */ #define PAGE \ "" \ "" \ "" \ "" \ "libmicrohttpd websocket chatserver demo" \ "" \ "" \ "" \ "" \ "" #define PAGE_NOT_FOUND \ "404 Not Found" #define PAGE_INVALID_WEBSOCKET_REQUEST \ "Invalid WebSocket request!" /** * This struct is used to keep the data of a connected chat user. * It is passed to the socket-receive thread (connecteduser_receive_messages) as well as to * the socket-send thread (connecteduser_send_messages). * It can also be accessed via the global array users (mutex protected). */ struct ConnectedUser { /* the TCP/IP socket for reading/writing */ MHD_socket fd; /* the UpgradeResponseHandle of libmicrohttpd (needed for closing the socket) */ struct MHD_UpgradeResponseHandle *urh; /* the websocket encode/decode stream */ struct MHD_WebSocketStream *ws; /* the possibly read data at the start (only used once) */ char *extra_in; size_t extra_in_size; /* the unique user id (counting from 1, ids will never be re-used) */ size_t user_id; /* the current user name */ char *user_name; size_t user_name_len; /* the zero-based index of the next message; may be decremented when old messages are deleted */ size_t next_message_index; /* specifies whether the websocket shall be closed (1) or not (0) */ int disconnect; /* condition variable to wake up the sender of this connection */ pthread_cond_t wake_up_sender; /* mutex to ensure that no send actions are mixed (sending can be done by send and recv thread; may not be simultaneously locked with chat_mutex by the same thread) */ pthread_mutex_t send_mutex; /* specifies whether a ping shall be executed (1), is being executed (2) or no ping is pending (0) */ int ping_status; /* the start time of the ping, if a ping is running */ struct timespec ping_start; /* the message used for the ping (must match the pong response)*/ char ping_message[128]; /* the length of the ping message (may not exceed 125) */ size_t ping_message_len; /* the numeric ping message suffix to detect ping messages, which are too old */ int ping_counter; }; /** * A single message, which has been send via the chat. * This can be text, an image or a command. */ struct Message { /* The user id of the sender. This is 0 if it is a system message- */ size_t from_user_id; /* The user id of the recipient. This is 0 if every connected user shall receive it */ size_t to_user_id; /* The data of the message. */ char *data; size_t data_len; /* Specifies whether the data is UTF-8 encoded text (0) or binary data (1) */ int is_binary; }; /* the unique user counter for new users (only accessed by main thread) */ size_t unique_user_id = 0; /* the chat data (users and messages; may be accessed by all threads, but is protected by mutex) */ pthread_mutex_t chat_mutex; struct ConnectedUser **users = NULL; size_t user_count = 0; struct Message **messages = NULL; size_t message_count = 0; /* specifies whether all websockets must close (1) or not (0) */ volatile int disconnect_all = 0; /* a counter for cleaning old messages (each 10 messages we will try to clean the list */ int clean_count = 0; #define CLEANUP_LIMIT 10 /** * Change socket to blocking. * * @param fd the socket to manipulate */ static void make_blocking (MHD_socket fd) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (fd, F_GETFL); if (-1 == flags) abort (); if ((flags & ~O_NONBLOCK) != flags) if (-1 == fcntl (fd, F_SETFL, flags & ~O_NONBLOCK)) abort (); #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 0; if (0 != ioctlsocket (fd, (int) FIONBIO, &flags)) abort (); #endif /* MHD_WINSOCK_SOCKETS */ } /** * Sends all data of the given buffer via the TCP/IP socket * * @param fd The TCP/IP socket which is used for sending * @param buf The buffer with the data to send * @param len The length in bytes of the data in the buffer */ static void send_all (struct ConnectedUser *cu, const char *buf, size_t len) { ssize_t ret; size_t off; if (0 != pthread_mutex_lock (&cu->send_mutex)) abort (); for (off = 0; off < len; off += ret) { ret = send (cu->fd, &buf[off], (int) (len - off), 0); if (0 > ret) { if (EAGAIN == errno) { ret = 0; continue; } break; } if (0 == ret) break; } if (0 != pthread_mutex_unlock (&cu->send_mutex)) abort (); } /** * Adds a new chat message to the list of messages. * * @param from_user_id the user id of the sender (0 means system) * @param to_user_id the user id of the recipiend (0 means everyone) * @param data the data to send (UTF-8 text or binary; will be copied) * @param data_len the length of the data to send * @param is_binary specifies whether the data is UTF-8 text (0) or binary (1) * @param needs_lock specifies whether the caller has already locked the global chat mutex (0) or * if this procedure needs to lock it (1) * * @return 0 on success, other values on error */ static int chat_addmessage (size_t from_user_id, size_t to_user_id, char *data, size_t data_len, int is_binary, int needs_lock) { /* allocate the buffer and fill it with data */ struct Message *message = (struct Message *) malloc (sizeof (struct Message)); if (NULL == message) return 1; memset (message, 0, sizeof (struct Message)); message->from_user_id = from_user_id; message->to_user_id = to_user_id; message->is_binary = is_binary; message->data_len = data_len; message->data = malloc (data_len + 1); if (NULL == message->data) { free (message); return 1; } memcpy (message->data, data, data_len); message->data[data_len] = 0; /* lock the global mutex if needed */ if (0 != needs_lock) { if (0 != pthread_mutex_lock (&chat_mutex)) abort (); } /* add the new message to the global message list */ size_t message_count_ = message_count + 1; struct Message **messages_ = (struct Message **) realloc (messages, message_count_ * sizeof (struct Message *)); if (NULL == messages_) { free (message); if (0 != needs_lock) if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); return 1; } messages_[message_count] = message; messages = messages_; message_count = message_count_; /* inform the sender threads about the new message */ for (size_t i = 0; i < user_count; ++i) pthread_cond_signal (&users[i]->wake_up_sender); /* unlock the global mutex if needed */ if (0 != needs_lock) { if (0 != needs_lock) if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); } return 0; } /** * Cleans up old messages * * @param needs_lock specifies whether the caller has already locked the global chat mutex (0) or * if this procedure needs to lock it (1) * @return 0 on success, other values on error */ static int chat_clearmessages (int needs_lock) { /* lock the global mutex if needed */ if (0 != needs_lock) { if (0 != pthread_mutex_lock (&chat_mutex)) abort (); } /* update the clean counter and check whether we need cleaning */ ++clean_count; if (CLEANUP_LIMIT > clean_count) { /* no cleanup required */ if (0 != needs_lock) { if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); } return 0; } clean_count = 0; /* check whether we got any messages (without them no cleaning is required */ if (0 < message_count) { /* then check whether we got any connected users */ if (0 < user_count) { /* determine the minimum index for the next message of all connected users */ size_t min_message = users[0]->next_message_index; for (size_t i = 1; i < user_count; ++i) { if (min_message > users[i]->next_message_index) min_message = users[i]->next_message_index; } if (0 < min_message) { /* remove all messages with index below min_message and update the message indices of the users */ for (size_t i = 0; i < min_message; ++i) { free (messages[i]->data); free (messages[i]); } for (size_t i = min_message; i < message_count; ++i) messages[i - min_message] = messages[i]; message_count -= min_message; for (size_t i = 0; i < user_count; ++i) users[i]->next_message_index -= min_message; } } else { /* without connected users, simply remove all messages */ for (size_t i = 0; i < message_count; ++i) { free (messages[i]->data); free (messages[i]); } free (messages); messages = NULL; message_count = 0; } } /* unlock the global mutex if needed */ if (0 != needs_lock) { if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); } return 0; } /** * Adds a new chat user to the global user list. * This will be called at the start of connecteduser_receive_messages. * * @param cu The connected user * @return 0 on success, other values on error */ static int chat_adduser (struct ConnectedUser *cu) { /* initialize the notification message of the new user */ char user_index[32]; snprintf (user_index, 32, "%d", (int) cu->user_id); size_t user_index_len = strlen (user_index); size_t data_len = user_index_len + cu->user_name_len + 9; char *data = (char *) malloc (data_len + 1); if (NULL == data) return 1; strcpy (data, "useradd|"); strcat (data, user_index); strcat (data, "|"); strcat (data, cu->user_name); /* lock the mutex */ if (0 != pthread_mutex_lock (&chat_mutex)) abort (); /* inform the other chat users about the new user */ if (0 != chat_addmessage (0, 0, data, data_len, 0, 0)) { free (data); if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); return 1; } free (data); /* add the new user to the list */ size_t user_count_ = user_count + 1; struct ConnectedUser **users_ = (struct ConnectedUser **) realloc (users, user_count_ * sizeof (struct ConnectedUser *)); if (NULL == users_) { /* realloc failed */ if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); return 1; } users_[user_count] = cu; users = users_; user_count = user_count_; /* Initialize the next message index to the current message count. */ /* This will skip all old messages for this new connected user. */ cu->next_message_index = message_count; /* unlock the mutex */ if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); return 0; } /** * Removes a chat user from the global user list. * * @param cu The connected user * @return 0 on success, other values on error */ static int chat_removeuser (struct ConnectedUser *cu) { char user_index[32]; /* initialize the chat message for the removed user */ snprintf (user_index, 32, "%d", (int) cu->user_id); size_t user_index_len = strlen (user_index); size_t data_len = user_index_len + 9; char *data = (char *) malloc (data_len + 1); if (NULL == data) return 1; strcpy (data, "userdel|"); strcat (data, user_index); strcat (data, "|"); /* lock the mutex */ if (0 != pthread_mutex_lock (&chat_mutex)) abort (); /* inform the other chat users that the user is gone */ int got_error = 0; if (0 != chat_addmessage (0, 0, data, data_len, 0, 0)) { free (data); got_error = 1; } /* remove the user from the list */ int found = 0; for (size_t i = 0; i < user_count; ++i) { if (cu == users[i]) { found = 1; for (size_t j = i + 1; j < user_count; ++j) { users[j - 1] = users[j]; } --user_count; break; } } if (0 == found) got_error = 1; /* unlock the mutex */ if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); return got_error; } /** * Renames a chat user * * @param cu The connected user * @param new_name The new user name. On success this pointer will be taken. * @param new_name_len The length of the new name * @return 0 on success, other values on error. 2 means name already in use. */ static int chat_renameuser (struct ConnectedUser *cu, char *new_name, size_t new_name_len) { /* lock the mutex */ if (0 != pthread_mutex_lock (&chat_mutex)) abort (); /* check whether the name is already in use */ for (size_t i = 0; i < user_count; ++i) { if (cu != users[i]) { if ((users[i]->user_name_len == new_name_len) && (0 == strcasecmp (users[i]->user_name, new_name))) { if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); return 2; } } } /* generate the notification message */ char user_index[32]; snprintf (user_index, 32, "%d", (int) cu->user_id); size_t user_index_len = strlen (user_index); size_t data_len = user_index_len + new_name_len + 10; char *data = (char *) malloc (data_len + 1); if (NULL == data) return 1; strcpy (data, "username|"); strcat (data, user_index); strcat (data, "|"); strcat (data, new_name); /* inform the other chat users about the new name */ if (0 != chat_addmessage (0, 0, data, data_len, 0, 0)) { free (data); if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); return 1; } free (data); /* accept the new user name */ free (cu->user_name); cu->user_name = new_name; cu->user_name_len = new_name_len; /* unlock the mutex */ if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); return 0; } /** * Parses received data from the TCP/IP socket with the websocket stream * * @param cu The connected user * @param new_name The new user name * @param new_name_len The length of the new name * @return 0 on success, other values on error */ static int connecteduser_parse_received_websocket_stream (struct ConnectedUser *cu, char *buf, size_t buf_len) { size_t buf_offset = 0; while (buf_offset < buf_len) { size_t new_offset = 0; char *frame_data = NULL; size_t frame_len = 0; int status = MHD_websocket_decode (cu->ws, buf + buf_offset, buf_len - buf_offset, &new_offset, &frame_data, &frame_len); if (0 > status) { /* an error occurred and the connection must be closed */ if (NULL != frame_data) { /* depending on the WebSocket flag */ /* MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR */ /* close frames might be generated on errors */ send_all (cu, frame_data, frame_len); MHD_websocket_free (cu->ws, frame_data); } return 1; } else { buf_offset += new_offset; if (0 < status) { /* the frame is complete */ switch (status) { case MHD_WEBSOCKET_STATUS_TEXT_FRAME: case MHD_WEBSOCKET_STATUS_BINARY_FRAME: /** * a text or binary frame has been received. * in this chat server example we use a simple protocol where * the JavaScript added a prefix like "||data". * Some examples: * "||test" means a regular chat message to everyone with the message "test". * "private|1|secret" means a private chat message to user with id 1 with the message "secret". * "name||MyNewName" means that the user requests a rename to "MyNewName" * "ping|1|" means that the user with id 1 shall get a ping * * Binary data is handled here like text data. * The difference in the data is only checked by the JavaScript. */ { size_t command = 1000; size_t from_user_id = cu->user_id; size_t to_user_id = 0; size_t i; /* parse the command */ for (i = 0; i < frame_len; ++i) { if ('|' == frame_data[i]) { frame_data[i] = 0; ++i; break; } } if (0 < i) { if (i == 1) { /* no command means regular message */ command = 0; } else if (0 == strcasecmp (frame_data, "private")) { /* private means private message */ command = 1; } else if (0 == strcasecmp (frame_data, "name")) { /* name means chat user rename */ command = 2; } else if (0 == strcasecmp (frame_data, "ping")) { /* ping means a ping request */ command = 3; } else { /* no other commands supported, so this means invalid */ command = 1000; } } /* parse the to_user_id, if given */ size_t j = i; for (; j < frame_len; ++j) { if ('|' == frame_data[j]) { frame_data[j] = 0; ++j; break; } } if (i + 1 < j) { to_user_id = (size_t) atoi (frame_data + i); } /* decide via the command what action to do */ if (frame_len >= j) { int is_binary = (MHD_WEBSOCKET_STATUS_BINARY_FRAME == status ? 1 : 0); switch (command) { case 0: /* regular chat message */ { /** * Generate the message for the message list. * Regular chat messages get the command "regular". * After that we add the from_user_id, followed by the content. * The content must always be copied with memcpy instead of strcat, * because the data (binary as well as UTF-8 encoded) is allowed * to contain the NUL character. * However we will add a terminating NUL character, * which is not included in the data length * (and thus will not be send to the recipients). * This is useful for debugging with an IDE. */ char user_index[32]; snprintf (user_index, 32, "%d", (int) cu->user_id); size_t user_index_len = strlen (user_index); size_t data_len = user_index_len + frame_len - j + 9; char *data = (char *) malloc (data_len + 1); if (NULL != data) { strcpy (data, "regular|"); strcat (data, user_index); strcat (data, "|"); size_t offset = strlen (data); memcpy (data + offset, frame_data + j, frame_len - j); data[data_len] = 0; /* add the chat message to the global list */ chat_addmessage (from_user_id, 0, data, data_len, is_binary, 1); free (data); } } break; case 1: /* private chat message */ if (0 != to_user_id) { /** * Generate the message for the message list. * This is similar to the code for regular messages above. * The difference is the prefix "private" */ char user_index[32]; snprintf (user_index, 32, "%d", (int) cu->user_id); size_t user_index_len = strlen (user_index); size_t data_len = user_index_len + frame_len - j + 9; char *data = (char *) malloc (data_len + 1); if (NULL != data) { strcpy (data, "private|"); strcat (data, user_index); strcat (data, "|"); size_t offset = strlen (data); memcpy (data + offset, frame_data + j, frame_len - j); data[data_len] = 0; /* add the chat message to the global list */ chat_addmessage (from_user_id, to_user_id, data, data_len, is_binary, 1); free (data); } } break; case 2: /* rename */ { /* check whether the new name is valid and allocate a new buffer for it */ size_t new_name_len = frame_len - j; if (0 == new_name_len) { chat_addmessage (0, from_user_id, "error||Your new name is invalid. You haven't been renamed.", 58, 0, 1); break; } char *new_name = (char *) malloc (new_name_len + 1); if (NULL == new_name) { chat_addmessage (0, from_user_id, "error||Error while renaming. You haven't been renamed.", 54, 0, 1); break; } new_name[new_name_len] = 0; for (size_t k = 0; k < new_name_len; ++k) { char c = frame_data[j + k]; if ((32 >= c) || (c >= 127)) { free (new_name); new_name = NULL; chat_addmessage (0, from_user_id, "error||Your new name contains invalid characters. You haven't been renamed.", 75, 0, 1); break; } new_name[k] = c; } if (NULL == new_name) break; /* rename the user */ int rename_result = chat_renameuser (cu, new_name, new_name_len); if (0 != rename_result) { /* the buffer will only be freed if no rename was possible */ free (new_name); if (2 == rename_result) { chat_addmessage (0, from_user_id, "error||Your new name is already in use by another user. You haven't been renamed.", 81, 0, 1); } else { chat_addmessage (0, from_user_id, "error||Error while renaming. You haven't been renamed.", 54, 0, 1); } } } break; case 3: /* ping */ { if (0 != pthread_mutex_lock (&chat_mutex)) abort (); /* check whether the to_user exists */ struct ConnectedUser *ping_user = NULL; for (size_t k = 0; k < user_count; ++k) { if (users[k]->user_id == to_user_id) { ping_user = users[k]; break; } } if (NULL == ping_user) { chat_addmessage (0, from_user_id, "error||Couldn't find the specified user for pinging.", 52, 0, 0); } else { /* if pinging is requested, */ /* we mark the user and inform the sender about this */ if (0 == ping_user->ping_status) { ping_user->ping_status = 1; pthread_cond_signal (&ping_user->wake_up_sender); } } if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); } break; default: /* invalid command */ chat_addmessage (0, from_user_id, "error||You sent an invalid command.", 35, 0, 1); break; } } } MHD_websocket_free (cu->ws, frame_data); return 0; case MHD_WEBSOCKET_STATUS_CLOSE_FRAME: /* if we receive a close frame, we will respond with one */ MHD_websocket_free (cu->ws, frame_data); { char *result = NULL; size_t result_len = 0; int er = MHD_websocket_encode_close (cu->ws, MHD_WEBSOCKET_CLOSEREASON_REGULAR, NULL, 0, &result, &result_len); if (MHD_WEBSOCKET_STATUS_OK == er) { send_all (cu, result, result_len); MHD_websocket_free (cu->ws, result); } } return 1; case MHD_WEBSOCKET_STATUS_PING_FRAME: /* if we receive a ping frame, we will respond */ /* with the corresponding pong frame */ { char *pong = NULL; size_t pong_len = 0; int er = MHD_websocket_encode_pong (cu->ws, frame_data, frame_len, &pong, &pong_len); MHD_websocket_free (cu->ws, frame_data); if (MHD_WEBSOCKET_STATUS_OK == er) { send_all (cu, pong, pong_len); MHD_websocket_free (cu->ws, pong); } } return 0; case MHD_WEBSOCKET_STATUS_PONG_FRAME: /* if we receive a pong frame, */ /* we will check whether we requested this frame and */ /* whether it is the last requested pong */ if (2 == cu->ping_status) { cu->ping_status = 0; struct timespec now; timespec_get (&now, TIME_UTC); if ((cu->ping_message_len == frame_len) && (0 == strcmp (frame_data, cu->ping_message))) { int ping = (int) (((int64_t) (now.tv_sec - cu->ping_start.tv_sec)) * 1000 + ((int64_t) (now.tv_nsec - cu->ping_start.tv_nsec)) / 1000000); char result_text[240]; strcpy (result_text, "ping|"); snprintf (result_text + 5, 235, "%d", (int) cu->user_id); strcat (result_text, "|"); snprintf (result_text + strlen (result_text), 240 - strlen (result_text), "%d", (int) ping); chat_addmessage (0, 0, result_text, strlen (result_text), 0, 1); } } MHD_websocket_free (cu->ws, frame_data); return 0; default: /* This case should really never happen, */ /* because there are only five types of (finished) websocket frames. */ /* If it is ever reached, it means that there is memory corruption. */ MHD_websocket_free (cu->ws, frame_data); return 1; } } } } return 0; } /** * Sends messages from the message list over the TCP/IP socket * after encoding it with the websocket stream. * This is also used for server-side actions, * because the thread for receiving messages waits for * incoming data and cannot be woken up. * But the sender thread can be woken up easily. * * @param cls The connected user * @return Always NULL */ static void * connecteduser_send_messages (void *cls) { struct ConnectedUser *cu = cls; /* the main loop of sending messages requires to lock the mutex */ if (0 != pthread_mutex_lock (&chat_mutex)) abort (); for (;;) { /* loop while not all messages processed */ int all_messages_read = 0; while (0 == all_messages_read) { if (1 == disconnect_all) { /* the application closes and want that we disconnect all users */ struct MHD_UpgradeResponseHandle *urh = cu->urh; if (NULL != urh) { /* Close the TCP/IP socket. */ /* This will also wake-up the waiting receive-thread for this connected user. */ cu->urh = NULL; MHD_upgrade_action (urh, MHD_UPGRADE_ACTION_CLOSE); } if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); return NULL; } else if (1 == cu->disconnect) { /* The sender thread shall close. */ /* This is only requested by the receive thread, so we can just leave. */ if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); return NULL; } else if (1 == cu->ping_status) { /* A pending ping is requested */ ++cu->ping_counter; strcpy (cu->ping_message, "libmicrohttpdchatserverpingdata"); snprintf (cu->ping_message + 31, 97, "%d", (int) cu->ping_counter); cu->ping_message_len = strlen (cu->ping_message); char *frame_data = NULL; size_t frame_len = 0; int er = MHD_websocket_encode_ping (cu->ws, cu->ping_message, cu->ping_message_len, &frame_data, &frame_len); if (MHD_WEBSOCKET_STATUS_OK == er) { cu->ping_status = 2; timespec_get (&cu->ping_start, TIME_UTC); /* send the data via the TCP/IP socket and */ /* unlock the mutex while sending */ if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); send_all (cu, frame_data, frame_len); if (0 != pthread_mutex_lock (&chat_mutex)) abort (); } MHD_websocket_free (cu->ws, frame_data); } else if (cu->next_message_index < message_count) { /* a chat message or command is pending */ char *frame_data = NULL; size_t frame_len = 0; int er = 0; { struct Message *msg = messages[cu->next_message_index]; if ((0 == msg->to_user_id) || (cu->user_id == msg->to_user_id) || (cu->user_id == msg->from_user_id) ) { if (0 == msg->is_binary) { er = MHD_websocket_encode_text (cu->ws, msg->data, msg->data_len, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame_data, &frame_len, NULL); } else { er = MHD_websocket_encode_binary (cu->ws, msg->data, msg->data_len, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame_data, &frame_len); } } } ++cu->next_message_index; /* send the data via the TCP/IP socket and */ /* unlock the mutex while sending */ if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); if (MHD_WEBSOCKET_STATUS_OK == er) { send_all (cu, frame_data, frame_len); } MHD_websocket_free (cu->ws, frame_data); if (0 != pthread_mutex_lock (&chat_mutex)) abort (); /* check whether there are still pending messages */ all_messages_read = (cu->next_message_index < message_count) ? 0 : 1; } else { all_messages_read = 1; } } /* clear old messages */ chat_clearmessages (0); /* Wait for wake up. */ /* This will automatically unlock the mutex while waiting and */ /* lock the mutex after waiting */ pthread_cond_wait (&cu->wake_up_sender, &chat_mutex); } return NULL; } /** * Receives messages from the TCP/IP socket and * initializes the connected user. * * @param cls The connected user * @return Always NULL */ static void * connecteduser_receive_messages (void *cls) { struct ConnectedUser *cu = cls; char buf[128]; ssize_t got; int result; /* make the socket blocking */ make_blocking (cu->fd); /* generate the user name */ { char user_name[32]; strcpy (user_name, "User"); snprintf (user_name + 4, 28, "%d", (int) cu->user_id); cu->user_name_len = strlen (user_name); cu->user_name = malloc (cu->user_name_len + 1); if (NULL == cu->user_name) { free (cu->extra_in); free (cu); MHD_upgrade_action (cu->urh, MHD_UPGRADE_ACTION_CLOSE); return NULL; } strcpy (cu->user_name, user_name); } /* initialize the wake-up-sender condition variable */ if (0 != pthread_cond_init (&cu->wake_up_sender, NULL)) { MHD_upgrade_action (cu->urh, MHD_UPGRADE_ACTION_CLOSE); free (cu->user_name); free (cu->extra_in); free (cu); return NULL; } /* initialize the send mutex */ if (0 != pthread_mutex_init (&cu->send_mutex, NULL)) { MHD_upgrade_action (cu->urh, MHD_UPGRADE_ACTION_CLOSE); pthread_cond_destroy (&cu->wake_up_sender); free (cu->user_name); free (cu->extra_in); free (cu); return NULL; } /* add the user to the chat user list */ chat_adduser (cu); /* initialize the web socket stream for encoding/decoding */ result = MHD_websocket_stream_init (&cu->ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0); if (MHD_WEBSOCKET_STATUS_OK != result) { chat_removeuser (cu); pthread_cond_destroy (&cu->wake_up_sender); pthread_mutex_destroy (&cu->send_mutex); MHD_upgrade_action (cu->urh, MHD_UPGRADE_ACTION_CLOSE); free (cu->user_name); free (cu->extra_in); free (cu); return NULL; } /* send a list of all currently connected users (bypassing the messaging system) */ { struct UserInit { char *user_init; size_t user_init_len; }; struct UserInit *init_users = NULL; size_t init_users_len = 0; /* first collect all users without sending (so the mutex isn't locked too long) */ if (0 != pthread_mutex_lock (&chat_mutex)) abort (); if (0 < user_count) { init_users = (struct UserInit *) malloc (user_count * sizeof (struct UserInit)); if (NULL != init_users) { init_users_len = user_count; for (size_t i = 0; i < user_count; ++i) { char user_index[32]; snprintf (user_index, 32, "%d", (int) users[i]->user_id); size_t user_index_len = strlen (user_index); struct UserInit iu; iu.user_init_len = user_index_len + users[i]->user_name_len + 10; iu.user_init = (char *) malloc (iu.user_init_len + 1); if (NULL != iu.user_init) { strcpy (iu.user_init, "userinit|"); strcat (iu.user_init, user_index); strcat (iu.user_init, "|"); if (0 < users[i]->user_name_len) strcat (iu.user_init, users[i]->user_name); } init_users[i] = iu; } } } if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); /* then send all users to the connected client */ for (size_t i = 0; i < init_users_len; ++i) { char *frame_data = NULL; size_t frame_len = 0; if ((0 < init_users[i].user_init_len) && (NULL != init_users[i].user_init) ) { int status = MHD_websocket_encode_text (cu->ws, init_users[i].user_init, init_users[i].user_init_len, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame_data, &frame_len, NULL); if (MHD_WEBSOCKET_STATUS_OK == status) { send_all (cu, frame_data, frame_len); MHD_websocket_free (cu->ws, frame_data); } free (init_users[i].user_init); } } free (init_users); } /* send the welcome message to the user (bypassing the messaging system) */ { char *frame_data = NULL; size_t frame_len = 0; const char *welcome_msg = "moderator||" \ "Welcome to the libmicrohttpd WebSocket chatserver example.\n" \ "Supported commands are:\n" \ " /m - sends a private message to the specified user\n" \ " /ping - sends a ping to the specified user\n" \ " /name - changes your name to the specified name\n" \ " /disconnect - disconnects your websocket\n\n" \ "All messages, which does not start with a slash, " \ "are regular messages and will be sent to the selected user.\n\n" \ "Have fun!"; MHD_websocket_encode_text (cu->ws, welcome_msg, strlen (welcome_msg), MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame_data, &frame_len, NULL); send_all (cu, frame_data, frame_len); MHD_websocket_free (cu->ws, frame_data); } /* start the message-send thread */ pthread_t pt; if (0 != pthread_create (&pt, NULL, &connecteduser_send_messages, cu)) abort (); /* start by parsing extra data MHD may have already read, if any */ if (0 != cu->extra_in_size) { if (0 != connecteduser_parse_received_websocket_stream (cu, cu->extra_in, cu->extra_in_size)) { chat_removeuser (cu); if (0 != pthread_mutex_lock (&chat_mutex)) abort (); cu->disconnect = 1; pthread_cond_signal (&cu->wake_up_sender); if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); pthread_join (pt, NULL); struct MHD_UpgradeResponseHandle *urh = cu->urh; if (NULL != urh) { cu->urh = NULL; MHD_upgrade_action (urh, MHD_UPGRADE_ACTION_CLOSE); } pthread_cond_destroy (&cu->wake_up_sender); pthread_mutex_destroy (&cu->send_mutex); MHD_websocket_stream_free (cu->ws); free (cu->user_name); free (cu->extra_in); free (cu); return NULL; } free (cu->extra_in); cu->extra_in = NULL; } /* the main loop for receiving data */ while (1) { got = recv (cu->fd, buf, sizeof (buf), 0); if (0 >= got) { /* the TCP/IP socket has been closed */ break; } if (0 < got) { if (0 != connecteduser_parse_received_websocket_stream (cu, buf, (size_t) got)) { /* A websocket protocol error occurred */ chat_removeuser (cu); if (0 != pthread_mutex_lock (&chat_mutex)) abort (); cu->disconnect = 1; pthread_cond_signal (&cu->wake_up_sender); if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); pthread_join (pt, NULL); struct MHD_UpgradeResponseHandle *urh = cu->urh; if (NULL != urh) { cu->urh = NULL; MHD_upgrade_action (urh, MHD_UPGRADE_ACTION_CLOSE); } pthread_cond_destroy (&cu->wake_up_sender); pthread_mutex_destroy (&cu->send_mutex); MHD_websocket_stream_free (cu->ws); free (cu->user_name); free (cu); return NULL; } } } /* cleanup */ chat_removeuser (cu); if (0 != pthread_mutex_lock (&chat_mutex)) abort (); cu->disconnect = 1; pthread_cond_signal (&cu->wake_up_sender); if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); pthread_join (pt, NULL); struct MHD_UpgradeResponseHandle *urh = cu->urh; if (NULL != urh) { cu->urh = NULL; MHD_upgrade_action (urh, MHD_UPGRADE_ACTION_CLOSE); } pthread_cond_destroy (&cu->wake_up_sender); pthread_mutex_destroy (&cu->send_mutex); MHD_websocket_stream_free (cu->ws); free (cu->user_name); free (cu); return NULL; } /** * Function called after a protocol "upgrade" response was sent * successfully and the socket should now be controlled by some * protocol other than HTTP. * * Any data already received on the socket will be made available in * @e extra_in. This can happen if the application sent extra data * before MHD send the upgrade response. The application should * treat data from @a extra_in as if it had read it from the socket. * * Note that the application must not close() @a sock directly, * but instead use #MHD_upgrade_action() for special operations * on @a sock. * * Data forwarding to "upgraded" @a sock will be started as soon * as this function return. * * Except when in 'thread-per-connection' mode, implementations * of this function should never block (as it will still be called * from within the main event loop). * * @param cls closure, whatever was given to #MHD_create_response_for_upgrade(). * @param connection original HTTP connection handle, * giving the function a last chance * to inspect the original HTTP request * @param req_cls last value left in `req_cls` of the `MHD_AccessHandlerCallback` * @param extra_in if we happened to have read bytes after the * HTTP header already (because the client sent * more than the HTTP header of the request before * we sent the upgrade response), * these are the extra bytes already read from @a sock * by MHD. The application should treat these as if * it had read them from @a sock. * @param extra_in_size number of bytes in @a extra_in * @param sock socket to use for bi-directional communication * with the client. For HTTPS, this may not be a socket * that is directly connected to the client and thus certain * operations (TCP-specific setsockopt(), getsockopt(), etc.) * may not work as expected (as the socket could be from a * socketpair() or a TCP-loopback). The application is expected * to perform read()/recv() and write()/send() calls on the socket. * The application may also call shutdown(), but must not call * close() directly. * @param urh argument for #MHD_upgrade_action()s on this @a connection. * Applications must eventually use this callback to (indirectly) * perform the close() action on the @a sock. */ static void upgrade_handler (void *cls, struct MHD_Connection *connection, void *req_cls, const char *extra_in, size_t extra_in_size, MHD_socket fd, struct MHD_UpgradeResponseHandle *urh) { struct ConnectedUser *cu; pthread_t pt; (void) cls; /* Unused. Silent compiler warning. */ (void) connection; /* Unused. Silent compiler warning. */ (void) req_cls; /* Unused. Silent compiler warning. */ /* This callback must return as soon as possible. */ /* allocate new connected user */ cu = malloc (sizeof (struct ConnectedUser)); if (NULL == cu) abort (); memset (cu, 0, sizeof (struct ConnectedUser)); if (0 != extra_in_size) { cu->extra_in = malloc (extra_in_size); if (NULL == cu->extra_in) abort (); memcpy (cu->extra_in, extra_in, extra_in_size); } cu->extra_in_size = extra_in_size; cu->fd = fd; cu->urh = urh; cu->user_id = ++unique_user_id; cu->user_name = NULL; cu->user_name_len = 0; /* create thread for the new connected user */ if (0 != pthread_create (&pt, NULL, &connecteduser_receive_messages, cu)) abort (); pthread_detach (pt); } /** * Function called by the MHD_daemon when the client tries to access a page. * * This is used to provide the main page * (in this example HTML + CSS + JavaScript is all in the same file) * and to initialize a websocket connection. * The rules for the initialization of a websocket connection * are listed near the URL check of "/ChatServerWebSocket". * * @param cls closure, whatever was given to #MHD_start_daemon(). * @param connection The HTTP connection handle * @param url The requested URL * @param method The request method (typically "GET") * @param version The HTTP version * @param upload_data Given upload data for POST requests * @param upload_data_size The size of the upload data * @param req_cls A pointer for request specific data * @return MHD_YES on success or MHD_NO on error. */ static enum MHD_Result access_handler (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; int ret; (void) cls; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ if (0 == strcmp (url, "/")) { /* Default page for visiting the server */ struct MHD_Response *response; response = MHD_create_response_from_buffer_static (strlen (PAGE), PAGE); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); } else if (0 == strcmp (url, "/ChatServerWebSocket")) { /** * The path for the chat has been accessed. * For a valid WebSocket request, at least five headers are required: * 1. "Host: " * 2. "Connection: Upgrade" * 3. "Upgrade: websocket" * 4. "Sec-WebSocket-Version: 13" * 5. "Sec-WebSocket-Key: " * Values are compared in a case-insensitive manner. * Furthermore it must be a HTTP/1.1 or higher GET request. * See: https://tools.ietf.org/html/rfc6455#section-4.2.1 * * To make this example portable we skip the Host check */ char is_valid = 1; const char *value = NULL; char sec_websocket_accept[29]; /* check whether an websocket upgrade is requested */ if (0 != MHD_websocket_check_http_version (version)) { is_valid = 0; } value = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONNECTION); if (0 != MHD_websocket_check_connection_header (value)) { is_valid = 0; } value = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_UPGRADE); if (0 != MHD_websocket_check_upgrade_header (value)) { is_valid = 0; } value = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_SEC_WEBSOCKET_VERSION); if (0 != MHD_websocket_check_version_header (value)) { is_valid = 0; } value = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_SEC_WEBSOCKET_KEY); if (0 != MHD_websocket_create_accept_header (value, sec_websocket_accept)) { is_valid = 0; } if (1 == is_valid) { /* create the response for upgrade */ response = MHD_create_response_for_upgrade (&upgrade_handler, NULL); /** * For the response we need at least the following headers: * 1. "Connection: Upgrade" * 2. "Upgrade: websocket" * 3. "Sec-WebSocket-Accept: " * The value for Sec-WebSocket-Accept can be generated with MHD_websocket_create_accept_header. * It requires the value of the Sec-WebSocket-Key header of the request. * See also: https://tools.ietf.org/html/rfc6455#section-4.2.2 */ MHD_add_response_header (response, MHD_HTTP_HEADER_UPGRADE, "websocket"); MHD_add_response_header (response, MHD_HTTP_HEADER_SEC_WEBSOCKET_ACCEPT, sec_websocket_accept); ret = MHD_queue_response (connection, MHD_HTTP_SWITCHING_PROTOCOLS, response); MHD_destroy_response (response); } else { /* return error page */ struct MHD_Response *response; response = MHD_create_response_from_buffer_static ( \ strlen (PAGE_INVALID_WEBSOCKET_REQUEST), PAGE_INVALID_WEBSOCKET_REQUEST); ret = MHD_queue_response (connection, MHD_HTTP_BAD_REQUEST, response); MHD_destroy_response (response); } } else { struct MHD_Response *response; response = MHD_create_response_from_buffer_static (strlen (PAGE_NOT_FOUND), PAGE_NOT_FOUND); ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); MHD_destroy_response (response); } return ret; } /** * The main routine for this example * * This starts the daemon and waits for a key hit. * After this it will shutdown the daemon. */ int main (int argc, char *const *argv) { (void) argc; /* Unused. Silent compiler warning. */ (void) argv; /* Unused. Silent compiler warning. */ struct MHD_Daemon *d; if (0 != pthread_mutex_init (&chat_mutex, NULL)) return 1; #if USE_HTTPS == 1 const char private_key[] = "TODO: Enter your key in PEM format here"; const char certificate[] = "TODO: Enter your certificate in PEM format here"; d = MHD_start_daemon (MHD_ALLOW_UPGRADE | MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_TLS, 443, NULL, NULL, &access_handler, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_HTTPS_MEM_KEY, private_key, MHD_OPTION_HTTPS_MEM_CERT, certificate, MHD_OPTION_END); #else d = MHD_start_daemon (MHD_ALLOW_UPGRADE | MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 80, NULL, NULL, &access_handler, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_END); #endif if (NULL == d) return 1; (void) getc (stdin); if (0 != pthread_mutex_lock (&chat_mutex)) abort (); disconnect_all = 1; for (size_t i = 0; i < user_count; ++i) pthread_cond_signal (&users[i]->wake_up_sender); if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); sleep (2); if (0 != pthread_mutex_lock (&chat_mutex)) abort (); for (size_t i = 0; i < user_count; ++i) { struct MHD_UpgradeResponseHandle *urh = users[i]->urh; if (NULL != urh) { users[i]->urh = NULL; MHD_upgrade_action (users[i]->urh, MHD_UPGRADE_ACTION_CLOSE); } } if (0 != pthread_mutex_unlock (&chat_mutex)) abort (); sleep (2); /* usually we should wait here in a safe way for all threads to disconnect, */ /* but we skip this in the example */ pthread_mutex_destroy (&chat_mutex); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/minimal_example_empty_tls.c0000644000175000017500000001655114441373361020066 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff (and other contributing authors) Copyright (C) 2021-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file minimal_example_empty_tls.c * @brief minimal example for how to use libmicrohttpd * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ response = MHD_create_response_empty (MHD_RF_NONE); ret = MHD_queue_response (connection, MHD_HTTP_NO_CONTENT, response); MHD_destroy_response (response); return ret; } /* test server key */ static const char srv_signed_key_pem[] = "-----BEGIN PRIVATE KEY-----\n\ MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCff7amw9zNSE+h\n\ rOMhBrzbbsJluUP3gmd8nOKY5MUimoPkxmAXfp2L0il+MPZT/ZEmo11q0k6J2jfG\n\ UBQ+oZW9ahNZ9gCDjbYlBblo/mqTai+LdeLO3qk53d0zrZKXvCO6sA3uKpG2WR+g\n\ +sNKxfYpIHCpanqBU6O+degIV/+WKy3nQ2Fwp7K5HUNj1u0pg0QQ18yf68LTnKFU\n\ HFjZmmaaopWki5wKSBieHivzQy6w+04HSTogHHRK/y/UcoJNSG7xnHmoPPo1vLT8\n\ CMRIYnSSgU3wJ43XBJ80WxrC2dcoZjV2XZz+XdQwCD4ZrC1ihykcAmiQA+sauNm7\n\ dztOMkGzAgMBAAECggEAIbKDzlvXDG/YkxnJqrKXt+yAmak4mNQuNP+YSCEdHSBz\n\ +SOILa6MbnvqVETX5grOXdFp7SWdfjZiTj2g6VKOJkSA7iKxHRoVf2DkOTB3J8np\n\ XZd8YaRdMGKVV1O2guQ20Dxd1RGdU18k9YfFNsj4Jtw5sTFTzHr1P0n9ybV9xCXp\n\ znSxVfRg8U6TcMHoRDJR9EMKQMO4W3OQEmreEPoGt2/+kMuiHjclxLtbwDxKXTLP\n\ pD0gdg3ibvlufk/ccKl/yAglDmd0dfW22oS7NgvRKUve7tzDxY1Q6O5v8BCnLFSW\n\ D+z4hS1PzooYRXRkM0xYudvPkryPyu+1kEpw3fNsoQKBgQDRfXJo82XQvlX8WPdZ\n\ Ts3PfBKKMVu3Wf8J3SYpuvYT816qR3ot6e4Ivv5ZCQkdDwzzBKe2jAv6JddMJIhx\n\ pkGHc0KKOodd9HoBewOd8Td++hapJAGaGblhL5beIidLKjXDjLqtgoHRGlv5Cojo\n\ zHa7Viel1eOPPcBumhp83oJ+mQKBgQDC6PmdETZdrW3QPm7ZXxRzF1vvpC55wmPg\n\ pRfTRM059jzRzAk0QiBgVp3yk2a6Ob3mB2MLfQVDgzGf37h2oO07s5nspSFZTFnM\n\ KgSjFy0xVOAVDLe+0VpbmLp1YUTYvdCNowaoTE7++5rpePUDu3BjAifx07/yaSB+\n\ W+YPOfOuKwKBgQCGK6g5G5qcJSuBIaHZ6yTZvIdLRu2M8vDral5k3793a6m3uWvB\n\ OFAh/eF9ONJDcD5E7zhTLEMHhXDs7YEN+QODMwjs6yuDu27gv97DK5j1lEsrLUpx\n\ XgRjAE3KG2m7NF+WzO1K74khWZaKXHrvTvTEaxudlO3X8h7rN3u7ee9uEQKBgQC2\n\ wI1zeTUZhsiFTlTPWfgppchdHPs6zUqq0wFQ5Zzr8Pa72+zxY+NJkU2NqinTCNsG\n\ ePykQ/gQgk2gUrt595AYv2De40IuoYk9BlTMuql0LNniwsbykwd/BOgnsSlFdEy8\n\ 0RQn70zOhgmNSg2qDzDklJvxghLi7zE5aV9//V1/ewKBgFRHHZN1a8q/v8AAOeoB\n\ ROuXfgDDpxNNUKbzLL5MO5odgZGi61PBZlxffrSOqyZoJkzawXycNtoBP47tcVzT\n\ QPq5ZOB3kjHTcN7dRLmPWjji9h4O3eHCX67XaPVMSWiMuNtOZIg2an06+jxGFhLE\n\ qdJNJ1DkyUc9dN2cliX4R+rG\n\ -----END PRIVATE KEY-----"; /* test server CA signed certificates */ static const char srv_signed_cert_pem[] = "-----BEGIN CERTIFICATE-----\n\ MIIFSzCCAzOgAwIBAgIBBDANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx\n\ DzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwGTW9zY293MRswGQYDVQQKDBJ0ZXN0\n\ LWxpYm1pY3JvaHR0cGQxITAfBgkqhkiG9w0BCQEWEm5vYm9keUBleGFtcGxlLm9y\n\ ZzEQMA4GA1UEAwwHdGVzdC1DQTAgFw0yMjA0MjAxODQzMDJaGA8yMTIyMDMyNjE4\n\ NDMwMlowZTELMAkGA1UEBhMCUlUxDzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwG\n\ TW9zY293MRswGQYDVQQKDBJ0ZXN0LWxpYm1pY3JvaHR0cGQxFzAVBgNVBAMMDnRl\n\ c3QtbWhkc2VydmVyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn3+2\n\ psPczUhPoazjIQa8227CZblD94JnfJzimOTFIpqD5MZgF36di9IpfjD2U/2RJqNd\n\ atJOido3xlAUPqGVvWoTWfYAg422JQW5aP5qk2ovi3Xizt6pOd3dM62Sl7wjurAN\n\ 7iqRtlkfoPrDSsX2KSBwqWp6gVOjvnXoCFf/list50NhcKeyuR1DY9btKYNEENfM\n\ n+vC05yhVBxY2ZpmmqKVpIucCkgYnh4r80MusPtOB0k6IBx0Sv8v1HKCTUhu8Zx5\n\ qDz6Nby0/AjESGJ0koFN8CeN1wSfNFsawtnXKGY1dl2c/l3UMAg+GawtYocpHAJo\n\ kAPrGrjZu3c7TjJBswIDAQABo4HmMIHjMAsGA1UdDwQEAwIFoDAMBgNVHRMBAf8E\n\ AjAAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMBMDEGA1UdEQQqMCiCDnRlc3QtbWhk\n\ c2VydmVyhwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMB0GA1UdDgQWBBQ57Z06WJae\n\ 8fJIHId4QGx/HsRgDDAoBglghkgBhvhCAQ0EGxYZVGVzdCBsaWJtaWNyb2h0dHBk\n\ IHNlcnZlcjARBglghkgBhvhCAQEEBAMCBkAwHwYDVR0jBBgwFoAUWHVDwKVqMcOF\n\ Nd0arI3/QB3W6SwwDQYJKoZIhvcNAQELBQADggIBAI7Lggm/XzpugV93H5+KV48x\n\ X+Ct8unNmPCSzCaI5hAHGeBBJpvD0KME5oiJ5p2wfCtK5Dt9zzf0S0xYdRKqU8+N\n\ aKIvPoU1hFixXLwTte1qOp6TviGvA9Xn2Fc4n36dLt6e9aiqDnqPbJgBwcVO82ll\n\ HJxVr3WbrAcQTB3irFUMqgAke/Cva9Bw79VZgX4ghb5EnejDzuyup4pHGzV10Myv\n\ hdg+VWZbAxpCe0S4eKmstZC7mWsFCLeoRTf/9Pk1kQ6+azbTuV/9QOBNfFi8QNyb\n\ 18jUjmm8sc2HKo8miCGqb2sFqaGD918hfkWmR+fFkzQ3DZQrT+eYbKq2un3k0pMy\n\ UySy8SRn1eadfab+GwBVb68I9TrPRMrJsIzysNXMX4iKYl2fFE/RSNnaHtPw0C8y\n\ B7memyxPRl+H2xg6UjpoKYh3+8e44/XKm0rNIzXjrwA8f8gnw2TbqmMDkj1YqGnC\n\ SCj5A27zUzaf2pT/YsnQXIWOJjVvbEI+YKj34wKWyTrXA093y8YI8T3mal7Kr9YM\n\ WiIyPts0/aVeziM0Gunglz+8Rj1VesL52FTurobqusPgM/AME82+qb/qnxuPaCKj\n\ OT1qAbIblaRuWqCsid8BzP7ZQiAnAWgMRSUg1gzDwSwRhrYQRRWAyn/Qipzec+27\n\ /w0gW9EVWzFhsFeGEssi\n\ -----END CERTIFICATE-----"; int main (int argc, char *const *argv) { struct MHD_Daemon *d; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } d = MHD_start_daemon (/* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_TLS, /* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_CLIENT_DISCIPLINE_LVL, (int) 1, /* Optionally, the gnutls_load_file() can be used to load the key and the certificate from file. */ MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_END); if (d == NULL) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/post_example.c0000644000175000017500000005436414556705750015341 /* This file is part of libmicrohttpd Copyright (C) 2011 Christian Grothoff (and other contributing authors) Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file post_example.c * @brief example for processing POST requests using libmicrohttpd * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include #include #include #include #include #include /** * Invalid method page. */ #define METHOD_ERROR \ "Illegal requestGo away." /** * Invalid URL page. */ #define NOT_FOUND_ERROR \ "Not foundGo away." /** * Front page. (/) */ #define MAIN_PAGE \ "Welcome
    What is your name?
    " /** * Second page. (/2) */ #define SECOND_PAGE \ "Tell me moreprevious
    %s, what is your job?
    " /** * Second page (/S) */ #define SUBMIT_PAGE \ "Ready to submit?
    previous
    " /** * Last page. */ #define LAST_PAGE \ "Thank youThank you." /** * Name of our cookie. */ #define COOKIE_NAME "session" /** * State we keep for each user/session/browser. */ struct Session { /** * We keep all sessions in a linked list. */ struct Session *next; /** * Unique ID for this session. */ char sid[33]; /** * Reference counter giving the number of connections * currently using this session. */ unsigned int rc; /** * Time when this session was last active. */ time_t start; /** * String submitted via form. */ char value_1[64]; /** * Another value submitted via form. */ char value_2[64]; }; /** * Data kept per request. */ struct Request { /** * Associated session. */ struct Session *session; /** * Post processor handling form data (IF this is * a POST request). */ struct MHD_PostProcessor *pp; /** * URL to serve in response to this POST (if this request * was a 'POST') */ const char *post_url; }; /** * Linked list of all active sessions. Yes, O(n) but a * hash table would be overkill for a simple example... */ static struct Session *sessions; /** * Return the session handle for this connection, or * create one if this is a new user. */ static struct Session * get_session (struct MHD_Connection *connection) { struct Session *ret; const char *cookie; cookie = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, COOKIE_NAME); if (cookie != NULL) { /* find existing session */ ret = sessions; while (NULL != ret) { if (0 == strcmp (cookie, ret->sid)) break; ret = ret->next; } if (NULL != ret) { ret->rc++; return ret; } } /* create fresh session */ ret = calloc (1, sizeof (struct Session)); if (NULL == ret) { fprintf (stderr, "calloc error: %s\n", strerror (errno)); return NULL; } /* not a super-secure way to generate a random session ID, but should do for a simple example... */ snprintf (ret->sid, sizeof (ret->sid), "%X%X%X%X", (unsigned int) rand (), (unsigned int) rand (), (unsigned int) rand (), (unsigned int) rand ()); ret->rc++; ret->start = time (NULL); ret->next = sessions; sessions = ret; return ret; } /** * Type of handler that generates a reply. * * @param cls content for the page (handler-specific) * @param mime mime type to use * @param session session information * @param connection connection to process * @param #MHD_YES on success, #MHD_NO on failure */ typedef enum MHD_Result (*PageHandler)(const void *cls, const char *mime, struct Session *session, struct MHD_Connection *connection); /** * Entry we generate for each page served. */ struct Page { /** * Acceptable URL for this page. */ const char *url; /** * Mime type to set for the page. */ const char *mime; /** * Handler to call to generate response. */ PageHandler handler; /** * Extra argument to handler. */ const void *handler_cls; }; /** * Add header to response to set a session cookie. * * @param session session to use * @param response response to modify */ static void add_session_cookie (struct Session *session, struct MHD_Response *response) { char cstr[256]; snprintf (cstr, sizeof (cstr), "%s=%s", COOKIE_NAME, session->sid); if (MHD_NO == MHD_add_response_header (response, MHD_HTTP_HEADER_SET_COOKIE, cstr)) { fprintf (stderr, "Failed to set session cookie header!\n"); } } /** * Handler that returns a simple static HTTP page that * is passed in via 'cls'. * * @param cls a 'const char *' with the HTML webpage to return * @param mime mime type to use * @param session session handle * @param connection connection to use */ static enum MHD_Result serve_simple_form (const void *cls, const char *mime, struct Session *session, struct MHD_Connection *connection) { enum MHD_Result ret; const char *form = cls; struct MHD_Response *response; /* return static form */ response = MHD_create_response_from_buffer_static (strlen (form), (const void *) form); if (NULL == response) return MHD_NO; add_session_cookie (session, response); if (MHD_YES != MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_ENCODING, mime)) { fprintf (stderr, "Failed to set content encoding header!\n"); } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } /** * Handler that adds the 'v1' value to the given HTML code. * * @param cls unused * @param mime mime type to use * @param session session handle * @param connection connection to use */ static enum MHD_Result fill_v1_form (const void *cls, const char *mime, struct Session *session, struct MHD_Connection *connection) { enum MHD_Result ret; size_t slen; char *reply; struct MHD_Response *response; (void) cls; /* Unused. Silent compiler warning. */ slen = strlen (MAIN_PAGE) + strlen (session->value_1); reply = malloc (slen + 1); if (NULL == reply) return MHD_NO; snprintf (reply, slen + 1, MAIN_PAGE, session->value_1); /* return static form */ response = MHD_create_response_from_buffer_with_free_callback (slen, (void *) reply, &free); if (NULL == response) { free (reply); return MHD_NO; } add_session_cookie (session, response); if (MHD_YES != MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_ENCODING, mime)) { fprintf (stderr, "Failed to set content encoding header!\n"); } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } /** * Handler that adds the 'v1' and 'v2' values to the given HTML code. * * @param cls unused * @param mime mime type to use * @param session session handle * @param connection connection to use */ static enum MHD_Result fill_v1_v2_form (const void *cls, const char *mime, struct Session *session, struct MHD_Connection *connection) { enum MHD_Result ret; char *reply; struct MHD_Response *response; size_t slen; (void) cls; /* Unused. Silent compiler warning. */ slen = strlen (SECOND_PAGE) + strlen (session->value_1) + strlen (session->value_2); reply = malloc (slen + 1); if (NULL == reply) return MHD_NO; snprintf (reply, slen + 1, SECOND_PAGE, session->value_1, session->value_2); /* return static form */ response = MHD_create_response_from_buffer_with_free_callback (slen, (void *) reply, &free); if (NULL == response) { free (reply); return MHD_NO; } add_session_cookie (session, response); if (MHD_YES != MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_ENCODING, mime)) { fprintf (stderr, "Failed to set content encoding header!\n"); } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } /** * Handler used to generate a 404 reply. * * @param cls a 'const char *' with the HTML webpage to return * @param mime mime type to use * @param session session handle * @param connection connection to use */ static enum MHD_Result not_found_page (const void *cls, const char *mime, struct Session *session, struct MHD_Connection *connection) { enum MHD_Result ret; struct MHD_Response *response; (void) cls; /* Unused. Silent compiler warning. */ (void) session; /* Unused. Silent compiler warning. */ /* unsupported HTTP method */ response = MHD_create_response_from_buffer_static (strlen (NOT_FOUND_ERROR), (const void *) NOT_FOUND_ERROR); if (NULL == response) return MHD_NO; ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); if (MHD_YES != MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_ENCODING, mime)) { fprintf (stderr, "Failed to set content encoding header!\n"); } MHD_destroy_response (response); return ret; } /** * List of all pages served by this HTTP server. */ static struct Page pages[] = { { "/", "text/html", &fill_v1_form, NULL }, { "/2", "text/html", &fill_v1_v2_form, NULL }, { "/S", "text/html", &serve_simple_form, SUBMIT_PAGE }, { "/F", "text/html", &serve_simple_form, LAST_PAGE }, { NULL, NULL, ¬_found_page, NULL } /* 404 */ }; /** * Iterator over key-value pairs where the value * maybe made available in increments and/or may * not be zero-terminated. Used for processing * POST data. * * @param cls user-specified closure * @param kind type of the value * @param key 0-terminated key for the value * @param filename name of the uploaded file, NULL if not known * @param content_type mime-type of the data, NULL if not known * @param transfer_encoding encoding of the data, NULL if not known * @param data pointer to size bytes of data at the * specified offset * @param off offset of data in the overall value * @param size number of bytes in data available * @return MHD_YES to continue iterating, * MHD_NO to abort the iteration */ static enum MHD_Result post_iterator (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { struct Request *request = cls; struct Session *session = request->session; (void) kind; /* Unused. Silent compiler warning. */ (void) filename; /* Unused. Silent compiler warning. */ (void) content_type; /* Unused. Silent compiler warning. */ (void) transfer_encoding; /* Unused. Silent compiler warning. */ if (0 == strcmp ("DONE", key)) { fprintf (stdout, "Session `%s' submitted `%s', `%s'\n", session->sid, session->value_1, session->value_2); return MHD_YES; } if (0 == strcmp ("v1", key)) { if (off >= sizeof(session->value_1) - 1) return MHD_YES; /* Discard extra data */ if (size + off >= sizeof(session->value_1)) size = (size_t) (sizeof (session->value_1) - off - 1); /* crop extra data */ memcpy (&session->value_1[off], data, size); session->value_1[size + off] = '\0'; return MHD_YES; } if (0 == strcmp ("v2", key)) { if (off >= sizeof(session->value_2) - 1) return MHD_YES; /* Discard extra data */ if (size + off >= sizeof(session->value_2)) size = (size_t) (sizeof (session->value_2) - off - 1); /* crop extra data */ memcpy (&session->value_2[off], data, size); session->value_2[size + off] = '\0'; return MHD_YES; } fprintf (stderr, "Unsupported form value `%s'\n", key); return MHD_YES; } /** * Main MHD callback for handling requests. * * @param cls argument given together with the function * pointer when the handler was registered with MHD * @param connection handle identifying the incoming connection * @param url the requested url * @param method the HTTP method used ("GET", "PUT", etc.) * @param version the HTTP version string (i.e. "HTTP/1.1") * @param upload_data the data being uploaded (excluding HEADERS, * for a POST that fits into memory and that is encoded * with a supported encoding, the POST data will NOT be * given in upload_data and is instead available as * part of MHD_get_connection_values; very large POST * data *will* be made available incrementally in * upload_data) * @param upload_data_size set initially to the size of the * upload_data provided; the method must update this * value to the number of bytes NOT processed; * @param req_cls pointer that the callback can set to some * address and that will be preserved by MHD for future * calls for this request; since the access handler may * be called many times (i.e., for a PUT/POST operation * with plenty of upload data) this allows the application * to easily associate some request-specific state. * If necessary, this state can be cleaned up in the * global "MHD_RequestCompleted" callback (which * can be set with the MHD_OPTION_NOTIFY_COMPLETED). * Initially, *req_cls will be NULL. * @return MHS_YES if the connection was handled successfully, * MHS_NO if the socket must be closed due to a serious * error while handling the request */ static enum MHD_Result create_response (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; struct Request *request; struct Session *session; enum MHD_Result ret; unsigned int i; (void) cls; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ request = *req_cls; if (NULL == request) { request = calloc (1, sizeof (struct Request)); if (NULL == request) { fprintf (stderr, "calloc error: %s\n", strerror (errno)); return MHD_NO; } *req_cls = request; if (0 == strcmp (method, MHD_HTTP_METHOD_POST)) { request->pp = MHD_create_post_processor (connection, 1024, &post_iterator, request); if (NULL == request->pp) { fprintf (stderr, "Failed to setup post processor for `%s'\n", url); return MHD_NO; /* internal error */ } } return MHD_YES; } if (NULL == request->session) { request->session = get_session (connection); if (NULL == request->session) { fprintf (stderr, "Failed to setup session for `%s'\n", url); return MHD_NO; /* internal error */ } } session = request->session; session->start = time (NULL); if (0 == strcmp (method, MHD_HTTP_METHOD_POST)) { /* evaluate POST data */ if (MHD_YES != MHD_post_process (request->pp, upload_data, *upload_data_size)) return MHD_NO; if (0 != *upload_data_size) { *upload_data_size = 0; return MHD_YES; } /* done with POST data, serve response */ MHD_destroy_post_processor (request->pp); request->pp = NULL; method = MHD_HTTP_METHOD_GET; /* fake 'GET' */ if (NULL != request->post_url) url = request->post_url; } if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) || (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) ) { /* find out which page to serve */ i = 0; while ( (pages[i].url != NULL) && (0 != strcmp (pages[i].url, url)) ) i++; ret = pages[i].handler (pages[i].handler_cls, pages[i].mime, session, connection); if (ret != MHD_YES) fprintf (stderr, "Failed to create page for `%s'\n", url); return ret; } /* unsupported HTTP method */ response = MHD_create_response_from_buffer_static (strlen (METHOD_ERROR), (const void *) METHOD_ERROR); ret = MHD_queue_response (connection, MHD_HTTP_NOT_ACCEPTABLE, response); MHD_destroy_response (response); return ret; } /** * Callback called upon completion of a request. * Decrements session reference counter. * * @param cls not used * @param connection connection that completed * @param req_cls session handle * @param toe status code */ static void request_completed_callback (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { struct Request *request = *req_cls; (void) cls; /* Unused. Silent compiler warning. */ (void) connection; /* Unused. Silent compiler warning. */ (void) toe; /* Unused. Silent compiler warning. */ if (NULL == request) return; if (NULL != request->session) request->session->rc--; if (NULL != request->pp) MHD_destroy_post_processor (request->pp); free (request); } /** * Clean up handles of sessions that have been idle for * too long. */ static void expire_sessions (void) { struct Session *pos; struct Session *prev; struct Session *next; time_t now; now = time (NULL); prev = NULL; pos = sessions; while (NULL != pos) { next = pos->next; if (now - pos->start > 60 * 60) { /* expire sessions after 1h */ if (NULL == prev) sessions = pos->next; else prev->next = next; free (pos); } else prev = pos; pos = next; } } /** * Call with the port number as the only argument. * Never terminates (other than by signals, such as CTRL-C). */ int main (int argc, char *const *argv) { struct MHD_Daemon *d; struct timeval tv; struct timeval *tvp; fd_set rs; fd_set ws; fd_set es; MHD_socket max; uint64_t mhd_timeout; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } /* initialize PRNG */ srand ((unsigned int) time (NULL)); d = MHD_start_daemon (MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &create_response, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 15, MHD_OPTION_NOTIFY_COMPLETED, &request_completed_callback, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (NULL == d) return 1; while (1) { expire_sessions (); max = 0; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) break; /* fatal internal error */ if (MHD_get_timeout64 (d, &mhd_timeout) == MHD_YES) { #if ! defined(_WIN32) || defined(__CYGWIN__) tv.tv_sec = (time_t) (mhd_timeout / 1000LL); #else /* Native W32 */ tv.tv_sec = (long) (mhd_timeout / 1000LL); #endif /* Native W32 */ tv.tv_usec = ((long) (mhd_timeout % 1000)) * 1000; tvp = &tv; } else tvp = NULL; if (-1 == select ((int) max + 1, &rs, &ws, &es, tvp)) { if (EINTR != errno) abort (); } MHD_run (d); } MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/minimal_example_empty.c0000644000175000017500000000635314441373361017203 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff (and other contributing authors) Copyright (C) 2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file minimal_example.c * @brief minimal example for how to use libmicrohttpd * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ response = MHD_create_response_empty (MHD_RF_NONE); ret = MHD_queue_response (connection, MHD_HTTP_NO_CONTENT, response); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } d = MHD_start_daemon (/* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, /* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_END); if (d == NULL) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/demo_https.c0000644000175000017500000010027714556271671015002 /* This file is part of libmicrohttpd Copyright (C) 2013 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file demo_https.c * @brief complex demonstration site: create directory index, offer * upload via form and HTTP POST, download with mime type detection * and error reporting (403, etc.) --- and all of this with * high-performance settings (large buffers, thread pool). * If you want to benchmark MHD, this code should be used to * run tests against. Note that the number of threads may need * to be adjusted depending on the number of available cores. * Logic is identical to demo.c, just adds HTTPS support. * This demonstration uses key/cert stored in static string. Optionally, * use gnutls_load_file() to load them from file. * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #include #include #include #include #include #ifdef MHD_HAVE_LIBMAGIC #include #endif /* MHD_HAVE_LIBMAGIC */ #include #include #include #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #ifndef PATH_MAX /* Some platforms (namely: GNU Hurd) do no define PATH_MAX. As it is only example for MHD, just use reasonable value for PATH_MAX. */ #define PATH_MAX 16384 #endif /** * Number of threads to run in the thread pool. Should (roughly) match * the number of cores on your system. */ #define NUMBER_OF_THREADS MHD_CPU_COUNT #ifdef MHD_HAVE_LIBMAGIC /** * How many bytes of a file do we give to libmagic to determine the mime type? * 16k might be a bit excessive, but ought not hurt performance much anyway, * and should definitively be on the safe side. */ #define MAGIC_HEADER_SIZE (16 * 1024) #endif /* MHD_HAVE_LIBMAGIC */ /** * Page returned for file-not-found. */ #define FILE_NOT_FOUND_PAGE \ "File not foundFile not found" /** * Page returned for internal errors. */ #define INTERNAL_ERROR_PAGE \ "Internal errorInternal error" /** * Page returned for refused requests. */ #define REQUEST_REFUSED_PAGE \ "Request refusedRequest refused (file exists?)" /** * Head of index page. */ #define INDEX_PAGE_HEADER \ "\nWelcome\n\n" \ "

    Upload

    \n" \ "
    \n" \ "
    Content type:
    " \ "Book" \ "Image" \ "Music" \ "Software" \ "Videos\n" \ "Other
    " \ "
    Language:
    " \ "none" \ "English" \ "German" \ "French" \ "Spanish
    \n" \ "
    File:
    " \ "
    " \ "\n" \ "
    \n" \ "

    Download

    \n" \ "
      \n" /** * Footer of index page. */ #define INDEX_PAGE_FOOTER "
    \n\n" /** * NULL-terminated array of supported upload categories. Should match HTML * in the form. */ static const char *const categories[] = { "books", "images", "music", "software", "videos", "other", NULL, }; /** * Specification of a supported language. */ struct Language { /** * Directory name for the language. */ const char *dirname; /** * Long name for humans. */ const char *longname; }; /** * NULL-terminated array of supported upload categories. Should match HTML * in the form. */ static const struct Language languages[] = { { "no-lang", "No language specified" }, { "en", "English" }, { "de", "German" }, { "fr", "French" }, { "es", "Spanish" }, { NULL, NULL }, }; /** * Response returned if the requested file does not exist (or is not accessible). */ static struct MHD_Response *file_not_found_response; /** * Response returned for internal errors. */ static struct MHD_Response *internal_error_response; /** * Response returned for '/' (GET) to list the contents of the directory and allow upload. */ static struct MHD_Response *cached_directory_response; /** * Response returned for refused uploads. */ static struct MHD_Response *request_refused_response; /** * Mutex used when we update the cached directory response object. */ static pthread_mutex_t mutex; #ifdef MHD_HAVE_LIBMAGIC /** * Global handle to MAGIC data. */ static magic_t magic; #endif /* MHD_HAVE_LIBMAGIC */ /** * Mark the given response as HTML for the browser. * * @param response response to mark */ static void mark_as_html (struct MHD_Response *response) { (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html"); } /** * Replace the existing 'cached_directory_response' with the * given response. * * @param response new directory response */ static void update_cached_response (struct MHD_Response *response) { (void) pthread_mutex_lock (&mutex); if (NULL != cached_directory_response) MHD_destroy_response (cached_directory_response); cached_directory_response = response; (void) pthread_mutex_unlock (&mutex); } /** * Context keeping the data for the response we're building. */ struct ResponseDataContext { /** * Response data string. */ char *buf; /** * Number of bytes allocated for 'buf'. */ size_t buf_len; /** * Current position where we append to 'buf'. Must be smaller or equal to 'buf_len'. */ size_t off; }; /** * Create a listing of the files in 'dirname' in HTML. * * @param rdc where to store the list of files * @param dirname name of the directory to list * @return MHD_YES on success, MHD_NO on error */ static enum MHD_Result list_directory (struct ResponseDataContext *rdc, const char *dirname) { char fullname[PATH_MAX]; struct stat sbuf; DIR *dir; struct dirent *de; if (NULL == (dir = opendir (dirname))) return MHD_NO; while (NULL != (de = readdir (dir))) { int res; if ('.' == de->d_name[0]) continue; if (sizeof (fullname) <= (size_t) snprintf (fullname, sizeof (fullname), "%s/%s", dirname, de->d_name)) continue; /* ugh, file too long? how can this be!? */ if (0 != stat (fullname, &sbuf)) continue; /* ugh, failed to 'stat' */ if (! S_ISREG (sbuf.st_mode)) continue; /* not a regular file, skip */ if (rdc->off + 1024 > rdc->buf_len) { void *r; if ( (2 * rdc->buf_len + 1024) < rdc->buf_len) break; /* more than SIZE_T _index_ size? Too big for us */ rdc->buf_len = 2 * rdc->buf_len + 1024; if (NULL == (r = realloc (rdc->buf, rdc->buf_len))) break; /* out of memory */ rdc->buf = r; } res = snprintf (&rdc->buf[rdc->off], rdc->buf_len - rdc->off, "
  • %s
  • \n", fullname, de->d_name); if (0 >= res) continue; /* snprintf() error */ if (rdc->buf_len - rdc->off <= (size_t) res) continue; /* buffer too small?? */ rdc->off += (size_t) res; } (void) closedir (dir); return MHD_YES; } /** * Re-scan our local directory and re-build the index. */ static void update_directory (void) { static size_t initial_allocation = 32 * 1024; /* initial size for response buffer */ struct MHD_Response *response; struct ResponseDataContext rdc; unsigned int language_idx; unsigned int category_idx; const struct Language *language; const char *category; char dir_name[128]; struct stat sbuf; int res; size_t len; rdc.buf_len = initial_allocation; if (NULL == (rdc.buf = malloc (rdc.buf_len))) { update_cached_response (NULL); return; } len = strlen (INDEX_PAGE_HEADER); if (rdc.buf_len <= len) { /* buffer too small */ free (rdc.buf); update_cached_response (NULL); return; } memcpy (rdc.buf, INDEX_PAGE_HEADER, len); rdc.off = len; for (language_idx = 0; NULL != languages[language_idx].dirname; language_idx++) { language = &languages[language_idx]; if (0 != stat (language->dirname, &sbuf)) continue; /* empty */ /* we ensured always +1k room, filenames are ~256 bytes, so there is always still enough space for the header without need for an additional reallocation check. */ res = snprintf (&rdc.buf[rdc.off], rdc.buf_len - rdc.off, "

    %s

    \n", language->longname); if (0 >= res) continue; /* snprintf() error */ if (rdc.buf_len - rdc.off <= (size_t) res) continue; /* buffer too small?? */ rdc.off += (size_t) res; for (category_idx = 0; NULL != categories[category_idx]; category_idx++) { category = categories[category_idx]; res = snprintf (dir_name, sizeof (dir_name), "%s/%s", language->dirname, category); if ((0 >= res) || (sizeof (dir_name) <= (size_t) res)) continue; /* cannot print dir name */ if (0 != stat (dir_name, &sbuf)) continue; /* empty */ /* we ensured always +1k room, filenames are ~256 bytes, so there is always still enough space for the header without need for an additional reallocation check. */ res = snprintf (&rdc.buf[rdc.off], rdc.buf_len - rdc.off, "

    %s

    \n", category); if (0 >= res) continue; /* snprintf() error */ if (rdc.buf_len - rdc.off <= (size_t) res) continue; /* buffer too small?? */ rdc.off += (size_t) res; if (MHD_NO == list_directory (&rdc, dir_name)) { free (rdc.buf); update_cached_response (NULL); return; } } } /* we ensured always +1k room, filenames are ~256 bytes, so there is always still enough space for the footer without need for a final reallocation check. */ len = strlen (INDEX_PAGE_FOOTER); if (rdc.buf_len - rdc.off <= len) { /* buffer too small */ free (rdc.buf); update_cached_response (NULL); return; } memcpy (rdc.buf, INDEX_PAGE_FOOTER, len); rdc.off += len; initial_allocation = rdc.buf_len; /* remember for next time */ response = MHD_create_response_from_buffer_with_free_callback (rdc.off, rdc.buf, &free); mark_as_html (response); #ifdef FORCE_CLOSE (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "close"); #endif update_cached_response (response); } /** * Context we keep for an upload. */ struct UploadContext { /** * Handle where we write the uploaded file to. */ int fd; /** * Name of the file on disk (used to remove on errors). */ char *filename; /** * Language for the upload. */ char *language; /** * Category for the upload. */ char *category; /** * Post processor we're using to process the upload. */ struct MHD_PostProcessor *pp; /** * Handle to connection that we're processing the upload for. */ struct MHD_Connection *connection; /** * Response to generate, NULL to use directory. */ struct MHD_Response *response; }; /** * Append the 'size' bytes from 'data' to '*ret', adding * 0-termination. If '*ret' is NULL, allocate an empty string first. * * @param ret string to update, NULL or 0-terminated * @param data data to append * @param size number of bytes in 'data' * @return #MHD_NO on allocation failure, #MHD_YES on success */ static enum MHD_Result do_append (char **ret, const char *data, size_t size) { char *buf; size_t old_len; if (NULL == *ret) old_len = 0; else old_len = strlen (*ret); if (NULL == (buf = malloc (old_len + size + 1))) return MHD_NO; if (NULL != *ret) { memcpy (buf, *ret, old_len); free (*ret); } memcpy (&buf[old_len], data, size); buf[old_len + size] = '\0'; *ret = buf; return MHD_YES; } /** * Iterator over key-value pairs where the value * maybe made available in increments and/or may * not be zero-terminated. Used for processing * POST data. * * @param cls user-specified closure * @param kind type of the value, always MHD_POSTDATA_KIND when called from MHD * @param key 0-terminated key for the value * @param filename name of the uploaded file, NULL if not known * @param content_type mime-type of the data, NULL if not known * @param transfer_encoding encoding of the data, NULL if not known * @param data pointer to size bytes of data at the * specified offset * @param off offset of data in the overall value * @param size number of bytes in data available * @return #MHD_YES to continue iterating, * #MHD_NO to abort the iteration */ static enum MHD_Result process_upload_data (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) { struct UploadContext *uc = cls; size_t i; int res; (void) kind; /* Unused. Silent compiler warning. */ (void) content_type; /* Unused. Silent compiler warning. */ (void) transfer_encoding; /* Unused. Silent compiler warning. */ (void) off; /* Unused. Silent compiler warning. */ if (0 == strcmp (key, "category")) return do_append (&uc->category, data, size); if (0 == strcmp (key, "language")) return do_append (&uc->language, data, size); if (0 != strcmp (key, "upload")) { fprintf (stderr, "Ignoring unexpected form value `%s'\n", key); return MHD_YES; /* ignore */ } if (NULL == filename) { fprintf (stderr, "No filename, aborting upload.\n"); return MHD_NO; /* no filename, error */ } if ( (NULL == uc->category) || (NULL == uc->language) ) { fprintf (stderr, "Missing form data for upload `%s'\n", filename); uc->response = request_refused_response; return MHD_NO; } if (-1 == uc->fd) { char fn[PATH_MAX]; if ( (NULL != strstr (filename, "..")) || (NULL != strchr (filename, '/')) || (NULL != strchr (filename, '\\')) ) { uc->response = request_refused_response; return MHD_NO; } /* create directories -- if they don't exist already */ #ifdef WINDOWS (void) mkdir (uc->language); #else (void) mkdir (uc->language, S_IRWXU); #endif snprintf (fn, sizeof (fn), "%s/%s", uc->language, uc->category); #ifdef WINDOWS (void) mkdir (fn); #else (void) mkdir (fn, S_IRWXU); #endif /* open file */ res = snprintf (fn, sizeof (fn), "%s/%s/%s", uc->language, uc->category, filename); if ((0 >= res) || (sizeof (fn) <= (size_t) res)) { uc->response = request_refused_response; return MHD_NO; } for (i = 0; i < (size_t) res; i++) if (! isprint ((unsigned char) fn[i])) fn[i] = '_'; uc->fd = open (fn, O_CREAT | O_EXCL #ifdef O_LARGEFILE | O_LARGEFILE #endif | O_WRONLY, S_IRUSR | S_IWUSR); if (-1 == uc->fd) { fprintf (stderr, "Error opening file `%s' for upload: %s\n", fn, strerror (errno)); uc->response = request_refused_response; return MHD_NO; } uc->filename = strdup (fn); } if ( (0 != size) && #if ! defined(_WIN32) || defined(__CYGWIN__) (size != (size_t) write (uc->fd, data, size)) #else /* Native W32 */ (size != (size_t) write (uc->fd, data, (unsigned int) size)) #endif /* Native W32 */ ) { /* write failed; likely: disk full */ fprintf (stderr, "Error writing to file `%s': %s\n", uc->filename, strerror (errno)); uc->response = internal_error_response; (void) close (uc->fd); uc->fd = -1; if (NULL != uc->filename) { unlink (uc->filename); free (uc->filename); uc->filename = NULL; } return MHD_NO; } return MHD_YES; } /** * Function called whenever a request was completed. * Used to clean up 'struct UploadContext' objects. * * @param cls client-defined closure, NULL * @param connection connection handle * @param req_cls value as set by the last call to * the MHD_AccessHandlerCallback, points to NULL if this was * not an upload * @param toe reason for request termination */ static void response_completed_callback (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { struct UploadContext *uc = *req_cls; (void) cls; /* Unused. Silent compiler warning. */ (void) connection; /* Unused. Silent compiler warning. */ (void) toe; /* Unused. Silent compiler warning. */ if (NULL == uc) return; /* this request wasn't an upload request */ if (NULL != uc->pp) { MHD_destroy_post_processor (uc->pp); uc->pp = NULL; } if (-1 != uc->fd) { (void) close (uc->fd); if (NULL != uc->filename) { fprintf (stderr, "Upload of file `%s' failed (incomplete or aborted), removing file.\n", uc->filename); (void) unlink (uc->filename); } } if (NULL != uc->filename) free (uc->filename); free (uc); } /** * Return the current directory listing. * * @param connection connection to return the directory for * @return MHD_YES on success, MHD_NO on error */ static enum MHD_Result return_directory_response (struct MHD_Connection *connection) { enum MHD_Result ret; (void) pthread_mutex_lock (&mutex); if (NULL == cached_directory_response) ret = MHD_queue_response (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, internal_error_response); else ret = MHD_queue_response (connection, MHD_HTTP_OK, cached_directory_response); (void) pthread_mutex_unlock (&mutex); return ret; } /** * Main callback from MHD, used to generate the page. * * @param cls NULL * @param connection connection handle * @param url requested URL * @param method GET, PUT, POST, etc. * @param version HTTP version * @param upload_data data from upload (PUT/POST) * @param upload_data_size number of bytes in "upload_data" * @param req_cls our context * @return #MHD_YES on success, #MHD_NO to drop connection */ static enum MHD_Result generate_page (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *response; enum MHD_Result ret; int fd; struct stat buf; (void) cls; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ if (0 != strcmp (url, "/")) { /* should be file download */ #ifdef MHD_HAVE_LIBMAGIC char file_data[MAGIC_HEADER_SIZE]; ssize_t got; #endif /* MHD_HAVE_LIBMAGIC */ const char *mime; if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) return MHD_NO; /* unexpected method (we're not polite...) */ fd = -1; if ( (NULL == strstr (&url[1], "..")) && ('/' != url[1]) ) { fd = open (&url[1], O_RDONLY); if ( (-1 != fd) && ( (0 != fstat (fd, &buf)) || (! S_ISREG (buf.st_mode)) ) ) { (void) close (fd); fd = -1; } } if (-1 == fd) return MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, file_not_found_response); #ifdef MHD_HAVE_LIBMAGIC /* read beginning of the file to determine mime type */ got = read (fd, file_data, sizeof (file_data)); (void) lseek (fd, 0, SEEK_SET); if (0 < got) mime = magic_buffer (magic, file_data, (size_t) got); else #endif /* MHD_HAVE_LIBMAGIC */ mime = NULL; if (NULL == (response = MHD_create_response_from_fd ((size_t) buf.st_size, fd))) { /* internal error (i.e. out of memory) */ (void) close (fd); return MHD_NO; } /* add mime type if we had one */ if (NULL != mime) (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, mime); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } if (0 == strcmp (method, MHD_HTTP_METHOD_POST)) { /* upload! */ struct UploadContext *uc = *req_cls; if (NULL == uc) { if (NULL == (uc = malloc (sizeof (struct UploadContext)))) return MHD_NO; /* out of memory, close connection */ memset (uc, 0, sizeof (struct UploadContext)); uc->fd = -1; uc->connection = connection; uc->pp = MHD_create_post_processor (connection, 64 * 1024 /* buffer size */, &process_upload_data, uc); if (NULL == uc->pp) { /* out of memory, close connection */ free (uc); return MHD_NO; } *req_cls = uc; return MHD_YES; } if (0 != *upload_data_size) { if (NULL == uc->response) (void) MHD_post_process (uc->pp, upload_data, *upload_data_size); *upload_data_size = 0; return MHD_YES; } /* end of upload, finish it! */ MHD_destroy_post_processor (uc->pp); uc->pp = NULL; if (-1 != uc->fd) { close (uc->fd); uc->fd = -1; } if (NULL != uc->response) { return MHD_queue_response (connection, MHD_HTTP_FORBIDDEN, uc->response); } else { update_directory (); return return_directory_response (connection); } } if (0 == strcmp (method, MHD_HTTP_METHOD_GET)) { return return_directory_response (connection); } /* unexpected request, refuse */ return MHD_queue_response (connection, MHD_HTTP_FORBIDDEN, request_refused_response); } #ifndef MINGW /** * Function called if we get a SIGPIPE. Does nothing. * * @param sig will be SIGPIPE (ignored) */ static void catcher (int sig) { (void) sig; /* Unused. Silent compiler warning. */ /* do nothing */ } /** * setup handlers to ignore SIGPIPE. */ static void ignore_sigpipe (void) { struct sigaction oldsig; struct sigaction sig; sig.sa_handler = &catcher; sigemptyset (&sig.sa_mask); #ifdef SA_INTERRUPT sig.sa_flags = SA_INTERRUPT; /* SunOS */ #else sig.sa_flags = SA_RESTART; #endif if (0 != sigaction (SIGPIPE, &sig, &oldsig)) fprintf (stderr, "Failed to install SIGPIPE handler: %s\n", strerror (errno)); } #endif /* test server key */ static const char srv_signed_key_pem[] = "-----BEGIN PRIVATE KEY-----\n\ MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCff7amw9zNSE+h\n\ rOMhBrzbbsJluUP3gmd8nOKY5MUimoPkxmAXfp2L0il+MPZT/ZEmo11q0k6J2jfG\n\ UBQ+oZW9ahNZ9gCDjbYlBblo/mqTai+LdeLO3qk53d0zrZKXvCO6sA3uKpG2WR+g\n\ +sNKxfYpIHCpanqBU6O+degIV/+WKy3nQ2Fwp7K5HUNj1u0pg0QQ18yf68LTnKFU\n\ HFjZmmaaopWki5wKSBieHivzQy6w+04HSTogHHRK/y/UcoJNSG7xnHmoPPo1vLT8\n\ CMRIYnSSgU3wJ43XBJ80WxrC2dcoZjV2XZz+XdQwCD4ZrC1ihykcAmiQA+sauNm7\n\ dztOMkGzAgMBAAECggEAIbKDzlvXDG/YkxnJqrKXt+yAmak4mNQuNP+YSCEdHSBz\n\ +SOILa6MbnvqVETX5grOXdFp7SWdfjZiTj2g6VKOJkSA7iKxHRoVf2DkOTB3J8np\n\ XZd8YaRdMGKVV1O2guQ20Dxd1RGdU18k9YfFNsj4Jtw5sTFTzHr1P0n9ybV9xCXp\n\ znSxVfRg8U6TcMHoRDJR9EMKQMO4W3OQEmreEPoGt2/+kMuiHjclxLtbwDxKXTLP\n\ pD0gdg3ibvlufk/ccKl/yAglDmd0dfW22oS7NgvRKUve7tzDxY1Q6O5v8BCnLFSW\n\ D+z4hS1PzooYRXRkM0xYudvPkryPyu+1kEpw3fNsoQKBgQDRfXJo82XQvlX8WPdZ\n\ Ts3PfBKKMVu3Wf8J3SYpuvYT816qR3ot6e4Ivv5ZCQkdDwzzBKe2jAv6JddMJIhx\n\ pkGHc0KKOodd9HoBewOd8Td++hapJAGaGblhL5beIidLKjXDjLqtgoHRGlv5Cojo\n\ zHa7Viel1eOPPcBumhp83oJ+mQKBgQDC6PmdETZdrW3QPm7ZXxRzF1vvpC55wmPg\n\ pRfTRM059jzRzAk0QiBgVp3yk2a6Ob3mB2MLfQVDgzGf37h2oO07s5nspSFZTFnM\n\ KgSjFy0xVOAVDLe+0VpbmLp1YUTYvdCNowaoTE7++5rpePUDu3BjAifx07/yaSB+\n\ W+YPOfOuKwKBgQCGK6g5G5qcJSuBIaHZ6yTZvIdLRu2M8vDral5k3793a6m3uWvB\n\ OFAh/eF9ONJDcD5E7zhTLEMHhXDs7YEN+QODMwjs6yuDu27gv97DK5j1lEsrLUpx\n\ XgRjAE3KG2m7NF+WzO1K74khWZaKXHrvTvTEaxudlO3X8h7rN3u7ee9uEQKBgQC2\n\ wI1zeTUZhsiFTlTPWfgppchdHPs6zUqq0wFQ5Zzr8Pa72+zxY+NJkU2NqinTCNsG\n\ ePykQ/gQgk2gUrt595AYv2De40IuoYk9BlTMuql0LNniwsbykwd/BOgnsSlFdEy8\n\ 0RQn70zOhgmNSg2qDzDklJvxghLi7zE5aV9//V1/ewKBgFRHHZN1a8q/v8AAOeoB\n\ ROuXfgDDpxNNUKbzLL5MO5odgZGi61PBZlxffrSOqyZoJkzawXycNtoBP47tcVzT\n\ QPq5ZOB3kjHTcN7dRLmPWjji9h4O3eHCX67XaPVMSWiMuNtOZIg2an06+jxGFhLE\n\ qdJNJ1DkyUc9dN2cliX4R+rG\n\ -----END PRIVATE KEY-----"; /* test server CA signed certificates */ static const char srv_signed_cert_pem[] = "-----BEGIN CERTIFICATE-----\n\ MIIFSzCCAzOgAwIBAgIBBDANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx\n\ DzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwGTW9zY293MRswGQYDVQQKDBJ0ZXN0\n\ LWxpYm1pY3JvaHR0cGQxITAfBgkqhkiG9w0BCQEWEm5vYm9keUBleGFtcGxlLm9y\n\ ZzEQMA4GA1UEAwwHdGVzdC1DQTAgFw0yMjA0MjAxODQzMDJaGA8yMTIyMDMyNjE4\n\ NDMwMlowZTELMAkGA1UEBhMCUlUxDzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwG\n\ TW9zY293MRswGQYDVQQKDBJ0ZXN0LWxpYm1pY3JvaHR0cGQxFzAVBgNVBAMMDnRl\n\ c3QtbWhkc2VydmVyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn3+2\n\ psPczUhPoazjIQa8227CZblD94JnfJzimOTFIpqD5MZgF36di9IpfjD2U/2RJqNd\n\ atJOido3xlAUPqGVvWoTWfYAg422JQW5aP5qk2ovi3Xizt6pOd3dM62Sl7wjurAN\n\ 7iqRtlkfoPrDSsX2KSBwqWp6gVOjvnXoCFf/list50NhcKeyuR1DY9btKYNEENfM\n\ n+vC05yhVBxY2ZpmmqKVpIucCkgYnh4r80MusPtOB0k6IBx0Sv8v1HKCTUhu8Zx5\n\ qDz6Nby0/AjESGJ0koFN8CeN1wSfNFsawtnXKGY1dl2c/l3UMAg+GawtYocpHAJo\n\ kAPrGrjZu3c7TjJBswIDAQABo4HmMIHjMAsGA1UdDwQEAwIFoDAMBgNVHRMBAf8E\n\ AjAAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMBMDEGA1UdEQQqMCiCDnRlc3QtbWhk\n\ c2VydmVyhwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMB0GA1UdDgQWBBQ57Z06WJae\n\ 8fJIHId4QGx/HsRgDDAoBglghkgBhvhCAQ0EGxYZVGVzdCBsaWJtaWNyb2h0dHBk\n\ IHNlcnZlcjARBglghkgBhvhCAQEEBAMCBkAwHwYDVR0jBBgwFoAUWHVDwKVqMcOF\n\ Nd0arI3/QB3W6SwwDQYJKoZIhvcNAQELBQADggIBAI7Lggm/XzpugV93H5+KV48x\n\ X+Ct8unNmPCSzCaI5hAHGeBBJpvD0KME5oiJ5p2wfCtK5Dt9zzf0S0xYdRKqU8+N\n\ aKIvPoU1hFixXLwTte1qOp6TviGvA9Xn2Fc4n36dLt6e9aiqDnqPbJgBwcVO82ll\n\ HJxVr3WbrAcQTB3irFUMqgAke/Cva9Bw79VZgX4ghb5EnejDzuyup4pHGzV10Myv\n\ hdg+VWZbAxpCe0S4eKmstZC7mWsFCLeoRTf/9Pk1kQ6+azbTuV/9QOBNfFi8QNyb\n\ 18jUjmm8sc2HKo8miCGqb2sFqaGD918hfkWmR+fFkzQ3DZQrT+eYbKq2un3k0pMy\n\ UySy8SRn1eadfab+GwBVb68I9TrPRMrJsIzysNXMX4iKYl2fFE/RSNnaHtPw0C8y\n\ B7memyxPRl+H2xg6UjpoKYh3+8e44/XKm0rNIzXjrwA8f8gnw2TbqmMDkj1YqGnC\n\ SCj5A27zUzaf2pT/YsnQXIWOJjVvbEI+YKj34wKWyTrXA093y8YI8T3mal7Kr9YM\n\ WiIyPts0/aVeziM0Gunglz+8Rj1VesL52FTurobqusPgM/AME82+qb/qnxuPaCKj\n\ OT1qAbIblaRuWqCsid8BzP7ZQiAnAWgMRSUg1gzDwSwRhrYQRRWAyn/Qipzec+27\n\ /w0gW9EVWzFhsFeGEssi\n\ -----END CERTIFICATE-----"; /** * Entry point to demo. Note: this HTTP server will make all * files in the current directory and its subdirectories available * to anyone. Press ENTER to stop the server once it has started. * * @param argc number of arguments in argv * @param argv first and only argument should be the port number * @return 0 on success */ int main (int argc, char *const *argv) { struct MHD_Daemon *d; unsigned int port; if ( (argc != 2) || (1 != sscanf (argv[1], "%u", &port)) || (UINT16_MAX < port) ) { fprintf (stderr, "%s PORT\n", argv[0]); return 1; } #ifndef MINGW ignore_sigpipe (); #endif #ifdef MHD_HAVE_LIBMAGIC magic = magic_open (MAGIC_MIME_TYPE); (void) magic_load (magic, NULL); #endif /* MHD_HAVE_LIBMAGIC */ (void) pthread_mutex_init (&mutex, NULL); file_not_found_response = MHD_create_response_from_buffer_static (strlen (FILE_NOT_FOUND_PAGE), (const void *) FILE_NOT_FOUND_PAGE); mark_as_html (file_not_found_response); request_refused_response = MHD_create_response_from_buffer_static (strlen (REQUEST_REFUSED_PAGE), (const void *) REQUEST_REFUSED_PAGE); mark_as_html (request_refused_response); internal_error_response = MHD_create_response_from_buffer_static (strlen (INTERNAL_ERROR_PAGE), (const void *) INTERNAL_ERROR_PAGE); mark_as_html (internal_error_response); update_directory (); d = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_TLS, (uint16_t) port, NULL, NULL, &generate_page, NULL, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (256 * 1024), #ifdef PRODUCTION MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) (64), #endif MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) (120 /* seconds */) , MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) NUMBER_OF_THREADS, MHD_OPTION_NOTIFY_COMPLETED, &response_completed_callback, NULL, /* Optionally, the gnutls_load_file() can be used to load the key and the certificate from file. */ MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_END); if (NULL == d) return 1; fprintf (stderr, "HTTP server running. Press ENTER to stop the server.\n"); (void) getc (stdin); MHD_stop_daemon (d); MHD_destroy_response (file_not_found_response); MHD_destroy_response (request_refused_response); MHD_destroy_response (internal_error_response); update_cached_response (NULL); (void) pthread_mutex_destroy (&mutex); #ifdef MHD_HAVE_LIBMAGIC magic_close (magic); #endif /* MHD_HAVE_LIBMAGIC */ return 0; } /* end of demo_https.c */ libmicrohttpd-1.0.1/src/examples/websocket_threaded_example.c0000644000175000017500000006343714556705750020203 /* This file is part of libmicrohttpd Copyright (C) 2020 Christian Grothoff, Silvio Clecio (and other contributing authors) Copyright (C) 2020-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file websocket_threaded_example.c * @brief example for how to provide a tiny threaded websocket server * @author Silvio Clecio (silvioprog) * @author Karlson2k (Evgeny Grin) */ /* TODO: allow to send large messages. */ #include "platform.h" #include #include #include #define CHAT_PAGE \ "\n" \ "\n" \ "WebSocket chat\n" \ "\n" \ "\n" \ "\n" \ "\n" \ "

    \n" \ "\n" \ "\n" \ "" #define BAD_REQUEST_PAGE \ "\n" \ "\n" \ "WebSocket chat\n" \ "\n" \ "\n" \ "Bad Request\n" \ "\n" \ "\n" #define UPGRADE_REQUIRED_PAGE \ "\n" \ "\n" \ "WebSocket chat\n" \ "\n" \ "\n" \ "Upgrade required\n" \ "\n" \ "\n" #define WS_SEC_WEBSOCKET_VERSION "13" #define WS_UPGRADE_VALUE "websocket" #define WS_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" #define WS_GUID_LEN 36 #define WS_KEY_LEN 24 #define WS_KEY_GUID_LEN ((WS_KEY_LEN) + (WS_GUID_LEN)) #define WS_FIN 128 #define WS_OPCODE_TEXT_FRAME 1 #define WS_OPCODE_CON_CLOSE_FRAME 8 #define MAX_CLIENTS 10 static MHD_socket CLIENT_SOCKS[MAX_CLIENTS]; static pthread_mutex_t MUTEX = PTHREAD_MUTEX_INITIALIZER; struct WsData { struct MHD_UpgradeResponseHandle *urh; MHD_socket sock; }; /********** begin SHA-1 **********/ #define SHA1HashSize 20 #define SHA1CircularShift(bits, word) \ (((word) << (bits)) | ((word) >> (32 - (bits)))) enum SHA1_RESULT { SHA1_RESULT_SUCCESS = 0, SHA1_RESULT_NULL = 1, SHA1_RESULT_STATE_ERROR = 2 }; struct SHA1Context { uint32_t intermediate_hash[SHA1HashSize / 4]; uint32_t length_low; uint32_t length_high; int_least16_t message_block_index; unsigned char message_block[64]; int computed; int corrupted; }; static void SHA1ProcessMessageBlock (struct SHA1Context *context) { const uint32_t K[] = { 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 }; int i; uint32_t temp; uint32_t W[80]; uint32_t A, B, C, D, E; for (i = 0; i < 16; i++) { W[i] = ((uint32_t) context->message_block[i * 4]) << 24; W[i] |= ((uint32_t) context->message_block[i * 4 + 1]) << 16; W[i] |= ((uint32_t) context->message_block[i * 4 + 2]) << 8; W[i] |= context->message_block[i * 4 + 3]; } for (i = 16; i < 80; i++) { W[i] = SHA1CircularShift (1, W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]); } A = context->intermediate_hash[0]; B = context->intermediate_hash[1]; C = context->intermediate_hash[2]; D = context->intermediate_hash[3]; E = context->intermediate_hash[4]; for (i = 0; i < 20; i++) { temp = SHA1CircularShift (5, A) + ((B & C) | ((~B) & D)) + E + W[i] + K[0]; E = D; D = C; C = SHA1CircularShift (30, B); B = A; A = temp; } for (i = 20; i < 40; i++) { temp = SHA1CircularShift (5, A) + (B ^ C ^ D) + E + W[i] + K[1]; E = D; D = C; C = SHA1CircularShift (30, B); B = A; A = temp; } for (i = 40; i < 60; i++) { temp = SHA1CircularShift (5, A) + ((B & C) | (B & D) | (C & D)) + E + W[i] + K[2]; E = D; D = C; C = SHA1CircularShift (30, B); B = A; A = temp; } for (i = 60; i < 80; i++) { temp = SHA1CircularShift (5, A) + (B ^ C ^ D) + E + W[i] + K[3]; E = D; D = C; C = SHA1CircularShift (30, B); B = A; A = temp; } context->intermediate_hash[0] += A; context->intermediate_hash[1] += B; context->intermediate_hash[2] += C; context->intermediate_hash[3] += D; context->intermediate_hash[4] += E; context->message_block_index = 0; } static void SHA1PadMessage (struct SHA1Context *context) { if (context->message_block_index > 55) { context->message_block[context->message_block_index++] = 0x80; while (context->message_block_index < 64) { context->message_block[context->message_block_index++] = 0; } SHA1ProcessMessageBlock (context); while (context->message_block_index < 56) { context->message_block[context->message_block_index++] = 0; } } else { context->message_block[context->message_block_index++] = 0x80; while (context->message_block_index < 56) { context->message_block[context->message_block_index++] = 0; } } context->message_block[56] = (unsigned char) (context->length_high >> 24); context->message_block[57] = (unsigned char) (context->length_high >> 16); context->message_block[58] = (unsigned char) (context->length_high >> 8); context->message_block[59] = (unsigned char) (context->length_high); context->message_block[60] = (unsigned char) (context->length_low >> 24); context->message_block[61] = (unsigned char) (context->length_low >> 16); context->message_block[62] = (unsigned char) (context->length_low >> 8); context->message_block[63] = (unsigned char) (context->length_low); SHA1ProcessMessageBlock (context); } static enum SHA1_RESULT SHA1Reset (struct SHA1Context *context) { if (! context) { return SHA1_RESULT_NULL; } context->length_low = 0; context->length_high = 0; context->message_block_index = 0; context->intermediate_hash[0] = 0x67452301; context->intermediate_hash[1] = 0xEFCDAB89; context->intermediate_hash[2] = 0x98BADCFE; context->intermediate_hash[3] = 0x10325476; context->intermediate_hash[4] = 0xC3D2E1F0; context->computed = 0; context->corrupted = 0; return SHA1_RESULT_SUCCESS; } static enum SHA1_RESULT SHA1Result (struct SHA1Context *context, unsigned char Message_Digest[SHA1HashSize]) { int i; if (! context || ! Message_Digest) { return SHA1_RESULT_NULL; } if (context->corrupted) { return SHA1_RESULT_STATE_ERROR; } if (! context->computed) { SHA1PadMessage (context); for (i = 0; i < 64; ++i) { context->message_block[i] = 0; } context->length_low = 0; context->length_high = 0; context->computed = 1; } for (i = 0; i < SHA1HashSize; ++i) { Message_Digest[i] = (unsigned char) (context->intermediate_hash[i >> 2] >> 8 * (3 - (i & 0x03))); } return SHA1_RESULT_SUCCESS; } static enum SHA1_RESULT SHA1Input (struct SHA1Context *context, const unsigned char *message_array, unsigned length) { if (! length) { return SHA1_RESULT_SUCCESS; } if (! context || ! message_array) { return SHA1_RESULT_NULL; } if (context->computed) { context->corrupted = 1; return SHA1_RESULT_STATE_ERROR; } if (context->corrupted) { return SHA1_RESULT_STATE_ERROR; } while (length-- && ! context->corrupted) { context->message_block[context->message_block_index++] = (*message_array & 0xFF); context->length_low += 8; if (context->length_low == 0) { context->length_high++; if (context->length_high == 0) { context->corrupted = 1; } } if (context->message_block_index == 64) { SHA1ProcessMessageBlock (context); } message_array++; } return SHA1_RESULT_SUCCESS; } /********** end SHA-1 **********/ /********** begin Base64 **********/ static ssize_t BASE64Encode (const void *in, size_t len, char **output) { #define FILLCHAR '=' const char *cvt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; const char *data = in; char *opt; ssize_t ret; size_t i; char c; ret = 0; opt = malloc (2 + (len * 4 / 3) + 8); if (NULL == opt) { return -1; } for (i = 0; i < len; ++i) { c = (data[i] >> 2) & 0x3F; opt[ret++] = cvt[(int) c]; c = (data[i] << 4) & 0x3F; if (++i < len) { c = (char) (c | ((data[i] >> 4) & 0x0F)); } opt[ret++] = cvt[(int) c]; if (i < len) { c = (char) (c | ((data[i] << 2) & 0x3F)); if (++i < len) { c = (char) (c | ((data[i] >> 6) & 0x03)); } opt[ret++] = cvt[(int) c]; } else { ++i; opt[ret++] = FILLCHAR; } if (i < len) { c = data[i] & 0x3F; opt[ret++] = cvt[(int) c]; } else { opt[ret++] = FILLCHAR; } } *output = opt; return ret; } /********** end Base64 **********/ static enum MHD_Result is_websocket_request (struct MHD_Connection *con, const char *upg_header, const char *con_header) { (void) con; /* Unused. Silent compiler warning. */ return ((upg_header != NULL) && (con_header != NULL) && (0 == strcmp (upg_header, WS_UPGRADE_VALUE)) && (NULL != strstr (con_header, "Upgrade"))) ? MHD_YES : MHD_NO; } static enum MHD_Result send_chat_page (struct MHD_Connection *con) { struct MHD_Response *res; enum MHD_Result ret; res = MHD_create_response_from_buffer_static (strlen (CHAT_PAGE), (const void *) CHAT_PAGE); ret = MHD_queue_response (con, MHD_HTTP_OK, res); MHD_destroy_response (res); return ret; } static enum MHD_Result send_bad_request (struct MHD_Connection *con) { struct MHD_Response *res; enum MHD_Result ret; res = MHD_create_response_from_buffer_static (strlen (BAD_REQUEST_PAGE), (const void *) BAD_REQUEST_PAGE); ret = MHD_queue_response (con, MHD_HTTP_BAD_REQUEST, res); MHD_destroy_response (res); return ret; } static enum MHD_Result send_upgrade_required (struct MHD_Connection *con) { struct MHD_Response *res; enum MHD_Result ret; res = MHD_create_response_from_buffer_static (strlen (UPGRADE_REQUIRED_PAGE), (const void *) UPGRADE_REQUIRED_PAGE); if (MHD_YES != MHD_add_response_header (res, MHD_HTTP_HEADER_SEC_WEBSOCKET_VERSION, WS_SEC_WEBSOCKET_VERSION)) { MHD_destroy_response (res); return MHD_NO; } ret = MHD_queue_response (con, MHD_HTTP_UPGRADE_REQUIRED, res); MHD_destroy_response (res); return ret; } static enum MHD_Result ws_get_accept_value (const char *key, char **val) { struct SHA1Context ctx; unsigned char hash[SHA1HashSize]; char *str; ssize_t len; if ( (NULL == key) || (WS_KEY_LEN != strlen (key))) { return MHD_NO; } str = malloc (WS_KEY_LEN + WS_GUID_LEN + 1); if (NULL == str) { return MHD_NO; } strncpy (str, key, (WS_KEY_LEN + 1)); strncpy (str + WS_KEY_LEN, WS_GUID, WS_GUID_LEN + 1); SHA1Reset (&ctx); SHA1Input (&ctx, (const unsigned char *) str, WS_KEY_GUID_LEN); if (SHA1_RESULT_SUCCESS != SHA1Result (&ctx, hash)) { free (str); return MHD_NO; } free (str); len = BASE64Encode (hash, SHA1HashSize, val); if (-1 == len) { return MHD_NO; } (*val)[len] = '\0'; return MHD_YES; } static void make_blocking (MHD_socket fd) { #if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (fd, F_GETFL); if (-1 == flags) abort (); if ((flags & ~O_NONBLOCK) != flags) if (-1 == fcntl (fd, F_SETFL, flags & ~O_NONBLOCK)) abort (); #elif defined(MHD_WINSOCK_SOCKETS) unsigned long flags = 0; if (0 != ioctlsocket (fd, (int) FIONBIO, &flags)) abort (); #endif /* MHD_WINSOCK_SOCKETS */ } static size_t send_all (MHD_socket sock, const unsigned char *buf, size_t len) { ssize_t ret; size_t off; for (off = 0; off < len; off += (size_t) ret) { #if ! defined(_WIN32) || defined(__CYGWIN__) ret = send (sock, (const void *) &buf[off], len - off, 0); #else /* Native W32 */ ret = send (sock, (const void *) &buf[off], (int) (len - off), 0); #endif /* Native W32 */ if (0 > ret) { if (EAGAIN == errno) { ret = 0; continue; } break; } if (0 == ret) { break; } } return off; } static ssize_t ws_send_frame (MHD_socket sock, const char *msg, size_t length) { unsigned char *response; unsigned char frame[10]; unsigned char idx_first_rdata; size_t idx_response; size_t output; MHD_socket isock; size_t i; frame[0] = (WS_FIN | WS_OPCODE_TEXT_FRAME); if (length <= 125) { frame[1] = length & 0x7F; idx_first_rdata = 2; } #if SIZEOF_SIZE_T > 4 else if (0xFFFF < length) { frame[1] = 127; frame[2] = (unsigned char) ((length >> 56) & 0xFF); frame[3] = (unsigned char) ((length >> 48) & 0xFF); frame[4] = (unsigned char) ((length >> 40) & 0xFF); frame[5] = (unsigned char) ((length >> 32) & 0xFF); frame[6] = (unsigned char) ((length >> 24) & 0xFF); frame[7] = (unsigned char) ((length >> 16) & 0xFF); frame[8] = (unsigned char) ((length >> 8) & 0xFF); frame[9] = (unsigned char) (length & 0xFF); idx_first_rdata = 10; } #endif /* SIZEOF_SIZE_T > 4 */ else { frame[1] = 126; frame[2] = (length >> 8) & 0xFF; frame[3] = length & 0xFF; idx_first_rdata = 4; } idx_response = 0; response = malloc (idx_first_rdata + length + 1); if (NULL == response) { return -1; } for (i = 0; i < idx_first_rdata; i++) { response[i] = frame[i]; idx_response++; } for (i = 0; i < length; i++) { response[idx_response] = (unsigned char) msg[i]; idx_response++; } response[idx_response] = '\0'; output = 0; if (0 != pthread_mutex_lock (&MUTEX)) abort (); for (i = 0; i < MAX_CLIENTS; i++) { isock = CLIENT_SOCKS[i]; if ((isock != MHD_INVALID_SOCKET) && (isock != sock)) { output += send_all (isock, response, idx_response); } } if (0 != pthread_mutex_unlock (&MUTEX)) abort (); free (response); return (ssize_t) output; } static unsigned char * ws_receive_frame (unsigned char *frame, ssize_t *length, int *type) { unsigned char masks[4]; unsigned char mask; unsigned char *msg; unsigned char flength; unsigned char idx_first_mask; unsigned char idx_first_data; size_t data_length; int i; int j; msg = NULL; if (frame[0] == (WS_FIN | WS_OPCODE_TEXT_FRAME)) { *type = WS_OPCODE_TEXT_FRAME; idx_first_mask = 2; mask = frame[1]; flength = mask & 0x7F; if (flength == 126) { idx_first_mask = 4; } else if (flength == 127) { idx_first_mask = 10; } idx_first_data = (unsigned char) (idx_first_mask + 4); data_length = (size_t) *length - idx_first_data; masks[0] = frame[idx_first_mask + 0]; masks[1] = frame[idx_first_mask + 1]; masks[2] = frame[idx_first_mask + 2]; masks[3] = frame[idx_first_mask + 3]; msg = malloc (data_length + 1); if (NULL != msg) { for (i = idx_first_data, j = 0; i < *length; i++, j++) { msg[j] = frame[i] ^ masks[j % 4]; } *length = (ssize_t) data_length; msg[j] = '\0'; } } else if (frame[0] == (WS_FIN | WS_OPCODE_CON_CLOSE_FRAME)) { *type = WS_OPCODE_CON_CLOSE_FRAME; } else { *type = frame[0] & 0x0F; } return msg; } static void * run_usock (void *cls) { struct WsData *ws = cls; struct MHD_UpgradeResponseHandle *urh = ws->urh; unsigned char buf[2048]; unsigned char *msg; char *text; ssize_t got; int type; int i; make_blocking (ws->sock); while (1) { got = recv (ws->sock, (void *) buf, sizeof (buf), 0); if (0 >= got) { break; } msg = ws_receive_frame (buf, &got, &type); if (NULL == msg) { break; } if (type == WS_OPCODE_TEXT_FRAME) { ssize_t sent; int buf_size; buf_size = snprintf (NULL, 0, "User#%d: %s", (int) ws->sock, msg); if (0 < buf_size) { text = malloc ((size_t) buf_size + 1); if (NULL != text) { if (snprintf (text, (size_t) buf_size + 1, "User#%d: %s", (int) ws->sock, msg) == buf_size) sent = ws_send_frame (ws->sock, text, (size_t) buf_size); else sent = -1; free (text); } else sent = -1; } else sent = -1; free (msg); if (-1 == sent) { break; } } else { if (type == WS_OPCODE_CON_CLOSE_FRAME) { free (msg); break; } } } if (0 != pthread_mutex_lock (&MUTEX)) abort (); for (i = 0; i < MAX_CLIENTS; i++) { if (CLIENT_SOCKS[i] == ws->sock) { CLIENT_SOCKS[i] = MHD_INVALID_SOCKET; break; } } if (0 != pthread_mutex_unlock (&MUTEX)) abort (); free (ws); MHD_upgrade_action (urh, MHD_UPGRADE_ACTION_CLOSE); return NULL; } static void uh_cb (void *cls, struct MHD_Connection *con, void *req_cls, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh) { struct WsData *ws; pthread_t pt; int sock_overflow; int i; (void) cls; /* Unused. Silent compiler warning. */ (void) con; /* Unused. Silent compiler warning. */ (void) req_cls; /* Unused. Silent compiler warning. */ (void) extra_in; /* Unused. Silent compiler warning. */ (void) extra_in_size; /* Unused. Silent compiler warning. */ ws = malloc (sizeof (struct WsData)); if (NULL == ws) abort (); memset (ws, 0, sizeof (struct WsData)); ws->sock = sock; ws->urh = urh; sock_overflow = MHD_YES; if (0 != pthread_mutex_lock (&MUTEX)) abort (); for (i = 0; i < MAX_CLIENTS; i++) { if (MHD_INVALID_SOCKET == CLIENT_SOCKS[i]) { CLIENT_SOCKS[i] = ws->sock; sock_overflow = MHD_NO; break; } } if (0 != pthread_mutex_unlock (&MUTEX)) abort (); if (sock_overflow) { free (ws); MHD_upgrade_action (urh, MHD_UPGRADE_ACTION_CLOSE); return; } if (0 != pthread_create (&pt, NULL, &run_usock, ws)) abort (); /* Note that by detaching like this we make it impossible to ensure a clean shutdown, as the we stop the daemon even if a worker thread is still running. Alas, this is a simple example... */ pthread_detach (pt); } static enum MHD_Result ahc_cb (void *cls, struct MHD_Connection *con, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_Response *res; const char *upg_header; const char *con_header; const char *ws_version_header; const char *ws_key_header; char *ws_ac_value; enum MHD_Result ret; size_t key_size; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (NULL == *req_cls) { *req_cls = (void *) 1; return MHD_YES; } *req_cls = NULL; upg_header = MHD_lookup_connection_value (con, MHD_HEADER_KIND, MHD_HTTP_HEADER_UPGRADE); con_header = MHD_lookup_connection_value (con, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONNECTION); if (MHD_NO == is_websocket_request (con, upg_header, con_header)) { return send_chat_page (con); } if ((0 != strcmp (method, MHD_HTTP_METHOD_GET)) || (0 != strcmp (version, MHD_HTTP_VERSION_1_1))) { return send_bad_request (con); } ws_version_header = MHD_lookup_connection_value (con, MHD_HEADER_KIND, MHD_HTTP_HEADER_SEC_WEBSOCKET_VERSION); if ((NULL == ws_version_header) || (0 != strcmp (ws_version_header, WS_SEC_WEBSOCKET_VERSION))) { return send_upgrade_required (con); } ret = MHD_lookup_connection_value_n (con, MHD_HEADER_KIND, MHD_HTTP_HEADER_SEC_WEBSOCKET_KEY, strlen ( MHD_HTTP_HEADER_SEC_WEBSOCKET_KEY), &ws_key_header, &key_size); if ((MHD_NO == ret) || (key_size != WS_KEY_LEN)) { return send_bad_request (con); } ret = ws_get_accept_value (ws_key_header, &ws_ac_value); if (MHD_NO == ret) { return ret; } res = MHD_create_response_for_upgrade (&uh_cb, NULL); if (MHD_YES != MHD_add_response_header (res, MHD_HTTP_HEADER_SEC_WEBSOCKET_ACCEPT, ws_ac_value)) { free (ws_ac_value); MHD_destroy_response (res); return MHD_NO; } free (ws_ac_value); if (MHD_YES != MHD_add_response_header (res, MHD_HTTP_HEADER_UPGRADE, WS_UPGRADE_VALUE)) { MHD_destroy_response (res); return MHD_NO; } ret = MHD_queue_response (con, MHD_HTTP_SWITCHING_PROTOCOLS, res); MHD_destroy_response (res); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; unsigned int port; size_t i; if ( (argc != 2) || (1 != sscanf (argv[1], "%u", &port)) || (65535 < port) ) { printf ("%s PORT\n", argv[0]); return 1; } d = MHD_start_daemon (MHD_ALLOW_UPGRADE | MHD_USE_AUTO_INTERNAL_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_cb, NULL, MHD_OPTION_END); if (NULL == d) return 1; for (i = 0; i < sizeof(CLIENT_SOCKS) / sizeof(CLIENT_SOCKS[0]); ++i) CLIENT_SOCKS[i] = MHD_INVALID_SOCKET; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/dual_stack_example.c0000644000175000017500000000640714441373361016451 /* This file is part of libmicrohttpd Copyright (C) 2007, 2012 Christian Grothoff (and other contributing authors) Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file dual_stack_example.c * @brief how to use MHD with both IPv4 and IPv6 support (dual-stack) * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #define PAGE \ "libmicrohttpd demolibmicrohttpd demo" struct handler_param { const char *response_page; }; static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct handler_param *param = (struct handler_param *) cls; struct MHD_Response *response; enum MHD_Result ret; (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ response = MHD_create_response_from_buffer_static (strlen (param->response_page), param->response_page); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; struct handler_param data_for_handler; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } data_for_handler.response_page = PAGE; d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_DUAL_STACK, (uint16_t) port, NULL, NULL, &ahc_echo, &data_for_handler, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_END); (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/benchmark_https.c0000644000175000017500000002303114441373361015770 /* This file is part of libmicrohttpd Copyright (C) 2007, 2013 Christian Grothoff (and other contributing authors) Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file benchmark_https.c * @brief minimal code to benchmark MHD GET performance with HTTPS * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifndef PRIu64 #define PRIu64 "llu" #endif /* ! PRIu64 */ #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif #if ! defined(MHD_CPU_COUNT) #define MHD_CPU_COUNT 2 #endif #define PAGE \ "libmicrohttpd demolibmicrohttpd demo" #define SMALL (1024 * 128) /** * Number of threads to run in the thread pool. Should (roughly) match * the number of cores on your system. */ #define NUMBER_OF_THREADS MHD_CPU_COUNT static unsigned int small_deltas[SMALL]; static struct MHD_Response *response; /** * Signature of the callback used by MHD to notify the * application about completed requests. * * @param cls client-defined closure * @param connection connection handle * @param req_cls value as set by the last call to * the MHD_AccessHandlerCallback * @param toe reason for request termination * @see MHD_OPTION_NOTIFY_COMPLETED */ static void completed_callback (void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe) { struct timeval *tv = *req_cls; struct timeval tve; uint64_t delta; (void) cls; /* Unused. Silent compiler warning. */ (void) connection; /* Unused. Silent compiler warning. */ (void) toe; /* Unused. Silent compiler warning. */ if (NULL == tv) return; gettimeofday (&tve, NULL); delta = ((uint64_t) (tve.tv_sec - tv->tv_sec)) * 1000000LL + (uint64_t) tve.tv_usec - (uint64_t) tv->tv_usec; if (delta < SMALL) small_deltas[delta]++; else fprintf (stdout, "D: %" PRIu64 " 1\n", delta); free (tv); } static void * uri_logger_cb (void *cls, const char *uri) { struct timeval *tv = malloc (sizeof (struct timeval)); (void) cls; /* Unused. Silent compiler warning. */ (void) uri; /* Unused. Silent compiler warning. */ if (NULL != tv) gettimeofday (tv, NULL); return tv; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ (void) req_cls; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ return MHD_queue_response (connection, MHD_HTTP_OK, response); } /* test server key */ static const char srv_signed_key_pem[] = "-----BEGIN PRIVATE KEY-----\n\ MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCff7amw9zNSE+h\n\ rOMhBrzbbsJluUP3gmd8nOKY5MUimoPkxmAXfp2L0il+MPZT/ZEmo11q0k6J2jfG\n\ UBQ+oZW9ahNZ9gCDjbYlBblo/mqTai+LdeLO3qk53d0zrZKXvCO6sA3uKpG2WR+g\n\ +sNKxfYpIHCpanqBU6O+degIV/+WKy3nQ2Fwp7K5HUNj1u0pg0QQ18yf68LTnKFU\n\ HFjZmmaaopWki5wKSBieHivzQy6w+04HSTogHHRK/y/UcoJNSG7xnHmoPPo1vLT8\n\ CMRIYnSSgU3wJ43XBJ80WxrC2dcoZjV2XZz+XdQwCD4ZrC1ihykcAmiQA+sauNm7\n\ dztOMkGzAgMBAAECggEAIbKDzlvXDG/YkxnJqrKXt+yAmak4mNQuNP+YSCEdHSBz\n\ +SOILa6MbnvqVETX5grOXdFp7SWdfjZiTj2g6VKOJkSA7iKxHRoVf2DkOTB3J8np\n\ XZd8YaRdMGKVV1O2guQ20Dxd1RGdU18k9YfFNsj4Jtw5sTFTzHr1P0n9ybV9xCXp\n\ znSxVfRg8U6TcMHoRDJR9EMKQMO4W3OQEmreEPoGt2/+kMuiHjclxLtbwDxKXTLP\n\ pD0gdg3ibvlufk/ccKl/yAglDmd0dfW22oS7NgvRKUve7tzDxY1Q6O5v8BCnLFSW\n\ D+z4hS1PzooYRXRkM0xYudvPkryPyu+1kEpw3fNsoQKBgQDRfXJo82XQvlX8WPdZ\n\ Ts3PfBKKMVu3Wf8J3SYpuvYT816qR3ot6e4Ivv5ZCQkdDwzzBKe2jAv6JddMJIhx\n\ pkGHc0KKOodd9HoBewOd8Td++hapJAGaGblhL5beIidLKjXDjLqtgoHRGlv5Cojo\n\ zHa7Viel1eOPPcBumhp83oJ+mQKBgQDC6PmdETZdrW3QPm7ZXxRzF1vvpC55wmPg\n\ pRfTRM059jzRzAk0QiBgVp3yk2a6Ob3mB2MLfQVDgzGf37h2oO07s5nspSFZTFnM\n\ KgSjFy0xVOAVDLe+0VpbmLp1YUTYvdCNowaoTE7++5rpePUDu3BjAifx07/yaSB+\n\ W+YPOfOuKwKBgQCGK6g5G5qcJSuBIaHZ6yTZvIdLRu2M8vDral5k3793a6m3uWvB\n\ OFAh/eF9ONJDcD5E7zhTLEMHhXDs7YEN+QODMwjs6yuDu27gv97DK5j1lEsrLUpx\n\ XgRjAE3KG2m7NF+WzO1K74khWZaKXHrvTvTEaxudlO3X8h7rN3u7ee9uEQKBgQC2\n\ wI1zeTUZhsiFTlTPWfgppchdHPs6zUqq0wFQ5Zzr8Pa72+zxY+NJkU2NqinTCNsG\n\ ePykQ/gQgk2gUrt595AYv2De40IuoYk9BlTMuql0LNniwsbykwd/BOgnsSlFdEy8\n\ 0RQn70zOhgmNSg2qDzDklJvxghLi7zE5aV9//V1/ewKBgFRHHZN1a8q/v8AAOeoB\n\ ROuXfgDDpxNNUKbzLL5MO5odgZGi61PBZlxffrSOqyZoJkzawXycNtoBP47tcVzT\n\ QPq5ZOB3kjHTcN7dRLmPWjji9h4O3eHCX67XaPVMSWiMuNtOZIg2an06+jxGFhLE\n\ qdJNJ1DkyUc9dN2cliX4R+rG\n\ -----END PRIVATE KEY-----"; /* test server CA signed certificates */ static const char srv_signed_cert_pem[] = "-----BEGIN CERTIFICATE-----\n\ MIIFSzCCAzOgAwIBAgIBBDANBgkqhkiG9w0BAQsFADCBgTELMAkGA1UEBhMCUlUx\n\ DzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwGTW9zY293MRswGQYDVQQKDBJ0ZXN0\n\ LWxpYm1pY3JvaHR0cGQxITAfBgkqhkiG9w0BCQEWEm5vYm9keUBleGFtcGxlLm9y\n\ ZzEQMA4GA1UEAwwHdGVzdC1DQTAgFw0yMjA0MjAxODQzMDJaGA8yMTIyMDMyNjE4\n\ NDMwMlowZTELMAkGA1UEBhMCUlUxDzANBgNVBAgMBk1vc2NvdzEPMA0GA1UEBwwG\n\ TW9zY293MRswGQYDVQQKDBJ0ZXN0LWxpYm1pY3JvaHR0cGQxFzAVBgNVBAMMDnRl\n\ c3QtbWhkc2VydmVyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn3+2\n\ psPczUhPoazjIQa8227CZblD94JnfJzimOTFIpqD5MZgF36di9IpfjD2U/2RJqNd\n\ atJOido3xlAUPqGVvWoTWfYAg422JQW5aP5qk2ovi3Xizt6pOd3dM62Sl7wjurAN\n\ 7iqRtlkfoPrDSsX2KSBwqWp6gVOjvnXoCFf/list50NhcKeyuR1DY9btKYNEENfM\n\ n+vC05yhVBxY2ZpmmqKVpIucCkgYnh4r80MusPtOB0k6IBx0Sv8v1HKCTUhu8Zx5\n\ qDz6Nby0/AjESGJ0koFN8CeN1wSfNFsawtnXKGY1dl2c/l3UMAg+GawtYocpHAJo\n\ kAPrGrjZu3c7TjJBswIDAQABo4HmMIHjMAsGA1UdDwQEAwIFoDAMBgNVHRMBAf8E\n\ AjAAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMBMDEGA1UdEQQqMCiCDnRlc3QtbWhk\n\ c2VydmVyhwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMB0GA1UdDgQWBBQ57Z06WJae\n\ 8fJIHId4QGx/HsRgDDAoBglghkgBhvhCAQ0EGxYZVGVzdCBsaWJtaWNyb2h0dHBk\n\ IHNlcnZlcjARBglghkgBhvhCAQEEBAMCBkAwHwYDVR0jBBgwFoAUWHVDwKVqMcOF\n\ Nd0arI3/QB3W6SwwDQYJKoZIhvcNAQELBQADggIBAI7Lggm/XzpugV93H5+KV48x\n\ X+Ct8unNmPCSzCaI5hAHGeBBJpvD0KME5oiJ5p2wfCtK5Dt9zzf0S0xYdRKqU8+N\n\ aKIvPoU1hFixXLwTte1qOp6TviGvA9Xn2Fc4n36dLt6e9aiqDnqPbJgBwcVO82ll\n\ HJxVr3WbrAcQTB3irFUMqgAke/Cva9Bw79VZgX4ghb5EnejDzuyup4pHGzV10Myv\n\ hdg+VWZbAxpCe0S4eKmstZC7mWsFCLeoRTf/9Pk1kQ6+azbTuV/9QOBNfFi8QNyb\n\ 18jUjmm8sc2HKo8miCGqb2sFqaGD918hfkWmR+fFkzQ3DZQrT+eYbKq2un3k0pMy\n\ UySy8SRn1eadfab+GwBVb68I9TrPRMrJsIzysNXMX4iKYl2fFE/RSNnaHtPw0C8y\n\ B7memyxPRl+H2xg6UjpoKYh3+8e44/XKm0rNIzXjrwA8f8gnw2TbqmMDkj1YqGnC\n\ SCj5A27zUzaf2pT/YsnQXIWOJjVvbEI+YKj34wKWyTrXA093y8YI8T3mal7Kr9YM\n\ WiIyPts0/aVeziM0Gunglz+8Rj1VesL52FTurobqusPgM/AME82+qb/qnxuPaCKj\n\ OT1qAbIblaRuWqCsid8BzP7ZQiAnAWgMRSUg1gzDwSwRhrYQRRWAyn/Qipzec+27\n\ /w0gW9EVWzFhsFeGEssi\n\ -----END CERTIFICATE-----"; int main (int argc, char *const *argv) { struct MHD_Daemon *d; unsigned int i; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } response = MHD_create_response_from_buffer_static (strlen (PAGE), (const void *) PAGE); d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TLS #ifdef EPOLL_SUPPORT | MHD_USE_EPOLL | MHD_USE_TURBO #endif , (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) NUMBER_OF_THREADS, MHD_OPTION_URI_LOG_CALLBACK, &uri_logger_cb, NULL, MHD_OPTION_NOTIFY_COMPLETED, &completed_callback, NULL, MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 1000, /* Optionally, the gnutls_load_file() can be used to load the key and the certificate from file. */ MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_signed_cert_pem, MHD_OPTION_END); if (d == NULL) return 1; (void) getc (stdin); MHD_stop_daemon (d); MHD_destroy_response (response); for (i = 0; i < SMALL; i++) if (0 != small_deltas[i]) fprintf (stdout, "D: %u %u\n", i, small_deltas[i]); return 0; } libmicrohttpd-1.0.1/src/examples/fileserver_example_external_select.c0000644000175000017500000001343114522742656021750 /* This file is part of libmicrohttpd Copyright (C) 2007, 2008 Christian Grothoff (and other contributing authors) Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file fileserver_example_external_select.c * @brief minimal example for how to use libmicrohttpd to server files * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #include #include #include #define PAGE \ "File not foundFile not found" static ssize_t file_reader (void *cls, uint64_t pos, char *buf, size_t max) { FILE *file = (FILE *) cls; size_t bytes_read; /* 'fseek' may not support files larger 2GiB, depending on platform. * For production code, make sure that 'pos' has valid values, supported by * 'fseek', or use 'fseeko' or similar function. */ if (0 != fseek (file, (long) pos, SEEK_SET)) return MHD_CONTENT_READER_END_WITH_ERROR; bytes_read = fread (buf, 1, max, file); if (0 == bytes_read) return (0 != ferror (file)) ? MHD_CONTENT_READER_END_WITH_ERROR : MHD_CONTENT_READER_END_OF_STREAM; return (ssize_t) bytes_read; } static void free_callback (void *cls) { FILE *file = cls; fclose (file); } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; FILE *file; int fd; struct stat buf; (void) cls; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, MHD_HTTP_METHOD_GET)) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ file = fopen (&url[1], "rb"); if (NULL != file) { fd = fileno (file); if (-1 == fd) { (void) fclose (file); return MHD_NO; /* internal error */ } if ( (0 != fstat (fd, &buf)) || (! S_ISREG (buf.st_mode)) ) { /* not a regular file, refuse to serve */ fclose (file); file = NULL; } } if (NULL == file) { response = MHD_create_response_from_buffer_static (strlen (PAGE), PAGE); ret = MHD_queue_response (connection, MHD_HTTP_NOT_FOUND, response); MHD_destroy_response (response); } else { response = MHD_create_response_from_callback ((size_t) buf.st_size, 32 * 1024, /* 32k page size */ &file_reader, file, &free_callback); if (NULL == response) { fclose (file); return MHD_NO; } ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); } return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; time_t end; time_t t; struct timeval tv; fd_set rs; fd_set ws; fd_set es; MHD_socket max; uint64_t mhd_timeout; int port; if (argc != 3) { printf ("%s PORT SECONDS-TO-RUN\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } d = MHD_start_daemon (MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_APP_FD_SETSIZE, (int) FD_SETSIZE, MHD_OPTION_END); if (d == NULL) return 1; end = time (NULL) + atoi (argv[2]); while ((t = time (NULL)) < end) { #if ! defined(_WIN32) || defined(__CYGWIN__) tv.tv_sec = end - t; #else /* Native W32 */ tv.tv_sec = (long) (end - t); #endif /* Native W32 */ tv.tv_usec = 0; max = 0; FD_ZERO (&rs); FD_ZERO (&ws); FD_ZERO (&es); if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) break; /* fatal internal error */ if (MHD_get_timeout64 (d, &mhd_timeout) == MHD_YES) { if (((uint64_t) tv.tv_sec) < mhd_timeout / 1000LL) { #if ! defined(_WIN32) || defined(__CYGWIN__) tv.tv_sec = (time_t) (mhd_timeout / 1000LL); #else /* Native W32 */ tv.tv_sec = (long) (mhd_timeout / 1000LL); #endif /* Native W32 */ tv.tv_usec = ((long) (mhd_timeout % 1000)) * 1000; } } if (-1 == select ((int) max + 1, &rs, &ws, &es, &tv)) { if (EINTR != errno) abort (); } MHD_run (d); } MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/refuse_post_example.c0000644000175000017500000001013614441373361016667 /* This file is part of libmicrohttpd Copyright (C) 2007, 2008 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file refuse_post_example.c * @brief example for how to refuse a POST request properly * @author Christian Grothoff and Sebastian Gerhardt * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include struct handler_param { const char *response_page; }; static const char *askpage = "\n\ Upload a file, please!
    \n\
    \n\ \n\
    \n\ "; #define BUSYPAGE \ "Webserver busy" \ "We are too busy to process POSTs right now." static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct handler_param *param = (struct handler_param *) cls; struct MHD_Response *response; enum MHD_Result ret; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if ((0 != strcmp (method, "GET")) && (0 != strcmp (method, "POST"))) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { *req_cls = &aptr; /* always to busy for POST requests */ if (0 == strcmp (method, "POST")) { response = MHD_create_response_from_buffer_static (strlen (BUSYPAGE), (const void *) BUSYPAGE); ret = MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, response); MHD_destroy_response (response); return ret; } } *req_cls = NULL; /* reset when done */ response = MHD_create_response_from_buffer_static (strlen (param->response_page), (const void *) param->response_page); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; struct handler_param data_for_handler; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } data_for_handler.response_page = askpage; d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_echo, &data_for_handler, MHD_OPTION_END); if (d == NULL) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } /* end of refuse_post_example.c */ libmicrohttpd-1.0.1/src/examples/minimal_example_comet.c0000644000175000017500000000645214441373361017154 /* This file is part of libmicrohttpd Copyright (C) 2007, 2008 Christian Grothoff (and other contributing authors) Copyright (C) 2016-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file minimal_example.c * @brief minimal example for how to generate an infinite stream with libmicrohttpd * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include static ssize_t data_generator (void *cls, uint64_t pos, char *buf, size_t max) { (void) cls; /* Unused. Silent compiler warning. */ (void) pos; /* Unused. Silent compiler warning. */ if (max < 80) return 0; memset (buf, 'A', max - 1); buf[79] = '\n'; return 80; } static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct MHD_Response *response; enum MHD_Result ret; (void) cls; /* Unused. Silent compiler warning. */ (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 80, &data_generator, NULL, NULL); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } d = MHD_start_daemon (MHD_USE_AUTO | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, (uint16_t) port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); if (d == NULL) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/examples/minimal_example.c0000644000175000017500000000712414504615230015754 /* This file is part of libmicrohttpd Copyright (C) 2007 Christian Grothoff (and other contributing authors) Copyright (C) 2014-2022 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file minimal_example.c * @brief minimal example for how to use libmicrohttpd * @author Christian Grothoff * @author Karlson2k (Evgeny Grin) */ #include "platform.h" #include #define PAGE \ "libmicrohttpd demo" \ "libmicrohttpd demo" struct handler_param { const char *response_page; }; static enum MHD_Result ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int aptr; struct handler_param *param = (struct handler_param *) cls; struct MHD_Response *response; enum MHD_Result ret; (void) url; /* Unused. Silent compiler warning. */ (void) version; /* Unused. Silent compiler warning. */ (void) upload_data; /* Unused. Silent compiler warning. */ (void) upload_data_size; /* Unused. Silent compiler warning. */ if (0 != strcmp (method, "GET")) return MHD_NO; /* unexpected method */ if (&aptr != *req_cls) { /* do never respond on first call */ *req_cls = &aptr; return MHD_YES; } *req_cls = NULL; /* reset when done */ response = MHD_create_response_from_buffer_static (strlen (param->response_page), param->response_page); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); return ret; } int main (int argc, char *const *argv) { struct MHD_Daemon *d; struct handler_param data_for_handler; int port; if (argc != 2) { printf ("%s PORT\n", argv[0]); return 1; } port = atoi (argv[1]); if ( (1 > port) || (port > 65535) ) { fprintf (stderr, "Port must be a number between 1 and 65535.\n"); return 1; } data_for_handler.response_page = PAGE; d = MHD_start_daemon (/* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, /* MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | MHD_USE_POLL, */ /* MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, */ (uint16_t) port, NULL, NULL, &ahc_echo, &data_for_handler, MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_END); if (d == NULL) return 1; (void) getc (stdin); MHD_stop_daemon (d); return 0; } libmicrohttpd-1.0.1/src/tools/0000755000175000017500000000000014566140217012053 5libmicrohttpd-1.0.1/src/tools/mhd_tool_get_cpu_count.c0000644000175000017500000007205014500102730016650 /* This file is part of GNU libmicrohttpd Copyright (C) 2023 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file tools/mhd_tool_get_cpu_count.c * @brief Implementation of functions to detect the number of available * CPU cores. * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include "mhd_tool_get_cpu_count.h" #ifdef HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H # include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS__CPUSET_H # include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_STDDEF_H # include #endif /* HAVE_STDDEF_H */ #ifdef HAVE_STRING_H # include #endif /* HAVE_STRING_H */ #ifdef HAVE_SYS_SYSCTL_H # include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_FEATURES_H # include #endif /* HAVE_FEATURES_H */ #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_VXCPULIB_H # include #endif #ifdef HAVE_WINDOWS_H # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif /* ! WIN32_LEAN_AND_MEAN */ # include # ifndef ALL_PROCESSOR_GROUPS # define ALL_PROCESSOR_GROUPS 0xFFFFu # endif /* ALL_PROCESSOR_GROUPS */ #elif defined(_WIN32) && ! defined (__CYGWIN__) # error Windows headers are required for Windows build #endif /* HAVE_WINDOWS_H */ #ifdef HAVE_SCHED_H # include #endif /* HAVE_SCHED_H */ #ifdef HAVE_SYS_CPUSET_H # include #endif /* HAVE_SYS_CPUSET_H */ #ifdef HAVE_STDBOOL_H # include #endif /* HAVE_STDBOOL_H */ #if ! defined(HAS_DECL_CPU_SETSIZE) && ! defined(CPU_SETSIZE) # define CPU_SETSIZE (1024) # define CPU_SETSIZE_SAFE (64) #else /* HAS_DECL_CPU_SETSIZE || CPU_SETSIZE */ # define CPU_SETSIZE_SAFE CPU_SETSIZE #endif /* HAS_DECL_CPU_SETSIZE || CPU_SETSIZE */ /* Check and fix possible missing macros */ #if ! defined(HAS_DECL_CTL_HW) && defined(CTL_HW) # define HAS_DECL_CTL_HW 1 #endif /* ! HAS_DECL_CTL_HW && CTL_HW */ #if ! defined(HAS_DECL_HW_NCPUONLINE) && defined(HW_NCPUONLINE) # define HAS_DECL_HW_NCPUONLINE 1 #endif /* ! HAS_DECL_HW_NCPUONLINE && HW_NCPUONLINE */ #if ! defined(HAS_DECL_HW_AVAILCPU) && defined(HW_AVAILCPU) # define HAS_DECL_HW_AVAILCPU 1 #endif /* ! HAS_DECL_HW_AVAILCPU && HW_AVAILCPU */ #if ! defined(HAS_DECL_HW_NCPU) && defined(HW_NCPU) # define HAS_DECL_HW_NCPU 1 #endif /* ! HAS_DECL_HW_NCPU && HW_NCPU */ #if ! defined(HAS_DECL__SC_NPROCESSORS_ONLN) && defined(_SC_NPROCESSORS_ONLN) # define HAS_DECL__SC_NPROCESSORS_ONLN 1 #endif /* ! HAS_DECL__SC_NPROCESSORS_ONLN && _SC_NPROCESSORS_ONLN */ #if ! defined(HAS_DECL__SC_NPROC_ONLN) && defined(_SC_NPROC_ONLN) # define HAS_DECL__SC_NPROC_ONLN 1 #endif /* ! HAS_DECL__SC_NPROC_ONLN && _SC_NPROC_ONLN */ #if ! defined(HAS_DECL__SC_CRAY_NCPU) && defined(_SC_CRAY_NCPU) # define HAS_DECL__SC_CRAY_NCPU 1 #endif /* ! HAS_DECL__SC_CRAY_NCPU && _SC_CRAY_NCPU */ #if ! defined(HAS_DECL__SC_NPROCESSORS_CONF) && defined(_SC_NPROCESSORS_CONF) # define HAS_DECL__SC_NPROCESSORS_CONF 1 #endif /* ! HAVE_DECL__SC_NPROCESSORS_CONF && _SC_NPROCESSORS_CONF */ /* Forward declarations */ static int mhd_tool_get_sys_cpu_count_sysctl_ (void); /** * Detect the number of logical CPU cores available for the process by * sched_getaffinity() (and related) function. * @return the number of detected logical CPU cores or * -1 if failed to detect (or this function unavailable). */ static int mhd_tool_get_proc_cpu_count_sched_getaffinity_ (void) { int ret = -1; #if defined(HAVE_SCHED_GETAFFINITY) && defined(HAVE_GETPID) /* Glibc style */ if (0 >= ret) { cpu_set_t cur_set; if (0 == sched_getaffinity (getpid (), sizeof (cur_set), &cur_set)) { #ifdef HAVE_CPU_COUNT ret = CPU_COUNT (&cur_set); #else /* ! HAVE_CPU_COUNT */ unsigned int i; ret = 0; for (i = 0; i < CPU_SETSIZE_SAFE; ++i) { if (CPU_ISSET (i, &cur_set)) ++ret; } if (0 == ret) ret = -1; #endif /* ! HAVE_CPU_COUNT */ } } #ifdef HAVE_CPU_COUNT_S if (0 >= ret) { /* Use 256 times larger size than size for default maximum CPU number. Hopefully it would be enough even for exotic situations. */ static const unsigned int set_size_cpus = 256 * CPU_SETSIZE; const size_t set_size_bytes = CPU_ALLOC_SIZE (set_size_cpus); cpu_set_t *p_set; p_set = CPU_ALLOC (set_size_cpus); if (NULL != p_set) { if (0 == sched_getaffinity (getpid (), set_size_bytes, p_set)) { #ifndef MHD_FUNC_CPU_COUNT_S_GETS_CPUS ret = CPU_COUNT_S (set_size_bytes, p_set); #else /* MHD_FUNC_CPU_COUNT_S_GETS_CPUS */ ret = CPU_COUNT_S (set_size_cpus, p_set); #endif /* MHD_FUNC_CPU_COUNT_S_GETS_CPUS */ } CPU_FREE (p_set); } } #endif /* HAVE_CPU_COUNT_S */ #endif /* HAVE_SCHED_GETAFFINITY && HAVE_GETPID */ if (0 >= ret) return -1; return ret; } /** * Detect the number of logical CPU cores available for the process by * cpuset_getaffinity() function. * @return the number of detected logical CPU cores or * -1 if failed to detect (or this function unavailable). */ static int mhd_tool_get_proc_cpu_count_cpuset_getaffinity_ (void) { int ret = -1; #if defined(HAVE_CPUSET_GETAFFINITY) /* FreeBSD style */ if (0 >= ret) { cpuset_t cur_mask; /* The should get "anonymous" mask/set. The anonymous mask is always a subset of the assigned set (which is a subset of the root set). */ if (0 == cpuset_getaffinity (CPU_LEVEL_WHICH, CPU_WHICH_PID, (id_t) -1, sizeof (cur_mask), &cur_mask)) { #ifdef HAVE_CPU_COUNT ret = CPU_COUNT (&cur_mask); #else /* ! HAVE_CPU_COUNT */ unsigned int i; ret = 0; for (i = 0; i < CPU_SETSIZE_SAFE; ++i) { if (CPU_ISSET (i, &cur_mask)) ++ret; } if (0 == ret) ret = -1; #endif /* ! HAVE_CPU_COUNT */ } } #ifdef HAVE_CPU_COUNT_S if (0 >= ret) { /* Use 256 times larger size than size for default maximum CPU number. Hopefully it would be enough even for exotic situations. */ static const unsigned int mask_size_cpus = 256 * CPU_SETSIZE; const size_t mask_size_bytes = CPU_ALLOC_SIZE (mask_size_cpus); cpuset_t *p_mask; p_mask = CPU_ALLOC (mask_size_cpus); if (NULL != p_mask) { if (0 == cpuset_getaffinity (CPU_LEVEL_WHICH, CPU_WHICH_PID, (id_t) -1, mask_size_bytes, p_mask)) { #ifndef MHD_FUNC_CPU_COUNT_S_GETS_CPUS ret = CPU_COUNT_S (mask_size_bytes, p_mask); #else /* MHD_FUNC_CPU_COUNT_S_GETS_CPUS */ ret = CPU_COUNT_S (mask_size_cpus, p_mask); #endif /* MHD_FUNC_CPU_COUNT_S_GETS_CPUS */ } CPU_FREE (p_mask); } } #endif /* HAVE_CPU_COUNT_S */ #endif /* HAVE_CPUSET_GETAFFINITY */ if (0 >= ret) return -1; return ret; } /** * Detect the number of logical CPU cores available for the process by * sched_getaffinity_np() (and related) function. * @return the number of detected logical CPU cores or * -1 if failed to detect (or this function unavailable). */ static int mhd_tool_get_proc_cpu_count_sched_getaffinity_np_ (void) { int ret = -1; #if defined(HAVE_SCHED_GETAFFINITY_NP) && defined(HAVE_GETPID) /* NetBSD style */ cpuset_t *cpuset_ptr; cpuset_ptr = cpuset_create (); if (NULL != cpuset_ptr) { if (0 == sched_getaffinity_np (getpid (), cpuset_size (cpuset_ptr), cpuset_ptr)) { cpuid_t cpu_num; #if defined(HAVE_SYSCONF) && defined(HAVE_DECL__SC_NPROCESSORS_CONF) unsigned int max_num = 0; long sc_value; sc_value = sysconf (_SC_NPROCESSORS_ONLN); if (0 < sc_value) max_num = (unsigned int) sc_value; if (0 < max_num) { ret = 0; for (cpu_num = 0; cpu_num < max_num; ++cpu_num) if (0 < cpuset_isset (cpu_num, cpuset_ptr)) ++ret; } else /* Combined with the next 'if' */ #endif /* HAVE_SYSCONF && HAVE_DECL__SC_NPROCESSORS_CONF */ if (1) { int res; cpu_num = 0; ret = 0; do { res = cpuset_isset (cpu_num++, cpuset_ptr); if (0 < res) ++ret; } while (0 <= res); } #ifdef __NetBSD__ if (0 == ret) { /* On NetBSD "unset" affinity (exactly zero CPUs) means "all CPUs are available". */ ret = mhd_tool_get_sys_cpu_count_sysctl_ (); } #endif /* __NetBSD__ */ } cpuset_destroy (cpuset_ptr); } #endif /* HAVE_SCHED_GETAFFINITY_NP && HAVE_GETPID */ if (0 >= ret) return -1; return ret; } /** * Detect the number of logical CPU cores available for the process by * W32 API functions. * @return the number of detected logical CPU cores or * -1 if failed to detect (or this function unavailable). */ static int mhd_tool_get_proc_cpu_count_w32_ (void) { int ret = -1; #if defined(_WIN32) && ! defined(__CYGWIN__) /* W32 Native */ /** * Maximum used number of CPU groups. * Improvement: Implement dynamic allocation when it would be reasonable */ #define MHDT_MAX_GROUP_COUNT 128 /** * The count of logical CPUs as returned by GetProcessAffinityMask() */ int count_by_proc_aff_mask; count_by_proc_aff_mask = -1; if (1) { DWORD_PTR proc_aff; DWORD_PTR sys_aff; if (GetProcessAffinityMask (GetCurrentProcess (), &proc_aff, &sys_aff)) { /* Count all set bits */ for (count_by_proc_aff_mask = 0; 0 != proc_aff; proc_aff &= proc_aff - 1) ++count_by_proc_aff_mask; } } if (0 < count_by_proc_aff_mask) { HMODULE k32hndl; k32hndl = LoadLibraryA ("kernel32.dll"); if (NULL != k32hndl) { typedef BOOL (WINAPI *GPGA_PTR)(HANDLE hProcess, PUSHORT GroupCount, PUSHORT GroupArray); GPGA_PTR ptrGetProcessGroupAffinity; ptrGetProcessGroupAffinity = (GPGA_PTR) (void *) GetProcAddress (k32hndl, "GetProcessGroupAffinity"); if (NULL == ptrGetProcessGroupAffinity) { /* Windows version before Win7 */ /* No processor groups supported, the process affinity mask gives full picture */ ret = count_by_proc_aff_mask; } else { /* Windows version Win7 or later */ /* Processor groups are supported */ USHORT arr_elements = MHDT_MAX_GROUP_COUNT; USHORT groups_arr[MHDT_MAX_GROUP_COUNT]; /* Hopefully should be enough */ /* Improvement: Implement dynamic allocation when it would be reasonable */ /** * Exactly one processor group is assigned to the process */ bool single_cpu_group_assigned; /**< Exactly one processor group is assigned to the process */ struct mhdt_GR_AFFINITY { KAFFINITY Mask; WORD Group; WORD Reserved[3]; }; typedef BOOL (WINAPI *GPDCSM_PTR)(HANDLE Process, struct mhdt_GR_AFFINITY *CpuSetMasks, USHORT CpuSetMaskCount, USHORT *RequiredMaskCount); GPDCSM_PTR ptrGetProcessDefaultCpuSetMasks; bool win_fe_or_later; bool cpu_set_mask_assigned; single_cpu_group_assigned = false; if (ptrGetProcessGroupAffinity (GetCurrentProcess (), &arr_elements, groups_arr)) { if (1 == arr_elements) { /* Exactly one processor group assigned to the process */ single_cpu_group_assigned = true; #if 0 /* Disabled code */ /* The value returned by GetThreadGroupAffinity() is not relevant as for the new threads the process affinity mask is used. */ ULONG_PTR proc_aff2; typedef BOOL (WINAPI *GTGA_PTR)(HANDLE hThread, struct mhdt_GR_AFFINITY * GroupAffinity); GTGA_PTR ptrGetThreadGroupAffinity; ptrGetThreadGroupAffinity = (GTGA_PTR) (void *) GetProcAddress (k32hndl, "GetThreadGroupAffinity"); if (NULL != ptrGetThreadGroupAffinity) { struct mhdt_GR_AFFINITY thr_gr_aff; if (ptrGetThreadGroupAffinity (GetCurrentThread (), &thr_gr_aff)) proc_aff2 = (ULONG_PTR) thr_gr_aff.Mask; } #endif /* Disabled code */ } } ptrGetProcessDefaultCpuSetMasks = (GPDCSM_PTR) (void *) GetProcAddress (k32hndl, "GetProcessDefaultCpuSetMasks"); if (NULL != ptrGetProcessDefaultCpuSetMasks) { /* This is Iron Release / Codename Fe (also know as Windows 11 and Windows Server 2022) or later version */ struct mhdt_GR_AFFINITY gr_affs[MHDT_MAX_GROUP_COUNT]; /* Hopefully should be enough */ /* Improvement: Implement dynamic allocation when it would be reasonable */ USHORT num_elm; win_fe_or_later = true; if (ptrGetProcessDefaultCpuSetMasks (GetCurrentProcess (), gr_affs, sizeof (gr_affs) / sizeof (gr_affs[0]), &num_elm)) { if (0 == num_elm) { /* No group mask set */ cpu_set_mask_assigned = false; } else cpu_set_mask_assigned = true; } else cpu_set_mask_assigned = true; /* Assume the worst case */ } else { win_fe_or_later = false; cpu_set_mask_assigned = false; } if (! win_fe_or_later) { /* The OS is not capable of distributing threads across different processor groups. Results reported by GetProcessAffinityMask() are relevant for the main processor group for the process. */ ret = count_by_proc_aff_mask; } else { /* The of is capable of automatic threads distribution across processor groups. */ if (cpu_set_mask_assigned) { /* Assigned Default CpuSet Masks combines with "classic" affinity in the not fully clear way. The combination is not documented and this functionality could be changed any moment. */ ret = -1; } else { if (! single_cpu_group_assigned) { /* This is a multi processor group process on Win11 (or later). Each processor group may have different affinity and the OS has not API to get it. For example, affinity to the main processor group could be assigned by SetProcessAffinityMask() function, which converts the process to the single-processor-group type, but if SetThreadGroupAffinity() is called later and bind the thread to another processor group, the process becomes multi-processor- group again, however the initial affinity mask is still used for the initial (main) processor group. There is no API to read it. It is also possible that processor groups have different number of processors. */ ret = -1; } else { /* Single-processor-group process on Win11 (or later) without assigned Default CpuSet Masks. */ ret = count_by_proc_aff_mask; } } } } FreeLibrary (k32hndl); } } #endif /* _WIN32 && ! __CYGWIN__ */ if (0 >= ret) return -1; return ret; } /** * Detect the number of logical CPU cores available for the process. * The number of cores available for this process could be different from * value of cores available on the system. The OS may have limit on number * assigned/allowed cores for single process and process may have limited * CPU affinity. * @return the number of logical CPU cores available for the process or * -1 if failed to detect */ int mhd_tool_get_proc_cpu_count (void) { int res; #if defined(__linux__) || defined(__GLIBC__) /* On Linux kernel try first 'sched_getaffinity()' as it should be the native API. Also try it first on other kernels if Glibc is used. */ res = mhd_tool_get_proc_cpu_count_sched_getaffinity_ (); if (0 < res) return res; res = mhd_tool_get_proc_cpu_count_cpuset_getaffinity_ (); if (0 < res) return res; #else /* ! __linux__ && ! __GLIBC__ */ /* On non-Linux kernels 'cpuset_getaffinity()' could be the native API, while 'sched_getaffinity()' could be implemented in compatibility layer. */ res = mhd_tool_get_proc_cpu_count_cpuset_getaffinity_ (); if (0 < res) return res; res = mhd_tool_get_proc_cpu_count_sched_getaffinity_ (); if (0 < res) return res; #endif /* ! __linux__ && ! __GLIBC__ */ res = mhd_tool_get_proc_cpu_count_sched_getaffinity_np_ (); if (0 < res) return res; res = mhd_tool_get_proc_cpu_count_w32_ (); if (0 < res) return res; return -1; } /** * Detect the number of processors by special API functions * @return number of processors as returned by special API functions or * -1 in case of error or special API functions unavailable */ static int mhd_tool_get_sys_cpu_count_special_api_ (void) { int ret = -1; #ifdef HAVE_PSTAT_GETDYNAMIC if (0 >= ret) { /* HP-UX things */ struct pst_dynamic psd_data; memset ((void *) &psd_data, 0, sizeof (psd_data)); if (1 == pstat_getdynamic (&psd_data, sizeof (psd_data), (size_t) 1, 0)) { if (0 < psd_data.psd_proc_cnt) ret = (int) psd_data.psd_proc_cnt; } } #endif /* HAVE_PSTAT_GETDYNAMIC */ #ifdef HAVE_VXCPUENABLEDGET if (0 >= ret) { /* VxWorks */ cpuset_t enb_set; enb_set = vxCpuEnabledGet (); /* Count set bits */ for (ret = 0; 0 != enb_set; enb_set &= enb_set - 1) ++ret; } #endif /* HAVE_VXCPUENABLEDGET */ #if defined(_WIN32) && ! defined (__CYGWIN__) if (0 >= ret) { /* Native W32 */ HMODULE k32hndl; k32hndl = LoadLibraryA ("kernel32.dll"); if (NULL != k32hndl) { typedef DWORD (WINAPI *GAPC_PTR)(WORD GroupNumber); GAPC_PTR ptrGetActiveProcessorCount; /* Available on W7 or later */ ptrGetActiveProcessorCount = (GAPC_PTR) (void *) GetProcAddress (k32hndl, "GetActiveProcessorCount"); if (NULL != ptrGetActiveProcessorCount) { DWORD res; res = ptrGetActiveProcessorCount (ALL_PROCESSOR_GROUPS); ret = (int) res; if (res != (DWORD) ret) ret = -1; /* Overflow */ } } if ((0 >= ret) && (NULL != k32hndl)) { typedef void (WINAPI *GNSI_PTR)(SYSTEM_INFO *pSysInfo); GNSI_PTR ptrGetNativeSystemInfo; /* May give incorrect (low) result on versions from W7 to W11 when more then 64 CPUs are available */ ptrGetNativeSystemInfo = (GNSI_PTR) (void *) GetProcAddress (k32hndl, "GetNativeSystemInfo"); if (NULL != ptrGetNativeSystemInfo) { SYSTEM_INFO sysInfo; memset ((void *) &sysInfo, 0, sizeof (sysInfo)); ptrGetNativeSystemInfo (&sysInfo); ret = (int) sysInfo.dwNumberOfProcessors; if (sysInfo.dwNumberOfProcessors != (DWORD) ret) ret = -1; /* Overflow */ } } if (NULL != k32hndl) FreeLibrary (k32hndl); } if (0 >= ret) { /* May give incorrect (low) result on versions from W7 to W11 when more then 64 CPUs are available */ SYSTEM_INFO sysInfo; memset ((void *) &sysInfo, 0, sizeof (sysInfo)); GetSystemInfo (&sysInfo); ret = (int) sysInfo.dwNumberOfProcessors; if (sysInfo.dwNumberOfProcessors != (DWORD) ret) ret = -1; /* Overflow */ } #endif /* _WIN32 && ! __CYGWIN__ */ if (0 >= ret) return -1; return ret; } /** * Detect the number of processors by sysctl*() functions in reliable way. * * This function uses reliable identificators that coreponds to actual * number of CPU cores online currently. * @return number of processors as returned by 'sysctl*' functions or * -1 in case of error or the number cannot be detected * by these functions */ static int mhd_tool_get_sys_cpu_count_sysctl_ (void) { int ret = -1; /* Do not use sysctl() function on GNU/Linux even if sysctl() is available */ #ifndef __linux__ #ifdef HAVE_SYSCTLBYNAME if (0 >= ret) { size_t value_size = sizeof (ret); /* Darwin: The number of available logical CPUs */ if ((0 != sysctlbyname ("hw.logicalcpu", &ret, &value_size, NULL, 0)) || (sizeof (ret) != value_size)) ret = -1; } if (0 >= ret) { size_t value_size = sizeof (ret); /* FreeBSD: The number of online CPUs */ if ((0 != sysctlbyname ("kern.smp.cpus", &ret, &value_size, NULL, 0)) || (sizeof (ret) != value_size)) ret = -1; } if (0 >= ret) { size_t value_size = sizeof (ret); /* Darwin: The current number of CPUs available to run threads */ if ((0 != sysctlbyname ("hw.activecpu", &ret, &value_size, NULL, 0)) || (sizeof (ret) != value_size)) ret = -1; } if (0 >= ret) { size_t value_size = sizeof (ret); /* OpenBSD, NetBSD: The number of online CPUs */ if ((0 != sysctlbyname ("hw.ncpuonline", &ret, &value_size, NULL, 0)) || (sizeof (ret) != value_size)) ret = -1; } if (0 >= ret) { size_t value_size = sizeof (ret); /* Darwin: The old/alternative name for "hw.activecpu" */ if ((0 != sysctlbyname ("hw.availcpu", &ret, &value_size, NULL, 0)) || (sizeof (ret) != value_size)) ret = -1; } #endif /* HAVE_SYSCTLBYNAME */ #if defined(HAVE_SYSCTL) && \ defined(HAS_DECL_CTL_HW) && \ defined(HAS_DECL_HW_NCPUONLINE) if (0 >= ret) { /* OpenBSD, NetBSD: The number of online CPUs */ int mib[2] = {CTL_HW, HW_NCPUONLINE}; size_t value_size = sizeof (ret); if ((0 != sysctl (mib, 2, &ret, &value_size, NULL, 0)) || (sizeof (ret) != value_size)) ret = -1; } #endif /* HAVE_SYSCTL && HAS_DECL_CTL_HW && HAS_DECL_HW_NCPUONLINE */ #if defined(HAVE_SYSCTL) && \ defined(HAS_DECL_CTL_HW) && \ defined(HAS_DECL_HW_AVAILCPU) if (0 >= ret) { /* Darwin: The MIB name for "hw.activecpu" */ int mib[2] = {CTL_HW, HW_AVAILCPU}; size_t value_size = sizeof (ret); if ((0 != sysctl (mib, 2, &ret, &value_size, NULL, 0)) || (sizeof (ret) != value_size)) ret = -1; } #endif /* HAVE_SYSCTL && HAS_DECL_CTL_HW && HAS_DECL_HW_AVAILCPU */ #endif /* ! __linux__ */ if (0 >= ret) return -1; return ret; } /** * Detect the number of processors by sysctl*() functions, using fallback way. * * This function uses less reliable (compared to * #mhd_tool_get_sys_cpu_count_sysctl_()) ways to detect the number of * available CPU cores and may return values corresponding to the number of * physically available (but possibly not used by the kernel) CPU logical cores. * @return number of processors as returned by 'sysctl*' functions or * -1 in case of error or the number cannot be detected * by these functions */ static int mhd_tool_get_sys_cpu_count_sysctl_fallback_ (void) { int ret = -1; /* Do not use sysctl() function on GNU/Linux even if sysctl() is available */ #ifndef __linux__ #ifdef HAVE_SYSCTLBYNAME if (0 >= ret) { size_t value_size = sizeof (ret); /* FreeBSD, OpenBSD, NetBSD, Darwin (and others?): The number of CPUs */ if ((0 != sysctlbyname ("hw.ncpu", &ret, &value_size, NULL, 0)) || (sizeof (ret) != value_size)) ret = -1; } #endif /* HAVE_SYSCTLBYNAME */ #if defined(HAVE_SYSCTL) && \ defined(HAS_DECL_CTL_HW) && \ defined(HAS_DECL_HW_NCPU) if (0 >= ret) { /* FreeBSD, OpenBSD, NetBSD, Darwin (and others?): The number of CPUs */ int mib[2] = {CTL_HW, HW_NCPU}; size_t value_size = sizeof (ret); if ((0 != sysctl (mib, 2, &ret, &value_size, NULL, 0)) || (sizeof (ret) != value_size)) ret = -1; } #endif /* HAVE_SYSCTL && HAS_DECL_CTL_HW && HAS_DECL_HW_NCPU */ #endif /* ! __linux__ */ if (0 >= ret) return -1; return ret; } /** * Detect the number of processors by sysconf() function in reliable way. * * This function uses reliable identificators that coreponds to actual * number of CPU cores online currently. * @return number of processors as returned by 'sysconf' function or * -1 in case of error or 'sysconf' unavailable */ static int mhd_tool_get_sys_cpu_count_sysconf_ (void) { int ret = -1; #if defined(HAVE_SYSCONF) && \ (defined(HAS_DECL__SC_NPROCESSORS_ONLN) || defined(HAS_DECL__SC_NPROC_ONLN)) long value = -1; #ifdef HAS_DECL__SC_NPROCESSORS_ONLN if (0 >= value) value = sysconf (_SC_NPROCESSORS_ONLN); #endif /* HAS_DECL__SC_NPROCESSORS_ONLN */ #ifdef HAS_DECL__SC_NPROC_ONLN if (0 >= value) value = sysconf (_SC_NPROC_ONLN); #endif /* HAS_DECL__SC_NPROC_ONLN */ if (0 >= value) return -1; ret = (int) value; if ((long) ret != value) return -1; /* Overflow */ #endif /* HAVE_SYSCONF && (HAS_DECL__SC_NPROCESSORS_ONLN || HAS_DECL__SC_NPROC_ONLN) */ return ret; } /** * Detect the number of processors by sysconf() function, using fallback way. * * This function uses less reliable (compared to * #mhd_tool_get_sys_cpu_count_sysconf_()) ways to detect the number of * available CPU cores and may return values corresponding to the number of * physically available (but possibly not used by the kernel) CPU logical cores. * @return number of processors as returned by 'sysconf' function or * -1 in case of error or 'sysconf' unavailable */ static int mhd_tool_get_sys_cpu_count_sysconf_fallback_ (void) { int ret = -1; #if defined(HAVE_SYSCONF) && \ (defined(HAS_DECL__SC_CRAY_NCPU) || defined(HAS_DECL__SC_NPROCESSORS_CONF)) long value = -1; #ifdef HAS_DECL__SC_CRAY_NCPU if (0 >= value) value = sysconf (_SC_CRAY_NCPU); #endif /* HAS_DECL__SC_CRAY_NCPU */ #ifdef HAS_DECL__SC_NPROCESSORS_CONF if (0 >= value) value = sysconf (_SC_NPROCESSORS_CONF); #endif /* HAS_DECL__SC_NPROCESSORS_CONF */ if (0 >= value) return -1; ret = (int) value; if ((long) ret != value) return -1; /* Overflow */ #endif /* HAVE_SYSCONF && (HAS_DECL__SC_CRAY_NCPU || HAS_DECL__SC_NPROCESSORS_CONF) */ return ret; } /** * Try to detect the number of logical CPU cores available for the system. * The number of available logical CPU cores could be changed any time due to * CPU hotplug. * @return the number of logical CPU cores available, * -1 if failed to detect. */ int mhd_tool_get_system_cpu_count (void) { int res; /* Try specialised APIs first */ res = mhd_tool_get_sys_cpu_count_special_api_ (); if (0 < res) return res; /* Try sysctl*(). This is typically a direct interface to kernel values. */ res = mhd_tool_get_sys_cpu_count_sysctl_ (); if (0 < res) return res; /* Try sysconf() as the last resort as this is a generic interface which can be implemented by parsing system files. */ res = mhd_tool_get_sys_cpu_count_sysconf_ (); #if ! defined(__linux__) && ! defined(__GLIBC__) if (0 < res) return res; #else /* __linux__ || __GLIBC__ */ if (2 < res) return res; if (0 < res) { /* '1' or '2' could a be fallback number. * See get_nprocs_fallback() in glibc sysdeps/unix/sysv/linux/getsysstats.c */ int proc_cpu_count; proc_cpu_count = mhd_tool_get_proc_cpu_count (); if (proc_cpu_count == res) { /* The detected number of CPUs available for the process is equal to the detected number of system CPUs. Assume detected number is correct. */ return res; } } #endif /* __linux__ || __GLIBC__ */ /* Try available fallbacks */ res = mhd_tool_get_sys_cpu_count_sysctl_fallback_ (); if (0 < res) return res; res = mhd_tool_get_sys_cpu_count_sysconf_fallback_ (); #if ! defined(__linux__) && ! defined(__GLIBC__) if (0 < res) return res; #else /* __linux__ || __GLIBC__ */ if (2 < res) return res; #endif /* __linux__ || __GLIBC__ */ return -1; /* Cannot detect */ } libmicrohttpd-1.0.1/src/tools/Makefile.am0000644000175000017500000000167614464360003014033 # This Makefile.am is in the public domain SUBDIRS = . AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -DMHD_REAL_CPU_COUNT=@MHD_REAL_CPU_COUNT@ \ -DMHD_CPU_COUNT=$(CPU_COUNT) \ $(CPPFLAGS_ac) \ -DDATA_DIR=\"$(top_srcdir)/src/datadir/\" AM_CFLAGS = $(CFLAGS_ac) @LIBGCRYPT_CFLAGS@ AM_LDFLAGS = $(LDFLAGS_ac) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) if USE_COVERAGE AM_CFLAGS += --coverage endif LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la # Tools noinst_PROGRAMS = if USE_THREADS noinst_PROGRAMS += \ perf_replies endif perf_replies_SOURCES = \ perf_replies.c mhd_tool_str_to_uint.h \ mhd_tool_get_cpu_count.h mhd_tool_get_cpu_count.c libmicrohttpd-1.0.1/src/tools/Makefile.in0000644000175000017500000006440414566140141014044 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @USE_COVERAGE_TRUE@am__append_1 = --coverage noinst_PROGRAMS = $(am__EXEEXT_1) @USE_THREADS_TRUE@am__append_2 = \ @USE_THREADS_TRUE@ perf_replies subdir = src/tools ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @USE_THREADS_TRUE@am__EXEEXT_1 = perf_replies$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) am_perf_replies_OBJECTS = perf_replies.$(OBJEXT) \ mhd_tool_get_cpu_count.$(OBJEXT) perf_replies_OBJECTS = $(am_perf_replies_OBJECTS) perf_replies_LDADD = $(LDADD) perf_replies_DEPENDENCIES = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/mhd_tool_get_cpu_count.Po \ ./$(DEPDIR)/perf_replies.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(perf_replies_SOURCES) DIST_SOURCES = $(perf_replies_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in \ $(top_srcdir)/build-aux/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # This Makefile.am is in the public domain SUBDIRS = . AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -DMHD_REAL_CPU_COUNT=@MHD_REAL_CPU_COUNT@ \ -DMHD_CPU_COUNT=$(CPU_COUNT) \ $(CPPFLAGS_ac) \ -DDATA_DIR=\"$(top_srcdir)/src/datadir/\" AM_CFLAGS = $(CFLAGS_ac) @LIBGCRYPT_CFLAGS@ $(am__append_1) AM_LDFLAGS = $(LDFLAGS_ac) AM_TESTS_ENVIRONMENT = $(TESTS_ENVIRONMENT_ac) LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la perf_replies_SOURCES = \ perf_replies.c mhd_tool_str_to_uint.h \ mhd_tool_get_cpu_count.h mhd_tool_get_cpu_count.c all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/tools/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list perf_replies$(EXEEXT): $(perf_replies_OBJECTS) $(perf_replies_DEPENDENCIES) $(EXTRA_perf_replies_DEPENDENCIES) @rm -f perf_replies$(EXEEXT) $(AM_V_CCLD)$(LINK) $(perf_replies_OBJECTS) $(perf_replies_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mhd_tool_get_cpu_count.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perf_replies.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(PROGRAMS) installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ mostlyclean-am distclean: distclean-recursive -rm -f ./$(DEPDIR)/mhd_tool_get_cpu_count.Po -rm -f ./$(DEPDIR)/perf_replies.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/mhd_tool_get_cpu_count.Po -rm -f ./$(DEPDIR)/perf_replies.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--depfiles check check-am clean clean-generic clean-libtool \ clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am .PRECIOUS: Makefile $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/src/tools/mhd_tool_get_cpu_count.h0000644000175000017500000000357014464360003016666 /* This file is part of GNU libmicrohttpd Copyright (C) 2023 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file tools/mhd_tool_get_cpu_count.h * @brief Declaration of functions to detect the number of available * CPU cores. * @author Karlson2k (Evgeny Grin) */ #ifndef SRC_TOOLS_MHD_TOOL_GET_CPU_COUNT_H_ #define SRC_TOOLS_MHD_TOOL_GET_CPU_COUNT_H_ 1 /** * Detect the number of logical CPU cores available for the process. * The number of cores available for this process could be different from * value of cores available on the system. The OS may have limit on number * assigned/allowed cores for single process and process may have limited * CPU affinity. * @return the number of logical CPU cores available for the process or * -1 if failed to detect */ int mhd_tool_get_proc_cpu_count (void); /** * Try to detect the number of logical CPU cores available for the system. * The number of available logical CPU cores could be changed any time due to * CPU hotplug. * @return the number of logical CPU cores available, * -1 if failed to detect. */ int mhd_tool_get_system_cpu_count (void); #endif /* SRC_TOOLS_MHD_TOOL_GET_CPU_COUNT_H_ */ libmicrohttpd-1.0.1/src/tools/perf_replies.c0000644000175000017500000015460014556705750014634 /* This file is part of GNU libmicrohttpd Copyright (C) 2023 Evgeny Grin (Karlson2k) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice unmodified, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * @file tools/perf_replies.c * @brief Implementation of HTTP server optimised for fast replies * based on MHD. * @author Karlson2k (Evgeny Grin) */ #include "mhd_options.h" #include #include #include #include #include "microhttpd.h" #include "mhd_tool_str_to_uint.h" #include "mhd_tool_get_cpu_count.h" #if defined(MHD_REAL_CPU_COUNT) #if MHD_REAL_CPU_COUNT == 0 #undef MHD_REAL_CPU_COUNT #endif /* MHD_REAL_CPU_COUNT == 0 */ #endif /* MHD_REAL_CPU_COUNT */ #define PERF_RPL_ERR_CODE_BAD_PARAM 65 #ifndef MHD_STATICSTR_LEN_ /** * Determine length of static string / macro strings at compile time. */ #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) #endif /* ! MHD_STATICSTR_LEN_ */ /* Static constants */ static const char *const tool_copyright = "Copyright (C) 2023 Evgeny Grin (Karlson2k)"; /* Package or build specific string, like "Debian 1.2.3-4" or "RevX, built by MSYS2" */ static const char *const build_revision = "" #ifdef MHD_BUILD_REV_STR MHD_BUILD_REV_STR #endif /* MHD_BUILD_REV_STR */ ; #define PERF_REPL_PORT_FALLBACK 48080 /* Dynamic variables */ static char self_name[500] = "perf_replies"; static uint16_t mhd_port = 0; static void set_self_name (int argc, char *const *argv) { if ((argc >= 1) && (NULL != argv[0])) { const char *last_dir_sep; last_dir_sep = strrchr (argv[0], '/'); #ifdef _WIN32 if (1) { const char *last_w32_dir_sep; last_w32_dir_sep = strrchr (argv[0], '\\'); if ((NULL == last_dir_sep) || ((NULL != last_w32_dir_sep) && (last_w32_dir_sep > last_dir_sep))) last_dir_sep = last_w32_dir_sep; } #endif /* _WIN32 */ if (NULL != last_dir_sep) { size_t name_len; name_len = strlen (last_dir_sep + 1); if ((0 != name_len) && ((sizeof(self_name) / sizeof(char)) > name_len)) { strcpy (self_name, last_dir_sep + 1); return; } } } /* Set default name */ strcpy (self_name, "perf_replies"); return; } static unsigned int detect_cpu_core_count (void) { int sys_cpu_count; sys_cpu_count = mhd_tool_get_system_cpu_count (); if (0 >= sys_cpu_count) { int proc_cpu_count; fprintf (stderr, "Failed to detect the number of logical CPU cores " "available on the system.\n"); proc_cpu_count = mhd_tool_get_proc_cpu_count (); if (0 < proc_cpu_count) { fprintf (stderr, "The number of CPU cores available for this process " "is used as a fallback.\n"); sys_cpu_count = proc_cpu_count; } #ifdef MHD_REAL_CPU_COUNT if (0 >= sys_cpu_count) { fprintf (stderr, "configure-detected hardcoded number is used " "as a fallback.\n"); sys_cpu_count = MHD_REAL_CPU_COUNT; } #endif if (0 >= sys_cpu_count) sys_cpu_count = 1; printf ("Assuming %d logical CPU core%s on this system.\n", sys_cpu_count, (1 == sys_cpu_count) ? "" : "s"); } else { printf ("Detected %d logical CPU core%s on this system.\n", sys_cpu_count, (1 == sys_cpu_count) ? "" : "s"); } return (unsigned int) sys_cpu_count; } static unsigned int get_cpu_core_count (void) { static unsigned int num_cpu_cores = 0; if (0 == num_cpu_cores) num_cpu_cores = detect_cpu_core_count (); return num_cpu_cores; } static unsigned int detect_process_cpu_core_count (void) { unsigned int num_proc_cpu_cores; unsigned int sys_cpu_cores; int res; sys_cpu_cores = get_cpu_core_count (); res = mhd_tool_get_proc_cpu_count (); if (0 > res) { fprintf (stderr, "Cannot detect the number of logical CPU cores available " "for this process.\n"); if (1 != sys_cpu_cores) printf ("Assuming all %u system logical CPU cores are available to run " "threads of this process.\n", sys_cpu_cores); else printf ("Assuming single logical CPU core available for this process.\n"); num_proc_cpu_cores = sys_cpu_cores; } else { printf ("Detected %d logical CPU core%s available to run threads " "of this process.\n", res, (1 == res) ? "" : "s"); num_proc_cpu_cores = (unsigned int) res; } if (num_proc_cpu_cores > sys_cpu_cores) { fprintf (stderr, "WARNING: Detected number of CPU cores available " "for this process (%u) is larger than detected number " "of CPU cores on the system (%u).\n", num_proc_cpu_cores, sys_cpu_cores); num_proc_cpu_cores = sys_cpu_cores; fprintf (stderr, "Using %u as the number of logical CPU cores available " "for this process.\n", num_proc_cpu_cores); } return num_proc_cpu_cores; } static unsigned int get_process_cpu_core_count (void) { static unsigned int proc_num_cpu_cores = 0; if (0 == proc_num_cpu_cores) proc_num_cpu_cores = detect_process_cpu_core_count (); return proc_num_cpu_cores; } static unsigned int num_threads = 0; static unsigned int get_num_threads (void) { #if 0 /* disalbed code */ static const unsigned int max_threads = 32; #endif /* disalbed code */ if (0 < num_threads) return num_threads; num_threads = get_cpu_core_count () / 2; if (0 == num_threads) num_threads = 1; else { unsigned int num_proc_cpus; num_proc_cpus = get_process_cpu_core_count (); if (num_proc_cpus >= num_threads) { printf ("Using half of all available CPU cores, assuming the other half " "is used by client / requests generator.\n"); } else { printf ("Using all CPU cores available for this process as more than " "half of CPU cores on this system are still available for use " "by client / requests generator.\n"); num_threads = num_proc_cpus; } } #if 0 /* disalbed code */ if (max_threads < num_threads) { printf ("Number of threads are limited to %u as more threads " "are unlikely to improve the performance.\n", max_threads); num_threads = max_threads; } #endif /* disalbed code */ return num_threads; } /** * The result of short parameters processing */ enum PerfRepl_param_result { PERF_RPL_PARAM_ERROR, /**< Error processing parameter */ PERF_RPL_PARAM_ONE_CHAR, /**< Processed exactly one character */ PERF_RPL_PARAM_FULL_STR, /**< Processed current parameter completely */ PERF_RPL_PARAM_STR_PLUS_NEXT /**< Current parameter completely and next parameter processed */ }; /** * Extract parameter value * @param param_name the name of the parameter * @param param_tail the pointer to the character after parameter name in * the parameter string * @param next_param the pointer to the next parameter (if any) or NULL * @param[out] param_value the pointer where to store resulting value * @return enum value, the PERF_PERPL_SPARAM_ONE_CHAR is not used by * this function */ static enum PerfRepl_param_result get_param_value (const char *param_name, const char *param_tail, const char *next_param, unsigned int *param_value) { const char *value_str; size_t digits; if (0 != param_tail[0]) { if ('=' != param_tail[0]) value_str = param_tail; else value_str = param_tail + 1; } else value_str = next_param; if (NULL != value_str) digits = mhd_tool_str_to_uint (value_str, param_value); else digits = 0; if ((0 == digits) || (0 != value_str[digits])) { fprintf (stderr, "Parameter '%s' is not followed by valid number.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (0 != param_tail[0]) return PERF_RPL_PARAM_FULL_STR; return PERF_RPL_PARAM_STR_PLUS_NEXT; } static void show_help (void) { printf ("Usage: %s [OPTIONS] [PORT_NUMBER]\n", self_name); printf ("Start MHD-based web-server optimised for fast replies.\n"); printf ("\n"); printf ("Threads options (mutually exclusive):\n"); printf (" -A, --all-cpus use all available CPU cores (for \n" " testing with remote client)\n"); printf (" -t NUM, --threads=NUM use NUM threads\n"); printf (" -P, --thread-per-conn use thread-per-connection mode,\n" " the number of threads are limited only\n" " by the number of connection\n"); printf ("\n"); printf ("Force polling function (mutually exclusive):\n"); if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_EPOLL)) printf (" -e, --epoll use 'epoll' functionality\n"); if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_POLL)) printf (" -p, --poll use poll() function\n"); printf (" -s, --select use select() function\n"); printf ("\n"); printf ("Response body size options (mutually exclusive):\n"); printf (" -E, --empty empty response, 0 bytes\n"); printf (" -T, --tiny tiny response, 3 bytes (default)\n"); printf (" -M, --medium medium response, 8 KB\n"); printf (" -L, --large large response, 1 MB\n"); printf ("\n"); printf ("Response use options (mutually exclusive):\n"); printf (" -S, --shared pool of pre-generated shared response\n" " objects (default)\n"); printf (" -I, --single single pre-generated response object\n" " used for all requests\n"); printf (" -U, --unique response object generated for every\n" " request and used one time only\n"); printf ("\n"); printf ("Other options:\n"); printf (" -c NUM, --connections=NUM reject more than NUM client \n" " connections\n"); printf (" -O NUM, --timeout=NUM set connection timeout to NUM seconds,\n" " zero means no timeout\n"); printf (" --date-header use the 'Date:' header in every\n" " reply\n"); printf (" --help display this help and exit\n"); printf (" -V, --version output version information and exit\n"); printf ("\n"); printf ("This tool is part of GNU libmicrohttpd suite.\n"); printf ("%s\n", tool_copyright); } struct PerfRepl_parameters { unsigned int port; int all_cpus; unsigned int threads; int thread_per_conn; int epoll; int poll; int select; int empty; int tiny; int medium; int large; int shared; int single; int unique; unsigned int connections; unsigned int timeout; int date_header; int help; int version; }; static struct PerfRepl_parameters tool_params = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static enum PerfRepl_param_result process_param__all_cpus (const char *param_name) { if (0 != tool_params.threads) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-t' or '--threads'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.thread_per_conn) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-P' or '--thread-per-conn'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.all_cpus = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } /** * Process parameter '-t' or '--threads' * @param param_name the name of the parameter as specified in command line * @param param_tail the pointer to the character after parameter name in * the parameter string * @param next_param the pointer to the next parameter (if any) or NULL * @return enum value, the PERF_PERPL_SPARAM_ONE_CHAR is not used by * this function */ static enum PerfRepl_param_result process_param__threads (const char *param_name, const char *param_tail, const char *next_param) { unsigned int param_value; enum PerfRepl_param_result value_res; if (tool_params.all_cpus) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-A' or '--all-cpus'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.thread_per_conn) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-P' or '--thread-per-conn'.\n", param_name); return PERF_RPL_PARAM_ERROR; } value_res = get_param_value (param_name, param_tail, next_param, ¶m_value); if (PERF_RPL_PARAM_ERROR == value_res) return value_res; if (0 == param_value) { fprintf (stderr, "'0' is not valid value for parameter '%s'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.threads = param_value; return value_res; } static enum PerfRepl_param_result process_param__thread_per_conn (const char *param_name) { if (tool_params.all_cpus) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-A' or '--all-cpus'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (0 != tool_params.threads) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-t' or '--threads'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.thread_per_conn = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__epoll (const char *param_name) { if (tool_params.poll) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-p' or '--poll'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.select) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-s' or '--select'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.epoll = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__poll (const char *param_name) { if (tool_params.epoll) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-e' or '--epoll'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.select) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-s' or '--select'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.poll = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__select (const char *param_name) { if (tool_params.epoll) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-e' or '--epoll'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.poll) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-p' or '--poll'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.select = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__empty (const char *param_name) { if (tool_params.tiny) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-T' or '--tiny'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.medium) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-M' or '--medium'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.large) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-L' or '--large'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.empty = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__tiny (const char *param_name) { if (tool_params.empty) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-E' or '--empty'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.medium) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-M' or '--medium'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.large) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-L' or '--large'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.tiny = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__medium (const char *param_name) { if (tool_params.empty) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-E' or '--empty'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.tiny) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-T' or '--tiny'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.large) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-L' or '--large'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.medium = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__large (const char *param_name) { if (tool_params.empty) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-E' or '--empty'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.tiny) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-T' or '--tiny'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.medium) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-M' or '--medium'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.large = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__shared (const char *param_name) { if (tool_params.single) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-I' or '--single'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.unique) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-U' or '--unique'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.shared = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__single (const char *param_name) { if (tool_params.shared) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-S' or '--shared'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.unique) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-U' or '--unique'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.single = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__unique (const char *param_name) { if (tool_params.shared) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-S' or '--shared'.\n", param_name); return PERF_RPL_PARAM_ERROR; } if (tool_params.single) { fprintf (stderr, "Parameter '%s' cannot be used together " "with '-I' or '--single'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.unique = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } /** * Process parameter '-c' or '--connections' * @param param_name the name of the parameter as specified in command line * @param param_tail the pointer to the character after parameter name in * the parameter string * @param next_param the pointer to the next parameter (if any) or NULL * @return enum value, the PERF_PERPL_SPARAM_ONE_CHAR is not used by * this function */ static enum PerfRepl_param_result process_param__connections (const char *param_name, const char *param_tail, const char *next_param) { unsigned int param_value; enum PerfRepl_param_result value_res; value_res = get_param_value (param_name, param_tail, next_param, ¶m_value); if (PERF_RPL_PARAM_ERROR == value_res) return value_res; if (0 == param_value) { fprintf (stderr, "'0' is not valid value for parameter '%s'.\n", param_name); return PERF_RPL_PARAM_ERROR; } tool_params.connections = param_value; return value_res; } /** * Process parameter '-O' or '--timeout' * @param param_name the name of the parameter as specified in command line * @param param_tail the pointer to the character after parameter name in * the parameter string * @param next_param the pointer to the next parameter (if any) or NULL * @return enum value, the PERF_PERPL_SPARAM_ONE_CHAR is not used by * this function */ static enum PerfRepl_param_result process_param__timeout (const char *param_name, const char *param_tail, const char *next_param) { unsigned int param_value; enum PerfRepl_param_result value_res; value_res = get_param_value (param_name, param_tail, next_param, ¶m_value); if (PERF_RPL_PARAM_ERROR == value_res) return value_res; tool_params.timeout = param_value; return value_res; } static enum PerfRepl_param_result process_param__date_header (const char *param_name) { tool_params.date_header = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__help (const char *param_name) { /* Use only one of help | version */ if (! tool_params.version) tool_params.help = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } static enum PerfRepl_param_result process_param__version (const char *param_name) { /* Use only one of help | version */ if (! tool_params.help) tool_params.version = ! 0; return '-' == param_name[1] ? PERF_RPL_PARAM_FULL_STR :PERF_RPL_PARAM_ONE_CHAR; } /** * Process "short" (one character) parameter. * @param param the pointer to character after "-" or after another valid * parameter * @param next_param the pointer to the next parameter (if any) or * NULL if no next parameter * @return enum value with result */ static enum PerfRepl_param_result process_short_param (const char *param, const char *next_param) { const char param_chr = param[0]; if ('A' == param_chr) return process_param__all_cpus ("-A"); else if ('t' == param_chr) return process_param__threads ("-t", param + 1, next_param); else if ('P' == param_chr) return process_param__thread_per_conn ("-P"); else if ('e' == param_chr) return process_param__epoll ("-e"); else if ('p' == param_chr) return process_param__poll ("-p"); else if ('s' == param_chr) return process_param__select ("-s"); else if ('E' == param_chr) return process_param__empty ("-E"); else if ('T' == param_chr) return process_param__tiny ("-T"); else if ('M' == param_chr) return process_param__medium ("-M"); else if ('L' == param_chr) return process_param__large ("-L"); else if ('S' == param_chr) return process_param__shared ("-S"); else if ('I' == param_chr) return process_param__single ("-I"); else if ('U' == param_chr) return process_param__unique ("-U"); else if ('c' == param_chr) return process_param__connections ("-c", param + 1, next_param); else if ('O' == param_chr) return process_param__timeout ("-O", param + 1, next_param); else if ('V' == param_chr) return process_param__version ("-V"); fprintf (stderr, "Unrecognised parameter: -%c.\n", param_chr); return PERF_RPL_PARAM_ERROR; } /** * Process string of "short" (one character) parameters. * @param params_str the pointer to first character after "-" * @param next_param the pointer to the next parameter (if any) or * NULL if no next parameter * @return enum value with result */ static enum PerfRepl_param_result process_short_params_str (const char *params_str, const char *next_param) { if (0 == params_str[0]) { fprintf (stderr, "Unrecognised parameter: -\n"); return PERF_RPL_PARAM_ERROR; } do { enum PerfRepl_param_result param_res; param_res = process_short_param (params_str, next_param); if (PERF_RPL_PARAM_ONE_CHAR != param_res) return param_res; } while (0 != (++params_str)[0]); return PERF_RPL_PARAM_FULL_STR; } /** * Process "long" (--something) parameters. * @param param the pointer to first character after "--" * @param next_param the pointer to the next parameter (if any) or * NULL if no next parameter * @return enum value, the PERF_PERPL_SPARAM_ONE_CHAR is not used by * this function */ static enum PerfRepl_param_result process_long_param (const char *param, const char *next_param) { const size_t param_len = strlen (param); if ((MHD_STATICSTR_LEN_ ("all-cpus") == param_len) && (0 == memcmp (param, "all-cpus", MHD_STATICSTR_LEN_ ("all-cpus")))) return process_param__all_cpus ("--all-cpus"); else if ((MHD_STATICSTR_LEN_ ("threads") <= param_len) && (0 == memcmp (param, "threads", MHD_STATICSTR_LEN_ ("threads")))) return process_param__threads ("--threads", param + MHD_STATICSTR_LEN_ ("threads"), next_param); else if ((MHD_STATICSTR_LEN_ ("thread-per-conn") == param_len) && (0 == memcmp (param, "thread-per-conn", MHD_STATICSTR_LEN_ ("thread-per-conn")))) return process_param__thread_per_conn ("--thread-per-conn"); else if ((MHD_STATICSTR_LEN_ ("epoll") == param_len) && (0 == memcmp (param, "epoll", MHD_STATICSTR_LEN_ ("epoll")))) return process_param__epoll ("--epoll"); else if ((MHD_STATICSTR_LEN_ ("poll") == param_len) && (0 == memcmp (param, "poll", MHD_STATICSTR_LEN_ ("poll")))) return process_param__poll ("--poll"); else if ((MHD_STATICSTR_LEN_ ("select") == param_len) && (0 == memcmp (param, "select", MHD_STATICSTR_LEN_ ("select")))) return process_param__select ("--select"); else if ((MHD_STATICSTR_LEN_ ("empty") == param_len) && (0 == memcmp (param, "empty", MHD_STATICSTR_LEN_ ("empty")))) return process_param__empty ("--empty"); else if ((MHD_STATICSTR_LEN_ ("tiny") == param_len) && (0 == memcmp (param, "tiny", MHD_STATICSTR_LEN_ ("tiny")))) return process_param__tiny ("--tiny"); else if ((MHD_STATICSTR_LEN_ ("medium") == param_len) && (0 == memcmp (param, "medium", MHD_STATICSTR_LEN_ ("medium")))) return process_param__medium ("--medium"); else if ((MHD_STATICSTR_LEN_ ("large") == param_len) && (0 == memcmp (param, "large", MHD_STATICSTR_LEN_ ("large")))) return process_param__large ("--large"); else if ((MHD_STATICSTR_LEN_ ("shared") == param_len) && (0 == memcmp (param, "shared", MHD_STATICSTR_LEN_ ("shared")))) return process_param__shared ("--shared"); else if ((MHD_STATICSTR_LEN_ ("single") == param_len) && (0 == memcmp (param, "single", MHD_STATICSTR_LEN_ ("single")))) return process_param__single ("--single"); else if ((MHD_STATICSTR_LEN_ ("unique") == param_len) && (0 == memcmp (param, "unique", MHD_STATICSTR_LEN_ ("unique")))) return process_param__unique ("--unique"); else if ((MHD_STATICSTR_LEN_ ("connections") <= param_len) && (0 == memcmp (param, "connections", MHD_STATICSTR_LEN_ ("connections")))) return process_param__connections ("--connections", param + MHD_STATICSTR_LEN_ ("connections"), next_param); else if ((MHD_STATICSTR_LEN_ ("timeout") <= param_len) && (0 == memcmp (param, "timeout", MHD_STATICSTR_LEN_ ("timeout")))) return process_param__timeout ("--timeout", param + MHD_STATICSTR_LEN_ ("timeout"), next_param); else if ((MHD_STATICSTR_LEN_ ("date-header") == param_len) && (0 == memcmp (param, "date-header", MHD_STATICSTR_LEN_ ("date-header")))) return process_param__date_header ("--date-header"); else if ((MHD_STATICSTR_LEN_ ("help") == param_len) && (0 == memcmp (param, "help", MHD_STATICSTR_LEN_ ("help")))) return process_param__help ("--help"); else if ((MHD_STATICSTR_LEN_ ("version") == param_len) && (0 == memcmp (param, "version", MHD_STATICSTR_LEN_ ("version")))) return process_param__version ("--version"); fprintf (stderr, "Unrecognised parameter: --%s.\n", param); return PERF_RPL_PARAM_ERROR; } static int process_params (int argc, char *const *argv) { int proc_dash_param = ! 0; int i; for (i = 1; i < argc; ++i) { /** * The currently processed argument */ const char *const p = argv[i]; const char *const p_next = (argc == (i + 1)) ? NULL : (argv[i + 1]); if (NULL == p) { fprintf (stderr, "The NULL in the parameter number %d. " "The error in the C library?\n", i); continue; } else if (0 == p[0]) continue; /* Empty */ else if (proc_dash_param && ('-' == p[0])) { enum PerfRepl_param_result param_res; if ('-' == p[1]) { if (0 == p[2]) { proc_dash_param = 0; /* The '--' parameter */ continue; } param_res = process_long_param (p + 2, p_next); } else param_res = process_short_params_str (p + 1, p_next); if (PERF_RPL_PARAM_ERROR == param_res) return PERF_RPL_ERR_CODE_BAD_PARAM; if (PERF_RPL_PARAM_STR_PLUS_NEXT == param_res) ++i; else if (PERF_RPL_PARAM_ONE_CHAR == param_res) abort (); continue; } else if (('0' <= p[0]) && ('9' >= p[0])) { /* Process the port number */ unsigned int read_port; size_t num_digits; num_digits = mhd_tool_str_to_uint (p, &read_port); if (0 != p[num_digits]) { fprintf (stderr, "Error in specified port number: %s\n", p); return PERF_RPL_ERR_CODE_BAD_PARAM; } else if (65535 < read_port) { fprintf (stderr, "Wrong port number: %s\n", p); return PERF_RPL_ERR_CODE_BAD_PARAM; } mhd_port = (uint16_t) read_port; } else { fprintf (stderr, "Unrecognised parameter: %s\n\n", p); return PERF_RPL_ERR_CODE_BAD_PARAM; } } return 0; } static void print_version (void) { printf ("%s (GNU libmicrohttpd", self_name); if (0 != build_revision[0]) printf ("; %s", build_revision); printf (") %s\n", MHD_get_version ()); printf ("%s\n", tool_copyright); } static void print_all_cores_used (void) { printf ("No CPU cores on this machine are left unused and available " "for the client / requests generator. " "Testing with remote client is recommended.\n"); } static void check_param_port (void) { if (0 != tool_params.port) return; if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) tool_params.port = PERF_REPL_PORT_FALLBACK; } /** * Apply parameter '-A' or '--all-cpus' */ static void check_apply_param__all_cpus (void) { if (! tool_params.all_cpus) return; num_threads = get_process_cpu_core_count (); printf ("Requested use of all available CPU cores for MHD threads.\n"); if (get_cpu_core_count () == num_threads) print_all_cores_used (); } /** * Apply parameter '-t' or '--threads' */ static void check_apply_param__threads (void) { if (0 == tool_params.threads) return; num_threads = tool_params.threads; if (get_process_cpu_core_count () < num_threads) { fprintf (stderr, "WARNING: The requested number of threads (%u) is " "higher than the number of detected available CPU cores (%u).\n", num_threads, get_process_cpu_core_count ()); fprintf (stderr, "This decreases the performance. " "Consider using fewer threads.\n"); } if (get_cpu_core_count () == num_threads) { printf ("The requested number of threads is equal to the number of " "detected CPU cores.\n"); print_all_cores_used (); } } /** * Apply parameter '-P' or '--thread-per-conn' * @return non-zero - OK, zero - error */ static int check_apply_param__thread_per_conn (void) { if (! tool_params.thread_per_conn) return ! 0; if (tool_params.epoll) { fprintf (stderr, "'Thread-per-connection' mode cannot be used together " "with 'epoll'.\n"); return 0; } num_threads = 1; return ! 0; } /* non-zero - OK, zero - error */ static int check_param__epoll (void) { if (! tool_params.epoll) return ! 0; if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { fprintf (stderr, "'epoll' was requested, but this MHD build does not " "support 'epoll' functionality.\n"); return 0; } return ! 0; } /* non-zero - OK, zero - error */ static int check_param__poll (void) { if (! tool_params.poll) return ! 0; if (MHD_NO == MHD_is_feature_supported (MHD_FEATURE_POLL)) { fprintf (stderr, "poll() was requested, but this MHD build does not " "support polling by poll().\n"); return 0; } return ! 0; } static void check_param__empty_tiny_medium_large (void) { if (0 == (tool_params.empty | tool_params.tiny | tool_params.medium | tool_params.large)) tool_params.tiny = ! 0; } static void check_param__shared_single_unique (void) { if (0 == (tool_params.shared | tool_params.single | tool_params.unique)) tool_params.shared = ! 0; } /* Must be called after 'check_apply_param__threads()' and 'check_apply_param__all_cpus()' */ /* non-zero - OK, zero - error */ static int check_param__connections (void) { if (0 == tool_params.connections) return ! 0; if (get_num_threads () > tool_params.connections) { fprintf (stderr, "The connections number limit (%u) is less than number " "of threads used (%u). Use higher value for connections limit.\n", tool_params.connections, get_num_threads ()); return 0; } return ! 0; } /** * Apply decoded parameters * @return 0 if success, * positive error code if case of error, * -1 to exit program with success (0) error code. */ static int check_apply_params (void) { if (tool_params.help) { show_help (); return -1; } else if (tool_params.version) { print_version (); return -1; } check_param_port (); check_apply_param__all_cpus (); check_apply_param__threads (); if (! check_apply_param__thread_per_conn ()) return PERF_RPL_ERR_CODE_BAD_PARAM; if (! check_param__epoll ()) return PERF_RPL_ERR_CODE_BAD_PARAM; if (! check_param__poll ()) return PERF_RPL_ERR_CODE_BAD_PARAM; check_param__empty_tiny_medium_large (); check_param__shared_single_unique (); if (! check_param__connections ()) return PERF_RPL_ERR_CODE_BAD_PARAM; return 0; } /* The pool of shared responses */ static struct MHD_Response **resps = NULL; static unsigned int num_resps = 0; /* The single response */ static struct MHD_Response *resp_single = NULL; /* Use the same memory area to avoid multiple copies. The system will keep it in cache. */ static const char tiny_body[] = "Hi!"; static char *body_dyn = NULL; /* Non-static body data */ static size_t body_dyn_size; /* Non-zero - success, zero - failure */ static int init_response_body_data (void) { if (0 != body_dyn_size) { body_dyn = (char *) malloc (body_dyn_size); if (NULL == body_dyn) { fprintf (stderr, "Failed to allocate memory.\n"); return 0; } if (tool_params.medium) { /* Fill the body with HTML-like content */ size_t pos; size_t filler_pos; static const char body_header[] = "\n" "\nSample page title\n\n" "\n"; static const char body_filler[] = "The quick brown fox jumps over the lazy dog.
    \n"; static const char body_footer[] = "\n" "\n"; pos = 0; memcpy (body_dyn + pos, body_header, MHD_STATICSTR_LEN_ (body_header)); pos += MHD_STATICSTR_LEN_ (body_header); for (filler_pos = 0; filler_pos < (body_dyn_size - (MHD_STATICSTR_LEN_ (body_header) + MHD_STATICSTR_LEN_ (body_footer))); ++filler_pos) { body_dyn[pos + filler_pos] = body_filler[filler_pos % MHD_STATICSTR_LEN_ (body_filler)]; } pos += filler_pos; memcpy (body_dyn + pos, body_footer, MHD_STATICSTR_LEN_ (body_footer)); } else { /* Fill the body with binary-like content */ size_t pos; for (pos = 0; pos < body_dyn_size; ++pos) { body_dyn[pos] = (char) (unsigned char) (255U - pos % 256U); } } } return ! 0; } static struct MHD_Response * create_response_object (void) { #if MHD_VERSION >= 0x00097701 if (NULL != body_dyn) return MHD_create_response_from_buffer_static (body_dyn_size, body_dyn); else if (tool_params.empty) return MHD_create_response_empty (MHD_RF_NONE); return MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (tiny_body), tiny_body); #else /* MHD_VERSION < 0x00097701 */ if (NULL != body_dyn) return MHD_create_response_from_buffer (body_dyn_size, (void *) body_dyn, MHD_RESPMEM_PERSISTENT); else if (tool_params.empty) return MHD_create_response_from_buffer (0, (void *) tiny_body, MHD_RESPMEM_PERSISTENT); return MHD_create_response_from_buffer (MHD_STATICSTR_LEN_ (tiny_body), (void *) tiny_body, MHD_RESPMEM_PERSISTENT); #endif /* MHD_VERSION < 0x00097701 */ } static int init_data (void) { unsigned int i; if (tool_params.medium) body_dyn_size = 8U * 1024U; else if (tool_params.large) body_dyn_size = 1024U * 1024U; else body_dyn_size = 0; if (! init_response_body_data ()) return 25; if (tool_params.unique) return 0; /* Responses are generated on-fly */ if (tool_params.single) { resp_single = create_response_object (); if (NULL == resp_single) { fprintf (stderr, "Failed to create response.\n"); return 25; } return 0; } /* Use more responses to minimise waiting in threads while the response used by other thread. */ if (! tool_params.thread_per_conn) num_resps = 16 * get_num_threads (); else num_resps = 16 * get_cpu_core_count (); resps = (struct MHD_Response **) malloc ((sizeof(struct MHD_Response *)) * num_resps); if (NULL == resps) { if (NULL != body_dyn) { free (body_dyn); body_dyn = NULL; } fprintf (stderr, "Failed to allocate memory.\n"); return 25; } for (i = 0; i < num_resps; ++i) { resps[i] = create_response_object (); if (NULL == resps[i]) { fprintf (stderr, "Failed to create responses.\n"); break; } } if (i == num_resps) return 0; /* Success */ /* Cleanup */ while (--i < num_resps) MHD_destroy_response (resps[i]); free (resps); resps = NULL; num_resps = 0; if (NULL != body_dyn) free (body_dyn); body_dyn = NULL; return 32; } static void deinit_data (void) { if (NULL != resp_single) MHD_destroy_response (resp_single); resp_single = NULL; if (NULL != resps) { unsigned int i; for (i = 0; i < num_resps; ++i) MHD_destroy_response (resps[i]); num_resps = 0; free (resps); } resps = NULL; if (NULL != body_dyn) free (body_dyn); body_dyn = NULL; } static enum MHD_Result answer_shared_response (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker = 0; unsigned int resp_index; static volatile unsigned int last_index = 0; (void) cls; /* Unused */ (void) url; (void) version; /* Unused */ (void) upload_data; (void) upload_data_size; /* Unused */ if (NULL == *req_cls) { /* The fist call */ *req_cls = (void *) ▮ /* Do not send reply yet. No error. */ return MHD_YES; } if ((0 != strcmp (method, MHD_HTTP_METHOD_GET)) && (0 != strcmp (method, MHD_HTTP_METHOD_HEAD))) return MHD_NO; /* Unsupported method, close connection */ /* This kind of operation does not guarantee that numbers are not reused in parallel threads, when processed simultaneously, but this should not be a big problem, as it just slow down replies a bit due to responses locking. */ resp_index = (last_index++) % num_resps; return MHD_queue_response (connection, MHD_HTTP_OK, resps[resp_index]); } static enum MHD_Result answer_single_response (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker = 0; (void) cls; /* Unused */ (void) url; (void) version; /* Unused */ (void) upload_data; (void) upload_data_size; /* Unused */ if (NULL == *req_cls) { /* The fist call */ *req_cls = (void *) ▮ /* Do not send reply yet. No error. */ return MHD_YES; } if ((0 != strcmp (method, MHD_HTTP_METHOD_GET)) && (0 != strcmp (method, MHD_HTTP_METHOD_HEAD))) return MHD_NO; /* Unsupported method, close connection */ return MHD_queue_response (connection, MHD_HTTP_OK, resp_single); } static enum MHD_Result answer_unique_empty_response (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker = 0; struct MHD_Response *r; enum MHD_Result ret; (void) cls; /* Unused */ (void) url; (void) version; /* Unused */ (void) upload_data; (void) upload_data_size; /* Unused */ if (NULL == *req_cls) { /* The fist call */ *req_cls = (void *) ▮ /* Do not send reply yet. No error. */ return MHD_YES; } if ((0 != strcmp (method, MHD_HTTP_METHOD_GET)) && (0 != strcmp (method, MHD_HTTP_METHOD_HEAD))) return MHD_NO; /* Unsupported method, close connection */ #if MHD_VERSION >= 0x00097701 r = MHD_create_response_empty (MHD_RF_NONE); #else /* MHD_VERSION < 0x00097701 */ r = MHD_create_response_from_buffer (0, NULL, MHD_RESPMEM_PERSISTENT); #endif /* MHD_VERSION < 0x00097701 */ ret = MHD_queue_response (connection, MHD_HTTP_OK, r); MHD_destroy_response (r); return ret; } static enum MHD_Result answer_unique_tiny_response (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker = 0; struct MHD_Response *r; enum MHD_Result ret; (void) cls; /* Unused */ (void) url; (void) version; /* Unused */ (void) upload_data; (void) upload_data_size; /* Unused */ if (NULL == *req_cls) { /* The fist call */ *req_cls = (void *) ▮ /* Do not send reply yet. No error. */ return MHD_YES; } if ((0 != strcmp (method, MHD_HTTP_METHOD_GET)) && (0 != strcmp (method, MHD_HTTP_METHOD_HEAD))) return MHD_NO; /* Unsupported method, close connection */ #if MHD_VERSION >= 0x00097701 r = MHD_create_response_from_buffer_static (MHD_STATICSTR_LEN_ (tiny_body), tiny_body); #else /* MHD_VERSION < 0x00097701 */ r = MHD_create_response_from_buffer (MHD_STATICSTR_LEN_ (tiny_body), (void *) tiny_body, MHD_RESPMEM_PERSISTENT); #endif /* MHD_VERSION < 0x00097701 */ ret = MHD_queue_response (connection, MHD_HTTP_OK, r); MHD_destroy_response (r); return ret; } static enum MHD_Result answer_unique_dyn_response (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int marker = 0; struct MHD_Response *r; enum MHD_Result ret; (void) cls; /* Unused */ (void) url; (void) version; /* Unused */ (void) upload_data; (void) upload_data_size; /* Unused */ if (NULL == *req_cls) { /* The fist call */ *req_cls = (void *) ▮ /* Do not send reply yet. No error. */ return MHD_YES; } if ((0 != strcmp (method, MHD_HTTP_METHOD_GET)) && (0 != strcmp (method, MHD_HTTP_METHOD_HEAD))) return MHD_NO; /* Unsupported method, close connection */ #if MHD_VERSION >= 0x00097701 r = MHD_create_response_from_buffer_static (body_dyn_size, body_dyn); #else /* MHD_VERSION < 0x00097701 */ r = MHD_create_response_from_buffer (body_dyn_size, (void *) body_dyn, MHD_RESPMEM_PERSISTENT); #endif /* MHD_VERSION < 0x00097701 */ ret = MHD_queue_response (connection, MHD_HTTP_OK, r); MHD_destroy_response (r); return ret; } static void print_perf_warnings (void) { int newline_needed = 0; #if defined (_DEBUG) fprintf (stderr, "WARNING: Running with debug asserts enabled, " "the performance is suboptimal.\n"); newline_needed |= ! 0; #endif /* _DEBUG */ #if defined(__GNUC__) && ! defined (__OPTIMIZE__) fprintf (stderr, "WARNING: The tools is compiled without enabled compiler " "optimisations, the performance is suboptimal.\n"); newline_needed |= ! 0; #endif /* __GNUC__ && ! __OPTIMIZE__ */ #if defined(__GNUC__) && defined (__OPTIMIZE_SIZE__) fprintf (stderr, "WARNING: The tools is compiled with size-optimisations, " "the performance is suboptimal.\n"); #endif /* __GNUC__ && ! __OPTIMIZE__ */ #if MHD_VERSION >= 0x00097701 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_DEBUG_BUILD)) { fprintf (stderr, "WARNING: The libmicrohttpd is compiled with " "debug asserts enabled, the performance is suboptimal.\n"); newline_needed |= ! 0; } #endif /* MHD_VERSION >= 0x00097701 */ if (newline_needed) printf ("\n"); } /* Borrowed from daemon.c */ /* TODO: run-time detection */ /** * Default connection limit. */ #ifdef MHD_POSIX_SOCKETS #define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 4) #else #define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 2) #endif static unsigned int get_mhd_conn_limit (struct MHD_Daemon *d) { /* TODO: implement run-time detection */ (void) d; /* Unused */ if (0 != tool_params.connections) return tool_params.connections; return (unsigned int) MHD_MAX_CONNECTIONS_DEFAULT; } static const char * get_mhd_response_size (void) { if (tool_params.empty) return "0 bytes (empty)"; else if (tool_params.tiny) return "3 bytes (tiny)"; else if (tool_params.medium) return "8 KB (medium)"; else if (tool_params.large) return "1 MB (large)"; return "!!internal error!!"; } static int run_mhd (void) { MHD_AccessHandlerCallback reply_func; struct MHD_Daemon *d; unsigned int use_num_threads; unsigned int flags = MHD_NO_FLAG; struct MHD_OptionItem opt_arr[16]; size_t opt_count = 0; const union MHD_DaemonInfo *d_info; const char *poll_mode; uint16_t port; if (tool_params.thread_per_conn) use_num_threads = 0; else use_num_threads = get_num_threads (); printf ("\n"); print_perf_warnings (); printf ("Responses:\n"); printf (" Sharing: "); if (tool_params.shared) { reply_func = &answer_shared_response; printf ("pre-generated shared pool with %u objects\n", num_resps); } else if (tool_params.single) { reply_func = &answer_single_response; printf ("single pre-generated reused response object\n"); } else { /* Unique responses */ if (tool_params.empty) reply_func = &answer_unique_empty_response; else if (tool_params.tiny) reply_func = &answer_unique_tiny_response; else reply_func = &answer_unique_dyn_response; printf ("one-time response object generated for every request\n"); } printf (" Body size: %s\n", get_mhd_response_size ()); flags |= MHD_USE_ERROR_LOG; flags |= MHD_USE_INTERNAL_POLLING_THREAD; if (tool_params.epoll) flags |= MHD_USE_EPOLL; else if (tool_params.poll) flags |= MHD_USE_POLL; else if (tool_params.select) (void) flags; /* No special additional flag */ else flags |= MHD_USE_AUTO; if (tool_params.thread_per_conn) flags |= MHD_USE_THREAD_PER_CONNECTION; if (! tool_params.date_header) flags |= MHD_USE_SUPPRESS_DATE_NO_CLOCK; if (0 != tool_params.connections) { opt_arr[opt_count].option = MHD_OPTION_CONNECTION_LIMIT; opt_arr[opt_count].value = (intptr_t) tool_params.connections; opt_arr[opt_count].ptr_value = NULL; ++opt_count; } if (1 < use_num_threads) { opt_arr[opt_count].option = MHD_OPTION_THREAD_POOL_SIZE; opt_arr[opt_count].value = (intptr_t) use_num_threads; opt_arr[opt_count].ptr_value = NULL; ++opt_count; } if (1) { opt_arr[opt_count].option = MHD_OPTION_CONNECTION_TIMEOUT; opt_arr[opt_count].value = (intptr_t) tool_params.timeout; opt_arr[opt_count].ptr_value = NULL; ++opt_count; } if (1) { struct MHD_OptionItem option = { MHD_OPTION_END, 0, NULL }; opt_arr[opt_count] = option; if (opt_count >= (sizeof(opt_arr) / sizeof(opt_arr[0]))) abort (); } d = MHD_start_daemon (flags, mhd_port, NULL, NULL, reply_func, NULL, MHD_OPTION_ARRAY, opt_arr, MHD_OPTION_END); if (NULL == d) { fprintf (stderr, "Error starting MHD daemon.\n"); return 15; } d_info = MHD_get_daemon_info (d, MHD_DAEMON_INFO_FLAGS); if (NULL == d_info) abort (); flags = (unsigned int) d_info->flags; if (0 != (flags & MHD_USE_POLL)) poll_mode = "poll()"; else if (0 != (flags & MHD_USE_EPOLL)) poll_mode = "epoll"; else poll_mode = "select()"; d_info = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); if (NULL == d_info) abort (); port = d_info->port; if (0 == port) fprintf (stderr, "Cannot detect port number. Consider specifying " "port number explicitly.\n"); printf ("MHD is running.\n"); printf (" Bind port: %u\n", (unsigned int) port); printf (" Polling function: %s\n", poll_mode); printf (" Threading: "); if (MHD_USE_THREAD_PER_CONNECTION == (flags & MHD_USE_THREAD_PER_CONNECTION)) printf ("thread per connection\n"); else if (1 == get_num_threads ()) printf ("one MHD thread\n"); else printf ("%u MHD threads in thread pool\n", get_num_threads ()); printf (" Connections limit: %u\n", get_mhd_conn_limit (d)); printf (" Connection timeout: %u%s\n", tool_params.timeout, 0 == tool_params.timeout ? " (no timeout)" : ""); printf (" 'Date:' header: %s\n", tool_params.date_header ? "Yes" : "No"); printf ("To test with remote client use " "http://HOST_IP:%u/\n", (unsigned int) port); printf ("To test with client on the same host use " "http://127.0.0.1:%u/\n", (unsigned int) port); printf ("\nPress ENTER to stop.\n"); if (1) { char buf[10]; (void) fgets (buf, sizeof(buf), stdin); } MHD_stop_daemon (d); return 0; } int main (int argc, char *const *argv) { int ret; set_self_name (argc, argv); ret = process_params (argc, argv); if (0 != ret) return ret; ret = check_apply_params (); if (0 > ret) return 0; if (0 != ret) return ret; ret = init_data (); if (0 != ret) return ret; ret = run_mhd (); deinit_data (); return ret; } libmicrohttpd-1.0.1/src/tools/mhd_tool_str_to_uint.h0000644000175000017500000000370614500102730016372 /* This file is part of GNU libmicrohttpd Copyright (C) 2023 Evgeny Grin (Karlson2k) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file tools/mhd_tool_str_to_uint.h * @brief Function to decode the value of decimal string number. * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_TOOL_STR_TO_UINT_H_ #define MHD_TOOL_STR_TO_UINT_H_ 1 #include /** * Convert decimal string to unsigned int. * Function stops at the end of the string or on first non-digit character. * @param str the string to convert * @param[out] value the pointer to put the result * @return return the number of digits converted or * zero if no digits found or result would overflow the output * variable (the output set to UINT_MAX in this case). */ static size_t mhd_tool_str_to_uint (const char *str, unsigned int *value) { size_t i; unsigned int v = 0; *value = 0; for (i = 0; 0 != str[i]; ++i) { const char chr = str[i]; unsigned int digit; if (('0' > chr) || ('9' < chr)) break; digit = (unsigned char) (chr - '0'); if ((((0U - 1) / 10) < v) || ((v * 10 + digit) < v)) { /* Overflow */ *value = 0U - 1; return 0; } v *= 10; v += digit; } *value = v; return i; } #endif /* MHD_TOOL_STR_TO_UINT_H_ */ libmicrohttpd-1.0.1/src/microhttpd_ws/0000755000175000017500000000000014566140216013600 5libmicrohttpd-1.0.1/src/microhttpd_ws/Makefile.am0000644000175000017500000000217114441373361015556 # This Makefile.am is in the public domain AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/microhttpd AM_CFLAGS = $(HIDDEN_VISIBILITY_CFLAGS) $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la noinst_DATA = MOSTLYCLEANFILES = SUBDIRS = . lib_LTLIBRARIES = \ libmicrohttpd_ws.la libmicrohttpd_ws_la_SOURCES = \ sha1.c sha1.h \ mhd_websocket.c libmicrohttpd_ws_la_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) \ -DBUILDING_MHD_LIB=1 libmicrohttpd_ws_la_CFLAGS = \ $(AM_CFLAGS) $(MHD_LIB_CFLAGS) libmicrohttpd_ws_la_LDFLAGS = \ $(MHD_LIB_LDFLAGS) \ $(W32_MHD_LIB_LDFLAGS) \ -version-info 0:0:0 libmicrohttpd_ws_la_LIBADD = \ $(MHD_LIBDEPS) TESTS = $(check_PROGRAMS) check_PROGRAMS = \ test_websocket test_websocket_SOURCES = \ test_websocket.c test_websocket_LDADD = \ $(top_builddir)/src/microhttpd_ws/libmicrohttpd_ws.la \ $(top_builddir)/src/microhttpd/libmicrohttpd.la libmicrohttpd-1.0.1/src/microhttpd_ws/sha1.c0000644000175000017500000003701514417460232014524 /* This file is part of libmicrohttpd Copyright (C) 2019-2021 Karlson2k (Evgeny Grin) libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/sha1.c * @brief Calculation of SHA-1 digest as defined in FIPS PUB 180-4 (2015) * @author Karlson2k (Evgeny Grin) */ #include "sha1.h" #include #ifdef HAVE_MEMORY_H #include #endif /* HAVE_MEMORY_H */ #include "mhd_bithelpers.h" #include "mhd_assert.h" /** * Initialise structure for SHA-1 calculation. * * @param ctx_ must be a `struct sha1_ctx *` */ void MHD_SHA1_init (void *ctx_) { struct sha1_ctx *const ctx = ctx_; /* Initial hash values, see FIPS PUB 180-4 paragraph 5.3.1 */ /* Just some "magic" numbers defined by standard */ ctx->H[0] = UINT32_C (0x67452301); ctx->H[1] = UINT32_C (0xefcdab89); ctx->H[2] = UINT32_C (0x98badcfe); ctx->H[3] = UINT32_C (0x10325476); ctx->H[4] = UINT32_C (0xc3d2e1f0); /* Initialise number of bytes. */ ctx->count = 0; } /** * Base of SHA-1 transformation. * Gets full 512 bits / 64 bytes block of data and updates hash values; * @param H hash values * @param data data, must be exactly 64 bytes long */ static void sha1_transform (uint32_t H[_SHA1_DIGEST_LENGTH], const uint8_t data[SHA1_BLOCK_SIZE]) { /* Working variables, see FIPS PUB 180-4 paragraph 6.1.3 */ uint32_t a = H[0]; uint32_t b = H[1]; uint32_t c = H[2]; uint32_t d = H[3]; uint32_t e = H[4]; /* Data buffer, used as cyclic buffer. See FIPS PUB 180-4 paragraphs 5.2.1, 6.1.3 */ uint32_t W[16]; /* 'Ch' and 'Maj' macro functions are defined with widely-used optimization. See FIPS PUB 180-4 formulae 4.1. */ #define Ch(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) ) #define Maj(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) /* Unoptimized (original) versions: */ /* #define Ch(x,y,z) ( ( (x) & (y) ) ^ ( ~(x) & (z) ) ) */ /* #define Maj(x,y,z) ( ((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)) ) */ #define Par(x,y,z) ( (x) ^ (y) ^ (z) ) /* Single step of SHA-1 computation, see FIPS PUB 180-4 paragraph 6.1.3 step 3. * Note: instead of reassigning all working variables on each step, variables are rotated for each step: SHA1STEP32 (a, b, c, d, e, func, K00, W[0]); SHA1STEP32 (e, a, b, c, d, func, K00, W[1]); so current 'vC' will be used as 'vD' on the next step, current 'vE' will be used as 'vA' on the next step. * Note: 'wt' must be used exactly one time in this macro as it change other data as well every time when used. */ #define SHA1STEP32(vA,vB,vC,vD,vE,ft,kt,wt) do { \ (vE) += _MHD_ROTL32 ((vA), 5) + ft ((vB), (vC), (vD)) + (kt) + (wt); \ (vB) = _MHD_ROTL32 ((vB), 30); } while (0) /* Get value of W(t) from input data buffer, See FIPS PUB 180-4 paragraph 6.1.3. Input data must be read in big-endian bytes order, see FIPS PUB 180-4 paragraph 3.1.2. */ #define GET_W_FROM_DATA(buf,t) \ _MHD_GET_32BIT_BE (((const uint8_t*) (buf)) + (t) * SHA1_BYTES_IN_WORD) #ifndef _MHD_GET_32BIT_BE_UNALIGNED if (0 != (((uintptr_t) data) % _MHD_UINT32_ALIGN)) { /* Copy the unaligned input data to the aligned buffer */ memcpy (W, data, SHA1_BLOCK_SIZE); /* The W[] buffer itself will be used as the source of the data, * but data will be reloaded in correct bytes order during * the next steps */ data = (uint8_t *) W; } #endif /* _MHD_GET_32BIT_BE_UNALIGNED */ /* SHA-1 values of Kt for t=0..19, see FIPS PUB 180-4 paragraph 4.2.1. */ #define K00 UINT32_C(0x5a827999) /* SHA-1 values of Kt for t=20..39, see FIPS PUB 180-4 paragraph 4.2.1.*/ #define K20 UINT32_C(0x6ed9eba1) /* SHA-1 values of Kt for t=40..59, see FIPS PUB 180-4 paragraph 4.2.1.*/ #define K40 UINT32_C(0x8f1bbcdc) /* SHA-1 values of Kt for t=60..79, see FIPS PUB 180-4 paragraph 4.2.1.*/ #define K60 UINT32_C(0xca62c1d6) /* During first 16 steps, before making any calculations on each step, the W element is read from input data buffer as big-endian value and stored in array of W elements. */ /* Note: instead of using K constants as array, all K values are specified individually for each step. */ SHA1STEP32 (a, b, c, d, e, Ch, K00, W[0] = GET_W_FROM_DATA (data, 0)); SHA1STEP32 (e, a, b, c, d, Ch, K00, W[1] = GET_W_FROM_DATA (data, 1)); SHA1STEP32 (d, e, a, b, c, Ch, K00, W[2] = GET_W_FROM_DATA (data, 2)); SHA1STEP32 (c, d, e, a, b, Ch, K00, W[3] = GET_W_FROM_DATA (data, 3)); SHA1STEP32 (b, c, d, e, a, Ch, K00, W[4] = GET_W_FROM_DATA (data, 4)); SHA1STEP32 (a, b, c, d, e, Ch, K00, W[5] = GET_W_FROM_DATA (data, 5)); SHA1STEP32 (e, a, b, c, d, Ch, K00, W[6] = GET_W_FROM_DATA (data, 6)); SHA1STEP32 (d, e, a, b, c, Ch, K00, W[7] = GET_W_FROM_DATA (data, 7)); SHA1STEP32 (c, d, e, a, b, Ch, K00, W[8] = GET_W_FROM_DATA (data, 8)); SHA1STEP32 (b, c, d, e, a, Ch, K00, W[9] = GET_W_FROM_DATA (data, 9)); SHA1STEP32 (a, b, c, d, e, Ch, K00, W[10] = GET_W_FROM_DATA (data, 10)); SHA1STEP32 (e, a, b, c, d, Ch, K00, W[11] = GET_W_FROM_DATA (data, 11)); SHA1STEP32 (d, e, a, b, c, Ch, K00, W[12] = GET_W_FROM_DATA (data, 12)); SHA1STEP32 (c, d, e, a, b, Ch, K00, W[13] = GET_W_FROM_DATA (data, 13)); SHA1STEP32 (b, c, d, e, a, Ch, K00, W[14] = GET_W_FROM_DATA (data, 14)); SHA1STEP32 (a, b, c, d, e, Ch, K00, W[15] = GET_W_FROM_DATA (data, 15)); /* 'W' generation and assignment for 16 <= t <= 79. See FIPS PUB 180-4 paragraph 6.1.3. As only last 16 'W' are used in calculations, it is possible to use 16 elements array of W as cyclic buffer. */ #define Wgen(w,t) _MHD_ROTL32((w)[(t + 13) & 0xf] ^ (w)[(t + 8) & 0xf] \ ^ (w)[(t + 2) & 0xf] ^ (w)[t & 0xf], 1) /* During last 60 steps, before making any calculations on each step, W element is generated from W elements of cyclic buffer and generated value stored back in cyclic buffer. */ /* Note: instead of using K constants as array, all K values are specified individually for each step, see FIPS PUB 180-4 paragraph 4.2.1. */ SHA1STEP32 (e, a, b, c, d, Ch, K00, W[16 & 0xf] = Wgen (W, 16)); SHA1STEP32 (d, e, a, b, c, Ch, K00, W[17 & 0xf] = Wgen (W, 17)); SHA1STEP32 (c, d, e, a, b, Ch, K00, W[18 & 0xf] = Wgen (W, 18)); SHA1STEP32 (b, c, d, e, a, Ch, K00, W[19 & 0xf] = Wgen (W, 19)); SHA1STEP32 (a, b, c, d, e, Par, K20, W[20 & 0xf] = Wgen (W, 20)); SHA1STEP32 (e, a, b, c, d, Par, K20, W[21 & 0xf] = Wgen (W, 21)); SHA1STEP32 (d, e, a, b, c, Par, K20, W[22 & 0xf] = Wgen (W, 22)); SHA1STEP32 (c, d, e, a, b, Par, K20, W[23 & 0xf] = Wgen (W, 23)); SHA1STEP32 (b, c, d, e, a, Par, K20, W[24 & 0xf] = Wgen (W, 24)); SHA1STEP32 (a, b, c, d, e, Par, K20, W[25 & 0xf] = Wgen (W, 25)); SHA1STEP32 (e, a, b, c, d, Par, K20, W[26 & 0xf] = Wgen (W, 26)); SHA1STEP32 (d, e, a, b, c, Par, K20, W[27 & 0xf] = Wgen (W, 27)); SHA1STEP32 (c, d, e, a, b, Par, K20, W[28 & 0xf] = Wgen (W, 28)); SHA1STEP32 (b, c, d, e, a, Par, K20, W[29 & 0xf] = Wgen (W, 29)); SHA1STEP32 (a, b, c, d, e, Par, K20, W[30 & 0xf] = Wgen (W, 30)); SHA1STEP32 (e, a, b, c, d, Par, K20, W[31 & 0xf] = Wgen (W, 31)); SHA1STEP32 (d, e, a, b, c, Par, K20, W[32 & 0xf] = Wgen (W, 32)); SHA1STEP32 (c, d, e, a, b, Par, K20, W[33 & 0xf] = Wgen (W, 33)); SHA1STEP32 (b, c, d, e, a, Par, K20, W[34 & 0xf] = Wgen (W, 34)); SHA1STEP32 (a, b, c, d, e, Par, K20, W[35 & 0xf] = Wgen (W, 35)); SHA1STEP32 (e, a, b, c, d, Par, K20, W[36 & 0xf] = Wgen (W, 36)); SHA1STEP32 (d, e, a, b, c, Par, K20, W[37 & 0xf] = Wgen (W, 37)); SHA1STEP32 (c, d, e, a, b, Par, K20, W[38 & 0xf] = Wgen (W, 38)); SHA1STEP32 (b, c, d, e, a, Par, K20, W[39 & 0xf] = Wgen (W, 39)); SHA1STEP32 (a, b, c, d, e, Maj, K40, W[40 & 0xf] = Wgen (W, 40)); SHA1STEP32 (e, a, b, c, d, Maj, K40, W[41 & 0xf] = Wgen (W, 41)); SHA1STEP32 (d, e, a, b, c, Maj, K40, W[42 & 0xf] = Wgen (W, 42)); SHA1STEP32 (c, d, e, a, b, Maj, K40, W[43 & 0xf] = Wgen (W, 43)); SHA1STEP32 (b, c, d, e, a, Maj, K40, W[44 & 0xf] = Wgen (W, 44)); SHA1STEP32 (a, b, c, d, e, Maj, K40, W[45 & 0xf] = Wgen (W, 45)); SHA1STEP32 (e, a, b, c, d, Maj, K40, W[46 & 0xf] = Wgen (W, 46)); SHA1STEP32 (d, e, a, b, c, Maj, K40, W[47 & 0xf] = Wgen (W, 47)); SHA1STEP32 (c, d, e, a, b, Maj, K40, W[48 & 0xf] = Wgen (W, 48)); SHA1STEP32 (b, c, d, e, a, Maj, K40, W[49 & 0xf] = Wgen (W, 49)); SHA1STEP32 (a, b, c, d, e, Maj, K40, W[50 & 0xf] = Wgen (W, 50)); SHA1STEP32 (e, a, b, c, d, Maj, K40, W[51 & 0xf] = Wgen (W, 51)); SHA1STEP32 (d, e, a, b, c, Maj, K40, W[52 & 0xf] = Wgen (W, 52)); SHA1STEP32 (c, d, e, a, b, Maj, K40, W[53 & 0xf] = Wgen (W, 53)); SHA1STEP32 (b, c, d, e, a, Maj, K40, W[54 & 0xf] = Wgen (W, 54)); SHA1STEP32 (a, b, c, d, e, Maj, K40, W[55 & 0xf] = Wgen (W, 55)); SHA1STEP32 (e, a, b, c, d, Maj, K40, W[56 & 0xf] = Wgen (W, 56)); SHA1STEP32 (d, e, a, b, c, Maj, K40, W[57 & 0xf] = Wgen (W, 57)); SHA1STEP32 (c, d, e, a, b, Maj, K40, W[58 & 0xf] = Wgen (W, 58)); SHA1STEP32 (b, c, d, e, a, Maj, K40, W[59 & 0xf] = Wgen (W, 59)); SHA1STEP32 (a, b, c, d, e, Par, K60, W[60 & 0xf] = Wgen (W, 60)); SHA1STEP32 (e, a, b, c, d, Par, K60, W[61 & 0xf] = Wgen (W, 61)); SHA1STEP32 (d, e, a, b, c, Par, K60, W[62 & 0xf] = Wgen (W, 62)); SHA1STEP32 (c, d, e, a, b, Par, K60, W[63 & 0xf] = Wgen (W, 63)); SHA1STEP32 (b, c, d, e, a, Par, K60, W[64 & 0xf] = Wgen (W, 64)); SHA1STEP32 (a, b, c, d, e, Par, K60, W[65 & 0xf] = Wgen (W, 65)); SHA1STEP32 (e, a, b, c, d, Par, K60, W[66 & 0xf] = Wgen (W, 66)); SHA1STEP32 (d, e, a, b, c, Par, K60, W[67 & 0xf] = Wgen (W, 67)); SHA1STEP32 (c, d, e, a, b, Par, K60, W[68 & 0xf] = Wgen (W, 68)); SHA1STEP32 (b, c, d, e, a, Par, K60, W[69 & 0xf] = Wgen (W, 69)); SHA1STEP32 (a, b, c, d, e, Par, K60, W[70 & 0xf] = Wgen (W, 70)); SHA1STEP32 (e, a, b, c, d, Par, K60, W[71 & 0xf] = Wgen (W, 71)); SHA1STEP32 (d, e, a, b, c, Par, K60, W[72 & 0xf] = Wgen (W, 72)); SHA1STEP32 (c, d, e, a, b, Par, K60, W[73 & 0xf] = Wgen (W, 73)); SHA1STEP32 (b, c, d, e, a, Par, K60, W[74 & 0xf] = Wgen (W, 74)); SHA1STEP32 (a, b, c, d, e, Par, K60, W[75 & 0xf] = Wgen (W, 75)); SHA1STEP32 (e, a, b, c, d, Par, K60, W[76 & 0xf] = Wgen (W, 76)); SHA1STEP32 (d, e, a, b, c, Par, K60, W[77 & 0xf] = Wgen (W, 77)); SHA1STEP32 (c, d, e, a, b, Par, K60, W[78 & 0xf] = Wgen (W, 78)); SHA1STEP32 (b, c, d, e, a, Par, K60, W[79 & 0xf] = Wgen (W, 79)); /* Compute intermediate hash. See FIPS PUB 180-4 paragraph 6.1.3 step 4. */ H[0] += a; H[1] += b; H[2] += c; H[3] += d; H[4] += e; } /** * Process portion of bytes. * * @param ctx_ must be a `struct sha1_ctx *` * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_SHA1_update (void *ctx_, const uint8_t *data, size_t length) { struct sha1_ctx *const ctx = ctx_; unsigned bytes_have; /**< Number of bytes in buffer */ mhd_assert ((data != NULL) || (length == 0)); if (0 == length) return; /* Do nothing */ /* Note: (count & (SHA1_BLOCK_SIZE-1)) equal (count % SHA1_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned) (ctx->count & (SHA1_BLOCK_SIZE - 1)); ctx->count += length; if (0 != bytes_have) { unsigned bytes_left = SHA1_BLOCK_SIZE - bytes_have; if (length >= bytes_left) { /* Combine new data with the data in the buffer and process the full block. */ memcpy (ctx->buffer + bytes_have, data, bytes_left); data += bytes_left; length -= bytes_left; sha1_transform (ctx->H, ctx->buffer); bytes_have = 0; } } while (SHA1_BLOCK_SIZE <= length) { /* Process any full blocks of new data directly, without copying to the buffer. */ sha1_transform (ctx->H, data); data += SHA1_BLOCK_SIZE; length -= SHA1_BLOCK_SIZE; } if (0 != length) { /* Copy incomplete block of new data (if any) to the buffer. */ memcpy (ctx->buffer + bytes_have, data, length); } } /** * Size of "length" padding addition in bytes. * See FIPS PUB 180-4 paragraph 5.1.1. */ #define SHA1_SIZE_OF_LEN_ADD (64 / 8) /** * Finalise SHA-1 calculation, return digest. * * @param ctx_ must be a `struct sha1_ctx *` * @param[out] digest set to the hash, must be #SHA1_DIGEST_SIZE bytes */ void MHD_SHA1_finish (void *ctx_, uint8_t digest[SHA1_DIGEST_SIZE]) { struct sha1_ctx *const ctx = ctx_; uint64_t num_bits; /**< Number of processed bits */ unsigned bytes_have; /**< Number of bytes in buffer */ num_bits = ctx->count << 3; /* Note: (count & (SHA1_BLOCK_SIZE-1)) equals (count % SHA1_BLOCK_SIZE) for this block size. */ bytes_have = (unsigned) (ctx->count & (SHA1_BLOCK_SIZE - 1)); /* Input data must be padded with bit "1" and with length of data in bits. See FIPS PUB 180-4 paragraph 5.1.1. */ /* Data is always processed in form of bytes (not by individual bits), therefore position of first padding bit in byte is always predefined (0x80). */ /* Buffer always have space at least for one byte (as full buffers are processed immediately). */ ctx->buffer[bytes_have++] = 0x80; if (SHA1_BLOCK_SIZE - bytes_have < SHA1_SIZE_OF_LEN_ADD) { /* No space in current block to put total length of message. Pad current block with zeros and process it. */ if (SHA1_BLOCK_SIZE > bytes_have) memset (ctx->buffer + bytes_have, 0, SHA1_BLOCK_SIZE - bytes_have); /* Process full block. */ sha1_transform (ctx->H, ctx->buffer); /* Start new block. */ bytes_have = 0; } /* Pad the rest of the buffer with zeros. */ memset (ctx->buffer + bytes_have, 0, SHA1_BLOCK_SIZE - SHA1_SIZE_OF_LEN_ADD - bytes_have); /* Put the number of bits in the processed message as a big-endian value. */ _MHD_PUT_64BIT_BE_SAFE (ctx->buffer + SHA1_BLOCK_SIZE - SHA1_SIZE_OF_LEN_ADD, num_bits); /* Process the full final block. */ sha1_transform (ctx->H, ctx->buffer); /* Put final hash/digest in BE mode */ #ifndef _MHD_PUT_32BIT_BE_UNALIGNED if (0 != ((uintptr_t) digest) % _MHD_UINT32_ALIGN) { uint32_t alig_dgst[_SHA1_DIGEST_LENGTH]; _MHD_PUT_32BIT_BE (alig_dgst + 0, ctx->H[0]); _MHD_PUT_32BIT_BE (alig_dgst + 1, ctx->H[1]); _MHD_PUT_32BIT_BE (alig_dgst + 2, ctx->H[2]); _MHD_PUT_32BIT_BE (alig_dgst + 3, ctx->H[3]); _MHD_PUT_32BIT_BE (alig_dgst + 4, ctx->H[4]); /* Copy result to unaligned destination address */ memcpy (digest, alig_dgst, SHA1_DIGEST_SIZE); } else #else /* _MHD_PUT_32BIT_BE_UNALIGNED */ if (1) #endif /* _MHD_PUT_32BIT_BE_UNALIGNED */ { _MHD_PUT_32BIT_BE (digest + 0 * SHA1_BYTES_IN_WORD, ctx->H[0]); _MHD_PUT_32BIT_BE (digest + 1 * SHA1_BYTES_IN_WORD, ctx->H[1]); _MHD_PUT_32BIT_BE (digest + 2 * SHA1_BYTES_IN_WORD, ctx->H[2]); _MHD_PUT_32BIT_BE (digest + 3 * SHA1_BYTES_IN_WORD, ctx->H[3]); _MHD_PUT_32BIT_BE (digest + 4 * SHA1_BYTES_IN_WORD, ctx->H[4]); } /* Erase potentially sensitive data. */ memset (ctx, 0, sizeof(struct sha1_ctx)); } libmicrohttpd-1.0.1/src/microhttpd_ws/test_websocket.c0000644000175000017500000137500014441373361016720 /* This file is part of libmicrohttpd Copyright (C) 2021 David Gausmann libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * @file test_websocket.c * @brief Testcase for WebSocket decoding/encoding * @author David Gausmann */ #include "microhttpd.h" #include "microhttpd_ws.h" #include #include #include #include #include #if SIZE_MAX >= 0x100000000 #define ENABLE_64BIT_TESTS 1 #endif int disable_alloc = 0; size_t open_allocs = 0; /** * Custom `malloc()` function used for memory tests */ static void * test_malloc (size_t buf_len) { if (0 != disable_alloc) return NULL; void *result = malloc (buf_len); if (NULL != result) ++open_allocs; return result; } /** * Custom `realloc()` function used for memory tests */ static void * test_realloc (void *buf, size_t buf_len) { if (0 != disable_alloc) return NULL; void *result = realloc (buf, buf_len); if ((NULL != result) && (NULL == buf)) ++open_allocs; return result; } /** * Custom `free()` function used for memory tests */ static void test_free (void *buf) { if (NULL != buf) --open_allocs; free (buf); } /** * Custom `rng()` function used for client mode tests */ static size_t test_rng (void *cls, void *buf, size_t buf_len) { for (size_t i = 0; i < buf_len; ++i) { ((char *) buf) [i] = (char) (rand () % 0xFF); } return buf_len; } /** * Helper function which allocates a big amount of data */ static void allocate_length_test_data (char **buf1, char **buf2, size_t buf_len, const char *buf1_prefix, size_t buf1_prefix_len) { if (NULL != *buf1) free (*buf1); if (NULL != *buf2) free (*buf2); *buf1 = (char *) malloc (buf_len + buf1_prefix_len); *buf2 = (char *) malloc (buf_len); if ((NULL == buf1) || (NULL == buf2)) return; memcpy (*buf1, buf1_prefix, buf1_prefix_len); for (size_t i = 0; i < buf_len; i += 64) { size_t bytes_to_copy = buf_len - i; if (64 < bytes_to_copy) bytes_to_copy = 64; memcpy (*buf1 + i + buf1_prefix_len, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-", bytes_to_copy); memcpy (*buf2 + i, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-", bytes_to_copy); } } /** * Helper function which performs a single decoder test */ static int test_decode_single (unsigned int test_line, int flags, size_t max_payload_size, size_t decode_count, size_t buf_step, const char *buf, size_t buf_len, const char *expected_payload, size_t expected_payload_len, int expected_return, int expected_valid, size_t expected_streambuf_read_len) { struct MHD_WebSocketStream *ws = NULL; int ret = MHD_WEBSOCKET_STATUS_OK; /* initialize stream */ ret = MHD_websocket_stream_init2 (&ws, flags, max_payload_size, malloc, realloc, free, NULL, test_rng); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "Allocation failed for decode test in line %u.\n", (unsigned int) test_line); return 1; } /* perform decoding in a loop */ size_t streambuf_read_len = 0; size_t payload_len = 0; char *payload = NULL; for (size_t i = 0; i < decode_count; ++i) { size_t streambuf_read_len_ = 0; size_t bytes_to_take = buf_len - streambuf_read_len; if ((0 != buf_step) && (buf_step < bytes_to_take)) bytes_to_take = buf_step; ret = MHD_websocket_decode (ws, buf + streambuf_read_len, bytes_to_take, &streambuf_read_len_, &payload, &payload_len); streambuf_read_len += streambuf_read_len_; if (i + 1 < decode_count) { if (payload) { MHD_websocket_free (ws, payload); payload = NULL; payload_len = 0; } } } /* check the (last) result */ if (ret != expected_return) { fprintf (stderr, "Decode test failed in line %u: The return value should be %d, but is %d\n", (unsigned int) test_line, (int) expected_return, (int) ret); MHD_websocket_free (ws, payload); MHD_websocket_stream_free (ws); return 1; } if (payload_len != expected_payload_len) { fprintf (stderr, "Decode test failed in line %u: The payload_len should be %u, but is %u\n", (unsigned int) test_line, (unsigned int) expected_payload_len, (unsigned int) payload_len); MHD_websocket_free (ws, payload); MHD_websocket_stream_free (ws); return 1; } if (0 != payload_len) { if (NULL == payload) { fprintf (stderr, "Decode test failed in line %u: The payload is NULL\n", (unsigned int) test_line); MHD_websocket_free (ws, payload); MHD_websocket_stream_free (ws); return 1; } else if (NULL == expected_payload) { fprintf (stderr, "Decode test failed in line %u: The expected_payload is NULL (wrong test declaration)\n", (unsigned int) test_line); MHD_websocket_free (ws, payload); MHD_websocket_stream_free (ws); return 1; } else if (0 != memcmp (payload, expected_payload, payload_len)) { fprintf (stderr, "Decode test failed in line %u: The payload differs from the expected_payload\n", (unsigned int) test_line); MHD_websocket_free (ws, payload); MHD_websocket_stream_free (ws); return 1; } } else { if (NULL != payload) { fprintf (stderr, "Decode test failed in line %u: The payload is not NULL, but payload_len is 0\n", (unsigned int) test_line); MHD_websocket_free (ws, payload); MHD_websocket_stream_free (ws); return 1; } else if (NULL != expected_payload) { fprintf (stderr, "Decode test failed in line %u: The expected_payload is not NULL, but expected_payload_len is 0 (wrong test declaration)\n", (unsigned int) test_line); MHD_websocket_free (ws, payload); MHD_websocket_stream_free (ws); return 1; } } if (streambuf_read_len != expected_streambuf_read_len) { fprintf (stderr, "Decode test failed in line %u: The streambuf_read_len should be %u, but is %u\n", (unsigned int) test_line, (unsigned int) expected_streambuf_read_len, (unsigned int) streambuf_read_len); MHD_websocket_free (ws, payload); MHD_websocket_stream_free (ws); return 1; } ret = MHD_websocket_stream_is_valid (ws); if (ret != expected_valid) { fprintf (stderr, "Decode test failed in line %u: The stream validity should be %u, but is %u\n", (unsigned int) test_line, (int) expected_valid, (int) ret); MHD_websocket_free (ws, payload); MHD_websocket_stream_free (ws); return 1; } /* cleanup */ MHD_websocket_free (ws, payload); MHD_websocket_stream_free (ws); return 0; } /** * Test procedure for `MHD_websocket_stream_init()` and * `MHD_websocket_stream_init2()` */ int test_inits () { int failed = 0; struct MHD_WebSocketStream *ws; int ret; /* ------------------------------------------------------------------------------ All valid flags ------------------------------------------------------------------------------ */ /* Regular test: all valid flags for init (only the even ones work) */ for (int i = 0; i < 7; ++i) { ws = NULL; ret = MHD_websocket_stream_init (&ws, i, 0); if (((0 == (i & MHD_WEBSOCKET_FLAG_CLIENT)) && ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws))) || ((0 != (i & MHD_WEBSOCKET_FLAG_CLIENT)) && ((MHD_WEBSOCKET_STATUS_OK == ret) || (NULL != ws)))) { fprintf (stderr, "Init test failed in line %u for flags %d.\n", (unsigned int) __LINE__, (int) i); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } } /* Regular test: all valid flags for init2 */ for (int i = 0; i < 7; ++i) { ws = NULL; ret = MHD_websocket_stream_init2 (&ws, i, 0, test_malloc, test_realloc, test_free, NULL, test_rng); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u for flags %d.\n", (unsigned int) __LINE__, (int) i); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } } /* Fail test: Invalid flags for init */ for (int i = 4; i < 32; ++i) { int flags = 1 << i; ws = NULL; ret = MHD_websocket_stream_init (&ws, flags, 0); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != ws) ) { fprintf (stderr, "Init test failed in line %u for invalid flags %d.\n", (unsigned int) __LINE__, (int) flags); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } } /* Fail test: Invalid flag for init2 */ for (int i = 4; i < 32; ++i) { int flags = 1 << i; ws = NULL; ret = MHD_websocket_stream_init2 (&ws, flags, 0, test_malloc, test_realloc, test_free, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != ws) ) { fprintf (stderr, "Init test failed in line %u for invalid flags %d.\n", (unsigned int) __LINE__, (int) flags); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } } /* ------------------------------------------------------------------------------ max_payload_size ------------------------------------------------------------------------------ */ /* Regular test: max_payload_size = 0 for init */ ws = NULL; ret = MHD_websocket_stream_init (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u for max_payload_size 0.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Regular test: max_payload_size = 0 for init2 */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u for max_payload_size 0.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Edge test (success): max_payload_size = 1 for init */ ws = NULL; ret = MHD_websocket_stream_init (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 1); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u for max_payload_size 1.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Edge test (success): max_payload_size = 1 for init2 */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 1, test_malloc, test_realloc, test_free, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u for max_payload_size 1.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Regular test: max_payload_size = 1000 for init */ ws = NULL; ret = MHD_websocket_stream_init (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 1000); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u for max_payload_size 1000.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Regular test: max_payload_size = 1000 for init2 */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 1000, test_malloc, test_realloc, test_free, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u for max_payload_size 1000.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } #ifdef ENABLE_64BIT_TESTS /* Edge test (success): max_payload_size = 0x7FFFFFFFFFFFFFFF for init */ ws = NULL; ret = MHD_websocket_stream_init (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, (uint64_t) 0x7FFFFFFFFFFFFFFF); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u for max_payload_size 0x7FFFFFFFFFFFFFFF.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Edge test (success): max_payload_size = 0x7FFFFFFFFFFFFFFF for init2 */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, (uint64_t) 0x7FFFFFFFFFFFFFFF, test_malloc, test_realloc, test_free, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u for max_payload_size 0x7FFFFFFFFFFFFFFF.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Edge test (fail): max_payload_size = 0x8000000000000000 for init */ ws = NULL; ret = MHD_websocket_stream_init (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, (uint64_t) 0x8000000000000000); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != ws) ) { fprintf (stderr, "Init test failed in line %u for max_payload_size 0x8000000000000000.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Edge test (fail): max_payload_size = 0x8000000000000000 for init2 */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, (uint64_t) 0x8000000000000000, test_malloc, test_realloc, test_free, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != ws) ) { fprintf (stderr, "Init test failed in line %u for max_payload_size 0x8000000000000000.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } #endif /* ------------------------------------------------------------------------------ Missing parameters ------------------------------------------------------------------------------ */ /* Fail test: websocket stream variable missing for init */ ws = NULL; ret = MHD_websocket_stream_init (NULL, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != ws) ) { fprintf (stderr, "Init test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Fail test: websocket stream variable missing for init2 */ ws = NULL; ret = MHD_websocket_stream_init2 (NULL, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != ws) ) { fprintf (stderr, "Init test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Fail test: malloc missing for init2 */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, NULL, test_realloc, test_free, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != ws) ) { fprintf (stderr, "Init test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Fail test: realloc missing for init2 */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, NULL, test_free, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != ws) ) { fprintf (stderr, "Init test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Fail test: free missing for init2 */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, NULL, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != ws) ) { fprintf (stderr, "Init test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Regular test: rng given for server mode (will be ignored) */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, test_rng); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Regular test: cls_rng given for server mode (will be ignored) */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, (void *) 12345, test_rng); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Regular test: rng given for client mode */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, test_rng); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL == ws) ) { fprintf (stderr, "Init test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } /* Fail test: rng not given for client mode */ ws = NULL; ret = MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != ws) ) { fprintf (stderr, "Init test failed in line %u %u.\n", (unsigned int) __LINE__, ret); ++failed; } if (NULL != ws) { MHD_websocket_stream_free (ws); ws = NULL; } return failed != 0 ? 0x01 : 0x00; } /** * Test procedure for `MHD_websocket_create_accept_header()` */ int test_accept () { int failed = 0; char accept_key[29]; int ret; /* ------------------------------------------------------------------------------ accepting ------------------------------------------------------------------------------ */ /* Regular test: Test case from RFC6455 4.2.2 */ memset (accept_key, 0, 29); ret = MHD_websocket_create_accept_header ("dGhlIHNhbXBsZSBub25jZQ==", accept_key); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (0 != memcmp (accept_key, "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", 29))) { fprintf (stderr, "Accept test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Missing parameters ------------------------------------------------------------------------------ */ /* Fail test: missing sec-key value */ memset (accept_key, 0, 29); ret = MHD_websocket_create_accept_header (NULL, accept_key); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "Accept test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: missing accept variable */ memset (accept_key, 0, 29); ret = MHD_websocket_create_accept_header ("dGhlIHNhbXBsZSBub25jZQ==", NULL); if (MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) { fprintf (stderr, "Accept test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } return failed != 0 ? 0x02 : 0x00; } /** * Test procedure for `MHD_websocket_decode()` */ int test_decodes () { int failed = 0; char *buf1 = NULL, *buf2 = NULL; /* ------------------------------------------------------------------------------ text frame ------------------------------------------------------------------------------ */ /* Regular test: Masked text frame from RFC 6455, must succeed for server */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x85\x37\xfa\x21\x3d\x7f\x9f\x4d\x51\x58", 11, "Hello", 5, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Regular test: Unmasked text frame from RFC 6455, must succeed for client */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x05\x48\x65\x6c\x6c\x6f", 7, "Hello", 5, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 7); /* Fail test: Unmasked text frame from RFC 6455, must fail for server */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x05\x48\x65\x6c\x6c\x6f", 7, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Fail test: Masked text frame from RFC 6455, must fail for client */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x85\x37\xfa\x21\x3d\x7f\x9f\x4d\x51\x58", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Regular test: Text frame with UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x90\x00\x00\x00\x00" "This is my n" "\xC3\xB6" "te", 22, "This is my n" "\xC3\xB6" "te", 16, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 22); /* Fail test: Text frame with with invalid UTF-8 */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8F\x00\x00\x00\x00" "This is my n" "\xFF" "te", 21, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 18); /* Fail test: Text frame with broken UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8F\x00\x00\x00\x00" "This is my n" "\xC3" "te", 21, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 19); /* Regular test: Text frame without payload and mask (caller = server) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x80\x01\x02\x03\x04", 6, NULL, 0, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 6); /* Fail test: Text frame without payload and no mask (caller = server) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x00", 2, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Regular test: Text frame without payload and mask (caller = client) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x00", 2, NULL, 0, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 2); /* Fail test: Text frame without payload and no mask (caller = client) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x80\x01\x02\x03\x04", 6, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* ------------------------------------------------------------------------------ binary frame ------------------------------------------------------------------------------ */ /* Regular test: Masked binary frame (decoder = server) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x82\x85\x37\xfa\x21\x3d\x7f\x9f\x4d\x51\x58", 11, "Hello", 5, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Regular test: Unmasked binary frame (decoder = client) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x82\x05\x48\x65\x6c\x6c\x6f", 7, "Hello", 5, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 7); /* Fail test: Unmasked binary frame (decoder = server) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x82\x05\x48\x65\x6c\x6c\x6f", 7, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Fail test: Masked binary frame (decoder = client) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x82\x85\x37\xfa\x21\x3d\x7f\x9f\x4d\x51\x58", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Regular test: Binary frame without payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x82\x80\x00\x00\x00\x00", 6, NULL, 0, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 6); /* Regular test: Fragmented binary frame without payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x02\x80\x00\x00\x00\x00\x80\x80\x00\x00\x00\x00", 12, NULL, 0, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 12); /* Regular test: Fragmented binary frame without payload, fragments to the caller, 1st call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 1, 0, "\x02\x80\x00\x00\x00\x00\x80\x80\x00\x00\x00\x00", 12, NULL, 0, MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 6); /* Regular test: Fragmented binary frame without payload, fragments to the caller, 2nd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 2, 0, "\x02\x80\x00\x00\x00\x00\x80\x80\x00\x00\x00\x00", 12, NULL, 0, MHD_WEBSOCKET_STATUS_BINARY_LAST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 12); /* Regular test: Fragmented binary frame with payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x02\x83\x00\x00\x00\x00\x01\x02\x03\x80\x83\x00\x00\x00\x00\x04\x05\x06", 18, "\x01\x02\x03\x04\x05\x06", 6, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 18); /* Regular test: Fragmented binary frame with payload, fragments to the caller, 1st call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 1, 0, "\x02\x83\x00\x00\x00\x00\x01\x02\x03\x80\x83\x00\x00\x00\x00\x04\x05\x06", 18, "\x01\x02\x03", 3, MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 9); /* Regular test: Fragmented binary frame without payload, fragments to the caller, 2nd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 2, 0, "\x02\x83\x00\x00\x00\x00\x01\x02\x03\x80\x83\x00\x00\x00\x00\x04\x05\x06", 18, "\x04\x05\x06", 3, MHD_WEBSOCKET_STATUS_BINARY_LAST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 18); /* Regular test: Fragmented binary frame with payload, fragments to the caller, 1st call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 1, 0, "\x02\x83\x00\x00\x00\x00\x01\x02\x03\x00\x83\x00\x00\x00\x00\x04\x05\x06\x00\x83\x00\x00\x00\x00\x07\x08\x09\x80\x83\x00\x00\x00\x00\x0A\x0B\x0C", 36, "\x01\x02\x03", 3, MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 9); /* Regular test: Fragmented binary frame without payload, fragments to the caller, 2nd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 2, 0, "\x02\x83\x00\x00\x00\x00\x01\x02\x03\x00\x83\x00\x00\x00\x00\x04\x05\x06\x00\x83\x00\x00\x00\x00\x07\x08\x09\x80\x83\x00\x00\x00\x00\x0A\x0B\x0C", 36, "\x04\x05\x06", 3, MHD_WEBSOCKET_STATUS_BINARY_NEXT_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 18); /* Regular test: Fragmented binary frame without payload, fragments to the caller, 3rd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 3, 0, "\x02\x83\x00\x00\x00\x00\x01\x02\x03\x00\x83\x00\x00\x00\x00\x04\x05\x06\x00\x83\x00\x00\x00\x00\x07\x08\x09\x80\x83\x00\x00\x00\x00\x0A\x0B\x0C", 36, "\x07\x08\x09", 3, MHD_WEBSOCKET_STATUS_BINARY_NEXT_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 27); /* Regular test: Fragmented binary frame without payload, fragments to the caller, 4th call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 4, 0, "\x02\x83\x00\x00\x00\x00\x01\x02\x03\x00\x83\x00\x00\x00\x00\x04\x05\x06\x00\x83\x00\x00\x00\x00\x07\x08\x09\x80\x83\x00\x00\x00\x00\x0A\x0B\x0C", 36, "\x0A\x0B\x0C", 3, MHD_WEBSOCKET_STATUS_BINARY_LAST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 36); /* Regular test: Binary frame with bytes which look like invalid UTF-8 character */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x82\x85\x00\x00\x00\x00" "Hell\xf6", 11, "Hell\xf6", 5, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Regular test: Binary frame with bytes which look like broken UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x82\x85\x00\x00\x00\x00" "H\xC3llo", 11, "H\xC3llo", 5, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Regular test: Binary frame with bytes which look like valid UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x82\x85\x00\x00\x00\x00" "H\xC3\xA4lo", 11, "H\xC3\xA4lo", 5, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Regular test: Fragmented binary frame with bytes which look like valid UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x02\x82\x00\x00\x00\x00" "H\xC3" "\x80\x83\x00\x00\x00\x00" "\xA4lo", 17, "H\xC3\xA4lo", 5, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* Regular test: Fragmented binary frame with bytes which look like valid UTF-8 sequence, fragments to the caller, 1st call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 1, 0, "\x02\x82\x00\x00\x00\x00" "H\xC3" "\x80\x83\x00\x00\x00\x00" "\xA4lo", 17, "H\xC3", 2, MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 8); /* Regular test: Fragmented binary frame with bytes which look like valid UTF-8 sequence, fragments to the caller, 2nd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 2, 0, "\x02\x82\x00\x00\x00\x00" "H\xC3" "\x80\x83\x00\x00\x00\x00" "\xA4lo", 17, "\xA4lo", 3, MHD_WEBSOCKET_STATUS_BINARY_LAST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* ------------------------------------------------------------------------------ close frame ------------------------------------------------------------------------------ */ /* Regular test: Close frame with no payload but with mask (decoder = server) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x80\x00\x00\x00\x00", 6, NULL, 0, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 6); /* Regular test: Close frame with no payload (decoder = client) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x00", 2, NULL, 0, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 2); /* Fail test: Close frame with no payload and no mask (decoder = server) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x00", 2, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Fail test: Close frame with no payload but with mask (decoder = client) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x80\x00\x00\x00\x00", 6, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Regular test: Close frame with 2 byte payload for close reason */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x82\x00\x00\x00\x00\x03\xEB", 8, "\x03\xEB", 2, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 8); /* Fail test: Close frame with 1 byte payload (no valid close reason) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x81\x00\x00\x00\x00\x03", 7, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Regular test: Close frame with close reason and UTF-8 description */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x95\x00\x00\x00\x00\x03\xEB" "Something was wrong", 27, "\x03\xEB" "Something was wrong", 21, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 27); /* Regular test: Close frame with close reason and UTF-8 description (with UTF-8 sequence) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x96\x00\x00\x00\x00\x03\xEB" "Something was wr" "\xC3\xB6" "ng", 28, "\x03\xEB" "Something was wr" "\xC3\xB6" "ng", 22, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 28); /* Fail test: Close frame with close reason and invalid UTF-8 in description */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x95\x00\x00\x00\x00\x03\xEB" "Something was wr" "\xFF" "ng", 27, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 24); /* Fail test: Close frame with close reason and broken UTF-8 sequence in description */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x95\x00\x00\x00\x00\x03\xEB" "Something was wr" "\xC3" "ng", 27, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 25); /* Edge test (success): Close frame with 125 bytes of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\xFD\x00\x00\x00\x00\x03\xEB" "Something was wrong, so I decided to close this websocket. I hope you are not angry. But this is also the 123 cap test. :-)", 131, "\x03\xEB" "Something was wrong, so I decided to close this websocket. I hope you are not angry. But this is also the 123 cap test. :-)", 125, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 131); /* Edge test (failure): Close frame with 126 bytes of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\xFE\x00\x7e\x00\x00\x00\x00\x03\xEB" "Something was wrong, so I decided to close this websocket. I hope you are not angry. But this is also the 123 cap test. >:-)", 134, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Fail test: Close frame with 500 bytes of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\xFE\x01\xf4\x00\x00\x00\x00\x03\xEB" "The payload of this test isn't parsed.", 49, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Edge test (failure): Close frame with 65535 bytes of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\xFE\xff\xff\x00\x00\x00\x00\x03\xEB" "The payload of this test isn't parsed.", 49, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Edge test (failure): Close frame with 65536 bytes of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\xFF\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03\xEB" "The payload of this test isn't parsed.", 54, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Fail test: Close frame with 1000000 bytes of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\xFF\x00\x00\x00\x00\x00\x0F\x42\x40\x00\x00\x00\x00\x03\xEB" "The payload of this test isn't parsed.", 54, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* ------------------------------------------------------------------------------ ping frame ------------------------------------------------------------------------------ */ /* Regular test: Ping frame with no payload but with mask (decoder = server) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\x80\x00\x00\x00\x00", 6, NULL, 0, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 6); /* Regular test: Ping frame with no payload (decoder = client) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\x00", 2, NULL, 0, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 2); /* Fail test: Ping frame with no payload and no mask (decoder = server) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\x00", 2, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Fail test: Ping frame with no payload but with mask (decoder = client) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\x80\x00\x00\x00\x00", 6, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Regular test: Ping frame with some (masked) payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\x88\x01\x20\x03\x40\xFF\xFF\xFF\xFF\x00\x00\x00\x00", 14, "\xFE\xDF\xFC\xBF\x01\x20\x03\x40", 8, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 14); /* Edge test (success): Ping frame with one byte of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\x81\x00\x00\x00\x00" "a", 7, "a", 1, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 7); /* Edge test (success): Ping frame with 125 bytes of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\xFD\x00\x00\x00\x00" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 131, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 125, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 131); /* Edge test (fail): Ping frame with 126 bytes of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\xFE\x00\x7E\x00\x00\x00\x00" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 134, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Regular test: Ping frame with UTF-8 data */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\x90\x00\x00\x00\x00" "Ping is bin" "\xC3\xA4" "ry.", 22, "Ping is bin" "\xC3\xA4" "ry.", 16, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 22); /* Regular test: Ping frame with invalid UTF-8 data */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\x8F\x00\x00\x00\x00" "Ping is bin" "\xFF" "ry.", 21, "Ping is bin" "\xFF" "ry.", 15, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 21); /* Regular test: Ping frame with broken UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\x8F\x00\x00\x00\x00" "Ping is bin" "\xC3" "ry.", 21, "Ping is bin" "\xC3" "ry.", 15, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 21); /* ------------------------------------------------------------------------------ pong frame ------------------------------------------------------------------------------ */ /* Regular test: Pong frame with no payload but with mask (decoder = server) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\x80\x00\x00\x00\x00", 6, NULL, 0, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 6); /* Regular test: Pong frame with no payload (decoder = client) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\x00", 2, NULL, 0, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 2); /* Fail test: Pong frame with no payload and no mask (decoder = server) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\x00", 2, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Fail test: Pong frame with no payload but with mask (decoder = client) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_CLIENT | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\x80\x00\x00\x00\x00", 6, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Regular test: Pong frame with some (masked) payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\x88\x01\x20\x03\x40\xFF\xFF\xFF\xFF\x00\x00\x00\x00", 14, "\xFE\xDF\xFC\xBF\x01\x20\x03\x40", 8, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 14); /* Edge test (success): Pong frame with one byte of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\x81\x00\x00\x00\x00" "a", 7, "a", 1, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 7); /* Edge test (success): Pong frame with 125 bytes of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\xFD\x00\x00\x00\x00" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 131, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 125, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 131); /* Edge test (fail): Pong frame with 126 bytes of payload */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\xFE\x00\x7E\x00\x00\x00\x00" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 134, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 1); /* Regular test: Pong frame with UTF-8 data */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\x90\x00\x00\x00\x00" "Pong is bin" "\xC3\xA4" "ry.", 22, "Pong is bin" "\xC3\xA4" "ry.", 16, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 22); /* Regular test: Pong frame with invalid UTF-8 data */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\x8F\x00\x00\x00\x00" "Pong is bin" "\xFF" "ry.", 21, "Pong is bin" "\xFF" "ry.", 15, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 21); /* Regular test: Pong frame with broken UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8A\x8F\x00\x00\x00\x00" "Pong is bin" "\xC3" "ry.", 21, "Pong is bin" "\xC3" "ry.", 15, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 21); /* ------------------------------------------------------------------------------ fragmentation ------------------------------------------------------------------------------ */ /* Regular test: Fragmented, masked text frame, we are the server and don't want fragments as caller */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x01\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x80\x82\x3d\x37\xfa\x21\x51\x58", 17, "Hello", 5, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* Regular test: Fragmented, masked text frame, we are the server and don't want fragments as caller, but call decode two times */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x01\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x80\x82\x3d\x37\xfa\x21\x51\x58", 17, NULL, 0, MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* Regular test: Fragmented, masked text frame, we are the server and want fragments, one call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 1, 0, "\x01\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x80\x82\x3d\x37\xfa\x21\x51\x58", 17, "Hel", 3, MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 9); /* Regular test: Fragmented, masked text frame, we are the server and want fragments, second call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 2, 0, "\x01\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x80\x82\x3d\x37\xfa\x21\x51\x58", 17, "lo", 2, MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* Regular test: Fragmented, masked text frame, we are the server and want fragments, third call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 3, 0, "\x01\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x80\x82\x3d\x37\xfa\x21\x51\x58", 17, NULL, 0, MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* Regular test: Fragmented, masked text frame, we are the server and want fragments, 1st call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 1, 0, "\x01\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x00\x81\x3d\x37\xfa\x21\x51\x80\x81\x37\x37\xfa\x21\x58", 23, "Hel", 3, MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 9); /* Regular test: Fragmented, masked text frame, we are the server and want fragments, 2nd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 2, 0, "\x01\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x00\x81\x3d\x37\xfa\x21\x51\x80\x81\x37\x37\xfa\x21\x58", 23, "l", 1, MHD_WEBSOCKET_STATUS_TEXT_NEXT_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Regular test: Fragmented, masked text frame, we are the server and want fragments, 3rd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 3, 0, "\x01\x83\x37\xfa\x21\x3d\x7f\x9f\x4d\x00\x81\x3d\x37\xfa\x21\x51\x80\x81\x37\x37\xfa\x21\x58", 23, "o", 1, MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 23); /* ------------------------------------------------------------------------------ invalid flags ------------------------------------------------------------------------------ */ /* Regular test: Template with valid data for the next tests (this one must succeed) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x85\x00\x00\x00\x00Hello", 11, "Hello", 5, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Fail test: RSV1 flag set */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x91\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: RSV2 flag set */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\xA1\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: RSV3 flag set */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\xC1\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* ------------------------------------------------------------------------------ invalid opcodes ------------------------------------------------------------------------------ */ /* Fail test: Invalid opcode 0 (0 is usually valid, but only if there was a data frame before) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x80\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Invalid opcode 3 */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x83\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Invalid opcode 4 */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x84\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Invalid opcode 5 */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x85\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Invalid opcode 6 */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x86\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Invalid opcode 7 */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x87\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Invalid opcode 0x0B */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8B\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Invalid opcode 0x0C */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8c\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Invalid opcode 0x0D */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8d\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Invalid opcode 0x0E */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8e\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Invalid opcode 0x0F */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x8f\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* ------------------------------------------------------------------------------ control frames without FIN flag ------------------------------------------------------------------------------ */ /* Fail test: Close frame without FIN flag */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x08\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Ping frame without FIN flag */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x09\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Fail test: Pong frame without FIN flag */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x0a\x85\x00\x00\x00\x00Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* ------------------------------------------------------------------------------ length checks (without max_payload_len) ------------------------------------------------------------------------------ */ /* Edge test (success): 0 bytes of payload (requires 1 byte length) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x80\x00\x00\x00\x00", 6, NULL, 0, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 6); /* Edge test (success): 1 byte of payload (requires 1 byte length) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x81\x00\x00\x00\x00" "a", 7, "a", 1, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 7); /* Edge test (success): 125 bytes of payload (requires 1 byte length) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\xfd\x00\x00\x00\x00" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 131, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 125, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 131); /* Edge test (success): 126 bytes of payload (requires 2 byte length) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\xfe\x00\x7e\x00\x00\x00\x00" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 134, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 126, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 134); /* Edge test (success): 65535 bytes of payload (requires 2 byte length) */ allocate_length_test_data (&buf1, &buf2, 65535, "\x81\xfe\xff\xff\x00\x00\x00\x00", 8); failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, buf1, 65535 + 8, buf2, 65535, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 65535 + 8); /* Edge test (success): 65536 bytes of payload (requires 8 byte length) */ allocate_length_test_data (&buf1, &buf2, 65536, "\x81\xff\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00", 14); failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, buf1, 65536 + 14, buf2, 65536, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 65536 + 14); /* Regular test: 1 MB of payload */ allocate_length_test_data (&buf1, &buf2, 1048576, "\x81\xff\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00", 14); failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, buf1, 1048576 + 14, buf2, 1048576, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 1048576 + 14); /* Regular test: 100 MB of payload */ allocate_length_test_data (&buf1, &buf2, 104857600, "\x81\xff\x00\x00\x00\x00\x06\x40\x00\x00\x00\x00\x00\x00", 14); failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, buf1, 104857600 + 14, buf2, 104857600, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 104857600 + 14); if (NULL != buf1) { free (buf1); buf1 = NULL; } if (NULL != buf2) { free (buf2); buf2 = NULL; } #ifdef ENABLE_64BIT_TESTS /* Edge test (success): Maximum allowed length (here is only the header checked) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\xff\x7f\xff\xff\xff\xff\xff\xff\xff", 10, NULL, 0, MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_VALIDITY_VALID, 10); #else /* Edge test (fail): Maximum allowed length (the size is allowed, but the system cannot handle this amount of memory) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\xff\x7f\xff\xff\xff\xff\xff\xff\xff", 10, NULL, 0, MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED, MHD_WEBSOCKET_VALIDITY_INVALID, 10); #endif /* Edge test (fail): Too big payload length */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\xff\x80\x00\x00\x00\x00\x00\x00\x00", 10, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 10); /* Edge test (fail): Too big payload length */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\xff\xff\xff\xff\xff\xff\xff\xff\xff", 10, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 10); /* Fail test: Not the smallest payload length syntax used (2 byte instead of 1 byte) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\xfe\x00\x05\x00\x00\x00\x00" "abcde", 13, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 4); /* Fail test: Not the smallest payload length syntax used (8 byte instead of 1 byte) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\xff\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00" "abcde", 13, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 10); /* Fail test: Not the smallest payload length syntax used (8 byte instead of 2 byte) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\xff\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00" "abcde", 13, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 10); /* ------------------------------------------------------------------------------ length checks (with max_payload_len) ------------------------------------------------------------------------------ */ /* Regular test: Frame with less payload than specified as limit */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 100, 1, 0, "\x81\x85\x00\x00\x00\x00" "Hello", 11, "Hello", 5, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Edge test (success): Frame with the same payload as the specified limit */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 5, 1, 0, "\x81\x85\x00\x00\x00\x00" "Hello", 11, "Hello", 5, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Edge test (fail): Frame with more payload than specified as limit */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 4, 1, 0, "\x81\x85\x00\x00\x00\x00" "Hello", 11, NULL, 0, MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED, MHD_WEBSOCKET_VALIDITY_INVALID, 2); /* Regular test: Fragmented frames with the sum of payload less than specified as limit */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 100, 1, 0, "\x01\x83\x00\x00\x00\x00" "Hel\x80\x82\x00\x00\x00\x00" "lo", 17, "Hello", 5, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* Edge test (success): Fragmented frames with the sum of payload equal to the specified limit */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 5, 1, 0, "\x01\x83\x00\x00\x00\x00" "Hel\x80\x82\x00\x00\x00\x00" "lo", 17, "Hello", 5, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* Edge test (fail): Fragmented frames with the sum of payload more than specified as limit */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 4, 1, 0, "\x01\x83\x00\x00\x00\x00" "Hel\x80\x82\x00\x00\x00\x00" "lo", 17, NULL, 0, MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED, MHD_WEBSOCKET_VALIDITY_INVALID, 15); /* Edge test (success): Fragmented frames with the sum of payload greater than the specified limit, but we take fragments (one call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 5, 1, 0, "\x01\x83\x00\x00\x00\x00" "Hel\x80\x82\x00\x00\x00\x00" "lo", 17, "Hel", 3, MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 9); /* Edge test (success): Fragmented frames with the sum of payload greater than the specified limit, but we take fragments (two calls) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 5, 2, 0, "\x01\x83\x00\x00\x00\x00" "Hel\x80\x82\x00\x00\x00\x00" "lo", 17, "lo", 2, MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* ------------------------------------------------------------------------------ UTF-8 sequences ------------------------------------------------------------------------------ */ /* Regular test: No UTF-8 characters */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 a ", 16, " a ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Fail test: A UTF-8 tail character without sequence start character */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xA4 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 7); /* Regular test: A two byte UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xC3\xA4 ", 16, " \xC3\xA4 ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Fail test: A broken two byte UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xC3 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Fail test: A two byte UTF-8 sequence with one UTF-8 tail too much */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xC3\xA4\xA4 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 9); /* Regular test: A three byte UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEF\x8F\x8F ", 16, " \xEF\x8F\x8F ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Fail test: A broken byte UTF-8 sequence (two of three bytes) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEF\x8F ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 9); /* Fail test: A broken byte UTF-8 sequence (one of three bytes) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEF ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Fail test: A three byte UTF-8 sequence followed by one UTF-8 tail byte */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEF\x8F\x8F\x8F ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 10); /* Regular test: A four byte UTF-8 sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF2\x8F\x8F\x8F ", 16, " \xF2\x8F\x8F\x8F ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Fail test: A broken four byte UTF-8 sequence (three of four bytes) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF2\x8F\x8F ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 10); /* Fail test: A broken four byte UTF-8 sequence (two of four bytes) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF2\x8F ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 9); /* Fail test: A broken four byte UTF-8 sequence (one of four bytes) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF2 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Fail test: A four byte UTF-8 sequence followed by UTF-8 tail */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF2\x8F\x8F\x8F\x8F ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 11); /* Fail test: A five byte UTF-8 sequence (only up to four bytes allowed) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xFB\x8F\x8F\x8F\x8F ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 7); /* Fail test: A six byte UTF-8 sequence (only up to four bytes allowed) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xFD\x8F\x8F\x8F\x8F\x8F ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 7); /* Fail test: A seven byte UTF-8 sequence (only up to four bytes allowed) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xFE\x8F\x8F\x8F\x8F\x8F\x8F ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 7); /* Fail test: A eight byte UTF-8 sequence (only up to four bytes allowed) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xFF\x8F\x8F\x8F\x8F\x8F\x8F\x8F ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 7); /* Edge test (success): The maximum allowed UTF-8 character */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF4\x8F\xBF\xBF ", 16, " \xF4\x8F\xBF\xBF ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (fail): The maximum allowed UTF-8 character + 1 */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF4\x90\x80\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (success): The last valid UTF8-1 character */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \x7F ", 16, " \x7F ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (fail): The value after the last valid UTF8-1 character */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 7); /* Edge test (fail): The value before the first valid UTF8-2 character */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xC1\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 7); /* Edge test (success): The first valid UTF8-2 character */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xC2\x80 ", 16, " \xC2\x80 ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (success): The last valid UTF8-2 character */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xDF\xBF ", 16, " \xDF\xBF ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (fail): The value after the lst valid UTF8-2 character */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xE0\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (fail): The value before the first valid UTF8-3 character (tail 1) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xE0\x9F\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (success): The first valid UTF8-3 character (tail 1) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xE0\xA0\x80 ", 16, " \xE0\xA0\x80 ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (success): The last valid UTF8-3 character (tail 1) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xE0\xBF\xBF ", 16, " \xE0\xBF\xBF ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (fail): The value after the first valid UTF8-3 character (tail 1) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xE0\xC0\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (success): The first valid UTF8-3 character (tail 2) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xE1\x80\x80 ", 16, " \xE1\x80\x80 ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (success): The last valid UTF8-3 character (tail 2) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEC\xBF\xBF ", 16, " \xEC\xBF\xBF ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (fail): The value after the last valid UTF8-3 character (tail 2) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEC\xC0\xBF ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (fail): The value before the first valid UTF8-3 character (tail 3) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xED\x7F\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (success): The first valid UTF8-3 character (tail 3) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xED\x80\x80 ", 16, " \xED\x80\x80 ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (success): The last valid UTF8-3 character (tail 3) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xED\x9F\xBF ", 16, " \xED\x9F\xBF ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (fail): The value after the last valid UTF8-3 character (tail 3) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xED\xA0\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (fail): The value before the first valid UTF8-3 character (tail 4) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEE\x7F\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (success): The first valid UTF8-3 character (tail 4) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEE\x80\x80 ", 16, " \xEE\x80\x80 ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (success): The last valid UTF8-3 character (tail 4) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEF\xBF\xBF ", 16, " \xEF\xBF\xBF ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (fail): The value after the last valid UTF8-3 character (tail 4) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEF\xBF\xC0 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 9); /* Edge test (fail): The value after the last valid UTF8-3 character (tail 4) #2 */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xEF\xC0\xBF ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (fail): The value before the first valid UTF8-4 character (tail 1) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF0\x8F\x80\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (success): The first valid UTF8-4 character (tail 1) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF0\x90\x80\x80 ", 16, " \xF0\x90\x80\x80 ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (success): The last valid UTF8-4 character (tail 1) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF0\xBF\xBF\xBF ", 16, " \xF0\xBF\xBF\xBF ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (success): The first valid UTF8-4 character (tail 2) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF1\x80\x80\x80 ", 16, " \xF1\x80\x80\x80 ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (success): The last valid UTF8-4 character (tail 2) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF3\xBF\xBF\xBF ", 16, " \xF3\xBF\xBF\xBF ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (fail): A value before the last valid UTF8-4 character in the second byte (tail 2) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF3\x7F\x80\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (fail): A value after the last valid UTF8-4 character in the second byte (tail 2) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF3\xC0\x80\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (success): The first valid UTF8-4 character (tail 3) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF4\x80\x80\x80 ", 16, " \xF4\x80\x80\x80 ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (success): The last valid UTF8-4 character (tail 3) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF4\x8F\xBF\xBF ", 16, " \xF4\x8F\xBF\xBF ", 10, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 16); /* Edge test (fail): The value after the last valid UTF8-4 character (tail 3) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF4\x90\x80\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 8); /* Edge test (fail): The first byte value the last valid UTF8-4 character */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x8A\x00\x00\x00\x00 \xF5\x90\x80\x80 ", 16, NULL, 0, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 7); /* ------------------------------------------------------------------------------ Unfinished UTF-8 sequence between fragmented text frame ------------------------------------------------------------------------------ */ /* Regular test: UTF-8 sequence between fragments, no fragmentation for the caller */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x01\x8D\x00\x00\x00\x00" "This is my n" "\xC3\x80\x83\x00\x00\x00\x00\xB6" "te", 28, "This is my n" "\xC3\xB6" "te", 16, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 28); /* Regular test: UTF-8 sequence between fragments, fragmentation for the caller, 1st call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 1, 0, "\x01\x8D\x00\x00\x00\x00" "This is my n" "\xC3\x80\x83\x00\x00\x00\x00\xB6" "te", 28, "This is my n", 12, MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 19); /* Regular test: UTF-8 sequence between fragments, fragmentation for the caller, 2nd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 2, 0, "\x01\x8D\x00\x00\x00\x00" "This is my n" "\xC3\x80\x83\x00\x00\x00\x00\xB6" "te", 28, "\xC3\xB6" "te", 4, MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 28); /* Edge test (success): UTF-8 sequence between fragments, but nothing before, fragmentation for the caller, 1st call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 1, 0, "\x01\x81\x00\x00\x00\x00\xC3\x80\x81\x00\x00\x00\x00\xB6", 14, NULL, 0, MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 7); /* Edge test (success): UTF-8 sequence between fragments, but nothing before, fragmentation for the caller, 2nd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 2, 0, "\x01\x81\x00\x00\x00\x00\xC3\x80\x81\x00\x00\x00\x00\xB6", 14, "\xC3\xB6", 2, MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 14); /* ------------------------------------------------------------------------------ Decoding with broken stream ------------------------------------------------------------------------------ */ /* Failure test: Invalid sequence */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\xFF\x81\x85\x00\x00\x00\x00" "Hello", 12, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Failure test: Call after invalidated stream */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\xFF\x81\x85\x00\x00\x00\x00" "Hello", 12, NULL, 0, MHD_WEBSOCKET_STATUS_STREAM_BROKEN, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Failure test: Call after invalidated stream (but with different buffer) */ { struct MHD_WebSocketStream *ws; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0)) { size_t streambuf_read_len = 0; char *payload = NULL; size_t payload_len = 0; int ret = 0; ret = MHD_websocket_decode (ws, "\xFF", 1, &streambuf_read_len, &payload, &payload_len); if (MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR != ret) { fprintf (stderr, "Test failed in line %u: The return value should be -1, but is %d\n", (unsigned int) __LINE__, (int) ret); ++failed; } else { ret = MHD_websocket_decode (ws, "\x81\x85\x00\x00\x00\x00" "Hello", 11, &streambuf_read_len, &payload, &payload_len); if (MHD_WEBSOCKET_STATUS_STREAM_BROKEN != ret) { fprintf (stderr, "Test failed in line %u: The return value should be -2, but is %d\n", (unsigned int) __LINE__, (int) ret); ++failed; } } MHD_websocket_stream_free (ws); } else { fprintf (stderr, "Individual test failed in line %u\n", (unsigned int) __LINE__); ++failed; } } /* ------------------------------------------------------------------------------ frame after close frame ------------------------------------------------------------------------------ */ /* Regular test: Close frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x88\x80\x00\x00\x00\x00\x81\x85\x00\x00\x00\x00" "Hello", 17, NULL, 0, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 6); /* Failure test: Text frame after close frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x88\x80\x00\x00\x00\x00\x81\x85\x00\x00\x00\x00" "Hello", 17, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 6); /* Failure test: Binary frame after close frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x88\x80\x00\x00\x00\x00\x82\x85\x00\x00\x00\x00" "Hello", 17, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 6); /* Failure test: Continue frame after close frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x88\x80\x00\x00\x00\x00\x80\x85\x00\x00\x00\x00" "Hello", 17, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 6); /* Regular test: Ping frame after close frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x88\x80\x00\x00\x00\x00\x89\x85\x00\x00\x00\x00" "Hello", 17, "Hello", 5, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 17); /* Regular test: Pong frame after close frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x88\x80\x00\x00\x00\x00\x8A\x85\x00\x00\x00\x00" "Hello", 17, "Hello", 5, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 17); /* Regular test: Close frame after close frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x88\x80\x00\x00\x00\x00\x88\x80\x00\x00\x00\x00", 12, NULL, 0, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 12); /* ------------------------------------------------------------------------------ decoding byte-by-byte ------------------------------------------------------------------------------ */ /* Regular test: Text frame, 2 bytes per loop, 1st call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 2, "\x81\x91\x01\x02\x04\x08" "Ujm{!kw(uja(ugw|/", 23, NULL, 0, MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_VALIDITY_VALID, 2); /* Regular test: Text frame, 2 bytes per loop, 11th call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 11, 2, "\x81\x91\x01\x02\x04\x08" "Ujm{!kw(uja(ugw|/", 23, NULL, 0, MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_VALIDITY_VALID, 22); /* Regular test: Text frame, 2 bytes per loop, 12th call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 12, 2, "\x81\x91\x01\x02\x04\x08" "Ujm{!kw(uja(ugw|/", 23, "This is the test.", 17, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 23); /* Regular test: Text frame, 1 byte per loop, 1st call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 1, "\x81\x91\x01\x02\x04\x08" "Ujm{!kw(uja(ugw|/", 23, NULL, 0, MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_VALIDITY_VALID, 1); /* Regular test: Text frame, 1 byte per loop, 22nd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 22, 1, "\x81\x91\x01\x02\x04\x08" "Ujm{!kw(uja(ugw|/", 23, NULL, 0, MHD_WEBSOCKET_STATUS_OK, MHD_WEBSOCKET_VALIDITY_VALID, 22); /* Regular test: Text frame, 1 byte per loop, 23rd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 23, 1, "\x81\x91\x01\x02\x04\x08" "Ujm{!kw(uja(ugw|/", 23, "This is the test.", 17, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 23); /* ------------------------------------------------------------------------------ mix of fragmented data frames and control frames ------------------------------------------------------------------------------ */ /* Regular test: Fragmented text frame mixed with one ping frame (1st call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x01\x85\x00\x00\x00\x00" "This \x89\x80\x00\x00\x00\x00" "\x80\x8C\x00\x00\x00\x00" "is the test.", 35, NULL, 0, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* Regular test: Fragmented text frame mixed with one ping frame (2nd call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x01\x85\x00\x00\x00\x00" "This \x89\x80\x00\x00\x00\x00" "\x80\x8C\x00\x00\x00\x00" "is the test.", 35, "This is the test.", 17, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 35); /* Regular test: Fragmented text frame mixed with one close frame (1st call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x01\x85\x00\x00\x00\x00" "This \x88\x80\x00\x00\x00\x00" "\x80\x8C\x00\x00\x00\x00" "is the test.", 35, NULL, 0, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 17); /* Fail test: Fragmented text frame mixed with one ping frame (2nd call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x01\x85\x00\x00\x00\x00" "This \x88\x80\x00\x00\x00\x00" "\x80\x8C\x00\x00\x00\x00" "is the test.", 35, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 17); /* Regular test: Fragmented text frame mixed with one ping frame, the caller wants fragments (1st call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 1, 0, "\x01\x85\x00\x00\x00\x00" "This \x89\x80\x00\x00\x00\x00" "\x80\x8C\x00\x00\x00\x00" "is the test.", 35, "This ", 5, MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Regular test: Fragmented text frame mixed with one ping frame, the caller wants fragments (2nd call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 2, 0, "\x01\x85\x00\x00\x00\x00" "This \x89\x80\x00\x00\x00\x00" "\x80\x8C\x00\x00\x00\x00" "is the test.", 35, NULL, 0, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 17); /* Regular test: Fragmented text frame mixed with one ping frame, the caller wants fragments (3rd call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 3, 0, "\x01\x85\x00\x00\x00\x00" "This \x89\x80\x00\x00\x00\x00" "\x80\x8C\x00\x00\x00\x00" "is the test.", 35, "is the test.", 12, MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 35); /* ------------------------------------------------------------------------------ mix of fragmented data frames and data frames ------------------------------------------------------------------------------ */ /* Fail test: Fragmented text frame mixed with one non-fragmented binary frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x01\x85\x00\x00\x00\x00" "This \x82\x81\x00\x00\x00\x00" "a\x80\x8C\x00\x00\x00\x00" "is the test.", 36, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 11); /* Regular test: Fragmented text frame mixed with one non-fragmented binary frame; the caller wants fragments; 1st call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 1, 0, "\x01\x85\x00\x00\x00\x00" "This \x82\x81\x00\x00\x00\x00" "a\x80\x8C\x00\x00\x00\x00" "is the test.", 36, "This ", 5, MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Fail test: Fragmented text frame mixed with one non-fragmented binary frame; the caller wants fragments; 2nd call */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0, 2, 0, "\x01\x85\x00\x00\x00\x00" "This \x82\x81\x00\x00\x00\x00" "a\x80\x8C\x00\x00\x00\x00" "is the test.", 36, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 11); /* Fail test: Fragmented text frame mixed with one fragmented binary frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x01\x85\x00\x00\x00\x00" "This \x02\x81\x00\x00\x00\x00" "a\x80\x8C\x00\x00\x00\x00" "is the test.", 36, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 11); /* Fail test: Fragmented text frame, continue frame, non-fragmented binary frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x01\x85\x00\x00\x00\x00" "This \x00\x8C\x00\x00\x00\x00" "is the test.\x82\x81\x00\x00\x00\x00" "a", 36, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 29); /* Fail test: Fragmented text frame, continue frame, fragmented binary frame */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x01\x85\x00\x00\x00\x00" "This \x00\x8C\x00\x00\x00\x00" "is the test.\x02\x81\x00\x00\x00\x00" "a", 36, NULL, 0, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 29); /* ------------------------------------------------------------------------------ multiple data frames ------------------------------------------------------------------------------ */ /* Regular test: Text frame, binary frame, text frame (1st call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x81\x85\x00\x00\x00\x00" "This \x82\x87\x00\x00\x00\x00" "is the \x81\x85\x00\x00\x00\x00" "test.", 35, "This ", 5, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Regular test: Text frame, binary frame, text frame (2nd call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x81\x85\x00\x00\x00\x00" "This \x82\x87\x00\x00\x00\x00" "is the \x81\x85\x00\x00\x00\x00" "test.", 35, "is the ", 7, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 24); /* Regular test: Text frame, binary frame, text frame (3rd call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 3, 0, "\x81\x85\x00\x00\x00\x00" "This \x82\x87\x00\x00\x00\x00" "is the \x81\x85\x00\x00\x00\x00" "test.", 35, "test.", 5, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 35); /* ------------------------------------------------------------------------------ multiple control frames ------------------------------------------------------------------------------ */ /* Regular test: Ping frame, pong frame, close frame (1st call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, "\x89\x85\x00\x00\x00\x00" "This \x8A\x87\x00\x00\x00\x00" "is the \x88\x85\x00\x00\x00\x00" "test.", 35, "This ", 5, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 11); /* Regular test: Ping frame, pong frame, close frame (2nd call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 2, 0, "\x89\x85\x00\x00\x00\x00" "This \x8A\x87\x00\x00\x00\x00" "is the \x88\x85\x00\x00\x00\x00" "test.", 35, "is the ", 7, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, 24); /* Regular test: Ping frame, pong frame, close frame (3rd call) */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 3, 0, "\x89\x85\x00\x00\x00\x00" "This \x8A\x87\x00\x00\x00\x00" "is the \x88\x85\x00\x00\x00\x00" "test.", 35, "test.", 5, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, 35); /* ------------------------------------------------------------------------------ generated close frames for errors ------------------------------------------------------------------------------ */ /* Regular test: Close frame generated for protocol error */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS | MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR, 0, 1, 0, "\xFF", 1, "\x88\x02\x03\xEA", 4, MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 0); /* Regular test: Close frame generated for UTF-8 sequence error */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS | MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR, 0, 1, 0, "\x81\x85\x00\x00\x00\x00T\xFFst.", 11, "\x88\x02\x03\xEF", 4, MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR, MHD_WEBSOCKET_VALIDITY_INVALID, 7); /* Regular test: Close frame generated for message size exceeded */ failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS | MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR, 3, 1, 0, "\x81\x85\x00\x00\x00\x00T\xFFst.", 11, "\x88\x02\x03\xF1", 4, MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED, MHD_WEBSOCKET_VALIDITY_INVALID, 2); /* ------------------------------------------------------------------------------ terminating NUL character ------------------------------------------------------------------------------ */ { struct MHD_WebSocketStream *ws; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0)) { size_t streambuf_read_len = 0; char *payload = NULL; size_t payload_len = 0; int ret = 0; /* Regular test: text frame */ ret = MHD_websocket_decode (ws, "\x81\x85\x00\x00\x00\x00" "Hello", 11, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_TEXT_FRAME != ret) || (5 != payload_len) || (NULL == payload) || (0 != memcmp ("Hello", payload, 5 + 1))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != payload) { MHD_websocket_free (ws, payload); payload = NULL; } /* Regular test: text frame fragment */ ret = MHD_websocket_decode (ws, "\x01\x83\x00\x00\x00\x00" "Hel\x80\x82\x00\x00\x00\x00" "lo", 17, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_TEXT_FRAME != ret) || (5 != payload_len) || (NULL == payload) || (0 != memcmp ("Hello", payload, 5 + 1))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != payload) { MHD_websocket_free (ws, payload); payload = NULL; } /* Regular test: binary frame */ ret = MHD_websocket_decode (ws, "\x82\x85\x00\x00\x00\x00" "Hello", 11, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_BINARY_FRAME != ret) || (5 != payload_len) || (NULL == payload) || (0 != memcmp ("Hello", payload, 5 + 1))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != payload) { MHD_websocket_free (ws, payload); payload = NULL; } /* Regular test: binary frame fragment */ ret = MHD_websocket_decode (ws, "\x02\x83\x00\x00\x00\x00" "Hel\x80\x82\x00\x00\x00\x00" "lo", 17, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_BINARY_FRAME != ret) || (5 != payload_len) || (NULL == payload) || (0 != memcmp ("Hello", payload, 5 + 1))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != payload) { MHD_websocket_free (ws, payload); payload = NULL; } MHD_websocket_stream_free (ws); } else { fprintf (stderr, "Individual decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } } { struct MHD_WebSocketStream *ws; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS, 0)) { size_t streambuf_read_len = 0; char *payload = NULL; size_t payload_len = 0; int ret = 0; /* Regular test: text frame fragment (caller wants fragment, 1st call) */ ret = MHD_websocket_decode (ws, "\x01\x83\x00\x00\x00\x00" "Hel\x80\x82\x00\x00\x00\x00" "lo", 17, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT != ret) || (3 != payload_len) || (NULL == payload) || (0 != memcmp ("Hel", payload, 3 + 1))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != payload) { MHD_websocket_free (ws, payload); payload = NULL; } /* Regular test: text frame fragment (caller wants fragment, 2nd call) */ ret = MHD_websocket_decode (ws, "\x01\x83\x00\x00\x00\x00" "Hel\x80\x82\x00\x00\x00\x00" "lo" + streambuf_read_len, 17 - streambuf_read_len, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT != ret) || (2 != payload_len) || (NULL == payload) || (0 != memcmp ("lo", payload, 2 + 1))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != payload) { MHD_websocket_free (ws, payload); payload = NULL; } /* Regular test: text frame fragment with broken UTF-8 sequence (caller wants fragment, 1st call) */ ret = MHD_websocket_decode (ws, "\x01\x83\x00\x00\x00\x00" "He\xC3\x80\x82\x00\x00\x00\x00" "\xB6o", 17, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT != ret) || (2 != payload_len) || (NULL == payload) || (0 != memcmp ("He", payload, 2 + 1))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != payload) { MHD_websocket_free (ws, payload); payload = NULL; } /* Regular test: text frame fragment with broken UTF-8 sequence (caller wants fragment, 2nd call) */ ret = MHD_websocket_decode (ws, "\x01\x83\x00\x00\x00\x00" "He\xC3\x80\x82\x00\x00\x00\x00" "\xB6o" + streambuf_read_len, 17 - streambuf_read_len, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT != ret) || (3 != payload_len) || (NULL == payload) || (0 != memcmp ("\xC3\xB6o", payload, 3 + 1))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != payload) { MHD_websocket_free (ws, payload); payload = NULL; } MHD_websocket_stream_free (ws); } else { fprintf (stderr, "Individual decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } } /* ------------------------------------------------------------------------------ invalid parameters ------------------------------------------------------------------------------ */ { struct MHD_WebSocketStream *ws; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0)) { size_t streambuf_read_len = 0; char *payload = NULL; size_t payload_len = 0; int ret = 0; /* Failure test: `ws` is NULL */ payload = (char *) (uintptr_t) 0xBAADF00D; payload_len = 0x87654321; streambuf_read_len = 1000; ret = MHD_websocket_decode (NULL, "\x81\x85\x00\x00\x00\x00Hello", 11, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != payload) || (0 != payload_len) || (0 != streambuf_read_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid (ws))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == payload) { payload = NULL; } if (NULL != payload) { MHD_websocket_free (ws, payload); } /* Failure test: `buf` is NULL, while `buf_len` != 0 */ payload = (char *) (uintptr_t) 0xBAADF00D; payload_len = 0x87654321; streambuf_read_len = 1000; ret = MHD_websocket_decode (ws, NULL, 11, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != payload) || (0 != payload_len) || (0 != streambuf_read_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid (ws))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == payload) { payload = NULL; } if (NULL != payload) { MHD_websocket_free (ws, payload); } /* Failure test: `streambuf_read_len` is NULL */ payload = (char *) (uintptr_t) 0xBAADF00D; payload_len = 0x87654321; ret = MHD_websocket_decode (ws, "\x81\x85\x00\x00\x00\x00Hello", 11, NULL, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != payload) || (0 != payload_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid (ws))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == payload) { payload = NULL; } if (NULL != payload) { MHD_websocket_free (ws, payload); } /* Failure test: `payload` is NULL */ payload_len = 0x87654321; streambuf_read_len = 1000; ret = MHD_websocket_decode (ws, "\x81\x85\x00\x00\x00\x00Hello", 11, &streambuf_read_len, NULL, &payload_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != payload_len) || (0 != streambuf_read_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid (ws))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Failure test: `payload_len` is NULL */ payload = (char *) (uintptr_t) 0xBAADF00D; streambuf_read_len = 1000; ret = MHD_websocket_decode (ws, "\x81\x85\x00\x00\x00\x00Hello", 11, &streambuf_read_len, &payload, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != payload) || (0 != streambuf_read_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid (ws))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == payload) { payload = NULL; } if (NULL != payload) { MHD_websocket_free (ws, payload); } /* Regular test: `buf` is NULL and `buf_len` is 0 */ payload = (char *) (uintptr_t) 0xBAADF00D; payload_len = 0x87654321; streambuf_read_len = 1000; ret = MHD_websocket_decode (ws, NULL, 0, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL != payload) || (0 != payload_len) || (0 != streambuf_read_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid (ws))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == payload) { payload = NULL; } if (NULL != payload) { MHD_websocket_free (ws, payload); } /* Regular test: `buf` is not NULL and `buf_len` is 0 */ payload = (char *) (uintptr_t) 0xBAADF00D; payload_len = 0x87654321; streambuf_read_len = 1000; ret = MHD_websocket_decode (ws, "\x81\x85\x00\x00\x00\x00Hello", 0, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL != payload) || (0 != payload_len) || (0 != streambuf_read_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid (ws))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == payload) { payload = NULL; } if (NULL != payload) { MHD_websocket_free (ws, payload); } MHD_websocket_stream_free (ws); } else { fprintf (stderr, "Parameter decode tests failed in line %u\n", (unsigned int) __LINE__); ++failed; } } /* ------------------------------------------------------------------------------ validity after temporary out-of-memory ------------------------------------------------------------------------------ */ { struct MHD_WebSocketStream *ws; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { size_t streambuf_read_len = 0; char *payload = NULL; size_t payload_len = 0; int ret = 0; /* Failure test: No memory allocation at the start */ disable_alloc = 1; payload = (char *) (uintptr_t) 0xBAADF00D; payload_len = 0x87654321; streambuf_read_len = 1000; ret = MHD_websocket_decode (ws, "\x81\x85\x00\x00\x00\x00Hello", 11, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_MEMORY_ERROR != ret) || (NULL != payload) || (0 != payload_len) || (1000 == streambuf_read_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid (ws))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == payload) { payload = NULL; } if (NULL != payload) { MHD_websocket_free (ws, payload); } MHD_websocket_stream_free (ws); if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { /* Failure test: No memory allocation after fragmented frame */ disable_alloc = 0; payload = (char *) (uintptr_t) 0xBAADF00D; payload_len = 0x87654321; streambuf_read_len = 1000; ret = MHD_websocket_decode (ws, "\x01\x83\x00\x00\x00\x00" "Hel", 9, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (NULL != payload) || (0 != payload_len) || (9 != streambuf_read_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid ( ws))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == payload) { payload = NULL; } if (NULL != payload) { MHD_websocket_free (ws, payload); } disable_alloc = 1; payload = (char *) (uintptr_t) 0xBAADF00D; payload_len = 0x87654321; streambuf_read_len = 1000; ret = MHD_websocket_decode (ws, "\x80\x82\x00\x00\x00\x00" "lo", 8, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_MEMORY_ERROR != ret) || (NULL != payload) || (0 != payload_len) || (1000 == streambuf_read_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid ( ws))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == payload) { payload = NULL; } if (NULL != payload) { MHD_websocket_free (ws, payload); } /* Regular test: Success after memory allocation ok again */ /* (streambuf_read_len may not be overwritten for this test) */ disable_alloc = 0; payload = (char *) (uintptr_t) 0xBAADF00D; payload_len = 0x87654321; size_t old_streambuf_read_len = streambuf_read_len; ret = MHD_websocket_decode (ws, "\x80\x82\x00\x00\x00\x00lo" + old_streambuf_read_len, 8 - old_streambuf_read_len, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_TEXT_FRAME != ret) || (NULL == payload) || (5 != payload_len) || (8 != streambuf_read_len + old_streambuf_read_len) || (MHD_WEBSOCKET_VALIDITY_VALID != MHD_websocket_stream_is_valid ( ws)) || (0 != memcmp ("Hello", payload, 5))) { fprintf (stderr, "Decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == payload) { payload = NULL; } if (NULL != payload) { MHD_websocket_free (ws, payload); } MHD_websocket_stream_free (ws); } else { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } } else { fprintf (stderr, "Memory decode tests failed in line %u\n", (unsigned int) __LINE__); ++failed; } } /* ------------------------------------------------------------------------------ memory leak test, when freeing while decoding ------------------------------------------------------------------------------ */ { disable_alloc = 0; struct MHD_WebSocketStream *ws; size_t streambuf_read_len = 0; char *payload = NULL; size_t payload_len = 0; int ret = 0; /* Regular test: Free while decoding of data frame */ open_allocs = 0; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { ret = MHD_websocket_decode (ws, "\x81\x85\x00\x00\x00\x00Hel", 9, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (0 != payload_len) || (NULL != payload) || (9 != streambuf_read_len) ) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } ret = MHD_websocket_stream_free (ws); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (0 != open_allocs) { fprintf (stderr, "Memory decode test failed in line %u (memory leak detected)\n", (unsigned int) __LINE__); ++failed; } } else { fprintf (stderr, "Memory test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: Free while decoding of control frame */ open_allocs = 0; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { ret = MHD_websocket_decode (ws, "\x88\x85\x00\x00\x00\x00Hel", 9, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (0 != payload_len) || (NULL != payload) || (9 != streambuf_read_len) ) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } ret = MHD_websocket_stream_free (ws); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (0 != open_allocs) { fprintf (stderr, "Memory decode test failed in line %u (memory leak detected)\n", (unsigned int) __LINE__); ++failed; } } else { fprintf (stderr, "Memory test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: Free while decoding of fragmented data frame */ open_allocs = 0; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { ret = MHD_websocket_decode (ws, "\x01\x85\x00\x00\x00\x00Hello", 11, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (0 != payload_len) || (NULL != payload) || (11 != streambuf_read_len) ) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } ret = MHD_websocket_stream_free (ws); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (0 != open_allocs) { fprintf (stderr, "Memory decode test failed in line %u (memory leak detected)\n", (unsigned int) __LINE__); ++failed; } } else { fprintf (stderr, "Memory test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: Free while decoding of continued fragmented data frame */ open_allocs = 0; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { ret = MHD_websocket_decode (ws, "\x01\x85\x00\x00\x00\x00Hello", 11, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (0 != payload_len) || (NULL != payload) || (11 != streambuf_read_len) ) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } ret = MHD_websocket_decode (ws, "\x80\x85\x00\x00\x00\x00Hel", 9, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (0 != payload_len) || (NULL != payload) || (9 != streambuf_read_len) ) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } ret = MHD_websocket_stream_free (ws); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (0 != open_allocs) { fprintf (stderr, "Memory decode test failed in line %u (memory leak detected)\n", (unsigned int) __LINE__); ++failed; } } else { fprintf (stderr, "Memory test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: Free while decoding of control frame during fragmented data frame */ open_allocs = 0; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&ws, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { ret = MHD_websocket_decode (ws, "\x01\x85\x00\x00\x00\x00Hello", 11, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (0 != payload_len) || (NULL != payload) || (11 != streambuf_read_len) ) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } ret = MHD_websocket_decode (ws, "\x88\x85\x00\x00\x00\x00Hel", 9, &streambuf_read_len, &payload, &payload_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (0 != payload_len) || (NULL != payload) || (9 != streambuf_read_len) ) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } ret = MHD_websocket_stream_free (ws); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "Memory decode test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (0 != open_allocs) { fprintf (stderr, "Memory decode test failed in line %u (memory leak detected)\n", (unsigned int) __LINE__); ++failed; } } else { fprintf (stderr, "Memory test failed in line %u\n", (unsigned int) __LINE__); ++failed; } } if (NULL != buf1) { free (buf1); buf1 = NULL; } if (NULL != buf2) { free (buf2); buf2 = NULL; } return failed != 0 ? 0x04 : 0x00; } /** * Test procedure for `MHD_websocket_encode_text()` */ int test_encodes_text () { int failed = 0; struct MHD_WebSocketStream *wss; struct MHD_WebSocketStream *wsc; int ret; char *buf1 = NULL, *buf2 = NULL; char *frame = NULL; size_t frame_len = 0; int utf8_step = 0; if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init2 (&wsc, MHD_WEBSOCKET_FLAG_CLIENT, 0, malloc, realloc, free, NULL, test_rng)) { fprintf (stderr, "No encode text tests possible due to failed stream init in line %u\n", (unsigned int) __LINE__); return 0x08; } if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init (&wss, MHD_WEBSOCKET_FLAG_SERVER, 0)) { fprintf (stderr, "No encode text tests possible due to failed stream init in line %u\n", (unsigned int) __LINE__); if (NULL != wsc) MHD_websocket_stream_free (wsc); return 0x08; } /* ------------------------------------------------------------------------------ Encoding ------------------------------------------------------------------------------ */ /* Regular test: Some data without UTF-8, we are server */ ret = MHD_websocket_encode_text (wss, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x81\x09" "blablabla", 11))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Some data without UTF-8, we are client */ ret = MHD_websocket_encode_text (wsc, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (15 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, "blablabla", 9, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Regular test: Some data with UTF-8, we are server */ ret = MHD_websocket_encode_text (wss, "bla" "\xC3\xA4" "blabla", 11, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (13 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x81\x0B" "bla" "\xC3\xA4" "blabla", 13))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Some data with UTF-8, we are client */ ret = MHD_websocket_encode_text (wsc, "bla" "\xC3\xA4" "blabla", 11, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (17 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, "bla" "\xC3\xA4" "blabla", 11, MHD_WEBSOCKET_STATUS_TEXT_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Edge test (success): Some data with NUL characters, we are server */ ret = MHD_websocket_encode_text (wss, "bla" "\0\0\0" "bla", 9, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x81\x09" "bla" "\0\0\0" "bla", 11))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: Some data with broken UTF-8, we are server */ ret = MHD_websocket_encode_text (wss, "bla" "\xC3" "blabla", 10, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ Fragmentation ------------------------------------------------------------------------------ */ /* Regular test: Some data without UTF-8 */ ret = MHD_websocket_encode_text (wss, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x81\x09" "blablabla", 11))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: First fragment without UTF-8 */ ret = MHD_websocket_encode_text (wss, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_FIRST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x01\x09" "blablabla", 11))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Middle fragment without UTF-8 */ ret = MHD_websocket_encode_text (wss, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_FOLLOWING, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x00\x09" "blablabla", 11))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment without UTF-8 */ ret = MHD_websocket_encode_text (wss, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x09" "blablabla", 11))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): First fragment with UTF-8 on the edge */ ret = MHD_websocket_encode_text (wss, "blablabl\xC3", 9, MHD_WEBSOCKET_FRAGMENTATION_FIRST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_UTF2TAIL_1OF1 != utf8_step) || (0 != memcmp (frame, "\x01\x09" "blablabl\xC3", 11))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Last fragment with UTF-8 on the edge */ ret = MHD_websocket_encode_text (wss, "\xA4" "blablabla", 10, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (12 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0A" "\xA4" "blablabla", 12))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: Last fragment with UTF-8 on the edge (here with wrong old utf8_step) */ utf8_step = MHD_WEBSOCKET_UTF8STEP_NORMAL; ret = MHD_websocket_encode_text (wss, "\xA4" "blablabla", 10, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR != ret) || (0 != frame_len) || (NULL != frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment with UTF-8 on the edge for UTF2TAIL_1OF1 */ utf8_step = MHD_WEBSOCKET_UTF8STEP_UTF2TAIL_1OF1; ret = MHD_websocket_encode_text (wss, "\xA4" "blablabla", 10, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (12 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0A" "\xA4" "blablabla", 12))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment with UTF-8 on the edge for UTF3TAIL1_1OF2 */ utf8_step = MHD_WEBSOCKET_UTF8STEP_UTF3TAIL1_1OF2; ret = MHD_websocket_encode_text (wss, "\xA0\x80" "blablabla", 11, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (13 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0B" "\xA0\x80" "blablabla", 13))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment with UTF-8 on the edge for UTF3TAIL2_1OF2 */ utf8_step = MHD_WEBSOCKET_UTF8STEP_UTF3TAIL2_1OF2; ret = MHD_websocket_encode_text (wss, "\x80\x80" "blablabla", 11, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (13 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0B" "\x80\x80" "blablabla", 13))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment with UTF-8 on the edge for UTF3TAIL_1OF2 */ utf8_step = MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_1OF2; ret = MHD_websocket_encode_text (wss, "\x80\x80" "blablabla", 11, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (13 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0B" "\x80\x80" "blablabla", 13))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment with UTF-8 on the edge for UTF3TAIL_2OF2 */ utf8_step = MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_2OF2; ret = MHD_websocket_encode_text (wss, "\x80" " blablabla", 11, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (13 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0B" "\x80" " blablabla", 13))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment with UTF-8 on the edge for UTF4TAIL1_1OF3 */ utf8_step = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL1_1OF3; ret = MHD_websocket_encode_text (wss, "\x90\x80\x80" "blablabla", 12, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (14 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0C" "\x90\x80\x80" "blablabla", 14))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment with UTF-8 on the edge for UTF4TAIL2_1OF3 */ utf8_step = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL2_1OF3; ret = MHD_websocket_encode_text (wss, "\x80\x80\x80" "blablabla", 12, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (14 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0C" "\x80\x80\x80" "blablabla", 14))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment with UTF-8 on the edge for UTF4TAIL_1OF3 */ utf8_step = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_1OF3; ret = MHD_websocket_encode_text (wss, "\x80\x80\x80" "blablabla", 12, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (14 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0C" "\x80\x80\x80" "blablabla", 14))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment with UTF-8 on the edge for UTF4TAIL_2OF3 */ utf8_step = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_2OF3; ret = MHD_websocket_encode_text (wss, "\x80\x80" " blablabla", 12, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (14 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0C" "\x80\x80" " blablabla", 14))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment with UTF-8 on the edge for UTF4TAIL_3OF3 */ utf8_step = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_3OF3; ret = MHD_websocket_encode_text (wss, "\x80" " blablabla", 12, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (14 != frame_len) || (NULL == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x0C" "\x80" " blablabla", 14))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ Length checks ------------------------------------------------------------------------------ */ /* Edge test (success): Text frame without data */ ret = MHD_websocket_encode_text (wss, NULL, 0, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x81\x00", 2))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Text frame with 1 byte of data */ ret = MHD_websocket_encode_text (wss, "a", 1, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (3 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x81\x01" "a", 3))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Text frame with 125 bytes of data */ ret = MHD_websocket_encode_text (wss, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 125, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (127 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x81\x7D" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 127))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Text frame with 126 bytes of data */ ret = MHD_websocket_encode_text (wss, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 126, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (130 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x81\x7E\x00\x7E" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 130))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Text frame with 65535 bytes of data */ allocate_length_test_data (&buf1, &buf2, 65535, "\x81\x7E\xFF\xFF", 4); ret = MHD_websocket_encode_text (wss, buf2, 65535, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (65535 + 4 != frame_len) || (NULL == frame) || (0 != memcmp (frame, buf1, 65535 + 4))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Text frame with 65536 bytes of data */ allocate_length_test_data (&buf1, &buf2, 65536, "\x81\x7F\x00\x00\x00\x00\x00\x01\x00\x00", 10); ret = MHD_websocket_encode_text (wss, buf2, 65536, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (65536 + 10 != frame_len) || (NULL == frame) || (0 != memcmp (frame, buf1, 65536 + 10))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Text frame with 100 MB of data */ allocate_length_test_data (&buf1, &buf2, 104857600, "\x81\x7F\x00\x00\x00\x00\x06\x40\x00\x00", 10); ret = MHD_websocket_encode_text (wss, buf2, 104857600, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (104857600 + 10 != frame_len) || (NULL == frame) || (0 != memcmp (frame, buf1, 104857600 + 10))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } if (NULL != buf1) { free (buf1); buf1 = NULL; } if (NULL != buf2) { free (buf2); buf2 = NULL; } #ifdef ENABLE_64BIT_TESTS /* Fail test: frame_len is greater than 0x7FFFFFFFFFFFFFFF (this is the maximum allowed payload size) */ frame_len = 0; ret = MHD_websocket_encode_text (wss, "abc", (uint64_t) 0x8000000000000000, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } #endif /* ------------------------------------------------------------------------------ Wrong parameters ------------------------------------------------------------------------------ */ /* Fail test: `ws` not passed */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_text (NULL, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `payload_utf8` not passed, but `payload_utf8_len` != 0 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_text (wss, NULL, 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: `payload_utf8` passed, but `payload_utf8_len` == 0 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_text (wss, "abc", 0, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (((char *) (uintptr_t) 0xBAADF00D) == frame) || (0 != memcmp (frame, "\x81\x00", 2))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `frame` not passed */ frame_len = 0x87654321; ret = MHD_websocket_encode_text (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, NULL, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Fail test: `frame_len` not passed */ frame = (char *) (uintptr_t) 0xBAADF00D; ret = MHD_websocket_encode_text (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, NULL, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: `utf8_step` passed for non-fragmentation (is allowed and `utf8_step` will be filled then) */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; utf8_step = -99; ret = MHD_websocket_encode_text (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (5 != frame_len) || (NULL == frame) || (((char *) (uintptr_t) 0xBAADF00D) == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x81\x03" "abc", 5))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `utf8_step` passed for non-fragmentation with invalid UTF-8 (is allowed and `utf8_step` will be filled then) */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; utf8_step = -99; ret = MHD_websocket_encode_text (wss, "ab\xC3", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR != ret) || (0 != frame_len) || (NULL != frame) || (MHD_WEBSOCKET_UTF8STEP_UTF2TAIL_1OF1 != utf8_step) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `utf8_step` not passed for fragmentation #1 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_text (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_FIRST, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `utf8_step` not passed for fragmentation #2 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_text (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_FOLLOWING, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `utf8_step` not passed for fragmentation #3 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_text (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: `utf8_step` passed for fragmentation #1 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; utf8_step = -99; ret = MHD_websocket_encode_text (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_FIRST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (5 != frame_len) || (NULL == frame) || (((char *) (uintptr_t) 0xBAADF00D) == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x01\x03" "abc", 5))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: `utf8_step` passed for fragmentation #2 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; utf8_step = MHD_WEBSOCKET_UTF8STEP_NORMAL; ret = MHD_websocket_encode_text (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_FOLLOWING, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (5 != frame_len) || (NULL == frame) || (((char *) (uintptr_t) 0xBAADF00D) == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x00\x03" "abc", 5))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: `utf8_step` passed for fragmentation #3 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; utf8_step = MHD_WEBSOCKET_UTF8STEP_NORMAL; ret = MHD_websocket_encode_text (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (5 != frame_len) || (NULL == frame) || (((char *) (uintptr_t) 0xBAADF00D) == frame) || (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) || (0 != memcmp (frame, "\x80\x03" "abc", 5))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `fragmentation` has an invalid value */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; utf8_step = -99; ret = MHD_websocket_encode_text (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_LAST + 1, &frame, &frame_len, &utf8_step); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) || (-99 != utf8_step) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ validity after temporary out-of-memory ------------------------------------------------------------------------------ */ { struct MHD_WebSocketStream *wsx; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&wsx, MHD_WEBSOCKET_FLAG_SERVER, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { /* Fail test: allocation while no memory available */ disable_alloc = 1; ret = MHD_websocket_encode_text (wsx, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_MEMORY_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wsx, frame); frame = NULL; } /* Regular test: allocation while memory is available again */ disable_alloc = 0; ret = MHD_websocket_encode_text (wsx, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (5 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x81\x03" "abc", 5))) { fprintf (stderr, "Encode text test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wsx, frame); frame = NULL; } MHD_websocket_stream_free (wsx); } else { fprintf (stderr, "Couldn't perform memory test for text encoding in line %u\n", (unsigned int) __LINE__); ++failed; } } if (NULL != buf1) free (buf1); if (NULL != buf2) free (buf2); if (NULL != wsc) MHD_websocket_stream_free (wsc); if (NULL != wss) MHD_websocket_stream_free (wss); return failed != 0 ? 0x08 : 0x00; } /** * Test procedure for `MHD_websocket_encode_binary()` */ int test_encodes_binary () { int failed = 0; struct MHD_WebSocketStream *wss; struct MHD_WebSocketStream *wsc; int ret; char *buf1 = NULL, *buf2 = NULL; char *frame = NULL; size_t frame_len = 0; if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init2 (&wsc, MHD_WEBSOCKET_FLAG_CLIENT, 0, malloc, realloc, free, NULL, test_rng)) { fprintf (stderr, "No encode binary tests possible due to failed stream init in line %u\n", (unsigned int) __LINE__); return 0x10; } if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init (&wss, MHD_WEBSOCKET_FLAG_SERVER, 0)) { fprintf (stderr, "No encode binary tests possible due to failed stream init in line %u\n", (unsigned int) __LINE__); if (NULL != wsc) MHD_websocket_stream_free (wsc); return 0x10; } /* ------------------------------------------------------------------------------ Encoding ------------------------------------------------------------------------------ */ /* Regular test: Some data, we are server */ ret = MHD_websocket_encode_binary (wss, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x82\x09" "blablabla", 11))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Some data, we are client */ ret = MHD_websocket_encode_binary (wsc, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (15 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, "blablabla", 9, MHD_WEBSOCKET_STATUS_BINARY_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Edge test (success): Some data with NUL characters, we are server */ ret = MHD_websocket_encode_binary (wss, "bla" "\0\0\0" "bla", 9, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x82\x09" "bla" "\0\0\0" "bla", 11))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Some data which looks like broken UTF-8, we are server */ ret = MHD_websocket_encode_binary (wss, "bla" "\xC3" "blabla", 10, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (12 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x82\x0A" "bla" "\xC3" "blabla", 12))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ Fragmentation ------------------------------------------------------------------------------ */ /* Regular test: Some data */ ret = MHD_websocket_encode_binary (wss, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x82\x09" "blablabla", 11))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: First fragment */ ret = MHD_websocket_encode_binary (wss, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_FIRST, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x02\x09" "blablabla", 11))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Middle fragment */ ret = MHD_websocket_encode_binary (wss, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_FOLLOWING, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x00\x09" "blablabla", 11))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Last fragment */ ret = MHD_websocket_encode_binary (wss, "blablabla", 9, MHD_WEBSOCKET_FRAGMENTATION_LAST, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x80\x09" "blablabla", 11))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ Length checks ------------------------------------------------------------------------------ */ /* Edge test (success): Binary frame without data */ ret = MHD_websocket_encode_binary (wss, NULL, 0, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x82\x00", 2))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Binary frame with 1 byte of data */ ret = MHD_websocket_encode_binary (wss, "a", 1, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (3 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x82\x01" "a", 3))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Binary frame with 125 bytes of data */ ret = MHD_websocket_encode_binary (wss, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 125, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (127 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x82\x7D" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 127))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Binary frame with 126 bytes of data */ ret = MHD_websocket_encode_binary (wss, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 126, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (130 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x82\x7E\x00\x7E" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 130))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Binary frame with 65535 bytes of data */ allocate_length_test_data (&buf1, &buf2, 65535, "\x82\x7E\xFF\xFF", 4); ret = MHD_websocket_encode_binary (wss, buf2, 65535, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (65535 + 4 != frame_len) || (NULL == frame) || (0 != memcmp (frame, buf1, 65535 + 4))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Binary frame with 65536 bytes of data */ allocate_length_test_data (&buf1, &buf2, 65536, "\x82\x7F\x00\x00\x00\x00\x00\x01\x00\x00", 10); ret = MHD_websocket_encode_binary (wss, buf2, 65536, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (65536 + 10 != frame_len) || (NULL == frame) || (0 != memcmp (frame, buf1, 65536 + 10))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Binary frame with 100 MB of data */ allocate_length_test_data (&buf1, &buf2, 104857600, "\x82\x7F\x00\x00\x00\x00\x06\x40\x00\x00", 10); ret = MHD_websocket_encode_binary (wss, buf2, 104857600, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (104857600 + 10 != frame_len) || (NULL == frame) || (0 != memcmp (frame, buf1, 104857600 + 10))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } if (NULL != buf1) { free (buf1); buf1 = NULL; } if (NULL != buf2) { free (buf2); buf2 = NULL; } #ifdef ENABLE_64BIT_TESTS /* Fail test: `frame_len` is greater than 0x7FFFFFFFFFFFFFFF (this is the maximum allowed payload size) */ frame_len = 0; ret = MHD_websocket_encode_binary (wss, "abc", (uint64_t) 0x8000000000000000, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } #endif /* ------------------------------------------------------------------------------ Wrong parameters ------------------------------------------------------------------------------ */ /* Fail test: `ws` not passed */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_binary (NULL, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `payload` not passed, but `payload_len` != 0 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_binary (wss, NULL, 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: `payload` passed, but `payload_len` == 0 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_binary (wss, "abc", 0, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (((char *) (uintptr_t) 0xBAADF00D) == frame) || (0 != memcmp (frame, "\x82\x00", 2))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `frame` not passed */ frame_len = 0x87654321; ret = MHD_websocket_encode_binary (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, NULL, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Fail test: `frame_len` not passed */ frame = (char *) (uintptr_t) 0xBAADF00D; ret = MHD_websocket_encode_binary (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != frame) ) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `fragmentation` has an invalid value */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_binary (wss, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_LAST + 1, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ validity after temporary out-of-memory ------------------------------------------------------------------------------ */ { struct MHD_WebSocketStream *wsx; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&wsx, MHD_WEBSOCKET_FLAG_SERVER, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { /* Fail test: allocation while no memory available */ disable_alloc = 1; ret = MHD_websocket_encode_binary (wsx, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_MEMORY_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wsx, frame); frame = NULL; } /* Regular test: allocation while memory is available again */ disable_alloc = 0; ret = MHD_websocket_encode_binary (wsx, "abc", 3, MHD_WEBSOCKET_FRAGMENTATION_NONE, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (5 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x82\x03" "abc", 5))) { fprintf (stderr, "Encode binary test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wsx, frame); frame = NULL; } MHD_websocket_stream_free (wsx); } else { fprintf (stderr, "Couldn't perform memory test for binary encoding in line %u\n", (unsigned int) __LINE__); ++failed; } } if (NULL != buf1) free (buf1); if (NULL != buf2) free (buf2); if (NULL != wsc) MHD_websocket_stream_free (wsc); if (NULL != wss) MHD_websocket_stream_free (wss); return failed != 0 ? 0x10 : 0x00; } /** * Test procedure for `MHD_websocket_encode_close()` */ int test_encodes_close () { int failed = 0; struct MHD_WebSocketStream *wss; struct MHD_WebSocketStream *wsc; int ret; char *buf1 = NULL, *buf2 = NULL; char *frame = NULL; size_t frame_len = 0; if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init2 (&wsc, MHD_WEBSOCKET_FLAG_CLIENT, 0, malloc, realloc, free, NULL, test_rng)) { fprintf (stderr, "No encode close tests possible due to failed stream init in line %u\n", (unsigned int) __LINE__); return 0x10; } if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init2 (&wss, MHD_WEBSOCKET_FLAG_SERVER, 0, malloc, realloc, free, NULL, test_rng)) { fprintf (stderr, "No encode close tests possible due to failed stream init in line %u\n", (unsigned int) __LINE__); if (NULL != wsc) MHD_websocket_stream_free (wsc); return 0x10; } /* ------------------------------------------------------------------------------ Encoding ------------------------------------------------------------------------------ */ /* Regular test: Some data, we are server */ ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "blablabla", 9, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (13 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x88\x0B\x03\xE8" "blablabla", 13))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Some data, we are client */ ret = MHD_websocket_encode_close (wsc, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "blablabla", 9, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (17 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, "\x03\xE8" "blablabla", 11, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Regular test: Close reason without text, we are server */ ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (4 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x88\x02\x03\xE8", 4))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Close reason without text, we are client */ ret = MHD_websocket_encode_close (wsc, MHD_WEBSOCKET_CLOSEREASON_REGULAR, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (8 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, "\x03\xE8", 2, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Regular test: Close without reason, we are server */ ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_NO_REASON, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x88\x00", 2))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Close without reason, we are client */ ret = MHD_websocket_encode_close (wsc, MHD_WEBSOCKET_CLOSEREASON_NO_REASON, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (6 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, NULL, 0, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Regular test: Close with UTF-8 sequence in reason, we are client */ ret = MHD_websocket_encode_close (wsc, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "bla" "\xC3\xA4" "blabla", 11, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (19 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, "\x03\xE8" "bla" "\xC3\xA4" "blabla", 13, MHD_WEBSOCKET_STATUS_CLOSE_FRAME, MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Edge test (success): Close reason with NUL characters, we are server */ ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_GOING_AWAY, "bla" "\0\0\0" "bla", 9, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (13 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x88\x0B\x03\xE9" "bla" "\0\0\0" "bla", 13))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: Some data with broken UTF-8, we are server */ ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "bla" "\xC3" "blabla", 10, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ Length checks ------------------------------------------------------------------------------ */ /* Edge test (success): Close frame without payload */ ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_NO_REASON, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x88\x00", 2))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Close frame only reason code */ ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (4 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x88\x02\x03\xE8", 4))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Close frame with 1 bytes of reason text */ ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "a", 1, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (5 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x88\x03\x03\xE8" "a", 5))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Close frame with 123 bytes of reason text */ ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456", 123, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (127 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x88\x7D\x03\xE8" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456", 127))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (fail): Close frame with 124 bytes of reason text*/ ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567", 124, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ Wrong parameters ------------------------------------------------------------------------------ */ /* Fail test: `ws` not passed */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_close (NULL, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `payload` not passed, but `payload_len` != 0 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, NULL, 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: `payload` passed, but `payload_len` == 0 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "abc", 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (4 != frame_len) || (NULL == frame) || (((char *) (uintptr_t) 0xBAADF00D) == frame) || (0 != memcmp (frame, "\x88\x02\x03\xE8", 4))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `frame` not passed */ frame_len = 0x87654321; ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "abc", 3, NULL, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Fail test: `frame_len` not passed */ frame = (char *) (uintptr_t) 0xBAADF00D; ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "abc", 3, &frame, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: no reason code passed, but reason text */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_close (wss, MHD_WEBSOCKET_CLOSEREASON_NO_REASON, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (fail): Invalid reason code */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_close (wss, 1, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (fail): Invalid reason code */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_close (wss, 999, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Custom reason code */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_close (wss, 2000, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (7 != frame_len) || (NULL == frame) || (((char *) (uintptr_t) 0xBAADF00D) == frame) || (0 != memcmp (frame, "\x88\x05\x07\xD0" "abc", 7))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ validity after temporary out-of-memory ------------------------------------------------------------------------------ */ { struct MHD_WebSocketStream *wsx; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&wsx, MHD_WEBSOCKET_FLAG_SERVER, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { /* Fail test: allocation while no memory available */ disable_alloc = 1; ret = MHD_websocket_encode_close (wsx, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_MEMORY_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wsx, frame); frame = NULL; } /* Regular test: allocation while memory is available again */ disable_alloc = 0; ret = MHD_websocket_encode_close (wsx, MHD_WEBSOCKET_CLOSEREASON_REGULAR, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (7 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x88\x05\x03\xE8" "abc", 7))) { fprintf (stderr, "Encode close test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wsx, frame); frame = NULL; } MHD_websocket_stream_free (wsx); } else { fprintf (stderr, "Couldn't perform memory test for close encoding in line %u\n", (unsigned int) __LINE__); ++failed; } } if (NULL != buf1) free (buf1); if (NULL != buf2) free (buf2); if (NULL != wsc) MHD_websocket_stream_free (wsc); if (NULL != wss) MHD_websocket_stream_free (wss); return failed != 0 ? 0x20 : 0x00; } /** * Test procedure for `MHD_websocket_encode_ping()` */ int test_encodes_ping () { int failed = 0; struct MHD_WebSocketStream *wss; struct MHD_WebSocketStream *wsc; int ret; char *buf1 = NULL, *buf2 = NULL; char *frame = NULL; size_t frame_len = 0; if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init2 (&wsc, MHD_WEBSOCKET_FLAG_CLIENT, 0, malloc, realloc, free, NULL, test_rng)) { fprintf (stderr, "No encode ping tests possible due to failed stream init in line %u\n", (unsigned int) __LINE__); return 0x10; } if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init (&wss, MHD_WEBSOCKET_FLAG_SERVER, 0)) { fprintf (stderr, "No encode ping tests possible due to failed stream init in line %u\n", (unsigned int) __LINE__); if (NULL != wsc) MHD_websocket_stream_free (wsc); return 0x10; } /* ------------------------------------------------------------------------------ Encoding ------------------------------------------------------------------------------ */ /* Regular test: Some data, we are server */ ret = MHD_websocket_encode_ping (wss, "blablabla", 9, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x89\x09" "blablabla", 11))) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Some data, we are client */ ret = MHD_websocket_encode_ping (wsc, "blablabla", 9, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (15 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, "blablabla", 9, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Regular test: Ping without payload, we are server */ ret = MHD_websocket_encode_ping (wss, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x89\x00", 2))) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Ping without payload, we are client */ ret = MHD_websocket_encode_ping (wsc, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (6 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, NULL, 0, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Regular test: Ping with something like UTF-8 sequence in payload, we are client */ ret = MHD_websocket_encode_ping (wsc, "bla" "\xC3\xA4" "blabla", 11, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (17 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, "bla" "\xC3\xA4" "blabla", 11, MHD_WEBSOCKET_STATUS_PING_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Edge test (success): Ping payload with NUL characters, we are server */ ret = MHD_websocket_encode_ping (wss, "bla" "\0\0\0" "bla", 9, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x89\x09" "bla" "\0\0\0" "bla", 11))) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Ping payload with with something which looks like broken UTF-8, we are server */ ret = MHD_websocket_encode_ping (wss, "bla" "\xC3" "blabla", 10, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (12 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x89\x0A" "bla" "\xC3" "blabla", 12))) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ Length checks ------------------------------------------------------------------------------ */ /* Edge test (success): Ping frame without payload */ ret = MHD_websocket_encode_ping (wss, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x89\x00", 2))) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Ping frame with one byte of payload */ ret = MHD_websocket_encode_ping (wss, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x89\x00", 2))) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Ping frame with 125 bytes of payload */ ret = MHD_websocket_encode_ping (wss, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 125, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (127 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x89\x7D" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 127))) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (fail): Ping frame with 126 bytes of payload */ ret = MHD_websocket_encode_ping (wss, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 126, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ Wrong parameters ------------------------------------------------------------------------------ */ /* Fail test: `ws` not passed */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_ping (NULL, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `payload` not passed, but `payload_len` != 0 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_ping (wss, NULL, 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: `payload` passed, but `payload_len` == 0 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_ping (wss, "abc", 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (((char *) (uintptr_t) 0xBAADF00D) == frame) || (0 != memcmp (frame, "\x89\x00", 2))) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `frame` not passed */ frame_len = 0x87654321; ret = MHD_websocket_encode_ping (wss, "abc", 3, NULL, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) ) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Fail test: `frame_len` not passed */ frame = (char *) (uintptr_t) 0xBAADF00D; ret = MHD_websocket_encode_ping (wss, "abc", 3, &frame, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != frame) ) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ validity after temporary out-of-memory ------------------------------------------------------------------------------ */ { struct MHD_WebSocketStream *wsx; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&wsx, MHD_WEBSOCKET_FLAG_SERVER, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { /* Fail test: allocation while no memory available */ disable_alloc = 1; ret = MHD_websocket_encode_ping (wsx, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_MEMORY_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wsx, frame); frame = NULL; } /* Regular test: allocation while memory is available again */ disable_alloc = 0; ret = MHD_websocket_encode_ping (wsx, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (5 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x89\x03" "abc", 5))) { fprintf (stderr, "Encode ping test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wsx, frame); frame = NULL; } MHD_websocket_stream_free (wsx); } else { fprintf (stderr, "Couldn't perform memory test for ping encoding in line %u\n", (unsigned int) __LINE__); ++failed; } } if (NULL != buf1) free (buf1); if (NULL != buf2) free (buf2); if (NULL != wsc) MHD_websocket_stream_free (wsc); if (NULL != wss) MHD_websocket_stream_free (wss); return failed != 0 ? 0x40 : 0x00; } /** * Test procedure for `MHD_websocket_encode_pong()` */ int test_encodes_pong () { int failed = 0; struct MHD_WebSocketStream *wss; struct MHD_WebSocketStream *wsc; int ret; char *buf1 = NULL, *buf2 = NULL; char *frame = NULL; size_t frame_len = 0; if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init2 (&wsc, MHD_WEBSOCKET_FLAG_CLIENT, 0, malloc, realloc, free, NULL, test_rng)) { fprintf (stderr, "No encode pong tests possible due to failed stream init in line %u\n", (unsigned int) __LINE__); return 0x10; } if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init (&wss, MHD_WEBSOCKET_FLAG_SERVER, 0)) { fprintf (stderr, "No encode pong tests possible due to failed stream init in line %u\n", (unsigned int) __LINE__); if (NULL != wsc) MHD_websocket_stream_free (wsc); return 0x10; } /* ------------------------------------------------------------------------------ Encoding ------------------------------------------------------------------------------ */ /* Regular test: Some data, we are server */ ret = MHD_websocket_encode_pong (wss, "blablabla", 9, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x8A\x09" "blablabla", 11))) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Some data, we are client */ ret = MHD_websocket_encode_pong (wsc, "blablabla", 9, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (15 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, "blablabla", 9, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Regular test: Pong without payload, we are server */ ret = MHD_websocket_encode_pong (wss, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x8A\x00", 2))) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Pong without payload, we are client */ ret = MHD_websocket_encode_pong (wsc, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (6 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, NULL, 0, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Regular test: Pong with something like UTF-8 sequence in payload, we are client */ ret = MHD_websocket_encode_pong (wsc, "bla" "\xC3\xA4" "blabla", 11, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (17 != frame_len) || (NULL == frame) ) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } else { failed += test_decode_single (__LINE__, MHD_WEBSOCKET_FLAG_SERVER | MHD_WEBSOCKET_FLAG_NO_FRAGMENTS, 0, 1, 0, frame, frame_len, "bla" "\xC3\xA4" "blabla", 11, MHD_WEBSOCKET_STATUS_PONG_FRAME, MHD_WEBSOCKET_VALIDITY_VALID, frame_len); } if (NULL != frame) { MHD_websocket_free (wsc, frame); frame = NULL; } /* Edge test (success): Pong payload with NUL characters, we are server */ ret = MHD_websocket_encode_pong (wss, "bla" "\0\0\0" "bla", 9, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (11 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x8A\x09" "bla" "\0\0\0" "bla", 11))) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: Pong payload with with something which looks like broken UTF-8, we are server */ ret = MHD_websocket_encode_pong (wss, "bla" "\xC3" "blabla", 10, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (12 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x8A\x0A" "bla" "\xC3" "blabla", 12))) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ Length checks ------------------------------------------------------------------------------ */ /* Edge test (success): Pong frame without payload */ ret = MHD_websocket_encode_pong (wss, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x8A\x00", 2))) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Pong frame with one byte of payload */ ret = MHD_websocket_encode_pong (wss, NULL, 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x8A\x00", 2))) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (success): Pong frame with 125 bytes of payload */ ret = MHD_websocket_encode_pong (wss, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 125, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (127 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x8A\x7D" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678", 127))) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Edge test (fail): Pong frame with 126 bytes of payload */ ret = MHD_websocket_encode_pong (wss, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 126, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ Wrong parameters ------------------------------------------------------------------------------ */ /* Fail test: `ws` not passed */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_pong (NULL, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `payload` not passed, but `payload_len` != 0 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_pong (wss, NULL, 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Regular test: `payload` passed, but `payload_len` == 0 */ frame = (char *) (uintptr_t) 0xBAADF00D; frame_len = 0x87654321; ret = MHD_websocket_encode_pong (wss, "abc", 0, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (2 != frame_len) || (NULL == frame) || (((char *) (uintptr_t) 0xBAADF00D) == frame) || (0 != memcmp (frame, "\x8A\x00", 2))) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* Fail test: `frame` not passed */ frame_len = 0x87654321; ret = MHD_websocket_encode_pong (wss, "abc", 3, NULL, &frame_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (0 != frame_len) ) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Fail test: `frame_len` not passed */ frame = (char *) (uintptr_t) 0xBAADF00D; ret = MHD_websocket_encode_pong (wss, "abc", 3, &frame, NULL); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (NULL != frame) ) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (((char *) (uintptr_t) 0xBAADF00D) == frame) { frame = NULL; } if (NULL != frame) { MHD_websocket_free (wss, frame); frame = NULL; } /* ------------------------------------------------------------------------------ validity after temporary out-of-memory ------------------------------------------------------------------------------ */ { struct MHD_WebSocketStream *wsx; if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&wsx, MHD_WEBSOCKET_FLAG_SERVER, 0, test_malloc, test_realloc, test_free, NULL, NULL)) { /* Fail test: allocation while no memory available */ disable_alloc = 1; ret = MHD_websocket_encode_pong (wsx, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_MEMORY_ERROR != ret) || (0 != frame_len) || (NULL != frame) ) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wsx, frame); frame = NULL; } /* Regular test: allocation while memory is available again */ disable_alloc = 0; ret = MHD_websocket_encode_pong (wsx, "abc", 3, &frame, &frame_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (5 != frame_len) || (NULL == frame) || (0 != memcmp (frame, "\x8A\x03" "abc", 5))) { fprintf (stderr, "Encode pong test failed in line %u\n", (unsigned int) __LINE__); ++failed; } if (NULL != frame) { MHD_websocket_free (wsx, frame); frame = NULL; } MHD_websocket_stream_free (wsx); } else { fprintf (stderr, "Couldn't perform memory test for pong encoding in line %u\n", (unsigned int) __LINE__); ++failed; } } if (NULL != buf1) free (buf1); if (NULL != buf2) free (buf2); if (NULL != wsc) MHD_websocket_stream_free (wsc); if (NULL != wss) MHD_websocket_stream_free (wss); return failed != 0 ? 0x80 : 0x00; } /** * Test procedure for `MHD_websocket_split_close_reason()` */ int test_split_close_reason () { int failed = 0; const char *payload; unsigned short reason_code; const char *reason_utf8; size_t reason_utf8_len; int ret; /* ------------------------------------------------------------------------------ Normal splits ------------------------------------------------------------------------------ */ /* Regular test: Reason code + Reason text */ reason_code = 9999; reason_utf8 = (const char *) (intptr_t) 0xBAADF00D; reason_utf8_len = 12345; payload = "\x03\xE8" "abc"; ret = MHD_websocket_split_close_reason (payload, 5, &reason_code, &reason_utf8, &reason_utf8_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (MHD_WEBSOCKET_CLOSEREASON_REGULAR != reason_code) || (3 != reason_utf8_len) || (payload + 2 != reason_utf8) ) { fprintf (stderr, "split close reason test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: Reason code */ reason_code = 9999; reason_utf8 = (const char *) (intptr_t) 0xBAADF00D; reason_utf8_len = 12345; payload = "\x03\xE8"; ret = MHD_websocket_split_close_reason (payload, 2, &reason_code, &reason_utf8, &reason_utf8_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (MHD_WEBSOCKET_CLOSEREASON_REGULAR != reason_code) || (0 != reason_utf8_len) || (NULL != reason_utf8) ) { fprintf (stderr, "split close reason test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: No payload */ reason_code = 9999; reason_utf8 = (const char *) (intptr_t) 0xBAADF00D; reason_utf8_len = 12345; payload = NULL; ret = MHD_websocket_split_close_reason (payload, 0, &reason_code, &reason_utf8, &reason_utf8_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (MHD_WEBSOCKET_CLOSEREASON_NO_REASON != reason_code) || (0 != reason_utf8_len) || (NULL != reason_utf8) ) { fprintf (stderr, "split close reason test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: `payload` is not NULL given, but `payload_len` == 0 */ reason_code = 9999; reason_utf8 = (const char *) (intptr_t) 0xBAADF00D; reason_utf8_len = 12345; payload = "abc"; ret = MHD_websocket_split_close_reason (payload, 0, &reason_code, &reason_utf8, &reason_utf8_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (MHD_WEBSOCKET_CLOSEREASON_NO_REASON != reason_code) || (0 != reason_utf8_len) || (NULL != reason_utf8) ) { fprintf (stderr, "split close reason test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Wrong parameters ------------------------------------------------------------------------------ */ /* Fail test: `payload` not passed, but `payload_len` != 0 */ reason_code = 9999; reason_utf8 = (const char *) (intptr_t) 0xBAADF00D; reason_utf8_len = 12345; payload = NULL; ret = MHD_websocket_split_close_reason (payload, 3, &reason_code, &reason_utf8, &reason_utf8_len); if ((MHD_WEBSOCKET_STATUS_PARAMETER_ERROR != ret) || (MHD_WEBSOCKET_CLOSEREASON_NO_REASON != reason_code) || (0 != reason_utf8_len) || (NULL != reason_utf8) ) { fprintf (stderr, "split close reason test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: `reason_code` not passed */ reason_utf8 = (const char *) (intptr_t) 0xBAADF00D; reason_utf8_len = 12345; payload = "\x03\xE8" "abc"; ret = MHD_websocket_split_close_reason (payload, 5, NULL, &reason_utf8, &reason_utf8_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (3 != reason_utf8_len) || (payload + 2 != reason_utf8) ) { fprintf (stderr, "split close reason test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: `reason_utf8` not passed */ reason_code = 9999; reason_utf8_len = 12345; payload = "\x03\xE8" "abc"; ret = MHD_websocket_split_close_reason (payload, 5, &reason_code, NULL, &reason_utf8_len); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (MHD_WEBSOCKET_CLOSEREASON_REGULAR != reason_code) || (3 != reason_utf8_len) ) { fprintf (stderr, "split close reason test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: `reason_utf8_len` not passed */ reason_code = 9999; reason_utf8 = (const char *) (intptr_t) 0xBAADF00D; payload = "\x03\xE8" "abc"; ret = MHD_websocket_split_close_reason (payload, 5, &reason_code, &reason_utf8, NULL); if ((MHD_WEBSOCKET_STATUS_OK != ret) || (MHD_WEBSOCKET_CLOSEREASON_REGULAR != reason_code) || (payload + 2 != reason_utf8) ) { fprintf (stderr, "split close reason test failed in line %u\n", (unsigned int) __LINE__); ++failed; } /* Regular test: `reason_code`, `reason_utf8` and `reason_utf8_len` not passed */ /* (this is not prohibited, although it doesn't really make sense) */ payload = "\x03\xE8" "abc"; ret = MHD_websocket_split_close_reason (payload, 5, NULL, NULL, NULL); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "split close reason test failed in line %u\n", (unsigned int) __LINE__); ++failed; } return failed != 0 ? 0x100 : 0x00; } /** * Test procedure for `MHD_websocket_check_http_version()` */ int test_check_http_version () { int failed = 0; int ret; /* ------------------------------------------------------------------------------ Version check with valid HTTP version syntax ------------------------------------------------------------------------------ */ /* Regular test: HTTP/1.1 */ ret = MHD_websocket_check_http_version ("HTTP/1.1"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Regular test: HTTP/1.2 */ ret = MHD_websocket_check_http_version ("HTTP/1.2"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Regular test: HTTP/1.10 */ ret = MHD_websocket_check_http_version ("HTTP/1.10"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Regular test: HTTP/2.0 */ ret = MHD_websocket_check_http_version ("HTTP/2.0"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Regular test: HTTP/3.0 */ ret = MHD_websocket_check_http_version ("HTTP/3.0"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: HTTP/1.0 */ ret = MHD_websocket_check_http_version ("HTTP/1.0"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: HTTP/0.9 */ ret = MHD_websocket_check_http_version ("HTTP/0.9"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Version check edge cases ------------------------------------------------------------------------------ */ /* Edge test (success): HTTP/123.45 */ ret = MHD_websocket_check_http_version ("HTTP/123.45"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): HTTP/1.45 */ ret = MHD_websocket_check_http_version ("HTTP/1.45"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): HTTP/01.1 */ ret = MHD_websocket_check_http_version ("HTTP/01.1"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): HTTP/0001.1 */ ret = MHD_websocket_check_http_version ("HTTP/0001.1"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): HTTP/1.01 */ ret = MHD_websocket_check_http_version ("HTTP/1.01"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): HTTP/1.0001 */ ret = MHD_websocket_check_http_version ("HTTP/1.0001"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): HTTP/0001.0001 */ ret = MHD_websocket_check_http_version ("HTTP/0001.0001"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): HTTP/2.000 */ ret = MHD_websocket_check_http_version ("HTTP/2.000"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): HTTP/0.0 */ ret = MHD_websocket_check_http_version ("HTTP/0.0"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): HTTP/00.0 */ ret = MHD_websocket_check_http_version ("HTTP/00.0"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): HTTP/00.0 */ ret = MHD_websocket_check_http_version ("HTTP/0.00"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Invalid version syntax ------------------------------------------------------------------------------ */ /* Fail test: (empty string) */ ret = MHD_websocket_check_http_version (""); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: http/1.1 */ ret = MHD_websocket_check_http_version ("http/1.1"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: "HTTP / 1.1" */ ret = MHD_websocket_check_http_version ("HTTP / 1.1"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Missing parameters ------------------------------------------------------------------------------ */ /* Fail test: NULL as version */ ret = MHD_websocket_check_http_version (NULL); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_http_version test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } return failed != 0 ? 0x200 : 0x00; } /** * Test procedure for `MHD_websocket_check_connection_header()` */ int test_check_connection_header () { int failed = 0; int ret; /* ------------------------------------------------------------------------------ Check with valid Connection header syntax ------------------------------------------------------------------------------ */ /* Regular test: Upgrade */ ret = MHD_websocket_check_connection_header ("Upgrade"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Regular test: keep-alive, Upgrade */ ret = MHD_websocket_check_connection_header ("keep-alive, Upgrade"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: keep-alive */ ret = MHD_websocket_check_connection_header ("keep-alive"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: close */ ret = MHD_websocket_check_connection_header ("close"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Connection check edge cases ------------------------------------------------------------------------------ */ /* Edge test (success): keep-alive,Upgrade */ ret = MHD_websocket_check_connection_header ("keep-alive,Upgrade"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): Upgrade, keep-alive */ ret = MHD_websocket_check_connection_header ("Upgrade, keep-alive"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): Upgrade,keep-alive */ ret = MHD_websocket_check_connection_header ("Upgrade,keep-alive"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): Transfer-Encoding,Upgrade,keep-alive */ ret = MHD_websocket_check_connection_header ( "Transfer-Encoding,Upgrade,keep-alive"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): Transfer-Encoding , Upgrade , keep-alive */ ret = MHD_websocket_check_connection_header ( "Transfer-Encoding , Upgrade , keep-alive"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): upgrade */ ret = MHD_websocket_check_connection_header ("upgrade"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): UPGRADE */ ret = MHD_websocket_check_connection_header ("UPGRADE"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): All allowed token characters, then upgrade token */ ret = MHD_websocket_check_connection_header ( "!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,Upgrade"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): Different, allowed whitespaces */ ret = MHD_websocket_check_connection_header (" \tUpgrade \t"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): Different, disallowed whitespaces */ ret = MHD_websocket_check_connection_header ("\rUpgrade"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): Different, disallowed whitespaces */ ret = MHD_websocket_check_connection_header ("\nUpgrade"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): Different, disallowed whitespaces */ ret = MHD_websocket_check_connection_header ("\vUpgrade"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): Different, disallowed whitespaces */ ret = MHD_websocket_check_connection_header ("\fUpgrade"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Invalid header syntax ------------------------------------------------------------------------------ */ /* Fail test: (empty string) */ ret = MHD_websocket_check_connection_header (""); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: (Disallowed) multiple word token with the term "Upgrade" in it */ ret = MHD_websocket_check_connection_header ("Upgrade or Downgrade"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: Invalid characters */ ret = MHD_websocket_check_connection_header ("\"Upgrade\""); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Missing parameters ------------------------------------------------------------------------------ */ /* Fail test: NULL as connection */ ret = MHD_websocket_check_connection_header (NULL); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_connection_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } return failed != 0 ? 0x400 : 0x00; } /** * Test procedure for `MHD_websocket_check_upgrade_header()` */ int test_check_upgrade_header () { int failed = 0; int ret; /* ------------------------------------------------------------------------------ Check with valid Upgrade header syntax ------------------------------------------------------------------------------ */ /* Regular test: websocket */ ret = MHD_websocket_check_upgrade_header ("websocket"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: HTTP/2.0 */ ret = MHD_websocket_check_upgrade_header ("HTTP/2.0"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Upgrade check edge cases ------------------------------------------------------------------------------ */ /* Edge test (success): websocket,HTTP/2.0 */ ret = MHD_websocket_check_upgrade_header ("websocket,HTTP/2.0"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): websocket ,HTTP/2.0 */ ret = MHD_websocket_check_upgrade_header (" websocket ,HTTP/2.0"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): HTTP/2.0, websocket */ ret = MHD_websocket_check_upgrade_header ("HTTP/2.0, websocket "); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): websocket/13 */ ret = MHD_websocket_check_upgrade_header ("websocket/13"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): WeBsOcKeT */ ret = MHD_websocket_check_upgrade_header ("WeBsOcKeT"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): WEBSOCKET */ ret = MHD_websocket_check_upgrade_header ("WEBSOCKET"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): All allowed token characters plus /, then websocket keyword */ ret = MHD_websocket_check_upgrade_header ( "!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/,websocket"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (success): Different, allowed whitespaces */ ret = MHD_websocket_check_upgrade_header (" \twebsocket \t"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): Different, disallowed whitespaces */ ret = MHD_websocket_check_upgrade_header ("\rwebsocket"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): Different, disallowed whitespaces */ ret = MHD_websocket_check_upgrade_header ("\nwebsocket"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): Different, disallowed whitespaces */ ret = MHD_websocket_check_upgrade_header ("\vwebsocket"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): Different, disallowed whitespaces */ ret = MHD_websocket_check_upgrade_header ("\fwebsocket"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Invalid header syntax ------------------------------------------------------------------------------ */ /* Fail test: (empty string) */ ret = MHD_websocket_check_upgrade_header (""); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: (Disallowed) multiple word token with the term "websocket" in it */ ret = MHD_websocket_check_upgrade_header ("websocket or something"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: Invalid characters */ ret = MHD_websocket_check_upgrade_header ("\"websocket\""); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Missing parameters ------------------------------------------------------------------------------ */ /* Fail test: NULL as upgrade */ ret = MHD_websocket_check_upgrade_header (NULL); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_upgrade_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } return failed != 0 ? 0x800 : 0x00; } /** * Test procedure for `MHD_websocket_check_version_header()` */ int test_check_version_header () { int failed = 0; int ret; /* ------------------------------------------------------------------------------ Check with valid Upgrade header syntax ------------------------------------------------------------------------------ */ /* Regular test: 13 */ ret = MHD_websocket_check_version_header ("13"); if (MHD_WEBSOCKET_STATUS_OK != ret) { fprintf (stderr, "check_version_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Version check edge cases ------------------------------------------------------------------------------ */ /* Edge test (fail): 14 */ ret = MHD_websocket_check_version_header ("14"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_version_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): 12 */ ret = MHD_websocket_check_version_header ("12"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_version_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): 0 */ ret = MHD_websocket_check_version_header ("1"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_version_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): 1 */ ret = MHD_websocket_check_version_header ("1"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_version_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): 130 */ ret = MHD_websocket_check_version_header ("130"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_version_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Edge test (fail): " 13" */ ret = MHD_websocket_check_version_header (" 13"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_version_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Invalid header syntax ------------------------------------------------------------------------------ */ /* Fail test: (empty string) */ ret = MHD_websocket_check_version_header (""); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_version_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* Fail test: Invalid characters */ ret = MHD_websocket_check_version_header ("abc"); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_version_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } /* ------------------------------------------------------------------------------ Missing parameters ------------------------------------------------------------------------------ */ /* Fail test: NULL as version */ ret = MHD_websocket_check_version_header (NULL); if (MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER != ret) { fprintf (stderr, "check_version_header test failed in line %u.\n", (unsigned int) __LINE__); ++failed; } return failed != 0 ? 0x1000 : 0x00; } int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ /* seed random number generator */ srand ((unsigned long) time (NULL)); /* perform tests */ errorCount += test_inits (); errorCount += test_accept (); errorCount += test_decodes (); errorCount += test_encodes_text (); errorCount += test_encodes_binary (); errorCount += test_encodes_close (); errorCount += test_encodes_ping (); errorCount += test_encodes_pong (); errorCount += test_split_close_reason (); errorCount += test_check_http_version (); errorCount += test_check_connection_header (); errorCount += test_check_upgrade_header (); errorCount += test_check_version_header (); /* output result */ if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); return errorCount != 0; /* 0 == pass */ } libmicrohttpd-1.0.1/src/microhttpd_ws/mhd_websocket.c0000644000175000017500000023773014417460232016514 /* This file is part of libmicrohttpd Copyright (C) 2021 David Gausmann This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file microhttpd_ws/mhd_websocket.c * @brief Support for the websocket protocol * @author David Gausmann */ #include "platform.h" #include "microhttpd.h" #include "microhttpd_ws.h" #include "sha1.h" struct MHD_WebSocketStream { /* The function pointer to malloc for payload (can be used to use different memory management) */ MHD_WebSocketMallocCallback malloc; /* The function pointer to realloc for payload (can be used to use different memory management) */ MHD_WebSocketReallocCallback realloc; /* The function pointer to free for payload (can be used to use different memory management) */ MHD_WebSocketFreeCallback free; /* A closure for the random number generator (only used for client mode; usually not required) */ void *cls_rng; /* The random number generator (only used for client mode; usually not required) */ MHD_WebSocketRandomNumberGenerator rng; /* The flags specified upon initialization. It may alter the behavior of decoding/encoding */ int flags; /* The current step for the decoder. 0 means start of a frame. */ char decode_step; /* Specifies whether the stream is valid (1) or not (0), if a close frame has been received this is (-1) to indicate that no data frames are allowed anymore */ char validity; /* The current step of the UTF-8 encoding check in the data payload */ char data_utf8_step; /* The current step of the UTF-8 encoding check in the control payload */ char control_utf8_step; /* if != 0 means that we expect a CONTINUATION frame */ char data_type; /* The start of the current frame (may differ from data_payload for CONTINUATION frames) */ char *data_payload_start; /* The buffer for the data frame */ char *data_payload; /* The buffer for the control frame */ char *control_payload; /* Configuration for the maximum allowed buffer size for payload data */ size_t max_payload_size; /* The current frame header size */ size_t frame_header_size; /* The current data payload size (can be greater than payload_size for fragmented frames) */ size_t data_payload_size; /* The size of the payload of the current frame (control or data) */ size_t payload_size; /* The processing offset to the start of the payload of the current frame (control or data) */ size_t payload_index; /* The frame header of the current frame (control or data) */ char frame_header[32]; /* The mask key of the current frame (control or data); this is 0 if no masking used */ char mask_key[4]; }; #define MHD_WEBSOCKET_FLAG_MASK_SERVERCLIENT MHD_WEBSOCKET_FLAG_CLIENT #define MHD_WEBSOCKET_FLAG_MASK_FRAGMENTATION \ MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS #define MHD_WEBSOCKET_FLAG_MASK_GENERATE_CLOSE_FRAMES \ MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR #define MHD_WEBSOCKET_FLAG_MASK_ALL \ (MHD_WEBSOCKET_FLAG_MASK_SERVERCLIENT \ | MHD_WEBSOCKET_FLAG_MASK_FRAGMENTATION \ | MHD_WEBSOCKET_FLAG_MASK_GENERATE_CLOSE_FRAMES) enum MHD_WebSocket_Opcode { MHD_WebSocket_Opcode_Continuation = 0x0, MHD_WebSocket_Opcode_Text = 0x1, MHD_WebSocket_Opcode_Binary = 0x2, MHD_WebSocket_Opcode_Close = 0x8, MHD_WebSocket_Opcode_Ping = 0x9, MHD_WebSocket_Opcode_Pong = 0xA }; enum MHD_WebSocket_DecodeStep { MHD_WebSocket_DecodeStep_Start = 0, MHD_WebSocket_DecodeStep_Length1ofX = 1, MHD_WebSocket_DecodeStep_Length1of2 = 2, MHD_WebSocket_DecodeStep_Length2of2 = 3, MHD_WebSocket_DecodeStep_Length1of8 = 4, MHD_WebSocket_DecodeStep_Length2of8 = 5, MHD_WebSocket_DecodeStep_Length3of8 = 6, MHD_WebSocket_DecodeStep_Length4of8 = 7, MHD_WebSocket_DecodeStep_Length5of8 = 8, MHD_WebSocket_DecodeStep_Length6of8 = 9, MHD_WebSocket_DecodeStep_Length7of8 = 10, MHD_WebSocket_DecodeStep_Length8of8 = 11, MHD_WebSocket_DecodeStep_Mask1Of4 = 12, MHD_WebSocket_DecodeStep_Mask2Of4 = 13, MHD_WebSocket_DecodeStep_Mask3Of4 = 14, MHD_WebSocket_DecodeStep_Mask4Of4 = 15, MHD_WebSocket_DecodeStep_HeaderCompleted = 16, MHD_WebSocket_DecodeStep_PayloadOfDataFrame = 17, MHD_WebSocket_DecodeStep_PayloadOfControlFrame = 18, MHD_WebSocket_DecodeStep_BrokenStream = 99 }; enum MHD_WebSocket_UTF8Result { MHD_WebSocket_UTF8Result_Invalid = 0, MHD_WebSocket_UTF8Result_Valid = 1, MHD_WebSocket_UTF8Result_Incomplete = 2 }; static void MHD_websocket_copy_payload (char *dst, const char *src, size_t len, uint32_t mask, unsigned long mask_offset); static int MHD_websocket_check_utf8 (const char *buf, size_t buf_len, int *utf8_step, size_t *buf_offset); static enum MHD_WEBSOCKET_STATUS MHD_websocket_decode_header_complete (struct MHD_WebSocketStream *ws, char **payload, size_t *payload_len); static enum MHD_WEBSOCKET_STATUS MHD_websocket_decode_payload_complete (struct MHD_WebSocketStream *ws, char **payload, size_t *payload_len); static char MHD_websocket_encode_is_masked (struct MHD_WebSocketStream *ws); static char MHD_websocket_encode_overhead_size (struct MHD_WebSocketStream *ws, size_t payload_len); static enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_data (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, int fragmentation, char **frame, size_t *frame_len, char opcode); static enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_ping_pong (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, char **frame, size_t *frame_len, char opcode); static uint32_t MHD_websocket_generate_mask (struct MHD_WebSocketStream *ws); static uint16_t MHD_htons (uint16_t value); static uint64_t MHD_htonll (uint64_t value); /** * Checks whether the HTTP version is 1.1 or above. */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_http_version (const char *http_version) { /* validate parameters */ if (NULL == http_version) { /* Like with the other check routines, */ /* NULL is threated as "value not given" and not as parameter error */ return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } /* Check whether the version has a valid format */ /* RFC 1945 3.1: The format must be "HTTP/x.x" where x is */ /* any digit and must appear at least once */ if (('H' != http_version[0]) || ('T' != http_version[1]) || ('T' != http_version[2]) || ('P' != http_version[3]) || ('/' != http_version[4])) { return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } /* Find the major and minor part of the version */ /* RFC 1945 3.1: Both numbers must be threated as separate integers. */ /* Leading zeros must be ignored and both integers may have multiple digits */ const char *major = NULL; const char *dot = NULL; size_t i = 5; for (;;) { char c = http_version[i]; if (('0' <= c) && ('9' >= c)) { if ((NULL == major) || ((http_version + i == major + 1) && ('0' == *major)) ) { major = http_version + i; } ++i; } else if ('.' == http_version[i]) { dot = http_version + i; ++i; break; } else { return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } } const char *minor = NULL; const char *end = NULL; for (;;) { char c = http_version[i]; if (('0' <= c) && ('9' >= c)) { if ((NULL == minor) || ((http_version + i == minor + 1) && ('0' == *minor)) ) { minor = http_version + i; } ++i; } else if (0 == c) { end = http_version + i; break; } else { return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } } if ((NULL == major) || (NULL == dot) || (NULL == minor) || (NULL == end)) { return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } if ((2 <= dot - major) || ('2' <= *major) || (('1' == *major) && ((2 <= end - minor) || ('1' <= *minor))) ) { return MHD_WEBSOCKET_STATUS_OK; } return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } /** * Checks whether the "Connection" request header has the 'Upgrade' token. */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_connection_header (const char *connection_header) { /* validate parameters */ if (NULL == connection_header) { /* To be compatible with the return value */ /* of MHD_lookup_connection_value, */ /* NULL is threated as "value not given" and not as parameter error */ return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } /* Check whether the Connection includes an Upgrade token */ /* RFC 7230 6.1: Multiple tokens may appear. */ /* RFC 7230 3.2.6: Tokens are comma separated */ const char *token_start = NULL; const char *token_end = NULL; for (size_t i = 0; ; ++i) { char c = connection_header[i]; /* RFC 7230 3.2.6: The list of allowed characters is a token is: */ /* "!" / "#" / "$" / "%" / "&" / "'" / "*" / */ /* "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" */ /* DIGIT / ALPHA */ if (('!' == c) || ('#' == c) || ('$' == c) || ('%' == c) || ('&' == c) || ('\'' == c) || ('*' == c) || ('+' == c) || ('-' == c) || ('.' == c) || ('^' == c) || ('_' == c) || ('`' == c) || ('|' == c) || ('~' == c) || (('0' <= c) && ('9' >= c)) || (('A' <= c) && ('Z' >= c)) || (('a' <= c) && ('z' >= c)) ) { /* This is a valid token character */ if (NULL == token_start) { token_start = connection_header + i; } token_end = connection_header + i + 1; } else if ((' ' == c) || ('\t' == c)) { /* White-spaces around tokens will be ignored */ } else if ((',' == c) || (0 == c)) { /* Check the token (case-insensitive) */ if (NULL != token_start) { if (7 == (token_end - token_start) ) { if ( (('U' == token_start[0]) || ('u' == token_start[0])) && (('P' == token_start[1]) || ('p' == token_start[1])) && (('G' == token_start[2]) || ('g' == token_start[2])) && (('R' == token_start[3]) || ('r' == token_start[3])) && (('A' == token_start[4]) || ('a' == token_start[4])) && (('D' == token_start[5]) || ('d' == token_start[5])) && (('E' == token_start[6]) || ('e' == token_start[6])) ) { /* The token equals to "Upgrade" */ return MHD_WEBSOCKET_STATUS_OK; } } } if (0 == c) { break; } token_start = NULL; token_end = NULL; } else { /* RFC 7230 3.2.6: Other characters are not allowed */ return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } } return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } /** * Checks whether the "Upgrade" request header has the "websocket" keyword. */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_upgrade_header (const char *upgrade_header) { /* validate parameters */ if (NULL == upgrade_header) { /* To be compatible with the return value */ /* of MHD_lookup_connection_value, */ /* NULL is threated as "value not given" and not as parameter error */ return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } /* Check whether the Connection includes an Upgrade token */ /* RFC 7230 6.1: Multiple tokens may appear. */ /* RFC 7230 3.2.6: Tokens are comma separated */ const char *keyword_start = NULL; const char *keyword_end = NULL; for (size_t i = 0; ; ++i) { char c = upgrade_header[i]; /* RFC 7230 3.2.6: The list of allowed characters is a token is: */ /* "!" / "#" / "$" / "%" / "&" / "'" / "*" / */ /* "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" */ /* DIGIT / ALPHA */ /* We also allow "/" here as the sub-delimiter for the protocol version */ if (('!' == c) || ('#' == c) || ('$' == c) || ('%' == c) || ('&' == c) || ('\'' == c) || ('*' == c) || ('+' == c) || ('-' == c) || ('.' == c) || ('^' == c) || ('_' == c) || ('`' == c) || ('|' == c) || ('~' == c) || ('/' == c) || (('0' <= c) && ('9' >= c)) || (('A' <= c) && ('Z' >= c)) || (('a' <= c) && ('z' >= c)) ) { /* This is a valid token character */ if (NULL == keyword_start) { keyword_start = upgrade_header + i; } keyword_end = upgrade_header + i + 1; } else if ((' ' == c) || ('\t' == c)) { /* White-spaces around tokens will be ignored */ } else if ((',' == c) || (0 == c)) { /* Check the token (case-insensitive) */ if (NULL != keyword_start) { if (9 == (keyword_end - keyword_start) ) { if ( (('W' == keyword_start[0]) || ('w' == keyword_start[0])) && (('E' == keyword_start[1]) || ('e' == keyword_start[1])) && (('B' == keyword_start[2]) || ('b' == keyword_start[2])) && (('S' == keyword_start[3]) || ('s' == keyword_start[3])) && (('O' == keyword_start[4]) || ('o' == keyword_start[4])) && (('C' == keyword_start[5]) || ('c' == keyword_start[5])) && (('K' == keyword_start[6]) || ('k' == keyword_start[6])) && (('E' == keyword_start[7]) || ('e' == keyword_start[7])) && (('T' == keyword_start[8]) || ('t' == keyword_start[8])) ) { /* The keyword equals to "websocket" */ return MHD_WEBSOCKET_STATUS_OK; } } } if (0 == c) { break; } keyword_start = NULL; keyword_end = NULL; } else { /* RFC 7230 3.2.6: Other characters are not allowed */ return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } } return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } /** * Checks whether the "Sec-WebSocket-Version" request header * equals to "13" */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_check_version_header (const char *version_header) { /* validate parameters */ if (NULL == version_header) { /* To be compatible with the return value */ /* of MHD_lookup_connection_value, */ /* NULL is threated as "value not given" and not as parameter error */ return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } if (('1' == version_header[0]) && ('3' == version_header[1]) && (0 == version_header[2])) { /* The version equals to "13" */ return MHD_WEBSOCKET_STATUS_OK; } return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } /** * Creates the response for the Sec-WebSocket-Accept header */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_create_accept_header (const char *sec_websocket_key, char *sec_websocket_accept) { /* initialize output variables for errors cases */ if (NULL != sec_websocket_accept) *sec_websocket_accept = 0; /* validate parameters */ if (NULL == sec_websocket_accept) { return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; } if (NULL == sec_websocket_key) { /* NULL is not a parameter error, */ /* because MHD_lookup_connection_value returns NULL */ /* if the header wasn't found */ return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER; } /* build SHA1 hash of the given key and the UUID appended */ char sha1[20]; const char *suffix = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; int length = (int) strlen (sec_websocket_key); struct sha1_ctx ctx; MHD_SHA1_init (&ctx); MHD_SHA1_update (&ctx, (const uint8_t *) sec_websocket_key, length); MHD_SHA1_update (&ctx, (const uint8_t *) suffix, 36); MHD_SHA1_finish (&ctx, (uint8_t *) sha1); /* base64 encode that SHA1 hash */ /* (simple algorithm here; SHA1 has always 20 bytes, */ /* which will always result in a 28 bytes base64 hash) */ const char *base64_encoding_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; for (int i = 0, j = 0; i < 20;) { uint32_t octet_a = i < 20 ? (unsigned char) sha1[i++] : 0; uint32_t octet_b = i < 20 ? (unsigned char) sha1[i++] : 0; uint32_t octet_c = i < 20 ? (unsigned char) sha1[i++] : 0; uint32_t triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c; sec_websocket_accept[j++] = base64_encoding_table[(triple >> 3 * 6) & 0x3F]; sec_websocket_accept[j++] = base64_encoding_table[(triple >> 2 * 6) & 0x3F]; sec_websocket_accept[j++] = base64_encoding_table[(triple >> 1 * 6) & 0x3F]; sec_websocket_accept[j++] = base64_encoding_table[(triple >> 0 * 6) & 0x3F]; } sec_websocket_accept[27] = '='; sec_websocket_accept[28] = 0; return MHD_WEBSOCKET_STATUS_OK; } /** * Initializes a new websocket stream */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_init (struct MHD_WebSocketStream **ws, int flags, size_t max_payload_size) { return MHD_websocket_stream_init2 (ws, flags, max_payload_size, malloc, realloc, free, NULL, NULL); } /** * Initializes a new websocket stream with * additional parameters for allocation functions */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_init2 (struct MHD_WebSocketStream **ws, int flags, size_t max_payload_size, MHD_WebSocketMallocCallback callback_malloc, MHD_WebSocketReallocCallback callback_realloc, MHD_WebSocketFreeCallback callback_free, void *cls_rng, MHD_WebSocketRandomNumberGenerator callback_rng) { /* initialize output variables for errors cases */ if (NULL != ws) *ws = NULL; /* validate parameters */ if ((NULL == ws) || (0 != (flags & ~MHD_WEBSOCKET_FLAG_MASK_ALL)) || ((uint64_t) 0x7FFFFFFFFFFFFFFF < max_payload_size) || (NULL == callback_malloc) || (NULL == callback_realloc) || (NULL == callback_free) || ((0 != (flags & MHD_WEBSOCKET_FLAG_CLIENT)) && (NULL == callback_rng))) { return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; } /* allocate stream */ struct MHD_WebSocketStream *ws_ = (struct MHD_WebSocketStream *) malloc ( sizeof (struct MHD_WebSocketStream)); if (NULL == ws_) return MHD_WEBSOCKET_STATUS_MEMORY_ERROR; /* initialize stream */ memset (ws_, 0, sizeof (struct MHD_WebSocketStream)); ws_->flags = flags; ws_->max_payload_size = max_payload_size; ws_->malloc = callback_malloc; ws_->realloc = callback_realloc; ws_->free = callback_free; ws_->cls_rng = cls_rng; ws_->rng = callback_rng; ws_->validity = MHD_WEBSOCKET_VALIDITY_VALID; /* return stream */ *ws = ws_; return MHD_WEBSOCKET_STATUS_OK; } /** * Frees a previously allocated websocket stream */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_free (struct MHD_WebSocketStream *ws) { /* validate parameters */ if (NULL == ws) return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; /* free allocated payload data */ if (ws->data_payload) ws->free (ws->data_payload); if (ws->control_payload) ws->free (ws->control_payload); /* free the stream */ free (ws); return MHD_WEBSOCKET_STATUS_OK; } /** * Invalidates a websocket stream (no more decoding possible) */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_invalidate (struct MHD_WebSocketStream *ws) { /* validate parameters */ if (NULL == ws) return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; /* invalidate stream */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; return MHD_WEBSOCKET_STATUS_OK; } /** * Returns whether a websocket stream is valid */ _MHD_EXTERN enum MHD_WEBSOCKET_VALIDITY MHD_websocket_stream_is_valid (struct MHD_WebSocketStream *ws) { /* validate parameters */ if (NULL == ws) return MHD_WEBSOCKET_VALIDITY_INVALID; return ws->validity; } /** * Decodes incoming data to a websocket frame */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_decode (struct MHD_WebSocketStream *ws, const char *streambuf, size_t streambuf_len, size_t *streambuf_read_len, char **payload, size_t *payload_len) { /* initialize output variables for errors cases */ if (NULL != streambuf_read_len) *streambuf_read_len = 0; if (NULL != payload) *payload = NULL; if (NULL != payload_len) *payload_len = 0; /* validate parameters */ if ((NULL == ws) || ((NULL == streambuf) && (0 != streambuf_len)) || (NULL == streambuf_read_len) || (NULL == payload) || (NULL == payload_len) ) { return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; } /* validate stream validity */ if (MHD_WEBSOCKET_VALIDITY_INVALID == ws->validity) return MHD_WEBSOCKET_STATUS_STREAM_BROKEN; /* decode loop */ size_t current = 0; while (current < streambuf_len) { switch (ws->decode_step) { /* start of frame */ case MHD_WebSocket_DecodeStep_Start: { /* The first byte contains the opcode, the fin flag and three reserved bits */ if (MHD_WEBSOCKET_VALIDITY_INVALID != ws->validity) { char opcode = streambuf [current]; if (0 != (opcode & 0x70)) { /* RFC 6455 5.2 RSV1-3: If a reserved flag is set */ /* (while it isn't specified by an extension) the communication must fail. */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } switch (opcode & 0x0F) { case MHD_WebSocket_Opcode_Continuation: if (0 == ws->data_type) { /* RFC 6455 5.4: Continuation frame without previous data frame */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } if (MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES == ws->validity) { /* RFC 6455 5.5.1: After a close frame has been sent, */ /* no data frames may be sent (so we don't accept data frames */ /* for decoding anymore) */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } break; case MHD_WebSocket_Opcode_Text: case MHD_WebSocket_Opcode_Binary: if (0 != ws->data_type) { /* RFC 6455 5.4: Continuation expected, but new data frame */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } if (MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES == ws->validity) { /* RFC 6455 5.5.1: After a close frame has been sent, */ /* no data frames may be sent (so we don't accept data frames */ /* for decoding anymore) */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } break; case MHD_WebSocket_Opcode_Close: case MHD_WebSocket_Opcode_Ping: case MHD_WebSocket_Opcode_Pong: if ((opcode & 0x80) == 0) { /* RFC 6455 5.4: Control frames may not be fragmented */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } if (MHD_WebSocket_Opcode_Close == (opcode & 0x0F)) { /* RFC 6455 5.5.1: After a close frame has been sent, */ /* no data frames may be sent (so we don't accept data frames */ /* for decoding anymore) */ ws->validity = MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES; } break; default: /* RFC 6455 5.2 OPCODE: Only six opcodes are specified. */ /* All other are invalid in version 13 of the protocol. */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } } ws->frame_header [ws->frame_header_size++] = streambuf [current++]; ws->decode_step = MHD_WebSocket_DecodeStep_Length1ofX; } break; case MHD_WebSocket_DecodeStep_Length1ofX: { /* The second byte specifies whether the data is masked and the size */ /* (the client MUST mask the payload, the server MUST NOT mask the payload) */ char frame_len = streambuf [current]; char is_masked = (frame_len & 0x80); frame_len &= 0x7f; if (MHD_WEBSOCKET_VALIDITY_INVALID != ws->validity) { if (0 != is_masked) { if (MHD_WEBSOCKET_FLAG_CLIENT == (ws->flags & MHD_WEBSOCKET_FLAG_CLIENT)) { /* RFC 6455 5.1: All frames from the server must be unmasked */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } } else { if (MHD_WEBSOCKET_FLAG_SERVER == (ws->flags & MHD_WEBSOCKET_FLAG_CLIENT)) { /* RFC 6455 5.1: All frames from the client must be masked */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } } if (126 <= frame_len) { if (0 != (ws->frame_header [0] & 0x08)) { /* RFC 6455 5.5: Control frames may not have more payload than 125 bytes */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } } if (1 == frame_len) { if (MHD_WebSocket_Opcode_Close == (ws->frame_header [0] & 0x0F)) { /* RFC 6455 5.5.1: The close frame must have at least */ /* two bytes of payload if payload is used */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } } } ws->frame_header [ws->frame_header_size++] = streambuf [current++]; if (126 == frame_len) { ws->decode_step = MHD_WebSocket_DecodeStep_Length1of2; } else if (127 == frame_len) { ws->decode_step = MHD_WebSocket_DecodeStep_Length1of8; } else { size_t size = (size_t) frame_len; if ((SIZE_MAX < size) || (ws->max_payload_size && (ws->max_payload_size < size)) ) { /* RFC 6455 7.4.1 1009: If the message is too big to process, we may close the connection */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_MAXIMUM_ALLOWED_PAYLOAD_SIZE_EXCEEDED, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED; } ws->payload_size = size; if (0 != is_masked) { /* with mask */ ws->decode_step = MHD_WebSocket_DecodeStep_Mask1Of4; } else { /* without mask */ *((uint32_t *) ws->mask_key) = 0; ws->decode_step = MHD_WebSocket_DecodeStep_HeaderCompleted; } } } break; /* Payload size first byte of 2 bytes */ case MHD_WebSocket_DecodeStep_Length1of2: /* Payload size first 7 bytes of 8 bytes */ case MHD_WebSocket_DecodeStep_Length1of8: case MHD_WebSocket_DecodeStep_Length2of8: case MHD_WebSocket_DecodeStep_Length3of8: case MHD_WebSocket_DecodeStep_Length4of8: case MHD_WebSocket_DecodeStep_Length5of8: case MHD_WebSocket_DecodeStep_Length6of8: case MHD_WebSocket_DecodeStep_Length7of8: /* Mask first 3 bytes of 4 bytes */ case MHD_WebSocket_DecodeStep_Mask1Of4: case MHD_WebSocket_DecodeStep_Mask2Of4: case MHD_WebSocket_DecodeStep_Mask3Of4: ws->frame_header [ws->frame_header_size++] = streambuf [current++]; ++ws->decode_step; break; /* 2 byte length finished */ case MHD_WebSocket_DecodeStep_Length2of2: { ws->frame_header [ws->frame_header_size++] = streambuf [current++]; size_t size = (size_t) MHD_htons ( *((uint16_t *) &ws->frame_header [2])); if (125 >= size) { /* RFC 6455 5.2 Payload length: The minimal number of bytes */ /* must be used for the length */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } if ((SIZE_MAX < size) || (ws->max_payload_size && (ws->max_payload_size < size)) ) { /* RFC 6455 7.4.1 1009: If the message is too big to process, */ /* we may close the connection */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_MAXIMUM_ALLOWED_PAYLOAD_SIZE_EXCEEDED, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED; } ws->payload_size = size; if (0 != (ws->frame_header [1] & 0x80)) { /* with mask */ ws->decode_step = MHD_WebSocket_DecodeStep_Mask1Of4; } else { /* without mask */ *((uint32_t *) ws->mask_key) = 0; ws->decode_step = MHD_WebSocket_DecodeStep_HeaderCompleted; } } break; /* 8 byte length finished */ case MHD_WebSocket_DecodeStep_Length8of8: { ws->frame_header [ws->frame_header_size++] = streambuf [current++]; uint64_t size = MHD_htonll (*((uint64_t *) &ws->frame_header [2])); if (0x7fffffffffffffff < size) { /* RFC 6455 5.2 frame-payload-length-63: The length may */ /* not exceed 0x7fffffffffffffff */ ws->decode_step = MHD_WebSocket_DecodeStep_BrokenStream; ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } if (65535 >= size) { /* RFC 6455 5.2 Payload length: The minimal number of bytes */ /* must be used for the length */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; } if ((SIZE_MAX < size) || (ws->max_payload_size && (ws->max_payload_size < size)) ) { /* RFC 6455 7.4.1 1009: If the message is too big to process, */ /* we may close the connection */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_MAXIMUM_ALLOWED_PAYLOAD_SIZE_EXCEEDED, 0, 0, payload, payload_len); } *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED; } ws->payload_size = (size_t) size; if (0 != (ws->frame_header [1] & 0x80)) { /* with mask */ ws->decode_step = MHD_WebSocket_DecodeStep_Mask1Of4; } else { /* without mask */ *((uint32_t *) ws->mask_key) = 0; ws->decode_step = MHD_WebSocket_DecodeStep_HeaderCompleted; } } break; /* mask finished */ case MHD_WebSocket_DecodeStep_Mask4Of4: ws->frame_header [ws->frame_header_size++] = streambuf [current++]; *((uint32_t *) ws->mask_key) = *((uint32_t *) &ws->frame_header [ws-> frame_header_size - 4]); ws->decode_step = MHD_WebSocket_DecodeStep_HeaderCompleted; break; /* header finished */ case MHD_WebSocket_DecodeStep_HeaderCompleted: /* return or assign either to data or control */ { int ret = MHD_websocket_decode_header_complete (ws, payload, payload_len); if (MHD_WEBSOCKET_STATUS_OK != ret) { *streambuf_read_len = current; return ret; } } break; /* payload data */ case MHD_WebSocket_DecodeStep_PayloadOfDataFrame: case MHD_WebSocket_DecodeStep_PayloadOfControlFrame: { size_t bytes_needed = ws->payload_size - ws->payload_index; size_t bytes_remaining = streambuf_len - current; size_t bytes_to_take = bytes_needed < bytes_remaining ? bytes_needed : bytes_remaining; if (0 != bytes_to_take) { size_t utf8_start = ws->payload_index; char *decode_payload = ws->decode_step == MHD_WebSocket_DecodeStep_PayloadOfDataFrame ? ws->data_payload_start : ws->control_payload; /* copy the new payload data (with unmasking if necessary */ MHD_websocket_copy_payload (decode_payload + ws->payload_index, &streambuf [current], bytes_to_take, *((uint32_t *) ws->mask_key), (unsigned long) (ws->payload_index & 0x03)); current += bytes_to_take; ws->payload_index += bytes_to_take; if (((MHD_WebSocket_DecodeStep_PayloadOfDataFrame == ws->decode_step) && (MHD_WebSocket_Opcode_Text == ws->data_type)) || ((MHD_WebSocket_DecodeStep_PayloadOfControlFrame == ws->decode_step) && (MHD_WebSocket_Opcode_Close == (ws->frame_header [0] & 0x0f)) && (2 < ws->payload_index)) ) { /* RFC 6455 8.1: We need to check the UTF-8 validity */ int utf8_step; char *decode_payload_utf8; size_t bytes_to_check; size_t utf8_error_offset = 0; if (MHD_WebSocket_DecodeStep_PayloadOfDataFrame == ws->decode_step) { utf8_step = ws->data_utf8_step; decode_payload_utf8 = decode_payload + utf8_start; bytes_to_check = bytes_to_take; } else { utf8_step = ws->control_utf8_step; if ((MHD_WebSocket_Opcode_Close == (ws->frame_header [0] & 0x0f)) && (2 > utf8_start) ) { /* The first two bytes of the close frame are binary content and */ /* must be skipped in the UTF-8 check */ utf8_start = 2; utf8_error_offset = 2; } decode_payload_utf8 = decode_payload + utf8_start; bytes_to_check = bytes_to_take - utf8_start; } size_t utf8_check_offset = 0; int utf8_result = MHD_websocket_check_utf8 (decode_payload_utf8, bytes_to_check, &utf8_step, &utf8_check_offset); if (MHD_WebSocket_UTF8Result_Invalid != utf8_result) { /* memorize current validity check step to continue later */ ws->data_utf8_step = utf8_step; } else { /* RFC 6455 8.1: We must fail on broken UTF-8 sequence */ ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_MALFORMED_UTF8, 0, 0, payload, payload_len); } *streambuf_read_len = current - bytes_to_take + utf8_check_offset + utf8_error_offset; return MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR; } } } } if (ws->payload_size == ws->payload_index) { /* all payload data of the current frame has been received */ int ret = MHD_websocket_decode_payload_complete (ws, payload, payload_len); if (MHD_WEBSOCKET_STATUS_OK != ret) { *streambuf_read_len = current; return ret; } } break; case MHD_WebSocket_DecodeStep_BrokenStream: *streambuf_read_len = current; return MHD_WEBSOCKET_STATUS_STREAM_BROKEN; } } /* Special treatment for zero payload length messages */ if (MHD_WebSocket_DecodeStep_HeaderCompleted == ws->decode_step) { int ret = MHD_websocket_decode_header_complete (ws, payload, payload_len); if (MHD_WEBSOCKET_STATUS_OK != ret) { *streambuf_read_len = current; return ret; } } switch (ws->decode_step) { case MHD_WebSocket_DecodeStep_PayloadOfDataFrame: case MHD_WebSocket_DecodeStep_PayloadOfControlFrame: if (ws->payload_size == ws->payload_index) { /* all payload data of the current frame has been received */ int ret = MHD_websocket_decode_payload_complete (ws, payload, payload_len); if (MHD_WEBSOCKET_STATUS_OK != ret) { *streambuf_read_len = current; return ret; } } break; } *streambuf_read_len = current; /* more data needed */ return MHD_WEBSOCKET_STATUS_OK; } static enum MHD_WEBSOCKET_STATUS MHD_websocket_decode_header_complete (struct MHD_WebSocketStream *ws, char **payload, size_t *payload_len) { /* assign either to data or control */ char opcode = ws->frame_header [0] & 0x0f; switch (opcode) { case MHD_WebSocket_Opcode_Continuation: { /* validate payload size */ size_t new_size_total = ws->payload_size + ws->data_payload_size; if ((0 != ws->max_payload_size) && (ws->max_payload_size < new_size_total) ) { /* RFC 6455 7.4.1 1009: If the message is too big to process, */ /* we may close the connection */ ws->decode_step = MHD_WebSocket_DecodeStep_BrokenStream; ws->validity = MHD_WEBSOCKET_VALIDITY_INVALID; if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR)) { MHD_websocket_encode_close (ws, MHD_WEBSOCKET_CLOSEREASON_MAXIMUM_ALLOWED_PAYLOAD_SIZE_EXCEEDED, 0, 0, payload, payload_len); } return MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED; } /* allocate buffer for continued data frame */ char *new_buf = NULL; if (0 != new_size_total) { new_buf = ws->realloc (ws->data_payload, new_size_total + 1); if (NULL == new_buf) { return MHD_WEBSOCKET_STATUS_MEMORY_ERROR; } new_buf [new_size_total] = 0; ws->data_payload_start = &new_buf[ws->data_payload_size]; } else { ws->data_payload_start = new_buf; } ws->data_payload = new_buf; ws->data_payload_size = new_size_total; } ws->decode_step = MHD_WebSocket_DecodeStep_PayloadOfDataFrame; break; case MHD_WebSocket_Opcode_Text: case MHD_WebSocket_Opcode_Binary: /* allocate buffer for data frame */ { size_t new_size_total = ws->payload_size; char *new_buf = NULL; if (0 != new_size_total) { new_buf = ws->malloc (new_size_total + 1); if (NULL == new_buf) { return MHD_WEBSOCKET_STATUS_MEMORY_ERROR; } new_buf [new_size_total] = 0; } ws->data_payload = new_buf; ws->data_payload_start = new_buf; ws->data_payload_size = new_size_total; ws->data_type = opcode; } ws->decode_step = MHD_WebSocket_DecodeStep_PayloadOfDataFrame; break; case MHD_WebSocket_Opcode_Close: case MHD_WebSocket_Opcode_Ping: case MHD_WebSocket_Opcode_Pong: /* allocate buffer for control frame */ { size_t new_size_total = ws->payload_size; char *new_buf = NULL; if (0 != new_size_total) { new_buf = ws->malloc (new_size_total + 1); if (NULL == new_buf) { return MHD_WEBSOCKET_STATUS_MEMORY_ERROR; } new_buf[new_size_total] = 0; } ws->control_payload = new_buf; } ws->decode_step = MHD_WebSocket_DecodeStep_PayloadOfControlFrame; break; } return MHD_WEBSOCKET_STATUS_OK; } static enum MHD_WEBSOCKET_STATUS MHD_websocket_decode_payload_complete (struct MHD_WebSocketStream *ws, char **payload, size_t *payload_len) { /* all payload data of the current frame has been received */ char is_continue = MHD_WebSocket_Opcode_Continuation == (ws->frame_header [0] & 0x0F); char is_fin = ws->frame_header [0] & 0x80; if (0 != is_fin) { /* the frame is complete */ if (MHD_WebSocket_DecodeStep_PayloadOfDataFrame == ws->decode_step) { /* data frame */ char data_type = ws->data_type; if ((0 != (ws->flags & MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS)) && (0 != is_continue)) { data_type |= 0x40; /* mark as last fragment */ } *payload = ws->data_payload; *payload_len = ws->data_payload_size; ws->data_payload = 0; ws->data_payload_start = 0; ws->data_payload_size = 0; ws->decode_step = MHD_WebSocket_DecodeStep_Start; ws->payload_index = 0; ws->data_type = 0; ws->frame_header_size = 0; return data_type; } else { /* control frame */ *payload = ws->control_payload; *payload_len = ws->payload_size; ws->control_payload = 0; ws->decode_step = MHD_WebSocket_DecodeStep_Start; ws->payload_index = 0; ws->frame_header_size = 0; return (ws->frame_header [0] & 0x0f); } } else if (0 != (ws->flags & MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS)) { /* RFC 6455 5.4: To allow streaming, the user can choose */ /* to return fragments */ if ((MHD_WebSocket_Opcode_Text == ws->data_type) && (MHD_WEBSOCKET_UTF8STEP_NORMAL != ws->data_utf8_step) ) { /* the last UTF-8 sequence is incomplete, so we keep the start of that and only return the part before */ size_t given_utf8 = 0; switch (ws->data_utf8_step) { /* one byte given */ case MHD_WEBSOCKET_UTF8STEP_UTF2TAIL_1OF1: case MHD_WEBSOCKET_UTF8STEP_UTF3TAIL1_1OF2: case MHD_WEBSOCKET_UTF8STEP_UTF3TAIL2_1OF2: case MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_1OF2: case MHD_WEBSOCKET_UTF8STEP_UTF4TAIL1_1OF3: case MHD_WEBSOCKET_UTF8STEP_UTF4TAIL2_1OF3: case MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_1OF3: given_utf8 = 1; break; /* two bytes given */ case MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_2OF2: case MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_2OF3: given_utf8 = 2; break; /* three bytes given */ case MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_3OF3: given_utf8 = 3; break; } size_t new_len = ws->data_payload_size - given_utf8; if (0 != new_len) { char *next_payload = ws->malloc (given_utf8 + 1); if (NULL == next_payload) { return MHD_WEBSOCKET_STATUS_MEMORY_ERROR; } memcpy (next_payload, ws->data_payload_start + ws->payload_index - given_utf8, given_utf8); next_payload[given_utf8] = 0; ws->data_payload[new_len] = 0; *payload = ws->data_payload; *payload_len = new_len; ws->data_payload = next_payload; ws->data_payload_size = given_utf8; } else { *payload = NULL; *payload_len = 0; } ws->decode_step = MHD_WebSocket_DecodeStep_Start; ws->payload_index = 0; ws->frame_header_size = 0; if (0 != is_continue) return ws->data_type | 0x20; /* mark as middle fragment */ else return ws->data_type | 0x10; /* mark as first fragment */ } else { /* we simply pass the entire data frame */ *payload = ws->data_payload; *payload_len = ws->data_payload_size; ws->data_payload = 0; ws->data_payload_start = 0; ws->data_payload_size = 0; ws->decode_step = MHD_WebSocket_DecodeStep_Start; ws->payload_index = 0; ws->frame_header_size = 0; if (0 != is_continue) return ws->data_type | 0x20; /* mark as middle fragment */ else return ws->data_type | 0x10; /* mark as first fragment */ } } else { /* RFC 6455 5.4: We must await a continuation frame to get */ /* the remainder of this data frame */ ws->decode_step = MHD_WebSocket_DecodeStep_Start; ws->frame_header_size = 0; ws->payload_index = 0; return MHD_WEBSOCKET_STATUS_OK; } } /** * Splits the received close reason */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_split_close_reason (const char *payload, size_t payload_len, unsigned short *reason_code, const char **reason_utf8, size_t *reason_utf8_len) { /* initialize output variables for errors cases */ if (NULL != reason_code) *reason_code = MHD_WEBSOCKET_CLOSEREASON_NO_REASON; if (NULL != reason_utf8) *reason_utf8 = NULL; if (NULL != reason_utf8_len) *reason_utf8_len = 0; /* validate parameters */ if ((NULL == payload) && (0 != payload_len)) return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; if (1 == payload_len) return MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR; if (125 < payload_len) return MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED; /* decode reason code */ if (2 > payload_len) { if (NULL != reason_code) *reason_code = MHD_WEBSOCKET_CLOSEREASON_NO_REASON; } else { if (NULL != reason_code) *reason_code = MHD_htons (*((uint16_t *) payload)); } /* decode reason text */ if (2 >= payload_len) { if (NULL != reason_utf8) *reason_utf8 = NULL; if (NULL != reason_utf8_len) *reason_utf8_len = 0; } else { if (NULL != reason_utf8) *reason_utf8 = payload + 2; if (NULL != reason_utf8_len) *reason_utf8_len = payload_len - 2; } return MHD_WEBSOCKET_STATUS_OK; } /** * Encodes a text into a websocket text frame */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_text (struct MHD_WebSocketStream *ws, const char *payload_utf8, size_t payload_utf8_len, int fragmentation, char **frame, size_t *frame_len, int *utf8_step) { /* initialize output variables for errors cases */ if (NULL != frame) *frame = NULL; if (NULL != frame_len) *frame_len = 0; if ((NULL != utf8_step) && ((MHD_WEBSOCKET_FRAGMENTATION_FIRST == fragmentation) || (MHD_WEBSOCKET_FRAGMENTATION_NONE == fragmentation) )) { /* the old UTF-8 step will be ignored for new fragments */ *utf8_step = MHD_WEBSOCKET_UTF8STEP_NORMAL; } /* validate parameters */ if ((NULL == ws) || ((0 != payload_utf8_len) && (NULL == payload_utf8)) || (NULL == frame) || (NULL == frame_len) || (MHD_WEBSOCKET_FRAGMENTATION_NONE > fragmentation) || (MHD_WEBSOCKET_FRAGMENTATION_LAST < fragmentation) || ((MHD_WEBSOCKET_FRAGMENTATION_NONE != fragmentation) && (NULL == utf8_step)) ) { return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; } /* check max length */ if ((uint64_t) 0x7FFFFFFFFFFFFFFF < (uint64_t) payload_utf8_len) { return MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED; } /* check UTF-8 */ int utf8_result = MHD_websocket_check_utf8 (payload_utf8, payload_utf8_len, utf8_step, NULL); if ((MHD_WebSocket_UTF8Result_Invalid == utf8_result) || ((MHD_WebSocket_UTF8Result_Incomplete == utf8_result) && (MHD_WEBSOCKET_FRAGMENTATION_NONE == fragmentation)) ) { return MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR; } /* encode data */ return MHD_websocket_encode_data (ws, payload_utf8, payload_utf8_len, fragmentation, frame, frame_len, MHD_WebSocket_Opcode_Text); } /** * Encodes binary data into a websocket binary frame */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_binary (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, int fragmentation, char **frame, size_t *frame_len) { /* initialize output variables for errors cases */ if (NULL != frame) *frame = NULL; if (NULL != frame_len) *frame_len = 0; /* validate parameters */ if ((NULL == ws) || ((0 != payload_len) && (NULL == payload)) || (NULL == frame) || (NULL == frame_len) || (MHD_WEBSOCKET_FRAGMENTATION_NONE > fragmentation) || (MHD_WEBSOCKET_FRAGMENTATION_LAST < fragmentation) ) { return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; } /* check max length */ if ((uint64_t) 0x7FFFFFFFFFFFFFFF < (uint64_t) payload_len) { return MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED; } return MHD_websocket_encode_data (ws, payload, payload_len, fragmentation, frame, frame_len, MHD_WebSocket_Opcode_Binary); } /** * Internal function for encoding text/binary data into a websocket frame */ static enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_data (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, int fragmentation, char **frame, size_t *frame_len, char opcode) { /* calculate length and masking */ char is_masked = MHD_websocket_encode_is_masked (ws); size_t overhead_len = MHD_websocket_encode_overhead_size (ws, payload_len); size_t total_len = overhead_len + payload_len; uint32_t mask = 0 != is_masked ? MHD_websocket_generate_mask (ws) : 0; /* allocate memory */ char *result = ws->malloc (total_len + 1); if (NULL == result) return MHD_WEBSOCKET_STATUS_MEMORY_ERROR; result [total_len] = 0; *frame = result; *frame_len = total_len; /* add the opcode */ switch (fragmentation) { case MHD_WEBSOCKET_FRAGMENTATION_NONE: *(result++) = 0x80 | opcode; break; case MHD_WEBSOCKET_FRAGMENTATION_FIRST: *(result++) = opcode; break; case MHD_WEBSOCKET_FRAGMENTATION_FOLLOWING: *(result++) = MHD_WebSocket_Opcode_Continuation; break; case MHD_WEBSOCKET_FRAGMENTATION_LAST: *(result++) = 0x80 | MHD_WebSocket_Opcode_Continuation; break; } /* add the length */ if (126 > payload_len) { *(result++) = is_masked | (char) payload_len; } else if (65536 > payload_len) { *(result++) = is_masked | 126; *((uint16_t *) result) = MHD_htons ((uint16_t) payload_len); result += 2; } else { *(result++) = is_masked | 127; *((uint64_t *) result) = MHD_htonll ((uint64_t) payload_len); result += 8; } /* add the mask */ if (0 != is_masked) { *(result++) = ((char *) &mask)[0]; *(result++) = ((char *) &mask)[1]; *(result++) = ((char *) &mask)[2]; *(result++) = ((char *) &mask)[3]; } /* add the payload */ if (0 != payload_len) { MHD_websocket_copy_payload (result, payload, payload_len, mask, 0); } return MHD_WEBSOCKET_STATUS_OK; } /** * Encodes a websocket ping frame */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_ping (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, char **frame, size_t *frame_len) { /* encode the ping frame */ return MHD_websocket_encode_ping_pong (ws, payload, payload_len, frame, frame_len, MHD_WebSocket_Opcode_Ping); } /** * Encodes a websocket pong frame */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_pong (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, char **frame, size_t *frame_len) { /* encode the pong frame */ return MHD_websocket_encode_ping_pong (ws, payload, payload_len, frame, frame_len, MHD_WebSocket_Opcode_Pong); } /** * Internal function for encoding ping/pong frames */ static enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_ping_pong (struct MHD_WebSocketStream *ws, const char *payload, size_t payload_len, char **frame, size_t *frame_len, char opcode) { /* initialize output variables for errors cases */ if (NULL != frame) *frame = NULL; if (NULL != frame_len) *frame_len = 0; /* validate the parameters */ if ((NULL == ws) || ((0 != payload_len) && (NULL == payload)) || (NULL == frame) || (NULL == frame_len) ) { return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; } /* RFC 6455 5.5: Control frames may only have up to 125 bytes of payload data */ if (125 < payload_len) return MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED; /* calculate length and masking */ char is_masked = MHD_websocket_encode_is_masked (ws); size_t overhead_len = MHD_websocket_encode_overhead_size (ws, payload_len); size_t total_len = overhead_len + payload_len; uint32_t mask = is_masked != 0 ? MHD_websocket_generate_mask (ws) : 0; /* allocate memory */ char *result = ws->malloc (total_len + 1); if (NULL == result) return MHD_WEBSOCKET_STATUS_MEMORY_ERROR; result [total_len] = 0; *frame = result; *frame_len = total_len; /* add the opcode */ *(result++) = 0x80 | opcode; /* add the length */ *(result++) = is_masked | (char) payload_len; /* add the mask */ if (0 != is_masked) { *(result++) = ((char *) &mask)[0]; *(result++) = ((char *) &mask)[1]; *(result++) = ((char *) &mask)[2]; *(result++) = ((char *) &mask)[3]; } /* add the payload */ if (0 != payload_len) { MHD_websocket_copy_payload (result, payload, payload_len, mask, 0); } return MHD_WEBSOCKET_STATUS_OK; } /** * Encodes a websocket close frame */ _MHD_EXTERN enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_close (struct MHD_WebSocketStream *ws, unsigned short reason_code, const char *reason_utf8, size_t reason_utf8_len, char **frame, size_t *frame_len) { /* initialize output variables for errors cases */ if (NULL != frame) *frame = NULL; if (NULL != frame_len) *frame_len = 0; /* validate the parameters */ if ((NULL == ws) || ((0 != reason_utf8_len) && (NULL == reason_utf8)) || (NULL == frame) || (NULL == frame_len) || ((MHD_WEBSOCKET_CLOSEREASON_NO_REASON != reason_code) && (1000 > reason_code)) || ((0 != reason_utf8_len) && (MHD_WEBSOCKET_CLOSEREASON_NO_REASON == reason_code)) ) { return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; } /* RFC 6455 5.5: Control frames may only have up to 125 bytes of payload data, */ /* but in this case only 123 bytes, because 2 bytes are reserved */ /* for the close reason code. */ if (123 < reason_utf8_len) return MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED; /* RFC 6455 5.5.1: If close payload data is given, it must be valid UTF-8 */ if (0 != reason_utf8_len) { int utf8_result = MHD_websocket_check_utf8 (reason_utf8, reason_utf8_len, NULL, NULL); if (MHD_WebSocket_UTF8Result_Valid != utf8_result) return MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR; } /* calculate length and masking */ char is_masked = MHD_websocket_encode_is_masked (ws); size_t payload_len = (MHD_WEBSOCKET_CLOSEREASON_NO_REASON != reason_code ? 2 + reason_utf8_len : 0); size_t overhead_len = MHD_websocket_encode_overhead_size (ws, payload_len); size_t total_len = overhead_len + payload_len; uint32_t mask = is_masked != 0 ? MHD_websocket_generate_mask (ws) : 0; /* allocate memory */ char *result = ws->malloc (total_len + 1); if (NULL == result) return MHD_WEBSOCKET_STATUS_MEMORY_ERROR; result [total_len] = 0; *frame = result; *frame_len = total_len; /* add the opcode */ *(result++) = 0x88; /* add the length */ *(result++) = is_masked | (char) payload_len; /* add the mask */ if (0 != is_masked) { *(result++) = ((char *) &mask)[0]; *(result++) = ((char *) &mask)[1]; *(result++) = ((char *) &mask)[2]; *(result++) = ((char *) &mask)[3]; } /* add the payload */ if (0 != reason_code) { /* close reason code */ uint16_t reason_code_nb = MHD_htons (reason_code); MHD_websocket_copy_payload (result, (const char *) &reason_code_nb, 2, mask, 0); result += 2; /* custom reason payload */ if (0 != reason_utf8_len) { MHD_websocket_copy_payload (result, reason_utf8, reason_utf8_len, mask, 2); } } return MHD_WEBSOCKET_STATUS_OK; } /** * Returns the 0x80 prefix for masked data, 0x00 otherwise */ static char MHD_websocket_encode_is_masked (struct MHD_WebSocketStream *ws) { return (ws->flags & MHD_WEBSOCKET_FLAG_MASK_SERVERCLIENT) == MHD_WEBSOCKET_FLAG_CLIENT ? 0x80 : 0x00; } /** * Calculates the size of the overhead in bytes */ static char MHD_websocket_encode_overhead_size (struct MHD_WebSocketStream *ws, size_t payload_len) { return 2 + (MHD_websocket_encode_is_masked (ws) != 0 ? 4 : 0) + (125 < payload_len ? (65535 < payload_len ? 8 : 2) : 0); } /** * Copies the payload to the destination (using mask) */ static void MHD_websocket_copy_payload (char *dst, const char *src, size_t len, uint32_t mask, unsigned long mask_offset) { if (0 != len) { if (0 == mask) { /* when the mask is zero, we can just copy the data */ memcpy (dst, src, len); } else { /* mask is used */ char mask_[4]; *((uint32_t *) mask_) = mask; for (size_t i = 0; i < len; ++i) { dst[i] = src[i] ^ mask_[(i + mask_offset) & 3]; } } } } /** * Checks a UTF-8 sequence */ static int MHD_websocket_check_utf8 (const char *buf, size_t buf_len, int *utf8_step, size_t *buf_offset) { int utf8_step_ = (NULL != utf8_step) ? *utf8_step : MHD_WEBSOCKET_UTF8STEP_NORMAL; for (size_t i = 0; i < buf_len; ++i) { unsigned char character = (unsigned char) buf[i]; switch (utf8_step_) { case MHD_WEBSOCKET_UTF8STEP_NORMAL: if ((0x00 <= character) && (0x7F >= character)) { /* RFC 3629 4: single byte UTF-8 sequence */ /* (nothing to do here) */ } else if ((0xC2 <= character) && (0xDF >= character)) { /* RFC 3629 4: two byte UTF-8 sequence */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF2TAIL_1OF1; } else if (0xE0 == character) { /* RFC 3629 4: three byte UTF-8 sequence, but the second byte must be 0xA0-0xBF */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF3TAIL1_1OF2; } else if (0xED == character) { /* RFC 3629 4: three byte UTF-8 sequence, but the second byte must be 0x80-0x9F */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF3TAIL2_1OF2; } else if (((0xE1 <= character) && (0xEC >= character)) || ((0xEE <= character) && (0xEF >= character)) ) { /* RFC 3629 4: three byte UTF-8 sequence, both tail bytes must be 0x80-0xBF */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_1OF2; } else if (0xF0 == character) { /* RFC 3629 4: four byte UTF-8 sequence, but the second byte must be 0x90-0xBF */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL1_1OF3; } else if (0xF4 == character) { /* RFC 3629 4: four byte UTF-8 sequence, but the second byte must be 0x80-0x8F */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL2_1OF3; } else if ((0xF1 <= character) && (0xF3 >= character)) { /* RFC 3629 4: four byte UTF-8 sequence, all three tail bytes must be 0x80-0xBF */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_1OF3; } else { /* RFC 3629 4: Invalid UTF-8 byte */ if (NULL != buf_offset) *buf_offset = i; return MHD_WebSocket_UTF8Result_Invalid; } break; case MHD_WEBSOCKET_UTF8STEP_UTF3TAIL1_1OF2: if ((0xA0 <= character) && (0xBF >= character)) { /* RFC 3629 4: Second byte of three byte UTF-8 sequence */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_2OF2; } else { /* RFC 3629 4: Invalid UTF-8 byte */ if (NULL != buf_offset) *buf_offset = i; return MHD_WebSocket_UTF8Result_Invalid; } break; case MHD_WEBSOCKET_UTF8STEP_UTF3TAIL2_1OF2: if ((0x80 <= character) && (0x9F >= character)) { /* RFC 3629 4: Second byte of three byte UTF-8 sequence */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_2OF2; } else { /* RFC 3629 4: Invalid UTF-8 byte */ if (NULL != buf_offset) *buf_offset = i; return MHD_WebSocket_UTF8Result_Invalid; } break; case MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_1OF2: if ((0x80 <= character) && (0xBF >= character)) { /* RFC 3629 4: Second byte of three byte UTF-8 sequence */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_2OF2; } else { /* RFC 3629 4: Invalid UTF-8 byte */ if (NULL != buf_offset) *buf_offset = i; return MHD_WebSocket_UTF8Result_Invalid; } break; case MHD_WEBSOCKET_UTF8STEP_UTF4TAIL1_1OF3: if ((0x90 <= character) && (0xBF >= character)) { /* RFC 3629 4: Second byte of four byte UTF-8 sequence */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_2OF3; } else { /* RFC 3629 4: Invalid UTF-8 byte */ if (NULL != buf_offset) *buf_offset = i; return MHD_WebSocket_UTF8Result_Invalid; } break; case MHD_WEBSOCKET_UTF8STEP_UTF4TAIL2_1OF3: if ((0x80 <= character) && (0x8F >= character)) { /* RFC 3629 4: Second byte of four byte UTF-8 sequence */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_2OF3; } else { /* RFC 3629 4: Invalid UTF-8 byte */ if (NULL != buf_offset) *buf_offset = i; return MHD_WebSocket_UTF8Result_Invalid; } break; case MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_1OF3: if ((0x80 <= character) && (0xBF >= character)) { /* RFC 3629 4: Second byte of four byte UTF-8 sequence */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_2OF3; } else { /* RFC 3629 4: Invalid UTF-8 byte */ if (NULL != buf_offset) *buf_offset = i; return MHD_WebSocket_UTF8Result_Invalid; } break; case MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_2OF3: if ((0x80 <= character) && (0xBF >= character)) { /* RFC 3629 4: Third byte of four byte UTF-8 sequence */ utf8_step_ = MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_3OF3; } else { /* RFC 3629 4: Invalid UTF-8 byte */ if (NULL != buf_offset) *buf_offset = i; return MHD_WebSocket_UTF8Result_Invalid; } break; /* RFC 3629 4: Second byte of two byte UTF-8 sequence */ case MHD_WEBSOCKET_UTF8STEP_UTF2TAIL_1OF1: /* RFC 3629 4: Third byte of three byte UTF-8 sequence */ case MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_2OF2: /* RFC 3629 4: Fourth byte of four byte UTF-8 sequence */ case MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_3OF3: if ((0x80 <= character) && (0xBF >= character)) { utf8_step_ = MHD_WEBSOCKET_UTF8STEP_NORMAL; } else { /* RFC 3629 4: Invalid UTF-8 byte */ if (NULL != buf_offset) *buf_offset = i; return MHD_WebSocket_UTF8Result_Invalid; } break; default: /* Invalid last step...? */ if (NULL != buf_offset) *buf_offset = i; return MHD_WebSocket_UTF8Result_Invalid; } } /* return values */ if (NULL != utf8_step) *utf8_step = utf8_step_; if (NULL != buf_offset) *buf_offset = buf_len; if (MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step_) { return MHD_WebSocket_UTF8Result_Incomplete; } return MHD_WebSocket_UTF8Result_Valid; } /** * Generates a mask for masking by calling * a random number generator. */ static uint32_t MHD_websocket_generate_mask (struct MHD_WebSocketStream *ws) { unsigned char mask_[4]; if (NULL != ws->rng) { size_t offset = 0; while (offset < 4) { size_t encoded = ws->rng (ws->cls_rng, mask_ + offset, 4 - offset); offset += encoded; } } else { /* this case should never happen */ mask_ [0] = 0; mask_ [1] = 0; mask_ [2] = 0; mask_ [3] = 0; } return *((uint32_t *) mask_); } /** * Calls the malloc function associated with the websocket steam */ _MHD_EXTERN void * MHD_websocket_malloc (struct MHD_WebSocketStream *ws, size_t buf_len) { if (NULL == ws) { return NULL; } return ws->malloc (buf_len); } /** * Calls the realloc function associated with the websocket steam */ _MHD_EXTERN void * MHD_websocket_realloc (struct MHD_WebSocketStream *ws, void *buf, size_t new_buf_len) { if (NULL == ws) { return NULL; } return ws->realloc (buf, new_buf_len); } /** * Calls the free function associated with the websocket steam */ _MHD_EXTERN int MHD_websocket_free (struct MHD_WebSocketStream *ws, void *buf) { if (NULL == ws) { return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR; } ws->free (buf); return MHD_WEBSOCKET_STATUS_OK; } /** * Converts a 16 bit value into network byte order (MSB first) * in dependence of the host system */ static uint16_t MHD_htons (uint16_t value) { uint16_t endian = 0x0001; if (((char *) &endian)[0] == 0x01) { /* least significant byte first */ ((char *) &endian)[0] = ((char *) &value)[1]; ((char *) &endian)[1] = ((char *) &value)[0]; return endian; } else { /* most significant byte first */ return value; } } /** * Converts a 64 bit value into network byte order (MSB first) * in dependence of the host system */ static uint64_t MHD_htonll (uint64_t value) { uint64_t endian = 0x0000000000000001; if (((char *) &endian)[0] == 0x01) { /* least significant byte first */ ((char *) &endian)[0] = ((char *) &value)[7]; ((char *) &endian)[1] = ((char *) &value)[6]; ((char *) &endian)[2] = ((char *) &value)[5]; ((char *) &endian)[3] = ((char *) &value)[4]; ((char *) &endian)[4] = ((char *) &value)[3]; ((char *) &endian)[5] = ((char *) &value)[2]; ((char *) &endian)[6] = ((char *) &value)[1]; ((char *) &endian)[7] = ((char *) &value)[0]; return endian; } else { /* most significant byte first */ return value; } } libmicrohttpd-1.0.1/src/microhttpd_ws/Makefile.in0000644000175000017500000013211414566140141015564 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ check_PROGRAMS = test_websocket$(EXEEXT) subdir = src/microhttpd_ws ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/MHD_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = libmicrohttpd_ws_la_DEPENDENCIES = $(am__DEPENDENCIES_1) am_libmicrohttpd_ws_la_OBJECTS = libmicrohttpd_ws_la-sha1.lo \ libmicrohttpd_ws_la-mhd_websocket.lo libmicrohttpd_ws_la_OBJECTS = $(am_libmicrohttpd_ws_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libmicrohttpd_ws_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(libmicrohttpd_ws_la_CFLAGS) $(CFLAGS) \ $(libmicrohttpd_ws_la_LDFLAGS) $(LDFLAGS) -o $@ am_test_websocket_OBJECTS = test_websocket.$(OBJEXT) test_websocket_OBJECTS = $(am_test_websocket_OBJECTS) test_websocket_DEPENDENCIES = \ $(top_builddir)/src/microhttpd_ws/libmicrohttpd_ws.la \ $(top_builddir)/src/microhttpd/libmicrohttpd.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = \ ./$(DEPDIR)/libmicrohttpd_ws_la-mhd_websocket.Plo \ ./$(DEPDIR)/libmicrohttpd_ws_la-sha1.Plo \ ./$(DEPDIR)/test_websocket.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libmicrohttpd_ws_la_SOURCES) $(test_websocket_SOURCES) DIST_SOURCES = $(libmicrohttpd_ws_la_SOURCES) \ $(test_websocket_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac DATA = $(noinst_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ check recheck distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' RECHECK_LOGS = $(TEST_LOGS) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in \ $(top_srcdir)/build-aux/depcomp \ $(top_srcdir)/build-aux/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # This Makefile.am is in the public domain AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/microhttpd AM_CFLAGS = $(HIDDEN_VISIBILITY_CFLAGS) noinst_DATA = MOSTLYCLEANFILES = SUBDIRS = . lib_LTLIBRARIES = \ libmicrohttpd_ws.la libmicrohttpd_ws_la_SOURCES = \ sha1.c sha1.h \ mhd_websocket.c libmicrohttpd_ws_la_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) \ -DBUILDING_MHD_LIB=1 libmicrohttpd_ws_la_CFLAGS = \ $(AM_CFLAGS) $(MHD_LIB_CFLAGS) libmicrohttpd_ws_la_LDFLAGS = \ $(MHD_LIB_LDFLAGS) \ $(W32_MHD_LIB_LDFLAGS) \ -version-info 0:0:0 libmicrohttpd_ws_la_LIBADD = \ $(MHD_LIBDEPS) TESTS = $(check_PROGRAMS) test_websocket_SOURCES = \ test_websocket.c test_websocket_LDADD = \ $(top_builddir)/src/microhttpd_ws/libmicrohttpd_ws.la \ $(top_builddir)/src/microhttpd/libmicrohttpd.la all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/microhttpd_ws/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/microhttpd_ws/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libmicrohttpd_ws.la: $(libmicrohttpd_ws_la_OBJECTS) $(libmicrohttpd_ws_la_DEPENDENCIES) $(EXTRA_libmicrohttpd_ws_la_DEPENDENCIES) $(AM_V_CCLD)$(libmicrohttpd_ws_la_LINK) -rpath $(libdir) $(libmicrohttpd_ws_la_OBJECTS) $(libmicrohttpd_ws_la_LIBADD) $(LIBS) test_websocket$(EXEEXT): $(test_websocket_OBJECTS) $(test_websocket_DEPENDENCIES) $(EXTRA_test_websocket_DEPENDENCIES) @rm -f test_websocket$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_websocket_OBJECTS) $(test_websocket_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_ws_la-mhd_websocket.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmicrohttpd_ws_la-sha1.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_websocket.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< libmicrohttpd_ws_la-sha1.lo: sha1.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_ws_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_ws_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_ws_la-sha1.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_ws_la-sha1.Tpo -c -o libmicrohttpd_ws_la-sha1.lo `test -f 'sha1.c' || echo '$(srcdir)/'`sha1.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_ws_la-sha1.Tpo $(DEPDIR)/libmicrohttpd_ws_la-sha1.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sha1.c' object='libmicrohttpd_ws_la-sha1.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_ws_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_ws_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_ws_la-sha1.lo `test -f 'sha1.c' || echo '$(srcdir)/'`sha1.c libmicrohttpd_ws_la-mhd_websocket.lo: mhd_websocket.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_ws_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_ws_la_CFLAGS) $(CFLAGS) -MT libmicrohttpd_ws_la-mhd_websocket.lo -MD -MP -MF $(DEPDIR)/libmicrohttpd_ws_la-mhd_websocket.Tpo -c -o libmicrohttpd_ws_la-mhd_websocket.lo `test -f 'mhd_websocket.c' || echo '$(srcdir)/'`mhd_websocket.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmicrohttpd_ws_la-mhd_websocket.Tpo $(DEPDIR)/libmicrohttpd_ws_la-mhd_websocket.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mhd_websocket.c' object='libmicrohttpd_ws_la-mhd_websocket.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_ws_la_CPPFLAGS) $(CPPFLAGS) $(libmicrohttpd_ws_la_CFLAGS) $(CFLAGS) -c -o libmicrohttpd_ws_la-mhd_websocket.lo `test -f 'mhd_websocket.c' || echo '$(srcdir)/'`mhd_websocket.c mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: $(check_PROGRAMS) @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? test_websocket.log: test_websocket$(EXEEXT) @p='test_websocket$(EXEEXT)'; \ b='test_websocket'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive all-am: Makefile $(LTLIBRARIES) $(DATA) install-checkPROGRAMS: install-libLTLIBRARIES installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f ./$(DEPDIR)/libmicrohttpd_ws_la-mhd_websocket.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_ws_la-sha1.Plo -rm -f ./$(DEPDIR)/test_websocket.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/libmicrohttpd_ws_la-mhd_websocket.Plo -rm -f ./$(DEPDIR)/libmicrohttpd_ws_la-sha1.Plo -rm -f ./$(DEPDIR)/test_websocket.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: $(am__recursive_targets) check-am install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--depfiles check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ recheck tags tags-am uninstall uninstall-am \ uninstall-libLTLIBRARIES .PRECIOUS: Makefile $(top_builddir)/src/microhttpd/libmicrohttpd.la: $(top_builddir)/src/microhttpd/Makefile @echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la'; \ $(am__cd) $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.la # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/src/microhttpd_ws/sha1.h0000644000175000017500000000526714417460232014535 /* This file is part of libmicrohttpd Copyright (C) 2019-2021 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ /** * @file microhttpd/sha1.h * @brief Calculation of SHA-1 digest * @author Karlson2k (Evgeny Grin) */ #ifndef MHD_SHA1_H #define MHD_SHA1_H 1 #include "mhd_options.h" #include #ifdef HAVE_STDDEF_H #include /* for size_t */ #endif /* HAVE_STDDEF_H */ /** * SHA-1 digest is kept internally as 5 32-bit words. */ #define _SHA1_DIGEST_LENGTH 5 /** * Number of bits in single SHA-1 word */ #define SHA1_WORD_SIZE_BITS 32 /** * Number of bytes in single SHA-1 word */ #define SHA1_BYTES_IN_WORD (SHA1_WORD_SIZE_BITS / 8) /** * Size of SHA-1 digest in bytes */ #define SHA1_DIGEST_SIZE (_SHA1_DIGEST_LENGTH * SHA1_BYTES_IN_WORD) /** * Size of SHA-1 digest string in chars including termination NUL */ #define SHA1_DIGEST_STRING_SIZE ((SHA1_DIGEST_SIZE) * 2 + 1) /** * Size of single processing block in bits */ #define SHA1_BLOCK_SIZE_BITS 512 /** * Size of single processing block in bytes */ #define SHA1_BLOCK_SIZE (SHA1_BLOCK_SIZE_BITS / 8) struct sha1_ctx { uint32_t H[_SHA1_DIGEST_LENGTH]; /**< Intermediate hash value / digest at end of calculation */ uint8_t buffer[SHA1_BLOCK_SIZE]; /**< SHA256 input data buffer */ uint64_t count; /**< number of bytes, mod 2^64 */ }; /** * Initialise structure for SHA-1 calculation. * * @param ctx must be a `struct sha1_ctx *` */ void MHD_SHA1_init (void *ctx_); /** * Process portion of bytes. * * @param ctx_ must be a `struct sha1_ctx *` * @param data bytes to add to hash * @param length number of bytes in @a data */ void MHD_SHA1_update (void *ctx_, const uint8_t *data, size_t length); /** * Finalise SHA-1 calculation, return digest. * * @param ctx_ must be a `struct sha1_ctx *` * @param[out] digest set to the hash, must be #SHA1_DIGEST_SIZE bytes */ void MHD_SHA1_finish (void *ctx_, uint8_t digest[SHA1_DIGEST_SIZE]); #endif /* MHD_SHA1_H */ libmicrohttpd-1.0.1/README0000644000175000017500000000657714441373360010742 About ===== GNU libmicrohttpd is a GNU package offering a C library that provides a compact API and implementation of an HTTP 1.1 web server (HTTP 1.0 is also supported). GNU libmicrohttpd only implements the HTTP 1.1 protocol. The main application must still provide the application logic to generate the content. GNU libmicrohttpd is dual-licensed under the GNU Lesser General Public License (LGPLv2.1+) and the eCos License. See COPYING for details. Joining GNU =========== This is a GNU program, developed by the GNU Project and part of the GNU Operating System. If you are the author of an awesome program and want to join us in writing Free Software, please consider making it an official GNU program and become a GNU maintainer. You can find instructions on how to do so at http://www.gnu.org/help/evaluation. We are looking forward to hacking with you! Installation ============ See INSTALL for generic installation instructions. If you are using Git, run "./bootstrap" to create configure. In order to run the testcases, you need a recent version of libcurl. libcurl is not required if you just want to install the library. Especially for development, do use the MHD_USE_ERROR_LOG option to get error messages. Configure options ================= If you are concerned about space, you should set "CFLAGS" to "-Os -fomit-frame-pointer" to have gcc generate tight code. You can use the following options to disable certain MHD features: --disable-https: no HTTPS / TLS / SSL support (significant reduction) --disable-messages: no error messages (they take space!) --disable-postprocessor: no MHD_PostProcessor API --disable-dauth: no digest authentication API --disable-epoll: no support for epoll, even on Linux The resulting binary should be about 30-40k depending on the platform. Portability =========== The latest version of libmicrohttpd will try to avoid SIGPIPE on its sockets. This should work on OS X, Linux and recent BSD systems (at least). On other systems that may trigger a SIGPIPE on send/recv, the main application should install a signal handler to handle SIGPIPE. libmicrohttpd should work well on GNU/Linux, W32, FreeBSD, Darwin, NetBSD, OpenBSD, Solaris/OpenIndiana, and z/OS. Note that HTTPS is not supported on z/OS (yet). We also have reports of users using it on vxWorks. Development Status ================== This is a beta release for libmicrohttpd. Before declaring the library stable, we should have testcases for the following features: - HTTP/1.1 pipelining (need to figure out how to ensure curl pipelines -- and it seems libcurl has issues with pipelining, see http://curl.haxx.se/mail/lib-2007-12/0248.html) - resource limit enforcement - client queuing early response, suppressing 100 CONTINUE - chunked encoding to validate handling of footers - more testing for SSL support - MHD basic and digest authentication In particular, the following functions are not covered by 'make check': - mhd_panic_std (mhd_panic.c); special case (abort) - parse_options (daemon.c) - MHD_get_version (daemon.c) Note that the working library is in src/microhttpd/ with the API in src/include/microhttpd.h. An *experimental* (read: not yet working at all) newer implementation is in src/lib/, with the new API in src/include/microhttpd2.h. The experimental code will need MUCH more testing and development, you are strongly advised to stick to microhttpd.h unless you are a MHD developer! libmicrohttpd-1.0.1/configure.ac0000644000175000017500000060144414566137250012346 # This file is part of libmicrohttpd. # (C) 2006-2021 Christian Grothoff (and other contributing authors) # (C) 2014-2024 Evgeny Grin (Karlson2k) # # libmicrohttpd is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your # option) any later version. # # libmicrohttpd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with libmicrohttpd; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. # # # Process this file with autoconf to produce a configure script. # # AC_PREREQ([2.64]) LT_PREREQ([2.4.0]) AC_INIT([GNU libmicrohttpd],[1.0.1],[libmicrohttpd@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) MHD_AUX_DIR='build-aux' # Must be set to the same value as in the previous line AC_CONFIG_HEADERS([MHD_config.h]) AC_CONFIG_MACRO_DIR([m4]) m4_pattern_forbid([^_?MHD_[A-Z_]+_CC_])dnl LIB_VERSION_CURRENT=74 LIB_VERSION_REVISION=1 LIB_VERSION_AGE=62 AC_SUBST([LIB_VERSION_CURRENT]) AC_SUBST([LIB_VERSION_REVISION]) AC_SUBST([LIB_VERSION_AGE]) PACKAGE_VERSION_MAJOR='m4_car(m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))' PACKAGE_VERSION_MINOR='m4_argn(2, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))' PACKAGE_VERSION_SUBMINOR='m4_argn(3, m4_unquote(m4_split(AC_PACKAGE_VERSION, [\.])))' AS_VAR_ARITH([MHD_W32_DLL_SUFF],[[$LIB_VERSION_CURRENT - $LIB_VERSION_AGE]]) AC_SUBST([PACKAGE_VERSION_MAJOR]) AC_SUBST([PACKAGE_VERSION_MINOR]) AC_SUBST([PACKAGE_VERSION_SUBMINOR]) AC_SUBST([MHD_W32_DLL_SUFF]) AC_CONFIG_FILES([src/microhttpd/microhttpd_dll_res.rc]) MHD_LIB_CPPFLAGS="" MHD_LIB_CFLAGS="" MHD_LIB_LDFLAGS="" MHD_LIBDEPS="" # for pkg-config MHD_REQ_PRIVATE='' MHD_LIBDEPS_PKGCFG='' AS_IF([test -z "$CC" && test -z "$CPP"], [ AC_MSG_CHECKING([[whether z/OS special settings are required]]) AS_IF([test `uname -s` = "OS/390"], [ # configure binaries for z/OS AS_IF([test -z "$CC"], [CC=`pwd`"/contrib/xcc" chmod +x $CC || true]) AS_IF([test -z "$CPP"], CPP="c89 -E") AC_MSG_RESULT([[yes]]) ], [AC_MSG_RESULT([[no]])] ) ]) AC_MSG_CHECKING([for build type]) AC_ARG_ENABLE([build-type], [AS_HELP_STRING([[--enable-build-type=TYPE]], [enable build TYPE, a set of configuration parameters; individual settings ] [(asserts, sanitizers, compiler and linker flags) can be overridden by ] [additional configure parameters (debug, debugger, neutral, release, release-compact, ] [release-hardened) [neutral]])], [], [enable_build_type=neutral]) AS_IF([test "x${enable_build_type}" = "x"], [enable_build_type="neutral"]) AS_VAR_IF([enable_build_type], ["no"], [enable_build_type="neutral"]) AS_VAR_IF([enable_build_type], ["yes"], [AC_MSG_ERROR([[Missing TYPE for --enable-build-type=]])]) AS_CASE([${enable_build_type}], [debug], [AC_MSG_RESULT([debug. Defaults: enable asserts, sanitizers (if any supported), debug information, compiler optimisation for debugging])], [debugger], [AC_MSG_RESULT([debugger. Defaults: enable asserts, disable sanitizers, debug information, no compiler optimisation, static lib])], [neutral], [AC_MSG_RESULT([neutral. Defaults: use only user-specified compiler and linker flags])], [release], [AC_MSG_RESULT([release. Defaults: disable asserts, enable compiler optimisations])], [release-compact], [AC_MSG_RESULT([release-compact. Defaults: disable asserts, enable compiler optimisations for size, enable compact code])], [release-hardened], [AC_MSG_RESULT([release-hardened. Defaults: disable asserts, enable compiler optimisations, enable linker and compiler hardening])], [AC_MSG_ERROR([[Unknown build type: ${enable_build_type}]])] ) AS_VAR_IF([enable_build_type], ["neutral"], [:], [ # For all non-neutral build types do not use automatic "-g -O2" for CFLAGS AS_IF([test -z "${CFLAGS}"], [CFLAGS=""]) ] ) AS_VAR_IF([enable_build_type], ["debugger"], [ # Build only static version unless something else is specified by the user AS_IF([test -z "${enable_static}" || test "x${enable_static}" = "xyes"], [ AS_IF([test -z "${enable_shared}"], [ enable_shared="no" enable_static="yes" ] ) ], [ AS_CASE([${enable_static}],[*libmicrohttpd*], [AS_IF([test -z "${enable_shared}"], [enable_shared="no"])], ) ] ) ] ) AS_CASE([${enable_build_type}],[debug|debugger], [ AS_IF([test -z "${enable_silent_rules}"], [ enable_silent_rules="yes" ])] ) AM_INIT_AUTOMAKE([gnu] [check-news] [filename-length-max=99] [tar-v7] [silent-rules] [subdir-objects]) # Checks for programs. AC_PROG_AWK AC_PROG_GREP AC_PROG_FGREP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_CANONICAL_HOST m4_version_prereq([2.70], [ # Find C compiler and compiler options to support # the latest C standard (C11). Fallback to C99 and C89 # if later C versions are not supported. AC_PROG_CC ], [ # Find C compiler and compiler options to support # the latest C standard (C99). Fallback to C89 # if later C versions are not supported. AC_PROG_CC_STDC ] ) # Workaround for libgcrypt AS_IF([[test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x"]], [[SYSROOT="$lt_sysroot"]]) user_CFLAGS="$CFLAGS" user_LDFLAGS="$LDFLAGS" user_CPPFLAGS="$CPPFLAGS" CFLAGS_ac="" LDFLAGS_ac="" CPPFLAGS_ac="" MHD_SYS_EXT([CPPFLAGS_ac]) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" LT_INIT([win32-dll]) LT_LANG([Windows Resource]) AC_ARG_ENABLE([compact-code], [AS_HELP_STRING([[--enable-compact-code]], [enable use of a reduced size version of the code, resulting in smaller ] [binaries with a slight performance hit [auto]])], [], [enable_compact_code=auto]) AS_IF([test "x${enable_compact_code}" = "x"], [enable_compact_code="auto"]) AH_TEMPLATE([[MHD_FAVOR_SMALL_CODE]], [Define to '1' to use compact code version]) AH_TEMPLATE([[MHD_FAVOR_FAST_CODE]], [Define to '1' to use fast (and larger) code version]) AS_UNSET([compact_code_MSG]) AS_CASE([${enable_compact_code}], [auto], [ # Parameter not set. # Check preprocessor macros AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE], [ enable_compact_code="yes" compact_code_MSG="enabled by preprocessor macro" ], [],[/* no includes */] ) AC_CHECK_DECL([MHD_FAVOR_FAST_CODE], [ AS_VAR_IF([enable_compact_code],["yes"], [AC_MSG_ERROR([Both MHD_FAVOR_SMALL_CODE and MHD_FAVOR_FAST_CODE macros are defined])] ) enable_compact_code="no" compact_code_MSG="set by preprocessor macro" ],[],[/* no includes */] ) AS_VAR_IF([enable_compact_code], ["auto"], [ # No preference by preprocessor macros AC_CACHE_CHECK([whether compiler is configured to optimize for size], [mhd_cv_cc_optim_size], [ AC_COMPILE_IFELSE( [ AC_LANG_PROGRAM([[ #ifndef __OPTIMIZE_SIZE__ #error Looks like compiler does not optimize for size choke me now #endif ]],[]) ], [mhd_cv_cc_optim_size="yes"],[mhd_cv_cc_optim_size="no"] ) ] ) AS_VAR_IF([mhd_cv_cc_optim_size], ["yes"], [ enable_compact_code="yes" compact_code_MSG="enabled automatically as compiler optimizes for size" AC_DEFINE([MHD_FAVOR_SMALL_CODE],[1]) ] ) ] ) AS_VAR_IF([enable_compact_code], ["auto"], [ # No preference by preprocessor macros and compiler flags AS_CASE([${enable_build_type}],[*-compact], [ enable_compact_code="yes" compact_code_MSG="enabled by --enable-build-type=${enable_build_type}" AC_DEFINE([MHD_FAVOR_SMALL_CODE],[1]) ] ) ] ) AS_VAR_IF([enable_compact_code], ["auto"], [ # No preference enable_compact_code="no" compact_code_MSG="by default" AC_DEFINE([MHD_FAVOR_FAST_CODE],[1]) ] ) ], [yes], [ compact_code_MSG="enabled by configure parameter" AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE], [], [AC_DEFINE([MHD_FAVOR_SMALL_CODE],[1])],[/* no includes */] ) AC_CHECK_DECL([MHD_FAVOR_FAST_CODE], [AC_MSG_ERROR([MHD_FAVOR_FAST_CODE macro is defined, --enable-compact-code could not be used]) ], [],[/* no includes */] ) ], [no], [ compact_code_MSG="disabled by configure parameter" AC_CHECK_DECL([MHD_FAVOR_FAST_CODE], [], [AC_DEFINE([MHD_FAVOR_FAST_CODE],[1])],[/* no includes */] ) AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE], [AC_MSG_ERROR([MHD_FAVOR_SMALL_CODE macro is defined, --disable-compact-code could not be used]) ], [],[/* no includes */] ) ], [AC_MSG_ERROR([[Unknown parameter value: --enable-compact-code=${enable_compact_code}]])] ) AC_MSG_CHECKING([whether to use a reduced size version of the code]) AC_MSG_RESULT([${enable_compact_code} (${compact_code_MSG})]) CFLAGS="${user_CFLAGS}" # Compiler options to always enable (if supported) MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-fno-strict-aliasing], [-qnoansialias]) # '-qlonglong' is XLC option for C89, not used with C99 or later MHD_CHECK_ADD_CC_CFLAG([-qlonglong], [CFLAGS_ac]) # Set basic optimisation flags AS_VAR_IF([enable_build_type],["neutral"],[], [ # Any non-neutral build types AC_CACHE_CHECK([whether workarounds for clang or clang-based compiler are required], [mhd_cv_cc_clang_based], [ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #if ! defined(__clang__) && ! defined(__llvm__) #error Compiler is not clang-based choke me now #endif ]] ) ], [mhd_cv_cc_clang_based="yes"],[mhd_cv_cc_clang_based="no"] ) ] ) ] ) AS_CASE([${enable_build_type}],[debug|debugger], [ # Debug build or build for walking with debugger CFLAGS="${user_CFLAGS}" AS_VAR_IF([enable_build_type],["debug"], [ # Clang has ASAN (pointer compare) broken when '-Og' optimisations are used AS_IF([test "x${enable_sanitizers}" != "xno" && test "x${mhd_cv_cc_clang_based}" = "xyes"], [MHD_CHECK_ADD_CC_CFLAG([-O0], [CFLAGS_ac])], [MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Og], [-O0])] ) ], [MHD_CHECK_ADD_CC_CFLAG([-O0], [CFLAGS_ac])] ) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ] ) AS_CASE([${enable_build_type}],[release|release-*], [ # All release types AS_VAR_IF([enable_build_type],["release-compact"], [ CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[], [AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[], [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_SMALL_CODE=1])], [/* no includes */])],[/* no includes */]) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${user_CFLAGS}" MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Oz], [-Os], [-O]) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ], [ # All non-compact release types CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[], [AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[], [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_FAST_CODE=1])], [/* no includes */])],[/* no includes */]) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${user_CFLAGS}" MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-O2], [-O]) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ] ) ] ) AS_VAR_IF([enable_build_type],["neutral"],[], [ # Any non-neutral build types MHD_CHECK_ADD_CC_CFLAGS([-Wall -Wnull-dereference], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wdeclaration-after-statement -Wimplicit -Wnested-externs], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wredundant-decls -Wtrampolines -Wunsafe-loop-optimizations], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wpoison-system-directories], [CFLAGS_ac]) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${user_LDFLAGS}" MHD_CHECK_ADD_CC_LDFLAG([-Wl,--warn-common], [LDFLAGS_ac]) LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) AS_CASE([${enable_build_type}],[debug|debugger], [ # Debug build or build for walking with debugger CFLAGS="${user_CFLAGS}" MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-ggdb3], [-g3], [-ggdb], [-g]) MHD_CHECK_ADD_CC_CFLAGS([-Wextra -Wdouble-promotion], [CFLAGS_ac]) MHD_FIND_ADD_CC_CFLAG_IFELSE( [ # clang produce warning when string pointer is used as a format specifier for v*printf() function AS_VAR_IF([mhd_cv_cc_clang_based],["yes"],[MHD_CHECK_ADD_CC_CFLAG([-Wno-format-nonliteral], [CFLAGS_ac])]) ],[], [CFLAGS_ac], [-Wformat=2], [-Wformat] ) MHD_CHECK_ADD_CC_CFLAGS([-Wformat-overflow -Wformat-truncation -Wformat-security -Wformat-signedness], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wmissing-include-dirs -Wshift-overflow=2 -Wstringop-overflow=4 -Walloc-zero], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wshadow -Wpointer-arith], [CFLAGS_ac]) MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wshadow-all], [-Wshadow]) MHD_CHECK_ADD_CC_CFLAGS([-Wbad-function-cast -Wcast-qual -Wwrite-strings -Wconversion], [CFLAGS_ac]) MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wcast-align=strict], [-Wcast-align]) MHD_CHECK_ADD_CC_CFLAGS([-Wjump-misses-init -Wlogical-op -Waggregate-return -Wstrict-prototypes], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wold-style-definition -Wmissing-declarations -Wmissing-prototypes], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wuninitialized -Winit-self -Wshift-negative-value -Wswitch-enum], [CFLAGS_ac]) MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wstrict-overflow=4], [-Wstrict-overflow]) MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wnormalized=nfkc], [-Wnormalized]) MHD_CHECK_ADD_CC_CFLAGS([-Walloca -Wbidi-chars=any -Warray-bounds -Wpacked -Wvariadic-macros], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wundef], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wanon-enum-enum-conversion -Warray-bounds-pointer-arithmetic -Wassign-enum], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wbit-int-extension -Wbitfield-enum-conversion -Wparentheses -Wbool-operation], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wcast-function-type -Wcomma -Wcomment -Wcompound-token-split], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wconditional-uninitialized -Wdeprecated], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wdocumentation-pedantic -Wempty-init-stmt -Wenum-conversion -Wexpansion-to-defined], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wflexible-array-extensions -Wloop-analysis -Wformat-pedantic], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wformat-type-confusion -Wfour-char-constants], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wgcc-compat -Wgnu-anonymous-struct -Wgnu-compound-literal-initializer], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-conditional-omitted-operand -Wgnu-designator -Wgnu-empty-initializer], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-empty-struct -Wgnu-flexible-array-initializer -Wgnu-folding-constant], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-null-pointer-arithmetic -Wgnu-pointer-arith -Wgnu-redeclared-enum], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wgnu-union-cast -Wgnu-variable-sized-type-not-at-end -Widiomatic-parentheses], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wmissing-noreturn -Wmissing-variable-declarations -Wnested-anon-types], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wnewline-eof -Wover-aligned -Wredundant-parens], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wshift-sign-overflow -Wtautological-compare -Wunaligned-access], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wunused -Wzero-as-null-pointer-constant -Wzero-length-array], [CFLAGS_ac]) MHD_CHECK_CC_CFLAG([-Wused-but-marked-unused],[CFLAGS_ac], [ AC_CACHE_CHECK([whether $[]CC -Wused-but-marked-unused works with system headers], [mhd_cv_wused_but_marked_unused_sys_header], [ SAVE_ac_c_werror_flag="$ac_c_werror_flag" ac_c_werror_flag="yes" CFLAGS="${CFLAGS_ac} -Wused-but-marked-unused ${user_CFLAGS}" AC_COMPILE_IFELSE( [ AC_LANG_SOURCE([[ #include int main(void) { char buf[16]; return (int) snprintf(buf, 16, "test"); } ]] ) ], [mhd_cv_wused_but_marked_unused_sys_header="yes"], [mhd_cv_wused_but_marked_unused_sys_header="no"] ) ac_c_werror_flag="$SAVE_ac_c_werror_flag" ] ) AS_VAR_IF([mhd_cv_wused_but_marked_unused_sys_header],["yes"], [MHD_APPEND_FLAG_TO_VAR([CFLAGS_ac],[-Wused-but-marked-unused])] ) ] ) # # Removed flags: # # -Wdisabled-macro-expansion - warns about macros from system headers CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${user_LDFLAGS}" MHD_CHECK_ADD_CC_LDFLAG([-Wl,--enable-long-section-names], [LDFLAGS_ac]) LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) AS_CASE([${enable_build_type}],[release|release-*], [ # All release types CFLAGS="${user_CFLAGS}" AS_VAR_IF([enable_build_type],["release-compact"], [], [ # All non-compact release types MHD_CHECK_ADD_CC_CFLAGS([-fsched-pressure -fira-loop-pressure -fmerge-all-constants], [CFLAGS_ac]) # These flags may improve size, recheck with LTO and linker garbage collection MHD_CHECK_ADD_CC_CFLAGS([-ftree-partial-pre -fgcse-after-reload -fipa-pta], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-fisolate-erroneous-paths-attribute -ffinite-loops -floop-nest-optimize], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-fpredictive-commoning -frename-registers], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-ftree-loop-distribute-patterns -fpeel-loops -fsplit-loops -ftree-vectorize], [CFLAGS_ac]) ] ) AS_VAR_IF([enable_build_type],["release-hardened"], [ MHD_CHECK_ADD_CC_CFLAGS([-Wformat-security -Wstack-protector], [CFLAGS_ac]) MHD_CHECK_ADD_CC_CFLAGS([-Wuninitialized -Winit-self -Walloc-zero -Wbidi-chars=any], [CFLAGS_ac]) ] ) AS_VAR_IF([enable_build_type],["release"], [ # Flags are not suitable for 'compact' and for 'hardened' MHD_CHECK_ADD_CC_CFLAGS([-ffast-math -fno-trapping-math], [CFLAGS_ac]) ] ) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" # W32-specific LDFLAGS="${user_LDFLAGS}" MHD_CHECK_ADD_CC_LDFLAG([-Wl,--disable-long-section-names], [LDFLAGS_ac]) LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" # Additional flags are checked and added at the end of 'configure' # Check for headers that are ALWAYS required AC_CHECK_HEADERS_ONCE([stdio.h string.h stdint.h errno.h limits.h fcntl.h], [], [AC_MSG_ERROR([Compiling libmicrohttpd requires standard POSIX headers files])], [AC_INCLUDES_DEFAULT]) # Check for basic optional headers AC_CHECK_HEADERS([stddef.h stdlib.h inttypes.h sys/types.h sys/stat.h unistd.h \ sys/uio.h], [], [], [AC_INCLUDES_DEFAULT]) # Check for clock-specific optional headers AC_CHECK_HEADERS([sys/time.h time.h], [], [], [AC_INCLUDES_DEFAULT]) # Check for system information and parameters optional headers AC_CHECK_HEADERS([endian.h machine/endian.h sys/endian.h sys/byteorder.h \ sys/machine.h machine/param.h sys/param.h sys/isa_defs.h \ sys/ioctl.h], [], [], [AC_INCLUDES_DEFAULT]) # Check for network and sockets optional headers AC_CHECK_HEADERS([sys/socket.h sys/select.h netinet/in_systm.h netinet/in.h \ arpa/inet.h netinet/ip.h netinet/tcp.h net/if.h \ netdb.h sockLib.h inetLib.h], [], [], [AC_INCLUDES_DEFAULT [ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_INTTYPES_H #include #endif /* HAVE_INTTYPES_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ ]] ) # Check for other optional headers AC_CHECK_HEADERS([sys/msg.h sys/mman.h signal.h], [], [], [AC_INCLUDES_DEFAULT]) AC_CHECK_HEADER([[search.h]], [ MHD_CHECK_LINK_RUN([[for proper tsearch(), tfind() and tdelete()]],[[mhd_cv_sys_tsearch_usable]], [ AS_CASE([$host_os], [openbsd*], [[ # Some OpenBSD versions have wrong return value for tdelete() mhd_cv_sys_tsearch_usable='assuming no' ]], [netbsd*], [[ # NetBSD had leaked root node for years mhd_cv_sys_tsearch_usable='assuming no' ]], [[mhd_cv_sys_tsearch_usable='assuming yes']] ) ], [ AC_LANG_SOURCE( [[ #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include static int cmp_func(const void *p1, const void *p2) { return (*((const int *)p1)) - (*((const int *)p2)); } int main(void) { int ret = 0; void *root_ptr = NULL; int element1 = 1; int **element_ptr_ptr1; int **element_ptr_ptr2; element_ptr_ptr1 = (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func); if (NULL == element_ptr_ptr1) { fprintf (stderr, "NULL pointer has been returned when tsearch() called for the first time.\n"); return ++ret; } if (*element_ptr_ptr1 != &element1) { fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the first time.\n"); return ++ret; } if (NULL == root_ptr) { fprintf (stderr, "Root pointer has not been set by tsearch().\n"); return ++ret; } element_ptr_ptr2 = (int **) tsearch ((void*) &element1, &root_ptr, &cmp_func); if (NULL == element_ptr_ptr2) { fprintf (stderr, "NULL pointer has been returned when tsearch() called for the second time.\n"); return ++ret; } if (*element_ptr_ptr2 != &element1) { fprintf (stderr, "Wrong pointer has been returned when tsearch() called for the second time.\n"); ++ret; } if (element_ptr_ptr2 != element_ptr_ptr1) { fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n"); ++ret; } element_ptr_ptr2 = (int **) tfind ((void*) &element1, &root_ptr, &cmp_func); if (NULL == element_ptr_ptr2) { fprintf (stderr, "NULL pointer has been returned by tfind().\n"); ++ret; } if (*element_ptr_ptr2 != &element1) { fprintf (stderr, "Wrong pointer has been returned when by tfind().\n"); ++ret; } if (element_ptr_ptr2 != element_ptr_ptr1) { fprintf (stderr, "Wrong element has been returned when tsearch() called for the second time.\n"); ++ret; } element_ptr_ptr1 = (int **) tdelete ((void*) &element1, &root_ptr, &cmp_func); if (NULL == element_ptr_ptr1) { fprintf (stderr, "NULL pointer has been returned by tdelete().\n"); ++ret; } if (NULL != root_ptr) { fprintf (stderr, "Root pointer has not been set to NULL by tdelete().\n"); ++ret; } return ret; } ]] ) ], [AC_DEFINE([[MHD_USE_SYS_TSEARCH]], [[1]], [Define to 1 if you have properly working tsearch(), tfind() and tdelete() functions.])] ) ], [], [AC_INCLUDES_DEFAULT] ) AM_CONDITIONAL([MHD_USE_SYS_TSEARCH], [[test "x$mhd_cv_sys_tsearch_usable" = "xyes" || test "x$mhd_cv_sys_tsearch_usable" = "xassuming yes"]]) # Optional headers used for tests AC_CHECK_HEADERS([sys/sysctl.h netinet/ip_icmp.h netinet/icmp_var.h], [], [], [[ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ ]] ) AC_ARG_ENABLE([compiler-hardening], [AS_HELP_STRING([--enable-compiler-hardening], [enable compiler security checks])], [], [AS_CASE([${enable_build_type}],[*-hardened], [enable_compiler_hardening='yes'],[enable_compiler_hardening='no'])] ) AS_VAR_IF([enable_compiler_hardening],["yes"], [ CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" AC_CHECK_DECL([_FORTIFY_SOURCE], [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-U_FORTIFY_SOURCE])], [],[/* no includes */]) MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-D_FORTIFY_SOURCE=2]) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${user_CFLAGS}" MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac],[-fstack-protector-strong],[-fstack-protector-all],[-fstack-protector]) MHD_CHECK_ADD_CC_CFLAGS([-fstack-clash-protection],[CFLAGS_ac]) MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac],[-ftrivial-auto-var-init=pattern],[-ftrivial-auto-var-init=zero]) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" AS_IF([test "x${enable_static}" = "xyes" && test "x${pic_mode}" != "xyes"], [ # PIE static lib can be used within non-PIE application, but # PIE static lib cannot be used in non-PIE shared lib. Let's assume # that static lib will not be used in shared lib # All "pie" flags will be used automatically by libtool only # for static library objects. CFLAGS="${user_CFLAGS}" # Perform tests here with "-pie" enabled LDFLAGS="${LDFLAGS_ac} -pie ${user_LDFLAGS}" MHD_CHECK_ADD_CC_CFLAG([-fPIE],[CFLAGS_ac], [ MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie]) ], [ MHD_CHECK_ADD_CC_CFLAG([-fpie],[CFLAGS_ac], [ MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie]) ] ) ] ) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) # Linker hardening options # Currently these options are ELF specific, they don't work on Darwin and W32 AC_ARG_ENABLE([linker-hardening], [AS_HELP_STRING([--enable-linker-hardening], [enable linker security fixups])], [], [AS_CASE([${enable_build_type}],[*-hardened], [enable_linker_hardening='yes'],[enable_linker_hardening='no'])] ) AS_VAR_IF([enable_linker_hardening],["yes"], [ CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${user_LDFLAGS}" MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,relro],[LDFLAGS_ac], [MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,now],[LDFLAGS_ac])]) # Actually should be "noexec" by default, but let's try to enforce it. MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,noexecstack],[LDFLAGS_ac]) # W32-specific. Some are enabled by default, but they will be enfored to be sure. MHD_CHECK_ADD_CC_LDFLAGS([-Wl,--large-address-aware -Wl,--enable-auto-image-base],[LDFLAGS_ac]) MHD_CHECK_ADD_CC_LDFLAGS([-Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va],[LDFLAGS_ac]) LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) AH_TEMPLATE([[HAVE_STDBOOL_H]], [Define to 1 if you have the header file and defines 'bool' type.]) AH_TEMPLATE([[HAVE_BUILTIN_TYPE_BOOL]], [Define to 1 if you have the real boolean type.]) AH_TEMPLATE([[bool]], [Define to type name which will be used as boolean type.]) AC_CHECK_HEADER([stdbool.h], [ AC_CHECK_TYPE([bool], [ AC_DEFINE([[HAVE_STDBOOL_H]], [[1]]) AC_DEFINE([[HAVE_BUILTIN_TYPE_BOOL]], [[1]]) ], [ AC_MSG_WARN([[Header is present, but "bool" type cannot be detected. Check compiler flags.]]) AC_DEFINE([[bool]], [[int]]) ], [ #include ] ) ], [ AC_CHECK_TYPE([bool], [AC_DEFINE([[HAVE_BUILTIN_TYPE_BOOL]], [[1]])], [ AC_CHECK_TYPE([_Bool], [ AC_DEFINE([[HAVE_BUILTIN_TYPE_BOOL]], [[1]]) AC_DEFINE([[bool]], [[_Bool]]) ], [ AC_DEFINE([[bool]], [[int]]) ], [] ) ], [] ) ], [AC_INCLUDES_DEFAULT] ) AC_CACHE_CHECK([[whether "true" is defined or builtin]], [[mhd_cv_macro_true_defined]], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ #ifdef HAVE_STDBOOL_H #include #endif ]], [[ #if defined(true) /* dummy */ #else (void)true; #endif ]]) ], [[mhd_cv_macro_true_defined='yes']], [[mhd_cv_macro_true_defined='no']]) ]) AS_VAR_IF([[mhd_cv_macro_true_defined]], [["yes"]], [[:]], [AC_DEFINE([[true]],[[(!0)]], [Define to value interpreted by compiler as boolean "true", if "true" is not defined by system headers.])]) AC_CACHE_CHECK([[whether "false" is defined or builtin]], [[mhd_cv_macro_false_defined]], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ #ifdef HAVE_STDBOOL_H #include #endif ]], [[ #if !defined(false) (void)false; #else /* dummy */ #endif ]]) ], [[mhd_cv_macro_false_defined='yes']], [[mhd_cv_macro_false_defined='no']]) ]) AS_VAR_IF([[mhd_cv_macro_false_defined]], [["yes"]], [[:]], [AC_DEFINE([[false]],[[0]], [Define to value interpreted by compiler as boolean "false", if "false" is not defined by system headers.])]) AC_CACHE_CHECK([[whether "true" and "false" could be used]], [[mhd_cv_macro_true_false_valid]], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ #ifdef HAVE_STDBOOL_H #include #endif ]], [[ int var1[true ? 1 : -1] = { 1 }; int var2[false ? -1 : 1] = { 2 }; int var3[!true ? -1 : 1] = { 3 }; int var4[!false ? 1 : -1] = { 4 }; if (var1[0] == var2[0] || var3[0] == var4[0]) return 1; ]]) ], [[mhd_cv_macro_true_false_valid='yes']], [[mhd_cv_macro_true_false_valid='no']]) ]) AS_VAR_IF([[mhd_cv_macro_true_false_valid]], [["yes"]], [[:]], [AC_MSG_ERROR([[Value of "true" or value of "false" is not valid. Check config.log for details.]])]) AX_CHECK_COMPILE_FLAG([[-Werror=attributes]], [ AC_MSG_CHECKING([[whether -Werror=attributes actually works]]) CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -Werror=attributes" AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[__attribute__((non_existing_attrb_dummy)) static int SimpleFunc(void) {return 3;}]], [[int r = SimpleFunc(); if (r) return r;]])], [ AC_MSG_RESULT([[no]]) errattr_CFLAGS="" ], [ AC_MSG_RESULT([[yes]]) errattr_CFLAGS="-Werror=attributes" ]) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ], [[errattr_CFLAGS=""]], [], []) AC_MSG_CHECKING([[for function inline keywords supported by $CC]]) CFLAGS="${CFLAGS_ac} ${user_CFLAGS} $errattr_CFLAGS" inln_prfx="none" # Prefer always inline functions for inln_prfx_chk in InlineWithAttr __forceinline inline __inline__ __inline _inline _Inline do # Try to link to avoid "symbol undefined" problems at build time AS_IF([[test "x$inln_prfx_chk" = "xInlineWithAttr"]], [ AS_IF([[test "x$errattr_CFLAGS" = "x"]], [[ # Skip test with attribute as negative result can't be detected inln_prfx_chk="__forceinline" # use next value ]],[[inln_prfx_chk="inline __attribute__((always_inline))"]]) ]) AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #ifdef __cplusplus #error This test is only for C. choke me #endif #ifdef HAVE_STDBOOL_H #include #endif static $inln_prfx_chk bool cmpfn(int x, int y) { return x > y; } static $inln_prfx_chk int sumfn(int x, int y) { return x + y; } ]],[[ int a = 1, b = 100, c; if (cmpfn(a, b)) c = sumfn(a, b); else c = 0 - sumfn(a, b); if (c) return 0; ]]) ], [[ inln_prfx="$inln_prfx_chk" ]]) test "x$inln_prfx" != "xnone" && break done AS_IF([[test "x$inln_prfx" != "xnone"]], [ AC_DEFINE([INLINE_FUNC],[1],[Define to 1 if your C compiler supports inline functions.]) AC_DEFINE_UNQUOTED([_MHD_static_inline],[static $inln_prfx],[Define to prefix which will be used with MHD static inline functions.]) ], [ AC_DEFINE([_MHD_static_inline],[static],[Define to prefix which will be used with MHD static inline functions.]) ]) AC_MSG_RESULT([[$inln_prfx]]) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" AC_CHECK_HEADERS([stdalign.h], [], [], [AC_INCLUDES_DEFAULT]) AC_CACHE_CHECK([[for C11 'alignof()' support]], [[mhd_cv_c_alignof]], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ #ifdef HAVE_STDALIGN_H #include #endif ]], [[ int var1[(alignof(int) >= 2) ? 1 : -1]; int var2[alignof(unsigned int) - 1]; int var3[(alignof(char) > 0) ? 1 : -1]; int var4[(alignof(long) >= 4) ? 1 : -1]; /* Mute compiler warnings */ var1[0] = var2[0] = var3[0] = 0; var4[0] = 1; if (var1[0] + var2[0] + var3[0] == var4[0]) return 1; ]]) ], [ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ #ifdef HAVE_STDALIGN_H #include #endif ]], [[ /* Should fail if 'alignof()' works */ int var1[alignof(nonexisting_type) - 1]; /* Mute compiler warnings */ var1[0] = 1; if (var1[0] + 1 == 1) return 1; ]]) ], [[mhd_cv_c_alignof='no']], [[mhd_cv_c_alignof='yes']]) ], [[mhd_cv_c_alignof='no']]) ]) AS_VAR_IF([mhd_cv_c_alignof], ["yes"], [AC_DEFINE([[HAVE_C_ALIGNOF]], [1], [Define to 1 if your compiler supports 'alignof()'])]) # Check system type AC_MSG_CHECKING([[for target host OS]]) os_is_windows="no" os_is_native_w32="no" AS_CASE(["$host_os"], [*darwin* | *rhapsody* | *macosx*], [AC_DEFINE([OSX],[1],[This is an OS X system]) mhd_host_os='Darwin' AC_MSG_RESULT([[$mhd_host_os]])], [kfreebsd*-gnu], [AC_DEFINE([SOMEBSD],[1],[This is a BSD system]) AC_DEFINE([FREEBSD],[1],[This is a FreeBSD system]) mhd_host_os='FreeBSD kernel with GNU userland' AC_MSG_RESULT([[$mhd_host_os]])], [freebsd*], [AC_DEFINE([SOMEBSD],[1],[This is a BSD system]) AC_DEFINE([FREEBSD],[1],[This is a FreeBSD system]) mhd_host_os='FreeBSD' AC_MSG_RESULT([[$mhd_host_os]])], [openbsd*], [AC_DEFINE([SOMEBSD],[1],[This is a BSD system]) AC_DEFINE([OPENBSD],[1],[This is an OpenBSD system]) mhd_host_os='OpenBSD' AC_MSG_RESULT([[$mhd_host_os]])], [netbsd*], [AC_DEFINE([SOMEBSD],[1],[This is a BSD system]) AC_DEFINE([NETBSD],[1],[This is a NetBSD system]) mhd_host_os='NetBSD' AC_MSG_RESULT([[$mhd_host_os]])], [*solaris*], [AC_DEFINE([SOLARIS],[1],[This is a Solaris system]) AC_DEFINE([_REENTRANT],[1],[Need with solaris or errno does not work]) mhd_host_os='Solaris' AC_MSG_RESULT([[$mhd_host_os]])], [*linux*], [AC_DEFINE([LINUX],[1],[This is a Linux kernel]) mhd_host_os='Linux' AC_MSG_RESULT([[$mhd_host_os]])], [*cygwin*], [AC_DEFINE([CYGWIN],[1],[This is a Cygwin system]) mhd_host_os='Windows/Cygwin' AC_MSG_RESULT([[$mhd_host_os]]) os_is_windows="yes"], [*mingw*], [ AC_DEFINE([MINGW],[1],[This is a MinGW system]) AC_DEFINE([WINDOWS],[1],[This is a Windows system]) mhd_host_os='Windows/MinGW' AC_MSG_RESULT([[$mhd_host_os]]) AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([[Winsock2 headers are required for W32]])], [AC_INCLUDES_DEFAULT]) AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool], [mslibcheck=`lib 2>&1` AS_IF([echo "$mslibcheck" | $GREP -e '^Microsoft (R) Library Manager' - >/dev/null], [ac_cv_use_ms_lib_tool=yes], [ac_cv_use_ms_lib_tool=no]) ]) AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes"], [AC_SUBST([MS_LIB_TOOL], [[lib]])]) AC_SUBST([lt_cv_objdir]) os_is_windows="yes" os_is_native_w32="yes" ], [*openedition*], [AC_DEFINE([OS390],[1],[This is a OS/390 system]) mhd_host_os='OS/390' AC_MSG_RESULT([[$mhd_host_os]])], [gnu*], [AC_DEFINE([[GNU_HURD]], [[1]], [Define to `1' if host machine runs on GNU Hurd.]) mhd_host_os='GNU Hurd' AC_MSG_RESULT([[$mhd_host_os]]) ], [ AC_MSG_RESULT([unrecognised OS]) mhd_host_os="${host_os}" AC_MSG_WARN([Unrecognised OS $host_os]) AC_DEFINE([OTHEROS],1,[Some strange OS]) ]) AM_CONDITIONAL([CYGWIN_TARGET], [[test "x$os_is_windows" = "xyes" && \ test "x${os_is_native_w32}" != "xyes"]]) AS_VAR_IF([os_is_windows], ["yes"], [ AC_MSG_CHECKING([[whether target W32 version is specified by precompiler defines]]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* Note: check logic is reversed for easy log reading */ #ifdef WINVER #error WINVER is defined choke me now; #endif #ifdef _WIN32_WINNT #error _WIN32_WINNT is defined choke me now; #endif #ifdef NTDDI #error NTDDI is defined choke me now; #endif ]],[[(void)0]]) ], [[mhd_w32_ver_preselect=no]], [[mhd_w32_ver_preselect=yes]] ) AC_MSG_RESULT([[${mhd_w32_ver_preselect}]]) AC_CHECK_HEADERS([windows.h sdkddkver.h], [], [], [AC_INCLUDES_DEFAULT]) AS_VAR_IF([mhd_w32_ver_preselect],["yes"], [ AC_MSG_CHECKING([[for specified target W32 version]]) AS_UNSET([[mhd_w32_ver]]) AS_UNSET([[mhd_w32_ver_msg]]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if _WIN32_WINNT+0 < 0x0501 /* Check before headers inclusion */ #error _WIN32_WINNT is less than 0x0501 choke me now; #endif #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #if _WIN32_WINNT+0 < 0x0501 #error _WIN32_WINNT is less than 0x0501 choke me now; #endif ]],[[(void)0]]) ], [], [ AC_MSG_RESULT([[pre-WinXP]]) AC_MSG_ERROR([[libmicrohttpd cannot be compiled for Windows version before Windows XP]]) ] ) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #if _WIN32_WINNT+0 == 0x0501 #error _WIN32_WINNT is 0x0501 choke me now; #endif #if _WIN32_WINNT+0 == 0x0502 #error _WIN32_WINNT is 0x0502 choke me now; #endif ]],[[(void)0]]) ], [], [ mhd_w32_ver="WinXP" mhd_w32_ver_msg="WinXP (selected by precompiler flags)" ] ) AS_VAR_SET_IF([mhd_w32_ver], [], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #if _WIN32_WINNT+0 < 0x0600 #error _WIN32_WINNT is less than 0x0600 but greater than 0x0502 choke me now; #endif ]],[[(void)0]]) ], [], [ AC_MSG_ERROR([[_WIN32_WINNT value is wrong (less than 0x0600 but greater than 0x0502)]]) ] ) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #if _WIN32_WINNT+0 == 0x0600 #error _WIN32_WINNT is 0x0600 choke me now; #endif ]],[[(void)0]]) ], [], [ mhd_w32_ver="Vista" mhd_w32_ver_msg="Vista (selected by precompiler flags)" ] ) ] ) AS_VAR_SET_IF([mhd_w32_ver], [], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #if _WIN32_WINNT+0 > 0x0600 #error _WIN32_WINNT is greater than 0x0600 choke me now; #endif ]],[[(void)0]]) ], [ mhd_w32_ver="unknown" mhd_w32_ver_msg="unknown (cannot be detected)" ], [ mhd_w32_ver="newer than Vista" mhd_w32_ver_msg="newer than Vista (selected by precompiler flags)" ] ) ] ) AC_MSG_RESULT([[${mhd_w32_ver}]]) ], [ mhd_w32_ver="Vista" mhd_w32_ver_msg="Vista (default, override by CPPFLAGS=-D_WIN32_WINNT=0xNNNN)" CPPFLAGS_ac="${CPPFLAGS_ac} -D_WIN32_WINNT=0x0600" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" AC_MSG_CHECKING([[whether headers accept _WIN32_WINNT=0x0600]]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_SDKDDKVER_H #include #endif #ifdef HAVE_WINDOWS_H #include #endif #include ]],[[(void)0]]) ], [ AC_MSG_RESULT([[yes]]) ], [ AC_MSG_RESULT([[no]]) AC_MSG_ERROR([Headers do not accept _WIN32_WINNT=0x0600. Consider override target W32 version by CPPFLAGS=-D_WIN32_WINNT=0xNNNN]) ] ) ] ) ] ) AS_IF([test "x${os_is_windows}" = "xyes" && test "x${os_is_native_w32}" = "xyes"], [ AC_CACHE_CHECK([W32 run-time library type], [mhd_cv_wctr_type], [ AC_EGREP_CPP([MHDMARKER: UCRT run-time library in use!], [ #include #if defined(_UCRT) #define CRT_STR "MHDMARKER: UCRT run-time library in use!" #endif #if defined(__MSVCRT_VERSION__) #if (__MSVCRT_VERSION__ >= 0xE00) && (__MSVCRT_VERSION__ < 0x1000) #define CRT_STR "MHDMARKER: UCRT run-time library in use!" #endif #if (__MSVCRT_VERSION__ > 0x1400) #define CRT_STR "MHDMARKER: UCRT run-time library in use!" #endif #endif #ifndef CRT_STR #define CRT_STR "MHDMARKER: MSVCRT run-time library in use!" #endif int main(void) { printf ("%\n", CRT_STR); return 0; } ], [mhd_cv_wctr_type="ucrt"], [mhd_cv_wctr_type="msvcrt"]) ] ) mhd_host_os="${mhd_host_os}-${mhd_cv_wctr_type}" AS_VAR_IF([mhd_cv_wctr_type], ["msvcrt"], [ # Use CFLAGS here to override user-supplied wrong CPPFLAGS. Durty trick, but choice is limited. AX_APPEND_COMPILE_FLAGS([-U__USE_MINGW_ANSI_STDIO -D__USE_MINGW_ANSI_STDIO=0], [CFLAGS_ac]) AC_SUBST([W32CRT], [MSVCRT]) ], [AC_SUBST([W32CRT], [UCRT])] ) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${user_LDFLAGS}" AS_CASE([$mhd_w32_ver], [WinXP], [MHD_CHECK_ADD_CC_LDFLAG([-Wl,--major-subsystem-version,5,--minor-subsystem-version,1],[LDFLAGS_ac])], [Vista], [MHD_CHECK_ADD_CC_LDFLAG([-Wl,--major-subsystem-version,6,--minor-subsystem-version,0],[LDFLAGS_ac])] ) LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" AC_ARG_WITH([threads], [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto, none) [auto]])], [], [with_threads='auto']) AS_CASE([[$with_threads]], [[win32]], [[with_threads='w32']], [[pthreads]], [[with_threads='posix']], [[posix]], [[:]], [[w32]], [[:]], [[none]], [[with_threads='none']], [[no]], [[with_threads='none']], [[auto]], [[:]], [AC_MSG_ERROR([[incorrect parameter "$with_threads" specified for --with-threads]])] ) # Check for posix threads support, regardless of configure parameters as # testsuite uses only posix threads. AX_PTHREAD( [ mhd_have_posix_threads='yes' AC_DEFINE([[HAVE_PTHREAD_H]],[[1]],[Define to 1 if you have the header file.]) AC_CACHE_CHECK([[whether pthread_sigmask(3) is available]], [[mhd_cv_func_pthread_sigmask]], [dnl save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="${CFLAGS_ac} ${PTHREAD_CFLAGS} ${user_CFLAGS}" AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ sigset_t nset, oset; sigemptyset (&nset); sigaddset (&nset, SIGPIPE); if (0 != pthread_sigmask(SIG_BLOCK, &nset, &oset)) return 1; ]])], [[mhd_cv_func_pthread_sigmask="yes"]],[[mhd_cv_func_pthread_sigmask="no"]]) LIBS="${save_LIBS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ]) AS_VAR_IF([mhd_cv_func_pthread_sigmask],["yes"], [AC_DEFINE([[HAVE_PTHREAD_SIGMASK]],[[1]],[Define to 1 if you have the pthread_sigmask(3) function.])]) ],[[mhd_have_posix_threads='no']]) AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$mhd_have_posix_threads" = "xyes"]) mhd_have_w32_threads='no' AS_IF([[test "x$with_threads" = "xauto"]], [ AS_IF([[test "x$os_is_windows" = "xyes"]], [ AC_MSG_CHECKING([[for W32 threads]]) AC_LINK_IFELSE( [AC_LANG_PROGRAM([[ #include ]], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])] , [[mhd_have_w32_threads='yes']], [[mhd_have_w32_threads='no']] ) AC_MSG_RESULT([[$mhd_have_w32_threads]]) ]) ] ) AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd ($with_threads)]]) AS_IF([test "x$with_threads" = "xposix"], [ # forced posix threads AS_IF([test "x$mhd_have_posix_threads" = "xyes"], [USE_THREADS='posix'], [ AS_IF([[test "x$os_is_windows" = "xyes"]] , [ AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]])], [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]])] ) ]) ]) AS_IF([test "x$with_threads" = "xw32"], [ # forced w32 threads AS_IF([[test "x$mhd_have_w32_threads" = "xyes"]], [[ USE_THREADS='w32' ]], [ AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]])]) ]) AS_IF([test "x$with_threads" = "xauto"], [# automatic threads lib selection AS_IF([[test "x$os_is_native_w32" = "xyes" && test "x$mhd_have_w32_threads" = "xyes"]] , [[ USE_THREADS='w32' ]] , [[ test "x$mhd_have_posix_threads" = "xyes" ]], [[ USE_THREADS='posix' ]], [[ test "x$mhd_have_w32_threads" = "xyes" ]], [[ USE_THREADS='w32' ]], [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]]) ] )]) AS_IF([test "x$with_threads" = "xnone"], [USE_THREADS='none']) AS_IF([test "x$USE_THREADS" = "xposix"], [CC="$PTHREAD_CC" AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads]) MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS" MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS" MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG"], [AS_IF([test "x$USE_THREADS" = "xw32"], [AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads])])]) AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"]) AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"]) AM_CONDITIONAL([USE_THREADS], [test "x$USE_THREADS" != "xnone"]) AM_CONDITIONAL([DISABLE_THREADS], [test "x$USE_THREADS" = "xnone"]) AC_MSG_RESULT([$USE_THREADS]) AC_ARG_ENABLE([[thread-names]], [AS_HELP_STRING([--disable-thread-names],[do not set names on MHD generated threads [auto]])], [], [enable_thread_names='auto']) AS_IF([test "x$enable_thread_names" != "xno" && test "x$USE_THREADS" = "xposix"],[ # Check for thread name function HAVE_THREAD_NAME_FUNC="no" SAVE_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="${CFLAGS_ac} $PTHREAD_CFLAGS ${user_CFLAGS}" AC_CHECK_HEADERS([pthread_np.h],[],[], [ AC_INCLUDES_DEFAULT [ #include ] ]) # Try to find how to set thread name by thread attributes. # If pthread_attr_setname_np(3) is not declared, it's not possible to detect # form of pthread_attr_setname_np(3) due to C "feature" "implicit declaration". AC_CHECK_DECL([[pthread_attr_setname_np]],[],[],[[ #include #ifdef HAVE_PTHREAD_NP_H #include #endif ]]) AS_IF([[test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]], [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in NetBSD or OSF1 form]]) AC_LINK_IFELSE( [AC_LANG_PROGRAM([[ #include #ifdef HAVE_PTHREAD_NP_H #include #endif ]], [[ pthread_attr_t thr_attr; pthread_attr_init(&thr_attr); pthread_attr_setname_np(&thr_attr, "name", 0); pthread_attr_destroy(&thr_attr); ]])], [AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_attr_setname_np(3) function.]) HAVE_THREAD_NAME_FUNC="yes" AC_MSG_RESULT([[yes]])], [AC_MSG_RESULT([[no]])] ) ]) AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_attr_setname_np" = "xyes"]], [AC_MSG_CHECKING([[for pthread_attr_setname_np(3) in IBM i or Solaris form]]) AC_LINK_IFELSE( [AC_LANG_PROGRAM([[ #include #ifdef HAVE_PTHREAD_NP_H #include #endif ]], [[ pthread_attr_t thr_attr; pthread_attr_init(&thr_attr); pthread_attr_setname_np(&thr_attr, "name"); pthread_attr_destroy(&thr_attr); ]])], [AC_DEFINE([[HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI]], [[1]], [Define if you have IBM i form (or Solaris form) of pthread_attr_setname_np(3) function.]) HAVE_THREAD_NAME_FUNC="yes" AC_MSG_RESULT([[yes]])], [AC_MSG_RESULT([[no]])] ) ]) # Try to find how to set thread name for started thread - less convenient # than setting name by attributes. # If pthread_setname_np(3) is not declared, it's not possible to detect # form of pthread_setname_np(3) due to C "feature" "implicit declaration". AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]], [AC_CHECK_DECL([[pthread_setname_np]],[],[],[[ #include #ifdef HAVE_PTHREAD_NP_H #include #endif ]]) ]) AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]], [AC_MSG_CHECKING([[for pthread_setname_np(3) in NetBSD or OSF1 form]]) AC_LINK_IFELSE( [AC_LANG_PROGRAM([[ #include #ifdef HAVE_PTHREAD_NP_H #include #endif ]], [[int res = pthread_setname_np(pthread_self(), "name", 0); if (res) return res;]])], [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_NETBSD]], [[1]], [Define if you have NetBSD form (or OSF1 form) of pthread_setname_np(3) function.]) HAVE_THREAD_NAME_FUNC="yes" AC_MSG_RESULT([[yes]])], [AC_MSG_RESULT([[no]])] ) ]) AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]], [AC_MSG_CHECKING([[for pthread_setname_np(3) in GNU/Linux form]]) AC_LINK_IFELSE( [AC_LANG_PROGRAM([[ #include #ifdef HAVE_PTHREAD_NP_H #include #endif ]], [[int res = pthread_setname_np(pthread_self(), "name"); if (res) return res;]])], [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_GNU]], [[1]], [Define if you have GNU/Linux form of pthread_setname_np(3) function.]) HAVE_THREAD_NAME_FUNC="yes" AC_MSG_RESULT([[yes]])], [AC_MSG_RESULT([[no]])] ) ]) AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes" && test "x$ac_cv_have_decl_pthread_setname_np" = "xyes"]], [AC_MSG_CHECKING([[for pthread_setname_np(3) in Darwin form]]) AC_LINK_IFELSE( [AC_LANG_PROGRAM([[ #include #ifdef HAVE_PTHREAD_NP_H #include #endif ]], [[int res = pthread_setname_np("name"); if (res) return res;]])], [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP_DARWIN]], [[1]], [Define if you have Darwin form of pthread_setname_np(3) function.]) HAVE_THREAD_NAME_FUNC="yes" AC_MSG_RESULT([[yes]])], [AC_MSG_RESULT([[no]])] ) ]) AS_IF([[test "x$HAVE_THREAD_NAME_FUNC" != "xyes"]], [ AC_CHECK_DECL([[pthread_set_name_np]], [ AC_MSG_CHECKING([[for pthread_set_name_np(3) in FreeBSD form]]) AC_LINK_IFELSE( [AC_LANG_PROGRAM([[ #include #ifdef HAVE_PTHREAD_NP_H #include #endif ]], [[pthread_set_name_np(pthread_self(), "name");]])], [AC_DEFINE([[HAVE_PTHREAD_SET_NAME_NP_FREEBSD]], [[1]], [Define if you have FreeBSD form of pthread_set_name_np(3) function.]) HAVE_THREAD_NAME_FUNC="yes" AC_MSG_RESULT([[yes]])], [AC_MSG_RESULT([[no]])] ) ],[],[[ #include #ifdef HAVE_PTHREAD_NP_H #include #endif ]] ) ]) LIBS="$SAVE_LIBS" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ]) AS_IF([[test "x$enable_thread_names" != "xno"]], [ AC_MSG_CHECKING([[whether to enable thread names]]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [[ #ifdef MHD_NO_THREAD_NAMES #error Thread names are disabled. choke me #endif /* Keep in sync with mhd_threads.h */ #if defined(MHD_USE_POSIX_THREADS) && (defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) || \ defined(HAVE_PTHREAD_SETNAME_NP_GNU) || defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) || defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) || \ defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) ) (void) 0; /* no-op */ #elif defined(MHD_USE_W32_THREADS) && defined(_MSC_FULL_VER) (void) 0; /* no-op */ #else #error No thread name function is available. choke me #endif ]]) ], [ enable_thread_names='yes' ], [ AS_IF([[test "x$enable_thread_names" = "xyes"]], [ AC_MSG_RESULT([[no]]) AC_MSG_ERROR([[thread names was explicitly requested, but thread name function is not available]]) ]) enable_thread_names='no' ]) AC_MSG_RESULT([[$enable_thread_names]]) ]) AS_IF([[test "x$enable_thread_names" = "xno"]], [AC_DEFINE([[MHD_NO_THREAD_NAMES]], [[1]], [Define to 1 to disable setting name on generated threads])]) AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"]) w32_shared_lib_exp=no AS_IF([test "x$enable_shared" = "xyes" && test "x$os_is_native_w32" = "xyes"], [ AS_IF([test "x$ac_cv_use_ms_lib_tool" = "xyes" || test -n "$DLLTOOL"], [ w32_shared_lib_exp=yes use_expfile="no" AS_VAR_IF([ac_cv_use_ms_lib_tool], ["yes"], [use_expfile="yes"], [ AC_CACHE_CHECK([whether $DLLTOOL supports export file generation], [mhd_cv_dlltool_expfile], [ AS_IF([AC_RUN_LOG([$DLLTOOL -e conftest.exp >&2 ])], [ AS_IF([test -f conftest.exp], [mhd_cv_dlltool_expfile="yes"], [mhd_cv_dlltool_expfile="no"]) ], [mhd_cv_dlltool_expfile="no"] ) rm -f conftest.exp ] ) use_expfile="${mhd_cv_dlltool_expfile}" ] ) ], [ AC_MSG_WARN([[GNU dlltool or MS lib.exe is required for creating shared library export on W32]]) AC_MSG_WARN([[Export library libmicrohttpd.lib will not be created]]) ] ) ] ) AM_CONDITIONAL([W32_SHARED_LIB_EXP], [test "x$w32_shared_lib_exp" = "xyes"]) AM_CONDITIONAL([USE_MS_LIB_TOOL], [test "x$ac_cv_use_ms_lib_tool" = "xyes"]) AM_CONDITIONAL([USE_EXPORT_FILE], [test "x$use_expfile" = "xyes"]) dnl gethostbyname() is not really needed dnl AC_SEARCH_LIBS([gethostbyname], [nsl]) MHD_FIND_LIB([socket], [[ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif ]], [(void)socket(0, 0, 0);], [socket ws2_32 xnet], [ AS_VAR_IF([[mhd_cv_find_lib_socket]],[["none required"]], [], [ MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_socket} $MHD_LIBDEPS_PKGCFG" ] ) ], [AC_MSG_ERROR([[cannot find header or library required for function socket()]])] ) MHD_CHECK_SOCKET_SHUTDOWN_TRIGGER([AC_DEFINE([HAVE_LISTEN_SHUTDOWN],[1],[can use shutdown on listen sockets])]) AM_CONDITIONAL([HAVE_LISTEN_SHUTDOWN], [test "x$mhd_cv_host_shtdwn_trgr_select" = "xyes"]) AC_CACHE_CHECK([fo][r system default FD_SETSIZE value],[mhd_cv_sys_fd_setsize_value], [ CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -UFD_SETSIZE" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS} -UFD_SETSIZE" AC_COMPUTE_INT([mhd_cv_sys_fd_setsize_value],[FD_SETSIZE],dnl [[ #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif ]], [mhd_cv_sys_fd_setsize_value="unknown"] ) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" AS_IF([test "x${mhd_cv_sys_fd_setsize_value}" != "xunknown" && \ test "${mhd_cv_sys_fd_setsize_value}" -eq "0" \ ], [mhd_cv_sys_fd_setsize_value="unknown"] ) ] ) AS_VAR_IF([mhd_cv_sys_fd_setsize_value],["unknown"],[:], [ AC_DEFINE_UNQUOTED([MHD_SYS_FD_SETSIZE_],[${mhd_cv_sys_fd_setsize_value}], [Define to system default value of FD_SETSIZE macro] ) ] ) AM_CONDITIONAL([NEED_SYS_FD_SET_SIZE_VALUE],[test "x${mhd_cv_sys_fd_setsize_value}" = "xunknown"]) AC_CACHE_CHECK([fo][r current FD_SETSIZE value],[mhd_cv_fd_setsize_value], [ CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" AS_IF([test "x${cross_compiling}" != "xno" && test "x${mhd_cv_sys_fd_setsize_value}" != "xunknown"], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[ #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif #define DETECTED_FD_SETZIE_VALUE ${mhd_cv_sys_fd_setsize_value} #if (FD_SETSIZE) != (DETECTED_FD_SETZIE_VALUE) #error The current default FD_SETSIZE value is different from ${mhd_cv_sys_fd_setsize_value} choke me here now #endif /* (FD_SETSIZE) != (DETECTED_FD_SETZIE_VALUE) */ #if (FD_SETSIZE) != (${mhd_cv_sys_fd_setsize_value}) #error The current default FD_SETSIZE value is different from ${mhd_cv_sys_fd_setsize_value} choke me here now #endif /* (FD_SETSIZE) != (${mhd_cv_sys_fd_setsize_value}) */ ]],[] ) ], [mhd_cv_fd_setsize_value="${mhd_cv_sys_fd_setsize_value}"] ) ] ) AS_VAR_SET_IF([mhd_cv_fd_setsize_value],[:], [ AC_COMPUTE_INT([mhd_cv_fd_setsize_value],[FD_SETSIZE],dnl [[ #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif ]], [mhd_cv_fd_setsize_value="unknown"] ) ] ) AS_IF([test "x${mhd_cv_fd_setsize_value}" != "xunknown" && \ test "${mhd_cv_fd_setsize_value}" -eq "0"], [mhd_cv_fd_setsize_value="unknown"] ) ] ) AC_CACHE_CHECK([whether FD_SETSIZE is overridable],[mhd_cv_fd_setsize_overridable], [ AS_VAR_IF([mhd_cv_fd_setsize_value],["unknown"], [ AS_VAR_IF([mhd_cv_sys_fd_setsize_value],["unknown"], [ # Assume the most popular FD_SETSIZE value base_fd_setsize=1024 ], [base_fd_setsize="${mhd_cv_sys_fd_setsize_value}"] ) base_min_fd_setsize="${base_fd_setsize}" ], [ AS_VAR_IF([mhd_cv_sys_fd_setsize_value],["unknown"], [ base_fd_setsize="${mhd_cv_fd_setsize_value}" base_min_fd_setsize="${base_fd_setsize}" ], [ AS_IF([test "${mhd_cv_fd_setsize_value}" -ge "${mhd_cv_sys_fd_setsize_value}"], [ base_fd_setsize="${mhd_cv_fd_setsize_value}" base_min_fd_setsize="${mhd_cv_sys_fd_setsize_value}" ], [ base_fd_setsize="${mhd_cv_sys_fd_setsize_value}" base_min_fd_setsize="${mhd_cv_fd_setsize_value}" ] ) ] ) ] ) # Use two times larger FD_SETSIZE value for test AS_VAR_ARITH([test_fd_setsize],[${base_fd_setsize} '+' ${base_fd_setsize}]) AS_IF([test "${test_fd_setsize}" -lt "128"],[test_fd_setsize=128]) test_type_fd_setsize="larger" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" _AS_ECHO_LOG([testing whether FD_SETSIZE test value (${test_fd_setsize}) is suitable for 'int' type]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ static int test_arr1[(((long long)${test_fd_setsize}) != ((int)${test_fd_setsize})) ? -1 : 1]; static int test_arr2[(0 > ((int)${test_fd_setsize})) ? -1 : 1]; test_arr1[0] = 0; test_arr2[0] = 0; i][f (test_arr1[0] != test_arr2[0]) return 1; ]] ) ],[], [ _AS_ECHO_LOG([The selected test FD_SETSIZE value (${test_fd_setsize}) is too large for 'int' type]) AS_VAR_ARITH([test_fd_setsize],[${base_min_fd_setsize} '/' '2']) test_type_fd_setsize="smaller" ] ) _AS_ECHO_LOG([will try ${test_fd_setsize} as FD_SETSIZE value]) AS_IF([test "x${cross_compiling}" = "xno" && test "x${test_type_fd_setsize}" = "xlarger"], [ _AS_ECHO_LOG([will try ${test_fd_setsize} as FD_SETSIZE value with run test]) AC_RUN_IFELSE( [ AC_LANG_SOURCE( [[ #ifdef FD_SETSIZE #undef FD_SETSIZE #endif /* FD_SETSIZE */ #define FD_SETSIZE ${test_fd_setsize} #define MY_TEST_FD_SETSIZE ${test_fd_setsize} #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #define MHD_TEST_SOCKET_TYPE SOCKET #else #define MHD_TEST_SOCKET_TYPE int #endif #ifdef HAVE_SYS_SELECT_H #include #endif #include #include /* Test fo][r mismatch by macro check */ #if (FD_SETSIZE) != (MY_TEST_FD_SETSIZE) #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize} choke me here now; #endif /* (FD_SETSIZE) != (MY_TEST_FD_SETSIZE) */ /* Additional test fo][r mismatch by macro check */ #if (FD_SETSIZE) != (${test_fd_setsize}) #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize} choke me here now; #endif /* (FD_SETSIZE) != (${test_fd_setsize}) */ static unsigned long var_fd_setsize_value = FD_SETSIZE; static unsigned long var_my_test_fd_setsize_value = MY_TEST_FD_SETSIZE; int main(void) { fd_set fds_num_one_copy; fd_set fds_num_three_copy; fd_set test_fdsets[6]; int i; int ret = 0; #if defined(_WIN32) && ! defined(__CYGWIN__) WSADATA wsa_data; if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data)) return 21; if (MAKEWORD(2, 2) != wsa_data.wVersion) { WSACleanup(); return 22; } #endif /* _WIN32 && ! __CYGWIN__ */ /* Init with zeros to make sure that slack areas are equal */ memset(test_fdsets, 0, sizeof(test_fdsets)); /* Correctly init fd_sets */ for (i = 0; i < 6; ++i) FD_ZERO(test_fdsets + i); /* Make copies of zero-inited fd_sets */ memcpy(&fds_num_one_copy, test_fdsets + 1, sizeof(fd_set)); memcpy(&fds_num_three_copy, test_fdsets + 3, sizeof(fd_set)); if (var_fd_setsize_value != var_my_test_fd_setsize_value) { fprintf (stderr, "System headers redefined FD_SETSIZE to another value (%lu).\n", (unsigned long) FD_SETSIZE); ret = 2; } else { /* Set (almost) all FDs in test_fdset[2] */ for (i = 1; i < FD_SETSIZE; ++i) FD_SET((MHD_TEST_SOCKET_TYPE)i, test_fdsets + 2); if (! FD_ISSET((MHD_TEST_SOCKET_TYPE)1, test_fdsets + 2)) { fprintf (stderr, "FD number one in original fd_set is unset, while should be set.\n"); ret |= 3; } if (! FD_ISSET((MHD_TEST_SOCKET_TYPE)(FD_SETSIZE - 1), test_fdsets + 2)) { fprintf (stderr, "FD number %lu in original fd_set is unset, while should be set.\n", (unsigned long) FD_SETSIZE); ret |= 3; } if (FD_ISSET((MHD_TEST_SOCKET_TYPE)1, test_fdsets + 1)) { fprintf (stderr, "FD number one in the first fd_set is unset, while should be set.\n"); ret |= 4; } if (FD_ISSET((MHD_TEST_SOCKET_TYPE)(FD_SETSIZE - 1), test_fdsets + 1)) { fprintf (stderr, "FD number %lu in the first fd_set is unset, while should be set.\n", (unsigned long) FD_SETSIZE); ret |= 4; } if (0 != memcmp (&fds_num_one_copy, test_fdsets + 1, sizeof(fd_set))) { fprintf (stderr, "The first fd_set has been altered.\n"); ret |= 4; } if (FD_ISSET((MHD_TEST_SOCKET_TYPE)1, test_fdsets + 3)) { fprintf (stderr, "FD number one in the third fd_set is unset, while should be set.\n"); ret |= 8; } if (FD_ISSET((MHD_TEST_SOCKET_TYPE)(FD_SETSIZE - 1), test_fdsets + 3)) { fprintf (stderr, "FD number %lu in the third fd_set is unset, while should be set.\n", (unsigned long) FD_SETSIZE); ret |= 8; } if (0 != memcmp (&fds_num_three_copy, test_fdsets + 3, sizeof(fd_set))) { fprintf (stderr, "The third fd_set has been altered.\n"); ret |= 8; } } #if defined(_WIN32) && ! defined(__CYGWIN__) WSACleanup(); #endif /* _WIN32 && ! __CYGWIN__ */ return ret; } ]] ) ], [mhd_cv_fd_setsize_overridable="yes"], [mhd_cv_fd_setsize_overridable="no"], [[# Not used when cross-compiling ]] ) ], [ _AS_ECHO_LOG([will try ${test_fd_setsize} as FD_SETSIZE with simple compile test]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[ #ifdef FD_SETSIZE #undef FD_SETSIZE #endif /* FD_SETSIZE */ #define FD_SETSIZE ${test_fd_setsize} #define MY_TEST_FD_SETSIZE ${test_fd_setsize} #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif /* Test fo][r mismatch by macro check */ #if (FD_SETSIZE) != (MY_TEST_FD_SETSIZE) #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize} choke me here now #endif /* (FD_SETSIZE) != (MY_TEST_FD_SETSIZE) */ /* Additional test fo][r mismatch by macro check */ #if (FD_SETSIZE) != (${test_fd_setsize}) #error System headers ignore custom FD_SETSIZE value, FD_SETSIZE is NOT ${test_fd_setsize} choke me here now #endif /* (FD_SETSIZE) != (${test_fd_setsize}) */ ]],[] ) ], [ _AS_ECHO_LOG([comple test succeed, will check whether another FD_SETSIZE value changes the size of 'fd_set']) # Check current size of fd_set _AS_ECHO_LOG([find the sizeof(fd_setsize) with current default (${mhd_cv_fd_setsize_value}) FD_SETSIZE value]) AC_COMPUTE_INT([sizeof_cur_fd_set],[sizeof(fd_set)],dnl [[ #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif ]], [sizeof_cur_fd_set="unknown"] ) _AS_ECHO_LOG([the sizeof(fd_setsize) with current default (${mhd_cv_fd_setsize_value}) FD_SETSIZE value is ${sizeof_cur_fd_set}]) # Check the size of fd_set with redefined FD_SETSIZE _AS_ECHO_LOG([find the sizeof(fd_setsize) with redefined (${test_fd_setsize}) FD_SETSIZE value]) AC_COMPUTE_INT([sizeof_mod_fd_set],[sizeof(fd_set)],dnl [[ #ifdef FD_SETSIZE #undef FD_SETSIZE #endif /* FD_SETSIZE */ #define FD_SETSIZE ${test_fd_setsize} #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif ]], [sizeof_mod_fd_set="unknown"] ) _AS_ECHO_LOG([the sizeof(fd_setsize) with redefined (${test_fd_setsize}) FD_SETSIZE value is ${sizeof_mod_fd_set}]) _AS_ECHO_LOG([detected sizes of 'fd_set': '${sizeof_cur_fd_set}' (by default), '${sizeof_mod_fd_set}' with modified FD_SETSIZE]) AS_IF([test "x${sizeof_cur_fd_set}" != "x${sizeof_mod_fd_set}"], [mhd_cv_fd_setsize_overridable="yes"], [mhd_cv_fd_setsize_overridable="no"] ) AS_UNSET([sizeof_mod_fd_set]) AS_UNSET([sizeof_cur_fd_set]) ], [mhd_cv_fd_setsize_overridable="no"] ) ] ) AS_UNSET([test_type_fd_setsize]) AS_UNSET([test_fd_setsize]) AS_UNSET([base_min_fd_setsize]) AS_UNSET([base_fd_setsize]) ] ) AS_VAR_IF([mhd_cv_fd_setsize_overridable],["no"], [ AS_VAR_IF([os_is_native_w32],["yes"], [AC_MSG_ERROR([Non-overridable FD_SETSIZE detected for native W32 build. FD_SETSIZE is overridable on W32.])] ) AS_IF([test "x${mhd_cv_fd_setsize_value}" != "xunknown" && test "x${mhd_cv_sys_fd_setsize_value}" != "xunknown" && test "${mhd_cv_fd_setsize_value}" -ne "${mhd_cv_sys_fd_setsize_value}"], [AC_MSG_WARN([Detected non-overridable FD_SETSIZE, but the toolchain uses FD_SETSIZE (${mhd_cv_fd_setsize_value}) different from system default (${mhd_cv_sys_fd_setsize_value})])] ) ], [AC_DEFINE([HAS_FD_SETSIZE_OVERRIDABLE],[1],[Define to 1 i][f your system allow overriding the value of FD_SETSIZE macro])] ) AC_CACHE_CHECK([whether socket value is a signed type],[mhd_cv_socket_signed], [ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #if defined(_WIN32) && ! defined(__CYGWIN__) #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif /* Keep in sync with microhttpd.h */ #if ! defined(_WIN32) || defined(_SYS_TYPES_FD_SET) typedef int MHD_socket; #else /* defined(_WIN32) && ! defined(_SYS_TYPES_FD_SET) */ typedef SOCKET MHD_socket; #endif /* defined(_WIN32) && ! defined(_SYS_TYPES_FD_SET) */ int main(void) { int test_arr[2 - 5*(!!(0 < ((MHD_socket)-1)))]; test_arr[1] = 0; return test_arr[1]; } ]] ) ], [mhd_cv_socket_signed="yes"], [mhd_cv_socket_signed="no"] ) ] ) AS_VAR_IF([mhd_cv_socket_signed],["yes"], [AC_DEFINE([HAS_SIGNED_SOCKET],[1],[Define to 1 i][f your socket type is signed])] ) MHD_CHECK_FUNC([writev], [[#include ]], [[ struct iovec iov[2]; char some_str[4] = "OK\n"; iov[0].iov_base = (void *) some_str; iov[0].iov_len = 3; i][f (0 > writev(1, iov, 1)) return 2; ]] ) MHD_FIND_LIB([sendmsg], [[ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_SOCKLIB_H #include #endif #ifdef HAVE_SYS_UIO_H #include #endif ]], [[ struct msghdr msg; struct iovec iov; unsigned int i; char some_str[5] = "test"; iov.iov_base = (void*)some_str; iov.iov_len = 4; for (i = 0; i < (unsigned int) sizeof(msg); i++) { *(((unsigned char *)&msg) + i) = 0; } msg.msg_iov = &iov; msg.msg_iovlen = 1; i][f (0 > sendmsg(1, &msg, 0)) return -1; ]], [socket], [ AC_DEFINE([HAVE_SENDMSG],[1],[Define to '1' if your have sendmsg() function]) AS_VAR_IF([[mhd_cv_find_lib_sendmsg]],[["none required"]], [], [ MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_sendmsg} $MHD_LIBDEPS_PKGCFG" ] ) ],[], [MHD_LIBDEPS] ) AC_C_BIGENDIAN AC_C_VARARRAYS AC_CACHE_CHECK([[whether __func__ magic-macro is available]], [[mhd_cv_macro___func___avail]], [dnl AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]],[[const char *funcname = __func__ ; if (NULL == funcname) return 1;]])], [[mhd_cv_macro___func___avail="yes"]],[[mhd_cv_macro___func___avail="no"]]) ]) AS_VAR_IF([mhd_cv_macro___func___avail], ["yes"], [AC_DEFINE([HAVE___FUNC__], [1], [Define to 1 if your compiler supports __func__ magic-macro.])], [ AC_CACHE_CHECK([[whether __FUNCTION__ magic-macro is available]], [[mhd_cv_macro___function___avail]], [dnl AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]],[[const char *funcname = __FUNCTION__ ; if (NULL == funcname) return 1;]])], [[mhd_cv_macro___function___avail="yes"]],[[mhd_cv_macro___function___avail="no"]]) ]) AS_VAR_IF([mhd_cv_macro___function___avail], ["yes"], [AC_DEFINE([HAVE___FUNCTION__], [1], [Define to 1 if your compiler supports __FUNCTION__ magic-macro.])], [ AC_CACHE_CHECK([[whether __PRETTY_FUNCTION__ magic-macro is available]], [[mhd_cv_macro___pretty_function___avail]], [dnl AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]],[[const char *funcname = __PRETTY_FUNCTION__ ; if (NULL == funcname) return 1;]])], [[mhd_cv_macro___pretty_function___avail="yes"]],[[mhd_cv_macro___pretty_function___avail="no"]]) ]) AS_VAR_IF([mhd_cv_macro___pretty_function___avail], ["yes"], [AC_DEFINE([HAVE___PRETTY_FUNCTION__], [1], [Define to 1 if your compiler supports __PRETTY_FUNCTION__ magic-macro.])], ) ] ) ] ) AC_CACHE_CHECK([[whether __builtin_bswap32() is available]], [[mhd_cv_func___builtin_bswap32_avail]], [dnl AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include]], [[uint32_t a = 1; uint32_t b = __builtin_bswap32(a); a = b; (void) a;]])], [[mhd_cv_func___builtin_bswap32_avail="yes"]],[[mhd_cv_func___builtin_bswap32_avail="no"]]) ]) AS_IF([[test "x$mhd_cv_func___builtin_bswap32_avail" = "xyes"]], [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP32]], [[1]], [Define to 1 if you have __builtin_bswap32() builtin function])]) AC_CACHE_CHECK([[whether __builtin_bswap64() is available]], [[mhd_cv_func___builtin_bswap64_avail]], [dnl AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include]], [[uint64_t a = 1; uint64_t b = __builtin_bswap64(a); a = b; (void) a;]])], [[mhd_cv_func___builtin_bswap64_avail="yes"]], [[mhd_cv_func___builtin_bswap64_avail="no"]]) ]) AS_IF([[test "x$mhd_cv_func___builtin_bswap64_avail" = "xyes"]], [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP64]], [[1]], [Define to 1 if you have __builtin_bswap64() builtin function])]) AC_CHECK_PROG([HAVE_CURL_BINARY],[curl],[yes],[no]) AM_CONDITIONAL([HAVE_CURL_BINARY],[test "x$HAVE_CURL_BINARY" = "xyes"]) AC_CHECK_PROG([HAVE_MAKEINFO_BINARY],[makeinfo],[yes],[no]) AM_CONDITIONAL([HAVE_MAKEINFO_BINARY],[test "x$HAVE_MAKEINFO_BINARY" = "xyes"]) AM_CONDITIONAL(W32_STATIC_LIB, [test "x$os_is_native_w32" = "xyes" && test "x$enable_static" = "xyes"]) AC_ARG_ENABLE([[doc]], [AS_HELP_STRING([[--disable-doc]], [do not build any documentation])], , [enable_doc=yes]) test "x$enable_doc" = "xno" || enable_doc=yes AM_CONDITIONAL([BUILD_DOC], [test "x$enable_doc" = "xyes"]) AC_ARG_ENABLE([[examples]], [AS_HELP_STRING([[--disable-examples]], [do not build any examples])], , [enable_examples=yes]) test "x$enable_examples" = "xno" || enable_examples=yes AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" = "xyes"]) AC_ARG_ENABLE([[tools]], [AS_HELP_STRING([[--disable-tools]], [do not build testing and demo tools])], , [enable_tools=yes]) test "x$enable_tools" = "xyes" || enable_tools=no AM_CONDITIONAL([BUILD_TOOLS], [test "x$enable_tools" = "xyes"]) AC_ARG_ENABLE([[heavy-tests]], [AS_HELP_STRING([[--enable-heavy-tests[=SCOPE]]], [use SCOPE of heavy tests in test-suite. WARNING:] [a dedicated host with minimal number of background processes and no network] [activity is recommended to enable. (basic, full)])], [], [enable_heavy_tests=no]) use_heavy_tests="no" use_vheavy_tests="no" use_heavy_tests_MSG="no" AS_CASE([${enable_heavy_tests}], [yes|basic], [ enable_heavy_tests="basic" use_heavy_tests="yes" use_vheavy_tests="no" use_heavy_tests_MSG="yes, basic heavy tests (a dedicated host is recommended)" ], [all|full], [ enable_heavy_tests="full" use_heavy_tests="yes" use_vheavy_tests="yes" use_heavy_tests_MSG="yes, full set of heavy tests (a dedicated host is recommended)" ], [no], [ use_heavy_tests="no" use_vheavy_tests="no" use_heavy_tests_MSG="no" ], [AC_MSG_ERROR([[Unknown parameter value: --enable-heavy-tests=${enable_heavy_tests}]])] ) AS_VAR_IF([use_heavy_tests], ["yes"], [ HEAVY_TESTS_NOTPARALLEL='.NOTPARALLEL:' AC_DEFINE([_MHD_HEAVY_TESTS], [1], [Define to 1 to enable "heavy" test paths.]) AS_VAR_IF([use_vheavy_tests], ["yes"], [AC_DEFINE([_MHD_VHEAVY_TESTS], [1], [Define to 1 to enable "very heavy" test paths.])] ) ], [ HEAVY_TESTS_NOTPARALLEL=" " ] ) AM_CONDITIONAL([HEAVY_TESTS],[test "x$use_heavy_tests" = "xyes"]) AM_CONDITIONAL([VHEAVY_TESTS],[test "x$use_vheavy_tests" = "xyes"]) AM_CONDITIONAL([TESTS_STRESS_OS],[false]) AC_ARG_ENABLE([[poll]], [AS_HELP_STRING([[--enable-poll[=ARG]]], [enable poll support (yes, no, auto) [auto]])], [enable_poll=${enableval}], [enable_poll='auto'] ) AS_IF([test "$enable_poll" != "no"], [ AS_IF([test "$os_is_native_w32" != "yes"], [ AC_CHECK_HEADERS([poll.h], [ MHD_CHECK_FUNC([poll], [[ #include ]], [[ struct pollfd fds[2]; fds[0].fd = 0; fds[0].events = POLLIN; if (0 > poll(fds, 1, 0)) return 2; ]], [have_poll='yes'], [have_poll='no'] ) ], [], [AC_INCLUDES_DEFAULT] ) ], [ MHD_CHECK_FUNC([WSAPoll], [[ #include ]], [[ WSAPOLLFD fda[2]; WSAPoll(fda, 2, 0); ]], [ have_poll='yes' AC_DEFINE([HAVE_POLL],[1]) ], [have_poll='no'] ) ] ) AS_IF([test "$enable_poll" = "yes" && test "$have_poll" != "yes"], [AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]])]) enable_poll="$have_poll" ] ) AC_ARG_ENABLE([[epoll]], [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])], [enable_epoll=${enableval}], [enable_epoll='auto'] ) AS_IF([test "$enable_epoll" != "no"], [ AX_HAVE_EPOLL AS_IF([test "${ax_cv_have_epoll}" = "yes"], [ AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll support]) enable_epoll='yes' ], [ AS_IF([test "$enable_epoll" = "yes"], [AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]])] ) enable_epoll='no' ] ) ] ) AM_CONDITIONAL([MHD_HAVE_EPOLL], [[test "x$enable_epoll" = xyes]]) AS_IF([test "x$enable_epoll" = "xyes"], [ MHD_CHECK_FUNC([epoll_create1], [[ #include ]], [[ i][f (0 > epoll_create1(EPOLL_CLOEXEC)) return 3; ]] ) ] ) AC_CACHE_CHECK([for supported 'noreturn' keyword], [mhd_cv_decl_noreturn], [ mhd_cv_decl_noreturn="none" CFLAGS="${CFLAGS_ac} ${user_CFLAGS} ${errattr_CFLAGS}" for decl_noret in '_Noreturn' '__attribute__((__noreturn__))' '__declspec(noreturn)' do AC_LINK_IFELSE([AC_LANG_SOURCE( [[ #ifdef HAVE_STDLIB_H #include #endif ${decl_noret} static void myexitfunc(int code) { #ifdef HAVE_STDLIB_H exit (code); #else (void)code; #endif } int main (int argc, char *const *argv) { (void) argv; if (argc > 2) myexitfunc (2); return 0; } ]] )], [mhd_cv_decl_noreturn="${decl_noret}"] ) AS_IF([test "x${mhd_cv_decl_noreturn}" != "xnone"], [break]) done CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ] ) AS_VAR_IF([mhd_cv_decl_noreturn], ["none"], [AC_DEFINE([_MHD_NORETURN], [], [Define to supported 'noreturn' function declaration])], [AC_DEFINE_UNQUOTED([_MHD_NORETURN], [${mhd_cv_decl_noreturn}], [Define to supported 'noreturn' function declaration])] ) # Check for types sizes # Types sizes are used as an indirect indication of maximum allowed values for types # which is used to exclude by preprocessor some compiler checks for values clips # Assuming no staffing or uniform staffing for integer types AC_CACHE_CHECK([size of tv_sec member of struct timeval], [mhd_cv_size_timeval_tv_sec], [ AC_COMPUTE_INT([mhd_cv_size_timeval_tv_sec], [((long int)sizeof(test_var.tv_sec))], [[ #ifdef HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H #include #endif /* HAVE_TIME_H */ #if HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ static struct timeval test_var; ]], [ # The size is used only to exclude additional checks/comparison in code # to avoid compiler warnings. With larger size MHD code will use # additional checks which ensure that value will fit but it may produce # a harmless compiler warning. AC_MSG_WARN([The size cannot be determined, assuming 8.]) mhd_cv_size_timeval_tv_sec=8 ] ) ] ) AC_DEFINE_UNQUOTED([SIZEOF_STRUCT_TIMEVAL_TV_SEC], [$mhd_cv_size_timeval_tv_sec], [The size of `tv_sec' member of `struct timeval', as computed by sizeof]) AC_CHECK_SIZEOF([int64_t], [], [[#include ]]) AC_CHECK_SIZEOF([uint64_t], [], [[#include ]]) AC_CHECK_SIZEOF([int], [], [[#include ]]) AC_CHECK_SIZEOF([unsigned int], [], [[#include ]]) AC_CHECK_SIZEOF([unsigned long long], [], [[#include ]]) AC_CHECK_SIZEOF([size_t], [], [[ #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #include ]] ) AC_CHECK_HEADERS([dlfcn.h],[have_tlsplugin=yes],[have_tlsplugin=no], [AC_INCLUDES_DEFAULT]) AM_CONDITIONAL([MHD_HAVE_TLS_PLUGIN], [[test "x$have_tlsplugin" = xyes]]) AC_CHECK_HEADERS([zlib.h],[have_zlib=yes],[have_zlib=no], [AC_INCLUDES_DEFAULT]) AM_CONDITIONAL([HAVE_ZLIB], [[test "x$have_zlib" = xyes]]) # Check for generic functions MHD_CHECK_FUNC([random], [ AC_INCLUDES_DEFAULT [#include ]], [[long int r = random(); (void)r;]], [], [ MHD_CHECK_FUNC([rand], [ AC_INCLUDES_DEFAULT [#include ]], [[int r = rand(); (void)r;]], ) ] ) AC_CHECK_MEMBERS([struct sockaddr.sa_len, struct sockaddr_storage.ss_len, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], [], [], [ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif ]) MHD_CHECK_LINK_RUN([[f][or working getsockname()]],[[mhd_cv_getsockname_usable]], [[mhd_cv_getsockname_usable='assuming yes']], [ AC_LANG_SOURCE( [[ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NETINET_IP_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif static void zr_mem(void *ptr, socklen_t size) { char *mem = ptr; while(size--) {mem[0] = 0; mem++;} } int main(void) { const socklen_t c_addr_size = (socklen_t)sizeof(struct sockaddr_in); struct sockaddr_in sa; socklen_t addr_size; int ret = 1; #if !defined(_WIN32) || defined(__CYGWIN__) int sckt; const int invld_sckt = -1; #else SOCKET sckt; const SOCKET invld_sckt = INVALID_SOCKET; WSADATA wsa_data; if (0 != WSAStartup(MAKEWORD(2, 2), &wsa_data) || MAKEWORD(2, 2) != wsa_data.wVersion) return 20; #endif sckt = socket (PF_INET, SOCK_STREAM, 0); if (invld_sckt != sckt) { zr_mem(&sa, c_addr_size); sa.sin_family = AF_INET; #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sa.sin_len = c_addr_size; #endif if (0 == bind (sckt, (struct sockaddr *)&sa, c_addr_size)) { if (0 == listen (sckt, 1)) { addr_size = c_addr_size; if (0 == getsockname (sckt, (struct sockaddr *)&sa, &addr_size)) { if (c_addr_size >= addr_size) { if (0 != ntohs(sa.sin_port)) { ret = 0; } else ret = 7; } else ret = 6; } else ret = 5; } else ret = 4; } else ret = 3; } else ret = 2; #if !defined(_WIN32) || defined(__CYGWIN__) close (sckt); #else closesocket (sckt); WSACleanup(); #endif return ret; } ]] ) ], [AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable `getsockname' function.])] ) AC_CACHE_CHECK([for usable PAGESIZE macro], [mhd_cv_macro_pagesize_usable], [ AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifndef PAGESIZE #error No PAGESIZE macro defined choke me now #endif ]], [[ long pgsz = PAGESIZE + 0; if (1 > pgsz) return 1; ]] ) ], [[mhd_cv_macro_pagesize_usable="yes"]], [[mhd_cv_macro_pagesize_usable="no"]] ) ] ) AS_VAR_IF([[mhd_cv_macro_pagesize_usable]], [["yes"]], [ AC_DEFINE([[MHD_USE_PAGESIZE_MACRO]],[[1]],[Define if you have usable PAGESIZE macro]) AC_CACHE_CHECK([whether PAGESIZE macro could be used for static init], [mhd_cv_macro_pagesize_usable_static], [ AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifndef PAGESIZE #error No PAGESIZE macro defined choke me now #endif static long ac_pgsz = PAGESIZE + 0; ]], [[ if (1 > ac_pgsz) return 1; ]] ) ], [[mhd_cv_macro_pagesize_usable_static="yes"]], [[mhd_cv_macro_pagesize_usable_static="no"]] ) ] ) AS_VAR_IF([[mhd_cv_macro_pagesize_usable_static]], [["yes"]], [AC_DEFINE([[MHD_USE_PAGESIZE_MACRO_STATIC]],[[1]],[Define if you have PAGESIZE macro usable for static init])] ) ], [ AC_CACHE_CHECK([for usable PAGE_SIZE macro], [mhd_cv_macro_page_size_usable], [ AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifndef PAGE_SIZE #error No PAGE_SIZE macro defined choke me now #endif ]], [[ long pgsz = PAGE_SIZE + 0; if (1 > pgsz) return 1; ]] ) ], [[mhd_cv_macro_page_size_usable="yes"]], [[mhd_cv_macro_page_size_usable="no"]] ) ] ) AS_VAR_IF([[mhd_cv_macro_page_size_usable]], [["yes"]], [ AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO]],[[1]],[Define if you have usable PAGE_SIZE macro]) AC_CACHE_CHECK([whether PAGE_SIZE macro could be used for static init], [mhd_cv_macro_page_size_usable_static], [ AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_SYS_PARAM_H #include #endif #ifndef PAGE_SIZE #error No PAGE_SIZE macro defined choke me now #endif static long ac_pgsz = PAGE_SIZE + 0; ]], [[ if (1 > ac_pgsz) return 1; ]] ) ], [[mhd_cv_macro_page_size_usable_static="yes"]], [[mhd_cv_macro_page_size_usable_static="no"]] ) ] ) AS_VAR_IF([[mhd_cv_macro_page_size_usable_static]], [["yes"]], [AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO_STATIC]],[[1]],[Define if you have PAGE_SIZE macro usable for static init])] ) ] ) ] ) # Check for inter-thread signaling type AC_ARG_ENABLE([[itc]], [AS_HELP_STRING([[--enable-itc=TYPE]], [use TYPE of inter-thread communication (pipe, socketpair, eventfd) [auto]])], [], [[enable_itc='auto']] ) AS_CASE([[$enable_itc]], [[pipe]], [[:]], [[socketpair]], [[:]], [[eventfd]], [[:]], [[auto]], [AS_VAR_IF([[os_is_windows]], [["yes"]], [[enable_itc='socketpair']])], [[eventFD]], [[enable_itc='eventfd']], [[socket]], [[enable_itc='socketpair']], [[no]], [AC_MSG_ERROR([[inter-thread communication cannot be disabled]])], [AC_MSG_ERROR([[unrecognized type "$enable_itc" of inter-thread communication specified by "--enable-itc=$enable_itc"]])] ) AS_UNSET([[use_itc]]) AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]], [ MHD_CHECK_LINK_RUN([[f][or working eventfd(2)]],[[mhd_cv_eventfd_usable]],[[mhd_cv_eventfd_usable='assuming no']], [ AC_LANG_SOURCE([[ #include #include int main(void) { unsigned char buf[8]; int ret; int efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); if (0 > efd) return 2; ret = 0; buf[3] = 1; if (8 != write(efd, buf, 8)) ret = 3; else { if (8 != read(efd, buf, 8)) ret = 4; } close(efd); return ret; } ]] ) ], [ use_itc='eventfd' enable_itc="$use_itc" AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for inter-thread communication]) ], [ AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not usable, consider using other type of inter-thread communication]])]) ] ) AS_VAR_IF([mhd_cv_eventfd_usable],["assuming no"], [AC_MSG_WARN([if you have 'eventfd' support enabled on your target system consider overriding test result by "mhd_cv_eventfd_usable=yes" configure parameter])] ) ] ) AS_IF([[test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto"]], [ AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [ AC_CACHE_CHECK([[whether pipe(3) is usable]], [[mhd_cv_pipe_usable]], [ AC_LINK_IFELSE([ AC_LANG_PROGRAM([ AC_INCLUDES_DEFAULT #ifdef HAVE_UNISTD_H #include #endif ], [[ int arr[2]; int res; res = pipe(arr); if (res != 0) return 33; close (arr[0]); close (arr[1]); ]]) ], [[mhd_cv_pipe_usable='yes']], [[mhd_cv_pipe_usable='no']]) ]) AS_VAR_IF([[mhd_cv_pipe_usable]], [["yes"]], [ use_itc='pipe' enable_itc="$use_itc" AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread communication]) MHD_CHECK_LINK_RUN([[whether pipe2(2) is usable]],[[mhd_cv_pipe2_usable]], [ # Cross-compiling AS_CASE([${host_os}], [kfreebsd*-gnu], [[mhd_cv_pipe2_usable='assuming no']], [[mhd_cv_pipe2_usable='assuming yes']]) ], [ AC_LANG_PROGRAM([ AC_INCLUDES_DEFAULT #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_UNISTD_H #include #endif ], [[ int arr[2]; int res; res = pipe2(arr, O_CLOEXEC | O_NONBLOCK); if (res != 0) return 33; close (arr[0]); close (arr[1]); ]] ) ], [AC_DEFINE([[HAVE_PIPE2_FUNC]], [[1]], [Define if you have usable pipe2(2) function])] ) ], [ AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not usable, consider using other type of inter-thread communication]])]) ]) ]) ]) AS_IF([[test "x$enable_itc" = "xsocketpair" || test "x$enable_itc" = "xauto"]], [ AS_VAR_IF([[os_is_native_w32]], [["yes"]], [[mhd_cv_socketpair_usable='yes']], [ AC_CACHE_CHECK([[whether socketpair(3) is usable]], [[mhd_cv_socketpair_usable]], [ AC_LINK_IFELSE([ AC_LANG_PROGRAM([ AC_INCLUDES_DEFAULT #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif ], [[ int arr[2]; int res; #if defined(AF_LOCAL) res = socketpair(AF_LOCAL, SOCK_STREAM, 0, arr); #elif defined(AF_UNIX) res = socketpair(AF_UNIX, SOCK_STREAM, 0, arr); #else #error AF_LOCAL and AF_UNIX are both undefined choke me now; #endif if (res != 0) return 1 ]]) ], [[mhd_cv_socketpair_usable='yes']], [[mhd_cv_socketpair_usable='no']]) ]) ]) AS_VAR_IF([[mhd_cv_socketpair_usable]], [["yes"]], [ use_itc='socketpair' enable_itc="$use_itc" AC_DEFINE([[_MHD_ITC_SOCKETPAIR]], [[1]], [Define to use socketpair for inter-thread communication]) ], [ AS_VAR_IF([[enable_itc]], [["socketpair"]], [AC_MSG_ERROR([[socketpair(3) is not usable, consider using other type of inter-thread communication]])]) ]) ]) AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find usable type of inter-thread communication]])]) MHD_CHECK_FUNC([accept4], [[ #if defined(HAVE_SYS_TYPES_H) # include #endif #include ]], [[ struct sockaddr sk_addr; socklen_t addr_size; i][f (0 > accept4(0, &sk_addr, &addr_size, 0)) return 3; ]] ) MHD_CHECK_FUNC([gmtime_r], [[ #if defined(HAVE_SYS_TYPES_H) # include #endif #include ]], [[ time_t timer = (time_t) 0; struct tm res; i][f (&res != gmtime_r(&timer, &res)) return 3; ]] ) MHD_CHECK_FUNC([memmem], [[ #if defined(HAVE_STDDEF_H) # include #elif defined(HAVE_STDLIB_H) # include #endif /* HAVE_STDLIB_H */ #include ]], [[ const char *haystack = "abc"; size_t hslen = 3; const char *needle = "b"; size_t needlelen = 1; i][f ((haystack + 1) != memmem(haystack, hslen, needle, needlelen)) return 3; ]] ) MHD_CHECK_FUNC([snprintf], [[ #include ]], [[ char buf[2]; i][f (1 != snprintf(buf, 2, "a")) return 3; /* Do not use the next check to avoid compiler warning */ /* i][f (4 != snprintf(buf, 2, "abcd")) return 4; */ ]] ) AC_CHECK_DECL([gmtime_s], [ AC_MSG_CHECKING([[whether gmtime_s is in C11 form]]) AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #define __STDC_WANT_LIB_EXT1__ 1 #include #ifdef __cplusplus extern "C" #endif struct tm* gmtime_s(const time_t* time, struct tm* result); ]], [[ static struct tm res; static time_t t = 0; gmtime_s (&t, &res); ]]) ], [ AC_DEFINE([HAVE_C11_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in C11 form.]) AC_MSG_RESULT([[yes]]) ], [ AC_MSG_RESULT([[no]]) AC_MSG_CHECKING([[whether gmtime_s is in W32 form]]) AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #include #ifdef __cplusplus extern "C" #endif errno_t gmtime_s(struct tm* _tm, const time_t* time); ]], [[ static struct tm res; static time_t t = 0; gmtime_s (&res, &t); ]]) ], [ AC_DEFINE([HAVE_W32_GMTIME_S], [1], [Define to 1 if you have the `gmtime_s' function in W32 form.]) AC_MSG_RESULT([[yes]]) ], [AC_MSG_RESULT([[no]]) ]) ]) ], [], [[#define __STDC_WANT_LIB_EXT1__ 1 #include ]]) AC_CHECK_DECL([SOCK_NONBLOCK], [AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBLOCK is defined in a socket header])], [], [[ #if defined(HAVE_SYS_TYPES_H) # include #endif #if defined(HAVE_SYS_SOCKET_H) # include #elif defined(HAVE_WINSOCK2_H) # include #endif ]] ) MHD_FIND_LIB([clock_gettime],[[#include ]], [[ struct timespec tp; i][f (0 > clock_gettime(CLOCK_REALTIME, &tp)) return 3; ]], [rt], [ AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define to '1' if you have clock_gettime() function]) AS_VAR_IF([[mhd_cv_find_lib_clock_gettime]],[["none required"]], [], [ MHD_LIBDEPS_PKGCFG="${mhd_cv_find_lib_clock_gettime} $MHD_LIBDEPS_PKGCFG" ] ) ],[], [MHD_LIBDEPS] ) MHD_CHECK_FUNC([clock_get_time], [[ #include #include ]], [[ clock_serv_t cs; mach_timespec_t mt; host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cs); clock_get_time(cs, &mt); mach_port_deallocate(mach_task_self(), cs); ]] ) MHD_CHECK_FUNC([gethrtime], [[ #ifdef HAVE_SYS_TIME_H /* Solaris define gethrtime() in sys/time.h */ #include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_TIME_H /* HP-UX define gethrtime() in time.h */ #include #endif /* HAVE_TIME_H */ ]], [[ hrtime_t hrt = gethrtime(); i][f (0 == hrt) return 3; ]] ) AS_VAR_IF([ac_cv_header_time_h], ["yes"], [ MHD_CHECK_FUNC([timespec_get], [[ #include #ifndef TIME_UTC #error TIME_UTC must be defined to use timespec_get() choke me now #endif ]], [[ struct timespec ts; i][f (TIME_UTC != timespec_get (&ts, TIME_UTC)) return 3; ]] ) ] ) MHD_CHECK_FUNC_GETTIMEOFDAY # IPv6 AC_CACHE_CHECK([for IPv6],[mhd_cv_have_inet6], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif ]], [[ int af=AF_INET6; int pf=PF_INET6; struct sockaddr_in6 sa; printf("%d %d %p\n", af, pf, (void*) &sa); ]] ) ], [AS_VAR_SET([mhd_cv_have_inet6],["yes"])], [AS_VAR_SET([mhd_cv_have_inet6],["no"])] ) ] ) AS_VAR_IF([mhd_cv_have_inet6],["yes"], [AC_DEFINE([HAVE_INET6], [1], [Define to '1' if you have IPv6 headers])] ) MHD_CHECK_FUNC([[sysconf]], [[#include ]], [[long a = sysconf(0); if (a) return 1;]]) MHD_CHECK_FUNC([[sysctl]], [[ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #if defined(HAVE_STDDEF_H) #include #elif defined(HAVE_STDLIB_H) #include #endif ]], [[ int mib[2] = {0, 0}; /* Avoid any platform-specific values */ i][f (sysctl(mib, 2, NULL, NULL, NULL, 0)) return 1; ]], [ AC_CHECK_DECLS([CTL_NET,PF_INET,IPPROTO_ICMP,ICMPCTL_ICMPLIM],[],[], [[ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif /* HAVE_NETINET_IN_SYSTM_H */ #ifdef HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NETINET_IP_H #include #endif /* HAVE_NETINET_IP_H */ #ifdef HAVE_NETINET_IP_ICMP_H #include #endif /* HAVE_NETINET_IP_ICMP_H */ #ifdef HAVE_NETINET_ICMP_VAR_H #include #endif /* HAVE_NETINET_ICMP_VAR_H */ ]] ) ] ) MHD_CHECK_FUNC([[sysctlbyname]], [[ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SYSCTL_H #include #endif #if defined(HAVE_STDDEF_H) #include #elif defined(HAVE_STDLIB_H) #include #endif ]], [[sysctlbyname("test", NULL, NULL, NULL, 0);]] ) MHD_CHECK_FUNC([[usleep]], [[#include ]], [[usleep(100000);]]) MHD_CHECK_FUNC([[nanosleep]], [[#include ]], [[struct timespec ts2, ts1 = {0, 0}; nanosleep(&ts1, &ts2);]]) HIDDEN_VISIBILITY_CFLAGS="" AH_TEMPLATE([_MHD_EXTERN],[defines how to decorate public symbols w][hile building the library]) CFLAGS="${user_CFLAGS}" MHD_CHECK_CC_CFLAG([-fvisibility=hidden],[CFLAGS_ac], [ # NOTE: require setting of errattr_CFLAGS above CFLAGS="${CFLAGS_ac} -fvisibility=hidden ${user_CFLAGS} ${errattr_CFLAGS}" AC_CACHE_CHECK([whether $CC supports __attribute__((visibility("default")))],[mhd_cv_cc_attr_visibility], [ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ extern __attribute__((visibility("default"))) int test_extrn_func(void); int test_extrn_func(void) {return 0;} ]]) ], [mhd_cv_cc_attr_visibility="yes"],[mhd_cv_cc_attr_visibility="no"] ) ] ) AS_VAR_IF([mhd_cv_cc_attr_visibility],["yes"], [ HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden" AS_IF([test "x$os_is_native_w32" = "xyes" && test "x$enable_shared" = "xyes"], [AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern])], [AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default"))) extern])] ) ], [ AC_MSG_WARN([$CC supports -fvisibility, but does not support __attribute__((visibility("default"))). Check compiler and compiler flags.]) AC_DEFINE([_MHD_EXTERN], [extern]) ] ) ],[AC_DEFINE([_MHD_EXTERN], [extern])] ) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" AC_SUBST([HIDDEN_VISIBILITY_CFLAGS]) # libcurl (required for testing) AC_ARG_ENABLE([curl], [AS_HELP_STRING([--disable-curl],[disable cURL based testcases])], [enable_curl=${enableval}]) curl=0 AS_IF([test "$enable_curl" != "no"], [LIBCURL_CHECK_CONFIG([yes],[7.16.4],[enable_curl=yes], [ AS_IF([test "x$enable_curl" = "xyes"], [AC_MSG_WARN([[cURL-based tests cannot be enabled because libcurl is missing]])]) enable_curl=no ]) ]) AM_CONDITIONAL([RUN_LIBCURL_TESTS], [test "x$enable_curl" = "xyes"]) AS_IF([test "x$enable_curl" = "xyes"], [MSG_CURL="yes"], [MSG_CURL="no, many unit tests will not run"] ) MHD_CHECK_FUNC([magic_open], [[ #include ]], [[ char var_data[256]; const char *var_mime; magic_t var_magic = magic_open (MAGIC_MIME_TYPE); (void)magic_load (var_magic, "filename"); var_data[0] = 0; var_mime = magic_buffer (var_magic, var_data, 1); i][f (! var_mime) return 1; magic_close (var_magic); ]], [AC_DEFINE([MHD_HAVE_LIBMAGIC], [1], [Define to 1 if you have suitable libmagic.])], [], [-lmagic] ) AM_CONDITIONAL([MHD_HAVE_LIBMAGIC], [[test "x$mhd_cv_func_magic_open" = "xyes"]]) # large file support (> 4 GB) AC_SYS_LARGEFILE AC_FUNC_FSEEKO MHD_CHECK_FUNC([lseek64], [[ #if defined(HAVE_SYS_TYPES_H) # include #endif #include ]], [[ i][f (((off64_t) -1) == lseek64(0, (off64_t) 0, SEEK_SET)) return 3; ]] ) MHD_CHECK_FUNC([pread64], [[ #if defined(HAVE_SYS_TYPES_H) # include #endif #include ]], [[ char buf[5]; i][f (0 > pread64(0, (void *) buf, 1, (off64_t) 0)) return 3; ]] ) MHD_CHECK_FUNC([pread], [[ #if defined(HAVE_SYS_TYPES_H) # include #endif #include ]], [[ char buf[5]; i][f (0 > pread(0, (void *) buf, 1, 0)) return 3; ]] ) # check for various sendfile functions AC_ARG_ENABLE([sendfile], [AS_HELP_STRING([--disable-sendfile], [disable usage of sendfile() for HTTP connections [auto]])], [], [enable_sendfile="auto"]) AS_CASE([$enable_sendfile], [[auto | yes]],[[found_sendfile="no"]], [[no]],[[found_sendfile="disabled"]], [AC_MSG_ERROR([[unknown value specified: --enable-sendfile=$enable_sendfile]])] ) AS_VAR_IF([[found_sendfile]], [["no"]], [ AC_MSG_CHECKING([[for Linux-style sendfile(2)]]) AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include static void empty_func(void) { /* Check for declaration */ (void)sendfile; } /* Declare again to check form match */ ssize_t sendfile(int, int, off_t*, size_t); ]], [[ int fd1=0, fd2=2; off_t o = 0; size_t s = 5; ssize_t r; r = sendfile (fd1, fd2, &o, s); if (r) empty_func(); ]] ) ], [ AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).]) found_sendfile="yes, Linux-style" AC_MSG_RESULT([[yes]]) MHD_CHECK_FUNC([sendfile64], [[ #include ]], [[ off64_t f_offset = (off64_t) 0; if (0 > sendfile64 (0, 1, &f_offset, 1)) return 3; ]] ) ], [AC_MSG_RESULT([[no]]) ] ) ] ) AS_VAR_IF([[found_sendfile]], [["no"]], [ AC_MSG_CHECKING([[for FreeBSD-style sendfile(2)]]) AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include #include #include static void empty_func(void) { /* Check for declaration */ (void)sendfile; } /* Declare again to check form match */ int sendfile(int, int, off_t, size_t, struct sf_hdtr*, off_t*, int); ]], [[ int fd1=0, fd2=1; off_t o = 0; size_t s = 5; off_t r1; int r2; r2 = sendfile (fd1, fd2, o, s, (void*)0, &r1, 0); if (r2) empty_func(); ]] ) ], [ AC_DEFINE([HAVE_FREEBSD_SENDFILE], [1], [Define to 1 if you have FreeBSD-style sendfile(2).]) found_sendfile="yes, FreeBSD-style" AC_MSG_RESULT([[yes]]) ], [AC_MSG_RESULT([[no]]) ] ) ] ) AS_VAR_IF([[found_sendfile]], [["no"]], [ AC_MSG_CHECKING([[for Darwin-style sendfile(2)]]) AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include #include #include static void empty_func(void) { /* Check for declaration */ (void)sendfile; } /* Declare again to check form match */ int sendfile(int, int, off_t, off_t*, struct sf_hdtr *, int); ]], [[ int fd=0, s=1; off_t o = 0; off_t l = 5; int r; r = sendfile (fd, s, o, &l, (void*)0, 0); if (r) empty_func(); ]] ) ], [ AC_DEFINE([HAVE_DARWIN_SENDFILE], [1], [Define to 1 if you have Darwin-style sendfile(2).]) found_sendfile="yes, Darwin-style" AC_MSG_RESULT([[yes]]) ], [AC_MSG_RESULT([[no]]) ] ) ] ) AS_VAR_IF([[found_sendfile]], [["no"]], [ AC_MSG_CHECKING([[for Solaris-style sendfile(3)]]) SAVE_LIBS="$LIBS" LIBS="-lsendfile $LIBS" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include #include #include static void empty_func(void) { /* Check for declaration */ (void)sendfile; } /* Declare again to check form match */ ssize_t sendfile(int out_fd, int in_fd, off_t *off, size_t len); ]], [[ int fd1=0, fd2=1; off_t o = 0; size_t l = 5; ssize_t r; r = sendfile (fd1, fd2, &o, l); if (r) empty_func(); ]] ) ], [ AC_DEFINE([HAVE_SOLARIS_SENDFILE], [1], [Define to 1 if you have Solaris-style sendfile(3).]) found_sendfile="yes, Solaris-style" MHD_LIBDEPS="-lsendfile $MHD_LIBDEPS" MHD_LIBDEPS_PKGCFG="-lsendfile $MHD_LIBDEPS_PKGCFG" AC_MSG_RESULT([[yes]]) MHD_CHECK_FUNC([sendfile64], [[ #include #include #include ]], [[ off64_t f_offset = (off64_t) 0; if (0 > sendfile64 (0, 1, &f_offset, 1)) return 3; ]] ) ], [AC_MSG_RESULT([[no]]) ] ) LIBS="$SAVE_LIBS" ] ) AS_IF([[test "x$found_sendfile" = "xno" && test "x$enable_sendfile" = "xyes"]], [AC_MSG_ERROR([[sendfile() usage was requested by configure parameter, but no usable sendfile() function is detected]])] ) # optional: enable error and informational messages AC_MSG_CHECKING([[whether to generate text messages]]) AC_ARG_ENABLE([messages], [AS_HELP_STRING([--disable-messages], [disable error, warning messages and text bodies for ] [automatic HTTP responses (to reduce the binary size)])], [enable_messages=${enableval}], [enable_messages=yes]) AS_IF([[test "x$enable_messages" = "xyes"]], [ AC_DEFINE([HAVE_MESSAGES],[1],[Define to 1 to enable support for text messages.]) ], [[ enable_messages=no ]]) AC_MSG_RESULT([[$enable_messages]]) AM_CONDITIONAL([HAVE_MESSAGES], [test "x$enable_messages" != "xno"]) # optional: have postprocessor? AC_MSG_CHECKING([[whether to enable postprocessor]]) AC_ARG_ENABLE([postprocessor], [AS_HELP_STRING([--disable-postprocessor], [disable MHD PostProcessor functionality])], [enable_postprocessor=${enableval}], [enable_postprocessor=yes]) AS_IF([[test "x$enable_postprocessor" != "xno"]], [ enable_postprocessor=yes AC_DEFINE([HAVE_POSTPROCESSOR],[1],[Define to 1 if libmicrohttpd is compiled with postprocessor support.]) ]) AM_CONDITIONAL([HAVE_POSTPROCESSOR], [test "x$enable_postprocessor" != "xno"]) AC_MSG_RESULT([[$enable_postprocessor]]) have_gnutls=no have_gnutls_sni=no have_gcrypt=no AS_UNSET([GNUTLS_CPPFLAGS]) AS_UNSET([GNUTLS_LDFLAGS]) # optional: HTTPS support. Enabled by default AC_ARG_ENABLE([https], [AS_HELP_STRING([--enable-https], [enable HTTPS support (yes, no, auto)[auto]])], [enable_https=${enableval}]) AS_IF([test "x$enable_https" != "xno"],[ # # Next block is large unindented block # # gnutls have_gnutls_pkgcfg=no AC_MSG_CHECKING([[how to find GnuTLS library]]) AC_ARG_WITH([[gnutls]], [AS_HELP_STRING([[--with-gnutls[=PFX]]],[use GnuTLS for HTTPS support, optional PFX overrides pkg-config data for GnuTLS headers (PFX/include) and libs (PFX/lib)])], [ AS_CASE([$with_gnutls], [no],[ AC_MSG_RESULT([[GnuTLS disabled]]) AS_UNSET([GNUTLS_CPPFLAGS]) AS_UNSET([GNUTLS_CFLAGS]) AS_UNSET([GNUTLS_LDFLAGS]) AS_UNSET([GNUTLS_LIBS]) ], [yes],[ AC_MSG_RESULT([[automatically, forced]]) ], [ AC_MSG_RESULT([[-I$with_gnutls/include -L$with_gnutls/lib -lgnutls]]) SAVE_LIBS="$LIBS" LDFLAGS="${LDFLAGS_ac} -L$with_gnutls/lib ${user_LDFLAGS}" CPPFLAGS="${CPPFLAGS_ac} -I$with_gnutls/include ${user_CPPFLAGS}" have_gnutls_pkgcfg=no MHD_CHECK_FUNC([gnutls_check_version],[[#include ]], [ if(!gnutls_check_version("2.0.0")) return 3; ], [ GNUTLS_CPPFLAGS="-I$with_gnutls/include" GNUTLS_LDFLAGS="-L$with_gnutls/lib" GNUTLS_LIBS="-lgnutls" have_gnutls=yes ], [AC_MSG_ERROR([can't find usable libgnutls at specified prefix $with_gnutls])], [-lgnutls] ) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" LIBS="$SAVE_LIBS" ]) ], [AC_MSG_RESULT([[automatically]]) ]) AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"], [ PKG_CHECK_MODULES(GNUTLS, [[gnutls]], [ have_gnutls_pkgcfg='yes' SAVE_LIBS="$LIBS" CFLAGS="${CFLAGS_ac} $GNUTLS_CFLAGS ${user_CFLAGS}" LIBS="$GNUTLS_LIBS $LIBS" AC_MSG_CHECKING([[whether GnuTLS is usable]]) AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ #include ]], [[ gnutls_session_t session; gnutls_priority_t priorities; gnutls_global_init(); gnutls_priority_init(&priorities, "NORMAL", NULL); gnutls_init(&session, GNUTLS_SERVER); gnutls_priority_set(session, priorities); ]])], [ AC_MSG_RESULT([[yes]]) have_gnutls=yes # GNUTLS_CFLAGS is actually CPPFLAGS GNUTLS_CPPFLAGS="$GNUTLS_CFLAGS" # GNUTLS_LDFLAGS is a combination of LDFLAGS and LIBS GNUTLS_LDFLAGS="$GNUTLS_LIBS" ], [ AC_MSG_RESULT([[no]]) have_gnutls=no ]) AS_IF([test "x$have_gnutls" != "xyes"], [ AC_MSG_WARN([pkg-config reports that GnuTLS is present, but GnuTLS can't be used]) AS_UNSET([GNUTLS_CPPFLAGS]) AS_UNSET([GNUTLS_CFLAGS]) AS_UNSET([GNUTLS_LDFLAGS]) AS_UNSET([GNUTLS_LIBS]) ] ) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" LIBS="$SAVE_LIBS" ], [ # check for GnuTLS at default paths have_gnutls_pkgcfg='no' AC_CHECK_HEADERS([gnutls/gnutls.h], [AC_CHECK_LIB([gnutls], [gnutls_priority_set], [ GNUTLS_LIBS="-lgnutls" have_gnutls=yes ])], [], [AC_INCLUDES_DEFAULT]) ]) ]) have_gcrypt='unknown' AS_IF([test "x$with_gnutls" != "xno" && test "x$have_gnutls" != "xyes"], [ AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no]) AS_IF([[test "x$have_gcrypt" = "xyes"]], [ SAVE_LIBS="$LIBS" CFLAGS="${CFLAGS_ac} $LIBGCRYPT_CFLAGS ${user_CFLAGS}" # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both CPPFLAGS="${CPPFLAGS_ac} $LIBGCRYPT_CFLAGS ${user_CPPFLAGS}" AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT]) # Check for GnuTLS with gcrypt flags LDFLAGS="${LDFLAGS_ac} ${LIBGCRYPT_LIBS} ${user_LDFLAGS}" # A bit of hack: unset cache variable to force recheck AS_UNSET([ac_cv_header_gnutls_gnutls_h]) AC_CHECK_HEADERS([gnutls/gnutls.h], [AS_UNSET([ac_cv_lib_gnutls_gnutls_priority_set]) # A bit of hack: unset cache variable to force recheck AC_CHECK_LIB([gnutls], [gnutls_priority_set], [ GNUTLS_CPPFLAGS="$LIBGCRYPT_CFLAGS" GNUTLS_CFLAGS="$LIBGCRYPT_CFLAGS" GNUTLS_LDFLAGS="$LIBGCRYPT_LIBS" GNUTLS_LIBS="-lgnutls" have_gnutls=yes ])], [], [AC_INCLUDES_DEFAULT]) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" LIBS="$SAVE_LIBS" ] ) ] ) AS_IF([test "x$have_gnutls" != "xyes" && test "x$with_gnutls" = "xyes"], [AC_MSG_ERROR([[can't find usable libgnutls]])]) AS_IF([test "x$have_gnutls" = "xyes"], [ SAVE_LIBS="$LIBS" CPPFLAGS="${CPPFLAGS_ac} ${GNUTLS_CPPFLAGS} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${GNUTLS_CFLAGS} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${GNUTLS_LDFLAGS} ${user_LDFLAGS}" LIBS="$GNUTLS_LIBS $LIBS" AC_MSG_CHECKING([[for gnutls_privkey_import_x509_raw()]]) AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ #include #include ]], [[ gnutls_datum_t data; gnutls_privkey_t key = 0; #ifndef gnutls_load_file (void)gnutls_load_file; /* Check for declaration. */ #endif #ifndef gnutls_privkey_import_x509_raw (void)gnutls_privkey_import_x509_raw; /* Check for declaration. */ #endif gnutls_load_file("key.pem", &data); gnutls_privkey_import_x509_raw(key, &data, GNUTLS_X509_FMT_PEM, NULL, 0); gnutls_free(data.data); ]])], [[have_gnutls_sni=yes]], [[have_gnutls_sni=no]]) AC_MSG_RESULT([[$have_gnutls_sni]]) AC_CACHE_CHECK([[whether GnuTLS require libgcrypt initialisation]], [mhd_cv_gcrypt_required], [ AC_COMPILE_IFELSE( [ AC_LANG_PROGRAM( [ #include ], [ #if !defined(GNUTLS_VERSION_NUMBER) || GNUTLS_VERSION_NUMBER+0 <= 0x020c14 #error Old versions of GnuTLS require libgcript initialisation choke me now #endif ] ) ], [[mhd_cv_gcrypt_required='no']], [[mhd_cv_gcrypt_required='yes']] ) ] ) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" LIBS="$SAVE_LIBS" ], [ AS_UNSET([GNUTLS_CPPFLAGS]) AS_UNSET([GNUTLS_LDFLAGS]) ] ) AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" = "xunknown"]], [ AM_PATH_LIBGCRYPT([1.2.2], [have_gcrypt=yes], [have_gcrypt=no]) AS_IF([[test "x$have_gcrypt" = "xyes"]], [ CFLAGS="${CFLAGS_ac} ${LIBGCRYPT_CFLAGS} ${user_CFLAGS}" # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both CPPFLAGS="${CPPFLAGS_ac} ${LIBGCRYPT_CFLAGS} ${user_CPPFLAGS}" AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], [AC_INCLUDES_DEFAULT]) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ] ) ] ) AS_UNSET([[crypt_missing]]) AS_IF([[test "x$have_gnutls" = "xyes"]], [ AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes" && test "x$have_gcrypt" != "xyes"]], [ crypt_missing="required libgcrypt" AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])]) enable_https=no MSG_HTTPS="no (lacking $crypt_missing)" AS_UNSET([LIBGCRYPT_CFLAGS]) AS_UNSET([LIBGCRYPT_LIBS]) AS_UNSET([GNUTLS_CPPFLAGS]) AS_UNSET([GNUTLS_CFLAGS]) AS_UNSET([GNUTLS_LDFLAGS]) AS_UNSET([GNUTLS_LIBS]) ], [ AC_DEFINE([[HTTPS_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTPS support.]) enable_https=yes AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]], [ MSG_HTTPS="yes (using libgnutls and libgcrypt)" MHD_TLS_LIB_CPPFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CPPFLAGS" MHD_TLS_LIB_CFLAGS="$LIBGCRYPT_CFLAGS $GNUTLS_CFLAGS" MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS" MHD_TLS_LIBDEPS="$GNUTLS_LIBS $LIBGCRYPT_LIBS" AC_DEFINE([[MHD_HTTPS_REQUIRE_GCRYPT]], [[1]], [Define to `1' if HTTPS require initialisation of libgcrypt]) ], [ MSG_HTTPS="yes (using libgnutls)" AS_UNSET([LIBGCRYPT_CFLAGS]) AS_UNSET([LIBGCRYPT_LIBS]) MHD_TLS_LIB_CPPFLAGS="$GNUTLS_CPPFLAGS" MHD_TLS_LIB_CFLAGS="$GNUTLS_CFLAGS" MHD_TLS_LIB_LDFLAGS="$GNUTLS_LDFLAGS" MHD_TLS_LIBDEPS="$GNUTLS_LIBS" ] ) AS_IF([[ test "x$have_gnutls_pkgcfg" = "xyes" ]], [ # remove GnuTLS from private libs in .pc file as it defined in Requires.private MHD_REQ_PRIVATE='gnutls' AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]], [[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]] ) ], [ MHD_REQ_PRIVATE='' AS_IF([[test "x$mhd_cv_gcrypt_required" = "xyes"]], [[MHD_LIBDEPS_PKGCFG="$LIBGCRYPT_LIBS $MHD_LIBDEPS_PKGCFG"]] ) MHD_LIBDEPS_PKGCFG="$GNUTLS_LIBS $MHD_LIBDEPS_PKGCFG" ]) ] ) ], [ crypt_missing="libgnutls" AS_IF([[test "x$enable_https" = "xyes" ]], [AC_MSG_ERROR([[HTTPS support cannot be enabled without $crypt_missing.]])]) enable_https=no MSG_HTTPS="no (lacking $crypt_missing)" AS_UNSET([LIBGCRYPT_CFLAGS]) AS_UNSET([LIBGCRYPT_LIBS]) AS_UNSET([GNUTLS_CPPFLAGS]) AS_UNSET([GNUTLS_CFLAGS]) AS_UNSET([GNUTLS_LDFLAGS]) AS_UNSET([GNUTLS_LIBS]) ] ) ],[ MSG_HTTPS="no (disabled)" ]) # # End of large unindented block # AC_MSG_CHECKING(whether to support HTTPS) AC_MSG_RESULT([$MSG_HTTPS]) AM_CONDITIONAL([HAVE_GNUTLS], [[test "x$have_gnutls" = "xyes"]]) AM_CONDITIONAL([HAVE_GNUTLS_SNI], [[test "x$have_gnutls_sni" = "xyes"]]) AM_CONDITIONAL([ENABLE_HTTPS], [test "x$enable_https" = "xyes"]) AM_CONDITIONAL([HTTPS_REQUIRE_GCRYPT], [[test "x$enable_https" = "xyes" && test "x$mhd_cv_gcrypt_required" = "xyes"]]) AC_SUBST([GNUTLS_CPPFLAGS]) AC_SUBST([GNUTLS_CFLAGS]) AC_SUBST([GNUTLS_LDFLAGS]) AC_SUBST([GNUTLS_LIBS]) AS_VAR_IF([have_gnutls], ["yes"], [ AC_CACHE_CHECK([for GnuTLS quirks], [mhd_cv_gnutls_mthread_broken], [ mhd_cv_gnutls_mthread_broken="no" AS_IF([test -r /etc/redhat-release], [ AS_IF([$FGREP ' release 6.' /etc/redhat-release >/dev/null || $FGREP '(Santiago)' /etc/redhat-release >/dev/null], [mhd_cv_gnutls_mthread_broken="found"], ) ] ) AS_VAR_IF([mhd_cv_gnutls_mthread_broken], ["no"], [ AS_IF([command -v rpm >/dev/null], [ AS_IF([test "r`rpm -E '%{rhel}' 2>/dev/null`" = "r6"], [mhd_cv_gnutls_mthread_broken="found"], ) ] ) ] ) ] ) AC_CACHE_CHECK([for gnutls-cli binary], [mhd_cv_gnutls_cli], [ mhd_cv_gnutls_cli="no" AS_IF([command -v gnutls-cli >/dev/null 2>&1], [AS_IF([AC_RUN_LOG([gnutls-cli --version >&2])], [mhd_cv_gnutls_cli="yes"])] ) ] ) ] ) AM_CONDITIONAL([HAVE_GNUTLS_MTHREAD_BROKEN], [[test "x${mhd_cv_gnutls_mthread_broken}" = "xfound"]]) AM_CONDITIONAL([USE_UPGRADE_TLS_TESTS], [[test "x${mhd_cv_gnutls_mthread_broken}" = "xno" || test "x${mhd_cv_gnutls_cli}" = "xyes"]]) # optional: HTTP Basic Auth support. Enabled by default AC_MSG_CHECKING([[whether to support HTTP Basic authentication]]) AC_ARG_ENABLE([bauth], [AS_HELP_STRING([--disable-bauth],[disable HTTP Basic Authentication support])], [enable_bauth=${enableval}], [enable_bauth=yes]) AS_IF([[test "x$enable_bauth" != "xno"]], [ enable_bauth=yes AC_DEFINE([BAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with Basic Auth support.]) ]) AM_CONDITIONAL([ENABLE_BAUTH], [test "x$enable_bauth" != "xno"]) AC_MSG_RESULT([[$enable_bauth]]) # optional: HTTP Digest Auth support. Enabled by default AC_MSG_CHECKING([[whether to support HTTP Digest authentication]]) AC_ARG_ENABLE([dauth], [AS_HELP_STRING([--disable-dauth], [disable HTTP Digest Authentication support])], [enable_dauth="${enableval}"], [enable_dauth="yes"]) AS_IF([[test "x$enable_dauth" != "xno"]], [ enable_dauth=yes AC_DEFINE([DAUTH_SUPPORT],[1],[Define to 1 if libmicrohttpd is compiled with Digest Auth support.]) ]) AM_CONDITIONAL([ENABLE_DAUTH], [test "x$enable_dauth" != "xno"]) AC_MSG_RESULT([[$enable_dauth]]) AS_VAR_IF([enable_dauth], ["yes"], [ AC_MSG_CHECKING([[for Digest Authentication default nonce timeout value]]) AC_ARG_ENABLE([dauth-def-timeout], [AS_HELP_STRING([--enable-dauth-def-timeout=NNN], [set default Digest Auth nonce validity time to NNN seconds])], [enable_dauth_def_timeout="${enableval}"], [enable_dauth_def_timeout=""] ) AS_VAR_IF([enable_dauth_def_timeout], ["no"], [ AC_MSG_WARN([Default Diget Auth nonce validity time cannot be disabled, --disable-dauth-def-timeout parameter is ignored]) enable_dauth_def_timeout="" ] ) AS_IF([test -z "${enable_dauth_def_timeout}"], [ enable_dauth_def_timeout="90" enable_dauth_def_timeout_MSG="${enable_dauth_def_timeout} seconds (default)" ], [ AS_IF([[test "x${enable_dauth_def_timeout}" = "x`echo ${enable_dauth_def_timeout}|${SED-sed} 's/[^0-9]//g'`" && \ test "${enable_dauth_def_timeout}" -ge "0" 2>/dev/null ]],[:], [AC_MSG_ERROR([Invalid parameter --enable-dauth-def-timeout=${enable_dauth_def_timeout}. Timeout value must be a positive integer.]) ] ) AC_COMPILE_IFELSE( [ AC_LANG_PROGRAM([], [[ static int arr[((int) 2) - 4 * (int)(${enable_dauth_def_timeout} != ((unsigned int)${enable_dauth_def_timeout}))]; (void) arr; ]] ) ], [], [AC_MSG_ERROR([The value specified by --enable-dauth-def-timeout=${enable_dauth_def_timeout} is too large.])] ) enable_dauth_def_timeout_MSG="${enable_dauth_def_timeout} seconds (set by parameter)" ] ) AC_DEFINE_UNQUOTED([MHD_DAUTH_DEF_TIMEOUT_],[${enable_dauth_def_timeout}], [The default HTTP Digest Auth default nonce timeout value (in seconds)]) AC_MSG_RESULT([[${enable_dauth_def_timeout_MSG}]]) AC_MSG_CHECKING([[for Digest Authentication default maximum nc value]]) AC_ARG_ENABLE([dauth-def-max-nc], [AS_HELP_STRING([--enable-dauth-def-max-nc=NNN], [set default Digest Auth maximum nc (nonce count) value to NNN])], [enable_dauth_def_max_nc="${enableval}"], [enable_dauth_def_max_nc=""] ) AS_VAR_IF([enable_dauth_def_max_nc], ["no"], [ AC_MSG_WARN([Default Diget Auth maximum nc cannot be disabled, --disable-dauth-def-max-nc parameter is ignored]) enable_dauth_def_max_nc="" ] ) AS_IF([test -z "${enable_dauth_def_max_nc}"], [ enable_dauth_def_max_nc="1000" enable_dauth_def_max_nc_MSG="${enable_dauth_def_max_nc} (default)" ], [ AS_IF([[test "x${enable_dauth_def_max_nc}" = "x`echo ${enable_dauth_def_max_nc}|${SED-sed} 's/[^0-9]//g'`" && \ test "${enable_dauth_def_max_nc}" -ge "0" 2>/dev/null ]],[:], [AC_MSG_ERROR([Invalid parameter --enable-dauth-def-max-nc=${enable_dauth_def_max_nc}. The value must be a positive integer.]) ] ) AC_COMPILE_IFELSE( [ AC_LANG_PROGRAM( [[ #include ]], [[ static int arr[((int) 2) - 4 * (int)(${enable_dauth_def_max_nc} != ((uint32_t)${enable_dauth_def_max_nc}))]; (void) arr; ]] ) ], [], [AC_MSG_ERROR([The value specified by --enable-dauth-def-max-nc=${enable_dauth_def_max_nc} is too large.])] ) enable_dauth_def_max_nc_MSG="${enable_dauth_def_max_nc} (set by parameter)" ] ) AC_DEFINE_UNQUOTED([MHD_DAUTH_DEF_MAX_NC_],[${enable_dauth_def_max_nc}], [The default HTTP Digest Auth default maximum nc (nonce count) value]) AC_MSG_RESULT([[${enable_dauth_def_max_nc_MSG}]]) dauth_defs_MSG="timeout: ${enable_dauth_def_timeout_MSG}, max nc: ${enable_dauth_def_max_nc_MSG}" ], [ dauth_defs_MSG="N/A" ] ) AM_CONDITIONAL([HAVE_ANYAUTH],[test "x$enable_bauth" != "xno" || test "x$enable_dauth" != "xno"]) # optional: HTTP "Upgrade" support. Enabled by default AC_MSG_CHECKING([[whether to support HTTP "Upgrade"]]) AC_ARG_ENABLE([[httpupgrade]], [AS_HELP_STRING([[--disable-httpupgrade]], [disable HTTP "Upgrade" support])], [AS_VAR_IF([[enable_httpupgrade]],[["no"]],[],[[enable_httpupgrade='yes']])], [[enable_httpupgrade='yes']]) AS_VAR_IF([[enable_httpupgrade]],[["yes"]], [ AC_DEFINE([[UPGRADE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTP Upgrade support.]) ]) AM_CONDITIONAL([ENABLE_UPGRADE], [[test "x$enable_httpupgrade" = "xyes"]]) AC_MSG_RESULT([[$enable_httpupgrade]]) # optional: HTTP cookie parsing support. Enabled by default AC_MSG_CHECKING([[whether to support HTTP cookie parsing]]) AC_ARG_ENABLE([[cookie]], [AS_HELP_STRING([[--disable-cookie]], [disable HTTP cookie parsing support])], [AS_VAR_IF([[enable_cookie]],[["no"]],[],[[enable_cookie='yes']])], [[enable_cookie='yes']]) AS_VAR_IF([[enable_cookie]],[["yes"]], [ AC_DEFINE([[COOKIE_SUPPORT]],[[1]],[Define to 1 if libmicrohttpd is compiled with HTTP cookie parsing support.]) ]) AM_CONDITIONAL([ENABLE_COOKIE], [[test "x$enable_cookie" = "xyes"]]) AC_MSG_RESULT([[$enable_cookie]]) # optional: MD5 support for Digest Auth. Enabled by default. AC_ARG_ENABLE([[md5]], [AS_HELP_STRING([[--enable-md5=TYPE]], [enable TYPE of MD5 hashing code (yes, no, builtin, tlslib) [yes if dauth enabled]])], [ AS_VAR_IF([enable_md5],["internal"],[enable_md5='builtin']) AS_VAR_IF([enable_md5],["built-in"],[enable_md5='builtin']) AS_VAR_IF([enable_dauth],["yes"],[], [ AS_VAR_IF([enable_md5],["no"],[], [ AC_MSG_WARN([The parameter --enable-md5=${enable_md5} is ignored as Digest Authentication is disabled]) enable_md5='no' ] ) ] ) ], [[enable_md5="${enable_dauth}"]] ) AS_CASE([${enable_md5}],[yes|tlslib], [ AS_IF([test "x${enable_compact_code}" != "xno" || test "x$enable_md5" = "xtlslib"], [ AS_IF([test "x$enable_https" = "xyes"], [ AC_CACHE_CHECK([whether GnuTLS supports MD5 hashing],[mhd_cv_gnutls_md5], [ CFLAGS="${CFLAGS_ac} ${GNUTLS_CFLAGS} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${MHD_TLS_LIB_CPPFLAGS} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${MHD_TLS_LIB_CFLAGS} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${MHD_TLS_LIB_LDFLAGS} ${user_LDFLAGS}" save_LIBS="$LIBS" LIBS="${MHD_TLS_LIBDEPS} ${LIBS}" AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #include ]], [[ gnutls_hash_hd_t hash_handle; unsigned char digest[16]; int exit_code; if (0 == gnutls_hash_init(&hash_handle, GNUTLS_DIG_MD5)) { if (0 == gnutls_hash(hash_handle, "", 1)) { gnutls_hash_output(hash_handle, digest); if (0x93 == digest[0]) exit_code = 0; else exit_code = 7; } else exit_code = 5; gnutls_hash_deinit(hash_handle, (void *)0); } else exit_code = 2; if (exit_code) return exit_code; ]] ) ], [mhd_cv_gnutls_md5='yes'],[mhd_cv_gnutls_md5='no'] ) LIBS="${save_LIBS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) AS_VAR_IF([mhd_cv_gnutls_md5],["no"], [ AS_VAR_IF([enable_md5],["tlslib"], [AC_MSG_FAILURE([TLS library MD5 implementation is not available])] ) enable_md5="builtin" ], [enable_md5="tlslib"] ) ], [ AS_VAR_IF([enable_md5],["tlslib"], [AC_MSG_ERROR([HTTPS is not enabled, TLS library MD5 implementation cannot be used])] ) enable_md5="builtin" ] ) ], [ enable_md5="builtin" ] ) ] ) AC_MSG_CHECKING([[whether to support MD5]]) AS_UNSET([enable_md5_MSG]) AS_CASE([${enable_md5}], [builtin],[enable_md5_MSG='yes, built-in'], [tlslib],[enable_md5_MSG='yes, external (TLS library)'], [no],[enable_md5_MSG='no'], [yes],[AC_MSG_ERROR([configure internal error: unexpected variable value])], [AC_MSG_ERROR([Unrecognized parameter --enable-md5=${enable_md5}])] ) AS_IF([test "x${enable_md5}" = "xbuiltin" || test "x${enable_md5}" = "xtlslib" ], [ AC_DEFINE([[MHD_MD5_SUPPORT]],[[1]], [Define to 1 if libmicrohttpd is compiled with MD5 hashing support.]) ] ) AS_IF([test "x${enable_md5}" = "xtlslib" ], [ AC_DEFINE([[MHD_MD5_TLSLIB]],[[1]], [Define to 1 if libmicrohttpd is compiled with MD5 hashing by TLS library.]) ] ) AM_CONDITIONAL([ENABLE_MD5], [[test "x${enable_md5}" = "xbuiltin" || test "x${enable_md5}" = "xtlslib" ]]) AM_CONDITIONAL([ENABLE_MD5_EXT], [[test "x${enable_md5}" = "xtlslib" ]]) AC_MSG_RESULT([[${enable_md5_MSG}]]) # optional: SHA-256 support for Digest Auth. Enabled by default. AC_ARG_ENABLE([[sha256]], [AS_HELP_STRING([[--enable-sha256=TYPE]], [enable TYPE of SHA-256 hashing code (yes, no, builtin, tlslib) [yes if dauth enabled]])], [ AS_VAR_IF([enable_sha256],["internal"],[enable_sha256='builtin']) AS_VAR_IF([enable_sha256],["built-in"],[enable_sha256='builtin']) AS_VAR_IF([enable_dauth],["yes"],[], [ AS_VAR_IF([enable_sha256],["no"],[], [ AC_MSG_WARN([The parameter --enable-sha256=${enable_sha256} is ignored as Digest Authentication is disabled]) enable_sha256='no' ] ) ] ) ], [[enable_sha256="${enable_dauth}"]] ) AS_CASE([${enable_sha256}],[yes|tlslib], [ AS_IF([test "x${enable_compact_code}" != "xno" || test "x$enable_sha256" = "xtlslib"], [ AS_IF([test "x$enable_https" = "xyes"], [ AC_CACHE_CHECK([whether GnuTLS supports sha256 hashing],[mhd_cv_gnutls_sha256], [ CFLAGS="${CFLAGS_ac} ${GNUTLS_CFLAGS} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${MHD_TLS_LIB_CPPFLAGS} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${MHD_TLS_LIB_CFLAGS} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${MHD_TLS_LIB_LDFLAGS} ${user_LDFLAGS}" save_LIBS="$LIBS" LIBS="${MHD_TLS_LIBDEPS} ${LIBS}" AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #include ]], [[ gnutls_hash_hd_t hash_handle; unsigned char digest[32]; int exit_code; if (0 == gnutls_hash_init(&hash_handle, GNUTLS_DIG_SHA256)) { if (0 == gnutls_hash(hash_handle, "", 1)) { gnutls_hash_output(hash_handle, digest); if (0x6e == digest[0]) exit_code = 0; else exit_code = 7; } else exit_code = 5; gnutls_hash_deinit(hash_handle, (void *)0); } else exit_code = 2; if (exit_code) return exit_code; ]] ) ], [mhd_cv_gnutls_sha256='yes'],[mhd_cv_gnutls_sha256='no'] ) LIBS="${save_LIBS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}" ] ) AS_VAR_IF([mhd_cv_gnutls_sha256],["no"], [ AS_VAR_IF([enable_sha256],["tlslib"], [AC_MSG_FAILURE([TLS library SHA-256 implementation is not available])] ) enable_sha256="builtin" ], [enable_sha256="tlslib"] ) ], [ AS_VAR_IF([enable_sha256],["tlslib"], [AC_MSG_ERROR([HTTPS is not enabled, TLS library SHA-256 implementation cannot be used])] ) enable_sha256="builtin" ] ) ], [ enable_sha256="builtin" ] ) ] ) AC_MSG_CHECKING([[whether to support SHA-256]]) AS_UNSET([enable_sha256_MSG]) AS_CASE([${enable_sha256}], [builtin],[enable_sha256_MSG='yes, built-in'], [tlslib],[enable_sha256_MSG='yes, external (TLS library)'], [no],[enable_sha256_MSG='no'], [yes],[AC_MSG_ERROR([configure internal error: unexpected variable value])], [AC_MSG_ERROR([Unrecognized parameter --enable-sha256=${enable_sha256}])] ) AS_IF([test "x${enable_sha256}" = "xbuiltin" || test "x${enable_sha256}" = "xtlslib" ], [ AC_DEFINE([[MHD_SHA256_SUPPORT]],[[1]], [Define to 1 if libmicrohttpd is compiled with SHA-256 hashing support.]) ] ) AS_IF([test "x${enable_sha256}" = "xtlslib" ], [ AC_DEFINE([[MHD_SHA256_TLSLIB]],[[1]], [Define to 1 if libmicrohttpd is compiled with SHA-256 hashing by TLS library.]) ] ) AM_CONDITIONAL([ENABLE_SHA256], [[test "x${enable_sha256}" = "xbuiltin" || test "x${enable_sha256}" = "xtlslib" ]]) AM_CONDITIONAL([ENABLE_SHA256_EXT], [[test "x${enable_sha256}" = "xtlslib" ]]) AC_MSG_RESULT([[${enable_sha256_MSG}]]) # optional: SHA-512/256 support for Digest Auth. Enabled by default. AC_ARG_ENABLE([[sha512-256]], [AS_HELP_STRING([[--disable-sha512-256]], [disable SHA-512/256 hashing support for Digest Authentication])], [ AS_VAR_IF([[enable_sha512_256]],[["yes"]], [ AS_VAR_IF([enable_dauth],["yes"],[], [ AC_MSG_WARN([The parameter --enable-sha512-256 is ignored as Digest Authentication is disabled]) enable_sha512_256='no' ] ) ],[[enable_sha512_256='no']] ) ], [[enable_sha512_256="${enable_dauth}"]] ) AC_MSG_CHECKING([[whether to support SHA-512/256]]) AS_UNSET([enable_sha512_256_MSG]) AS_CASE([${enable_sha512_256}], [yes],[enable_sha512_256_MSG='yes, built-in'], [no],[enable_sha512_256_MSG='no'], [AC_MSG_ERROR([Unrecognized parameter --enable-sha512-256=${enable_sha512_256}])] ) AS_VAR_IF([[enable_sha512_256]],[["yes"]], [ AC_DEFINE([[MHD_SHA512_256_SUPPORT]],[[1]], [Define to 1 if libmicrohttpd is compiled with SHA-512/256 hashing support.]) ] ) AM_CONDITIONAL([ENABLE_SHA512_256], [[test "x${enable_sha512_256}" = "xyes"]]) AC_MSG_RESULT([[${enable_sha512_256_MSG}]]) AS_IF([test "x$enable_dauth" != "xno"], [ AS_IF([test "x${enable_md5}" = "xno" && test "x${enable_sha256}" = "xno" && test "x${enable_sha512_256}" != "xyes"], [AC_MSG_ERROR([At least one hashing algorithm must be enabled if Digest Auth is enabled])] ) ] ) AC_CACHE_CHECK([[for calloc()]], [[mhd_cv_have_func_calloc]], [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include ]],[[void * ptr = calloc(1, 2); if (ptr) return 1;]]) ], [[mhd_cv_have_func_calloc='yes']], [[mhd_cv_have_func_calloc='no']] ) ] ) AS_VAR_IF([[mhd_cv_have_func_calloc]], [["yes"]], [AC_DEFINE([[HAVE_CALLOC]], [[1]], [Define to 1 if you have the usable `calloc' function.])]) # Some systems have IPv6 disabled in kernel at run-time AS_IF([[test "x${mhd_cv_have_inet6}" = "xyes" && test "x${cross_compiling}" = "xno"]], [ AC_CACHE_CHECK([whether IPv6 could be used for testing],[mhd_cv_ipv6_for_testing], [ AC_RUN_IFELSE( [ AC_LANG_SOURCE([[ #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NETINET_IP_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #ifdef HAVE_NETINET_TCP_H #include #endif static void zr_mem(void *ptr, socklen_t size) { char *mem = ptr; while(size--) {mem[0] = 0; mem++;} } int main(void) { int ret = 30; struct sockaddr_in6 sa; #if !defined(_WIN32) || defined(__CYGWIN__) int sckt; const int invld_sckt = -1; #else SOCKET sckt; const SOCKET invld_sckt = INVALID_SOCKET; WSADATA wsa_data; WSAStartup(MAKEWORD(2, 2), &wsa_data); #endif zr_mem(&sa, sizeof(sa)); sa.sin6_family = AF_INET6; sa.sin6_port = 0; sa.sin6_addr = in6addr_loopback; #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN sa.sin6_len = sizeof(sa); #endif sckt = socket (PF_INET6, SOCK_STREAM, 0); if (invld_sckt != sckt) { if (0 == bind (sckt, (struct sockaddr *)&sa, sizeof(sa))) { if (0 == listen (sckt, 1)) ret = 0; else ret = 1; /* listen() failed */ } else ret = 2; /* bind() failed */ #if !defined(_WIN32) || defined(__CYGWIN__) close (sckt); #else closesocket (sckt); #endif } else ret = 3; /* socket() failed */ #if defined(_WIN32) && !defined(__CYGWIN__) WSACleanup(); #endif return ret; } ]]) ], [[mhd_cv_ipv6_for_testing="yes"]], [[mhd_cv_ipv6_for_testing="no"]], [[mhd_cv_ipv6_for_testing="no"]] ) ] ) ] ) AS_VAR_IF([mhd_cv_ipv6_for_testing],["yes"], [AC_DEFINE([[USE_IPV6_TESTING]], [[1]], [Define to 1 if your kernel supports IPv6 and IPv6 is enabled and useful for testing.])] ) AS_VAR_IF([enable_tools],["yes"], [ AC_CHECK_HEADERS([features.h sys/pstat.h vxCpuLib.h],[],[],[AC_INCLUDES_DEFAULT]) AC_CHECK_DECLS( [_SC_NPROCESSORS_ONLN,_SC_NPROC_ONLN,_SC_CRAY_NCPU,_SC_NPROCESSORS_CONF,CTL_HW,HW_NCPUONLINE,HW_NCPU,HW_AVAILCPU], [],[], [[ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_SYSCTL_H #include #endif /* HAVE_SYS_SYSCTL_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ ]] ) MHD_CHECK_FUNC([pstat_getdynamic],[[ #include #include ]], [[ struct pst_dynamic psd_data; i][f (1 != pstat_getdynamic(&psd_data, sizeof(psd_data), (size_t)1, 0)) return 2; i][f (0 >= psd_data.psd_proc_cnt) return 3; ]] ) MHD_CHECK_FUNC([vxCpuEnabledGet],[[#include ]], [[ cpuset_t enb_set; enb_set = vxCpuEnabledGet(); (void) enb_set; ]] ) AC_CHECK_HEADERS([sched.h sys/_cpuset.h sys/cpuset.h],[],[],[AC_INCLUDES_DEFAULT]) # glibc / Linux kernel MHD_CHECK_FUNC([getpid],[[ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #include ]], [[ pid_t cur_pid; cur_pid = getpid(); (void) &cur_pid; /* Mute possible warning */ ]], [ MHD_CHECK_FUNC([sched_getaffinity],[[ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #include #include ]], [[ cpu_set_t cur_set; i][f (0 != sched_getaffinity(getpid(), sizeof(cur_set), &cur_set)) return 2; i][f (0 == CPU_SET (0, &cur_set)) return 3; /* Actually this could be a valid result */ ]], [ MHD_CHECK_FUNC([CPU_COUNT],[[ #include #include ]], [[ cpu_set_t cur_set; CPU_ZERO(&cur_set); i][f (0 != CPU_COUNT(&cur_set)) return 2; ]], [ MHD_CHECK_FUNC([CPU_COUNT_S],[[ #include #include ]], [[ static const unsigned int set_size_cpus = 2048u; const size_t set_size_bytes = (size_t) CPU_ALLOC_SIZE(set_size_cpus); cpu_set_t *p_set; p_set = CPU_ALLOC(set_size_cpus); i][f (!p_set) return 2; CPU_ZERO_S(set_size_bytes, p_set); i][f (0 != CPU_COUNT_S(set_size_bytes, p_set)) { CPU_FREE(p_set); return 3; } CPU_FREE(p_set); ]], [AC_CHECK_DECLS([CPU_SETSIZE],[],[],[#include ])] ) ] ) ] ) # NetBSD # Should work only with -lrt, but actually works without it. MHD_CHECK_FUNC([sched_getaffinity_np],[[ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #include #include ]], [[ cpuset_t *cpuset_ptr; cpuid_t cpu_num = 0; cpuset_ptr = cpuset_create(); i][f (!cpuset_ptr) return 2; i][f (0 != sched_getaffinity_np(getpid(), cpuset_size(cpuset_ptr), cpuset_ptr)) { cpuset_destroy(cpuset_ptr); return 3; } i][f (0 >= cpuset_isset(cpu_num, cpuset_ptr)) { cpuset_destroy(cpuset_ptr); return 4; /* Actually this could be a valid result */ } cpuset_destroy(cpuset_ptr); ]] ) ] ) # FreeBSD MHD_CHECK_FUNC([cpuset_getaffinity],[[ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #include ]], [[ cpuset_t cur_mask; i][f (0 != cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, (id_t) -1, sizeof(cur_mask), &cur_mask)) return 2; ]], [ MHD_CHECK_FUNC([CPU_COUNT],[[ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS__CPUSET_H #include #endif /* HAVE_SYS_PARAM_H */ #include ]], [[ cpuset_t test_mask; CPU_ZERO(&test_mask); i][f (0 != CPU_COUNT(&test_mask)) return 2; ]], [ MHD_CHECK_FUNC([CPU_COUNT_S],[[ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS__CPUSET_H #include #endif /* HAVE_SYS_PARAM_H */ #include ]], [[ static const unsigned int max_cpu_num = 2048u; cpuset_t *mask_ptr; mask_ptr = CPU_ALLOC(max_cpu_num); i][f (! mask_ptr) return 2; i][f (0 != cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, (id_t) -1, CPU_ALLOC_SIZE(max_cpu_num), mask_ptr)) { CPU_FREE(mask_ptr); return 3; } i][f (0 == CPU_COUNT_S(CPU_ALLOC_SIZE(max_cpu_num), &test_mask)) { CPU_FREE(mask_ptr); return 4; } CPU_FREE(mask_ptr); ]] ) ] ) ] ) AS_VAR_IF([mhd_cv_func_CPU_COUNT_S],["yes"], [ AC_CACHE_CHECK([whether CPU_COUNT_S() expects max CPU number as 'size' parameter],[mhd_cv_func_cpu_count_s_cpus], [ AS_VAR_IF([cross-compiling],["yes"],[mhd_cv_func_cpu_count_s_cpus="assuming no"], [ AC_LINK_IFELSE( [ AC_LANG_PROGRAM([[ #ifdef HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS__CPUSET_H #include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_CPUSET_H #include #endif /* HAVE_SYS_CPUSET_H */ #ifdef HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_SCHED_H #include #endif /* HAVE_SCHED_H */ #include #ifdef HAVE_SCHED_GETAFFINITY #define TEST_CPUSET_TYPE cpu_set_t #else /* ! HAVE_SCHED_GETAFFINITY */ #define TEST_CPUSET_TYPE cpuset_t #endif /* ! HAVE_SCHED_GETAFFINITY */ ]], [[ TEST_CPUSET_TYPE *p_testset; /* The size of the cpuset that is larger then the test cpuset (in CPUs) */ static const unsigned int testset_size_oversized_cpus = (8 * sizeof(long)) * 1024; const size_t testset_size_oversized_bytes = CPU_ALLOC_SIZE(testset_size_oversized_cpus); /* The size of the test cpuset in number of CPUs */ const unsigned int testset_size_cpus = (unsigned int) testset_size_oversized_bytes; /* The size of the test cpuset in bytes */ const size_t testset_size_bytes = CPU_ALLOC_SIZE(testset_size_cpus); /* The last one CPU in the test set */ const unsigned int test_cpu_num1 = testset_size_cpus - 1; /* The penultimate CPU in the test set */ const unsigned int test_cpu_num2 = testset_size_cpus - 2; /* The CPU numbers that should be cleared */ const unsigned int test_cpu_clear1 = testset_size_cpus - 3; const unsigned int test_cpu_clear2 = testset_size_cpus - 4; unsigned int count_res; int ret = 0; /* Allocate oversize area to ensure that memory outside the buffer is not used */ p_testset = CPU_ALLOC(testset_size_oversized_cpus); if (! p_testset) { fprintf (stderr, "Error allocating memory.\n"); return 99; } /* Set the some CPU numbers and then clear them */ CPU_SET_S(test_cpu_clear1, testset_size_bytes, p_testset); CPU_SET_S(test_cpu_clear2, testset_size_bytes, p_testset); CPU_ZERO_S(testset_size_bytes, p_testset); /* Set two CPUs on */ CPU_SET_S(test_cpu_num1, testset_size_bytes, p_testset); CPU_SET_S(test_cpu_num2, testset_size_bytes, p_testset); count_res = (unsigned int) CPU_COUNT_S(testset_size_bytes, p_testset); if (0 == count_res) { fprintf (stderr, "Full cpuset cannot be read by CPU_COUNT_S() when using the number of bytes as the size parameter.\n"); /* Set the some CPU numbers and then clear them */ CPU_SET_S(test_cpu_clear1, testset_size_cpus, p_testset); CPU_SET_S(test_cpu_clear2, testset_size_cpus, p_testset); CPU_ZERO_S(testset_size_cpus, p_testset); /* Set two CPUs on */ CPU_SET_S(test_cpu_num1, testset_size_cpus, p_testset); CPU_SET_S(test_cpu_num2, testset_size_cpus, p_testset); count_res = (unsigned int) CPU_COUNT_S(testset_size_cpus, p_testset); if (2 == count_res) { fprintf (stderr, "Full cpuset is read by CPU_COUNT_S() only when using the maximum CPU number as the size parameter.\n"); ret = 3; } else { fprintf (stderr, "Wrong result returned by CPU_COUNT_S() when using the maximum CPU number as the size parameter.\n"); fprintf (stderr, "Number of 'enabled' CPUs: 2\n"); fprintf (stderr, "Number of counted CPUs: %u\n", count_res); fprintf (stderr, "CPU_COUNT_S() could be unreliable.\n"); ret = 70; } } else if (2 == count_res) { fprintf (stderr, "Full cpuset is read by CPU_COUNT_S() when using the number of bytes as the size parameter.\n"); } else { fprintf (stderr, "Wrong result returned by CPU_COUNT_S() when using the number of bytes as the size parameter.\n"); fprintf (stderr, "Number of 'enabled' CPUs: 2\n"); fprintf (stderr, "Number of counted CPUs: %u\n", count_res); fprintf (stderr, "CPU_COUNT_S() could be unreliable.\n"); ret = 71; } CPU_FREE(p_testset); if (0 != ret) return ret; ]] ) ], [ AM_RUN_LOG([./conftest$EXEEXT]) count_test_res=$? AS_IF([test $count_test_res -eq 0],[mhd_cv_func_cpu_count_s_cpus="no"], [test $count_test_res -eq 3],[mhd_cv_func_cpu_count_s_cpus="yes"], [ AC_MSG_WARN([Unexpected value returned by CPU_COUNT_S() test program. Please report to ${PACKAGE_BUGREPORT}]) mhd_cv_func_cpu_count_s_cpus="assuming no" ] ) ], [ AC_MSG_WARN([Cannot build CPU_COUNT_S() test program. Please report to ${PACKAGE_BUGREPORT}]) mhd_cv_func_cpu_count_s_cpus="assuming no" ] ) ] ) ] ) AS_VAR_IF([mhd_cv_func_cpu_count_s_cpus],["yes"], [AC_DEFINE([MHD_FUNC_CPU_COUNT_S_GETS_CPUS],[1], [Define to '1' if CPU_COUNT_S() function expects max CPU number as 'size' parameter]) ] ) ] ) ] ) # Check for fork() and waitpid(). They are used for tests. AC_MSG_CHECKING([[for fork()]]) mhd_have_fork_waitpid='no' AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif ]], [[ pid_t p = fork (); if (0 == p) return 1; ]]) ], [ AC_DEFINE([[HAVE_FORK]], [[1]], [Define to 1 if you have the usable `fork' function.]) AC_MSG_RESULT([[yes]]) AC_MSG_CHECKING([[for waitpid()]]) AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [[ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #include ]], [[ pid_t p = fork (); if (0 == p) return 1; waitpid (p, (void*)0, 0) ]]) ], [ AC_DEFINE([[HAVE_WAITPID]], [[1]], [Define to 1 if you have the usable `waitpid' function.]) AC_MSG_RESULT([[yes]]) mhd_have_fork_waitpid='yes' ],[ AC_MSG_RESULT([[no]]) ]) ],[ AC_MSG_RESULT([[no]]) ]) AM_CONDITIONAL([HAVE_FORK_WAITPID], [test "x$mhd_have_fork_waitpid" = "xyes"]) # gcov compilation AC_MSG_CHECKING(whether to compile with support for code coverage analysis) AC_ARG_ENABLE([coverage], AS_HELP_STRING([--enable-coverage], [compile the library with code coverage support]), [use_gcov=${enableval}], [use_gcov=no]) AC_MSG_RESULT($use_gcov) AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"]) AX_COUNT_CPUS AC_SUBST([MHD_REAL_CPU_COUNT],[${CPU_COUNT}]) AM_SUBST_NOTMAKE([MHD_REAL_CPU_COUNT]) AC_MSG_CHECKING([for number of CPU cores to use in tests]) AS_VAR_IF([use_heavy_tests], ["yes"], [ # Enable usage of many core if heavy tests are enabled AS_IF([[test "$CPU_COUNT" -gt "32"]], [[CPU_COUNT="32"]])dnl Limit resource usage ], [ # Limit usage to just a few cores if heavy tests are not enabled AS_IF([[test "$CPU_COUNT" -gt "6"]], [[CPU_COUNT="6"]]) AS_IF([[test "$CPU_COUNT" -lt "2"]], [[CPU_COUNT="2"]]) ] ) AC_MSG_RESULT([$CPU_COUNT]) AC_ARG_ENABLE([[asserts]], [AS_HELP_STRING([[--enable-asserts]], [enable test build with debug asserts])], [], [enable_asserts='auto'] ) AS_UNSET([use_asserts_MSG]) AC_CACHE_CHECK([[whether NDEBUG macro is defined]], [mhd_cv_macro_ndebug_def], [ AC_LINK_IFELSE( [ AC_LANG_SOURCE([[ #ifndef NDEBUG #error NDEBUG is NOT defined chome me now #endif int main(void) { return 0; } ]] ) ], [[mhd_cv_macro_ndebug_def='yes']], [[mhd_cv_macro_ndebug_def='no']] ) ] ) AS_VAR_IF([enable_asserts],["yes"], [ AS_VAR_IF([mhd_cv_macro_ndebug_def],["yes"], [ AC_MSG_FAILURE([Parameter --enable-asserts is specified, but NDEBUG macro is defined as well]) ] ) use_asserts_MSG="yes, enabled by configure parameter" ] ) AC_CACHE_CHECK([[whether _DEBUG macro is defined]], [mhd_cv_macro__debug_def], [ AC_LINK_IFELSE( [ AC_LANG_SOURCE([[ #ifndef _DEBUG #error _DEBUG is NOT defined chome me now #endif int main(void) { return 0; } ]] ) ], [[mhd_cv_macro__debug_def='yes']], [[mhd_cv_macro__debug_def='no']] ) ] ) AS_VAR_IF([enable_asserts],["no"], [ AS_VAR_IF([mhd_cv_macro__debug_def],["yes"], [ AC_MSG_FAILURE([Parameter --disable-asserts is specified, but _DEBUG macro is defined as well]) ] ) use_asserts_MSG="no, set by configure parameter" ] ) AS_IF([test "x${mhd_cv_macro_ndebug_def}" = "xyes" && test "x${mhd_cv_macro__debug_def}" = "xyes"], [AC_MSG_FAILURE([Both NDEBUG and _DEBUG macros are defined])] ) AS_VAR_IF([enable_asserts],["auto"], [ AS_VAR_IF([mhd_cv_macro_ndebug_def],["yes"], [ enable_asserts="no" use_asserts_MSG="no, set by NDEBUG preprocessor macro" ] ) ] ) AS_VAR_IF([enable_asserts],["auto"], [ AS_VAR_IF([mhd_cv_macro__debug_def],["yes"], [ enable_asserts="yes" use_asserts_MSG="yes, enabled by _DEBUG preprocessor macro" ] ) ] ) AS_VAR_IF([enable_asserts],["auto"], [ AC_CACHE_CHECK([[whether DEBUG macro is defined]], [mhd_cv_macro_debug_def], [ AC_LINK_IFELSE( [ AC_LANG_SOURCE([[ #ifndef DEBUG #error DEBUG is NOT defined chome me now #endif int main(void) { return 0; } ]] ) ], [[mhd_cv_macro_debug_def='yes']], [[mhd_cv_macro_debug_def='no']] ) ] ) AS_VAR_IF([mhd_cv_macro_debug_def],["yes"], [ enable_asserts="yes" use_asserts_MSG="yes, enabled by DEBUG preprocessor macro" ] ) ] ) AC_MSG_CHECKING([[whether to enable debug asserts]]) AS_VAR_IF([enable_asserts],["auto"], [ AS_CASE([${enable_build_type}], [debug|debugger], [ enable_asserts="yes" use_asserts_MSG="yes, enabled by --enable-bulid-type=${enable_build_type}" ], [ enable_asserts="no" use_asserts_MSG="no" ] ) ] ) AS_CASE([[$enable_asserts]], [[yes]], [[:]], [[no]], [[:]], [[enable_asserts='no']]) AC_MSG_RESULT([[${use_asserts_MSG=no}]]) AS_VAR_IF([[enable_asserts]], [["yes"]], [ AS_VAR_IF([[mhd_cv_macro__debug_def]], [["yes"]], [:], [ MHD_PREPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-D_DEBUG=1]) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" ] ) AC_CACHE_CHECK([[whether system assert() is available]], [mhd_cv_sys_assert_avail], [ AC_LINK_IFELSE( [ AC_LANG_SOURCE([[ #include static int pos_val(void) {return 5;} static int neg_val(void) {return -5;} int main(void) { int pos_var = pos_val(), neg_var = neg_val(); assert(neg_var > pos_var); /* Must trigger assert. */ return pos_var + neg_var; } ]]) ], [[mhd_cv_sys_assert_avail='yes']], [[mhd_cv_sys_assert_avail='no']] ) ] ) AS_VAR_IF([[mhd_cv_sys_assert_avail]], [["no"]], [], [AC_DEFINE([[HAVE_ASSERT]], [[1]], [Define if you have usable assert() and assert.h])]) ], [ AS_VAR_IF([[mhd_cv_macro_ndebug_def]], [["yes"]], [:], [ MHD_PREPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DNDEBUG=1]) CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}" ] ) ] ) AS_UNSET([enabled_sanitizers]) TESTS_ENVIRONMENT_ac="" AM_ASAN_OPTIONS="" AM_UBSAN_OPTIONS="" AM_LSAN_OPTIONS="" AS_UNSET([ASAN_OPTIONS]) AS_UNSET([UBSAN_OPTIONS]) AS_UNSET([LSAN_OPTIONS]) AC_MSG_CHECKING([whether to enable run-time sanitizers]) AC_ARG_ENABLE([sanitizers], [AS_HELP_STRING([[--enable-sanitizers[=address,undefined,leak,user-poison]]], [enable run-time sanitizers, specify the list of types of sanitizers to enable, ] [leave the list empty (or set to "auto") to enable all supported and available ] [sanitizers, or specify "auto-fallback" to use sanitizers even without ] [installed sanitizer run-time library])], [], [AS_CASE([${enable_build_type}],[debug], [enable_sanitizers='auto-optional'],[enable_sanitizers='no'])] ) AS_IF([test "x${enable_sanitizers}" = "x"], [enable_sanitizers="auto"]) AS_VAR_IF([enable_sanitizers], ["yes"], [enable_sanitizers="auto"]) AS_VAR_IF([enable_sanitizers], ["autofallback"], [enable_sanitizers="auto-fallback"]) AS_VAR_IF([enable_sanitizers], ["autooptional"], [enable_sanitizers="auto-optional"]) AS_IF([test "x${enable_sanitizers}" = "xno"], [ enable_sanitizers="no" enable_san_address="no" enable_san_undef="no" enable_san_leak="no" enable_san_upoison="no" ], [test "x${enable_sanitizers}" = "xauto" || test "x${enable_sanitizers}" = "xauto-optional"], [ AS_VAR_IF([enable_compiler_hardening],["yes"], [ AS_VAR_IF([enable_sanitizers],["auto"], [AC_MSG_ERROR([sanitizers cannot be enabled with compiler hardnening])], [AC_MSG_WARN([sanitizers cannot be enabled with compiler hardnening])] ) enable_sanitizers="no" enable_san_address="no" enable_san_undef="no" enable_san_leak="no" enable_san_upoison="no" ], [ enable_san_address="auto" enable_san_undef="auto" enable_san_leak="auto" enable_san_upoison="auto" ] ) ], [test "x${enable_sanitizers}" = "xauto-fallback"], [ enable_san_address="auto" enable_san_undef="auto-fallback" enable_san_leak="auto" enable_san_upoison="auto" ], [ AS_UNSET([san]) enable_san_address="no" enable_san_undef="no" enable_san_leak="no" enable_san_upoison="no" f][or san in `AS_ECHO([${enable_sanitizers}]) | tr ',' ' '` do AS_CASE([$san], [address], [enable_san_address="yes"], [undefined], [enable_san_undef="yes"], [leak], [enable_san_leak="yes"], [user-poison|user_poison], [enable_san_upoison="yes"], [no|yes|auto|auto-fallback|autofallback], [AC_MSG_ERROR(["$san" cannot be used with other options for --enable-sanitizers=])], [AC_MSG_ERROR([Unknown parameter "$san" for --enable-sanitizers=])] ) done AS_IF([test "x${enable_san_upoison}" = "xyes" && test "x${enable_san_address}" = "xno"], [AC_MSG_ERROR([User memory poisoning cannot be used without address sanitizer])] ) enable_sanitizers="selected" ] ) AS_CASE([${enable_sanitizers}], [selected], [AC_MSG_RESULT([selected])], [auto], [AC_MSG_RESULT([yes, detect and use supported sanitizers])], [auto-fallback], [AC_MSG_RESULT([yes, detect and use supported sanitizers even without run-time lib])], [auto-optional], [AC_MSG_RESULT([yes, detect and use supported sanitizers if any])], [AC_MSG_RESULT([no])] ) AS_VAR_IF([enable_sanitizers], ["no"], [:], [ AS_UNSET([san_FLAGS]) # the sanitizer flags to be added to both CFLAGS and LDFLAGS AS_UNSET([san_CFLAGS]) # the sanitizer flags to be added to CFLAGS AC_CACHE_CHECK([whether '-fsanitize=' works for $CC], [mhd_cv_cc_sanitizer_works], [ CFLAGS="${CFLAGS_ac} -fsanitize=wrongFeatureName ${user_CFLAGS}" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [mhd_cv_cc_sanitizer_works=no], [mhd_cv_cc_sanitizer_works=yes]) ] ) AS_VAR_IF([mhd_cv_cc_sanitizer_works], ["yes"], [ AS_VAR_IF([enable_san_address], ["no"], [:], [ AC_CACHE_CHECK([for address sanitizer], [mhd_cv_cc_sanitizer_address], [ CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=address ${user_CFLAGS}" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [mhd_cv_cc_sanitizer_address=yes], [mhd_cv_cc_sanitizer_address=no]) ] ) AS_VAR_IF([mhd_cv_cc_sanitizer_address],["yes"], [ AC_DEFINE([MHD_ASAN_ACTIVE], [1], [Define to '1' if you have address sanitizer enabled]) AX_APPEND_FLAG([-fsanitize=address], [san_FLAGS]) enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }address" AS_VAR_IF([enable_san_leak], ["no"], [:], [ AC_CACHE_CHECK([whether leak detect is not rejected by address sanitizer], [mhd_cv_cc_sanitizer_address_leak], [ CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${user_CFLAGS}" ASAN_OPTIONS="exitcode=88:detect_leaks=1:halt_on_error=1" export ASAN_OPTIONS AC_RUN_IFELSE([AC_LANG_PROGRAM([],[])], [mhd_cv_cc_sanitizer_address_leak=yes], [mhd_cv_cc_sanitizer_address_leak=no], [ # Cross-compiling with sanitizers? mhd_cv_cc_sanitizer_address_leak='assuming no' ] ) AS_UNSET([ASAN_OPTIONS]) ] ) ] ) AC_CACHE_CHECK([for pointer compare sanitizer], [mhd_cv_cc_sanitizer_pointer_compare], [ CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-compare ${user_CFLAGS}" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [mhd_cv_cc_sanitizer_pointer_compare=yes], [mhd_cv_cc_sanitizer_pointer_compare=no]) ] ) AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_compare],["yes"], [ AX_APPEND_FLAG([-fsanitize=pointer-compare], [san_FLAGS]) enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer compare" ] ) AC_CACHE_CHECK([for pointer subtract sanitizer], [mhd_cv_cc_sanitizer_pointer_subtract], [ CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} -fsanitize=pointer-subtract ${user_CFLAGS}" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [mhd_cv_cc_sanitizer_pointer_subtract=yes], [mhd_cv_cc_sanitizer_pointer_subtract=no]) ] ) AS_VAR_IF([mhd_cv_cc_sanitizer_pointer_subtract],["yes"], [ AX_APPEND_FLAG([-fsanitize=pointer-subtract], [san_FLAGS]) enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }pointer subtract" ] ) AS_VAR_IF([enable_san_upoison], ["no"], [:], [ AC_CHECK_HEADERS([sanitizer/asan_interface.h], [], [], [AC_INCLUDES_DEFAULT]) AS_VAR_IF([ac_cv_header_sanitizer_asan_interface_h],["yes"], [ CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}" MHD_CHECK_FUNC([__asan_address_is_poisoned],[[#include ]], [[int a_var=1; i][f(__asan_address_is_poisoned((void*) &a_var)) return 3;]] ) MHD_CHECK_FUNC([__asan_region_is_poisoned],[[#include ]], [[int a_var=1; i][f(((void*) 0) != __asan_region_is_poisoned((void*) &a_var, sizeof(a_var))) return 3;]] ) AC_CACHE_CHECK([whether special function attribute is needed for user-poison], [mhd_cv_func_u_p_attribute_needed], [ ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1" export ASAN_OPTIONS CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}" AC_RUN_IFELSE( [ AC_LANG_SOURCE( [[ #include #include #include static const size_t first_pos = 0; static const size_t mid_pos = 64; static const size_t last_pos = 128; static const size_t zone_size = 16; static const size_t buf_size = 128 + 16; static int ptr_compare(void *ptr1, uint8_t *ptr2) { if ((((uintptr_t) (uint8_t *)ptr1) >= ((uintptr_t)ptr2))) return ((char *) ptr1)[0] < ((char *) ptr2)[0]; return ((char *) ptr1)[0] > ((char *) ptr2)[0]; } static int ptr_subtract(void *ptr1, uint8_t *ptr2) { return ((size_t)(((uintptr_t)(uint8_t*)ptr1) - ((uintptr_t)ptr2))) <= last_pos; } int main(int argc, char *argv[]) { char *buf = (char*) malloc (buf_size); char *a; char *b; int ret; (void) argv; if (NULL == buf) return 10; ASAN_POISON_MEMORY_REGION (buf + first_pos + zone_size, mid_pos - first_pos - zone_size); ASAN_POISON_MEMORY_REGION (buf + mid_pos + zone_size, last_pos - mid_pos - zone_size); if (0 < argc) a = buf + last_pos; else a = buf + first_pos; b = buf + mid_pos; *a = '0'; *b = '9'; if (ptr_compare((void *)a, (uint8_t*) b)) { if (ptr_subtract((void *)a, (uint8_t*) b)) ret = 0; else ret = 10; } else ret = 5; ASAN_UNPOISON_MEMORY_REGION (buf, buf_size); free (buf); return ret; } ]] ) ], [mhd_cv_func_u_p_attribute_needed="no"], [mhd_cv_func_u_p_attribute_needed="yes"], [ # Cross-compiling with sanitizers?? mhd_cv_func_up_attribute_needed='assuming no' ] ) AS_UNSET([ASAN_OPTIONS]) ] ) ] ) AS_VAR_IF([mhd_cv_func_u_p_attribute_needed],["yes"],[:], [ AC_DEFINE([FUNC_PTRCOMPARE_CAST_WORKAROUND_WORKS],[1],[Define to '1' if cast to 'uintptr_t' works for safely processing user-poisoned pointer]) ] ) AS_IF([test "x${mhd_cv_func_u_p_attribute_needed}" = "xyes" && test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes"], [ AC_CACHE_CHECK([whether '__attribute__((no_sanitize("pointer-compare")))' and '__attribute__((no_sanitize("pointer-subtract")))' work], [mhd_cv_func_attribute_nosanitize_ptr], [ ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1" export ASAN_OPTIONS CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}" AC_RUN_IFELSE( [ AC_LANG_SOURCE( [[ #include #include #include static const size_t first_pos = 0; static const size_t mid_pos = 64; static const size_t last_pos = 128; static const size_t zone_size = 16; static const size_t buf_size = 128 + 16; __attribute__((no_sanitize("pointer-compare"))) static int ptr_compare(void *ptr1, uint8_t *ptr2) { if ((((const uint8_t*)ptr1) >= ((const uint8_t*)ptr2))) return ((char *) ptr1)[0] < ((char *) ptr2)[0]; return ((char *) ptr1)[0] > ((char *) ptr2)[0]; } __attribute__((no_sanitize("pointer-subtract"))) static int ptr_subtract(void *ptr1, uint8_t *ptr2) { return ((size_t)(((const uint8_t*)ptr1) - \ ((const uint8_t*)ptr2))) <= last_pos; } int main(int argc, char *argv[]) { char *buf = (char*) malloc (buf_size); char *a; char *b; int ret; (void) argv; if (NULL == buf) return 10; ASAN_POISON_MEMORY_REGION (buf + first_pos + zone_size, mid_pos - first_pos - zone_size); ASAN_POISON_MEMORY_REGION (buf + mid_pos + zone_size, last_pos - mid_pos - zone_size); if (0 < argc) a = buf + last_pos; else a = buf + first_pos; b = buf + mid_pos; *a = '0'; *b = '9'; if (ptr_compare((void *)a, (uint8_t*) b)) { if (ptr_subtract((void *)a, (uint8_t*) b)) ret = 0; else ret = 10; } else ret = 5; ASAN_UNPOISON_MEMORY_REGION (buf, buf_size); free (buf); return ret; } ]] ) ], [mhd_cv_func_attribute_nosanitize_ptr=yes], [mhd_cv_func_attribute_nosanitize_ptr=no], [ # Cross-compiling with sanitizers?? mhd_cv_func_attribute_nosanitize_ptr='assuming no' ] ) AS_UNSET([ASAN_OPTIONS]) ] ) AS_VAR_IF([mhd_cv_func_attribute_nosanitize_ptr], ["yes"], [ AC_DEFINE([FUNC_ATTR_PTRCOMPARE_WORKS],[1],[Define to '1' if '__attribute__((no_sanitize("pointer-compare")))' works]) AC_DEFINE([FUNC_ATTR_PTRSUBTRACT_WORKS],[1],[Define to '1' if '__attribute__((no_sanitize("pointer-subtract")))' works]) ], [ AC_CACHE_CHECK([whether '__attribute__((no_sanitize("address")))' works for pointers compare], [mhd_cv_func_attribute_nosanitize_addr], [ ASAN_OPTIONS="exitcode=88:detect_invalid_pointer_pairs=3:halt_on_error=1" export ASAN_OPTIONS CFLAGS="${CFLAGS_ac} ${san_CFLAGS} ${san_FLAGS} ${errattr_CFLAGS} ${user_CFLAGS}" AC_RUN_IFELSE( [ AC_LANG_SOURCE( [[ #include #include #include static const size_t first_pos = 0; static const size_t mid_pos = 64; static const size_t last_pos = 128; static const size_t zone_size = 16; static const size_t buf_size = 128 + 16; __attribute__((no_sanitize("address"))) static int ptr_compare(void *ptr1, uint8_t *ptr2) { if ((((const uint8_t*)ptr1) >= ((const uint8_t*)ptr2))) return ((char *) ptr1)[0] < ((char *) ptr2)[0]; return ((char *) ptr1)[0] > ((char *) ptr2)[0]; } __attribute__((no_sanitize("address"))) static int ptr_subtract(void *ptr1, uint8_t *ptr2) { return ((size_t)(((const uint8_t*)ptr1) - \ ((const uint8_t*)ptr2))) <= last_pos; } int main(int argc, char *argv[]) { char *buf = (char*) malloc (buf_size); char *a; char *b; int ret; (void) argv; if (NULL == buf) return 10; ASAN_POISON_MEMORY_REGION (buf + first_pos + zone_size, mid_pos - first_pos - zone_size); ASAN_POISON_MEMORY_REGION (buf + mid_pos + zone_size, last_pos - mid_pos - zone_size); if (0 < argc) a = buf + last_pos; else a = buf + first_pos; b = buf + mid_pos; *a = '0'; *b = '9'; if (ptr_compare((void *)a, (uint8_t*) b)) { if (ptr_subtract((void *)a, (uint8_t*) b)) ret = 0; else ret = 10; } else ret = 5; ASAN_UNPOISON_MEMORY_REGION (buf, buf_size); free (buf); return ret; } ]] ) ], [mhd_cv_func_attribute_nosanitize_addr=yes], [mhd_cv_func_attribute_nosanitize_addr=no], [ # Cross-compiling with sanitizers?? mhd_cv_func_attribute_nosanitize_addr='assuming no' ] ) AS_UNSET([ASAN_OPTIONS]) ] ) AS_VAR_IF([mhd_cv_func_attribute_nosanitize_addr], ["yes"], [AC_DEFINE([FUNC_ATTR_NOSANITIZE_WORKS],[1],[Define to '1' if '__attribute__((no_sanitize("address")))' works for pointers compare])] ) ] ) ] ) ] ) ] ) AS_IF([test "x${enable_san_address}" = "xyes" && test "x${mhd_cv_cc_sanitizer_address}" != "xyes"], [AC_MSG_ERROR([Address sanitizer cannot be enabled])] ) enable_san_address="${mhd_cv_cc_sanitizer_address}" ] ) AS_VAR_IF([enable_san_undef], ["no"], [:], [ dnl Ensure that '#' will be processed correctly [ test_undf_prog=' #include static void func_out_b(char *arr) { arr[0] = 0; arr[16] = 2; } static unsigned int int_deref(void *ptr) { return (*((unsigned int*)ptr)) + 2; } static int func1(void) { char chr[16]; func_out_b (chr); return (int) (int_deref(chr + 1) + int_deref(chr + 2)); } int main(void) { unsigned long ulvar; signed char ch1; ulvar = -1 * func1(); ch1 = ulvar * 6UL; printf("%lu\n", ulvar + ch1); return 0; } ' ] AC_CACHE_CHECK([for undefined behavior sanitizer], [mhd_cv_cc_sanitizer_undefined], [ CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined ${user_CFLAGS}" AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])], [mhd_cv_cc_sanitizer_undefined=yes], [mhd_cv_cc_sanitizer_undefined=no]) ] ) AS_VAR_IF([mhd_cv_cc_sanitizer_undefined],["yes"], [ AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS]) enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined" ], [ AS_CASE([${enable_san_undef}], [yes|auto-fallback], [ AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-undefined-trap-on-error'], [mhd_cv_cc_sanitizer_undefined_trap], [ CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-undefined-trap-on-error ${user_CFLAGS}" AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])], [mhd_cv_cc_sanitizer_undefined_trap=yes], [mhd_cv_cc_sanitizer_undefined_trap=no]) ] ) AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap], ["yes"], [ AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS]) AX_APPEND_FLAG([-fsanitize-undefined-trap-on-error], [san_FLAGS]) enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined" AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited]) ], [ AS_IF([test -z "${enabled_sanitizers}"], [ # Last resort AC_CACHE_CHECK([for undefined behavior sanitizer with '-fsanitize-trap=all'], [mhd_cv_cc_sanitizer_undefined_trap_all], [ CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all ${user_CFLAGS}" AC_LINK_IFELSE([AC_LANG_SOURCE([${test_undf_prog}])], [mhd_cv_cc_sanitizer_undefined_trap_all=yes], [mhd_cv_cc_sanitizer_undefined_trap_all=no]) ] ) AS_VAR_IF([mhd_cv_cc_sanitizer_undefined_trap_all],["yes"], [ AX_APPEND_FLAG([-fsanitize=undefined], [san_FLAGS]) AX_APPEND_FLAG([-fsanitize-trap=all], [san_FLAGS]) CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=undefined -fsanitize-trap=all ${user_CFLAGS}" enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }undefined" AC_MSG_WARN([Enabled sanitizer without run-time library, error reporting will be limited]) ] ) ] ) ] ) AS_CASE(["$enabled_sanitizers"], [*undefined], [ AS_VAR_IF([mhd_cv_cc_sanitizer_undefined], ["yes"],[], [ # A workaround for broken clang which is trying to use UBSan lib # even when instructed to not use it CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}" AX_APPEND_LINK_FLAGS([-fsanitize-trap=implicit-conversion], [san_FLAGS], [], [AC_LANG_SOURCE([${test_undf_prog}])]) ] ) ] ) ] ) ] ) AS_CASE(["$enabled_sanitizers"], [*undefined], [ CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}" AX_APPEND_LINK_FLAGS([-fsanitize=bounds-strict -fsanitize=local-bounds -fsanitize=implicit-conversion -fsanitize=nullability-arg], [san_CFLAGS], [], [AC_LANG_SOURCE([${test_undf_prog}])]) ] ) AS_UNSET([test_undf_prog]) AS_CASE(["$enabled_sanitizers"], [*undefined], [enable_san_undef="yes"], [ AS_VAR_IF([enable_san_undef], [yes], [AC_MSG_ERROR([Undefined behavior sanitizer cannot be enabled])]) enable_san_undef="no" ] ) ] ) AS_VAR_IF([enable_san_leak], ["no"], [:], [ AC_CACHE_CHECK([for leak sanitizer], [mhd_cv_cc_sanitizer_leak], [ CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} -fsanitize=leak ${user_CFLAGS}" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [mhd_cv_cc_sanitizer_leak=yes], [mhd_cv_cc_sanitizer_leak=no]) ] ) AS_VAR_IF([mhd_cv_cc_sanitizer_leak],["yes"], [ AX_APPEND_FLAG([-fsanitize=leak], [san_FLAGS]) enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }leak" ] ) AS_IF([test "x${enable_san_leak}" = "xyes" && test "x${mhd_cv_cc_sanitizer_leak}" != "xyes"], [AC_MSG_ERROR([User poison cannot be enabled])] ) enable_san_leak="${mhd_cv_cc_sanitizer_leak}" ] ) AS_IF([test -z "${enabled_sanitizers}"], [ AS_VAR_IF([enable_sanitizers], ["auto-optional"], [ san_FLAGS="" san_CFLAGS="" ], [ AC_MSG_ERROR([cannot find any sanitizer supported by $CC]) ] ) ], [ AS_VAR_IF([enable_san_upoison], ["no"], [:], [ AC_MSG_CHECKING([whether to enable user memory poisoning]) AS_IF([test "x${mhd_cv_cc_sanitizer_address}" = "xyes" && test "x${ac_cv_header_sanitizer_asan_interface_h}" = "xyes" && \ (test "x${mhd_cv_func_u_p_attribute_needed}" != "xyes" || test "x${mhd_cv_func_attribute_nosanitize_ptr}" = "xyes" || \ test "x${mhd_cv_func_attribute_nosanitize_addr}" = "xyes")], [ AC_DEFINE([MHD_ASAN_POISON_ACTIVE], [1], [Define to '1' if user memory poison is used]) enabled_sanitizers="${enabled_sanitizers}${enabled_sanitizers:+, }user-poison" enable_san_upoison="yes" AC_MSG_RESULT([yes]) ], [ AC_MSG_RESULT([no]) AS_VAR_IF([enable_san_upoison], ["yes"], [AC_MSG_ERROR([User memory poisoning cannot be enabled])]) enable_san_upoison="no" ] ) ] ) AS_VAR_IF([enable_san_address], ["yes"], [ CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}" AC_CHECK_DECL([_FORTIFY_SOURCE], [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-U_FORTIFY_SOURCE])], [],[/* no includes */]) AX_APPEND_FLAG([-D_FORTIFY_SOURCE=0], [san_CFLAGS]) ], [ AS_CASE([$enable_sanitizers], [auto|auto-fallback], [AC_MSG_WARN([$CC does not support address sanitizer])]) ] ) CFLAGS="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS} ${user_CFLAGS}" # Always stop on sanitizer error AX_APPEND_COMPILE_FLAGS([-fno-sanitize-recover=all], [san_CFLAGS]) # Get a better output for sanitizers error reporting AX_APPEND_COMPILE_FLAGS([-fno-omit-frame-pointer -fno-optimize-sibling-calls], [san_CFLAGS]) AS_VAR_IF([enable_san_address], ["yes"], [ AM_ASAN_OPTIONS="exitcode=88:strict_string_checks=1:detect_stack_use_after_return=1" AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:check_initialization_order=1:strict_init_order=1:redzone=64" AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:max_free_fill_size=1024:detect_invalid_pointer_pairs=3" AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:handle_ioctl=1:halt_on_error=1" AS_VAR_IF([enable_san_upoison], ["yes"], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:allow_user_poisoning=1"]) AS_VAR_IF([enable_san_leak], ["yes"], [AS_VAR_IF([mhd_cv_cc_sanitizer_address_leak], ["yes"], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=1"]) ], [AM_ASAN_OPTIONS="${AM_ASAN_OPTIONS}:detect_leaks=0"] ) ] ) AS_VAR_IF([enable_san_undef], [yes], [AM_UBSAN_OPTIONS="exitcode=87:print_stacktrace=1:halt_on_error=1"]) AS_VAR_IF([enable_san_leak], ["yes"], [AM_LSAN_OPTIONS="use_unaligned=1"] ) TESTS_ENVIRONMENT_ac='\ ASAN_OPTIONS="$(AM_ASAN_OPTIONS)" ; export ASAN_OPTIONS ; \ UBSAN_OPTIONS="$(AM_UBSAN_OPTIONS)" ; export UBSAN_OPTIONS ; \ LSAN_OPTIONS="$(AM_LSAN_OPTIONS)" ; export LSAN_OPTIONS ;' ] ) ] ) CFLAGS_ac="${CFLAGS_ac} ${san_FLAGS} ${san_CFLAGS}" CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ] ) # fuzzing tests run_zzuf_tests="no" zzuf_socat_mandatory="no" AS_VAR_IF([use_heavy_tests],["yes"], [ AS_VAR_IF([enable_curl],["yes"], [ AC_PATH_PROG([ZZUF],[zzuf],[no]) AS_VAR_IF([ZZUF],["no"], [ run_zzuf_tests="no" run_zzuf_tests_MSG="no, zzuf tool not found" ], [ AC_PATH_PROG([SOCAT],[socat],[no]) AS_IF([test "x${ac_cv_func_accept4}" = "xyes" && test "x${enable_asserts}" = "xno"], [ zzuf_socat_mandatory="yes" AS_VAR_IF([SOCAT],["no"], [run_zzuf_tests_MSG="no, socat not found, but required for fuzzing tests on this platform without asserts enabled"], [ run_zzuf_tests="yes" run_zzuf_tests_MSG="yes, with zzuf and socat tools" ] ) ], [test -n "${enabled_sanitizers}"], [ zzuf_socat_mandatory="yes" AS_VAR_IF([SOCAT],["no"], [run_zzuf_tests_MSG="no, socat not found, but required for fuzzing tests when sanitizers enabled"], [ run_zzuf_tests="yes" run_zzuf_tests_MSG="yes, with zzuf and socat tools" ] ) ], [ run_zzuf_tests="yes" run_zzuf_tests_MSG="yes, with zzuf tool" ] ) ] ) ], [ run_zzuf_tests="no" run_zzuf_tests_MSG="no, tests with libcurl are not enabled" ] ) ], [ run_zzuf_tests="no" run_zzuf_tests_MSG="no, heavy tests are not enabled" ] ) AM_CONDITIONAL([RUN_ZZUF_TESTS],[test "x$run_zzuf_tests" = "xyes"]) AM_CONDITIONAL([FORCE_USE_ZZUF_SOCAT],[test "x$zzuf_socat_mandatory" = "xyes"]) # Final flags that may interfere with autoconf detections AS_CASE([${enable_build_type}],[debug|debugger], [ # Debug build or build for walking with debugger CFLAGS="${user_CFLAGS}" MHD_CHECK_ADD_CC_CFLAGS([-Wextra-semi -Wextra-semi-stmt], [CFLAGS_ac]) CFLAGS="${CFLAGS_ac} ${user_CFLAGS}" ] ) AM_CONDITIONAL([USE_SANITIZERS], [test -n "$enabled_sanitizers" && test "x$mhd_cv_cc_sanitizer_works" = "xyes"]) AC_SUBST([AM_ASAN_OPTIONS]) AC_SUBST([AM_UBSAN_OPTIONS]) AC_SUBST([AM_LSAN_OPTIONS]) AC_SUBST([TESTS_ENVIRONMENT_ac]) MHD_LIB_LDFLAGS="$MHD_LIB_LDFLAGS" AC_SUBST([CPU_COUNT]) AC_SUBST([HEAVY_TESTS_NOTPARALLEL]) AM_SUBST_NOTMAKE([HEAVY_TESTS_NOTPARALLEL]) AC_SUBST(MHD_LIB_CPPFLAGS) AC_SUBST(MHD_LIB_CFLAGS) AC_SUBST(MHD_LIB_LDFLAGS) AC_SUBST(MHD_LIBDEPS) AC_SUBST(MHD_TLS_LIB_CPPFLAGS) AC_SUBST(MHD_TLS_LIB_CFLAGS) AC_SUBST(MHD_TLS_LIB_LDFLAGS) AC_SUBST(MHD_TLS_LIBDEPS) # for pkg-config AC_SUBST([MHD_REQ_PRIVATE]) AC_SUBST([MHD_LIBDEPS_PKGCFG]) # Restore flags as set by the user CFLAGS="${user_CFLAGS}" LDFLAGS="${user_LDFLAGS}" CPPFLAGS="${user_CPPFLAGS}" AC_SUBST([CFLAGS]) AC_SUBST([LDFLAGS]) AC_SUBST([CPPFLAGS]) AC_SUBST([LIBS]) # Configure-defined flags AC_SUBST([CFLAGS_ac]) AC_SUBST([LDFLAGS_ac]) AC_SUBST([CPPFLAGS_ac]) # Used for 'po' directory staff AC_SUBST([ac_configure_args]) AC_SUBST([EMPTY_VAR],[]) AC_SUBST([MHD_AUX_DIR]) AC_CONFIG_FILES([po/po-configure.ac]) AC_CONFIG_COMMANDS([po/Makefile.in], [ echo "Skipping update of po/Makefile.in" echo "Real update of po/Makefile.in for 'make dist' is performed by po-config.status" ] ) AC_CONFIG_COMMANDS([po-directories], [ echo "Skipping po-directories command." echo "Real po-directories command for 'make dist' is implemented in po-config.status" ] ) # We define the paths here, because MinGW/GCC expands paths # passed through the command line ("-DDIR=..."). This would # lead to hard-coded paths ("C:\mingw\mingw\bin...") that do # not contain the actual installation. AC_DEFINE_DIR([MHD_PLUGIN_INSTALL_PREFIX], [libdir/libmicrohttpd], [tls plugins]) AC_SUBST([ZZUF]) AC_SUBST([SOCAT]) # should experimental code be compiled (code that may not yet compile)? AC_MSG_CHECKING(whether to compile experimental code) AC_ARG_ENABLE([experimental], [AS_HELP_STRING([--enable-experimental], [enable compiling experimental code])], [enable_experimental=${enableval}], [enable_experimental=no]) AC_MSG_RESULT($enable_experimental) AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"]) AC_CONFIG_FILES([libmicrohttpd.pc w32/common/microhttpd_dll_res_vc.rc Makefile contrib/Makefile doc/Makefile doc/doxygen/libmicrohttpd.doxy doc/doxygen/Makefile doc/examples/Makefile m4/Makefile src/Makefile src/include/Makefile src/lib/Makefile src/microhttpd/Makefile src/microhttpd_ws/Makefile src/examples/Makefile src/tools/Makefile src/testcurl/Makefile src/testcurl/https/Makefile src/testzzuf/Makefile]) AC_OUTPUT # Finally: summary # Format flags without extra spaces for visual beauty fin_CPPFLAGS="$user_CPPFLAGS" fin_CFLAGS="$user_CFLAGS" fin_LDFLAGS="$user_LDFLAGS" MHD_PREPEND_FLAG_TO_VAR([fin_CPPFLAGS],[$CPPFLAGS_ac]) MHD_PREPEND_FLAG_TO_VAR([fin_CFLAGS],[$CFLAGS_ac]) MHD_PREPEND_FLAG_TO_VAR([fin_LDFLAGS],[$LDFLAGS_ac]) fin_lib_CPPFLAGS="$user_CPPFLAGS" fin_lib_CFLAGS="$user_CFLAGS" fin_lib_LDFLAGS="$user_LDFLAGS" MHD_PREPEND_FLAG_TO_VAR([fin_lib_CPPFLAGS],[$MHD_LIB_CPPFLAGS]) MHD_PREPEND_FLAG_TO_VAR([fin_lib_CFLAGS],[$MHD_LIB_CFLAGS]) MHD_PREPEND_FLAG_TO_VAR([fin_lib_LDFLAGS],[$MHD_LIB_LDFLAGS]) MHD_PREPEND_FLAG_TO_VAR([fin_lib_CPPFLAGS],[$CPPFLAGS_ac]) MHD_PREPEND_FLAG_TO_VAR([fin_lib_CFLAGS],[$CFLAGS_ac]) MHD_PREPEND_FLAG_TO_VAR([fin_lib_LDFLAGS],[$LDFLAGS_ac]) AC_MSG_NOTICE([Toolchain settings: CC=$CC User/system/default flags: CPPFLAGS="$user_CPPFLAGS" CFLAGS= "$user_CFLAGS" LDFLAGS= "$user_LDFLAGS" Final set of the flags for tests and examples: CPPFLAGS="$fin_CPPFLAGS" CFLAGS= "$fin_CFLAGS" LDFLAGS= "$fin_LDFLAGS" Final set of the flags for ${PACKAGE_NAME} library: CPPFLAGS="$fin_lib_CPPFLAGS" CFLAGS= "$fin_lib_CFLAGS" LDFLAGS= "$fin_lib_LDFLAGS" ]) AS_UNSET([fin_CPPFLAGS]) AS_UNSET([fin_CFLAGS]) AS_UNSET([fin_LDFLAGS]) AS_UNSET([fin_lib_CPPFLAGS]) AS_UNSET([fin_lib_CFLAGS]) AS_UNSET([fin_lib_LDFLAGS]) AS_VAR_IF([os_is_windows], ["yes"], [os_ver_msg=" Target W32 ver: ${mhd_w32_ver_msg}"], [AS_UNSET([[os_ver_msg]])]) AC_MSG_NOTICE([GNU libmicrohttpd ${PACKAGE_VERSION} Configuration Summary: Target directory: ${prefix} Cross-compiling: ${cross_compiling} Operating System: ${mhd_host_os}${os_ver_msg} Threading lib: ${USE_THREADS} Inter-thread comm: ${use_itc} Shutdown of listening socket triggers select: ${mhd_cv_host_shtdwn_trgr_select} poll support: ${enable_poll=no} epoll support: ${enable_epoll=no} sendfile used: ${found_sendfile} HTTPS support: ${MSG_HTTPS} Messages: ${enable_messages} Cookie parsing: ${enable_cookie} Postproc: ${enable_postprocessor} Basic auth.: ${enable_bauth} Digest auth.: ${enable_dauth} Digest auth. defaults: ${dauth_defs_MSG} MD5: ${enable_md5_MSG} SHA-256: ${enable_sha256_MSG} SHA-512/256: ${enable_sha512_256_MSG} HTTP "Upgrade": ${enable_httpupgrade} Compact code: ${enable_compact_code} (${compact_code_MSG}) Use thread names: ${enable_thread_names} Use debug asserts: ${use_asserts_MSG=no} Use sanitizers: ${enabled_sanitizers:=no} Build static lib: ${enable_static} Build shared lib: ${enable_shared} Build docs: ${enable_doc} Build examples: ${enable_examples} Build tools: ${enable_examples} Test with libcurl: ${MSG_CURL} Heavy tests: ${use_heavy_tests_MSG} Fuzzing tests: ${run_zzuf_tests_MSG=no} ]) AS_IF([test "x$enable_https" = "xyes"], [AC_MSG_NOTICE([HTTPS subsystem configuration: License : LGPL version 2.1 or any later version ])], [AC_MSG_NOTICE([ License : LGPLv2.1+ or eCos ])]) AS_IF([test "x$enable_bauth" != "xyes" || \ test "x$enable_dauth" != "xyes" || \ test "x${enable_md5}" = "xno" || \ test "x${enable_sha256}" = "xno" || \ test "x${enable_sha512_256}" != "xyes" || \ test "x${USE_THREADS}" = "xnone" || \ test "x$enable_httpupgrade" != "xyes" || \ test "x$enable_cookie" != "xyes" || \ test "x$enable_httpupgrade" != "xyes" || \ test "x$enable_postprocessor" != "xyes"], [AC_MSG_WARN([This will be a custom build with missing symbols. Do NOT use this build in a distribution. Building with these kinds of configure options is only for custom builds for embedded systems.])] ) libmicrohttpd-1.0.1/Makefile.in0000644000175000017500000014124614566140140012114 # Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @BUILD_DOC_TRUE@am__append_1 = doc subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ $(top_srcdir)/m4/ax_append_compile_flags.m4 \ $(top_srcdir)/m4/ax_append_flag.m4 \ $(top_srcdir)/m4/ax_append_link_flags.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ $(top_srcdir)/m4/ax_count_cpus.m4 \ $(top_srcdir)/m4/ax_have_epoll.m4 \ $(top_srcdir)/m4/ax_pthread.m4 \ $(top_srcdir)/m4/ax_require_defined.m4 \ $(top_srcdir)/m4/c_backported.m4 $(top_srcdir)/m4/libcurl.m4 \ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/mhd_append_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_cflags.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflag.m4 \ $(top_srcdir)/m4/mhd_check_add_cc_ldflags.m4 \ $(top_srcdir)/m4/mhd_check_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_check_func.m4 \ $(top_srcdir)/m4/mhd_check_func_gettimeofday.m4 \ $(top_srcdir)/m4/mhd_check_link_run.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag.m4 \ $(top_srcdir)/m4/mhd_find_add_cc_cflag_ifelse.m4 \ $(top_srcdir)/m4/mhd_find_lib.m4 \ $(top_srcdir)/m4/mhd_norm_expd.m4 \ $(top_srcdir)/m4/mhd_prepend_flag_to_var.m4 \ $(top_srcdir)/m4/mhd_shutdown_socket_trigger.m4 \ $(top_srcdir)/m4/mhd_sys_extentions.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ $(am__configure_deps) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = MHD_config.h CONFIG_CLEAN_FILES = po/po-configure.ac libmicrohttpd.pc \ w32/common/microhttpd_dll_res_vc.rc CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkgconfigdir)" DATA = $(pkgconfig_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir distdir-am dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \ MHD_config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` DIST_SUBDIRS = contrib m4 src . doc am__DIST_COMMON = $(srcdir)/MHD_config.h.in $(srcdir)/Makefile.in \ $(srcdir)/libmicrohttpd.pc.in $(top_srcdir)/build-aux/compile \ $(top_srcdir)/build-aux/config.guess \ $(top_srcdir)/build-aux/config.sub \ $(top_srcdir)/build-aux/install-sh \ $(top_srcdir)/build-aux/ltmain.sh \ $(top_srcdir)/build-aux/missing \ $(top_srcdir)/po/po-configure.ac.in \ $(top_srcdir)/w32/common/microhttpd_dll_res_vc.rc.in AUTHORS \ COPYING ChangeLog INSTALL NEWS README build-aux/compile \ build-aux/config.guess build-aux/config.rpath \ build-aux/config.sub build-aux/depcomp build-aux/install-sh \ build-aux/ltmain.sh build-aux/mdate-sh build-aux/missing \ build-aux/texinfo.tex DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip # Exists only to be overridden by the user if desired. AM_DISTCHECK_DVI_TARGET = dvi distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_ASAN_OPTIONS = @AM_ASAN_OPTIONS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LSAN_OPTIONS = @AM_LSAN_OPTIONS@ AM_UBSAN_OPTIONS = @AM_UBSAN_OPTIONS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CFLAGS_ac = @CFLAGS_ac@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CPPFLAGS_ac = @CPPFLAGS_ac@ CPU_COUNT = @CPU_COUNT@ CSCOPE = @CSCOPE@ CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EMPTY_VAR = @EMPTY_VAR@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FILECMD = @FILECMD@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_CPPFLAGS = @GNUTLS_CPPFLAGS@ GNUTLS_LDFLAGS = @GNUTLS_LDFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_CURL_BINARY = @HAVE_CURL_BINARY@ HAVE_MAKEINFO_BINARY = @HAVE_MAKEINFO_BINARY@ HIDDEN_VISIBILITY_CFLAGS = @HIDDEN_VISIBILITY_CFLAGS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LDFLAGS_ac = @LDFLAGS_ac@ LIBCURL = @LIBCURL@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIB_VERSION_AGE = @LIB_VERSION_AGE@ LIB_VERSION_CURRENT = @LIB_VERSION_CURRENT@ LIB_VERSION_REVISION = @LIB_VERSION_REVISION@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MHD_AUX_DIR = @MHD_AUX_DIR@ MHD_LIBDEPS = @MHD_LIBDEPS@ MHD_LIBDEPS_PKGCFG = @MHD_LIBDEPS_PKGCFG@ MHD_LIB_CFLAGS = @MHD_LIB_CFLAGS@ MHD_LIB_CPPFLAGS = @MHD_LIB_CPPFLAGS@ MHD_LIB_LDFLAGS = @MHD_LIB_LDFLAGS@ MHD_PLUGIN_INSTALL_PREFIX = @MHD_PLUGIN_INSTALL_PREFIX@ MHD_REQ_PRIVATE = @MHD_REQ_PRIVATE@ MHD_TLS_LIBDEPS = @MHD_TLS_LIBDEPS@ MHD_TLS_LIB_CFLAGS = @MHD_TLS_LIB_CFLAGS@ MHD_TLS_LIB_CPPFLAGS = @MHD_TLS_LIB_CPPFLAGS@ MHD_TLS_LIB_LDFLAGS = @MHD_TLS_LIB_LDFLAGS@ MHD_W32_DLL_SUFF = @MHD_W32_DLL_SUFF@ MKDIR_P = @MKDIR_P@ MS_LIB_TOOL = @MS_LIB_TOOL@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ PACKAGE_VERSION_SUBMINOR = @PACKAGE_VERSION_SUBMINOR@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_CXX = @PTHREAD_CXX@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SOCAT = @SOCAT@ STRIP = @STRIP@ TESTS_ENVIRONMENT_ac = @TESTS_ENVIRONMENT_ac@ VERSION = @VERSION@ W32CRT = @W32CRT@ ZZUF = @ZZUF@ _libcurl_config = @_libcurl_config@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_configure_args = @ac_configure_args@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ lt_cv_objdir = @lt_cv_objdir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # This Makefile.am is in the public domain ACLOCAL_AMFLAGS = -I m4 SUBDIRS = contrib m4 src . $(am__append_1) W32COMMON = w32/common/gen_dll_res.ps1 w32/common/microhttpd_dll_res_vc.rc.in w32/common/microhttpd_dll_res_vc.rc \ w32/common/MHD_config.h w32/common/vs_dirs.props \ w32/common/common-build-settings.props w32/common/libmicrohttpd-build-settings.props \ w32/common/apps-build-settings.props \ w32/common/project-configs.props w32/common/project-configs-xp.props \ w32/common/libmicrohttpd-files.vcxproj w32/common/libmicrohttpd-filters.vcxproj \ w32/common/hellobrowser-files.vcxproj w32/common/hellobrowser-filters.vcxproj W32VS2013 = w32/VS2013/libmicrohttpd.vcxproj w32/VS2013/libmicrohttpd.vcxproj.filters \ w32/VS2013/hellobrowser.vcxproj w32/VS2013/hellobrowser.vcxproj.filters \ w32/VS2013/simplepost.vcxproj w32/VS2013/largepost.vcxproj \ w32/VS2013/libmicrohttpd.sln W32VS2015 = w32/VS2015/libmicrohttpd.vcxproj w32/VS2015/libmicrohttpd.vcxproj.filters \ w32/VS2015/hellobrowser.vcxproj w32/VS2015/hellobrowser.vcxproj.filters \ w32/VS2015/simplepost.vcxproj w32/VS2015/largepost.vcxproj \ w32/VS2015/libmicrohttpd.sln W32VS2017 = w32/VS2017/libmicrohttpd.vcxproj w32/VS2017/libmicrohttpd.vcxproj.filters \ w32/VS2017/hellobrowser.vcxproj w32/VS2017/hellobrowser.vcxproj.filters \ w32/VS2017/simplepost.vcxproj w32/VS2017/largepost.vcxproj \ w32/VS2017/libmicrohttpd.sln W32VS2019 = w32/VS2019/libmicrohttpd.vcxproj w32/VS2019/libmicrohttpd.vcxproj.filters \ w32/VS2019/hellobrowser.vcxproj w32/VS2019/hellobrowser.vcxproj.filters \ w32/VS2019/simplepost.vcxproj w32/VS2019/largepost.vcxproj \ w32/VS2019/libmicrohttpd.sln W32VS2022 = w32/VS2022/libmicrohttpd.vcxproj w32/VS2022/libmicrohttpd.vcxproj.filters \ w32/VS2022/hellobrowser.vcxproj w32/VS2022/hellobrowser.vcxproj.filters \ w32/VS2022/simplepost.vcxproj w32/VS2022/largepost.vcxproj \ w32/VS2022/libmicrohttpd.sln W32VSAV = w32/VS-Any-Version/libmicrohttpd.vcxproj w32/VS-Any-Version/libmicrohttpd.vcxproj.filters \ w32/VS-Any-Version/hellobrowser.vcxproj w32/VS-Any-Version/hellobrowser.vcxproj.filters \ w32/VS-Any-Version/simplepost.vcxproj w32/VS-Any-Version/largepost.vcxproj \ w32/VS-Any-Version/libmicrohttpd.sln EXTRA_DIST = libmicrohttpd.pc.in $(W32COMMON) $(W32VS2013) \ $(W32VS2015) $(W32VS2017) $(W32VS2019) $(W32VS2022) $(W32VSAV) \ pre-dist-hook-dummy $(top_srcdir)/$(MHD_AUX_DIR)/config.rpath \ $(srcdir_po)/$(MHD_AUX_DIR)/install-sh $(PO_ALL_FILES) \ $(PO_ACLOCAL_M4) $(srcdir_po)/po-configure.ac.in \ $(srcdir_po)/configure.ac $(top_srcdir)/po-configure \ $(srcdir_po)/stamp-m.in $(APIM_TMSTMP) $(APIM_TRIGGER) pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libmicrohttpd.pc MOSTLYCLEANFILES = pre-dist-hook-dummy DISTCLEANFILES = config.main.log po-config.log po/stamp-m MAINTAINERCLEANFILES = m4/c_backported.m4 $(srcdir_po)/configure.ac # Works with old automake versions (<1.12.2) as "false" MHD_V = $(AM_V_P) false srcdir_po = $(top_srcdir)/po PO_ACLOCAL_M4 = $(srcdir_po)/aclocal.m4 PO_MAIN_FILES = $(srcdir_po)/Makefile.in.in $(srcdir_po)/remove-potcdate.sin \ $(srcdir_po)/quot.sed $(srcdir_po)/boldquot.sed \ $(srcdir_po)/en@quot.header $(srcdir_po)/en@boldquot.header \ $(srcdir_po)/insert-header.sin $(srcdir_po)/Rules-quot PO_EXTRA_FILES = $(srcdir_po)/Makevars.template PO_ROOT_FILES = $(srcdir_po)/ABOUT-NLS PO_M4_FILES = $(srcdir_po)/m4/gettext.m4 $(srcdir_po)/m4/host-cpu-c-abi.m4 \ $(srcdir_po)/m4/iconv.m4 $(srcdir_po)/m4/intlmacosx.m4 \ $(srcdir_po)/m4/lib-ld.m4 $(srcdir_po)/m4/lib-link.m4 \ $(srcdir_po)/m4/lib-prefix.m4 $(srcdir_po)/m4/nls.m4 \ $(srcdir_po)/m4/po.m4 $(srcdir_po)/m4/progtest.m4 PO_AUX_FILES = $(srcdir_po)/$(MHD_AUX_DIR)/config.rpath # All autopoint-created files PO_ALL_FILES = $(PO_MAIN_FILES) $(PO_EXTRA_FILES) $(PO_ROOT_FILES) \ $(PO_M4_FILES) $(PO_AUX_FILES) am__po_aclocal_m4_deps = $(PO_M4_FILES) $(srcdir_po)/configure.ac am__po_configure_deps = $(am__po_aclocal_m4_deps) $(PO_ACLOCAL_M4) AUTOPOINT = autopoint AUTOPOINT_FLAGS = APIM_LOCK_BASE = autopoint-updating-lock APIM_TMSTMP_BASE = autopoint-timestamp APIM_TMSTMP_TMP_BASE = $(APIM_TMSTMP_BASE)-tmp APIM_TRIGGER_BASE = autopoint-trigger APIM_LOCK = $(srcdir_po)/$(APIM_LOCK_BASE) APIM_TMSTMP = $(srcdir_po)/$(APIM_TMSTMP_BASE) APIM_TMSTMP_TMP = $(srcdir_po)/$(APIM_TMSTMP_TMP_BASE) APIM_TRIGGER = $(srcdir_po)/$(APIM_TRIGGER_BASE) # Run 'autopoint' even if no file missing FORCE_AUTOPOINT_CHECK = no LOCK_TIMEOUT_VALUE = 120 sleep_with_timeout = \ sleep 1; \ sec_waiting=`expr ${sec_waiting} + 1`; \ if test $${sec_waiting} -gt '$(LOCK_TIMEOUT_VALUE)'; then \ echo "Waiting timeout" 1>&2; \ rmdir "$${lock_name}" ; \ exit 1; \ fi wait_for_unlock = \ test -n "$${lock_name}" || lock_name='$(APIM_LOCK)'; \ if test -d "$${lock_name}"; then \ { $(MHD_V) && \ echo "Autopoint files are being updated in parallel thread, wait"; } || : ; \ sec_waiting=0; \ while test -d "$${lock_name}"; do \ $(sleep_with_timeout) ; \ done; \ fi apim_prepare = \ $(am__cd) '$(srcdir_po)' || exit 1; \ lock_name='$(APIM_LOCK_BASE)'; \ { trap "rm -rf $(APIM_TMSTMP_BASE) $(APIM_TMSTMP_TMP_BASE) $${lock_name} po" HUP ABRT INT TERM 2>/dev/null && \ trap "rm -rf $(APIM_TMSTMP_BASE) $(APIM_TMSTMP_TMP_BASE) $${lock_name} po" PIPE 2>/dev/null ; } || \ trap "rm -rf $(APIM_TMSTMP_BASE) $(APIM_TMSTMP_TMP_BASE) $${lock_name} po" 1 2 13 15; \ lock_held='false'; \ sec_waiting=0; \ while : ; do \ if mkdir "$${lock_name}" 2>/dev/null; then lock_held=':' ; else : ; fi; \ $${lock_held} && break || : ; \ test 'xyes' = 'x$(FORCE_AUTOPOINT_CHECK)' || break ; \ $(sleep_with_timeout) ; \ done; \ if $${lock_held} ; then \ rm -f '$(APIM_TMSTMP_BASE)' '$(APIM_TMSTMP_TMP_BASE)' || exit 1; \ echo 'timestamp' > '$(APIM_TMSTMP_TMP_BASE)' || exit 1; \ if test 'xyes' = 'x$(FORCE_AUTOPOINT_CHECK)'; then \ call_autopoint=':'; check_all='false'; \ else \ call_autopoint='false'; check_all=':'; \ fi; \ if $(MHD_V) ; then apim_echo='echo' ; else apim_echo=':'; fi ;\ $$apim_echo "Sync autopoint files"; \ files_missing='false'; \ $(MKDIR_P) 'po'; \ $(MKDIR_P) '$(MHD_AUX_DIR)'; \ main_f_names=`for f in $(PO_MAIN_FILES) $(PO_EXTRA_FILES); do echo "$$f"; done | $(SED) -e 's|^.*/||'`; \ root_f_names=`for f in $(PO_ROOT_FILES); do echo "$$f"; done | $(SED) -e 's|^.*/||'`; \ m4_f_names=`for f in $(PO_M4_FILES); do echo "$$f"; done | $(SED) -e 's|^.*/||'`; \ aux_f_names=`for f in $(PO_AUX_FILES); do echo "$$f"; done | $(SED) -e 's|^.*/||'`; \ for f in $${main_f_names}; do \ if test -f "$$f"; then \ cp -f "$$f" "po/$$f" ; \ else \ $$apim_echo "Missing $(srcdir_po)/$$f" ; \ files_missing=':' ; \ fi; \ done; \ if $${check_all} ; then \ for f in $${root_f_names}; do \ if test -f "./$$f"; then : ; \ else \ $$apim_echo "Missing $(srcdir_po)/$$f" ; \ files_missing=':' ; \ fi; \ done; \ for f in $${m4_f_names}; do \ if test -f "m4/$$f"; then : ; \ else \ $$apim_echo "Missing $(srcdir_po)/m4/$$f" ; \ files_missing=':' ; \ fi; \ done; \ for f in $${aux_f_names}; do \ if test -f "$(MHD_AUX_DIR)/$$f"; then : ;\ else \ $$apim_echo "Missing $(srcdir_po)/$(MHD_AUX_DIR)/$$f" ; \ files_missing=':' ; \ fi; \ done; \ fi; \ if $${files_missing} ; then \ call_autopoint=':' ; \ $$apim_echo "Some files are missing, call autopoint to restore them" ; \ elif $${call_autopoint}; then $$apim_echo "Check and update autopoint files" ; \ fi; \ rc_code=0; \ if $${call_autopoint} ; then \ echo ' cd $(srcdir_po) && $(AUTOPOINT) $(AUTOPOINT_FLAGS)'; \ '$(AUTOPOINT)' $(AUTOPOINT_FLAGS) || rc_code=1; \ fi; \ if test "$${rc_code}" = "0"; then \ $$apim_echo "Re-sync autopoint files back"; \ for f in $${aux_f_names}; do \ if test -f "$(MHD_AUX_DIR)/$$f"; then \ touch -f "$(MHD_AUX_DIR)/$$f" && \ cp -f "$(MHD_AUX_DIR)/$$f" "../$(MHD_AUX_DIR)/$$f"; \ else \ $$apim_echo "Still missing $(srcdir_po)/$(MHD_AUX_DIR)/$$f" 1>&2 ; \ rc_code=1; \ fi; \ done; \ for f in $${m4_f_names}; do \ if test -f "m4/$$f"; then \ touch "m4/$$f"; \ else \ $$apim_echo "Still missing $(srcdir_po)/m4/$$f" 1>&2 ; \ rc_code=1; \ fi; \ done; \ for f in $${root_f_names}; do \ if test -f "./$$f"; then \ touch "./$$f"; \ else \ $$apim_echo "Still missing $(srcdir_po)/$$f" 1>&2 ; \ rc_code=1; \ fi; \ done; \ for f in $${main_f_names}; do \ if test -f "po/$$f"; then \ cp -f "po/$$f" "$$f"; \ else \ $$apim_echo "Still missing $(srcdir_po)/$$f" 1>&2 ; \ rc_code=1; \ fi; \ done; \ fi; \ if test $${rc_code} = 0; then \ cp -fp '$(APIM_TMSTMP_TMP_BASE)' '$(APIM_TMSTMP_BASE)' ; \ touch -r '$(APIM_TMSTMP_TMP_BASE)' '$(APIM_TMSTMP_BASE)' ; \ $$apim_echo "All autopoint files have been synced"; \ rm -f '$(APIM_TMSTMP_TMP_BASE)'; \ else \ rm -f '$(APIM_TMSTMP_BASE)' '$(APIM_TMSTMP_TMP_BASE)'; \ fi; \ rm -fr 'po'; \ rmdir "$${lock_name}"; \ exit $${rc_code} ; \ else \ $(wait_for_unlock) ; \ test -f '$(APIM_TMSTMP_BASE)' || exit 1; \ fi; \ : all: MHD_config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): MHD_config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/MHD_config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status MHD_config.h $(srcdir)/MHD_config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f MHD_config.h stamp-h1 po/po-configure.ac: $(top_builddir)/config.status $(top_srcdir)/po/po-configure.ac.in cd $(top_builddir) && $(SHELL) ./config.status $@ libmicrohttpd.pc: $(top_builddir)/config.status $(srcdir)/libmicrohttpd.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ w32/common/microhttpd_dll_res_vc.rc: $(top_builddir)/config.status $(top_srcdir)/w32/common/microhttpd_dll_res_vc.rc.in cd $(top_builddir) && $(SHELL) ./config.status $@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ done uninstall-pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @case `sed 15q $(srcdir)/NEWS` in \ *"$(VERSION)"*) : ;; \ *) \ echo "NEWS not updated; not releasing" 1>&2; \ exit 1;; \ esac $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" @if test -z "$(am__skip_length_check)" && find "$(distdir)" -type f -print | \ grep '^...................................................................................................' 1>&2; then \ echo 'error: the above filenames are too long' 1>&2; \ exit 1; \ else :; fi dist-gzip: distdir tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-zstd: distdir tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ *.tar.zst*) \ zstd -dc $(distdir).tar.zst | $(am__untar) ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build/sub \ && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(DATA) MHD_config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(pkgconfigdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr \ distclean-libtool distclean-local distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-pkgconfigDATA install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic \ maintainer-clean-local mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool \ mostlyclean-local pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-pkgconfigDATA .MAKE: $(am__recursive_targets) all install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-hook dist-lzip dist-shar \ dist-tarZ dist-xz dist-zip dist-zstd distcheck distclean \ distclean-generic distclean-hdr distclean-libtool \ distclean-local distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-pkgconfigDATA install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs installdirs-am maintainer-clean \ maintainer-clean-generic maintainer-clean-local mostlyclean \ mostlyclean-generic mostlyclean-libtool mostlyclean-local pdf \ pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkgconfigDATA .PRECIOUS: Makefile pre-dist-hook-dummy: pre-dist-hook Makefile @echo "dummy" > $@ dist-hook: dist-po @chmod u+w '$(distdir)/pre-dist-hook-dummy' && \ rm -f '$(distdir)/pre-dist-hook-dummy' @rm -f pre-dist-hook-dummy @if test -w '$(distdir)/m4/c_backported.m4'; then \ echo "Use empty m4/c_backported.m4 for dist target"; \ touch -r '$(distdir)/m4/c_backported.m4' '$(distdir)/m4/c_backported.m4-tmst' && \ echo 'dnl Not used for distribution' > '$(distdir)/m4/c_backported.m4' && \ touch -r '$(distdir)/m4/c_backported.m4-tmst' '$(distdir)/m4/c_backported.m4' && \ rm -f '$(distdir)/m4/c_backported.m4-tmst'; \ else \ true; \ fi dist-custm: distdir @test -n "$(ARC_CMD)" || \ { echo 'The valid archive command must be defined by "ARC_CMD".' >&2; false; } @test -n "$(ARC_EXT)" || \ { echo 'The archive file extension must be set by "ARC_EXT".' >&2; false; } -rm -f '$(distdir).$(ARC_EXT)' tardir=$(distdir) && $(am__tar) | $(ARC_CMD) >$(distdir).$(ARC_EXT) $(am__post_remove_distdir) dist-custm2: distdir @test -n "$(ARC_CMD)" || \ { echo 'The valid archive command must be defined by "ARC_CMD".' >&2; false; } @test -n "$(ARC_EXT)" || \ { echo 'The archive file extension must be set by "ARC_EXT".' >&2; false; } -rm -f '$(distdir).$(ARC_EXT)' tardir=$(distdir) && $(am__tar) >$(distdir).tar && $(ARC_CMD) $(distdir).tar rm -f $(distdir).tar $(am__post_remove_distdir) pre-dist-hook: pre-dist-hook-doc @echo "Preparing to make dist" pre-dist-hook-doc: @echo "Preparing to make dist in doc" @if test -w '$(top_srcdir)/doc' ; then \ $(am__cd) doc && $(MAKE) $(AM_MAKEFLAGS) update-stamp; \ else \ echo "Source tree is read-only, skipping force doc update"; \ fi; .PHONY: pre-dist-hook pre-dist-hook-doc distclean-local: distclean-po maintainer-clean-local: maintainer-clean-po $(PO_ACLOCAL_M4): $(am__po_aclocal_m4_deps) @{ $(MHD_V) && echo "Building $@" ; } || true @echo "cd $(srcdir_po) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)" && \ $(am__cd) '$(srcdir_po)' && $(ACLOCAL) $(ACLOCAL_AMFLAGS) # Do update po/configure.ac only if template files updated $(srcdir_po)/configure.ac: $(srcdir_po)/po-configure.ac.in $(top_srcdir)/configure.ac @{ $(MHD_V) && echo "Building $@" ; } || true @$(MAKE) $(AM_MAKEFLAGS) po/po-configure.ac @cp -f po/po-configure.ac '$@' $(top_srcdir)/po-configure: $(srcdir_po)/configure.ac $(PO_ACLOCAL_M4) $(PO_AUX_FILES) $(srcdir_po)/$(MHD_AUX_DIR)/install-sh @{ $(MHD_V) && echo "Building $@" ; } || true @echo "cd $(srcdir_po) && $(AUTOCONF)" && \ ( $(am__cd) '$(srcdir_po)' && $(AUTOCONF) ) mv -f '$(srcdir_po)/configure' '$@' -chmod a-x '$@' $(srcdir_po)/stamp-m.in: @: > '$@' po-config.status: $(top_srcdir)/po-configure $(top_srcdir)/$(MHD_AUX_DIR)/install-sh $(top_srcdir)/$(MHD_AUX_DIR)/config.rpath @if test -f config.log; then \ mv -f config.log config.main.log; \ else \ true; \ fi @SHELL@ '$(top_srcdir)/po-configure' $(ac_configure_args) --silent --no-create --no-recursion --disable-option-checking @mv -f config.log po-config.log @if test -f config.main.log; then \ mv -f config.main.log config.log; \ else \ true; \ fi po/Makefile: $(srcdir_po)/Makefile.in.in $(srcdir_po)/Makevars po-config.status $(srcdir_po)/POTFILES.in $(srcdir_po)/stamp-m.in @: && @SHELL@ ./po-config.status po/stamp-m po/Makefile.in po-directories dist-po: po/Makefile $(PO_MAIN_FILES) @dir1="po"; dir2="$(distdir)/po"; \ $(am__relativize); \ rel_distsubdir=$$reldir; \ echo "cd po && $(MAKE) $(AM_MAKEFLAGS) distdir='$$rel_distsubdir' distdir" && \ $(am__cd) po && $(MAKE) $(AM_MAKEFLAGS) distdir="$$rel_distsubdir" distdir $(srcdir_po)/POTFILES.in: $(top_srcdir)/src/microhttpd/Makefile.am @echo "cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS) update-po-POTFILES.in" && \ $(am__cd) '$(top_builddir)/src/microhttpd' && $(MAKE) $(AM_MAKEFLAGS) update-po-POTFILES.in mostlyclean-local: mostlyclean-autopoint-update mostlyclean-autopoint-update: -test -d '$(APIM_LOCK)' && rm -rf '$(APIM_LOCK)' -test -d '$(srcdir_po)/po' && rm -rf '$(srcdir_po)/po' rm -f '$(APIM_TMSTMP_TMP)' $(APIM_TRIGGER): @echo "autopoint files rebuild trigger" > "$@" $(APIM_TMSTMP): $(srcdir_po)/configure.ac $(APIM_TRIGGER) @ $(apim_prepare) .DELETE_ON_ERROR: $(APIM_TMSTMP) $(PO_ALL_FILES): $(APIM_TMSTMP) $(srcdir_po)/configure.ac @ ( $(apim_prepare) ) @test -f '$@' prepare-autopoint: $(srcdir_po)/configure.ac @ ( $(apim_prepare) ) @test -f '$(APIM_TMSTMP)' check-prepare-autopoint: $(srcdir_po)/$(MHD_AUX_DIR)/install-sh $(APIM_TMSTMP) @echo "Check all autopoint files"; \ files_missing='false'; \ for f in $(PO_ALL_FILES); do \ if test -f "$$f"; then : ; \ else \ echo "Missing $$f" ; \ files_missing=':' ; \ fi; \ done; \ if $${files_missing}; then \ $(MAKE) $(AM_MAKEFLAGS) prepare-autopoint || exit 1; \ else \ exit 0; \ fi # This could be used to update autopoint files for git or for 'dist' target update-autopoint-force: $(MAKE) $(AM_MAKEFLAGS) 'FORCE_AUTOPOINT_CHECK=yes' 'AUTOPOINT_FLAGS=$(AUTOPOINT_FLAGS) -f' prepare-autopoint autopoint-files-all: $(APIM_TRIGGER) $(APIM_TMSTMP) $(PO_MAIN_FILES) $(PO_EXTRA_FILES) $(PO_M4_FILES) $(PO_AUX_FILES) $(srcdir_po)/$(MHD_AUX_DIR)/install-sh $(top_srcdir)/$(MHD_AUX_DIR)/config.rpath: $(srcdir_po)/$(MHD_AUX_DIR)/config.rpath cp -f '$(srcdir_po)/$(MHD_AUX_DIR)/config.rpath' '$@' $(srcdir_po)/$(MHD_AUX_DIR)/install-sh: $(top_srcdir)/$(MHD_AUX_DIR)/install-sh $(MKDIR_P) '$(srcdir_po)/$(MHD_AUX_DIR)' cp -f '$(top_srcdir)/$(MHD_AUX_DIR)/install-sh' '$@' .PHONY: mostlyclean-autopoint-update prepare-autopoint update-autopoint-force check-prepare-autopoint autopoint-files-all distclean-po: @( if test -f po/Makefile; then \ $(am__cd) po && $(MAKE) $(AM_MAKEFLAGS) distclean; \ else \ true; \ fi ) -rm -f po-config.status po/Makefile po/stamp-m -rm -f po/POTFILES po/remove-potcdate.sed po/Makefile.in maintainer-clean-po: @( if test -f po/Makefile; then \ $(am__cd) po && $(MAKE) $(AM_MAKEFLAGS) maintainer-clean; \ else \ true; \ fi ) -rm -f po/$(PACKAGE_TARNAME).pot -rm -rf $(srcdir_po)/autom4te.cache .PHONY: distclean-po maintainer-clean-po # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: libmicrohttpd-1.0.1/w32/0000755000175000017500000000000014566140215010535 5libmicrohttpd-1.0.1/w32/VS2017/0000755000175000017500000000000014566140215011377 5libmicrohttpd-1.0.1/w32/VS2017/libmicrohttpd.sln0000644000175000017500000007423514500102730014700  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26228.9 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hellobrowser", "hellobrowser.vcxproj", "{310F39BD-A2D6-44FF-8344-37ADD0524CBD}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmicrohttpd", "libmicrohttpd.vcxproj", "{9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simplepost", "simplepost.vcxproj", "{294D5317-E983-4682-8DB5-678EA4645E11}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "largepost", "largepost.vcxproj", "{77A27E6D-9A39-40B8-961B-40E63DB7FA65}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perf_replies", "perf_replies.vcxproj", "{0192C6B5-D870-4857-B673-471E3EBD41D4}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug-dll|x64 = Debug-dll|x64 Debug-dll|Win32 = Debug-dll|Win32 Debug-dll|ARM64 = Debug-dll|ARM64 Debug-dll|ARM = Debug-dll|ARM Debug-dll-xp|x64 = Debug-dll-xp|x64 Debug-dll-xp|Win32 = Debug-dll-xp|Win32 Debug-dll-xp|ARM64 = Debug-dll-xp|ARM64 Debug-dll-xp|ARM = Debug-dll-xp|ARM Debug-static|x64 = Debug-static|x64 Debug-static|Win32 = Debug-static|Win32 Debug-static|ARM64 = Debug-static|ARM64 Debug-static|ARM = Debug-static|ARM Debug-static-xp|x64 = Debug-static-xp|x64 Debug-static-xp|Win32 = Debug-static-xp|Win32 Debug-static-xp|ARM64 = Debug-static-xp|ARM64 Debug-static-xp|ARM = Debug-static-xp|ARM Release-dll|x64 = Release-dll|x64 Release-dll|Win32 = Release-dll|Win32 Release-dll|ARM64 = Release-dll|ARM64 Release-dll|ARM = Release-dll|ARM Release-dll-xp|x64 = Release-dll-xp|x64 Release-dll-xp|Win32 = Release-dll-xp|Win32 Release-dll-xp|ARM64 = Release-dll-xp|ARM64 Release-dll-xp|ARM = Release-dll-xp|ARM Release-static|x64 = Release-static|x64 Release-static|Win32 = Release-static|Win32 Release-static|ARM64 = Release-static|ARM64 Release-static|ARM = Release-static|ARM Release-static-xp|x64 = Release-static-xp|x64 Release-static-xp|Win32 = Release-static-xp|Win32 Release-static-xp|ARM64 = Release-static-xp|ARM64 Release-static-xp|ARM = Release-static-xp|ARM EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.Build.0 = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.ActiveCfg = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.Build.0 = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.Build.0 = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.Build.0 = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.ActiveCfg = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.Build.0 = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.Build.0 = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.Build.0 = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.ActiveCfg = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.Build.0 = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.ActiveCfg = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.Build.0 = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.Build.0 = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|x64.Build.0 = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM.Build.0 = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.Build.0 = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|x64.ActiveCfg = Debug-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|x64.Build.0 = Debug-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|Win32.Build.0 = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|ARM64.ActiveCfg = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|ARM.ActiveCfg = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.ActiveCfg = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.Build.0 = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.Build.0 = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.Build.0 = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|x64.ActiveCfg = Debug-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|x64.Build.0 = Debug-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|Win32.ActiveCfg = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|Win32.Build.0 = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|ARM64.ActiveCfg = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|ARM.ActiveCfg = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.ActiveCfg = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.Build.0 = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.Build.0 = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.Build.0 = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|x64.ActiveCfg = Release-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|x64.Build.0 = Release-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|Win32.ActiveCfg = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|Win32.Build.0 = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|ARM64.ActiveCfg = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|ARM.ActiveCfg = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.ActiveCfg = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.Build.0 = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.ActiveCfg = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.Build.0 = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.Build.0 = Release-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.ActiveCfg = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.Build.0 = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|x64.ActiveCfg = Release-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|x64.Build.0 = Release-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|Win32.ActiveCfg = Release-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|Win32.Build.0 = Release-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|ARM64.ActiveCfg = Release-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|ARM.ActiveCfg = Release-static-xp|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.Build.0 = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.ActiveCfg = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.Build.0 = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.Build.0 = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.Build.0 = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.ActiveCfg = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.Build.0 = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.Build.0 = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.Build.0 = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.ActiveCfg = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.Build.0 = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.ActiveCfg = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.Build.0 = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.Build.0 = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|x64.Build.0 = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.Build.0 = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.ActiveCfg = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.Build.0 = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.Build.0 = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.Build.0 = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.ActiveCfg = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.Build.0 = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.Build.0 = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.Build.0 = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.ActiveCfg = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.Build.0 = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.ActiveCfg = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.Build.0 = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.Build.0 = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|x64.Build.0 = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.Build.0 = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.ActiveCfg = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.Build.0 = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.Build.0 = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.Build.0 = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.ActiveCfg = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.Build.0 = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.Build.0 = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.Build.0 = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.ActiveCfg = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.Build.0 = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.ActiveCfg = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.Build.0 = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.Build.0 = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|x64.Build.0 = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM.Build.0 = Release-static|ARM EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal libmicrohttpd-1.0.1/w32/VS2017/hellobrowser.vcxproj0000644000175000017500000000365214445225034015450  {310F39BD-A2D6-44FF-8344-37ADD0524CBD} Win32Proj hellobrowser x64 Application true false v141 true Unicode libmicrohttpd-1.0.1/w32/VS2017/hellobrowser.vcxproj.filters0000644000175000017500000000041514417460232017111  libmicrohttpd-1.0.1/w32/VS2017/libmicrohttpd.vcxproj0000644000175000017500000000442214445225034015601  {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} Win32Proj libmicrohttpd x64 StaticLibrary DynamicLibrary true false v141 v141_xp true Unicode libmicrohttpd-1.0.1/w32/VS2017/largepost.vcxproj0000644000175000017500000000364414445225034014742  {77A27E6D-9A39-40B8-961B-40E63DB7FA65} Win32Proj largepost x64 Application true false v141 true Unicode libmicrohttpd-1.0.1/w32/VS2017/libmicrohttpd.vcxproj.filters0000644000175000017500000000041614417460232017247  libmicrohttpd-1.0.1/w32/VS2017/simplepost.vcxproj0000644000175000017500000000364614445225034015143  {294D5317-E983-4682-8DB5-678EA4645E11} Win32Proj simplepost x64 Application true false v141 true Unicode libmicrohttpd-1.0.1/w32/VS-Any-Version/0000755000175000017500000000000014566140216013236 5libmicrohttpd-1.0.1/w32/VS-Any-Version/libmicrohttpd.sln0000644000175000017500000003742314500102730016534  Microsoft Visual Studio Solution File, Format Version 12.00 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hellobrowser", "hellobrowser.vcxproj", "{310F39BD-A2D6-44FF-8344-37ADD0524CBD}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmicrohttpd", "libmicrohttpd.vcxproj", "{9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simplepost", "simplepost.vcxproj", "{294D5317-E983-4682-8DB5-678EA4645E11}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "largepost", "largepost.vcxproj", "{77A27E6D-9A39-40B8-961B-40E63DB7FA65}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perf_replies", "perf_replies.vcxproj", "{0192C6B5-D870-4857-B673-471E3EBD41D4}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug-dll|Win32 = Debug-dll|Win32 Debug-dll|x64 = Debug-dll|x64 Debug-dll|ARM = Debug-dll|ARM Debug-dll|ARM64 = Debug-dll|ARM64 Debug-static|Win32 = Debug-static|Win32 Debug-static|x64 = Debug-static|x64 Debug-static|ARM = Debug-static|ARM Debug-static|ARM64 = Debug-static|ARM64 Release-dll|Win32 = Release-dll|Win32 Release-dll|x64 = Release-dll|x64 Release-dll|ARM = Release-dll|ARM Release-dll|ARM64 = Release-dll|ARM64 Release-static|Win32 = Release-static|Win32 Release-static|x64 = Release-static|x64 Release-static|ARM = Release-static|ARM Release-static|ARM64 = Release-static|ARM64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.Build.0 = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.Build.0 = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.ActiveCfg = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.Build.0 = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.Build.0 = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.Build.0 = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.ActiveCfg = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.Build.0 = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.Build.0 = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.ActiveCfg = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.Build.0 = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.ActiveCfg = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.Build.0 = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.ActiveCfg = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.Build.0 = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.Build.0 = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.Build.0 = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.Build.0 = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.ActiveCfg = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.Build.0 = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.Build.0 = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.Build.0 = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.ActiveCfg = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.Build.0 = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.Build.0 = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.ActiveCfg = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.Build.0 = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.ActiveCfg = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.Build.0 = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.Build.0 = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.Build.0 = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.Build.0 = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.ActiveCfg = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.Build.0 = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.Build.0 = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.Build.0 = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.ActiveCfg = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.Build.0 = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.Build.0 = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.ActiveCfg = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.Build.0 = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.ActiveCfg = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.Build.0 = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.Build.0 = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.Build.0 = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.Build.0 = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.ActiveCfg = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.Build.0 = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.Build.0 = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.Build.0 = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.ActiveCfg = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.Build.0 = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.Build.0 = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.ActiveCfg = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.Build.0 = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.ActiveCfg = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.Build.0 = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.Build.0 = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.Build.0 = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.Build.0 = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.ActiveCfg = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.Build.0 = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.Build.0 = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.Build.0 = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.ActiveCfg = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.Build.0 = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.Build.0 = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.ActiveCfg = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.Build.0 = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.ActiveCfg = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.Build.0 = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal libmicrohttpd-1.0.1/w32/VS-Any-Version/hellobrowser.vcxproj0000644000175000017500000000365314500102730017274  {310F39BD-A2D6-44FF-8344-37ADD0524CBD} Win32Proj hellobrowser x64 Application true false $(DefaultPlatformToolset) true Unicode libmicrohttpd-1.0.1/w32/VS-Any-Version/hellobrowser.vcxproj.filters0000644000175000017500000000041514417460232020747  libmicrohttpd-1.0.1/w32/VS-Any-Version/libmicrohttpd.vcxproj0000644000175000017500000000421714445225034017441  {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} Win32Proj libmicrohttpd 10.0 x64 StaticLibrary DynamicLibrary true false $(DefaultPlatformToolset) true Unicode libmicrohttpd-1.0.1/w32/VS-Any-Version/largepost.vcxproj0000644000175000017500000000367114445225034016600  {77A27E6D-9A39-40B8-961B-40E63DB7FA65} Win32Proj largepost x64 Application true false $(DefaultPlatformToolset) true Unicode libmicrohttpd-1.0.1/w32/VS-Any-Version/libmicrohttpd.vcxproj.filters0000644000175000017500000000041614417460232021105  libmicrohttpd-1.0.1/w32/VS-Any-Version/simplepost.vcxproj0000644000175000017500000000364714445225034017002  {294D5317-E983-4682-8DB5-678EA4645E11} Win32Proj simplepost x64 Application true false $(DefaultPlatformToolset) true Unicode libmicrohttpd-1.0.1/w32/VS2019/0000755000175000017500000000000014566140216011402 5libmicrohttpd-1.0.1/w32/VS2019/libmicrohttpd.sln0000644000175000017500000003765714500102730014711  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.28803.156 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hellobrowser", "hellobrowser.vcxproj", "{310F39BD-A2D6-44FF-8344-37ADD0524CBD}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmicrohttpd", "libmicrohttpd.vcxproj", "{9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simplepost", "simplepost.vcxproj", "{294D5317-E983-4682-8DB5-678EA4645E11}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "largepost", "largepost.vcxproj", "{77A27E6D-9A39-40B8-961B-40E63DB7FA65}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perf_replies", "perf_replies.vcxproj", "{0192C6B5-D870-4857-B673-471E3EBD41D4}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug-dll|Win32 = Debug-dll|Win32 Debug-dll|x64 = Debug-dll|x64 Debug-dll|ARM = Debug-dll|ARM Debug-dll|ARM64 = Debug-dll|ARM64 Debug-static|Win32 = Debug-static|Win32 Debug-static|x64 = Debug-static|x64 Debug-static|ARM = Debug-static|ARM Debug-static|ARM64 = Debug-static|ARM64 Release-dll|Win32 = Release-dll|Win32 Release-dll|x64 = Release-dll|x64 Release-dll|ARM = Release-dll|ARM Release-dll|ARM64 = Release-dll|ARM64 Release-static|Win32 = Release-static|Win32 Release-static|x64 = Release-static|x64 Release-static|ARM = Release-static|ARM Release-static|ARM64 = Release-static|ARM64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.Build.0 = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.Build.0 = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.ActiveCfg = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.Build.0 = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.Build.0 = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.Build.0 = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.ActiveCfg = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.Build.0 = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.Build.0 = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.ActiveCfg = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.Build.0 = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.ActiveCfg = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.Build.0 = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.ActiveCfg = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.Build.0 = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.Build.0 = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.Build.0 = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.Build.0 = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.ActiveCfg = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.Build.0 = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.Build.0 = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.Build.0 = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.ActiveCfg = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.Build.0 = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.Build.0 = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.ActiveCfg = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.Build.0 = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.ActiveCfg = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.Build.0 = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.Build.0 = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.Build.0 = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.Build.0 = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.ActiveCfg = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.Build.0 = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.Build.0 = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.Build.0 = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.ActiveCfg = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.Build.0 = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.Build.0 = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.ActiveCfg = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.Build.0 = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.ActiveCfg = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.Build.0 = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.Build.0 = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.Build.0 = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.Build.0 = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.ActiveCfg = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.Build.0 = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.Build.0 = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.Build.0 = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.ActiveCfg = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.Build.0 = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.Build.0 = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.ActiveCfg = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.Build.0 = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.ActiveCfg = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.Build.0 = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.Build.0 = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.Build.0 = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.Build.0 = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.ActiveCfg = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.Build.0 = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.Build.0 = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.Build.0 = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.ActiveCfg = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.Build.0 = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.Build.0 = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.ActiveCfg = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.Build.0 = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.ActiveCfg = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.Build.0 = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.Build.0 = Release-static|ARM64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal libmicrohttpd-1.0.1/w32/VS2019/hellobrowser.vcxproj0000644000175000017500000000370414445225034015450  16.0 {310F39BD-A2D6-44FF-8344-37ADD0524CBD} Win32Proj hellobrowser x64 Application true false v142 true Unicode libmicrohttpd-1.0.1/w32/VS2019/hellobrowser.vcxproj.filters0000644000175000017500000000041514417460232017113  libmicrohttpd-1.0.1/w32/VS2019/libmicrohttpd.vcxproj0000644000175000017500000000414214500102730015567  16.0 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} Win32Proj libmicrohttpd x64 StaticLibrary DynamicLibrary true false v142 true Unicode libmicrohttpd-1.0.1/w32/VS2019/largepost.vcxproj0000644000175000017500000000364414445225034014744  {77A27E6D-9A39-40B8-961B-40E63DB7FA65} Win32Proj largepost x64 Application true false v142 true Unicode libmicrohttpd-1.0.1/w32/VS2019/libmicrohttpd.vcxproj.filters0000644000175000017500000000041614417460232017251  libmicrohttpd-1.0.1/w32/VS2019/simplepost.vcxproj0000644000175000017500000000370014500102730015121  16.0 {294D5317-E983-4682-8DB5-678EA4645E11} Win32Proj simplepost x64 Application true false v142 true Unicode libmicrohttpd-1.0.1/w32/common/0000755000175000017500000000000014566140215012025 5libmicrohttpd-1.0.1/w32/common/common-build-settings.props0000644000175000017500000001361214556705750017272  3 0 1 64 32 $(SolutionDir);$(MhdW32Common);$(MhdSrc)include;$(IncludePath) $(SolutionDir)$(ProjectName)\$(Configuration)\$(Platform)\ $(SolutionDir)Output\$(Platform)\ true false NotUsing EnableAllWarnings Level4 Level3 _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 4996;4820;4127;5045;4711;4710 4013 false $(IntDir)$(TargetName).pdb ProgramDatabase stdc17 true WIN32;%(PreprocessorDefinitions) _WIN32_WINNT=0x0602;%(PreprocessorDefinitions) 6.02 6.02 _WIN32_WINNT=0x0600;%(PreprocessorDefinitions) 6.00 6.00 _WIN32_WINNT=0x0501;%(PreprocessorDefinitions) 5.01 5.01 _WIN32_WINNT=0x0502;%(PreprocessorDefinitions) 5.02 5.02 Disabled _DEBUG;%(PreprocessorDefinitions) _DEBUG;%(PreprocessorDefinitions) MaxSpeed true true AnySuitable Speed true NDEBUG;%(PreprocessorDefinitions) true true UseLinkTimeCodeGeneration NDEBUG;%(PreprocessorDefinitions) MachineX86 MachineX86 MachineX64 MachineX64 libmicrohttpd-1.0.1/w32/common/libmicrohttpd-filters.vcxproj0000644000175000017500000002027414445225054017702  {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;hm;inl;inc;xsd {ec88d605-3383-4989-8e25-bc8efa824720} h;hh;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms {df5ad836-e372-437b-a0e3-299d3675d6b4} in Public Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Internal Headers Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Resource Files Template Files libmicrohttpd-1.0.1/w32/common/libmicrohttpd-files.vcxproj0000644000175000017500000001161314556705750017342  true true true true false Document PowerShell.exe -Version 3.0 -NonInteractive -NoProfile -ExecutionPolicy Bypass -File "$(MhdW32Common)gen_dll_res.ps1" -BasePath "$(MhdW32Common)\" Generating .dll description resource $(MhdW32Common)microhttpd_dll_res_vc.rc $(MhdW32Common)gen_dll_res.ps1;$(MhdRoot)configure.ac libmicrohttpd-1.0.1/w32/common/project-configs-xp.props0000644000175000017500000000571014445225034016555  Debug-dll-xp Win32 Debug-dll-xp x64 Debug-static-xp Win32 Debug-static-xp x64 Release-dll-xp Win32 Release-dll-xp x64 Release-static-xp Win32 Release-static-xp x64 Debug-dll-xp ARM Debug-dll-xp ARM64 Debug-static-xp ARM Debug-static-xp ARM64 Release-dll-xp ARM Release-dll-xp ARM64 Release-static-xp ARM Release-static-xp ARM64 libmicrohttpd-1.0.1/w32/common/hellobrowser-files.vcxproj0000644000175000017500000000063114417460232017170  {9cfb0342-a9e7-483e-bee5-a1de22584c5a} libmicrohttpd-1.0.1/w32/common/gen_dll_res.ps10000644000175000017500000000315414445225034014651 param ([string]$BasePath = ".\") $Host.SetShouldExit(111) # Set non-zero return code until task successfully finished $ErrorActionPreference = "Stop" # Stop on any error Remove-Variable MHD_ver,MHD_ver_major,MHD_ver_minor,MHD_ver_patchlev -ErrorAction:SilentlyContinue Write-Output "Processing: ${BasePath}..\..\configure.ac" foreach($line in Get-Content "${BasePath}..\..\configure.ac") { if ($line -match '^AC_INIT\(\[(?:GNU )?libmicrohttpd\],\[((\d+).(\d+).(\d+))\]') { [string]$MHD_ver = $Matches[1].ToString() [string]$MHD_ver_major = $Matches[2].ToString() [string]$MHD_ver_minor = $Matches[3].ToString() [string]$MHD_ver_patchlev = $Matches[4].ToString() break } } if ("$MHD_ver" -eq "" -or "$MHD_ver_major" -eq "" -or "$MHD_ver_minor" -eq "" -or "$MHD_ver_patchlev" -eq "") { Write-Error -Message ("error MHDVSVER01 : Can't find MHD version") Throw ($MyInvocation.MyCommand.Name + " : error MHDVSVER01 : Can't find MHD version") } Write-Output "Detected MHD version: $MHD_ver" Write-Output "Generating ${BasePath}microhttpd_dll_res_vc.rc" Get-Content "${BasePath}microhttpd_dll_res_vc.rc.in" | ForEach-Object { $_ -replace '@PACKAGE_VERSION_MAJOR@',"$MHD_ver_major" ` -replace '@PACKAGE_VERSION_MINOR@', "$MHD_ver_minor" ` -replace '@PACKAGE_VERSION_SUBMINOR@', "$MHD_ver_patchlev" ` -replace '@PACKAGE_VERSION@', "$MHD_ver" } | Out-File -FilePath "${BasePath}microhttpd_dll_res_vc.rc" -Force $Host.SetShouldExit(0) # Reset return code Write-Output "${BasePath}microhttpd_dll_res_vc.rc was generated " exit 0 # Exit with success code libmicrohttpd-1.0.1/w32/common/project-configs.props0000644000175000017500000000541114445225034016126  Debug-dll Win32 Debug-dll x64 Debug-dll ARM Debug-dll ARM64 Debug-static Win32 Debug-static x64 Debug-static ARM Debug-static ARM64 Release-dll Win32 Release-dll x64 Release-dll ARM Release-dll ARM64 Release-static Win32 Release-static x64 Release-static ARM Release-static ARM64 libmicrohttpd-1.0.1/w32/common/microhttpd_dll_res_vc.rc.in0000644000175000017500000000273514417460232017257 /* W32 resources for .dll */ #include LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO FILEVERSION @PACKAGE_VERSION_MAJOR@,@PACKAGE_VERSION_MINOR@,@PACKAGE_VERSION_SUBMINOR@,0 PRODUCTVERSION @PACKAGE_VERSION_MAJOR@,@PACKAGE_VERSION_MINOR@,@PACKAGE_VERSION_SUBMINOR@,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #if defined(_DEBUG) FILEFLAGS VS_FF_DEBUG #else FILEFLAGS 0 #endif FILEOS VOS_NT_WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE VFT2_UNKNOWN BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "04090000" /* Lang = US English, Charset = ASCII */ BEGIN VALUE "ProductName", "GNU libmicrohttpd\0" VALUE "ProductVersion", "@PACKAGE_VERSION@\0" VALUE "FileVersion", "@PACKAGE_VERSION@\0" VALUE "FileDescription", "GNU libmicrohttpd DLL for Windows (VC build)\0" VALUE "InternalName", "libmicrohttpd\0" #if defined(_DEBUG) VALUE "OriginalFilename", "libmicrohttpd-dll_d.dll\0" #else VALUE "OriginalFilename", "libmicrohttpd-dll.dll\0" #endif VALUE "CompanyName", "Free Software Foundation\0" VALUE "LegalCopyright", "Copyright (C) 2007-2021 Christian Grothoff, Evgeny Grin, and project contributors\0" VALUE "Comments", "http://www.gnu.org/software/libmicrohttpd/\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 0 /* US English, ASCII */ END END libmicrohttpd-1.0.1/w32/common/microhttpd_dll_res_vc.rc0000644000175000017500000000247314566140212016647 /* W32 resources for .dll */ #include LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO FILEVERSION 1,0,1,0 PRODUCTVERSION 1,0,1,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #if defined(_DEBUG) FILEFLAGS VS_FF_DEBUG #else FILEFLAGS 0 #endif FILEOS VOS_NT_WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE VFT2_UNKNOWN BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "04090000" /* Lang = US English, Charset = ASCII */ BEGIN VALUE "ProductName", "GNU libmicrohttpd\0" VALUE "ProductVersion", "1.0.1\0" VALUE "FileVersion", "1.0.1\0" VALUE "FileDescription", "GNU libmicrohttpd DLL for Windows (VC build)\0" VALUE "InternalName", "libmicrohttpd\0" #if defined(_DEBUG) VALUE "OriginalFilename", "libmicrohttpd-dll_d.dll\0" #else VALUE "OriginalFilename", "libmicrohttpd-dll.dll\0" #endif VALUE "CompanyName", "Free Software Foundation\0" VALUE "LegalCopyright", "Copyright (C) 2007-2021 Christian Grothoff, Evgeny Grin, and project contributors\0" VALUE "Comments", "http://www.gnu.org/software/libmicrohttpd/\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 0 /* US English, ASCII */ END END libmicrohttpd-1.0.1/w32/common/MHD_config.h0000644000175000017500000001641714560002050014050 /* MHD_config.h for W32 */ /* Created manually. */ /* *** Basic OS/compiler information *** */ /* This is a Windows system */ #define WINDOWS 1 /* Define if MS VC compiler is used */ #define MSVC 1 #ifndef __clang__ /* Define that MS VC does not support VLAs */ #ifndef __STDC_NO_VLA__ #define __STDC_NO_VLA__ 1 #endif /* ! __STDC_NO_VLA__ */ #else /* If clang is used then variable-length arrays are supported. */ #define HAVE_C_VARARRAYS 1 #endif /* Define to 1 if your C compiler supports inline functions. */ #define INLINE_FUNC 1 /* Define to prefix which will be used with MHD inline functions. */ #define _MHD_static_inline static __forceinline #ifdef __clang__ /* Define to 1 if you have __builtin_bswap32() builtin function */ #define MHD_HAVE___BUILTIN_BSWAP32 1 /* Define to 1 if you have __builtin_bswap64() builtin function */ #define MHD_HAVE___BUILTIN_BSWAP64 1 #endif /* __clang__ */ /* The size of `size_t', as computed by sizeof. */ #if defined(_M_X64) || defined(_M_AMD64) || defined(_M_ARM64) || defined(_WIN64) #define SIZEOF_SIZE_T 8 #else /* ! _WIN64 */ #define SIZEOF_SIZE_T 4 #endif /* ! _WIN64 */ /* The size of `tv_sec' member of `struct timeval', as computed by sizeof */ #define SIZEOF_STRUCT_TIMEVAL_TV_SEC 4 /* The size of `int64_t', as computed by sizeof. */ #define SIZEOF_INT64_T 8 /* The size of `uint64_t', as computed by sizeof. */ #define SIZEOF_UINT64_T 8 /* The size of `int', as computed by sizeof. */ #define SIZEOF_INT 4 /* The size of `unsigned int', as computed by sizeof. */ #define SIZEOF_UNSIGNED_INT 4 /* The size of `unsigned long long', as computed by sizeof. */ #define SIZEOF_UNSIGNED_LONG_LONG 8 /* Define to supported 'noreturn' function declaration */ #if defined(_STDC_VERSION__) && (__STDC_VERSION__ + 0) >= 201112L #define _MHD_NORETURN _Noreturn #else /* before C11 */ #define _MHD_NORETURN __declspec(noreturn) #endif /* before C11 */ /* *** MHD configuration *** */ /* Undef to disable feature */ /* Enable basic Auth support */ #define BAUTH_SUPPORT 1 /* Enable digest Auth support */ #define DAUTH_SUPPORT 1 /* The default HTTP Digest Auth default maximum nc (nonce count) value */ #define MHD_DAUTH_DEF_MAX_NC_ 1000 /* The default HTTP Digest Auth default nonce timeout value (in seconds) */ #define MHD_DAUTH_DEF_TIMEOUT_ 90 /* Enable MD5 hashing support. */ #define MHD_MD5_SUPPORT 1 /* Enable SHA-256 hashing support. */ #define MHD_SHA256_SUPPORT 1 /* Enable SHA-512/256 hashing support. */ #define MHD_SHA512_256_SUPPORT 1 /* Enable postprocessor.c */ #define HAVE_POSTPROCESSOR 1 /* Enable error messages */ #define HAVE_MESSAGES 1 /* Enable HTTP Upgrade support. */ #define UPGRADE_SUPPORT 1 /* Enable HTTP cookie parsing support. */ #define COOKIE_SUPPORT 1 /* *** OS features *** */ /* Provides IPv6 headers */ #define HAVE_INET6 1 /* Define to 1 if your system allow overriding the value of FD_SETSIZE macro */ #define HAS_FD_SETSIZE_OVERRIDABLE 1 #if 0 /* Do not define the macro to keep maintability simple if system value is updated */ /* Define to system default value of FD_SETSIZE macro */ # define MHD_SYS_FD_SETSIZE_ 64 #endif /* Define to use socketpair for inter-thread communication */ #define _MHD_ITC_SOCKETPAIR 1 /* define to use W32 threads */ #define MHD_USE_W32_THREADS 1 #ifndef _WIN32_WINNT /* MHD supports Windows XP and later W32 systems*/ #define _WIN32_WINNT 0x0600 #endif /* _WIN32_WINNT */ /* winsock poll is available only on Vista and later */ #if _WIN32_WINNT >= 0x0600 #define HAVE_POLL 1 #endif /* _WIN32_WINNT >= 0x0600 */ /* Define to 1 if you have the header file. */ #define HAVE_WINSOCK2_H 1 /* Define to 1 if you have the header file. */ #define HAVE_WS2TCPIP_H 1 /* Define to 1 if you have the `_lseeki64' function. */ #define HAVE___LSEEKI64 1 /* Define to 1 if you have the `gmtime_s' function in W32 form. */ #define HAVE_W32_GMTIME_S 1 /* Define to 1 if you have the usable `calloc' function. */ #define HAVE_CALLOC 1 /* Define if you have usable assert() and assert.h */ #define HAVE_ASSERT 1 /* Define to 1 if you have the header file. */ #define HAVE_LIMITS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDDEF_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_TIME_H 1 #if _MSC_VER >= 1900 /* snprintf() supported natively since VS2015 */ /* Define to 1 if you have the `snprintf' function. */ #define HAVE_SNPRINTF 1 #endif #if _MSC_VER >= 1800 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 #endif #if _MSC_VER + 0 >= 1800 /* VS 2013 and later */ /* Define to 1 if you have the header file and defines 'bool' type. */ #define HAVE_STDBOOL_H 1 /* Define to 1 if you have the real boolean type. */ #define HAVE_REAL_BOOL 1 /* Define to 1 if you have the real boolean type. */ #define HAVE_BUILTIN_TYPE_BOOL 1 #else /* before VS 2013 */ /* Define to type name which will be used as boolean type. */ #define bool int /* Define to value interpreted by compiler as boolean "false", if "false" is not defined by system headers. */ #define false 0 /* Define to value interpreted by compiler as boolean "true", if "true" is not defined by system headers. */ #define true (!0) #endif /* before VS 2013 */ /* Define to 1 if you have the `getsockname' function. */ #define HAVE_GETSOCKNAME 1 /* Define if you have usable `getsockname' function. */ #define MHD_USE_GETSOCKNAME 1 /* Define to 1 if your compiler supports __func__ magic-macro. */ #define HAVE___FUNC__ 1 #if _MSC_VER + 0 >= 1900 /* VS 2015 and later */ #if defined(_STDC_VERSION__) && (__STDC_VERSION__ + 0) >= 201112L /* Define to 1 if your compiler supports 'alignof()' */ #define HAVE_C_ALIGNOF 1 /* Define to 1 if you have the header file. */ #define HAVE_STDALIGN_H 1 #endif /* C11 */ #endif /* VS 2015 and later */ /* Define to 1 if you have the 'rand' function. */ #define HAVE_RAND 1 /* *** Headers information *** */ /* Not really important as not used by code currently */ /* Define to 1 if you have the header file. */ #define HAVE_ERRNO_H 1 /* Define to 1 if you have the header file. */ #define HAVE_FCNTL_H 1 /* Define to 1 if you have the header file. */ #define HAVE_LOCALE_H 1 /* Define to 1 if you have the header file. */ #define HAVE_MATH_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SDKDDKVER_H 1 /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDIO_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_WINDOWS_H 1 /* *** Other useful staff *** */ #define _GNU_SOURCE 1 /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* End of MHD_config.h */ libmicrohttpd-1.0.1/w32/common/libmicrohttpd-build-settings.props0000644000175000017500000000527614445225034020642  ResourceCompile $(ProjectName)_d $(ProjectName) $(ProjectName)-dll_d $(ProjectName)-dll BUILDING_MHD_LIB;%(PreprocessorDefinitions) 4746;%(DisableSpecificWarnings) WINDOWS Windows Copy headers to output xcopy /F /I /Y "$(MhdSrc)include\microhttpd.h" "$(OutputPath)" $(OutputPath)microhttpd.h;%(Outputs) $(MhdSrc)include\microhttpd.h _LIB;MHD_W32LIB;%(PreprocessorDefinitions) MultiThreadedDebug MultiThreaded Ws2_32.lib xcopy /F /I /Y "$(IntermediateOutputPath)$(TargetName).pdb" "$(OutputPath)" Copy .pdb to output directory _USRDLL;MHD_W32DLL;%(PreprocessorDefinitions) MultiThreadedDebugDLL MultiThreadedDLL Ws2_32.lib;%(AdditionalDependencies) libmicrohttpd-1.0.1/w32/common/hellobrowser-filters.vcxproj0000644000175000017500000000101214417460232017530  {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx Source Files libmicrohttpd-1.0.1/w32/common/apps-build-settings.props0000644000175000017500000000261414445225034016732  $(ProjectName)_d $(ProjectName)-dll_d $(ProjectName) $(ProjectName)-dll _CONSOLE;%(PreprocessorDefinitions) Console MultiThreadedDebug MultiThreadedDebugDLL MultiThreaded MultiThreadedDLL libmicrohttpd-1.0.1/w32/common/vs_dirs.props0000644000175000017500000000060214417460232014500  $(SolutionDir)..\..\ $(SolutionDir)..\..\src\ $(SolutionDir)..\ $(MhdW32Dir)common\ libmicrohttpd-1.0.1/w32/VS2013/0000755000175000017500000000000014566140215011373 5libmicrohttpd-1.0.1/w32/VS2013/libmicrohttpd.sln0000644000175000017500000007424114500102730014671  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hellobrowser", "hellobrowser.vcxproj", "{310F39BD-A2D6-44FF-8344-37ADD0524CBD}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmicrohttpd", "libmicrohttpd.vcxproj", "{9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simplepost", "simplepost.vcxproj", "{294D5317-E983-4682-8DB5-678EA4645E11}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "largepost", "largepost.vcxproj", "{77A27E6D-9A39-40B8-961B-40E63DB7FA65}" 77ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perf_replies", "perf_replies.vcxproj", "{0192C6B5-D870-4857-B673-471E3EBD41D4}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug-dll|x64 = Debug-dll|x64 Debug-dll|Win32 = Debug-dll|Win32 Debug-dll|ARM64 = Debug-dll|ARM64 Debug-dll|ARM = Debug-dll|ARM Debug-dll-xp|x64 = Debug-dll-xp|x64 Debug-dll-xp|Win32 = Debug-dll-xp|Win32 Debug-dll-xp|ARM64 = Debug-dll-xp|ARM64 Debug-dll-xp|ARM = Debug-dll-xp|ARM Debug-static|x64 = Debug-static|x64 Debug-static|Win32 = Debug-static|Win32 Debug-static|ARM64 = Debug-static|ARM64 Debug-static|ARM = Debug-static|ARM Debug-static-xp|x64 = Debug-static-xp|x64 Debug-static-xp|Win32 = Debug-static-xp|Win32 Debug-static-xp|ARM64 = Debug-static-xp|ARM64 Debug-static-xp|ARM = Debug-static-xp|ARM Release-dll|x64 = Release-dll|x64 Release-dll|Win32 = Release-dll|Win32 Release-dll|ARM64 = Release-dll|ARM64 Release-dll|ARM = Release-dll|ARM Release-dll-xp|x64 = Release-dll-xp|x64 Release-dll-xp|Win32 = Release-dll-xp|Win32 Release-dll-xp|ARM64 = Release-dll-xp|ARM64 Release-dll-xp|ARM = Release-dll-xp|ARM Release-static|x64 = Release-static|x64 Release-static|Win32 = Release-static|Win32 Release-static|ARM64 = Release-static|ARM64 Release-static|ARM = Release-static|ARM Release-static-xp|x64 = Release-static-xp|x64 Release-static-xp|Win32 = Release-static-xp|Win32 Release-static-xp|ARM64 = Release-static-xp|ARM64 Release-static-xp|ARM = Release-static-xp|ARM EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.Build.0 = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.ActiveCfg = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.Build.0 = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.Build.0 = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.Build.0 = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.ActiveCfg = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.Build.0 = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.Build.0 = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.Build.0 = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.ActiveCfg = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.Build.0 = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.ActiveCfg = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.Build.0 = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.Build.0 = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|x64.Build.0 = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM.Build.0 = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.Build.0 = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|x64.ActiveCfg = Debug-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|x64.Build.0 = Debug-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|Win32.Build.0 = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|ARM64.ActiveCfg = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|ARM.ActiveCfg = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.ActiveCfg = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.Build.0 = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.Build.0 = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.Build.0 = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|x64.ActiveCfg = Debug-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|x64.Build.0 = Debug-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|Win32.ActiveCfg = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|Win32.Build.0 = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|ARM64.ActiveCfg = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|ARM.ActiveCfg = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.ActiveCfg = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.Build.0 = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.Build.0 = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.Build.0 = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|x64.ActiveCfg = Release-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|x64.Build.0 = Release-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|Win32.ActiveCfg = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|Win32.Build.0 = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|ARM64.ActiveCfg = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|ARM.ActiveCfg = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.ActiveCfg = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.Build.0 = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.ActiveCfg = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.Build.0 = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.Build.0 = Release-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.ActiveCfg = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.Build.0 = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|x64.ActiveCfg = Release-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|x64.Build.0 = Release-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|Win32.ActiveCfg = Release-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|Win32.Build.0 = Release-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|ARM64.ActiveCfg = Release-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|ARM.ActiveCfg = Release-static-xp|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.Build.0 = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.ActiveCfg = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.Build.0 = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.Build.0 = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.Build.0 = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.ActiveCfg = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.Build.0 = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.Build.0 = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.Build.0 = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.ActiveCfg = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.Build.0 = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.ActiveCfg = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.Build.0 = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.Build.0 = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|x64.Build.0 = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.Build.0 = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.ActiveCfg = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.Build.0 = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.Build.0 = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.Build.0 = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.ActiveCfg = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.Build.0 = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.Build.0 = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.Build.0 = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.ActiveCfg = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.Build.0 = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.ActiveCfg = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.Build.0 = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.Build.0 = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|x64.Build.0 = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.Build.0 = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.ActiveCfg = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.Build.0 = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.Build.0 = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.Build.0 = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.ActiveCfg = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.Build.0 = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.Build.0 = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.Build.0 = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.ActiveCfg = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.Build.0 = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.ActiveCfg = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.Build.0 = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.Build.0 = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|x64.Build.0 = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM.Build.0 = Release-static|ARM EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal libmicrohttpd-1.0.1/w32/VS2013/hellobrowser.vcxproj0000644000175000017500000000530114445225034015435  {310F39BD-A2D6-44FF-8344-37ADD0524CBD} Win32Proj hellobrowser x64 Application true v120 Unicode Application true v120 Unicode Application false v120 true Unicode Application false v120 true Unicode libmicrohttpd-1.0.1/w32/VS2013/hellobrowser.vcxproj.filters0000644000175000017500000000041514417460232017105  libmicrohttpd-1.0.1/w32/VS2013/libmicrohttpd.vcxproj0000644000175000017500000001007614445225034015577  {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} Win32Proj libmicrohttpd x64 StaticLibrary true v120 Unicode StaticLibrary true v120_xp Unicode DynamicLibrary true v120 Unicode DynamicLibrary true v120_xp Unicode StaticLibrary false v120 true Unicode StaticLibrary false v120_xp true Unicode DynamicLibrary false v120 true Unicode DynamicLibrary false v120_xp true Unicode libmicrohttpd-1.0.1/w32/VS2013/largepost.vcxproj0000644000175000017500000000527314445225034014736  {77A27E6D-9A39-40B8-961B-40E63DB7FA65} Win32Proj largepost x64 Application true v120 Unicode Application true v120 Unicode Application false v120 true Unicode Application false v120 true Unicode libmicrohttpd-1.0.1/w32/VS2013/libmicrohttpd.vcxproj.filters0000644000175000017500000000041614417460232017243  libmicrohttpd-1.0.1/w32/VS2013/simplepost.vcxproj0000644000175000017500000000527514445225034015137  {294D5317-E983-4682-8DB5-678EA4645E11} Win32Proj simplepost x64 Application true v120 Unicode Application true v120 Unicode Application false v120 true Unicode Application false v120 true Unicode libmicrohttpd-1.0.1/w32/VS2015/0000755000175000017500000000000014566140215011375 5libmicrohttpd-1.0.1/w32/VS2015/libmicrohttpd.sln0000644000175000017500000007423514500102730014676  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hellobrowser", "hellobrowser.vcxproj", "{310F39BD-A2D6-44FF-8344-37ADD0524CBD}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmicrohttpd", "libmicrohttpd.vcxproj", "{9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simplepost", "simplepost.vcxproj", "{294D5317-E983-4682-8DB5-678EA4645E11}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "largepost", "largepost.vcxproj", "{77A27E6D-9A39-40B8-961B-40E63DB7FA65}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perf_replies", "perf_replies.vcxproj", "{0192C6B5-D870-4857-B673-471E3EBD41D4}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug-dll|x64 = Debug-dll|x64 Debug-dll|Win32 = Debug-dll|Win32 Debug-dll|ARM64 = Debug-dll|ARM64 Debug-dll|ARM = Debug-dll|ARM Debug-dll-xp|x64 = Debug-dll-xp|x64 Debug-dll-xp|Win32 = Debug-dll-xp|Win32 Debug-dll-xp|ARM64 = Debug-dll-xp|ARM64 Debug-dll-xp|ARM = Debug-dll-xp|ARM Debug-static|x64 = Debug-static|x64 Debug-static|Win32 = Debug-static|Win32 Debug-static|ARM64 = Debug-static|ARM64 Debug-static|ARM = Debug-static|ARM Debug-static-xp|x64 = Debug-static-xp|x64 Debug-static-xp|Win32 = Debug-static-xp|Win32 Debug-static-xp|ARM64 = Debug-static-xp|ARM64 Debug-static-xp|ARM = Debug-static-xp|ARM Release-dll|x64 = Release-dll|x64 Release-dll|Win32 = Release-dll|Win32 Release-dll|ARM64 = Release-dll|ARM64 Release-dll|ARM = Release-dll|ARM Release-dll-xp|x64 = Release-dll-xp|x64 Release-dll-xp|Win32 = Release-dll-xp|Win32 Release-dll-xp|ARM64 = Release-dll-xp|ARM64 Release-dll-xp|ARM = Release-dll-xp|ARM Release-static|x64 = Release-static|x64 Release-static|Win32 = Release-static|Win32 Release-static|ARM64 = Release-static|ARM64 Release-static|ARM = Release-static|ARM Release-static-xp|x64 = Release-static-xp|x64 Release-static-xp|Win32 = Release-static-xp|Win32 Release-static-xp|ARM64 = Release-static-xp|ARM64 Release-static-xp|ARM = Release-static-xp|ARM EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.Build.0 = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.ActiveCfg = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.Build.0 = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.Build.0 = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.Build.0 = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.ActiveCfg = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.Build.0 = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.Build.0 = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.Build.0 = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.ActiveCfg = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.Build.0 = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.ActiveCfg = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.Build.0 = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.Build.0 = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|x64.Build.0 = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static-xp|ARM.Build.0 = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.Build.0 = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|x64.ActiveCfg = Debug-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|x64.Build.0 = Debug-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|Win32.Build.0 = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|ARM64.ActiveCfg = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll-xp|ARM.ActiveCfg = Debug-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.ActiveCfg = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.Build.0 = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.Build.0 = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.Build.0 = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|x64.ActiveCfg = Debug-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|x64.Build.0 = Debug-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|Win32.ActiveCfg = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|Win32.Build.0 = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|ARM64.ActiveCfg = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static-xp|ARM.ActiveCfg = Debug-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.ActiveCfg = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.Build.0 = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.Build.0 = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.Build.0 = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|x64.ActiveCfg = Release-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|x64.Build.0 = Release-dll-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|Win32.ActiveCfg = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|Win32.Build.0 = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|ARM64.ActiveCfg = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll-xp|ARM.ActiveCfg = Release-dll-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.ActiveCfg = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.Build.0 = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.ActiveCfg = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.Build.0 = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.Build.0 = Release-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.ActiveCfg = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.Build.0 = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|x64.ActiveCfg = Release-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|x64.Build.0 = Release-static-xp|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|Win32.ActiveCfg = Release-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|Win32.Build.0 = Release-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|ARM64.ActiveCfg = Release-static-xp|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static-xp|ARM.ActiveCfg = Release-static-xp|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.Build.0 = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.ActiveCfg = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.Build.0 = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.Build.0 = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.Build.0 = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.ActiveCfg = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.Build.0 = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.Build.0 = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.Build.0 = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.ActiveCfg = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.Build.0 = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.ActiveCfg = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.Build.0 = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.Build.0 = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|x64.Build.0 = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.Build.0 = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.ActiveCfg = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.Build.0 = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.Build.0 = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.Build.0 = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.ActiveCfg = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.Build.0 = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.Build.0 = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.Build.0 = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.ActiveCfg = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.Build.0 = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.ActiveCfg = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.Build.0 = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.Build.0 = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|x64.Build.0 = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.Build.0 = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|x64.ActiveCfg = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|x64.Build.0 = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|Win32.ActiveCfg = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|Win32.Build.0 = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.ActiveCfg = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.Build.0 = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.Build.0 = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.Build.0 = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|x64.ActiveCfg = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|x64.Build.0 = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|Win32.ActiveCfg = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|Win32.Build.0 = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.ActiveCfg = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.Build.0 = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.Build.0 = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.Build.0 = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|x64.ActiveCfg = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|x64.Build.0 = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|Win32.ActiveCfg = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|Win32.Build.0 = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll-xp|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.ActiveCfg = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.Build.0 = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.ActiveCfg = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.Build.0 = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.Build.0 = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|x64.ActiveCfg = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|x64.Build.0 = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|Win32.ActiveCfg = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|Win32.Build.0 = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM64.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM64.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static-xp|ARM.Build.0 = Release-static|ARM EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal libmicrohttpd-1.0.1/w32/VS2015/hellobrowser.vcxproj0000644000175000017500000000530114445225034015437  {310F39BD-A2D6-44FF-8344-37ADD0524CBD} Win32Proj hellobrowser x64 Application true v140 Unicode Application true v140 Unicode Application false v140 true Unicode Application false v140 true Unicode libmicrohttpd-1.0.1/w32/VS2015/hellobrowser.vcxproj.filters0000644000175000017500000000041514417460232017107  libmicrohttpd-1.0.1/w32/VS2015/libmicrohttpd.vcxproj0000644000175000017500000001007614445225034015601  {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} Win32Proj libmicrohttpd x64 StaticLibrary true v140 Unicode StaticLibrary true v140_xp Unicode DynamicLibrary true v140 Unicode DynamicLibrary true v140_xp Unicode StaticLibrary false v140 true Unicode StaticLibrary false v140_xp true Unicode DynamicLibrary false v140 true Unicode DynamicLibrary false v140_xp true Unicode libmicrohttpd-1.0.1/w32/VS2015/largepost.vcxproj0000644000175000017500000000527314445225034014740  {77A27E6D-9A39-40B8-961B-40E63DB7FA65} Win32Proj largepost x64 Application true v140 Unicode Application true v140 Unicode Application false v140 true Unicode Application false v140 true Unicode libmicrohttpd-1.0.1/w32/VS2015/libmicrohttpd.vcxproj.filters0000644000175000017500000000041614417460232017245  libmicrohttpd-1.0.1/w32/VS2015/simplepost.vcxproj0000644000175000017500000000527514445225034015141  {294D5317-E983-4682-8DB5-678EA4645E11} Win32Proj simplepost x64 Application true v140 Unicode Application true v140 Unicode Application false v140 true Unicode Application false v140 true Unicode libmicrohttpd-1.0.1/w32/VS2022/0000755000175000017500000000000014566140216011374 5libmicrohttpd-1.0.1/w32/VS2022/libmicrohttpd.sln0000644000175000017500000003766014500102730014675  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31815.197 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hellobrowser", "hellobrowser.vcxproj", "{310F39BD-A2D6-44FF-8344-37ADD0524CBD}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmicrohttpd", "libmicrohttpd.vcxproj", "{9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simplepost", "simplepost.vcxproj", "{294D5317-E983-4682-8DB5-678EA4645E11}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "largepost", "largepost.vcxproj", "{77A27E6D-9A39-40B8-961B-40E63DB7FA65}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "perf_replies", "perf_replies.vcxproj", "{0192C6B5-D870-4857-B673-471E3EBD41D4}" ProjectSection(ProjectDependencies) = postProject {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} = {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug-dll|Win32 = Debug-dll|Win32 Debug-dll|x64 = Debug-dll|x64 Debug-dll|ARM = Debug-dll|ARM Debug-dll|ARM64 = Debug-dll|ARM64 Debug-static|Win32 = Debug-static|Win32 Debug-static|x64 = Debug-static|x64 Debug-static|ARM = Debug-static|ARM Debug-static|ARM64 = Debug-static|ARM64 Release-dll|Win32 = Release-dll|Win32 Release-dll|x64 = Release-dll|x64 Release-dll|ARM = Release-dll|ARM Release-dll|ARM64 = Release-dll|ARM64 Release-static|Win32 = Release-static|Win32 Release-static|x64 = Release-static|x64 Release-static|ARM = Release-static|ARM Release-static|ARM64 = Release-static|ARM64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|x64.Build.0 = Debug-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|Win32.Build.0 = Debug-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.ActiveCfg = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|x64.Build.0 = Debug-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM.Build.0 = Debug-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|Win32.Build.0 = Release-dll|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.ActiveCfg = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|x64.Build.0 = Release-dll|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM.Build.0 = Release-dll|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.ActiveCfg = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|Win32.Build.0 = Release-static|Win32 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.ActiveCfg = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|x64.Build.0 = Release-static|x64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.ActiveCfg = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM.Build.0 = Release-static|ARM {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A}.Release-static|ARM64.Build.0 = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|x64.Build.0 = Debug-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|Win32.Build.0 = Debug-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.ActiveCfg = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|x64.Build.0 = Debug-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM.Build.0 = Debug-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|Win32.Build.0 = Release-dll|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.ActiveCfg = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|x64.Build.0 = Release-dll|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM.Build.0 = Release-dll|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.ActiveCfg = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|Win32.Build.0 = Release-static|Win32 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.ActiveCfg = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|x64.Build.0 = Release-static|x64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.ActiveCfg = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM.Build.0 = Release-static|ARM {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {310F39BD-A2D6-44FF-8344-37ADD0524CBD}.Release-static|ARM64.Build.0 = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|x64.Build.0 = Debug-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|Win32.Build.0 = Debug-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.ActiveCfg = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|x64.Build.0 = Debug-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM.Build.0 = Debug-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|Win32.Build.0 = Release-dll|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.ActiveCfg = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|x64.Build.0 = Release-dll|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM.Build.0 = Release-dll|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.ActiveCfg = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|Win32.Build.0 = Release-static|Win32 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.ActiveCfg = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|x64.Build.0 = Release-static|x64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.ActiveCfg = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM.Build.0 = Release-static|ARM {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {294D5317-E983-4682-8DB5-678EA4645E11}.Release-static|ARM64.Build.0 = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|x64.Build.0 = Debug-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|Win32.Build.0 = Debug-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.ActiveCfg = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM.Build.0 = Debug-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Debug-static|x64.Build.0 = Debug-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|Win32.Build.0 = Release-dll|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.ActiveCfg = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|x64.Build.0 = Release-dll|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM.Build.0 = Release-dll|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.ActiveCfg = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|Win32.Build.0 = Release-static|Win32 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.ActiveCfg = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|x64.Build.0 = Release-static|x64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.ActiveCfg = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM.Build.0 = Release-static|ARM {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {77A27E6D-9A39-40B8-961B-40E63DB7FA65}.Release-static|ARM64.Build.0 = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.ActiveCfg = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|Win32.Build.0 = Debug-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.ActiveCfg = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|x64.Build.0 = Debug-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.ActiveCfg = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM.Build.0 = Debug-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.ActiveCfg = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-dll|ARM64.Build.0 = Debug-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.ActiveCfg = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|Win32.Build.0 = Debug-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.ActiveCfg = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|x64.Build.0 = Debug-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.ActiveCfg = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM.Build.0 = Debug-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.ActiveCfg = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Debug-static|ARM64.Build.0 = Debug-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.ActiveCfg = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|Win32.Build.0 = Release-dll|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.ActiveCfg = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|x64.Build.0 = Release-dll|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.ActiveCfg = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM.Build.0 = Release-dll|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.ActiveCfg = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-dll|ARM64.Build.0 = Release-dll|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.ActiveCfg = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|Win32.Build.0 = Release-static|Win32 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.ActiveCfg = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|x64.Build.0 = Release-static|x64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.ActiveCfg = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM.Build.0 = Release-static|ARM {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.ActiveCfg = Release-static|ARM64 {0192C6B5-D870-4857-B673-471E3EBD41D4}.Release-static|ARM64.Build.0 = Release-static|ARM64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal libmicrohttpd-1.0.1/w32/VS2022/hellobrowser.vcxproj0000644000175000017500000000370414500102730015427  17.0 {310F39BD-A2D6-44FF-8344-37ADD0524CBD} Win32Proj hellobrowser x64 Application true false v143 true Unicode libmicrohttpd-1.0.1/w32/VS2022/hellobrowser.vcxproj.filters0000644000175000017500000000041514417460232017105  libmicrohttpd-1.0.1/w32/VS2022/libmicrohttpd.vcxproj0000644000175000017500000000414214500102730015561  17.0 {9CFB0342-A9E7-483E-BEE5-A1DE22584C5A} Win32Proj libmicrohttpd x64 StaticLibrary DynamicLibrary true false v143 true Unicode libmicrohttpd-1.0.1/w32/VS2022/largepost.vcxproj0000644000175000017500000000372214500102730014720  17.0 {77A27E6D-9A39-40B8-961B-40E63DB7FA65} Win32Proj largepost x64 Application true false v143 true Unicode libmicrohttpd-1.0.1/w32/VS2022/libmicrohttpd.vcxproj.filters0000644000175000017500000000041614417460232017243  libmicrohttpd-1.0.1/w32/VS2022/simplepost.vcxproj0000644000175000017500000000370014500102730015113  17.0 {294D5317-E983-4682-8DB5-678EA4645E11} Win32Proj simplepost x64 Application true false v143 true Unicode libmicrohttpd-1.0.1/ChangeLog0000644000175000017500000046133714566137250011637 Fri 23 Feb 2024 21:00:00 UZT Releasing GNU libmicrohttpd 1.0.1 -EG February 2024 Fixed builds without messages. -JP & CG Fixed builds with external MD5 calculation. Fixed SHA-512/256 code for hypothetical extra large sizes. Fixed response handling during daemon shutdown. Fixed code logic for builds without messages. Reduced the binary size for builds without messages by removing the strings with filenames used for panic reports. Fixed tests and examples for builds without messages and for builds without basic auth. Fixed some compiler warnings. -EG Thu 01 Feb 2024 15:00:00 CET Releasing GNU libmicrohttpd 1.0.0 -EG January 2024 add missing lock, do not call 'close(-1)' on very rare error path. use correct HTTP header (content type, not content encoding) for mime type in examples. fix memory leak on error path. -CG MHD_OPTION_CONNECTION_MEMORY_{LIMIT,INCREMENT}: added ignore of zero value. test_upgrade{,_large}{,_tls}: unified code, removed workarounds, added new test. digest_auth_example_adv: added new advanced example for the new Digest Auth API use. Fixed compiler warnings in configure, lib, examples, tests. test_digestauth2: supported old libcurl versions. Fixed tests with GnuTLS in non-default path. configure: sorted messages in final config summary. Fixed non-debug build without HTTPS. configure: removed old workaround for Solaris. test_upgrade: adapted for macOS. -EG December 2023 "Upgraded" TLS connections: fixed data pumping in various edge conditions. 'bootstrap': fixes and simplifications. Digest Auth: added default timeout and max nc values, added daemon options for default nonce timeout and max nc values, added testing, implemented setting DAuth defaults by configure parameters. -EG November 2023 Updated HTTP methods, headers and reason phrases. Renamed one new basic auth function, improved doxy. digest auth: updated header, slightly modified multi-value processing. -EG websocket_threaded_example: fix websocket url string. -Evgeniy Gavrilenko configure: warn if building without threads. -EG configure: added detection of FD_SETSIZE value and ability to override it. internal.h: added macros for polling mode detection. Added use of configure-detected system default FD_SETSIZE value. internal.h: added macros for internal threads modes detection. Added MHD_OPTION_APP_FD_SETSIZE and MHD_FEATURE_FLEXIBLE_FD_SETSIZE. daemon.c: moved processing and checking of app-provided listen socket. MHD_start_daemon(): mark listen as UNIX based on available information. MHD_start_daemon(): added stricter checks for bind() and listen() return values. MHD_start_daemon(): added check for epoll FD to fit fd_set for external polling mode. Implemented and documented MHD_OPTION_LISTEN_SOCKET followed by MHD_INVALID_SOCKET. Fixed ignored daemon port when MHD_OPTION_LISTEN_SOCKET or MHD_OPTION_SOCK_ADDR are used as documented. MHD_start_daemon(): further improved UNIX / IP socket detection. Implemented new option MHD_OPTION_SOCK_ADDR_LEN. MHD_start_daemon(): added check for app-provided socket to fit fd_set. MHD_start_daemon(): fixed leaked listen socket when daemon start failed. MHD_add_connection(): added more checks for correct members of sockaddr. Timeout handling added detection of more conditions to process the data without waiting. MHD_quiesce_daemon(): fixed return value if already quiesced. MHD_start_daemon(): reject INTERNAL_POLLING_THREAD if threads are disabled. test_daemon: fixed to not skip the test if failed. test_digestauth2: fixed order of the initial checks. Improved daemon shutdown handling in external polling mode. Unified and simplified fd_set filling. Added new daemon flag MHD_USE_NO_THREAD_SAFETY and testing. Officially support zero for MHD_OPTION_THREAD_POOL_SIZE. test_upgrade: used sized send and receive, removed VLA, other improvements. test_upgrade: implemented proper timeout detection and handling. -EG September 2023 fix #7928: correct tutorial direntry. proper fix for #7757. -CG W32 VS projects: added perf_replies. W32 VS projects: added .editorconfig. perf_replies improvements for W32. mhd_threads: muted compiler warning on W32. mhd_threads: fixed check for error when starting a new thread on W32. Renamed 'pid' -> 'tid' when used for threads. mhd_str: fixed possible compiler and run-time sanitizers warnings. Muted and fixed some compiler warnings. W32 VS project: corrected compiler settings. W32 VS: really muted run-time false warnings about data truncation. examples/sessions.c: fixes. Fixed missing includes. Refactored threads support to handle platforms without "invalid" ID value. Fixed MHD_CONNECTION_INFO_DAEMON: return master daemon. -EG check rvalues from pthread_mutex_, MHD_add_response_header, MHD_post_process in examples. Theoretical use-after-free in test on error path. -CG Do no use internal magic number if it is used by the remote client. Refactoring: store "request target" original length. Detect error earlier if request HTTP version is bad. Added calculation of request headers total size. Rewritten handling of exhaustion of memory pool when receiving. tests: fixed compiler warnings, copy-paste error, added error reporting. test_long_header: re-use the same port for all checks. Control acceptance of LF as CRLF in chunked encoding in the same way as in headers parsing. Improved compatibility with old compilers. Fixed more compiler warnings. -EG Sun Sep 3 12:23:18 AM CEST 2023 Prevent queueing of responses if connection is not currently in the access handler callback (which was always not allowed per API spec, but is now met with an appropriate error response). Fixes #7757. -CG August 2023 Improved CPU cores detection in perf_replies. -EG July 2023 Added new tool perf_replies with automatic detection of number of available CPU on system and for the program. -EG June 2023 Bump version numbers as v0.9.77 was released on parallel branch. Added test for MHD_get_version{,_bin} function and related macros. base64 decoding: added more compact code version. Refactoring: check whether memory pool block is resizeable. Re-implemented parsing of the request line from scratch with strict conformance with RFC 9110 and 9112 requirements. Re-implemented parsing of the request headers and footers from scratch with strict conformance with RFC 9110 and 9112 requirements. Fuzzing tests: almost completely re-implemented. The new version is unified and much easier to maintain. Added new tests for folded headers. Corrected HTTP error responses for clients. connection: fixed pipelined requests processing. Added checks for correct values specified for connection memory limits. process new connection: fixed missing mutex unlock in error handling path. W32 VS Projects: fixed code parsing by GUI. Focused all read-buffer grows in a single point, related improvements. -EG May 2023 Improved portability of boostrap (and autogen.sh) Muted more compiler warnings in configure. Tests: updated to support new libcurl APIs and fixed deprecation warnings with new versions (the old versions are supported still). Tests: minor and cosmetic fixes and improvements. Tests: compiler warnings fixes. configure: bump gettext version. Tests: fixed build with C89 compilers. Tests: fixed tests on Darwin 22.x (Ventura). Tests: redesigned one tests group to avoid stress-testing of the OS. configure: improved portability for exotic platforms. examples: removed non-portable functions, added some checking, fixed compiler warnings, fixed erroneously commented out code. configure: fixed detection of __FUNCTION__ magic macro. Unified function name magic macros usage in code. W32 VS projects: supported ARM and ARM64. Fixed compiler warning on x32. Some minor fixes for W32 VS compilation. -EG April 2023 Implemented and used new function MHD_pool_deallocate(). Updated libtool fixes. Removed some autotools files from git. Added autoconf patches and fixes. {md5,sha256}_ext.c: fixed processing of initialisation error with NULL handler. -EG March 2023 Upgraded TLS: fixed inefficient communication. Upgraded TLS: use more available memory for pumping the data. -EG Web 29 Mar 2023 20:56:00 CEST Bumped version as the hotfix was released based on the separate branch. -EG March 2023 configure: reordered checks for compiler flags. configure: fixed checks for tsearch() and related changes. Makefile: fixed build with 'make' without nested vars support. configure: fixed compiler warnings. libcurl.m4: patched to fix compiler warning. configure: internal fixes, compiler warning fixes, cosmetics, better POSIX compatibility, fixed compatibility with old autoconf. Upgraded TLS: warn if emergency buffer is used. -EG Sun Feb 26 05:49:30 PM CET 2023 Fix potential DoS vector in MHD_PostProcessor discovered by Gynvael Coldwind and Dejan Alvadzijevic (CVE-2023-27371). -CG February 2023 epoll: immediately notice when other side closes the socket, instead of waiting for timeout. -CG December 2022 Refactored cookies parsing. Always close connection after reply if both Content-Length and chucked are used. This is specified by RFC. Added new daemon option MHD_OPTION_CLIENT_DISCIPLINE_LV with more detailed control of accepted/rejected non-standard requests. Added new M4 helper macro. configure: used better detection of some functions when cross-compiling. configure: try to detect whether eventfd is enabled. Compiler warning fixes. Improved reported strings in tests. -EG November 2022 connection: refuse requests with unsupported Transfer-Encoding. connection: reject or log requests with both chunked encoding and Content-Length. tests: fixed checking response headers as null-terminated string. Some tests fixes. configure: check fixes. Refactored user-poison: minimized scope of non-sanitized code. digestauth: avoided malloc() repeating by using the new function. MHD_get_version_bin(): added new function. test_parse_cookies: rewritten. -EG October 2022 Reworked HTTPS tests. Removed hardcoded TLS version and ciphers, updated self-signed certificate. Fixed delayed call of connection notification callback in thread-per-connection mode. Fixed delayed new connection notification in thread-per-connection mode. Minor internal code improvements. Added handling of "DEBUG" preprocessor macro as an alias of "_DEBUG". TLS initialisation: re-implemented. New implementation trying to use "libmicrohttpd" system-wide GnuTLS configuration by default with fallbacks to generic system-wide GnuTLS configuration and default GnuTLS configuration. New daemon option to use addition to default configuration instead of specifying full configuration string. Added relevant tests for GnuTLS initialization. Added reporting of failed part of GnuTLS configuration string. Added MHD_FEATURE_DEBUG_BUILD value. Implemented internal protection from some wild data hypothetically reported by accept4(). Internal refactoring. Prevented sending "100 continue" if request has no body or if any part of request data has been received. Reworked handling of situation when app just partially processed the data: if any data was processed then zero timeout if used for polling sockets, if no data was processed then callback in not called until the new data arrived. Fixed handling of various errors conditions detected in requests. Added test with Content-Length broken value in request. test_head: added check for excess data in reply Improved epoll connection handling. Fuzzing tests: fixed CPPFLAGS. configure: do not pass AM_TESTS_ENVIRONMENT directly. configure: added summary message about heavy and fuzzing tests test-suite: marked some tests as "very heavy" tests configure: improved check for asserts. -EG September 2022 Added testing of userdigest and userhash calculations. Implemented SHA-512/256 from scratch. Digest Auth: implemented SHA-512/256 support, added MHD_FEATURE_DIGEST_AUTH_SHA512_256 and relevant tests. Made all algorithms (MD5, SHA-256, SHA-512/256) optional with ability to remove by configure parameter. Digest Auth: internal refactoring and improvements. configure: minor improvements. Fixed initialisation of very old GnuTLS versions. Replace public domain MD5 implementation with the new implementation written from scratch. MD5, SHA-256, SHA-512/256: various code improvements, special versions for compact code. Digest Auth: changed internal algorithm for re-use of nonce-nc slot. Digest Auth: used weak pseudo-random generators to avoid slot clashes. Implemented optional ability to use GnuTLS functions for MD5 and SHA-256 calculations. Fixed harmless unwanted extra data processing resulting in triggering of the assert. Added testing of HEAD requests. Minor internal changes. Fixed compiler warnings for compact code version. Muted compiler warnings with clang. Configure: more workarounds for clang on W32 with incorrect headers. Removed long-unused "gauger" from tests. Fixed compiler warnings in test. test_add_conn: added reasonable limits. -EG August 2022 Added testing of userhash parameter parsing. Added testing of the auth type headers in one request. Warn in log if random data has not been initialised. Digest Auth: improved response header in RFC2069 mode. Added more string processing internal functions. Digest Auth: added new option MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE to control nonces generation. Increased testing for Digest Auth. Digest Auth: do not use reproducible nonces generation by default. Minor correction for auth headers processing. Digest Auth: internal refactoring. Digest Auth: added algorithm value to username info (required for userhash values). Digest Auth: added new public functions for userhash and userdigest calculations. -EG July 2022 Digest Auth: internal optimisations and refactoring, digest_auth_check almost completely rewritten. Digest Auth: removed use of VLA. Digest Auth: added support for username in extended notation and test for extended notation. Digest Auth: implemented userhash support and tests for extended notation. MHD_add_response_entry(): refactoring Digest Auth: implemented DAuth response function MHD_queue_auth_required_response3() from scratch. Removed old implementations, old functions converted to wrappers for the new function. Digest Auth: added new group of tests. Digest Auth: added related MHD_FEATURES_* values. Digest Auth: added detection of the algorithm used by the client and use specified algorithm if allowed by application. Configure: cosmetics and reports improvements, control static and shared enablement by --enable-build-type=. Added new daemon option MHD_OPTION_DIGEST_AUTH_RANDOM_COPY and tests. Digest Auth: implemented support for old RFC 2069 (if allowed by app) and tests for RFC 2069. Internal refactoring: moved all request-related connection struct members to dedicated struct. The same for reply-related struct members. Implemented support for both Basic and Digest headers in the same request. -EG June 2022 Fixed compiler warnings in main code and examples. Added error checking in examples. Added test for parsing auth headers. Improved parsing of auth headers. Added more internal functions for quoted string processing. Added test for quoting string processing. Digest Auth: internal optimisations. Basic Auth: fixed handling of realms with slashes and/or double quotes. Digest Auth: fixed use of possible maximum client nonce length as maximum server nonce length. Reduced size of internal arrays. Basic Auth: new function MHD_queue_basic_auth_fail_response3() with support for RFC 7617. Basic Auth: added new function MHD_basic_auth_get_username_password3() with more details about username and password. Technically allow binary zero in username and in password. Fixed data races when closing upgraded connection. Replaced public domain Base64 decoder with the new implementation written from scratch. The new implementation has very precise checks for the input data. Added new test for Base64 decoding. Updated examples to use new Basic Auth functions. Fixed and improved postprocessor tests. Ported test to non-VLA compilers. Added configure parameter --enable-compact-code. Removed duplication of "Connection: upgrade" header. Patch by Alexander Irion. Configure: removed some unneeded compiler flags. Digest Auth: improved RFC match (qop value caseless match), check parameters length validity before checking the values validity, correctly compare URLs with binary zeros, check URL arguments only in the same order as specified in DAuth header. Added internal functions for percent-decoding and tests for percent-decoding. Added internal function for hex to bin decoding, tests for hex<->bin decoding. Digest Auth: added new function MHD_digest_auth_get_request_info3() and MHD_digest_auth_get_username3() with detailed information about DAuth request. -EG Fixed memory leaks in tests. Fixed wrong array size for Digest Auth. -CG May 2022 Improved public doxy. Digest Auth: fixed missing mark on 'nc' value as 'used'. Digest Auth: added internal checks for unrealistically high values. Digest Auth: added check for correct values from application. Digest Auth: nonce timestamps changed to milliseconds to lower conflict probability. Digest Auth: implemented management nonce-nc map array slots so old entries are removed safely while trying to avoid to remove the new entries. configure: added 'debugger' build type. Added more tests for cookies parsing. Digest Auth: use nonce-nc map arrays with locks in master daemon only so works can re-use the nonces and nc information. MHD_set_connection_option(): reduced scope for the lock. Fixed leak of mutexes when daemon creation failed and when closing daemon with thread pool. Digest Auth: fixed stale nonce result value ambiguity. Digest Auth: added special check for fabricated nonces. Added new functions MHD_digest_auth_check3() and MHD_digest_auth_check_digest3() with detailed result of the checks. Added return NULL MHD_CONNECTION_INFO_CLIENT_ADDRESS when information is not available. Improved internal handling of non-IP connections (UNIX sockets or pipes) when processing the client address. Fixed compiler warnings. Increased testing of cookies parsing. Completely re-written cookies parsing. The new code follow RFC 6265. Made cookies parsing functionality optional, can be disabled by configure. Configure: added more warning flags. Configure: internal improvements. Globally changed '#if HAVE_SOMETHING' to '#ifdef HAVE_SOMETHING'. Enabled more compiler warnings in W32 projects. Fixed MHD functionality with blocking sockets. Patch by Kolja Nowak. Moved some macros and declaration to new specialised headers: basicauth.h and digestauth.h. Added new function to process quoted strings. Digest Auth: reworking support for multiple digest algorithms. Response processing: better handle unrealistic but broken situation. Basic and Digest Auth: completely reworked headers parsing, unified code. Added new autoconf macros. Configure: added more workarounds for clang. Fixed possible use of uninitialised variable. Added new test for Basic Auth. Some code readability improvements. -EG April 2022 Added autoconf macro for checking compiler parameter/flag. Improved -fvisibility compiler flag support detection in configure. Fixed compiler warnings. Moved fixed libtool-specific flags to Makefile from configure. Configure: added reporting of final compiler/linker flags. Fixed ignored user linker flags when building library binary. Improved makefiles dependency specification. Implemented --enable-build-type=TYPE configure parameters for ready-to-use configuration sets (defaults). Separated internal types for request headers and response headers. Fixed many unneeded drops of 'const' qualifier, converted some pointers to 'const'. Added use of _MHD_EXTERN with all external function definitions. Refactored response creation functions. Added new function MHD_create_response_from_buffer_static() to avoid unwanted dropping of 'const' when application is using static strings. Added new API function MHD_create_response_from_buffer_copy(). Public doxy improvements. Improved handling of TLS backends for libcurl when testing HTTPS. Updated TLS certificates for tests and examples. New certificates were generated with SAN fields to match actual requirements. Fixed old style function definitions in examples. Tuned compiler warning flags. Fixed many preprocessor macros (removed space before bracket). Fixed printf() format specifications in examples. Removed non-literal strings for printf in examples. Improved portability of examples. Fixed unaligned access via sockaddr_in pointers. Fixed unaligned access in MHD_get_connection_info() and MHD_get_daemon_info(). Compiler warning fixes. Changed: any negative number returned by response data generation callback function is treated as an error. Fixed setting custom connection timeout value for thread-per-connection mode. Fixed short (lees then one second) busy-waiting when connection is about to expire by switching to milliseconds accuracy instead of seconds. Added new functions MHD_get_timeout64(), MHD_get_timeout64s(), MHD_get_timeout_i(). Added some checks for possible value trim due to width conversion. Digest Auth: continuation of refactoring, optimisations. Digest Auth: do not use nonces provided by the client if they were not generated previously by MHD. -EG March 2022 Added internal check for suitability of used response. Improved doxy. Improved handling of application-provide "Content-Length" header. Internally separated "Icy" flag from the response code. Fixed Address Sanitizer unpoison of memory when memory pool is destroyed. Improved log messages. Added more checks for "Upgrade" handling. Better internally separated response type handling: headers only without body-specific headers, body-specific headers without body (Content-Length/Transfer-Encoding), all headers with body. Blocked MHD_SIZE_UNKNOWN value for buffer-based responses. Significantly improved doxy for MHD_queue_response(). Added new function MHD_create_response_empty() Fixed compiler flags for UBsan in configure. Added new option for "--enable-sanitizers=" parameter. Improved autoconf macros. -EG January 2022 Tuned automake options. Fixed compiler warning in examples. Fixed use of initialised variable in tests. Removed unused autotools files. .gitignore: cleanup and update. Autotools: always let user override build flags. Moved 'po' files to separate directory. Fixed missing include file in docs. Fixed 'make distcheck'. Fixed use on GNU/kFreeBSD. Fixed HTTP/1.1 or 1.0 selection in tests. Other tests improvements and fixes. Digest Auth: changed "md5" / "sha-256" to "MD5" / "SHA-256" to better match RFC (while clients should use caseless matching). Initial digest auth refactoring, reject invalid input. Global rename of callback parameter 'con_cls' -> 'req_cls'. Digest auth tests improvements and fixes. Added test for parallel digest auth requests. Minor autoconf macros fixes. -EG December 2021 configure: fixed unwanted output on Fedora. configure: clarified licence message. Doxy corrections and improvments. -EG Sun 26 Dec 2021 20:30:00 MSK Releasing GNU libmicrohttpd 0.9.75 -EG December 2021 Fixed Makefile warning on MinGW. Fixed compiler warning on MinGW. Fixed "configure" portability (for NetBSD). MSVC project cosmetics. MSVC fixed project to fix linker warning. Fixed compiler warning on some platforms. Further improved test_client_put_stop to get stable results on all platforms. Added workaround for platforms (like OpenBSD) where system monotonic clocks may jump forward and back. Added more checks in test_large_put, increased timeout (was too small for this test). -EG Sun 19 Dec 2021 18:30:00 MSK Releasing GNU libmicrohttpd 0.9.74 -EG December 2021 Fixed doxy for MHD_suspend_connection(). Some code improvements for new test test_client_put_stop. Added special log message if thread creation failed due to system limits. Fully restructured new_connection_process_() to correctly handle errors, fixed missing decrement of number of daemon connections if any error encountered, fixed app notification of connection termination when app has not been notified about connection start, fixed (highly unlikely) reset of the list of connections if reached daemon's connections limit. configure: fixed some compiler warnings reported in config.log. Fixed tests on FreeBSD to support system-limited rate of RST packets and 'blackhole' system setting. -EG Fixed tests for libmagic to really use libmagic in examples. -CG Used tricks in code formatting to workaround uncrustify bugs. configure: improved compatibility with various shells. configure: added selective enable of sanitizers. Fixed compatibility with old GnuTLS versions. Fixed tests compatibility with old libcurl versions. Fixed busy-waiting in test_timeout (fixed CPU load spikes in the test). test_https_time_out: check rewritten, previously it is was no-op. test_upgrade{,_large}: fixed passing of socket value to GnuTLS on W32. Simplified Makefile for HTTPS tests. Added detection of old broken GnuTLS builds (on RHEL6 and clones) and disabled some tests broken with these builds. Muted compiler warnings with old libcurl versions. Reworked dlltool support: added support for weakened oversimplified half-broken llvm-dlltool Silenced MS lib tool warning and MS lib tool invocation. Added Makefiles rules for automatic regeneration of all required files if anything is missing. Added Makefile silent rules support for W32 RC and W32 static libs. Added local patches for autotools (mainly for libtool) to build MHD correctly on modern MinGW64/Clang. Updated HTTP headers macros from registry. -EG November 2021 Clarified comments and doxy for MHD_str* and related tests. MHD_uint32_to_strx(): rewritten for readability and minor optimization, used indexes instead of pointers. Documented in doxy how to use MHD_AccessHandlerCallback. mhd_sockets: added more network error codes. W32 socket pair: set TCP_NODELAY to avoid unwanted buffering and delays. Additional doxy fixes in microhttpd.h. Fixed blocking sockets setting in tests and examples for W32. Added checks for fcntl() results in tests and examples. Added series of tests based on simple HTTP client implementation developed for testing of MHD. Renamed 'early_response' connection flag to 'discard_request' and reworked handling of connection's flags. Clarified request termination reasons doxy, fixed reporting of MHD_REQUEST_TERMINATED_READ_ERROR (previously this code was not really used in reporting). Enforce all libcurl tests exit code to be zero or one. Rewritten client upload processing: removed redundant checks, fixed skipping of chunk closure when not data is not received yet, fixed skipping of the last LF in termination chunk, handle correctly chunk sizes with more than 16 digits (leading zeros are valid according to HTTP RFC), fixed handling of CRCR, LFCR, LFLF, and bare CR as single line delimiters, report error when invalid chunk format is received without waiting to receive (possibly missing) end of the line, reply to the client with special error if chunk size is too large to be handled by MHD (>16 EiB). Added error reply if client used too large request payload (>16 EiB). Fixed return value for MHD_FEATURE_AUTOSUPPRESS_SIGPIPE on W32, now it returns MHD_YES as W32 does not need sigpipe suppression. configure: reordered and improved headers detection. Some headers require other headers to be included before, now configure supports it. Added missing ifdef guard for . mhd_sockets: reordered includes for better compatibility. Some code readability and formatting improvements. -EG October 2021 Added test family test_toolarge to check correct handling of the buffers when the size of data is larger than free space. Fixed missing updated of read and write buffers sizes. Added detection and use of supported "noreturn" keyword for function declaration. It should help compiler and static analyser. Added support for leak sanitizer. Fixed analyser errors on W32. Partially reworked memory allocation from the pool, more robust implementation, always track read and write buffers. Added custom memory poisoning in memory pool with address sanitizer. Added missing update of the read buffer size. Addition for doxy for new behaviour of MHD_del_response_header(). Added two tests with non-standard symbols in requests. Removed double close of connection with error in headers processing. Respond to the client with error if chunked request has broken chunked encoding as required by HTTP RFC instead of just closing the connection. Fixed request headers processing. Do not recognize bare CR as end of line. Fixed processing of CRCR, bare CR, LFCR, and LFLF as end of the line for request chunked encoding. Now only CRLF or bare LF are recognized as end of line. Added Lawrence Sebald to the AUTHORS file (iovec-based responses). Check for PAGESIZE and PAGE_SIZE macros and check whether they can be used for static variable initialization. Include "MHD_config.h" before all other includes to set macros required to be set before standard includes. Chunked response: abort with error if application returns more data than requested. Monotonic clock: use only native clock on W32 as all other clocks are just wrappers. W32: fixed builds with MSVC, added projects for VS2022, added MSVC universal project that use latest available toolset, use C17 if supported. Chunked response: fixed calculation of number of bytes left to send. microhttpd.h: doxy clarifications for sockets polling. Updated HTTP statuses, methods, and headers names from the registries. Further improved doxy for MHD_add_response_header(). A few comments improvements and clarifications. Added internal connection's flag indicating discard of the request. -EG Websockets update by David Gausmann. -DG Fixed reported value for MHD_CONNECTION_INFO_CONNECTION_TIMEOUT. Minor code readability improvements in MHD_set_connection_option(). Improved doxy for MHD_get_timeout(). Memorypool: minor code improvements. -EG September 2021 Improved system includes headers detection and usage. Removed unused headers detection. Added indirect calculation of maximum values at compile time by using types size detection. These values are used only to mute compiler warnings. Fixed pre-compiler errors if various *_MAX macros defined with non-digits symbols not readable for pre-compiler. Limit number of used CPU cores in tests to 6, unless heavy tests are enabled. Disabled parallel tests with libcurl if heavy tests are enabled. configure: removed '--enable-sanitizer' and added '--enable-sanitizers' parameters. Added testing for supported sanitizers and enabling only supported sanitizers. Added support for run-time sanitizers settings for tests when sanitizers are enabled. Added support for undefined behavior sanitizer without run-time library. Fixed various undefined behavior sanitizer detected errors, improved portability. Fixed how bitwise NOT is used with enum, fixed portability. microhttpd.h: changed macros MHD_CONTENT_READER_* to use ssize_t. test_postprocessor: added more check, improved error reporting, added new test data. postprocessor: fixed undefined behavior (memcpy(), memmove() with zero size and NULL pointer). Updated copyright year in W32 DLLs. postprocessor: fixed empty key processing. test_postprocessor: added tests with hex-encoded values. postprocessor: fixed incomplete processing of the last part of hex-encoded value if data was broken into certain sized pieces. Used type specifiers for printf() from inttypes.h to improved compatibility with various run-time libs. Fallback to standard values if type specifiers are not defined. Added detection of used run-time library (MSVCRT/UCRT) on W32. testcurl: fixed incorrect case-insensitive match for method name. Method name must be checked by using case-sensitive match. microhttpd.h: clarified some doxy descriptions. Prevented potential double sending of error responses. Fixed application notification with MHD_REQUEST_TERMINATED_COMPLETED_OK when error response has been sent (MHD_REQUEST_TERMINATED_WITH_ERROR is used). Avoid trying to send error response if response is already being sent. Improved log error message when error response is processing. -EG August 2021 Silently drop "keep-alive" token from response "connection" header, "keep-alive" cannot be enforced and always enabled if possible. Further improved doxy for MHD_add_response_header(). Added detection of the "Date:" header in the response headers set by app at response forming time. Disallow space in response header name, allow tab in response header value. Added internal MHD_uint8_to_str_pad() function. Used internal MHD_uint8_to_str_pad() in datestamp generation function. Added detection and reporting of incorrect "Upgrade" responses. -EG Fixed short busy waiting (up to one second) when connection is going to be closed. -AI Minor improvement for test_callback, test_get_chunked Fixed chunked responses with known size. Added two more tests for chunked response. Fixed chunked responses with predefined data (without data callback). Fixed calculation of the buffer size for the next response chunk. Completely rewritten reply header build function. The old version had several levels of hacks, was unmaintainable, did not follow HTTP specification in details; fixed used caseless header matching where case-sensitive matching must be used; removed two passes of header building. New version use clear logic and can be extended when needed. Changed behaviour: "Connection: keep-alive" is not being sent for HTTP/1.1 connection (as per HTTP RFC). test_get_chunked: fixed error reporting. HTTPS tests: fixed memory leaks if function failed. libcurl tests: improved handling of curl multi_*. Added two tests for correct choice of "Keep-Alive" or "Close". Simplified Makefile for testcurl. Fixed select() error handling in tests. microhttpd.h: minor macro formatting Changed behaviour: if response size is unknown and chunked encoding is allowed, chunked encoding is used even for non-keep-alive connection as required by HTTP RFC. Added two more tests for chunked replies. Simplified keepalive_possible(); added new value for MHD_ConnKeepAlive, added third state "Upgrade". Changed behaviour: used HTTP/1.1 replies for HTTP/1.0 requests as required by HTTP RFC. HTTP/1.0 reply still can be enforced by response flag. Added more doxy for MHD_ResponseFlags, added new names with the same values as old names: MHD_RF_HTTP_1_0_COMPATIBLE_STRICT and MHD_RF_HTTP_1_0_SERVER. Added new value MHD_RF_SEND_KEEP_ALIVE_HEADER to enforce sending of "Connection: keep-alive" even for HTTP/1.1 clients when keep-alive is used. test_get_close_keep_alive: added more combinations of parameters to check. Added separate flag for chunked response in connection instead of reusing the same flag as for chunked request. Added new connection's flag "stop_with_error". Fixed empty first line processing: the request could be not processed unless something else kicks next processing the same connection again. Added new connection states: MHD_CONNECTION_REQ_LINE_RECEIVING, MHD_CONNECTION_FULL_REQ_RECEIVED, MHD_CONNECTION_START_REPLY to simplify states logic. Changed write buffer allocation logic: as connection buffer size is known and fixed, use initially use full buffer for writing and reduce size of part used for writing if another allocation from the same buffer needs to be done. Implemented helper function to automatically reduce the size of read or write part to allocate buffer for other needs. Added define of NDEBUG if neither _DEBUG nor NDEBUG are defined. As accepted sockets inherit non-blocking flag from listening socket on all platform except Linux, track this state to use less number of syscalls. Fixed compiler and static analyser warnings. Moved HTTPS tests helper file to the HTTPS tests directory. Minor Makefiles cleanup. Added support for new monotonic clock ids. Added new internal monotonic clock function with milliseconds accuracy. Fixed support of custom connection timeout in thread-per-connection mode. Added more error checking to test_timeout. microhttpd.h: removed duplicated macro. Refined timeouts handling. Switched from seconds resolution to milliseconds resolution, added automatic detection and support of low-resolution system clock to avoid busy-waiting at connection expiration. Added log message for too large timeout period (> 146 million years) with trim to supported values. -EG Wed 04 Aug 2021 06:56:52 PM CEST Introduce new MHD_CONNECTION_INFO_HTTP_STATUS. -CG July 2021 Added automatic response flags with detection when response is being formed. Added special processing for response "Connection" headers, combined multiple "Connection" headers into single header. Restructured MSVC project files. Changed MSVC project defaults to Vista+ (WinXP is still supported). Fixed copy-paste error in mhd_aligh.h, added support for MSVC. Added internal function for printing hex and decimals numbers. Reply chunked body handling fixes, used new internal functions instead of snprintf(). Added automatic response flag when app sets chunked encoding header. New internal function for chunked reply footer forming. Unification with reply header forming function just over-complicated things and made function hardly maintainable. Added new function MHD_get_reason_phrase_len_for(), related tests and updated scripts for response phrases. Added more tests for chunked replies. Added function to reset connection state after finishing processing of request-reply to prepare for the next request. Added even more tests for chunked replies. Added internal function for printing uint64_t decimal numbers. -EG June 2021 Tests: implemented checking of response footer. Fixed loss of incoming data if more than half of buffer is used for the next request data. Fixed completely broken calculation of request header size. Chunked response: do not ask app callback for more data then it is possible to process (more than 16 MBytes). Check and report if app used wrong response code (>999 or <100) Refuse to add second "Transfer-Encoding" header. HTTPS tests: check whether all libcurl function succeeded. HTTPS tests: implemented new detection of TLS backend. HTTPS tests: fixed tests with new TLS defaults (SSL forbidden). Implemented detection of basic HTTP methods, fixed wrong caseless matching for HTTP method names. MHD_create_response_*() functions: improved doxy. MHD_add_response_header: added detailed comment about automatic headers. Do not allow responses with 1xx codes for HTTP/1.0 requests. Fixed used order of headers: now user response headers are used in the same order as was added by application. Added new internal function MHD_get_response_element_n_(). Added detection of more compiler built-ins for bits rotations. Minor optimisation of caseless strings matching. Added MHD_str_remove_token_caseless_() function and tests. Added MHD_str_remove_tokens_caseless_() function and tests. -EG May 2021 Doxy description clarifications for MHD_get_timeout() and related functions. Added MHD_create_response_from_buffer_with_free_callback_cls(). Added SHA-1 calculation (required for WebSockets). Added new internal header mhd_aligh.h for checking alignment of variables. Fixed SHA-256 and MD5 calculation with unaligned data. Added tests for hashes with unaligned data. Used compiler built-ins for bits rotations. Added detection of HTTP version at early stage. Added early response of unsupported HTTP version. Fixed wrong caseless matches for HTTP version strings. Added calculation of error responses at compile time (avoided repeated strlen() for known data). -EG April 2021 New test for reply chunked encoding. -EG Mon 26 Apr 2021 02:09:46 PM CEST Importing experimental Websocket support by David Gausmann. -CG Sun 25 Apr 2021 14:00:00 MSK Releasing GNU libmicrohttpd 0.9.73. -EG Sat 24 Apr 2021 23:00:00 MSK Fixed build with Clang and Visual Studio. MSVS project files updated. Enabled bind port autodetection with MSVS builds. -EG Fri 23 Apr 2021 14:27:00 MSK Fixed build without TLS lib. Fixed build without system poll() function. Fixed compiler warnings on 32-bit platforms. Fixed various compiler warnings. -EG Thu 22 Apr 2021 12:32:00 MSK Fixed some typos. Force disable TCP_CORK, TCP_NOPUSH, and TCP_NODELAY before switching connection to "upgraded" mode. Improved portability of the test-suite for upgraded connections. -EG Tue 20 Apr 2021 17:11:00 MSK Disabled NLS by default in configure. -EG Mon 19 Apr 2021 18:58:00 MSK Fixed testzzuf/test_put_chanked to correctly use MHD. Added internal error code for TLS errors. Added all missing messages to the .pot file. Detect more types of errors for receiving data and report error description in the MHD log. Added support for ALPN on TLS connections if supported by used TLS library. -EG Sun 18 Apr 2021 20:47:00 MSK Removed dead code. Limited iov-backed responses size to SSIZE_MAX as limited by system calls. Report error message in MHD log for send errors. -EG Sat 17 Apr 2021 18:50:00 MSK Unified upgrade test behavior for all platforms. Some code simplification and unification. Compiler warning (false positive) fixed. -EG Fri 16 Apr 2021 17:58:00 MSK Used run-time value if IOV_MAX if available. Fixed portability of error handling for sending functions. Detect pipes/unix sockets on fly and do not use TCP/IP specific functions with them. Fixed support of UNIX sockets on non-Linux kernels. -EG Fri 16 Apr 2021 10:23:39 AM CEST Detect if a socket is a UNIX domain socket and do not try to play with TCP corking options in this case (avoids useless failed syscalls). -CG Thu 15 Apr 2021 18:56:00 MSK Fixed configure '--enable-sanitizer' parameter. Stopped pushing of partial responses when limited by system maximum size for sendmsg(). -EG Web 14 Apr 2021 22:20:00 MSK Fixed: use sendmsg() in POSIX-compatible way, do not try to send more than IOV_MAX elements per single call. -EG Sun 11 Apr 2021 15:44:00 MSK Updated test TLS certificates to not expired modern versions, restored HTTPS examples compatibility with modern browsers. TCP_NODELAY is not pre-enabled for HTTPS connection as it actually does not speed-up TLS handshakes on moders OSes. -EG Thu 01 Apr 2021 21:29:46 MSK Fixed MD5 digest authorization broken when compiled without variable length arrays support (notably with MSVC). Fixed and muted compiler warning. Deeper test with zzuf if configured with --enable-heavy-tests. Removed run-check of assert() in configure to avoid core dumps. -EG Thu 01 Apr 2021 17:46:00 MSK Added new function MHD_run_wait() useful for single-threaded applications without other network activity. Added tests for the new function. -EG Wed 17 Mar 2021 20:53:33 MSK Re-factored startup log parameters processing. Warn user if wrong logger could be used potentially. Added headers doxy with information about minimal MHD version when particular symbols were introduced. Added new daemon option to indicate SIGPIPE handling by application for daemons being run in application thread. -EG Wed 24 Feb 2021 19:23:00 MSK SIGPIPE-related macro minor refactoring for readability. Added new response iov function (and related framework), based on the patch provided by Lawrence Sebald and Damon N. Earp from NASA. -EG Thu 04 Feb 2021 06:41:34 PM CET Fix PostProcessor to always properly stop iteration when application callback tells it to do so. -CG Sun 24 Jan 2021 21:30:00 MSK Added '--enable-heavy-tests' configure parameter. Minor configure.ac and Makefiles fixes. -EG Tue 19 Jan 2021 17:59:00 MSK Fixed compatibility with autoconf. 2.70 Updated M4 macros. -EG Wed 06 Jan 2021 08:39:58 PM CET Return timeout of zero also for connections awaiting cleanup. -CG Tue 29 Dec 2020 15:39:00 MSK Improved speed of TLS handshake by pre-enabling TCP_NODELAY. -EG Mon 28 Dec 2020 21:36:00 MSK Releasing libmicrohttpd 0.9.72. -EG Mon 28 Dec 2020 09:37:00 MSK Completely reworked and rewritten TCP_CORK, TCP_NOPUSH, TCP_NODELAY and MSG_MORE handling. Reduced number of sys-calls, fixed portability for FreeBSD, OpenBSD, NetBSD, Darwin, W32, Solaris. Removed usage of gnutls_record_cork() as it fully blocks stream until final block is ready. Fixed compatibility with C90 compilers. Really started using sendmsg() for header + body combined single-call response sending. Fixed sending of response body by sendmsg() when it shouldn't be sent, like responses for HEAD requests. Improved error handling for gnutls_record_send(). Updated W32 resources for .DLLs. Fixed building with various disabled features (like messages, HTTPS, http-upgrade, authorization etc.) Fixed possible SIGPIPE generation when sendfile() is used (it was always possible on Linux that sendfile() produce SIGPIPE, now it's fixed). Several compiler warnings muted and/or fixed in the lib code and in the examples. -EG Sun 01 Nov 2020 17:17:00 MSK Fixed conflict with system CPU_COUNT macro. Minor improvements of error reporting in MHD daemon. Fixed FTBFS with GnuTLS versions before 3.1.9 Fixed test_add_conn for multi-CPU machines. Fixed analyzer warnings. Fixed use-after-free and resources leaks for upgraded connections in TLS mode with thread-per-connection. -EG Sun 25 Oct 2020 19:31:00 MSK Fixed epoll mode without listening socket. Minor improvements of thread sync. Fixed broken sendfile on FreeBSD. Fixed broken MHD with thread-pool and without listening socket. Added four tests for MHD_add_connection(). Fixed several resources leaks in error handlers. Re-implemented scheme of handling of externally added connections, fixed thread-safety. -EG Wed 21 Oct 2020 10:00:58 AM CEST Corking should be OFF when sending the footer (#6610). -AP/CG Wed 07 Oct 2020 11:07:00 MSK W32 default target version changed to Vista, XP is still supported. Minor fixes and additional asserts for memorypool. IPv6 tests are not used if IPv6 is disabled at run-time. -EG Sun 27 Sep 2020 10:08:03 PM CEST Fixed incorrect triggering of epoll edge polling for "upgraded" TLS connections. Fixed a few cases where gnutls_record_uncork() return value was still ignored, possibly causing buffer to not be flushed correctly. -CG Sat 26 Sep 2020 08:18:02 PM CEST Make MHD_USE_NO_LISTEN_SOCKET work in conjunction with MHD internal threads. -CG/DE Thu 24 Sep 2020 16:55:00 MSK Fixed compiler warnings on W32. Minor optimisation of MHD_YES/MHD_NO internal usage. Refactor and cleanup of internal debugging macros. Updated HTTP status codes, header names and methods from the registries. Fixed portability of test_upgrade_large. Minor testsuite fixes. Restored parallel build of libmicrohttpd (except tests). -EG Fri 11 Sep 2020 10:08:22 PM CEST Fix crash problem in PostProcessor reported by MD. -CG Fix GnuTLS configure test to check for gnutls_record_uncork. -CG Wed 19 Aug 2020 09:40:39 AM CEST Add logic to check on MHD_pool_reallocate() failure reported on the mailinglist (will NOT yet fix the issue). -CG Sun 26 Jul 2020 01:56:54 PM CEST Add MHD_create_response_from_pipe() to allow creating a response based on data read from a pipe. -CG Fri Jul 10 15:04:51 CEST 2020 Fixed Postprocessor URL-encoded parsing if '%' fell on boundary. -CG/MD Thu 02 Jul 2020 09:56:23 PM CEST Fixed return type of MHD_queue_basic_auth_fail_response. -CA/CG Sun 28 Jun 2020 09:36:01 PM CEST Fix buffer overflow issue in URL parser. Releasing libmicrohttpd 0.9.71. -CG Tue 16 Jun 2020 08:44:22 PM CEST Add logic to try again if GNUtls uncork() fails. -CG Wed 10 Jun 2020 09:44:29 PM CEST Fixed PostProcessor bug discovered by MD, which given certain parser boundaries caused the returned values to be wrong. -CG/MD Wed 08 Apr 2020 10:53:01 PM CEST Introduce `enum MHD_Result` for #MHD_YES/#MHD_NO to avoid using 'int' so much. Note that this change WILL cause compiler warnings until (most) MHD callbacks in application code change their return type from 'int' to 'enum MHD_Result'. That said, avoiding possible confusions of different enums is going to make the code more robust in the future. For conditional compilation, test for "MHD_VERSION >= 0x00097002". -CG Tue 07 Apr 2020 02:58:39 PM BRT Fixed #5501 (Added example for how to provide a tiny threaded websocket server). -SC Tue 31 Mar 2020 02:36:40 PM BRT Fixed #6142 (applied several spelling fixes). -DKG/-SC Sat 07 Mar 2020 05:20:33 PM CET Fixed #6090 (misc. severe socket handling bugs on OS X). -CG Sat 08 Feb 2020 09:12:54 PM CET Fixed 100-continue handling for PATCH method (#6068). Fixed FTBFS from wrong #endif position for certain builds (#6025). Fixed connection overflow issue when combining MHD_USE_NO_LISTEN_SOCKET with MHD_USE_THREAD_PER_CONNECTION (#6036). Updated m4 script to fix FTBFS when using -Werror=unused-but-set-parameter (#6078). Releasing libmicrohttpd 0.9.70. -CG Thu Dec 26 14:43:27 CET 2019 Adding fix for urlencoding of keys without values in post-processor logic. -CG Tue 24 Dec 2019 03:32:18 PM CET Adding patch from Ethan Tuttle with test case for urlencoding in post-processor for keys without values. -CG/ET Sun 15 Dec 2019 02:12:02 PM CET Fix send() call (affects Mac OS X). #5977 -CG/fbrault Releasing libmicrohttpd 0.9.69. -CG Fri 29 Nov 2019 11:22:25 PM CET If application suspends a connection before we could send 100 CONTINUE, give application another shot at queuing a reply before the upload begins. -CG Sat 26 Oct 2019 06:53:05 PM CEST Fix regression where MHD would fail to return an empty response when used with HTTPS. Releasing libmicrohttpd 0.9.68. -CG/TR Fri 25 Oct 2019 02:31:59 PM CEST Introduce MHD_RF_INSANITY_HEADER_CONTENT_LENGTH. -CG Thu 17 Oct 2019 04:50:52 PM CEST Integrate 0-byte send() method for uncorking for old FreeBSD/OS X systems into new mhd_send.c logic for uncorking. Releasing libmicrohttpd 0.9.67. -CG Fri 18 Aug 2019 00:00:00 PM UTC Fixes and optimizations for the setsockopt handling: * Added: MHD_UPGRADE_ACTION_CORK_ON and MHD_UPGRADE_ACTION_CORK_OFF to enum MHD_UpgradeAction (turn corking on/off on the underlying socket). * Use calls and flags native to the system for corking and other operations, tested with performance improvements on FreeBSD, Debian Linux, NetBSD, and cygwin. In particular, this adds selective usage of MSG_MORE, NODELAY, TCP_NOPUSH, TCP_CORK. -ng0 Fri 09 Aug 2019 10:07:27 AM CEST Copy compiler and linker hardening flags from GNUnet (updating configure.ac). -CG Thu 01 Aug 2019 01:23:36 PM CEST Releasing libmicrohttpd 0.9.66. -CG Thu 01 Aug 2019 12:53:49 AM CEST Fix issue with discarding unhandled upload data discovered by Florian Dold. -CG Mon 29 Jul 2019 08:01:50 PM CEST Fix hanging situation with large transmission over upgraded (i.e. Web socket) connection with epoll() and HTTPS enabled (as reported by Viet on the mailinglist). -CG Thu 25 Jul 2019 02:40:12 PM CEST Fixing regression introduced in cc5032b85 (bit mask matching of the header kinds in MHD_lookup_connection_value()), as reported by Jose Bollo on the mailinglist. -CG/JB Tue Jul 16 19:56:14 CEST 2019 Add MHD_OPTION_HTTPS_CERT_CALLBACK2 to allow OCSP stapling and MHD_FEATURE_HTTPS_CERT_CALLBACK2 to check for. -TR Fri Jul 05 2019 22:30:40 MSK Releasing libmicrohttpd 0.9.65. -EG Sun Jun 23 2019 21:27:43 MSK Many fixes and improvements for connection-specific memory pool: * Added asserts; * Added testing of reallocation; * Reallocation code rewritten to avoid extra allocation, when possible to reuse already allocated memory; * Large memory pools aligned to system page size; * Large memory pools on W32 are cleared more securely after use, optimised usage of system memory. Better handled connection's memory shortage situations: * error response could be sent to client even if all buffer space was used; * if buffer space become low when receiving, do not allocate last buffer space and use small receive blocks instead. Improved sending speed by using all available buffer space for sending. -EG Sun Jun 09 2019 20:27:04 MSK Releasing libmicrohttpd 0.9.64. -EG Sun Jun 09 2019 20:03:16 MSK Updated HTTP headers, methods and status codes from registries, Added scripts to import new headers, methods and status codes from registries, Minor doxyget comment fix, Added missing MSVS project files to tarball. Reodered includes in microhttpd.h -EG Mon 03 Jun 2019 11:45:52 PM CEST Apply MHD_-prefix to hash functions, even if they are not in the officially exported API. -CG/DB Sun Jun 02 01:52:11 MSK 2019 Support usage of SOCK_NOSIGPIPE on Solaris 11.4 and NetBSD 7+, finally avoid SIGPIPE on Solaris. -EG Sat Jun 01 22:51:50 MSK 2019 Do not report errors if AF_UNIX socket is used on *BSD. -EG Thu May 30 23:32:09 MSK 2019 Improved detection of 'getsockname()' in configure. Avoided using 'getsockname()' in code if not detected. -EG Sun May 26 23:32:49 MSK 2019 Fixed some tests on W32. -EG Sun May 26 23:05:42 MSK 2019 Better detection of sockaddr member in configure, fixed build on *BSD, Fixed compiler warnings, Updated and fixed libcurl tests. -EG Tue May 21 22:12:43 MSK 2019 Fixed doxygen comments, Avoid dropping 'const' qualifier in macros, Fixed some compiler warnings, Properly support automatic port detections on some platforms, Added checks for too long TLS parameters strings. -EG Tue May 21 17:52:48 MSK 2019 Spelling fixes. -EG Mon May 20 15:39:35 MSK 2019 Compiler warning fixes. -EG/CG Fixed example for non-64bits platforms. -EG Wed May 15 23:51:49 MSK 2019 Optimized and improved processing speed by using precalculated and already calculated lengths of strings. -EG Wed May 15 14:54:00 MSK 2019 Fixed build from source on GNU Hurd. -EG Mon May 6 11:58:00 MSK 2019 Updated README and COPYING files. MHD remains LGPLv2.1-licensed. -EG Fri May 3 20:08:00 MSK 2019 Store connection's keys and values with sizes; Speedup keys search be comparing key length first; Added functions for working with keys and values with binary zeros; Fixed test_postprocessor_amp to fail on problems. -EG Wed May 1 16:40:00 MSK 2019 Reverted change of MHD_KeyValueIterator, implemented MHD_KeyValueIteratorN with sizes for connection's key and value to get keys and values with binary zeros. -EG Mon 29 Apr 2019 01:26:39 AM BRT Fixed signed/unsigned comparison in example http_chunked_compression.c. -SC/TR Sun Apr 21 16:40:00 MSK 2019 Improved compatibility with MSVC compilers; Fixed MHD compilation by Clang/LLVM in VS; Used MSVC intrinsics for bit rotations and bytes swap; Added project files for VS2019. -EG Fri Apr 19 23:00:00 MSK 2019 Rewritten SHA-256 calculations from scratch to avoid changing LGPL version; Added usage of GCC/Clang built-ins for bytes swap to significantly improve speed of MD5 and SHA-256 calculation on platforms with known endianness. Added test for SHA-256 calculations. -EG Wed Apr 17 20:52:00 MSK 2019 Refactoring of mhd5.c: optimized, dead code removed; Faster MD5 calculation on little endian platforms; Bit manipulations moved to separate header file. Added tests for MD5 calculations. -EG Mon 15 Apr 2019 05:33:52 PM CEST Add MHD_USE_POST_HANDSHAKE_AUTH_SUPPORT and MHD_USE_INSECURE_TLS_EARLY_DATA flags. -CG Thu Apr 11 11:37:00 MSK 2019 Fixed MSVC 'Release' builds; Fixed usage of MSVC's assert. -EG Wed Apr 10 14:31:00 MSK 2019 Improved shell compatibility for 'bootstrap', removed bash-ism. Added wrapper script 'autogen.sh'. -EG Mon 08 Apr 2019 03:06:05 PM CEST Fix close() checks as suggested by MK on the mailinglist (#3926). -MK/CG Wed 20 Mar 2019 10:20:24 AM CET Adding additional "value_length" argument to MHD_KeyValueIterator callback to support binary zeros in values. This is done in a backwards-compatible way, but may require adding a cast to existing code to avoid a compiler warning. -CG Sun Feb 10 21:00:37 BRT 2019 Added example for how to compress a chunked HTTP response. -SC Sun 10 Feb 2019 05:03:44 PM CET Releasing libmicrohttpd 0.9.63. -CG Sat 09 Feb 2019 01:51:02 PM CET Extended test_get to test URI logging and query string parsing to avoid regression fixed in previous patch in the future. -CG Thu Feb 7 16:16:12 CET 2019 Preliminary patch for the raw query string issue, to be tested. -CG Tue Jan 8 02:57:21 BRT 2019 Added minimal example for how to compress HTTP response. -SC Wed Dec 19 00:06:03 CET 2018 Check for GNUTLS_E_AGAIN instead of GNUTLS_E_INTERRUPTED when giving up on a TLS connection. -LM/CG Thu Dec 13 22:48:14 CET 2018 Fix connection timeout logic if in thread-per-connection mode the working thread takes longer than the timeout to queue the response. -CG Tue Dec 11 09:58:32 CET 2018 Add logic to avoid VLA arrays with compilers that do not support them. -CG Sat Dec 8 23:15:53 CET 2018 Fixed missing WSA_FLAG_OVERLAPPED which can cause W32 to block on socket races when using threadpool. (See very detailed description of the issue in the libmicrohttpd mailinglist post of today.) -JM Sat Dec 8 22:53:56 CET 2018 Added test for RFC 7616 and documented new API. Releasing libmicrohttpd 0.9.62. -CG Sat Dec 8 17:34:58 CET 2018 Adding support for RFC 7616, experimental, needs testing and documentation still! -CG Fri Dec 7 12:37:17 CET 2018 Add option to build MHD without any threads and MHD_FEATURE_THREADS to test for it. -CG Thu Dec 6 13:25:08 BRT 2018 Renamed all occurrences from _model(s)_ to _mode(s)_. -SC Thu Dec 6 12:50:11 BRT 2018 Optimized the function MHD_create_response_from_callback() for Windows by increasing its internal buffer size and allowed to customize it via macro MHD_FD_BLOCK_SIZE. -SC Thu Dec 6 02:11:15 BRT 2018 Referenced the gnutls_load_file() function in the HTTPs examples. -SC Wed Dec 5 18:08:59 CET 2018 Fix regression causing URLs to be unescaped twice. -CG Sun Nov 18 13:08:11 CET 2018 Parse arguments with (properly) escaped URLs correctly. (making things work with recent cURL changes, #5473). Replace sprintf with snprintf in testcases. Releasing libmicrohttpd 0.9.61. -CG Wed Nov 14 14:01:21 CET 2018 Fix build issue with GnuTLS < 3.0. -CG Mon Nov 12 19:50:43 CET 2018 Fix #5473 (test case failure due to change in libcurl). -eworm Thu Nov 8 14:53:27 CET 2018 Add MHD_create_response_from_buffer_with_free_callback. -CG Tue Nov 6 19:43:47 CET 2018 Upgrading to gettext 0.19.8. Releasing libmicrohttpd 0.9.60. -CG Thu Nov 1 16:29:59 CET 2018 Enable using epoll() without listen socket. -JB Sat Oct 20 12:44:16 CEST 2018 In thread-per-connection mode, signal main thread for thread termination for instant clean-up and application notification about closed connections. -CG Tue Oct 16 20:43:41 CEST 2018 Add MHD_RF_HTTP_VERSION_1_0_RESPONSE option to make MHD act more like an HTTP/1.0 server. -GH Fri Oct 5 18:44:45 CEST 2018 MHD_add_response_header() now prevents applications from setting a "Transfer-Encoding" header to values other than "identity" or "chunked" as other transfer encodings are not supported by MHD. (Note that usually MHD will pick the transfer encoding correctly automatically, but applications can use the header to force a particular behavior.) Fixing #5411 (never set Content-length if Transfer-Encoding is given). -CG Sat Jul 14 11:42:15 CEST 2018 Add MHD_OPTION_GNUTLS_PSK_CRED_HANDLER to allow use of PSK with TLS connections. -CG/TM Sat Jul 14 11:03:37 CEST 2018 Integrate patch for checking digest authentication based on a digest, allowing servers to store passwords only hashed. Adding new function MHD_digest_auth_check_digest(). -CG/DB Sat Mar 10 12:15:35 CET 2018 Upgrade to gettext-0.19.8.1. Switching to more canonical gettext integration. -CG Fri Mar 2 21:44:24 CET 2018 Ensure MHD_RequestCompletedCallback is always called from the correct thread (even on shutdown and for upgraded connections). -CG Tue Feb 27 23:27:02 CET 2018 Ensure MHD_RequestCompletedCallback is also called for upgraded connections. -CG Fri Feb 16 03:09:33 CET 2018 Fixing #5278 as suggested by reporter. -CG/texec Thu Feb 1 10:12:22 CET 2018 Releasing GNU libicrohttpd 0.9.59. -CG Thu Feb 1 08:39:50 CET 2018 Fix masking operation. -CG/silvioprog Mon Jan 29 17:33:54 CET 2018 Fix deadlock when failing to prepare chunked response (#5260). -CG/ghaderer Thu Jan 4 12:24:33 CET 2018 Fix __clang_major__ related warnings for non-clang compilers reported by Tim on the mailinglist. -CG Mon Dec 11 17:11:00 MSK 2017 Fixed tests on platforms with huge number of CPUs. Doxygen configuration was updated. Various doxygen fixes. -EG Mon Dec 07 21:08:00 MSK 2017 Releasing GNU libmicrohttpd 0.9.58. -EG Mon Dec 07 16:01:00 MSK 2017 Fixed HTTPS tests on modern platforms. -EG Mon Dec 04 15:43:00 MSK 2017 Minor documentation installation fixes. -EG Mon Nov 27 22:58:38 CET 2017 Tolerate AF_UNIX when trying to determine our binding port from socket. Use `sockaddr_storage` instead of trying to guess the sockaddr type before calling getsockname(). -CG Mon Nov 27 22:24:00 MSK 2017 Releasing GNU libmicrohttpd 0.9.57. -EG Mon Nov 27 21:36:00 MSK 2017 Updated README. -EG Mon Nov 27 18:37:00 MSK 2017 Corrected names in W32 DLL resources. Reordered and clarified configure summary message. Additional compiler warning mutes for builds with various configure parameters. Fixed tests on Cygwin. Used larger SETSIZE for Cygwin (same value as for native W32). Minor fixes for Cygwin. Added configure parameter to force disable usage of sendfile(). Minor testsuite fixes. Really fixed builds with optimisation for size. -EG Sat Nov 25 18:37:00 MSK 2017 Fixed build with optimisation for size. -EG Fri Nov 24 20:14:02 CET 2017 Releasing GNU libmicrohttpd 0.9.56. -CG Thu Nov 23 17:40:00 MSK 2017 Added MHD_FEATURE_SENDFILE enum value and report. -EG Thu Nov 23 08:56:00 MSK 2017 Fixed receiving large requests in TLS mode with epoll. Improved GnuTLS and libgcrypt detection in configure, do not ignore flags in GNUTLS_{CFLAGS,LIBS} variables. Added special trick for Solaris/Openindiana to find GnuTLS-3 with right bitness. Added support for Solaris sendfile(3) function. Fixed dataraces with thread ID on W32 and pthread. Now check for correct thread in MHD_queue_response() works correctly. Fixed and silenced compiler warnings in tests and examples. Removed usage of TLS flags in examples where TLS is not required. Added support for MultiSSL in https tests with libcurl >= 7.56.0. Improved detection of OFF_T_MAX, SIZE_MAX. Added macros for SSIZE_MAX in mhd_limits.h. There are some platforms that really require those macros. Added support for Darwin's sendfile() function. Updated .gitignore files. Reworked mhd_sys_extentions.m4 with better support of modern platforms, more reliable detection of required macros, and detection of disabling of system-specific features by _XOPEN_SOURCE macro. -EG Wed Nov 1 20:43:00 MSK 2017 Mixed and muted many compiler warnings. Now GCC's flags -Wall -Wextra could be used for building. Fixed compilation of examples without libmagic. Better detection of libgnutls in configure. Reworked launch of nested configure in "po" directory to prevent useless reconfiguration. Fixed some wrong asserts. Enabled "test_options" test. Use "test_start_stop" without libcurl. Use chunks with sendfile() to prevent locking thread for single connection with large file. Added support for FreeBSD's sendfile with additional optimisations for FreeBSD 11. Refactoring and improvements for MHD_start_daemon_va() and MHD_stop_daemon(). Fixed testing with GnuTLS >= 3.6.0. -EG Mon Oct 9 22:38:07 CEST 2017 Add MHD_free() to allow proper free()-ing of username/password data returned via MHD_digest_auth_get_username() or MHD_basic_auth_get_username_password() on Windows. -CG Tue Sep 26 14:00:58 CEST 2017 Fixing race involving setting "at_limit" flag. -CG Tue Sep 08 21:39:00 MSK 2017 Fixed build of examples when MHD build with non-pthread lib. MHD_queue_response(): added check for using in correct thread. Fixed sending responses larger 16 KiB in TLS mode with epoll. Improved doxy for MHD_get_timeout() and related functions. Minor internal refactoring. -EG Tue Jul 23 11:32:00 MSK 2017 Updated chunked_example.c to provide real illustration of usage of chunked encoding. -EG Thu Jul 13 21:41:00 MSK 2017 Restored SIGPIPE suppression in TLS mode. Added new value MHD_FEATURE_AUTOSUPPRESS_SIGPIPE so application could check whether SIGPIPE handling is required. Used GNUTLS_NONBLOCK for TLS sessions. -EG Tue Jun 20 23:52:00 MSK 2017 Libgcrypt is now optional and required only for old GnuTLS versions. -EG Wed Jun 14 21:42:00 MSK 2017 Added support for debug assert() and new configure parameter --enable-asserts for debug builds. Removed non-functional Symbian support. -EG Mon Jun 05 23:34:00 MSK 2017 More internal refactoring: merged MHD_tls_connection_handle_read/write() with non-TLS version, reduced and unified number of layers for network processing (before refactoring MHD_tls_connection_handle_read->MHD_connection_handle_read-> do_read->recv_tls_adapter->GnuTLS->recv_param_adapter - 5 MHD layers; after refactoring MHD_connection_handle_read->recv_tls_adapter->GnuTLS - 2 MHD layers), simplified and removed dead code from MHD_connection_handle_read/write() without functional change. -EG Mon Jun 05 22:20:00 MSK 2017 Internal refactoring: used TCP sockets directly with GnuTLS (performance improvement), moved some connection-related code from daemon.c to connection.c/connection_https.c, removed hacks around sendfile() and implemented correct support of sendfile(), removed do_read() and do_write() to reduce number of layer around send() and recv() and to improve readability and maintainability of code, implemented separate tracking of TLS layer state, independent of HTTP connection stage. -EG Sun Jun 04 15:02:00 MSK 2017 Improved thread-safety of MHD_add_connection() and internal_add_connection(), minor optimisations. -EG Sun May 28 23:26:00 MSK 2017 Releasing GNU libmicrohttpd 0.9.55. -EG Sun May 21 18:48:00 MSK 2017 Fixed build with disabled "UPGRADE". Fixed possible null-dereference in HTTPS test. Fixed compiler warning in process_request_body(), minor optimizations. Do not allow suspend of "upgraded" connections. Fixed returned value for MHD_CONNECTION_INFO_CONNECTION_SUSPENDED. Fixed removal from timeout lists of non-existing connections in cleanup_connection(). Fixed double locking of mutex. -EG Sun May 14 15:05:00 MSK 2017 Fixed resuming connections and closing upgraded connections in select() mode with thread-per-connection. -EG Sun May 14 14:49:00 MSK 2017 Removed extra call to resume connections in MHD_run(). Handle resumed connection without delay in epoll mode. Update states of resumed connection after resume in thread-per-connection mode. Fixed resuming connections and closing upgraded connections in poll() mode with thread-per-connection. -EG Thu May 11 22:37:00 MSK 2017 Faster start really processing data in resumed connections. -EG Thu May 11 14:24:00 MSK 2017 Do not add any "Connection" headers for "upgrade" connections. -EG Wed May 10 23:09:00 MSK 2017 Resume resuming connection before other processing in external polling mode. -EG Tue May 9 23:16:00 MSK 2017 Fixed: Do not add "Connection: Keep-Alive" header for "upgrade" connections. -EG Tue May 9 21:01:00 MSK 2017 Fixed: check all "Connection" headers of request for "Close" and "Upgrade" tokens instead of using only first "Connection" header with full string match. -EG Tue May 9 12:28:00 MSK 2017 Revert: continue match footers in MHD_get_response_header() for backward compatibility. -EG Mon May 8 19:30:00 MSK 2017 Fixed: use case-insensitive matching for header name in MHD_get_response_header(), match only headers (not footers). -EG Fri May 5 20:57:00 MSK 2017 Fixed null dereference when connection has "Upgrade" request and connection is not upgraded. -JB/EG Better handle Keep-Alive/Close. -EG Tue May 2 18:37:53 CEST 2017 Update manual. -CG Add MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE. Releasing GNU libmicrohttpd 0.9.54. -CG Thu Apr 27 22:31:00 CEST 2017 Replaced flags MHD_USE_PEDANTIC_CHECKS and MHD_USE_PERMISSIVE_CHECKS by single option MHD_OPTION_STRICT_FOR_CLIENT. Flag MHD_USE_PEDANTIC_CHECKS is still supported. -EG Tue Apr 26 15:11:00 CEST 2017 Fixed shift in HTTP reasons strings. Added test for HTTP reasons strings. -EG Tue Apr 25 19:11:00 CEST 2017 Allow flag MHD_USE_POLL with MHD_USE_THREAD_PER_CONNECTION and without flag MHD_USE_INTERNAL_POLLING_THREAD for backward compatibility. -EG Mon Apr 24 17:29:45 CEST 2017 Enforce RFC 7230's rule on no whitespace by default, introduce new MHD_USE_PERMISSIVE_CHECKS to disable. -CG Sun Apr 23 20:05:44 CEST 2017 Enforce RFC 7230's rule on no whitespace in HTTP header field names if MHD_USE_PEDANTIC_CHECKS is set. -CG Sun Apr 23 19:20:33 CEST 2017 Replace remaining occurrences of sprintf() with MHD_snprintf_(). Thanks to Ram for pointing this out. -CG Sat Apr 22 20:39:00 MSK 2017 Fixed builds in Linux without epoll. Check for invalid --with-thread= configure parameters. Fixed support for old libgcrypt on W32 with W32 threads. -EG Tue Apr 11 22:17:00 MSK 2017 Releasing GNU libmicrohttpd 0.9.53. -EG Mon Apr 10 19:50:20 MSK 2017 HTTPS tests: skip tests instead of failing if HTTPS is not supported by libcurl. HTTPS tests: fixed return values so testsuite is able to correctly interpret it. Fixed ignored result of epoll test in test_https_get_select. -EG Thu Apr 06 23:02:07 MSK 2017 Make zzuf tests compatible with *BSD platforms. -EG Thu Apr 06 22:14:22 MSK 2017 Added warning for hypothetical extra large timeout. Fixed incorrect timeout calculation under extra rare conditions. Fixed accidental usage of IPv6 in testsuite in specific conditions. -EG Wed Apr 05 14:14:22 MSK 2017 Updated autoinit_funcs.h to latest upstream version with proper support of Oracle/Sun compiler. -EG Wed Apr 05 12:53:26 MSK 2017 Fixed some compiler warnings. Fixed error snprintf() errors detection in digestauth.c. Converted many run-time 'strlen()' to compile-time calculations. -EG Sun Mar 26 13:49:01 MSK 2017 Internal refactoring for simplification and unification. Minor optimizations and minor fixes. MHD_USE_ITC used again in thread pool mode. -EG Sat Mar 25 20:58:24 CET 2017 Remove dead MHD_strx_to_sizet-functions and associated test cases from code. -CG Sat Mar 25 20:40:10 CET 2017 Allow chunk size > 16 MB (up to 2^64-1). Ignore chunk extensions instead of triggering an error. (fixes #4967). -CG Tue Mar 25 20:59:18 MSK 2017 Check for invalid combinations of flags and options in MHD_start_daemon(). -EG Tue Mar 21 13:51:04 CET 2017 Use "-lrt" to link libmicrohttpd if we are using clock_gettime() as needed by glibc < 2.17. -CG Tue Mar 21 13:42:07 CET 2017 Allow chaining of suspend-resume calls withuot the application processing data from the network. -CG Mon Mar 20 0:51:24 MSK 2017 Added autoconf module for detection whatever shutdown of listening socket trigger select. This is only reliable method to use such feature as some platforms change behaviour from version to version. -EG Sun Mar 19 13:57:30 MSK 2017 Rewritten logic of handling "upgraded" TLS connections in epoll mode: used edge trigger instead of level trigger, upgraded "ready" connection are stored in DL-list, fixed handling of more than 128 ready connections, fixed busy-waiting for idle "upgraded" TLS connections. -EG Fri Mar 17 10:45:31 MSK 2017 If read buffer is full, MHD need to receive remote data and application suspended connection, do not fail while connection is suspended and give application one more chance to read data from buffer once connection is resumed. -EG Thu Mar 16 23:45:29 MSK 2017 Allow again to run MHD in external epoll mode by MHD_run_from_select() - this allow unification of user code and produce no harm for performance. Especially useful with MHD_USE_AUTO flag. -EG Thu Mar 16 23:12:07 MSK 2017 Idle connection should be disconnected *after* "timeout" number of second, not *before* this number. -EG/VT Thu Mar 16 22:31:54 MSK 2017 Unified update of last activity on connections. Update last activity only if something is really transmitted. Update last activity each time when something is transmitted. Removed early duplicated check for timeout on HTTPS connections. Removed update of last active time for connections without timeout. Fixed reset of timeout timer on resumed connections. Fixed never-expired timeouts on HTTPS connections. Fixed thread-safety of MHD_set_connection_option(). -EG Thu Mar 16 21:05:08 MSK 2017 Fixed minor bug resulted in slight slowdown of HTTPS connection handshake. -EG Thu Mar 16 20:35:59 MSK 2017 Improved thread-safety for DL-lists. -EG Thu Mar 16 17:55:01 MSK 2017 Fixed thread-safety of MHD_get_daemon_info() for MHD_DAEMON_INFO_CURRENT_CONNECTIONS. -EG Thu Mar 16 16:49:07 MSK 2017 Added ability to get actual daemon flags via MHD_get_daemon_info(). Fixed test_upgrade to work in request mode. Fixed compiler warnings in test_upgrade. -EG Wed Mar 15 23:29:59 MSK 2017 Prevented socket read/write if connection is suspended. Added missing resets of 'connection->in_idle'. Reworked handling of suspended connection: ensure that connection is not disconnected by timeout, always updated read/write states right after suspending. -EG Wed Mar 15 21:02:26 MSK 2017 Added new enum value MHD_CONNECTION_INFO_CONNECTION_TIMEOUT to get connection timeout by MHD_get_connection_info(). -EG Sat Mar 11 12:03:45 CET 2017 Fix largepost example from tutorial to properly generate error pages. -CG Fix largepost example, must only queue replies either before upload happens or after upload is done, not while upload is ongoing Fri Mar 10 16:37:12 CET 2017 Fix hypothetical integer overflow for very, very large timeout values. -CG Fri Mar 10 16:22:54 CET 2017 Handle case that we do not listen at all more gracefully in MHD_start_daemon() and not pass '-1' to helper functions that expect a valid socket. -CG Tue Mar 7 12:11:44 BRT 2017 Updates file `.gitignore`. Tue Mar 7 10:37:45 BRT 2017 Updated the MHD_OPTION_URI_LOG_CALLBACK's documentation. Mon Mar 6 21:46:59 BRT 2017 Added the i18n example fixing #4924. -SC Wed Mar 1 23:47:05 CET 2017 Minor internal optimisations. Changed closure connection monitoring logic: now all connections are monitored for OOB data (which treated as error), connections are not monitored any more for incoming data if incoming data is not required for processing. except_fd_set is not optional now for MHD_get_fdset(), MHD_get_fdset2() and MHD_run_from_select(). Improved connection processing in epoll mode: now connection can process both read and write each turn. Updated HTTP response codes; updated and added all missing standard HTTP headers names (and headers categories); updated and added all missing standard and additional HTTP methods. Now MHD return status MHD_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE (431) instead of old MHD_HTTP_REQUEST_ENTITY_TOO_LARGE (413) for very long header. Reworked handling of data pending in TLS buffers, resolved busy-waiting if incoming data is pending in TLS buffers and connection is in LOOP_INFO_WRITE mode. Do not clear 'ready' flag in epoll mode if send()/recv() result is EINTERRUPTED. Better detection of unready connection state: used less number of calls of recv()/send() in epoll mode. Configure: do not run gcrypt and GnuTLS tests if HTTPS is disabled by configure parameter. Fixed wrong value returned by MHD_get_timeout(). All double-linked lists now walked from tail to head. As new items are added to head, this result in more uniform processing time. Improved sockets errors handling in epoll mode. OOB data on 'upgraded' sockets is treated as error. -EG Thu Feb 16 11:20:05 CET 2017 Replace tsearch configure check with code from gnulib. -CG Wed Feb 15 13:35:36 CET 2017 Fixing a few very rare race conditions for thread-pool or thread-per-connection operations during shutdown. Various minor cosmetic improvements. Fixed #4884 and #4888 (solaris portability issues). -CG Wed Feb 08 22:33:10 MSK 2016 Ported test_quiesce_stream to W32. Improved precompiler flags selection of OpenBSD. Fixed sending responses backed by files not supported by sendfile(). Fixed thread safety for responses backed by file FD. Updated fileserver_example. Improved handling of 'upgraded' TLS forwarding in select() and poll() modes. Fixed processing of incoming TLS data in epoll mode if more than 128 connections are active. Fixed accepting more than 128 incoming connection in epoll mode. Improved test_large_put, added poll() and epoll testing. Added test_large_put_inc for testing of incremental buffer processing. Rewritten epoll connection processing logic: handle all connection one time per turn instead of trying to handle all active connection until all pending data is dried. Result is more uniform connection processing period. -EG Wed Nov 23 15:24:10 MSK 2016 Used SO_REUSEADDR (on non-W32) alongside with SO_REUSEPORT if option MHD_OPTION_LISTENING_ADDRESS_REUSE was set. -EG Wed Nov 23 12:48:23 MSK 2016 Move all gettext-related staff to 'po' subdirectory. Excluded gettext files generation from normal build. Removed generated files from GIT. -EG Tue Nov 15 19:08:43 MSK 2016 Fixed forwarding "upgraded" TLS connections for chunks sizes larger than buffer size. -EG Mon Nov 14 22:18:30 MSK 2016 Fixed unintentional usage of SO_REUSEADDR on W32. Added support for SO_EXCLBIND on Solaris. Fixed using MHD with MHD_OPTION_LISTENING_ADDRESS_REUSE on Linux kernels before 3.9 (longterm 3.2 and 3.4 are still supported). -EG Sun Nov 13 19:16:38 CET 2016 Fixed a few race issues on suspend-resume in cases where the application uses threads even though MHD did not (or at least had no internal need for locking). Also fixed DLL handling of the timeout list, avoiding manipulating it for suspended connections. Finally, eliminated calling application logic on suspended connections (which before could happen under certain circumstances). -CG Thu Nov 11 20:49:23 MSK 2016 Added support for various forms of pthread_attr_setname_np() so thread names will be set more efficiently on certain platforms (Solaris, NetBSD etc.) -EG Thu Nov 10 21:50:35 MSK 2016 Added rejection in MHD_start_daemon() of invalid combinations of daemon flags. Added MHD_USE_AUTO and MHD_USE_AUTO_INTERNAL_THREAD for automatic selection of polling function depending on platform capabilities and requested mode. -EG Thu Nov 10 17:49:56 MSK 2016 Ported "upgrade" tests to W32 and other platforms, used "gnutls-cli" instead of "openssl" in tests, minor bugs fixed, added verbose reporting if requested. "Upgrade" processing - changed internal handling logic, improved and refactored, bugs fixed, fixed sigpipe on Darwin, added printing error to log, fixed compilation without HTTPS. Added 'configure' parameter "--disable-httpupgrade" for building minimal-sized MHD versions. Added feature check "MHD_FEATURE_UPGRADE". Responses destroyed (freed) earlier if possible. Added many remarks in code comments about thread safety. Some data races and other multithread-related issues are fixed, including usage of closed sockets (may resulted in accidental closing of wrong socket). SO_NOSIGPIPE is used on all platform which support it, not only on Darwin. Added support for suspending connections in thread-per-connection mode (itself almost useless, mostly to unify modes support). Fixed Inter-Thread Communication channel usage in epoll modes. Reworked daemon cleanups and handling MHD_stop_daemon(): resources are freed only by specific threads, data races and other fixes. Started usage of C99 standard 'bool' where supported with fallback to 'int'. Renamed many MHD flags. Now they are self-explainable and more obvious, like MHD_USE_INTERNAL_POLLING_THREAD instead of MHD_USE_SELECT_INTERNALLY. Old flag names are supported for backward compatibility. Improved processing of "fast" connections: now full sequence "read request - send reply headers - send reply body" is processed after single select()/poll(). If connection is slow, request is huge or response in not immediately ready - connection will be processed in "traditional" way. Added usage of "calloc()" where supported. Minor documentation fixes. Minor improvements and fixes. -EG "Upgrade" test fixes. Documentation updated. Added HTTP "Upgrade" example. -CG Mon Oct 17 19:08:18 CEST 2016 Fixed misc. issues relating to upgrade. Releasing experimental 0.9.52. -CG Wed Oct 12 14:26:20 CEST 2016 Migrated repository from Subversion to Git. -CG Tue Oct 11 18:09:56 CEST 2016 Deprecated MHD_USE_SSL, use MHD_USE_TLS instead. -CG Tue Oct 11 18:14:40 MSK 2016 Code internal refactoring: 'pipes' renamed to 'inter-thread communication (channels)/ITCs', as code can use different types of communications. Optimizations: ITCs now always created in non-blocking mode. Added configure parameter to choose ITC type. Updated documentation and comments. Minor errors fixed (related to heavy load). -EG Thu Sep 22 17:51:04 CEST 2016 Implementing support for eventfd() instead of pipe() for signaling (on platforms that support it); fixing #3557. -CG Thu Sep 22 11:03:43 CEST 2016 Simplify internal error handling logic by folding it into the MHD_socket_close_, MHD_mutex_lock_, MHD_mutex_unlock_ and MHD_mutex_destroy_ functions. -CG Tue Sep 13 22:20:26 MSK 2016 Added autoconf macro to enable maximum platform features. Fixed compiling on Solaris. -EG Wed Sep 7 12:57:57 CEST 2016 Fixing #4641. -Hawk Wed Sep 7 00:28:59 CEST 2016 Adding remaining "_"-markups for i18n (#4614). -CG Tue Sep 6 23:39:56 CEST 2016 Allow out-of-order nonces for digest authentication (#4636). -CG Tue Sep 6 21:29:09 CEST 2016 Martin was right, "socket_context" should be "void *" in `union MHD_ConnectionInfo`. -MS Sun Sep 4 18:16:32 CEST 2016 Fixing potential memory leak (#4634). -CG Sun Sep 4 17:25:45 CEST 2016 Tests for "Upgrade" logic are now in place and passing. However, still need to make sure code is portable. -CG Sat Sep 3 11:56:20 CEST 2016 Adding logic for handling HTTP "Upgrade" in thread-per-connection mode. Also still untested. -CG Sat Aug 27 21:01:43 CEST 2016 Adding a few extra safety checks around HTTP "Upgrade" (against wrong uses of API), and a testcase. -CG Sat Aug 27 20:07:53 CEST 2016 Adding completely *untested* logic for HTTP "Upgrade" handling. -CG Sat Aug 27 18:20:38 CEST 2016 Releasing libmicrohttpd 0.9.51. -CG Tue Aug 23 22:54:07 MSK 2016 Internal refactoring: W32 compatibility layer was finally replaced with several specialized abstraction layers for sockets, control pipes (inter-thread communication) and generic functions. Now all major platform functions (including threads and mutex) are implemented in thin abstraction layers. Improved performance on W32 due to eliminating translation of error to POSIX codes and using W32 codes directly (through macros). Improved error reporting on all platforms. Improved error handling and reporting on Darwin. Minor fixes. -EG Tue Aug 16 15:14:30 MSK 2016 Minor improvement for monotonic clock. Minor configure fix for non-bash shells. -EG Mon Aug 15 13:06:52 CEST 2016 Fixed possible crash due to write to read-only region of memory given ill-formed HTTP request (write was otherwise harmless, writing 0 to where there was already a 0). Fixed issue with closed connection slots not immediately being available again for new connections if we reached our connection limit. Avoid even accept()ing connections in certain thread modes if we are at the connection limit and MHD_USE_PIPE_FOR_SHUTDOWN is available. -CG Wed Aug 10 16:42:57 MSK 2016 Moved threads, locks and mutex abstraction to separate files, some minor errors fixed, added support for thread name functions on various platforms, added configure flag for disable thread naming. -EG Sat Jul 23 20:45:51 CEST 2016 Added macro detection of speed/size compiler optimization. Added different implementation of functions in mhd_str.c for size optimization. Enabled automatically if compiler size optimization is detected or MHD_FAVOR_SMALL_CODE is defined. Added unit tests for all mhd_str.c functions. -EG Sat Jul 16 21:54:49 CEST 2016 Warn user if they sent connection into blocking state by not processing all POST data, not suspending, and not running in external select mode. -CG Fri Jul 8 21:35:07 CEST 2016 Fix FIXME in tutorial. -CG Fri Jul 8 15:57:06 CEST 2016 Adding support for 308 status code. -CG Sat Jun 25 13:49:31 CEST 2016 Use shutdown to trigger select on NetBSD. -EG Thu Jun 2 09:55:50 CEST 2016 Releasing libmicrohttpd 0.9.50. -CG Wed Jun 1 21:59:34 CEST 2016 Do not send "Content-Length" header for 1xx/204/304 status codes. -CG Tue May 17 13:32:21 CEST 2016 Allow clients to determine whether a connection is suspended; introduces MHD_CONNECTION_INFO_CONNECTION_SUSPENDED. -CG/FC Sun May 15 12:17:25 CEST 2016 Fix handling system or process resource limit exhaustion upon accept(). -CG/CP Thu May 12 08:42:19 CEST 2016 Fix handling of partial writes in MHD_USE_EPOLL_LINUX_ONLY; only consider sockets returning EAGAIN as unready. -CG/CP Mon May 2 06:08:26 CEST 2016 Adding logic to help address FE performance issue as discussed on the mailinglist with subject "single-threaded daemon, multiple pending requests, responses batched". The new logic is only enabled when MHD_USE_EPOLL_TURBO is set. Note that some additional refactoring was also done to clean up the code and avoid code duplication, which may have actually fixed an unrelated issue with HTTPS and a POLL-style event loop. -CG Sat Apr 30 10:22:37 CEST 2016 Added clarifications to manual based on questions on list. -CG Sat Apr 23 20:12:01 CET 2016 Tests perf_get_concurrent and test_concurrent_stop ported to use pthread instead of fork(). Added more error detections. -EG Sat Apr 23 16:06:30 CET 2016 Improved test_quiesce test. -EG Sat Apr 23 15:39:38 CET 2016 Notify other threads in MHD_quiesce_daemon() so listen socket FD is removed from awaiting select() and poll(). -EG Sat Apr 23 14:17:15 CET 2016 Revert "shutdown trigger select" on Darwin. Fixed daemon shutdown on Darwin without "MHD_USE_PIPE_FOR_SHUTDOWN" option. -EG Fri Apr 22 14:29:28 CET 2016 Fixed race conditions when stopping quiesced daemon with thread pool. -EG Wed Apr 20 18:12:30 CET 2016 Fixed macros in sysfdsetsize.c which could prevent compiling with non-default FD_SETSIZE. Fixed comments in mhd_str.c. Updated test_post.c to not ignore specific error on W32 if libcurl is built with workaround for WinSock bug. -EG Mon Apr 18 19:35:14 CET 2016 Fixed data races leading to inability in rare situations to resume suspended connection. -EG Tue Apr 13 21:46:01 CET 2016 Removed unneeded locking for global timeout list in MHD_USE_THREAD_PER_CONNECTION mode. Added 'simplepost' and 'largepost' examples to VS projects. Added strtoXX() locale-independent replacement functions. Added more error checking and minor fixes in digest auth functions - should improve security. Ignored specific errors in 'test_post' test until libcurl will implement workaround for WinSock bug. Fixed handling of caller-supplied socket with MHD_OPTION_LISTEN_SOCKET (regression in 0.9.49). Minor fixes. Various cosmetics and comments fixes. -EG Sat Apr 09 13:05:42 CET 2016 Releasing libmicrohttpd 0.9.49. -EG Fri Apr 08 18:32:17 CET 2016 Some minor internal fixes, addition error checking and micro optimizations. Reworked usage of sockets shutdown() - now work equally on all platforms, disconnection should be "more graceful". -EG Tue Mar 15 21:52:27 CET 2016 Do not crash if pthread_create() fails. -DD Tue Mar 15 20:29:34 CET 2016 Do not use eready DLL data structure unless we are actually using epoll(). -DD/CG Fri Feb 5 20:43:11 CET 2016 Fixed testsuite compile warning on W32. Added check test for triggering poll() on listen socket. -EG Thu Feb 4 11:38:11 CET 2016 Added some buffer overrun protection. Fixed handling of malformed URI with spaces. -EG Wed Feb 3 15:41:57 CET 2016 Make signal-pipe non-blocking and drain it. -CG Sat Jan 30 15:49:07 CET 2016 Fix running select() with empty fdsets on W32. -EG Mon Jan 25 13:45:50 CET 2016 Added check test for triggering select() on listen socket. -EG Thu Jan 21 19:35:18 CET 2016 Fixed old bug with making sockets non-blocking on various platforms so now sockets are really non-blocking on all supported platforms. Reworked and fixed code for using SOCK_CLOEXEC, SOCK_NONBLOCK and EPOLL_CLOEXEC resulting in fewer used system calls. -EG Tue Jan 19 20:59:59 CET 2016 Cleaned up and optimized with minor fixes code for making sockets non-blocking non-inheritable. -EG Tue Jan 19 11:14:18 CET 2016 Removed workaround for Cygwin non-blocking sockets: handling non-blocking sockets were fixed in Cygwin and libmicrohttpd how uses non-blocking sockets on all platforms. -EG Mon Jan 18 23:54:45 CET 2016 Cleaned up examples to avoid giving oversimplified code that may lead to complications if adopted naively. -CG Sun Jan 17 11:18:55 CET 2016 Do no refuse to send response if sendfile() failed with EINVAL (common error for files located on SMB/CIF). -EG Sat Jan 16 19:14:39 CET 2016 Use US-ASCII only (instead of user locale settings) when performing caseless string comparison as required by standard. -EG Tue Jan 12 16:10:09 CET 2016 Fixed declaraion of MHD_get_reason_phrase_for(). -EG Mon Jan 11 19:58:50 CET 2016 Configure.ac small fixes and refactoring. -EG Fri Dec 18 15:54:50 CET 2015 Releasing libmicrohttpd 0.9.48. -CG Tue Dec 15 18:35:55 CET 2015 Improved compatibility with VS2010 and other older compilers. -EG Tue Dec 8 21:48:44 CET 2015 Default backlog size for listen socket was changed from 32 to SOMAXCONN, added new option MHD_OPTION_LISTEN_BACKLOG_SIZE to override default backlog size. If not all connections can be handled by MHD_select() than at least some of connections will be processed instead of failing without any processing. Fixed redefenition of FD_SETSIZE on W32 so select() will work with 2000 connections instead of 64. Better handled redefenition of FD_SETSIZE on all platforms. -EG Sat Dec 5 17:30:45 CET 2015 Close sockets more aggressively in multi-threaded mode (possibly relevant for idle servers). -CG Fri Dec 4 13:53:05 CET 2015 Releasing libmicrohttpd 0.9.47. -CG Thu Dec 3 18:21:44 CET 2015 Reworked VS project files. Used x64 build tools by default, many optimizations, fixes. Added project files for VS 2015. -EG Tue Dec 1 14:05:13 CET 2015 SPDY is dead, killing experimental libmicrospdy. -CG Tue Dec 1 10:01:12 CET 2015 New logic for controlling socket buffer modes. Eliminated delay before last packet in response and before "100 Continue" response on all platforms. Also response header are pushed to client without waiting for response body. -EG Wed Nov 25 17:02:53 CET 2015 Remove 200ms delay observable with keep-alive on Darwin and *BSD platforms. -EG Tue Nov 10 15:25:48 CET 2015 Fix issue with shutdown if connection was resumed just before shutdown. -FC Fri Nov 6 22:54:38 CET 2015 Fixing the buffer shrinkage issue, this time with test. -CG Releasing libmicrohttpd 0.9.46. -CG Tue Nov 3 23:24:52 CET 2015 Undoing change from Sun Oct 25 15:29:23 CET 2015 as the original code was counter-intuitive but correct, and the new code does break pipelining. Ignore empty lines at the beginning of an HTTP request (more tolerant implementation). -CG Sat Oct 31 15:52:52 CET 2015 Releasing libmicrohttpd 0.9.45. -CG Tue Oct 27 12:08:02 CET 2015 Rework deprecation maros: fix errors with old GCC versions, improved support for old clang and new GCC. -EG Sun Oct 25 23:05:32 CET 2015 Return correct header kind in MHD_get_connection_values() even if a bitmask is used for the "kind" argument. -FC/CG Sun Oct 25 15:29:23 CET 2015 Fixing transient resource leak affecting long-lived connections with a lot of keep-alive and HTTP request pipelining under certain circumstances (which reduced the receive window). Fixed assertion failure triggered by a race in thread-per-connection mode on shutdown in rare circumstances. -CG Mon Oct 5 11:53:52 CEST 2015 Deduplicate code between digestauth and connection parsing logic for URI arguments, shared code moved to new MHD_parse_arguments_ function in internal.c. -CG Thu Oct 1 21:22:05 CEST 2015 Releasing libmicrohttpd 0.9.44. -CG Wed Sep 30 21:05:38 CEST 2015 Various fixes for W32 VS project files. -EG Fri Sep 25 09:49:10 CEST 2015 Fix digest authentication with URL arguments where value-less keys are given before the last argument. Thanks to MA for reporting. -CG Tue Sep 22 19:17:54 CEST 2015 Do not use shutdown() on listen socket if MHD_USE_PIPE_FOR_SHUTDOWN is set. -CG Wed Sep 16 11:06:02 CEST 2015 Releasing libmicrohttpd 0.9.43. -CG Wed Sep 2 16:50:31 CEST 2015 Call resume_suspended_connections() when the user is running its own mainloop and calls MHD_run_from_select() to support resuming connections with external select. -FC Sun Aug 30 14:53:51 CEST 2015 Correct documentation as to when MHD_USE_EPOLL_LINUX_ONLY is allowed. -CG Thu Aug 27 09:38:44 CEST 2015 Reimplement monotonic clock functions for better support various platforms. Print more information during configure. -EG Fri Aug 14 14:13:55 CEST 2015 Export MHD_get_reason_phrase_for() symbol. -CG Sat Aug 8 12:19:47 CEST 2015 Added checks for overflows and buffer overruns, fixed possible buffer overrun. Updated md5 implementation. Fixed many compiler warning (mostly for VC compiler). -EG Tue Aug 4 13:50:23 CEST 2015 Fix failure to properly clean up timed out connections if running in external select mode without listen socket, which caused busy waiting until new connections arrived. (Fixes #3924, thanks to slimp for reporting and testcase). -CG Sun Aug 2 19:08:20 CEST 2015 Ignore close() errors on sockets except for EBADF, fixes #3926. -CG Sat Jun 27 22:16:27 CEST 2015 Make sure to decrement connection counter before calling connection notifier so that MHD_DAEMON_INFO_CURRENT_CONNECTIONS does not present stale information (relevant if this is used for termination detection of a daemon stopped via MHD_quiesce_daemon()). Thanks to Markus Doppelbauer for reporting. -CG Fri Jun 26 23:17:20 CEST 2015 Fix (automatic) handling of HEAD requests with MHD_create_response_from_callback() and HTTP/1.1 connection keep-alive. Thanks to Cristian Klein for reporting. -CG Tue Jun 09 18:30:17 CEST 2015 Add new functions MHD_create_response_from_fd64() and MHD_create_response_from_fd_at_offset64(). -EG Thu Jun 4 13:37:05 CEST 2015 Fixing memory leak in digest authentication. -AW Wed Jun 03 21:23:47 CEST 2015 Add deprecation compiler messages for deprecated functions and macros. -EG Fri May 29 12:23:01 CEST 2015 Fixing digest authentication when used in combination with escaped characters in URLs. -CG/AW Wed May 13 11:49:09 CEST 2015 Releasing libmicrohttpd 0.9.42. -CG Wed May 13 11:33:59 CEST 2015 Fix off-by-one in MHD_start_daemon_va() error handling logic when initialization of threads for thread pool fails for some reason. -CG/JC Thu May 7 17:05:46 CEST 2015 Add support for poll() in W32. -EG Wed May 6 18:07:38 CEST 2015 Fix #3784: actually implement MHD_CONNECTION_INFO_SOCKET_CONTEXT. -asherkin Thu Apr 30 00:03::49 CEST 2015 Releasing libmicrohttpd 0.9.41. -CG Thu Apr 30 00:02:33 CEST 2015 Fix issue where resumed connections would not continue unless other requests are active in certain event-loop modes. Thanks to Mike Castillo for reporting. -CG Wed Apr 15 03:16:18 CEST 2015 Fixing issue #3753 (testcase issue). -CG Wed Apr 15 00:30:34 CEST 2015 Fix looping issue when using MHD_USE_POLL_INTERNALLY and a client times out. -LB Sun Apr 12 21:48:50 CEST 2015 Fix looping issue when combining MHD_USE_EPOLL_LINUX_ONLY with HTTPS and slow clients. -CG Fri Apr 10 22:02:27 CEST 2015 Fix logic to add "Connection: Close" that was broken in 0.9.38 when adding MHD_RF_HTTP_VERSION_1_0_ONLY. -CG Fri Apr 10 00:38:40 CEST 2015 Ensure fast termination in MHD_USE_THREAD_PER_CONNECTION mode on W32 by using signal pipe. -CG Thu Apr 9 09:01:15 CEST 2015 Fixing issue with undrained signal pipe when using MHD_USE_SELECT_INTERNALLY and MHD_USE_POLL in combination with MHD_resume_connection(), causing 100% CPU usage. -DD Tue Apr 7 00:12:36 CEST 2015 Releasing libmicrohttpd 0.9.40. -CG Sat Apr 4 18:28:24 CEST 2015 Fix potential deadlock issue in MHD_USE_THREAD_PER_CONNECTION mode if shutdown is initiated while connections are active. -CG Sat Apr 4 17:48:13 CEST 2015 Fix issue in thread-pool mode where a MHD_stop_daemon() might not reach threads that stopped listening because we hit the maximum number of concurrent connections and the option MHD_USE_PIPE_FOR_SHUTDOWN was also not used. Testcase added as well. -CG Fri Apr 3 12:55:31 CEST 2015 Update HTTPS testcases to avoid SSLv3, as SSLv3 is dead. Fri Apr 3 12:25:28 CEST 2015 Do not enforce FD_SETSIZE-limit on worker control pipe when using MHD_USE_EPOLL_LINUX_ONLY (#3751). -MH/CG Tue Mar 31 10:28:26 CEST 2015 Adding MHD_OPTION_NOTIFY_CONNECTION, MHD_CONNECTION_NOTIFY_STARTED, MHD_CONNECTION_NOTIFY_CLOSED and MHD_CONNECTION_INFO_SOCKET_CONTEXT to allow applications to trigger operations when TCP connections start or end, instead of just exposing HTTP requests starting and ending. -RG/CG Thu Feb 26 09:55:43 CET 2015 Fixing bug that prevented MHD_OPTION_HTTPS_MEM_DHPARAMS from working within a MHD_OPTION_ARRAY. -DD Sun Feb 8 01:24:38 CET 2015 Adding MHD_OPTION_HTTPS_KEY_PASSWORD as proposed by Andrew Basile. -CG/AB Wed Feb 4 20:34:22 CET 2015 Fix issue where for HTTP/1.0-clients that set Connection: Keep-Alive header a response of indefinite size was generated with chunked encoding. -CG Sun Jan 18 20:09:06 CET 2015 Fix potential infinite loop on shutdown in multi-threaded mode under certain conditions. -CG Mon Dec 22 16:33:18 CET 2014 Releasing 0.9.39. -CG Mon Dec 22 13:02:36 CET 2014 Fix generated compiler flags for Solaris Studio linker (#3584). -CG Sat Dec 20 00:35:40 CET 2014 Adding MHD_http_unescape() to public API (#3585). -CG Updating documentation to document MHD_is_feature_supported(). -CG Thu Dec 4 00:43:10 CET 2014 If "Connection: upgrade" is requested, do not add "Connection: Keep-Alive" in the response. -GJ Tue Nov 18 13:52:29 CET 2014 Call MHD_cleanup_connections() during MHD_DAEMON_INFO_CURRENT_CONNECTIONS processing for more accurate results. -MS Wed Oct 29 20:45:21 CET 2014 Adding MHD_OPTION_LISTENING_ADDRESS_REUSE option allowing clients to force allowing re-use of the address:port combination (SO_REUSEPORT). -MS Wed Oct 29 16:27:05 CET 2014 Adding MHD_DAEMON_INFO_CURRENT_CONNECTIONS to allow clients to query the number of active connections. -MS Fri Oct 3 14:28:58 CEST 2014 Releasing 0.9.38. -CG Mon Sep 29 22:25:34 CEST 2014 Properly decode '+' in URL-encoded POST data. -CG/KM Fri Sep 12 17:32:09 CEST 2014 Fix --disable-dauth configure option (#3543). -doostee Thu Jun 26 21:06:04 CEST 2014 Fix failure to terminate 'instantly' in thread-per-connection mode if there is a client with open connections. Thanks to Kenneth Mastro for reporting. -CG Sun Jun 22 12:22:08 CEST 2014 Actually, avoid locking on response as responses must not be modified in a connection-specific way; instead modify the connection's data buffer to add missing responses headers. If we are forced to add "Connection: close", suppress output of conflicting application-provided "Connection: Keep-Alive" header. -CG Sun Jun 22 00:22:08 CEST 2014 Lock on response if adding headers, needed if response object is shared across threads and connections. -CG Thu Jun 19 17:32:32 CEST 2014 Ensure that listen FD is bound to epoll FD even before MHD_run() is called if running with MHD_USE_EPOLL_LINUX_ONLY in combination with 'external select' mode. Thanks to Marcos Pindado Sebastian for reporting. -CG Sun Jun 8 15:10:44 CEST 2014 Add 'MHD_set_response_options' as a way to set per-response flags. Add flag to force HTTP 1.0-only conservative behavior, in particular suppressing adding "Connection" headers. -CG Mon Jun 2 00:03:28 CEST 2014 Added back unescaping for URI path (#3413) but without unescaping '+' (#3371) to remain compatible with MHD 0.9.34 and before. Note that applications providing a custom MHD_OPTION_UNESCAPE_CALLBACK are no longer expected to replace '+' with ' ', as that is now done separately for the locations where this transformation is appropriate. Releasing 0.9.37. -CG Wed May 28 15:30:56 CEST 2014 Properly applying patch that was supposed to be committed on "May 2 20:22:45 CEST 2014" to address infinite loop (DoS) when HTTP connection is reset (#3392). -GM Sun May 25 20:18:27 CEST 2014 Fixed W32 build issues. -EG Releasing 0.9.36. -CG Sat May 17 06:47:00 CEST 2014 Fix notifying client about completed request twice under certain circumstances. -CG Tue May 13 18:24:37 CEST 2014 Fix accidental transmission of footer termination '\r\n' for responses with zero byte payload and non-chunked encoding (#3397). Thanks to amatus for reporting. -CG Sun May 4 11:05:26 CEST 2014 Fix gnutls header check to make it cross-compile aware. -BK May 2 20:22:45 CEST 2014 Fix infinite loop (DoS) when HTTP connection is reset (#3392). -GM Fix possible issue from combination of epoll and suspend/resume logic if edge trigger event is lost; also simplify logic to maintain simpler invariants on the epoll state. -CG Use OpenSSL cipher list "HIGH" in libmicrospdy (#3391). -CG Releasing 0.9.35. -CG Thu Apr 10 09:39:38 CEST 2014 Removed unescaping for URI path (#3371) as '+' should not be converted to space in accordance with http://www.w3.org/TR/html401/appendix/notes.html#ampersands-in-uris and http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1 Note that we now also no longer convert '#38;' to '&'; if needed, the application needs to apply unescaping to the path of the URI itself (before, MHD unescaped '#38;' but not '&', so this inconsistency was now resolved by simply not unescaping anything before the first '&'). -CG Tue Apr 08 15:35:44 CET 2014 Added support for W32 native threads. Added --with-threads=LIB configure parameter. -EG Mon Apr 7 13:25:30 CEST 2014 Add MHD_OPTION_HTTPS_MEM_DHPARAMS to allow applications to enable PFS. -HB/CG Tue Apr 01 07:10:23 CET 2014 Added usage of native mutex on W32. -EG Sat Mar 29 16:12:03 CET 2014 Added MHD_is_feature_supported() function. -EG Thu Mar 27 14:47:54 CET 2014 Used larger FD_SETSIZE internally on W32. Extended API to work with non-default FD_SETSIZE. -EG Tue Mar 25 12:53:55 CET 2014 Fix limiting by IPv6 address. -EG Tue Mar 25 09:06:13 CET 2014 Added more FD_SETSIZE checks. Implemented FD_SETSIZE checks for W32. -EG Wed Mar 05 13:15:05 CET 2014 Cleanup and refactoring of configure.ac. m4 macros updated. Custom configure macros replaced with autoconf archive macros. SPDY disabled by default on W32. Changed configure flag from '--disable-pipe' to '--enable-socketpair'. Added configure flags '--disable-doc' and '--disable-examples'. Narrowed down external lib specific compiler and linker flags usage. -EG Wed Feb 26 17:42:34 CET 2014 Refactoring of configure.ac: custom macros replaced with macros from Autoconf Archive. Minor corrections of configure.ac. Excluded pthread flags from global flags, pthread now used only where required. W32: fixed .dll resource compilation with '-isystem' CPPFLAG. W32: improved header compatibility with MSVC. W32: now tested on Win64, compiled by MinGW-w64. -EG Mon Feb 24 23:13:53 CET 2014 Added support for TCP FASTOPEN. -SHT Releasing 0.9.34. -CG Thu Feb 20 14:17:05 CET 2014 W32: Added creation of libmicrohttpd.lib, libmicrohttpd.def, libmicrohttpd.exp and libmicrohttpd-static.lib for easy use compiled MHD with MSVC. W32: Use MS lib.exe tool if available for creating MSVC staff. W32: Added .dll information resource. -EG Tue Feb 18 19:46:45 CET 2014 Removed dependency on plibc for simpler compilation for W32. Added configure option "--disable-pipes" to use socketpairs instead of pipes for signalling to child threads. Pipes are always disabled on W32. Some code refactoring. -EG Sat Feb 8 15:08:35 CET 2014 Corrected some uses of 'int' vs. 'size_t'. -EG/CG Wed Jan 22 09:44:33 CET 2014 MHD_USE_DUAL_STACK in libmicrohttpd currently just *inhibits setting* the IPV6_V6ONLY socket option, but per Microsoft's documentation the default on Windows is that this is enabled, thus MHD_USE_DUAL_STACK will not work (since it leaves the default). libmicrohttpd should probably just unconditionally set IPV6_V6ONLY to the desired value when the option is available. -LJ Wed Jan 1 21:38:18 CET 2014 Allow Keep-Alive with HTTP 1.0 (if explicitly requested), and automatically set "Connection: Keep-Alive" in response in this case as well. -CG Tue Dec 24 12:27:39 CET 2013 Adding explicit annotations to hide symbols that are not for export in the C code (gcc 4.0 or higher only). -CG Sun Dec 22 14:54:30 CET 2013 Adding a few lines to avoid warnings from picky compilers. -CG Sat Dec 21 17:26:08 CET 2013 Fixed an issue with a missing argument in the postexample. Fixed issue with bogus offset increment involving sendfile on GNU/Linux. Adding support for SNI. Releasing 0.9.33. -CG Mon Dec 9 21:41:57 CET 2013 Fix for per-worker daemon pipes enabled with MHD_USE_SUSPEND_RESUME that were not closed in MHD_stop_daemon. -MH Sat Dec 7 00:44:49 CET 2013 Fixing warnings and build issue if --disable-https is given to configure. -CG Tue Dec 3 21:25:56 CET 2013 Security fix: do not read past 0-terminator when unescaping strings (thanks to Florian Weimer for reporting). Releasing 0.9.32. -CG Tue Dec 3 21:05:38 CET 2013 Signaling n times for shutdown works, but for resume we need to wake up the correct daemon. Even if we signal n times in that case also, there's no guarantee that some daemon can't run through its select loop more than once before the daemon we want to wake up gets a chance to read. Thus we need a signal pipe per thread in the thread pool IF MHD_suspend_connection is used. This introduces a new flag MHD_USE_SUSPEND_RESUME to add those additional pipes and only allow MHD_suspend_connection to be used in conjunction with this flag. Also, as MHD_resume_connection() will be called on a non-daemon thread, but none of the queue insert/delete calls are thread safe, we need to be concerned about (a) corrupting the queue, and (b) having to add mutex protection around every access to the queues, including loops through timer queues, etc. This wasn't a problem before adding resume; even suspend should be safe since it happens in a callback from the daemon. I think it's easier to (a) have MHD_suspend_connection() move the connection to a suspended queue, (b) have MHD_resume_connection() mark the connection as resuming, and then (c) do all the actual queue manipulations in MHD_select (poll, epoll, etc.) to move the resumed connections back to their normal queues, in response to the wake up. The changes are simpler & cleaner. There is a cost to the basic select loop that is avoided by making suspend/resume a startup option. The per-worker pipes can then also be enabled only with that option set. -MH Fri Nov 29 20:17:03 CET 2013 Eliminating theoretical stack overflow by limiting length of URIs in authentication headers to 32k (only applicable if the application explicitly raised the memory limits, and only applies to MHD_digest_auth_check). Issue was reported by Florian Weimer. -CG Tue Nov 26 01:26:15 CET 2013 Fix race on shutdown signal with thread pool on non-Linux systems by signalling n times for n threads. -CG Sun Nov 24 13:41:15 CET 2013 Introduce state to mark connections in suspended state (with epoll); add missing locking operations in MHD_suspend_connection. Fix definition of MHD_TLS_CONNECTION_INIT. -MH/JC Wed Oct 30 09:34:20 CET 2013 Fixing issue in PostProcessor when getting partial boundary at the beginning, expanding test suite. -CG Sun Oct 27 15:19:44 CET 2013 Implementing faster processing of upload data in multipart encoding (thanks to performance analysis by Adam Homolya). -CG Thu Oct 24 10:40:03 CEST 2013 Adding support for connection flow control via MHD_suspend_connection and MHD_resume_connection. -CG Sat Oct 19 16:40:32 CEST 2013 Releasing libmicrohttpd 0.9.31. -CG Mon Sep 23 20:24:48 CEST 2013 Fixing build issues on OS X with CLOCK_MONOTONIC not being implemented on OS X. -CG Mon Sep 23 14:15:00 CEST 2013 Make libmicrohttpd play nicely with upcoming libgcrypt 1.6.0. -CG Fri Sep 20 17:01:37 CEST 2013 Improved configure checks for cURL. -CG Wed Sep 18 18:29:24 CEST 2013 Signal connection termination as OK (and not as ERROR) if the stream was terminated by the callback returning MHD_CONTENT_READER_END_OF_STREAM. Also, release response mutex before calling the termination callback, to avoid possible deadlock if the client destroys the response in the termination callback (due to non-recursiveness of the lock). -CG Wed Sep 18 14:31:35 CEST 2013 Adding #define MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN. -CG Tue Sep 17 21:32:47 CEST 2013 Also pass MHD connection handle in URI log callback. -CG Fri Sep 6 10:00:44 CEST 2013 Improved check for proper OpenSSL version for libmicrospdy. -CG Wed Sep 4 17:23:15 CEST 2013 Set IPV6_V6ONLY socket option correctly when IPv6 is enabled (MHD_USE_IPv6) but not dual stack (MHD_USE_DUAL_STACK) -MW Mon Sep 2 22:59:45 CEST 2013 Fix use-after-free in epoll()-mode on read error. Releasing libmicrohttpd 0.9.30. -CG Sun Sep 1 21:55:53 CEST 2013 Fixing build issues on FreeBSD. -CG Fri Aug 30 13:53:04 CEST 2013 Started to implement #3008 (RFC 2616, section 8.1.4 says HTTP server SHOULD terminate connection if the client closes it for writing via TCP FIN, so we should continue to try to read and react differently if recv() returns zero). -CG Wed Aug 28 18:40:47 CEST 2013 Fix #3007 (build issue if messages are disabled). -CG Tue Aug 27 18:39:08 CEST 2013 Fix build issue if SOCK_NONBLOCK/EPOLL_CLOEXEC are not defined (as is the case on older glibc versions). -CG Fri Aug 23 14:28:02 CEST 2013 Releasing libmicrohttpd 0.9.29. -CG Mon Aug 12 23:51:18 CEST 2013 Updated manual, documenting W32 select/shutdown issue. -CG Sat Aug 10 21:01:18 CEST 2013 Fixed #2983. -CG Sat Aug 10 20:39:27 CEST 2013 Use 'errno' to indicate why 'MHD_add_connection' failed (#2984). -CG Sat Aug 10 17:31:31 CEST 2013 Disable use of 'shutdown' on W32 always as winsock doesn't properly behave with half-closed connections (see http://www.chilkatsoft.com/p/p_299.asp). -CG/LRN Thu Aug 8 07:55:07 CEST 2013 Fixing issue with pipelining not working as desired. -CG Wed Aug 7 08:17:40 CEST 2013 Removing dependency on liberty (on W32). -MC Fri Aug 2 20:55:47 CEST 2013 Fix HTTP 1.1 compliance with respect to not returning content-length headers for successful "CONNECT" requests. Note that for unsuccessful "CONNECT" requests with an empty response body, users must now explicitly set the content-length header. -CG Sun Jul 28 16:35:17 CEST 2013 Fixing build issue (missing #ifdef) in conjunction with --disable-messages. -blueness Sat Jul 20 12:35:40 CEST 2013 Fixing combination of MHD_USE_SSL and MHD_USE_EPOLL_LINUX_ONLY. -CG Fri Jul 19 09:57:27 CEST 2013 Fix issue where connections were not cleaned up when 'MHD_run_from_select' was used. Adding experimental TURBO mode. Releasing libmicrohttpd 0.9.28. -CG Sun Jul 14 19:57:56 CEST 2013 Removing 'shutdown' calls that happen just before close or that are for read-only and for a client that has already stopped sending anyway (thus reducing number of system calls slightly). -CG Sun Jul 14 19:37:37 CEST 2013 Name MHD worker threads on glibc >= 2.12. -,L4X[o](B Fri Jul 5 12:05:01 CEST 2013 Added MHD_OPTION_CONNECTION_MEMORY_INCREMENT to allow users to specify a custom value for incrementing read buffer sizes (#2899). -MH Fri Jun 28 14:05:15 CEST 2013 If we shutdown connection for reading on POST due to error, really do not process further requests even if we already read the next request from the connection. Furthermore, do not shutdown connections for reading on GET/HEAD/etc. just because the application queued a response immediately --- reserve that behavior for PUT/POST. -CG Tue Jun 25 15:08:30 CEST 2013 Added option 'MHD_USE_DUAL_STACK' to support a single daemon for IPv4 and IPv6 without the application having to do the binding. -CG Mon Jun 24 22:33:34 CEST 2013 Finished integration with epoll, including benchmarking and documentation. -CG Sun Jun 23 15:28:13 CEST 2013 Added option 'MHD_USE_PIPE_FOR_SHUTDOWN' to cleanly support 'MHD_quiesce_daemon' with thread pools and per-connection threads (we then need a pipe for shutdown, but if 'MHD_quiesce_daemon' is not used, we do not want to require the use of a pipe; introducing the pipe after the threads have been started can also fail, so the application needs to tell us early on). -CG Sat Jun 22 20:24:17 CEST 2013 Removed locking calls for thread modes that do not need them. Reorganized way to obtain connection's event loop state. Added sorted XDLL for connections with default timeout to avoid having to loop over all connections to determine current timeout (custom per-connection timeouts are in another list which is iterated each time). -CG Fri Jun 21 20:55:48 CEST 2013 Preparing build system and tests for epoll support. -CG Tue May 21 14:34:36 CEST 2013 Improving configure tests for OpenSSL and spdylay to avoid build errors in libmicrospdy code if those libraries are not present. -CG Mon May 20 12:29:35 CEST 2013 Added MHD_CONNECTION_INFO_CONNECTION_FD to allow clients direct access to connection socket; useful for COMET applications that need to disable NAGLE (#2886). -CG Mon May 15 12:49:01 CEST 2013 Fixing #2859. -CG Sun May 5 21:44:08 CEST 2013 Merged libmicrospdy code with libmicrohttpd build system (no major changes to libmicrospdy itself yet). -CG Sun May 5 20:13:59 CEST 2013 Improved documentation and code style a bit. Releasing libmicrohttpd 0.9.27. -CG Thu Apr 25 13:08:10 CEST 2013 Added 'MHD_quiesce_daemon' to allow application to stop processing new incoming connections while finishing ongoing requests. -CG Sun Mar 31 23:17:13 CEST 2013 Added MHD demonstration code 'src/examples/demo.c'. -CG Sun Mar 31 20:27:48 CEST 2013 Adding new API call 'MHD_run_from_select' to allow programs running in 'external select mode' to reduce the number of 'select' calls by a factor of two. -CG Sun Mar 31 20:03:48 CEST 2013 Performance improvements, updated documentation. Make better use of available memory pool memory for reading (especially important for large POST uploads); improve post processor speed by internally adjusting the buffer size by 4 bytes to ensure "round" IO sizes given a "round" post processor buffer size argument. Note that applications that previously added 4 bytes to the post processor buffer size might now perform worse. Using the new 'demo' example, POST upload speed increased from ~90 MB/s to ~120 MB/s for a large file (note that the improvement comes from better aligned disk IO; without disk IO, the speed was (and remains) at ~1500 MB/s on this system). -CG Fri Mar 29 16:44:29 CET 2013 Renaming testcases to consistently begin with test_; Changing build system to build examples in doc/. Releasing libmicrohttpd 0.9.26. -CG Thu Mar 7 10:13:08 CET 2013 Fix bug in postprocessor URL parser (#2818). -jgresula Mon Mar 4 13:45:35 CET 2013 Fix dropping of SSL connections if uptime is less than MHD_OPTION_CONNECTION_TIMEOUT due to integer underflow (#2802). -greed Fri Mar 1 01:11:57 CET 2013 Fully initialize cleanup mutex struct for each thread (#2803). -Ulion Wed Feb 6 01:51:52 CET 2013 Releasing libmicrohttpd 0.9.25. -CG Fri Feb 1 10:19:44 CET 2013 Handle case where POST data contains "key=" without value at the end and is not new-line terminated by invoking the callback with the "key" during MHD_destroy_post_processor (#2733). -CG Wed Jan 30 13:09:30 CET 2013 Adding more 'const' to allow keeping of reason phrases in ROM. (see mailinglist). -CG/MV Tue Jan 29 21:27:56 CET 2013 Make code work with PlibC 0.1.7 (which removed plibc_init_utf8). Only relevant for W32. Fixes #2734. -CG Sat Jan 26 21:26:48 CET 2013 Fixing regression introduced Jan 6 (test on data_size instead of total_size. -CG Fri Jan 11 23:21:55 CET 2013 Also return MHD_YES from MHD_destroy_post_processor if we did not get '\r\n' in the upload. -CG Sun Jan 6 21:10:13 CET 2013 Enable use of "MHD_create_response_from_callback" with body size of zero. -CG Tue Dec 25 16:16:30 CET 2012 Releasing libmicrohttpd 0.9.24. -CG Tue Dec 18 21:18:11 CET 2012 Given both 'chunked' encoding and 'content-length', ignore the 'content-length' header as per RFC. -ES Thu Dec 6 10:14:44 CET 2012 Force adding "Connection: close" header to response if client asked for connection to be closed (so far, we did close the connection, but did not send the "Connection: close" header explicitly, which some clients seem to dislike. (See discussion on mailinglist). Also, if there is already a transfer-encoding other than 'chunked' set by the application, we also now close the connection if the response is of unknown size. -CG Wed Dec 5 19:22:26 CET 2012 Fixing parameter loss of POST parameters with IE8 and Chrome in the PostProcessor as the code failed to properly handle partial data. -MM Fri Nov 9 21:36:46 CET 2012 Releasing libmicrohttpd 0.9.23. -CG Thu Nov 8 22:32:59 CET 2012 Ship our own version of tsearch and friends if not provided by platform, so that MHD works nicely on Android. -JJ Mon Oct 22 13:05:01 CEST 2012 Immediately do a second read if we get a full buffer from TLS as there might be more data in the TLS buffers even if there is no activity on the socket. -CG Tue Oct 16 01:33:55 CEST 2012 Consistently use "#ifdef" and "#ifndef" WINDOWS, and not sometimes "#if". -CG Sat Sep 1 20:51:21 CEST 2012 Releasing libmicrohttpd 0.9.22. -CG Sat Sep 1 20:38:35 CEST 2012 Adding configure option to allow selecting support for basic and digest authentication separately (#2525). -CG Thu Aug 30 21:12:56 CEST 2012 Fixing URI argument parsing when string contained keys without equals sign (i.e. '&bar&') in the middle of the argument (#2531). Also replacing 'strstr' with more efficient 'strchr' when possible. -CG Tue Aug 21 14:36:17 CEST 2012 Use "int" instead of "enum X" in 'va_arg' calls to be nice to compilers that use 'short' (i.e. 8 or 16 bit) enums but pass enums still as "int" in varargs. (See discussion on mailinglist). -CG/MV Tue Aug 21 14:31:54 CEST 2012 Reduce default size in post processor buffer (for small systems; performance impact on large systems should be minimal). -CG/MV Thu Jul 19 21:48:42 CEST 2012 Releasing libmicrohttpd 0.9.21. -CG Thu Jul 19 11:34:50 CEST 2012 Consistently use 'panic' function instead of ever directly calling 'abort ()'. Eliminating unused mutex in SSL mode. Removing check in testcases that fails depending on which version of gnuTLS is involved. -CG Tue Jul 17 23:50:43 CEST 2012 Stylistic code clean up. Allowing lookup up of trailing values without keys using "MHD_lookup_connection_value" with a key of NULL (thus achieving consistency with the existing iterator API). -CG Tue Jul 17 22:37:05 CEST 2012 Adding experimental (!) code for MHD operation without listen socket. -CG Tue Jul 17 22:15:57 CEST 2012 Making sendfile test pass again on non-W32 systems. -CG Mon Jul 9 13:43:35 CEST 2012 Misc changes to allow testcases to pass on W32. -LRN Sun Jul 8 15:05:31 CEST 2012 Misc changes to fix build on W32. -LRN Fri Jun 22 11:31:25 CEST 2012 Make sure sockets opened by MHD are non-inheritable by default (#2414). -CG Tue Jun 19 19:44:53 CEST 2012 Change various uses of time(NULL) to new MHD_monotonic_time() function to make timeouts immune to the system real time clock changing. -MC Tue Jun 12 21:35:00 CEST 2012 Adding 451 status code. -CG Thu May 31 13:33:45 CEST 2012 Releasing 0.9.20. -CG Tue May 29 13:55:03 CEST 2012 Fixed some testcase build issues with disabled post processor. -CG Tue May 29 13:45:15 CEST 2012 Fixing bug where MHD failed to call connection termination callback if a connection either was closed due to read errors or if MHD was terminated with certain threading modes. Added new termination code MHD_REQUEST_TERMINATED_READ_ERROR for the read-termination cause. -CG Thu Mar 15 23:47:53 CET 2012 Eliminating code clone in tls connection read/write handlers. -CG Fri Mar 2 23:44:56 CET 2012 Making sure that MHD_get_connection_values iterates over the headers in the order in which they were received. -CG Wed Feb 1 09:39:12 CET 2012 Fixed compilation problem on MinGW. -BS Tue Jan 31 17:50:24 CET 2012 Releasing 0.9.19. -CG Mon Jan 30 20:02:34 CET 2012 Fixed handling of garbage prior to first multipart boundary (#2126). -woof Fri Jan 27 11:00:43 CET 2012 Fixed postprocessor failure for applications that enclosed boundary in quotes (#2120). -woof Tue Jan 24 16:07:53 CET 2012 Added configure check for sin_len in 'struct sockaddr' and adding code to initialize this field if it exists now. -CG Mon Jan 23 14:02:26 CET 2012 Fixed double-free if specified cipher was not valid (during MHD_daemon_start). Releasing 0.9.18. -CG Thu Jan 19 22:11:12 CET 2012 Switch to non-blocking sockets for all systems but Cygwin (we already used non-blocking sockets for GNU/Linux); also use non-blocking sockets on Cygwin for HTTPS as this is required to avoid DoS-by-partial-record via gnutls. On Cygwin, #1824 implies that we need to use blocking sockets for HTTP on Cygwin for now. -CG Thu Jan 19 17:46:05 CET 2012 Fixing use of uninitialized 'earliest_deadline' variable in MHD_get_timeout which can lead to returning an incorrect (too early) timeout (#2085). -tclaveirole Thu Jan 19 13:31:27 CET 2012 Fixing digest authentication for GET requests with URI arguments (#2059). -CG Sat Jan 7 17:30:48 CET 2012 Digest authentication expects nonce count in base 16, not base 10 (#2061). -tclaveirole Thu Jan 5 22:01:37 CET 2012 Partial fix for #2059, digest authentication with GET arguments. -CG Thu Dec 1 15:22:57 CET 2011 Updated authorization_example.c to actually demonstrate the current MHD API. -SG Mon Nov 21 18:51:30 CET 2011 Added option to suppress generation of the 'Date:' header to be used on embedded systems without RTC. Documented the new option and the configure options. -CG Sat Nov 19 20:08:40 CET 2011 Releasing 0.9.17. -CG Fri Nov 18 20:17:22 CET 2011 Fixing return value of MHD_get_timeout if timeouts are not in use. (#1914). -rboulton Sun Nov 13 13:34:29 CET 2011 Trying to fix accidental addition of a "Connection: close" footer under certain (rare) circumstances. -CG Fri Nov 4 10:03:00 CET 2011 Small updates to the tutorial. Releasing 0.9.16. -CG Thu Nov 3 10:14:59 CET 2011 shutdown(RDWR) fails on OS X after shutdown(RD), so only use shutdown(WR) if we already closed the socket for reading (otherwise OS X might not do shutdown (WR) at all). -CG Tue Nov 1 18:51:50 CET 2011 Force adding of 'Connection: close' to the header if we (for whatever reason) are shutting down the socket for reading (see also #1760). -CG Thu Oct 27 14:16:34 CEST 2011 Treat EAGAIN the same way as EINTR (helps on W32). -LRN Wed Oct 12 10:40:12 CEST 2011 Made sockets blocking again for non-Linux platforms as non-blocking sockets cause problems (#1824) on Cygwin but offer better performance on Linux (see change on August 11 2011). -CG/pross Fri Oct 7 19:50:07 CEST 2011 Fixed problems with testcases on W32. -LRN Fri Sep 30 17:56:36 CEST 2011 Fixed MHD_CONNECTION_OPTION_TIMEOUT for HTTPS (#1811). -CG Wed Sep 28 08:37:55 CEST 2011 Releasing libmicrohttpd 0.9.15. -CG Tue Sep 27 13:07:36 CEST 2011 Added ability to access URL arguments of the form 'url?foo' (without '='). Added testcase and updated documentation accordingly. -CG Mon Sep 26 21:24:00 CEST 2011 Only run response cleanup testcase if curl binary was found by configure. -CG Wed Sep 21 09:53:18 CEST 2011 Reverting to using pipes for signalling select on non-Linux platforms where shutdown-on-listen-sockets does not work. -WB/CG Mon Sep 19 14:06:30 CEST 2011 Fixing problem introduced with prompt response cleanup code. -CG Wed Sep 14 13:43:26 CEST 2011 Fixing minor memory leak if daemon with HTTPS support failed to initialize (#1766). -CG Tue Sep 13 09:47:58 CEST 2011 Try to release responses more promptly upon connection termination. -CG Mon Sep 12 10:20:28 CEST 2011 Releasing libmicrohttpd 0.9.14. -CG Mon Sep 12 10:05:36 CEST 2011 Added new function to allow setting of a custom timeout value for an individual connection (the MHD_set_connection_option is more generic, but this is currently the only use). -CG Sat Sep 10 07:30:12 CEST 2011 Documenting that MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT is not implemented and will not be implemented, and what to use instead. -CG Fri Sep 9 13:42:20 CEST 2011 Added testcase to demonstrate that response cleanup calling is working. No bug was found. -CG Thu Aug 18 11:05:16 CEST 2011 Fixed bug with wrong state transition if callback returned MHD_CONTENT_READER_END_OF_STREAM causing spurious extra callbacks to the handler (thanks to Jan Seeger for pointing it out). -CG/JS Thu Aug 11 11:40:03 CEST 2011 Changing sockets to be non-blocking as suggested by Eivind Sarto on the mailinglist. -CG Mon Jul 25 16:13:15 CEST 2011 Added a logo. -CG Sat Jul 16 22:42:10 CEST 2011 Change type of nonce to 'unsigned long int' to match return type from 'strtoul'. Fixes ERANGE check which would have previously failed. -CG Wed Jul 13 09:26:17 CEST 2011 Fixing HTTP error status strings for certain high-numbered status codes. Added support for some more (non-standard) status codes. Releasing libmicrohttpd 0.9.13. -CG Thu Jul 7 10:24:20 CEST 2011 Adding performance measurements. -CG Thu Jun 23 14:21:13 CEST 2011 Releasing libmicrohttpd 0.9.12. -CG Wed Jun 22 14:32:23 CEST 2011 Force closing connection if either the client asked it or if the response contains 'Connection: close' (so far, only the client's request was considered). -CG/RV Wed Jun 22 10:37:35 CEST 2011 Removing listen socket from poll/select sets in MHD_USE_THREAD_PER_CONNECTION mode; using 'shutdown' on connection sockets to signal termination instead. -CG Wed Jun 22 10:25:13 CEST 2011 Eliminate unnecessary (and badly synchronized) calls to MHD_get_timeout in MHD_USE_THREAD_PER_CONNECTION mode. Document that this is not acceptable. -CG Tue Jun 21 13:54:59 CEST 2011 Fixing tiny memory leak in SSL code from 'gnutls_priority_init'. Fixing data race between code doing connection shutdown and connection cleanup. Changing code to reduce connection cleanup cost from O(n) to O(1). Cleaning up logging code around 'connection_close_error'. -CG Sat Jun 11 13:05:12 CEST 2011 Replacing use of sscanf by strtoul (#1688). -CG/bplant Fri Jun 3 15:26:42 CEST 2011 Adding MHD_CONNECTION_INFO_DAEMON to obtain MHD_Daemon responsible for a given connection. -CG Wed May 25 14:23:20 CEST 2011 Trying to fix stutter problem on timeout described by David Myers on the mailinglist (5/10/2011). -CG Fri May 20 22:11:55 CEST 2011 Fixed bug in testcase setup code causing crashes in tls_session_timeout_test on some systems. Releasing libmicrohttpd 0.9.11. -CG Fri May 20 19:34:59 CEST 2011 Fixed bug in parsing multipart/form-data with post processor where the code failed to add a 0-terminator in the correct position. -PP Thu May 12 14:40:46 CEST 2011 Fixed bug where if multiple HTTP request messages are piped in at once, microhttpd would call the handler with the wrong upload_data_size. -HZM Thu May 12 14:40:08 CEST 2011 Documented possible issue with off_t being sometimes 32-bit and sometimes 64-bit depending on #includes. -CG Sun May 8 21:52:47 CEST 2011 Allow MHD_SIZE_UNKNOWN to be used in conjunction with MHD_create_response_from_fd (fixing #1679). -TG Wed Apr 27 16:11:18 CEST 2011 Releasing libmicrohttpd 0.9.10. -CG Fri Apr 8 11:40:35 CEST 2011 Workaround for cygwin poll brokenness. -TS Sun Apr 3 13:56:52 CEST 2011 Fixing compile error on OS X. -CG Wed Mar 30 12:56:09 CEST 2011 Initialize tv_usec in MHD_USE_THREAD_PER_CONNECTION with select and per-connection timeout. -CG Tue Mar 29 14:15:13 CEST 2011 Releasing libmicrohttpd 0.9.9. -CG Tue Mar 29 14:11:19 CEST 2011 Fixed call to mmap for memory pool, extended testcase to cover POLL. -CG Wed Mar 23 23:24:25 CET 2011 Do not use POLLIN when we only care about POLLHUP (significantly improves performance when using MHD_USE_THREAD_PER_CONNECTION in combination with MHD_USE_POLL). -ES Sun Mar 20 09:16:53 CET 2011 Fixing race when using MHD_USE_THREAD_PER_CONNECTION in combination with MHD_USE_POLL. -CG Fri Mar 18 13:23:47 CET 2011 Removing MSG_DONTWAIT which should not be needed and was presumably causing problems with EAGAIN under certain circumstances. -ES Fri Mar 11 22:25:29 CET 2011 Fixing bug in MHD_create_response_from_fd_at_offset with non-zero offsets. -ES Sat Mar 5 22:00:36 CET 2011 Do not use POLLRDHUP, which causes build errors on OS X / OpenSolaris (#1667). -CG Fri Mar 4 10:24:04 CET 2011 Added new API to allow MHD server to initiate connection to client (special use-case for servers behind NAT), thereby addressing #1661 (externally created connections). Releasing libmicrohttpd 0.9.8. -CG Fri Mar 4 10:07:18 CET 2011 Avoid using a pipe for signalling as well, just use server socket shutdown (also for thread-per-connection). -CG Thu Mar 3 21:42:47 CET 2011 Fixing issue where Base64 decode fails when char is defined as unsigned char (Mantis 1666). -CG/tmayer Tue Mar 1 13:58:04 CET 2011 Allow use of 'poll' in combination with the external select mode. Avoid using pthread signals (SIGALRM), use pipe instead. Corrected timeout calculation (s vs. ms). -CG Wed Feb 23 14:21:44 CET 2011 Removing useless code pointed out by Eivind Sarto. -CG Fri Feb 18 11:03:59 CET 2011 Handle large (>2 GB) file transfers with sendfile on 32-bit systems better; handle odd sendfile failures by libc/kernel by falling back to standard 'SEND'. -CG Sun Feb 13 10:52:29 CET 2011 Handle gnutls receive error(s) for interrupted SSL connections better. -MS Releasing libmicrohttpd 0.9.7. -CG Fri Feb 11 10:15:38 CET 2011 Fixing parameter ordering in documentation (#1659). -wellska Thu Jan 27 10:51:39 CET 2011 Disable 'EXTRA_CHECKS's by default as suggested in #1652 (I guess it is time). -CG/timn Thu Jan 27 10:48:55 CET 2011 Removing bogus assertion in basic authentication code (#1651). -CG/timn Tue Jan 25 14:10:45 CET 2011 Releasing libmicrohttpd 0.9.6. -CG Mon Jan 24 16:36:35 CET 2011 Fixing compilation error if DAUTH_SUPPORT was 0 (#1646). -CG/bplant Tue Jan 18 23:58:09 CET 2011 Fixing hash calculation in digest auth; old function had collisions causing the browser to challenge users for authentication too often. -CG/AW Fri Jan 14 19:19:45 CET 2011 Removing dead code, adding missing new symbols to export list. Fixed two missing NULL checks after malloc operations. -CG Mon Jan 10 14:07:33 CET 2011 Releasing libmicrohttpd 0.9.5. -CG Wed Jan 5 15:20:11 CET 2011 Fixing double-locking on non-Linux platforms when using MHD_create_response_from_fd (#1639). -CG Avoid use of strndup for better portability (#1636). -CG Tue Jan 4 13:07:21 CET 2011 Added MHD_create_response_from_buffer, deprecating MHD_create_response_from_data. Deprecating MHD_create_response_from_fd as well. -CG Sun Dec 26 00:02:15 CET 2010 Releasing libmicrohttpd 0.9.4. -CG Sat Dec 25 21:57:14 CET 2010 Adding support for basic authentication. Documented how to obtain client SSL certificates in tutorial. -MS Thu Dec 23 15:40:36 CET 2010 Increasing nonce length to 128 to support digest authentication with Opera (see #1633). Mon Dec 20 21:22:57 CET 2010 Added macro MHD_LONG_LONG to allow change of MHD's "long long" use to some other type on platforms that do not support "long long" (Mantis #1631). -CG/bplant Sun Dec 19 19:54:15 CET 2010 Added 'MHD_create_response_from_fd_at_offset'. -CG Sun Dec 19 15:16:16 CET 2010 Fixing --enable and --disable configure options to behave properly. -CG Sun Dec 19 13:46:52 CET 2010 Added option to specify size of stacks for threads created by MHD. -CG Tue Nov 23 09:41:00 CET 2010 Releasing libmicrohttpd 0.9.3. -CG Thu Nov 18 23:10:36 CET 2010 Fixing #1619 (testcases not working with NSS on Fedora). -CG/timn Thu Nov 18 22:55:58 CET 2010 Fixing #1621 (socket not closed under certain circumstances). -CG/jaredc Wed Nov 17 12:16:53 CET 2010 Allowing signalling of errors in generating chunked responses to clients (by closing connectins) using the new MHD_CONTENT_READER_END_WITH_ERROR ((size_t)-2) return value. Also introducing MHD_CONTENT_READER_END_OF_STREAM constant instead of (size_t) -1 / SIZE_MAX. Sun Nov 14 20:45:45 CET 2010 Adding API call to generate HTTP footers in response. -CG Sat Oct 16 12:38:43 CEST 2010 Releasing libmicrohttpd 0.9.2. -CG Tue Oct 12 15:41:51 CEST 2010 Fixed issue with data received via SSL being delayed in the GNUtls buffer if sender stopped transmitting (but did not close the connection) and MHD buffer size was smaller than last fragment, resulting in possibly significantly delayed processing of incoming data. -CG Wed Sep 22 09:48:59 CEST 2010 Changed port argument from 'unsigned short' to 'uint16_t'. Removed dead code when compiling with messages enabled. Minimal unrelated code cleanup. -CG Tue Sep 21 15:12:41 CEST 2010 Use "size_t" for buffer size instead of "int". -CG Sat Sep 18 07:16:30 CEST 2010 Adding support for SHOUTcast. -CG Wed Sep 15 09:33:46 CEST 2010 Fixed double-free. -CG/ES Fri Sep 10 14:47:11 CEST 2010 Releasing libmicrohttpd 0.9.1. -CG Fri Sep 10 14:29:37 CEST 2010 Adding proper nonce counter checking for digest authentication. -CG/AA Sat Sep 4 21:55:52 CEST 2010 Digest authentication now seems to be working. -CG/AA Wed Sep 1 13:59:16 CEST 2010 Added ability to specify external unescape function. "microhttpd.h" now includes the right headers for GNU/Linux systems unless MHD_PLATFORM_H is defined (in which case it is assumed that the right headers were already determined by some configure-like process). -CG Tue Aug 31 15:39:25 CEST 2010 Fixed bug with missing call to response cleanup in case of connection handling error (for example, after getting a SIGPIPE). -CG Tue Aug 24 11:39:25 CEST 2010 Fixed bug in handling EAGAIN from GnuTLS (caused needlessly dropped SSL connections). -CG Sun Aug 22 16:49:13 CEST 2010 Initial draft for digest authentication. -AA Thu Aug 19 14:15:01 CEST 2010 Changed code to enable error messages and HTTPS by default; added option to disable post processor API (use breaks binary compatibility, should only be done for embedded systems that require minimal footprint). -CG Thu Aug 19 13:26:00 CEST 2010 Patches for Windows to ease compilation trouble. -GT/CG Sat Aug 14 15:43:30 CEST 2010 Fixed small, largely hypothetical leaks. Reduced calls to strlen for header processing. -CG Fri Aug 6 12:51:59 CEST 2010 Fixing (small) memory leak on daemon-shutdown with SSL enabled. -CG/PG Thu Aug 5 22:24:37 CEST 2010 Fixing timeout bug on systems that think it's still 1970 (can happen if system time not initialized). -CG Mon Jul 26 10:46:57 CEST 2010 Releasing libmicrohttpd 0.9.0. -CG Sun Jul 25 14:57:47 CEST 2010 Adding support for sendfile on Linux. Adding support for systemd-style passing of an existing listen socket as an option. IPv6 sockets now only bind to IPv6 (if platform supports this). -CG Sun Jul 25 11:10:45 CEST 2010 Changed code to use external libgnutls code instead of the "fork". Minor API changes for setting TLS options. -CG Sun Jun 13 10:52:34 CEST 2010 Cleaned up example code. -CG Fri Apr 23 09:56:37 CEST 2010 Do not return HTTP headers for requests without version numbers. Do return HTTP version 1.0 if client requested HTTP version 1.1 (previously, we returned HTTP/1.1 even if the client specified HTTP/1.0). -GM/CG Sat Mar 13 09:41:01 CET 2010 Releasing libmicrohttpd 0.4.6. -CG Wed Mar 10 13:18:26 CET 2010 Fixing bug in 100 CONTINUE replacement when handling POSTs (see report on mailinglist), with testcase. -CG/MC Tue Feb 23 09:16:15 CET 2010 Added configure check for endianness to define WORDS_BIGENDIAN which fixes SSL support on big endian architectures. -JA/CG Sat Feb 20 10:01:09 CET 2010 Added check for inconsistent options (MHD_OPTION_PROTOCOL_VERSION without MHD_USE_SSL) causing instant segfault. -JA/CG Tue Feb 9 20:31:51 CET 2010 Fixed issue with poll doing busy waiting. -BK/CG Thu Jan 28 21:28:56 CET 2010 Releasing libmicrohttpd 0.4.5. -CG Thu Jan 28 20:35:48 CET 2010 Make sure addresses returned by memory pool are aligned (fixes bus errors on Sparc). -CG Thu Dec 17 20:26:52 CET 2009 poll.h is not strictly required anymore. -ND Fri Dec 4 13:17:50 CET 2009 Adding MHD_OPTION_ARRAY. -CG Mon Nov 16 14:41:26 CET 2009 Fixed busy-loop in internal select mode for inactive clients with infinite connection timeout. -CG Thu Nov 12 16:19:14 CET 2009 Adding support for setting a custom error handler for fatal errors (previously, the implementation always called 'abort' in these cases). -CG/ND Wed Nov 11 12:54:16 CET 2009 Adding support for poll (alternative to select allowing for more than FD_SETSIZE parallel connections). -JM Wed Oct 28 20:26:00 CET 2009 Releasing libmicrohttpd 0.4.4. -CG Wed Oct 14 14:37:37 CEST 2009 Fixing (rare) deadlock due to SELECT missing SIGALRM by making all SELECT calls block for at most 1s. While this can in (rare) situations delay the shutdown by 1s, I think this is preferable (both performance and possibly portability-wise) over using a pipe for the signal. -CG Sun Oct 11 14:57:29 CEST 2009 Adding eCos license as an additional license for the non-HTTPS code of MHD. -CG Sun Oct 11 11:24:27 CEST 2009 Adding support for Symbian. -MR Fri Oct 9 15:21:29 CEST 2009 Check for error codes from pthread operations (to help with error diagnostics) and abort if something went wrong. -CG Thu Oct 8 10:43:02 CEST 2009 Added check for sockets being '< FD_SETSIZE' (just to be safe). -CG Mon Oct 5 21:17:26 CEST 2009 Adding "COOKIE" header string #defines. -CG Mon Oct 5 08:29:06 CEST 2009 Documenting default values. -CG Fri Aug 28 22:56:47 CEST 2009 Releasing libmicrohttpd 0.4.3. -CG Sun Aug 23 16:21:35 UTC 2009 Allow MHD_get_daemon_info to return the daemon's listen socket. Includes a test case that uses this functionality to bind a server to an OS-assigned port, look the port up with getsockname, and curl it. -DR Tue Aug 4 00:14:04 CEST 2009 Fixing double-call to read from content-reader callback for first data segment (as reported by Alex on the mailinglist). -CG Thu Jul 29 21:41:52 CEST 2009 Fixed issue with the code not using the "block_size" argument given to MHD_create_response_from_callback causing inefficiencies for values < 2048 and segmentation faults for values > 2048 (as reported by Andre Colomb on the mailinglist). -CG Sun May 17 03:29:46 MDT 2009 Releasing libmicrohttpd 0.4.2. -CG Fri May 15 11:00:20 MDT 2009 Grow reserved read buffer more aggressively so that we are not needlessly stuck reading only a handful of bytes in each iteration. -CG Thu May 14 21:20:30 MDT 2009 Fixed issue where the "NOTIFY_COMPLETED" handler could be called twice (if a socket error or timeout occurred for a pipelined connection after successfully completing a request and before the next request was successfully transmitted). This could confuse applications not expecting to see a connection "complete" that they were never aware of in the first place. -CG Mon May 11 13:01:16 MDT 2009 Fixed issue where error code on timeout was "TERMINATED_WITH_ERROR" instead of "TERMINATED_TIMEOUT_REACHED". -CG Wed Apr 1 21:33:05 CEST 2009 Added MHD_get_version(). -ND Wed Mar 18 22:59:07 MDT 2009 Releasing libmicrohttpd 0.4.1. -CG Wed Mar 18 17:46:58 MDT 2009 Always RECV/SEND with MSG_DONTWAIT to (possibly) address strange deadlock reported by Erik on the mailinglist --- and/or issues with blocking read after select on GNU/Linux (see select man page under bugs). -CG Tue Mar 17 01:19:50 MDT 2009 Added support for thread-pools. -CG/RA Mon Mar 2 23:44:08 MST 2009 Fixed problem with 64-bit upload and download sizes and "-1" being used to indicate "unknown" by introducing new 64-bit constant "MHD_SIZE_UNKNOWN". -CG/DC Wed Feb 18 08:13:56 MST 2009 Added missing #include for build on arm-linux-uclibc. -CG/CC Mon Feb 16 21:12:21 MST 2009 Moved MHD_get_connection_info so that it is always defined, even if HTTPS support is not enabled. -CG Sun Feb 8 21:15:30 MST 2009 Releasing libmicrohttpd 0.4.0. -CG Thu Feb 5 22:43:45 MST 2009 Incompatible API change to allow 64-bit uploads and downloads. Clients must use "uint64_t" for the "pos" argument (MHD_ContentReaderCallback) and the "off" argument (MHD_PostDataIterator) and the "size" argument (MHD_create_response_from_callback) now. Also, "unsigned int" was changed to "size_t" for the "upload_data_size" argument (MHD_AccessHandlerCallback), the argument to MHD_OPTION_CONNECTION_MEMORY_LIMIT, the "block_size" argument (MHD_create_response_from_callback), the "buffer_size" argument (MHD_create_post_processor) and the "post_data_len" argument (MHD_post_process). You may need to #include before from now on. -CG Thu Feb 5 20:21:08 MST 2009 Allow getting address information about the connecting client after the accept call. -CG Mon Feb 2 22:21:48 MST 2009 Fixed missing size adjustment for offsets for %-encoded arguments processed by the post processor (Mantis #1447). -CG/SN Fri Jan 23 16:57:21 MST 2009 Support charset specification (ignore) after content-type when post-processing HTTP POST requests (Mantis #1443). -CG/SN Fri Dec 26 23:08:04 MST 2008 Fixed broken check for identical connection address. -CG Making cookie parser more RFC2109 compliant (handle spaces around key, allow value to be optional). -CG Sat Dec 6 18:36:17 MST 2008 Added configure option to disable checking for CURL support. Added MHD_OPTION to allow specification of custom logger. -CG Tue Nov 18 01:19:53 MST 2008 Removed support for untested and/or broken SSL features and (largely useless) options. -CG Sun Nov 16 16:54:54 MST 2008 Added option to get unparsed URI via callback. Releasing GNU libmicrohttpd 0.4.0pre1. -CG Sun Nov 16 02:48:14 MST 2008 Removed tons of dead code. -CG Sat Nov 15 17:34:24 MST 2008 Added build support for code coverage analysis. -CG Sat Nov 15 00:31:33 MST 2008 Removing (broken) support for HTTPS servers with anonymous (aka "no") certificates as well as various useless dead code. -CG Sat Nov 8 02:18:42 MST 2008 Unset TCP_CORK at the end of transmitting a response to improve performance (on systems where this is supported). -MM Tue Sep 30 16:48:08 MDT 2008 Make MHD useful to Cygwin users; detect IPv6 headers in configure. Sun Sep 28 14:57:46 MDT 2008 Unescape URIs (convert "%ef%e4%45" to "$BCf9q(B"). -CG Wed Sep 10 22:43:59 MDT 2008 Releasing GNU libmicrohttpd 0.4.0pre0. -CG Wed Sep 10 21:36:06 MDT 2008 Fixed data race on closing sockets during shutdown (in one-thread-per-connection mode). -CG Thu Sep 4 23:37:18 MDT 2008 Fixed some boundary issues with processing chunked requests; removed memmove from a number of spots, in favor of using an index into the current buffer instead. -GS Sun Aug 24 13:05:41 MDT 2008 Now handling clients returning 0 from response callback as specified in the documentation (abort if internal select is used, retry immediately if a thread per connection is used). -CG Sun Aug 24 12:44:43 MDT 2008 Added missing reason phrase. -SG Sun Aug 24 10:33:22 MDT 2008 Fixed bug where MHD failed to transmit the response when the client decided not to send "100 CONTINUE" during a PUT/POST request. -CG Wed Jul 16 18:54:03 MDT 2008 Fixed bug generating chunked responses with chunk sizes greater than 0xFFFFFF (would cause protocol violations). -CG Mon May 26 13:28:57 MDT 2008 Updated and improved documentation. Releasing GNU libmicrohttpd 0.3.1. -CG Fri May 23 16:54:41 MDT 2008 Fixed issue with postprocessor not handling URI-encoded values of more than 1024 bytes correctly. -CG Mon May 5 09:18:29 MDT 2008 Fixed date header (was off by 1900 years). -JP Sun Apr 13 01:06:20 MDT 2008 Releasing GNU libmicrohttpd 0.3.0. -CG Sat Apr 12 21:34:26 MDT 2008 Generate an internal server error if the programmer fails to handle upload data correctly. Tweaked testcases to avoid running into the problem in the testcases. Completed zzuf-based fuzzing testcases. -CG Sat Apr 12 15:14:05 MDT 2008 Restructured the code (curl-testcases and zzuf testcases are now in different directories; code examples are in src/examples/). Fixed a problem (introduced in 0.2.3) with handling very large requests (the code did not return proper error code). If "--enable-messages" is specified, the code now includes reasonable default HTML webpages for various built-in errors (such as request too large and malformed requests). Without that flag, the webpages returned will still be empty. Started to add zzuf-based fuzzing-testcases (these require the zzuf and socat binaries to be installed). -CG Fri Apr 11 20:20:34 MDT 2008 I hereby dub libmicrohttpd a GNU package. -Richard Stallman Sat Mar 29 22:36:09 MDT 2008 Fixed bugs in handling of malformed HTTP requests (causing either NULL dereferences or connections to persist until time-out, if any). -CG Updated and integrated TexInfo documentation. -CG Tue Mar 25 13:40:53 MDT 2008 Prevent multi-part post-processor from going to error state when the input buffer is full and current token just changes processor state without consuming any data. Also, the original implementation would not consume any input in process_value_to_boundary if there is no new line character in sight. -AS Remove checks for request method after it finished writing response footers as it's only _pipelined_ requests that should not be allowed after POST or PUT requests. Reusing the existing connection is perfectly ok though. And there is no reliable way to detect pipelining on server side anyway so it is the client's responsibility to not send new data before it gets a response after a POST operation. -AS Clarified license in man page. Releasing libmicrohttpd 0.2.3 -CG Sat Mar 22 01:12:38 MDT 2008 Releasing libmicrohttpd 0.2.2. -CG Mon Feb 25 19:13:53 MST 2008 Fixed a problem with sockets closed for reading ending up in the read set under certain circumstances. -CG Wed Jan 30 23:15:44 MST 2008 Added support for nested multiparts to post processor. Made sure that MHD does not allow pipelining for methods other than HEAD and GET (and of course still also only allows it for http 1.1). Releasing libmicrohttpd 0.2.1. -CG Mon Jan 21 11:59:46 MST 2008 Added option to limit number of concurrent connections accepted from the same IP address. -CG Fri Jan 4 16:02:08 MST 2008 Fix to properly close connection if application signals problem handling the request. - AS Wed Jan 2 16:41:05 MST 2008 Improvements and bugfixes to post processor implementation. - AS Wed Dec 19 21:12:04 MST 2007 Implemented chunked (HTTP 1.1) downloads (including sending of HTTP footers). Also allowed queuing of a response early to suppress the otherwise automatic "100 CONTINUE" response. Removed the mostly useless "(un)register handler" methods from the API. Changed the internal implementation to use a finite state machine (cleaner code, slightly less memory consumption). Releasing libmicrohttpd 0.2.0. - CG Sun Dec 16 03:24:13 MST 2007 Implemented handling of chunked (HTTP 1.1) uploads. Note that the upload callback must be able to process chunks in the size uploaded by the client, MHD will not "join" small chunks into a big contiguous block of memory (even if buffer space would be available). - CG Wed Dec 5 21:39:35 MST 2007 Fixed race in multi-threaded server mode. Fixed handling of POST data when receiving a "Connection: close" header (#1296). Releasing libmicrohttpd 0.1.2. - CG Sat Nov 17 00:55:24 MST 2007 Fixed off-by-one in error message string matching. Added code to avoid generating SIGPIPE on platforms where this is possible (everywhere else, the main application should install a handler for SIGPIPE). Thu Oct 11 11:02:06 MDT 2007 Releasing libmicrohttpd 0.1.1. - CG Thu Oct 11 10:09:12 MDT 2007 Fixing response to include HTTP status message. - EG Thu Sep 27 10:19:46 MDT 2007 Fixing parsing of "%xx" in URLs with GET arguments. - eglaysher Sun Sep 9 14:32:23 MDT 2007 Added option to compile debug/warning messages; error messages are now disabled by default. Modified linker option for GNU LD to not export non-public symbols (further reduces binary size). Releasing libmicrohttpd 0.1.0. - CG Sat Sep 8 21:54:04 MDT 2007 Extended API to allow for incremental POST processing. The new API is binary-compatible as long as the app does not handle POSTs, but since that maybe the case, we're strictly speaking breaking backwards compatibility (since url-encoded POST data is no longer obtained the same way). - CG Thu Aug 30 00:59:24 MDT 2007 Improving API to allow clients to associate state with a connection and to be notified about request termination (this is a binary-compatible change). - CG Fixed compile errors under OS X. - HL Sun Aug 26 03:11:46 MDT 2007 Added MHD_USE_PEDANTIC_CHECKS option which enforces receiving a "Host:" header in HTTP 1.1 (and sends a HTTP 400 status back if this is violated). - CG Tue Aug 21 01:01:46 MDT 2007 Fixing assertion failure that occurred when a client closed the connection after sending some data but not the full headers. - CG Sat Aug 18 03:06:09 MDT 2007 Check for out of memory when adding headers to responses. Check for NULL key when looking for headers. If a content reader callback for a response returns zero (has no data yet), do not possibly fall into busy waiting when using external select (with internal selects we have no choice). - CG Wed Aug 15 01:46:44 MDT 2007 Extending API to allow timeout of connections. Changed API (MHD_create_response_from_callback) to allow user to specify IO buffer size. Improved error handling. Released libmicrohttpd 0.0.3. - CG Tue Aug 14 19:45:49 MDT 2007 Changed license to LGPL (with consent from all contributors). Released libmicrohttpd 0.0.2. - CG Sun Aug 12 00:09:26 MDT 2007 Released libmicrohttpd 0.0.1. - CG Fri Aug 10 17:31:23 MDT 2007 Fixed problems with handling of responses created from callbacks. Allowing accept policy callback to be NULL (to accept from all). Added minimal fileserver example. Only send 100 continue header when specifically requested. - CG Wed Aug 8 01:46:06 MDT 2007 Added pool allocation and connection limitations (total number and memory size). Released libmicrohttpd 0.0.0. - CG Tue Jan 9 20:52:48 MST 2007 Created project build files and updated API. - CG libmicrohttpd-1.0.1/libmicrohttpd.pc.in0000644000175000017500000000051114417460232013633 prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libmicrohttpd Description: A library for creating an embedded HTTP server Version: @VERSION@ Requires: Requires.private: @MHD_REQ_PRIVATE@ Conflicts: Libs: -L${libdir} -lmicrohttpd Libs.private: @MHD_LIBDEPS_PKGCFG@ Cflags: -I${includedir} libmicrohttpd-1.0.1/COPYING0000644000175000017500000006013114417460232011075 Some of this code is DUAL-LICENSED. If you use MHD without HTTPS/SSL support, you are free to choose between the LGPL and the eCos License (http://ecos.sourceware.org/license-overview.html). If you compile MHD with HTTPS support, you must obey the terms of the GNU LGPL. GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS libmicrohttpd-1.0.1/AUTHORS0000644000175000017500000000530714417460232011116 Primary developers: Christian Grothoff (maintainer) Evgeny Grin (Karlson2k) (maintainer) Andrey Uzunov (libmicrospdy experiment) Nils Durner (W32 port) Sagie Amir (TLS/SSL support using GNUtls) Richard Alimi (performance) Amr Ali (digest authentication) Matthieu Speder (basic authentication, client certificates) Code contributions also came from: Chris GauthierDickey Elliot Glaysher Daniel Pittman John Popplewell Heikki Lindholm Alex Sadovsky Greg Schohn Thomas Martin Peter Ross RuXu W Matthew Moore Colin Caughie David Carvalho David Reiss Markus Doppelbauer Matt Holiday Michael Cronenworth Milan Straka Mika Raento Mike Crowe John Muth Geoffrey McRae Piotr Grzybowski Gerrit Telkamp Erik Slagter Andreas Wehrmann Eivind Sarto Thomas Stalder Zhimin Huang Jan Seeger Will Bryant LRN Sven Geggus Steve Wolf Brecht Sanders Jan Janak Matthew Mundell Scott Goldman Jared Cantwell Luke-Jr Sree Harsha Totakura Hani Benhabiles Guy Martin Robert Groenenberg Denis Dowling Louis Benoit Flavio Coelin Silvio Clecio Robert D Kosisko Tal Moaz Dirk Brinkmeier Jose Bollo Jonathan McDougall Tim Ruhsen Lawrence Sebald (iovec-based responses) Documentation contributions also came from: Marco Maggi Sebastian Gerhardt Special thanks to: Florian Weimer Ramakrishnan Muthukrishnan Gervasa Markham Liz Steininger libmicrohttpd-1.0.1/doc/0000755000175000017500000000000014566140220010663 5libmicrohttpd-1.0.1/doc/libmicrohttpd.info0000644000175000017500000107365414566140220014344 This is libmicrohttpd.info, produced by makeinfo version 7.1 from libmicrohttpd.texi. This manual is for GNU libmicrohttpd (version 1.0.1, 29 January 2024), a library for embedding an HTTP(S) server into C applications. Copyright © 2007-2019 Christian Grothoff Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". INFO-DIR-SECTION Software libraries START-INFO-DIR-ENTRY * libmicrohttpd: (libmicrohttpd). Embedded HTTP server library. END-INFO-DIR-ENTRY  File: libmicrohttpd.info, Node: Top, Next: microhttpd-intro, Up: (dir) The GNU libmicrohttpd Library ***************************** This manual is for GNU libmicrohttpd (version 1.0.1, 29 January 2024), a library for embedding an HTTP(S) server into C applications. Copyright © 2007-2019 Christian Grothoff Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". * Menu: * microhttpd-intro:: Introduction. * microhttpd-const:: Constants. * microhttpd-struct:: Structures type definition. * microhttpd-cb:: Callback functions definition. * microhttpd-init:: Starting and stopping the server. * microhttpd-inspect:: Implementing external ‘select’. * microhttpd-requests:: Handling requests. * microhttpd-responses:: Building responses to requests. * microhttpd-flow:: Flow control. * microhttpd-dauth:: Utilizing Authentication. * microhttpd-post:: Adding a ‘POST’ processor. * microhttpd-info:: Obtaining and modifying status information. * microhttpd-util:: Utilities. * microhttpd-websocket:: Websockets. Appendices * GNU-LGPL:: The GNU Lesser General Public License says how you can copy and share almost all of 'libmicrohttpd'. * eCos License:: The eCos License says how you can copy and share some parts of 'libmicrohttpd'. * GNU-GPL:: The GNU General Public License (with eCos extension) says how you can copy and share some parts of 'libmicrohttpd'. * GNU-FDL:: The GNU Free Documentation License says how you can copy and share the documentation of 'libmicrohttpd'. Indices * Concept Index:: Index of concepts and programs. * Function and Data Index:: Index of functions, variables and data types. * Type Index:: Index of data types.  File: libmicrohttpd.info, Node: microhttpd-intro, Next: microhttpd-const, Prev: Top, Up: Top 1 Introduction ************** All symbols defined in the public API start with ‘MHD_’. MHD is a small HTTP daemon library. As such, it does not have any API for logging errors (you can only enable or disable logging to stderr). Also, it may not support all of the HTTP features directly, where applicable, portions of HTTP may have to be handled by clients of the library. The library is supposed to handle everything that it must handle (because the API would not allow clients to do this), such as basic connection management. However, detailed interpretations of headers, such as range requests, are left to the main application. In particular, if an application developer wants to support range requests, he needs to explicitly indicate support in responses and also explicitly parse the range header and generate a response (for example, using the ‘MHD_create_response_from_fd_at_offset’ call to serve ranges from a file). MHD does understands headers that control connection management (specifically, ‘Connection: close’ and ‘Expect: 100 continue’ are understood and handled automatically). ‘Connection: upgrade’ is supported by passing control over the socket (or something that behaves like the real socket in the case of TLS) to the application (after sending the desired HTTP response header). MHD largely ignores the semantics of the different HTTP methods, so clients are left to handle those. One exception is that MHD does understand ‘HEAD’ and will only send the headers of the response and not the body, even if the client supplied a body. (In fact, clients do need to construct a response with the correct length, even for ‘HEAD’ request.) MHD understands ‘POST’ data and is able to decode certain formats (at the moment only ‘application/x-www-form-urlencoded’ and ‘multipart/form-data’) using the post processor API. The data stream of a POST is also provided directly to the main application, so unsupported encodings could still be processed, just not conveniently by MHD. The header file defines various constants used by the HTTP protocol. This does not mean that MHD actually interprets all of these values. The provided constants are exported as a convenience for users of the library. MHD does not verify that transmitted HTTP headers are part of the standard specification; users of the library are free to define their own extensions of the HTTP standard and use those with MHD. All functions are guaranteed to be completely reentrant and thread-safe. MHD checks for allocation failures and tries to recover gracefully (for example, by closing the connection). Additionally, clients can specify resource limits on the overall number of connections, number of connections per IP address and memory used per connection to avoid resource exhaustion. 1.1 Scope ========= MHD is currently used in a wide range of implementations. Examples based on reports we've received from developers include: • Embedded HTTP server on a cortex M3 (128 KB code space) • Large-scale multimedia server (reportedly serving at the simulator limit of 7.5 GB/s) • Administrative console (via HTTP/HTTPS) for network appliances 1.2 Thread modes and event loops ================================ MHD supports four basic thread modes and up to three event loop styles. The four basic thread modes are external sockets polling (MHD creates no threads, event loop is fully managed by the application), internal polling (MHD creates one thread for all connections), polling in thread pool (MHD creates a thread pool which is used to process all connections) and thread-per-connection (MHD creates one thread for listen sockets and then one thread per accepted connection). These thread modes are then combined with the evet loop styles (polling function type). MHD support select, poll and epoll. select is available on all platforms, epoll and poll may not be available on some platforms. Note that it is possible to combine MHD using epoll with an external select-based event loop. The default (if no other option is passed) is "external select". The highest performance can typically be obtained with a thread pool using ‘epoll’. Apache Benchmark (ab) was used to compare the performance of ‘select’ and ‘epoll’ when using a thread pool and a large number of connections. *note Figure 1.1: fig:performance. shows the resulting plot from the ‘benchmark.c’ example, which measures the latency between an incoming request and the completion of the transmission of the response. In this setting, the ‘epoll’ thread pool with four threads was able to handle more than 45,000 connections per second on loopback (with Apache Benchmark running three processes on the same machine). [image src="libmicrohttpd_performance_data.png" alt="Data"] Figure 1.1: Performance measurements for select vs. epoll (with thread-pool). Not all combinations of thread modes and event loop styles are supported. This is partially to keep the API simple, and partially because some combinations simply make no sense as others are strictly superior. Note that the choice of style depends first of all on the application logic, and then on the performance requirements. Applications that perform a blocking operation while handling a request within the callbacks from MHD must use a thread per connection. This is typically rather costly. Applications that do not support threads or that must run on embedded devices without thread-support must use the external mode. Using ‘epoll’ is only supported on some platform, thus portable applications must at least have a fallback option available. *note Table 1.1: tbl:supported. lists the sane combinations. select poll epoll external yes no yes internal yes yes yes thread pool yes yes yes thread-per-connection yes yes no Table 1.1: Supported combinations of event styles and thread modes. 1.3 Compiling GNU libmicrohttpd =============================== MHD uses the standard GNU system where the usual build process involves running $ ./configure $ make $ make install MHD supports various options to be given to configure to tailor the binary to a specific situation. Note that some of these options will remove portions of the MHD code that are required for binary-compatibility. They should only be used on embedded systems with tight resource constraints and no concerns about library versioning. Standard distributions including MHD are expected to always ship with all features enabled, otherwise unexpected incompatibilities can arise! Here is a list of MHD-specific options that can be given to configure (canonical configure options such as "-prefix" are also supported, for a full list of options run "./configure -help"): ‘``--disable-curl''’ disable running testcases using libcurl ‘``--disable-largefile''’ disable support for 64-bit files ‘``--disable-messages''’ disable logging of error messages (smaller binary size, not so much fun for debugging) ‘``--disable-https''’ disable HTTPS support, even if GNUtls is found; this option must be used if eCOS license is desired as an option (in all cases the resulting binary falls under a GNU LGPL-only license) ‘``--disable-postprocessor''’ do not include the post processor API (results in binary incompatibility) ‘``--disable-dauth''’ do not include the authentication APIs (results in binary incompatibility) ‘``--disable-httpupgrade''’ do not build code for HTTP "Upgrade" (smaller binary size, binary incompatible library) ‘``--disable-epoll''’ do not include epoll support, even if it supported (minimally smaller binary size, good for portability testing) ‘``--enable-coverage''’ set flags for analysis of code-coverage with gcc/gcov (results in slow, large binaries) ‘``--with-threads=posix,w32,none,auto''’ sets threading library to use. With use "none" to not support threads. In this case, MHD will only support the "external" threading modes and not perform any locking of data structures! Use ‘MHD_is_feature_supported(MHD_FEATURE_THREADS)’ to test if threads are available. Default is "auto". ‘``--with-gcrypt=PATH''’ specifies path to libgcrypt installation ‘``--with-gnutls=PATH''’ specifies path to libgnutls installation To cross-compile MHD for Android, install the Android NDK and use: ./configure --target=arm-linux-androideabi --host=arm-linux-androideabi --disable-doc --disable-examples make Similar build commands should work for cross-compilation to other platforms. Note that you may have to first cross-compile GnuTLS to get MHD with TLS support. 1.4 Validity of pointers ======================== MHD will give applications access to its internal data structures via pointers via arguments and return values from its API. This creates the question as to how long those pointers are assured to stay valid. Most MHD data structures are associated with the connection of an HTTP client. Thus, pointers associated with a connection are typically valid until the connection is finished, at which point MHD will call the ‘MHD_RequestCompletedCallback’ if one is registered. Applications that have such a callback registered may assume that keys and values from the ‘MHD_KeyValueIterator’, return values from ‘MHD_lookup_connection_value’ and the ‘url’, ‘method’ and ‘version’ arguments to the ‘MHD_AccessHandlerCallback’ will remain valid until the respective ‘MHD_RequestCompletedCallback’ is invoked. In contrast, the ‘upload_data’ argument of ‘MHD_RequestCompletedCallback’ as well as all pointers from the ‘MHD_PostDataIterator’ are only valid for the duration of the callback. Pointers returned from ‘MHD_get_response_header’ are valid as long as the response itself is valid. 1.5 Including the microhttpd.h header ===================================== Ideally, before including "microhttpd.h" you should add the necessary includes to define the ‘va_list’, ‘size_t’, ‘ssize_t’, ‘intptr_t’, ‘off_t’, ‘uint8_t’, ‘uint16_t’, ‘int32_t’, ‘uint32_t’, ‘int64_t’, ‘uint64_t’, ‘fd_set’, ‘socklen_t’ and ‘struct sockaddr’ data types. Which specific headers are needed may depend on your platform and your build system might include some tests to provide you with the necessary conditional operations. For possible suggestions consult ‘platform.h’ and ‘configure.ac’ in the MHD distribution. Once you have ensured that you manually (!) included the right headers for your platform before "microhttpd.h", you should also add a line with ‘#define MHD_PLATFORM_H’ which will prevent the "microhttpd.h" header from trying (and, depending on your platform, failing) to include the right headers. If you do not define MHD_PLATFORM_H, the "microhttpd.h" header will automatically include headers needed on GNU/Linux systems (possibly causing problems when porting to other platforms). 1.6 SIGPIPE =========== MHD does not install a signal handler for SIGPIPE. On platforms where this is possible (such as GNU/Linux), it disables SIGPIPE for its I/O operations (by passing MSG_NOSIGNAL or similar). On other platforms, SIGPIPE signals may be generated from network operations by MHD and will cause the process to die unless the developer explicitly installs a signal handler for SIGPIPE. Hence portable code using MHD must install a SIGPIPE handler or explicitly block the SIGPIPE signal. MHD does not do so in order to avoid messing with other parts of the application that may need to handle SIGPIPE in a particular way. You can make your application handle SIGPIPE by calling the following function in ‘main’: static void catcher (int sig) { } static void ignore_sigpipe () { struct sigaction oldsig; struct sigaction sig; sig.sa_handler = &catcher; sigemptyset (&sig.sa_mask); #ifdef SA_INTERRUPT sig.sa_flags = SA_INTERRUPT; /* SunOS */ #else sig.sa_flags = SA_RESTART; #endif if (0 != sigaction (SIGPIPE, &sig, &oldsig)) fprintf (stderr, "Failed to install SIGPIPE handler: %s\n", strerror (errno)); } 1.7 MHD_UNSIGNED_LONG_LONG ========================== Some platforms do not support ‘long long’. Hence MHD defines a macro ‘MHD_UNSIGNED LONG_LONG’ which will default to ‘unsigned long long’. For standard desktop operating systems, this is all you need to know. However, if your platform does not support ‘unsigned long long’, you should change "platform.h" to define ‘MHD_LONG_LONG’ and ‘MHD_UNSIGNED_LONG_LONG’ to an appropriate alternative type and also define ‘MHD_LONG_LONG_PRINTF’ and ‘MHD_UNSIGNED_LONG_LONG_PRINTF’ to the corresponding format string for printing such a data type. Note that the "signed" versions are deprecated. Also, for historical reasons, ‘MHD_LONG_LONG_PRINTF’ is without the percent sign, whereas ‘MHD_UNSIGNED_LONG_LONG_PRINTF’ is with the percent sign. Newly written code should only use the unsigned versions. However, you need to define both in "platform.h" if you need to change the definition for the specific platform. 1.8 Portability to W32 ====================== libmicrohttpd in general ported well to W32. Most libmicrohttpd features are supported. W32 do not support some functions, like epoll and corresponding MHD features are not available on W32. 1.9 Portability to z/OS ======================= To compile MHD on z/OS, extract the archive and run iconv -f UTF-8 -t IBM-1047 contrib/ascebc > /tmp/ascebc.sh chmod +x /tmp/ascebc.sh for n in `find * -type f` do /tmp/ascebc.sh $n done to convert all source files to EBCDIC. Note that you must run ‘configure’ from the directory where the configure script is located. Otherwise, configure will fail to find the ‘contrib/xcc’ script (which is a wrapper around the z/OS c89 compiler).  File: libmicrohttpd.info, Node: microhttpd-const, Next: microhttpd-struct, Prev: microhttpd-intro, Up: Top 2 Constants *********** -- Enumeration: MHD_FLAG Options for the MHD daemon. Note that MHD will run automatically in background thread(s) only if ‘MHD_USE_INTERNAL_POLLING_THREAD’ is used. Otherwise caller (application) must use ‘MHD_run’ or ‘MHD_run_from_select’ to have MHD processed network connections and data. Starting the daemon may also fail if a particular option is not implemented or not supported on the target platform (i.e. no support for TLS, threads or IPv6). TLS support generally depends on options given during MHD compilation. ‘MHD_NO_FLAG’ No options selected. ‘MHD_USE_ERROR_LOG’ If this flag is used, the library should print error messages and warnings to stderr (or to custom error printer if it's specified by options). Note that for this run-time option to have any effect, MHD needs to be compiled with messages enabled. This is done by default except you ran configure with the ‘--disable-messages’ flag set. ‘MHD_USE_DEBUG’ Currently the same as ‘MHD_USE_ERROR_LOG’. ‘MHD_USE_TLS’ Run in HTTPS-mode. If you specify ‘MHD_USE_TLS’ and MHD was compiled without SSL support, ‘MHD_start_daemon’ will return NULL. ‘MHD_USE_THREAD_PER_CONNECTION’ Run using one thread per connection. ‘MHD_USE_INTERNAL_POLLING_THREAD’ Run using an internal thread doing ‘SELECT’. ‘MHD_USE_IPv6’ Run using the IPv6 protocol (otherwise, MHD will just support IPv4). If you specify ‘MHD_USE_IPV6’ and the local platform does not support it, ‘MHD_start_daemon’ will return NULL. If you want MHD to support IPv4 and IPv6 using a single socket, pass MHD_USE_DUAL_STACK, otherwise, if you only pass this option, MHD will try to bind to IPv6-only (resulting in no IPv4 support). ‘MHD_USE_DUAL_STACK’ Use a single socket for IPv4 and IPv6. Note that this will mean that IPv4 addresses are returned by MHD in the IPv6-mapped format (the 'struct sockaddr_in6' format will be used for IPv4 and IPv6). ‘MHD_USE_PEDANTIC_CHECKS’ Deprecated (use ‘MHD_OPTION_STRICT_FOR_CLIENT’). Be pedantic about the protocol. Specifically, at the moment, this flag causes MHD to reject HTTP 1.1 connections without a ‘Host’ header. This is required by the standard, but of course in violation of the "be as liberal as possible in what you accept" norm. It is recommended to turn this *ON* if you are testing clients against MHD, and *OFF* in production. ‘MHD_USE_POLL’ Use ‘poll()’ instead of ‘select()’. This allows sockets with descriptors ‘>= FD_SETSIZE’. This option currently only works in conjunction with ‘MHD_USE_INTERNAL_POLLING_THREAD’ (at this point). If you specify ‘MHD_USE_POLL’ and the local platform does not support it, ‘MHD_start_daemon’ will return NULL. ‘MHD_USE_EPOLL’ Use ‘epoll()’ instead of ‘poll()’ or ‘select()’. This allows sockets with descriptors ‘>= FD_SETSIZE’. This option is only available on some systems and does not work in conjunction with ‘MHD_USE_THREAD_PER_CONNECTION’ (at this point). If you specify ‘MHD_USE_EPOLL’ and the local platform does not support it, ‘MHD_start_daemon’ will return NULL. Using ‘epoll()’ instead of ‘select()’ or ‘poll()’ can in some situations result in significantly higher performance as the system call has fundamentally lower complexity (O(1) for ‘epoll()’ vs. O(n) for ‘select()’/‘poll()’ where n is the number of open connections). ‘MHD_USE_TURBO’ Enable optimizations to aggressively improve performance. Currently, the optimizations this option enables are based on opportunistic reads and writes. Basically, MHD will simply try to read or write or accept on a socket before checking that the socket is ready for IO using the event loop mechanism. As the sockets are non-blocking, this may fail (at a loss of performance), but generally MHD does this in situations where the operation is likely to succeed, in which case performance is improved. Setting the flag should generally be safe (even though the code is slightly more experimental). You may want to benchmark your application to see if this makes any difference for you. ‘MHD_USE_SUPPRESS_DATE_NO_CLOCK’ Suppress (automatically) adding the 'Date:' header to HTTP responses. This option should ONLY be used on systems that do not have a clock and that DO provide other mechanisms for cache control. See also RFC 2616, section 14.18 (exception 3). ‘MHD_USE_NO_LISTEN_SOCKET’ Run the HTTP server without any listen socket. This option only makes sense if ‘MHD_add_connection’ is going to be used exclusively to connect HTTP clients to the HTTP server. This option is incompatible with using a thread pool; if it is used, ‘MHD_OPTION_THREAD_POOL_SIZE’ is ignored. ‘MHD_USE_ITC’ Force MHD to use a signal inter-thread communication channel to notify the event loop (of threads) of our shutdown and other events. This is required if an application uses ‘MHD_USE_INTERNAL_POLLING_THREAD’ and then performs ‘MHD_quiesce_daemon’ (which eliminates our ability to signal termination via the listen socket). In these modes, ‘MHD_quiesce_daemon’ will fail if this option was not set. Also, use of this option is automatic (as in, you do not even have to specify it), if ‘MHD_USE_NO_LISTEN_SOCKET’ is specified. In "external" select mode, this option is always simply ignored. Using this option also guarantees that MHD will not call ‘shutdown()’ on the listen socket, which means a parent process can continue to use the socket. ‘MHD_ALLOW_SUSPEND_RESUME’ Enables using ‘MHD_suspend_connection’ and ‘MHD_resume_connection’, as performing these calls requires some additional inter-thred communication channels to be created, and code not using these calls should not pay the cost. ‘MHD_USE_TCP_FASTOPEN’ Enable TCP_FASTOPEN on the listen socket. TCP_FASTOPEN is currently supported on Linux >= 3.6. On other systems using this option with cause ‘MHD_start_daemon’ to fail. ‘MHD_ALLOW_UPGRADE’ This option must be set if you want to upgrade connections (via "101 Switching Protocols" responses). This requires MHD to allocate additional resources, and hence we require this special flag so we only use the resources that are really needed. ‘MHD_USE_AUTO’ Automatically select best event loop style (polling function) depending on requested mode by other MHD flags and functions available on platform. If application doesn't have requirements for any specific polling function, it's recommended to use this flag. This flag is very convenient for multiplatform applications. ‘MHD_USE_POST_HANDSHAKE_AUTH_SUPPORT’ Tell the TLS library to support post handshake client authentication. Only useful in combination with ‘MHD_USE_TLS’. This option will only work if the underlying TLS library supports it (i.e. GnuTLS after 3.6.3). If the TLS library does not support it, MHD may ignore the option and proceed without supporting this features. ‘MHD_USE_INSECURE_TLS_EARLY_DATA’ Tell the TLS library to support TLS v1.3 early data (0-RTT) with the resulting security drawbacks. Only enable this if you really know what you are doing. MHD currently does NOT enforce that this only affects GET requests! You have been warned. This option will only work if the underlying TLS library supports it (i.e. GnuTLS after 3.6.3). If the TLS library does not support it, MHD may ignore the option and proceed without supporting this features. -- Enumeration: MHD_OPTION MHD options. Passed in the varargs portion of ‘MHD_start_daemon()’. ‘MHD_OPTION_END’ No more options / last option. This is used to terminate the VARARGs list. ‘MHD_OPTION_CONNECTION_MEMORY_LIMIT’ Maximum memory size per connection (followed by a ‘size_t’). The default is 32 kB (32*1024 bytes) as defined by the internal constant ‘MHD_POOL_SIZE_DEFAULT’. Values above 128k are unlikely to result in much benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems. ‘MHD_OPTION_CONNECTION_MEMORY_INCREMENT’ Increment to use for growing the read buffer (followed by a ‘size_t’). The default is 1024 (bytes). Increasing this value will make MHD use memory for reading more aggressively, which can reduce the number of ‘recvfrom’ calls but may increase the number of ‘sendto’ calls. The given value must fit within MHD_OPTION_CONNECTION_MEMORY_LIMIT. ‘MHD_OPTION_CONNECTION_LIMIT’ Maximum number of concurrent connections to accept (followed by an ‘unsigned int’). The default is ‘FD_SETSIZE - 4’ (the maximum number of file descriptors supported by ‘select’ minus four for ‘stdin’, ‘stdout’, ‘stderr’ and the server socket). In other words, the default is as large as possible. If the connection limit is reached, MHD's behavior depends a bit on other options. If ‘MHD_USE_ITC’ was given, MHD will stop accepting connections on the listen socket. This will cause the operating system to queue connections (up to the ‘listen()’ limit) above the connection limit. Those connections will be held until MHD is done processing at least one of the active connections. If ‘MHD_USE_ITC’ is not set, then MHD will continue to ‘accept()’ and immediately ‘close()’ these connections. Note that if you set a low connection limit, you can easily get into trouble with browsers doing request pipelining. For example, if your connection limit is "1", a browser may open a first connection to access your "index.html" file, keep it open but use a second connection to retrieve CSS files, images and the like. In fact, modern browsers are typically by default configured for up to 15 parallel connections to a single server. If this happens, MHD will refuse to even accept the second connection until the first connection is closed -- which does not happen until timeout. As a result, the browser will fail to render the page and seem to hang. If you expect your server to operate close to the connection limit, you should first consider using a lower timeout value and also possibly add a "Connection: close" header to your response to ensure that request pipelining is not used and connections are closed immediately after the request has completed: MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "close"); ‘MHD_OPTION_CONNECTION_TIMEOUT’ After how many seconds of inactivity should a connection automatically be timed out? (followed by an ‘unsigned int’; use zero for no timeout). The default is zero (no timeout). ‘MHD_OPTION_NOTIFY_COMPLETED’ Register a function that should be called whenever a request has been completed (this can be used for application-specific clean up). Requests that have never been presented to the application (via ‘MHD_AccessHandlerCallback()’) will not result in notifications. This option should be followed by *TWO* pointers. First a pointer to a function of type ‘MHD_RequestCompletedCallback()’ and second a pointer to a closure to pass to the request completed callback. The second pointer maybe ‘NULL’. ‘MHD_OPTION_NOTIFY_CONNECTION’ Register a function that should be called when the TCP connection to a client is opened or closed. The registered callback is called twice per TCP connection, with ‘MHD_CONNECTION_NOTIFY_STARTED’ and ‘MHD_CONNECTION_NOTIFY_CLOSED’ respectively. An additional argument can be used to store TCP connection specific information, which can be retrieved using ‘MHD_CONNECTION_INFO_SOCKET_CONTEXT’ during the lifetime of the TCP connection. Note ‘MHD_OPTION_NOTIFY_COMPLETED’ and the ‘req_cls’ argument to the ‘MHD_AccessHandlerCallback’ are per HTTP request (and there can be multiple HTTP requests per TCP connection). This option should be followed by *TWO* pointers. First a pointer to a function of type ‘MHD_NotifyConnectionCallback()’ and second a pointer to a closure to pass to the request completed callback. The second pointer maybe ‘NULL’. ‘MHD_OPTION_PER_IP_CONNECTION_LIMIT’ Limit on the number of (concurrent) connections made to the server from the same IP address. Can be used to prevent one IP from taking over all of the allowed connections. If the same IP tries to establish more than the specified number of connections, they will be immediately rejected. The option should be followed by an ‘unsigned int’. The default is zero, which means no limit on the number of connections from the same IP address. ‘MHD_OPTION_LISTEN_BACKLOG_SIZE’ Set the size of the ‘listen()’ back log queue of the TCP socket. Takes an ‘unsigned int’ as the argument. Default is the platform-specific value of ‘SOMAXCONN’. ‘MHD_OPTION_STRICT_FOR_CLIENT’ Specify how strict we should enforce the HTTP protocol. Takes an ‘int’ as the argument. Default is zero. If set to 1, MHD will be strict about the protocol. Specifically, at the moment, this flag uses MHD to reject HTTP 1.1 connections without a "Host" header. This is required by the standard, but of course in violation of the "be as liberal as possible in what you accept" norm. It is recommended to set this to 1 if you are testing clients against MHD, and 0 in production. If set to -1 MHD will be permissive about the protocol, allowing slight deviations that are technically not allowed by the RFC. Specifically, at the moment, this flag causes MHD to allow spaces in header field names. This is disallowed by the standard. It is not recommended to set it to -1 on publicly available servers as it may potentially lower level of protection. ‘MHD_OPTION_SERVER_INSANITY’ Allows the application to disable certain sanity precautions in MHD. With these, the client can break the HTTP protocol, so this should never be used in production. The options are, however, useful for testing HTTP clients against "broken" server implementations. This argument must be followed by an ‘unsigned int’, corresponding to an ‘enum MHD_DisableSanityCheck’. Right now, no sanity checks can be disabled. ‘MHD_OPTION_SOCK_ADDR’ Bind daemon to the supplied socket address. This option should be followed by a ‘struct sockaddr *’. If ‘MHD_USE_IPv6’ is specified, the ‘struct sockaddr*’ should point to a ‘struct sockaddr_in6’, otherwise to a ‘struct sockaddr_in’. If this option is not specified, the daemon will listen to incoming connections from anywhere. If you use this option, the 'port' argument from ‘MHD_start_daemon’ is ignored and the port from the given ‘struct sockaddr *’ will be used instead. ‘MHD_OPTION_URI_LOG_CALLBACK’ Specify a function that should be called before parsing the URI from the client. The specified callback function can be used for processing the URI (including the options) before it is parsed. The URI after parsing will no longer contain the options, which maybe inconvenient for logging. This option should be followed by two arguments, the first one must be of the form void * my_logger(void * cls, const char * uri, struct MHD_Connection *con) where the return value will be passed as ‘*req_cls’ in calls to the ‘MHD_AccessHandlerCallback’ when this request is processed later; returning a value of ‘NULL’ has no special significance; (however, note that if you return non-‘NULL’, you can no longer rely on the first call to the access handler having ‘NULL == *req_cls’ on entry) ‘cls’ will be set to the second argument following MHD_OPTION_URI_LOG_CALLBACK. Finally, ‘uri’ will be the 0-terminated URI of the request. Note that during the time of this call, most of the connection's state is not initialized (as we have not yet parsed he headers). However, information about the connecting client (IP, socket) is available. ‘MHD_OPTION_HTTPS_MEM_KEY’ Memory pointer to the private key to be used by the HTTPS daemon. This option should be followed by an "const char*" argument. This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_CERT'. ‘MHD_OPTION_HTTPS_KEY_PASSWORD’ Memory pointer to the password that decrypts the private key to be used by the HTTPS daemon. This option should be followed by an "const char*" argument. This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_KEY'. The password (or passphrase) is only used immediately during ‘MHD_start_daemon()’. Thus, the application may want to erase it from memory afterwards for additional security. ‘MHD_OPTION_HTTPS_MEM_CERT’ Memory pointer to the certificate to be used by the HTTPS daemon. This option should be followed by an "const char*" argument. This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_KEY'. ‘MHD_OPTION_HTTPS_MEM_TRUST’ Memory pointer to the CA certificate to be used by the HTTPS daemon to authenticate and trust clients certificates. This option should be followed by an "const char*" argument. The presence of this option activates the request of certificate to the client. The request to the client is marked optional, and it is the responsibility of the server to check the presence of the certificate if needed. Note that most browsers will only present a client certificate only if they have one matching the specified CA, not sending any certificate otherwise. ‘MHD_OPTION_HTTPS_CRED_TYPE’ Daemon credentials type. Either certificate or anonymous, this option should be followed by one of the values listed in "enum gnutls_credentials_type_t". ‘MHD_OPTION_HTTPS_PRIORITIES’ SSL/TLS protocol version and ciphers. This option must be followed by an "const char *" argument specifying the SSL/TLS protocol versions and ciphers that are acceptable for the application. The string is passed unchanged to gnutls_priority_init. If this option is not specified, "NORMAL" is used. ‘MHD_OPTION_HTTPS_CERT_CALLBACK’ Use a callback to determine which X.509 certificate should be used for a given HTTPS connection. This option should be followed by a argument of type "gnutls_certificate_retrieve_function2 *". This option provides an alternative to MHD_OPTION_HTTPS_MEM_KEY and MHD_OPTION_HTTPS_MEM_CERT. You must use this version if multiple domains are to be hosted at the same IP address using TLS's Server Name Indication (SNI) extension. In this case, the callback is expected to select the correct certificate based on the SNI information provided. The callback is expected to access the SNI data using gnutls_server_name_get(). Using this option requires GnuTLS 3.0 or higher. ‘MHD_OPTION_HTTPS_CERT_CALLBACK2’ Use a callback to determine which X.509 certificate should be used for a given HTTPS connection. This option should be followed by a argument of type 'gnutls_certificate_retrieve_function3 *'. This option provides an alternative/extension to #MHD_OPTION_HTTPS_CERT_CALLBACK. You must use this version if you want to use OCSP stapling. Using this option requires GnuTLS 3.6.3 or higher. ‘MHD_OPTION_GNUTLS_PSK_CRED_HANDLER’ Use pre-shared key for TLS credentials. Pass a pointer to callback of type ‘MHD_PskServerCredentialsCallback’ and a closure. The function will be called to retrieve the shared key for a given username. ‘MHD_OPTION_DIGEST_AUTH_RANDOM’ Digest Authentication nonce's seed. This option should be followed by two arguments. First an integer of type "size_t" which specifies the size of the buffer pointed to by the second argument in bytes. Note that the application must ensure that the buffer of the second argument remains allocated and unmodified while the daemon is running. For security, you SHOULD provide a fresh random nonce when using MHD with Digest Authentication. ‘MHD_OPTION_NONCE_NC_SIZE’ Size of an array of nonce and nonce counter map. This option must be followed by an "unsigned int" argument that have the size (number of elements) of a map of a nonce and a nonce-counter. If this option is not specified, a default value of 4 will be used (which might be too small for servers handling many requests). If you do not use digest authentication at all, you can specify a value of zero to save some memory. You should calculate the value of NC_SIZE based on the number of connections per second multiplied by your expected session duration plus a factor of about two for hash table collisions. For example, if you expect 100 digest-authenticated connections per second and the average user to stay on your site for 5 minutes, then you likely need a value of about 60000. On the other hand, if you can only expect only 10 digest-authenticated connections per second, tolerate browsers getting a fresh nonce for each request and expect a HTTP request latency of 250 ms, then a value of about 5 should be fine. ‘MHD_OPTION_LISTEN_SOCKET’ Listen socket to use. Pass a listen socket for MHD to use (systemd-style). If this option is used, MHD will not open its own listen socket(s). The argument passed must be of type "int" and refer to an existing socket that has been bound to a port and is listening. ‘MHD_OPTION_EXTERNAL_LOGGER’ Use the given function for logging error messages. This option must be followed by two arguments; the first must be a pointer to a function of type 'void fun(void * arg, const char * fmt, va_list ap)' and the second a pointer of type 'void*' which will be passed as the "arg" argument to "fun". Note that MHD will not generate any log messages without the MHD_USE_ERROR_LOG flag set and if MHD was compiled with the "-disable-messages" flag. ‘MHD_OPTION_THREAD_POOL_SIZE’ Number (unsigned int) of threads in thread pool. Enable thread pooling by setting this value to to something greater than 1. Currently, thread mode must be MHD_USE_INTERNAL_POLLING_THREAD if thread pooling is enabled (‘MHD_start_daemon’ returns ‘NULL’ for an unsupported thread mode). ‘MHD_OPTION_ARRAY’ This option can be used for initializing MHD using options from an array. A common use for this is writing an FFI for MHD. The actual options given are in an array of 'struct MHD_OptionItem', so this option requires a single argument of type 'struct MHD_OptionItem'. The array must be terminated with an entry ‘MHD_OPTION_END’. An example for code using MHD_OPTION_ARRAY is: struct MHD_OptionItem ops[] = { { MHD_OPTION_CONNECTION_LIMIT, 100, NULL }, { MHD_OPTION_CONNECTION_TIMEOUT, 10, NULL }, { MHD_OPTION_END, 0, NULL } }; d = MHD_start_daemon(0, 8080, NULL, NULL, dh, NULL, MHD_OPTION_ARRAY, ops, MHD_OPTION_END); For options that expect a single pointer argument, the second member of the ‘struct MHD_OptionItem’ is ignored. For options that expect two pointer arguments, the first argument must be cast to ‘intptr_t’. ‘MHD_OPTION_UNESCAPE_CALLBACK’ Specify a function that should be called for unescaping escape sequences in URIs and URI arguments. Note that this function will NOT be used by the MHD_PostProcessor. If this option is not specified, the default method will be used which decodes escape sequences of the form "%HH". This option should be followed by two arguments, the first one must be of the form size_t my_unescaper(void * cls, struct MHD_Connection *c, char *s) where the return value must be ‘strlen(s)’ and ‘s’ should be updated. Note that the unescape function must not lengthen ‘s’ (the result must be shorter than the input and still be 0-terminated). ‘cls’ will be set to the second argument following MHD_OPTION_UNESCAPE_CALLBACK. ‘MHD_OPTION_THREAD_STACK_SIZE’ Maximum stack size for threads created by MHD. This option must be followed by a ‘size_t’). Not specifying this option or using a value of zero means using the system default (which is likely to differ based on your platform). ‘MHD_OPTION_TCP_FASTQUEUE_QUEUE_SIZE’ When the flag ‘MHD_USE_TCP_FASTOPEN’ is used, this option sets the connection handshake queue size for the TCP FASTOPEN connections. Note that a TCP FASTOPEN connection handshake occupies more resources than a TCP handshake as the SYN packets also contain DATA which is kept in the associate state until handshake is completed. If this option is not given the queue size is set to a default value of 10. This option must be followed by a ‘unsigned int’. ‘MHD_OPTION_HTTPS_MEM_DHPARAMS’ Memory pointer for the Diffie-Hellman parameters (dh.pem) to be used by the HTTPS daemon for key exchange. This option must be followed by a ‘const char *’ argument. The argument would be a zero-terminated string with a PEM encoded PKCS3 DH parameters structure suitable for passing to ‘gnutls_dh_parms_import_pkcs3’. ‘MHD_OPTION_LISTENING_ADDRESS_REUSE’ This option must be followed by a ‘unsigned int’ argument. If this option is present and true (nonzero) parameter is given, allow reusing the address:port of the listening socket (using ‘SO_REUSEPORT’ on most platforms, and ‘SO_REUSEADDR’ on Windows). If a false (zero) parameter is given, disallow reusing the the address:port of the listening socket (this usually requires no special action, but ‘SO_EXCLUSIVEADDRUSE’ is needed on Windows). If this option is not present ‘SO_REUSEADDR’ is used on all platforms except Windows so reusing of address:port is disallowed. -- C Struct: MHD_OptionItem Entry in an MHD_OPTION_ARRAY. See the ‘MHD_OPTION_ARRAY’ option argument for its use. The ‘option’ member is used to specify which option is specified in the array. The other members specify the respective argument. Note that for options taking only a single pointer, the ‘ptr_value’ member should be set. For options taking two pointer arguments, the first pointer must be cast to ‘intptr_t’ and both the ‘value’ and the ‘ptr_value’ members should be used to pass the two pointers. -- Enumeration: MHD_ValueKind The ‘MHD_ValueKind’ specifies the source of the key-value pairs in the HTTP protocol. ‘MHD_HEADER_KIND’ HTTP header. ‘MHD_COOKIE_KIND’ Cookies. Note that the original HTTP header containing the cookie(s) will still be available and intact. ‘MHD_POSTDATA_KIND’ ‘POST’ data. This is available only if a content encoding supported by MHD is used (currently only URL encoding), and only if the posted content fits within the available memory pool. Note that in that case, the upload data given to the ‘MHD_AccessHandlerCallback()’ will be empty (since it has already been processed). ‘MHD_GET_ARGUMENT_KIND’ ‘GET’ (URI) arguments. ‘MHD_FOOTER_KIND’ HTTP footer (only for http 1.1 chunked encodings). -- Enumeration: MHD_RequestTerminationCode The ‘MHD_RequestTerminationCode’ specifies reasons why a request has been terminated (or completed). ‘MHD_REQUEST_TERMINATED_COMPLETED_OK’ We finished sending the response. ‘MHD_REQUEST_TERMINATED_WITH_ERROR’ Error handling the connection (resources exhausted, other side closed connection, application error accepting request, etc.) ‘MHD_REQUEST_TERMINATED_TIMEOUT_REACHED’ No activity on the connection for the number of seconds specified using ‘MHD_OPTION_CONNECTION_TIMEOUT’. ‘MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN’ We had to close the session since MHD was being shut down. -- Enumeration: MHD_ResponseMemoryMode The ‘MHD_ResponeMemoryMode’ specifies how MHD should treat the memory buffer given for the response in ‘MHD_create_response_from_buffer’. ‘MHD_RESPMEM_PERSISTENT’ Buffer is a persistent (static/global) buffer that won't change for at least the lifetime of the response, MHD should just use it, not free it, not copy it, just keep an alias to it. ‘MHD_RESPMEM_MUST_FREE’ Buffer is heap-allocated with ‘malloc’ (or equivalent) and should be freed by MHD after processing the response has concluded (response reference counter reaches zero). ‘MHD_RESPMEM_MUST_COPY’ Buffer is in transient memory, but not on the heap (for example, on the stack or non-malloc allocated) and only valid during the call to ‘MHD_create_response_from_buffer’. MHD must make its own private copy of the data for processing. -- Enumeration: MHD_ResponseFlags Response-specific flags. Passed as an argument to ‘MHD_set_response_options()’. ‘MHD_RF_NONE’ No special handling. ‘MHD_RF_HTTP_VERSION_1_0_ONLY’ Only respond in conservative HTTP 1.0-mode. In particular, do not (automatically) sent "Connection" headers and always close the connection after generating the response. By default, MHD will respond using the same HTTP version which was set in the request. You can also set the ‘MHD_RF_HTTP_VERSION_1_0_RESPONSE’ flag to force version 1.0 in the response. ‘MHD_RF_HTTP_VERSION_1_0_RESPONSE’ Only respond in HTTP 1.0-mode. Contrary to the ‘MHD_RF_HTTP_VERSION_1_0_ONLY’ flag, the response's HTTP version will always be set to 1.0 and "Connection" headers are still supported. You can even combine this option with MHD_RF_HTTP_VERSION_1_0_ONLY to change the response's HTTP version while maintaining strict compliance with HTTP 1.0 regarding connection management. This solution is not perfect as this flag is set on the response which is created after header processing. So MHD will behave as a HTTP 1.1 server until the response is queued. It means that an invalid HTTP 1.1 request will fail even if the response is sent with HTTP 1.0 and the request would be valid if interpreted with this version. For example, this request will fail in strict mode: GET / HTTP/1.1 as the "Host" header is missing and is mandatory in HTTP 1.1, but it should succeed when interpreted with HTTP 1.0. ‘MHD_RF_INSANITY_HEADER_CONTENT_LENGTH’ Disable sanity check preventing clients from manually setting the HTTP content length option. -- Enumeration: MHD_ResponseOptions Response-specific options. Passed in the varargs portion of ‘MHD_set_response_options()’. ‘MHD_RO_END’ No more options / last option. This is used to terminate the VARARGs list. -- Enumeration: MHD_WEBSOCKET_FLAG Options for the MHD websocket stream. This is used for initialization of a websocket stream when calling ‘MHD_websocket_stream_init’ or ‘MHD_websocket_stream_init2’ and alters the behavior of the websocket stream. Note that websocket streams are only available if you include the header file ‘microhttpd_ws.h’ and compiled _libmicrohttpd_ with websockets. ‘MHD_WEBSOCKET_FLAG_SERVER’ The websocket stream is initialized in server mode (default). Thus all outgoing payload will not be masked. All incoming payload must be masked. This flag cannot be used together with ‘MHD_WEBSOCKET_FLAG_CLIENT’. ‘MHD_WEBSOCKET_FLAG_CLIENT’ The websocket stream is initialized in client mode. You will usually never use that mode in combination with _libmicrohttpd_, because _libmicrohttpd_ provides a server and not a client. In client mode all outgoing payload will be masked (XOR-ed with random values). All incoming payload must be unmasked. If you use this mode, you must always call ‘MHD_websocket_stream_init2’ instead of ‘MHD_websocket_stream_init’, because you need to pass a random number generator callback function for masking. This flag cannot be used together with ‘MHD_WEBSOCKET_FLAG_SERVER’. ‘MHD_WEBSOCKET_FLAG_NO_FRAGMENTS’ You don't want to get fragmented data while decoding (default). Fragmented frames will be internally put together until they are complete. Whether or not data is fragmented is decided by the sender of the data during encoding. This cannot be used together with ‘MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS’. ‘MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS’ You want fragmented data, if it appears while decoding. You will receive the content of the fragmented frame, but if you are decoding text, you will never get an unfinished UTF-8 sequence (if the sequence appears between two fragments). Instead the text will end before the unfinished UTF-8 sequence. With the next fragment, which finishes the UTF-8 sequence, you will get the complete UTF-8 sequence. This cannot be used together with ‘MHD_WEBSOCKET_FLAG_NO_FRAGMENTS’. ‘MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR’ If the websocket stream becomes invalid during decoding due to protocol errors, a matching close frame will automatically be generated. The close frame will be returned via the parameters ‘payload’ and ‘payload_len’ of ‘MHD_websocket_decode’ and the return value is negative (a value of ‘enum MHD_WEBSOCKET_STATUS’). The generated close frame must be freed by the caller with ‘MHD_websocket_free’. -- Enumeration: MHD_WEBSOCKET_FRAGMENTATION This enumeration is used to specify the fragmentation behavior when encoding of data (text/binary) for a websocket stream. This is used with ‘MHD_websocket_encode_text’ or ‘MHD_websocket_encode_binary’. Note that websocket streams are only available if you include the header file ‘microhttpd_ws.h’ and compiled _libmicrohttpd_ with websockets. ‘MHD_WEBSOCKET_FRAGMENTATION_NONE’ You don't want to use fragmentation. The encoded frame consists of only one frame. ‘MHD_WEBSOCKET_FRAGMENTATION_FIRST’ You want to use fragmentation. The encoded frame is the first frame of a series of data frames of the same type (text or binary). You may send control frames (ping, pong or close) between these data frames. ‘MHD_WEBSOCKET_FRAGMENTATION_FOLLOWING’ You want to use fragmentation. The encoded frame is not the first frame of the series of data frames, but also not the last one. You may send control frames (ping, pong or close) between these data frames. ‘MHD_WEBSOCKET_FRAGMENTATION_LAST’ You want to use fragmentation. The encoded frame is the last frame of the series of data frames, but also not the first one. After this frame, you may send all types of frames again. -- Enumeration: MHD_WEBSOCKET_STATUS This enumeration is used for the return value of almost every websocket stream function. Errors are negative and values equal to or above zero mean a success. Positive values are only used by ‘MHD_websocket_decode’. Note that websocket streams are only available if you include the header file ‘microhttpd_ws.h’ and compiled _libmicrohttpd_ with websockets. ‘MHD_WEBSOCKET_STATUS_OK’ The call succeeded. Especially for ‘MHD_websocket_decode’ this means that no error occurred, but also no frame has been completed yet. For other functions this means simply a success. ‘MHD_WEBSOCKET_STATUS_TEXT_FRAME’ ‘MHD_websocket_decode’ has decoded a text frame. The parameters ‘payload’ and ‘payload_len’ are filled with the decoded text (if any). You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_BINARY_FRAME’ ‘MHD_websocket_decode’ has decoded a binary frame. The parameters ‘payload’ and ‘payload_len’ are filled with the decoded binary data (if any). You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_CLOSE_FRAME’ ‘MHD_websocket_decode’ has decoded a close frame. This means you must close the socket using ‘MHD_upgrade_action’ with ‘MHD_UPGRADE_ACTION_CLOSE’. You may respond with a close frame before closing. The parameters ‘payload’ and ‘payload_len’ are filled with the close reason (if any). The close reason starts with a two byte sequence of close code in network byte order (see ‘enum MHD_WEBSOCKET_CLOSEREASON’). After these two bytes a UTF-8 encoded close reason may follow. You can call ‘MHD_websocket_split_close_reason’ to split that close reason. You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_PING_FRAME’ ‘MHD_websocket_decode’ has decoded a ping frame. You should respond to this with a pong frame. The pong frame must contain the same binary data as the corresponding ping frame (if it had any). The parameters ‘payload’ and ‘payload_len’ are filled with the binary ping data (if any). You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_PONG_FRAME’ ‘MHD_websocket_decode’ has decoded a pong frame. You should usually only receive pong frames if you sent a ping frame before. The binary data should be equal to your ping frame and can be used to distinguish the response if you sent multiple ping frames. The parameters ‘payload’ and ‘payload_len’ are filled with the binary pong data (if any). You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT’ ‘MHD_websocket_decode’ has decoded a text frame fragment. The parameters ‘payload’ and ‘payload_len’ are filled with the decoded text (if any). This is like ‘MHD_WEBSOCKET_STATUS_TEXT_FRAME’, but it can only appear if you specified ‘MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS’ during the call of ‘MHD_websocket_stream_init’ or ‘MHD_websocket_stream_init2’. You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT’ ‘MHD_websocket_decode’ has decoded a binary frame fragment. The parameters ‘payload’ and ‘payload_len’ are filled with the decoded binary data (if any). This is like ‘MHD_WEBSOCKET_STATUS_BINARY_FRAME’, but it can only appear if you specified ‘MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS’ during the call of ‘MHD_websocket_stream_init’ or ‘MHD_websocket_stream_init2’. You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_TEXT_NEXT_FRAGMENT’ ‘MHD_websocket_decode’ has decoded the next text frame fragment. The parameters ‘payload’ and ‘payload_len’ are filled with the decoded text (if any). This is like ‘MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT’, but it appears only after the first and before the last fragment of a series of fragments. It can only appear if you specified ‘MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS’ during the call of ‘MHD_websocket_stream_init’ or ‘MHD_websocket_stream_init2’. You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_BINARY_NEXT_FRAGMENT’ ‘MHD_websocket_decode’ has decoded the next binary frame fragment. The parameters ‘payload’ and ‘payload_len’ are filled with the decoded binary data (if any). This is like ‘MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT’, but it appears only after the first and before the last fragment of a series of fragments. It can only appear if you specified ‘MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS’ during the call of ‘MHD_websocket_stream_init’ or ‘MHD_websocket_stream_init2’. You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT’ ‘MHD_websocket_decode’ has decoded the last text frame fragment. The parameters ‘payload’ and ‘payload_len’ are filled with the decoded text (if any). This is like ‘MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT’, but it appears only for the last fragment of a series of fragments. It can only appear if you specified ‘MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS’ during the call of ‘MHD_websocket_stream_init’ or ‘MHD_websocket_stream_init2’. You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_BINARY_LAST_FRAGMENT’ ‘MHD_websocket_decode’ has decoded the last binary frame fragment. The parameters ‘payload’ and ‘payload_len’ are filled with the decoded binary data (if any). This is like ‘MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT’, but it appears only for the last fragment of a series of fragments. It can only appear if you specified ‘MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS’ during the call of ‘MHD_websocket_stream_init’ or ‘MHD_websocket_stream_init2’. You must free the returned ‘payload’ after use with ‘MHD_websocket_free’. ‘MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR’ The call failed and the stream is invalid now for decoding. You must close the websocket now using ‘MHD_upgrade_action’ with ‘MHD_UPGRADE_ACTION_CLOSE’. You may send a close frame before closing. This is only used by ‘MHD_websocket_decode’ and happens if the stream contains errors (i. e. invalid byte data). ‘MHD_WEBSOCKET_STATUS_STREAM_BROKEN’ You tried to decode something, but the stream has already been marked invalid. You must close the websocket now using ‘MHD_upgrade_action’ with ‘MHD_UPGRADE_ACTION_CLOSE’. You may send a close frame before closing. This is only used by ‘MHD_websocket_decode’ and happens if you call ‘MDM_websocket_decode’ again after has been invalidated. You can call ‘MHD_websocket_stream_is_valid’ at any time to check whether a stream is invalid or not. ‘MHD_WEBSOCKET_STATUS_MEMORY_ERROR’ A memory allocation failed. The stream remains valid. If this occurred while decoding, the decoding could be possible later if enough memory is available. This could happen while decoding if you received a too big data frame. You could try to specify max_payload_size during the call of ‘MHD_websocket_stream_init’ or ‘MHD_websocket_stream_init2’ to avoid this and close the websocket instead. ‘MHD_WEBSOCKET_STATUS_PARAMETER_ERROR’ You passed invalid parameters during the function call (i. e. a NULL pointer for a required parameter). The stream remains valid. ‘MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED’ The maximum payload size has been exceeded. If you got this return code from ‘MHD_websocket_decode’ then the stream becomes invalid and the websocket must be closed using ‘MHD_upgrade_action’ with ‘MHD_UPGRADE_ACTION_CLOSE’. You may send a close frame before closing. The maximum payload size is specified during the call of ‘MHD_websocket_stream_init’ or ‘MHD_websocket_stream_init2’. This can also appear if you specified 0 as maximum payload size when the message is greater than the maximum allocatable memory size (i. e. more than 4 GiB on 32 bit systems). If you got this return code from ‘MHD_websocket_encode_close’, ‘MHD_websocket_encode_ping’ or ‘MHD_websocket_encode_pong’ then you passed to much payload data. The stream remains valid then. ‘MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR’ An UTF-8 sequence is invalid. If you got this return code from ‘MHD_websocket_decode’ then the stream becomes invalid and you must close the websocket using ‘MHD_upgrade_action’ with ‘MHD_UPGRADE_ACTION_CLOSE’. You may send a close frame before closing. If you got this from ‘MHD_websocket_encode_text’ or ‘MHD_websocket_encode_close’ then you passed invalid UTF-8 text. The stream remains valid then. ‘MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER’ A check routine for the HTTP headers came to the conclusion that the header value isn't valid for a websocket handshake request. This value can only be returned from the following functions: ‘MHD_websocket_check_http_version’, ‘MHD_websocket_check_connection_header’, ‘MHD_websocket_check_upgrade_header’, ‘MHD_websocket_check_version_header’, ‘MHD_websocket_create_accept_header’ -- Enumeration: MHD_WEBSOCKET_CLOSEREASON Enumeration of possible close reasons for websocket close frames. The possible values are specified in RFC 6455 7.4.1 These close reasons here are the default set specified by RFC 6455, but also other close reasons could be used. The definition is for short: • 0-999 are never used (if you pass 0 in ‘MHD_websocket_encode_close’ then no close reason is used). • 1000-2999 are specified by RFC 6455. • 3000-3999 are specified by libraries, etc. but must be registered by IANA. • 4000-4999 are reserved for private use. Note that websocket streams are only available if you include the header file ‘microhttpd_ws.h’ and compiled _libmicrohttpd_ with websockets. ‘MHD_WEBSOCKET_CLOSEREASON_NO_REASON’ This value is used as placeholder for ‘MHD_websocket_encode_close’ to tell that you don't want to specify any reason. If you use this value then no reason text may be used. This value cannot be a result of decoding, because this value is not a valid close reason for the websocket protocol. ‘MHD_WEBSOCKET_CLOSEREASON_REGULAR’ You close the websocket because it fulfilled its purpose and shall now be closed in a normal, planned way. ‘MHD_WEBSOCKET_CLOSEREASON_GOING_AWAY’ You close the websocket because you are shutting down the server or something similar. ‘MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR’ You close the websocket because a protocol error occurred during decoding (i. e. invalid byte data). ‘MHD_WEBSOCKET_CLOSEREASON_UNSUPPORTED_DATATYPE’ You close the websocket because you received data which you don't accept. For example if you received a binary frame, but your application only expects text frames. ‘MHD_WEBSOCKET_CLOSEREASON_MALFORMED_UTF8’ You close the websocket because it contains malformed UTF-8. The UTF-8 validity is automatically checked by ‘MHD_websocket_decode’, so you don't need to check it on your own. UTF-8 is specified in RFC 3629. ‘MHD_WEBSOCKET_CLOSEREASON_POLICY_VIOLATED’ You close the websocket because you received a frame which is too big to process. You can specify the maximum allowed payload size during the call of ‘MHD_websocket_stream_init’ or ‘MHD_websocket_stream_init2’. ‘MHD_WEBSOCKET_CLOSEREASON_MISSING_EXTENSION’ This status code can be sent by the client if it expected a specific extension, but this extension hasn't been negotiated. ‘MHD_WEBSOCKET_CLOSEREASON_UNEXPECTED_CONDITION’ The server closes the websocket because it encountered an unexpected condition that prevented it from fulfilling the request. -- Enumeration: MHD_WEBSOCKET_UTF8STEP Enumeration of possible UTF-8 check steps for websocket functions These values are used during the encoding of fragmented text frames or for error analysis while encoding text frames. Its values specify the next step of the UTF-8 check. UTF-8 sequences consist of one to four bytes. This enumeration just says how long the current UTF-8 sequence is and what is the next expected byte. Note that websocket streams are only available if you include the header file ‘microhttpd_ws.h’ and compiled _libmicrohttpd_ with websockets. ‘MHD_WEBSOCKET_UTF8STEP_NORMAL’ There is no open UTF-8 sequence. The next byte must be 0x00-0x7F or 0xC2-0xF4. ‘MHD_WEBSOCKET_UTF8STEP_UTF2TAIL_1OF1’ The second byte of a two byte UTF-8 sequence. The first byte was 0xC2-0xDF. The next byte must be 0x80-0xBF. ‘MHD_WEBSOCKET_UTF8STEP_UTF3TAIL1_1OF2’ The second byte of a three byte UTF-8 sequence. The first byte was 0xE0. The next byte must be 0xA0-0xBF. ‘MHD_WEBSOCKET_UTF8STEP_UTF3TAIL2_1OF2’ The second byte of a three byte UTF-8 sequence. The first byte was 0xED. The next byte must by 0x80-0x9F. ‘MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_1OF2’ The second byte of a three byte UTF-8 sequence. The first byte was 0xE1-0xEC or 0xEE-0xEF. The next byte must be 0x80-0xBF. ‘MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_2OF2’ The third byte of a three byte UTF-8 sequence. The next byte must be 0x80-0xBF. ‘MHD_WEBSOCKET_UTF8STEP_UTF4TAIL1_1OF3’ The second byte of a four byte UTF-8 sequence. The first byte was 0xF0. The next byte must be 0x90-0xBF. ‘MHD_WEBSOCKET_UTF8STEP_UTF4TAIL2_1OF3’ The second byte of a four byte UTF-8 sequence. The first byte was 0xF4. The next byte must be 0x80-0x8F. ‘MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_1OF3’ The second byte of a four byte UTF-8 sequence. The first byte was 0xF1-0xF3. The next byte must be 0x80-0xBF. ‘MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_2OF3’ The third byte of a four byte UTF-8 sequence. The next byte must be 0x80-0xBF. ‘MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_3OF3’ The fourth byte of a four byte UTF-8 sequence. The next byte must be 0x80-0xBF. -- Enumeration: MHD_WEBSOCKET_VALIDITY Enumeration of validity values of a websocket stream These values are used for ‘MHD_websocket_stream_is_valid’ and specify the validity status. Note that websocket streams are only available if you include the header file ‘microhttpd_ws.h’ and compiled _libmicrohttpd_ with websockets. ‘MHD_WEBSOCKET_VALIDITY_INVALID’ The stream is invalid. It cannot be used for decoding anymore. ‘MHD_WEBSOCKET_VALIDITY_VALID’ The stream is valid. Decoding works as expected. ‘MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES’ The stream has received a close frame and is partly invalid. You can still use the stream for decoding, but if a data frame is received an error will be reported. After a close frame has been sent, no data frames may follow from the sender of the close frame.  File: libmicrohttpd.info, Node: microhttpd-struct, Next: microhttpd-cb, Prev: microhttpd-const, Up: Top 3 Structures type definition **************************** -- C Struct: MHD_Daemon Handle for the daemon (listening on a socket for HTTP traffic). -- C Struct: MHD_Connection Handle for a connection / HTTP request. With HTTP/1.1, multiple requests can be run over the same connection. However, MHD will only show one request per TCP connection to the client at any given time. -- C Struct: MHD_Response Handle for a response. -- C Struct: MHD_IoVec An element of an array of memory buffers. -- C Struct: MHD_PostProcessor Handle for ‘POST’ processing. -- C Union: MHD_ConnectionInfo Information about a connection. -- C Union: MHD_DaemonInfo Information about an MHD daemon. -- C Struct: MHD_WebSocketStream Information about a MHD websocket stream.  File: libmicrohttpd.info, Node: microhttpd-cb, Next: microhttpd-init, Prev: microhttpd-struct, Up: Top 4 Callback functions definition ******************************* -- Function Pointer: enum MHD_Result *MHD_AcceptPolicyCallback (void *cls, const struct sockaddr * addr, socklen_t addrlen) Invoked in the context of a connection to allow or deny a client to connect. This callback return ‘MHD_YES’ if connection is allowed, ‘MHD_NO’ if not. CLS custom value selected at callback registration time; ADDR address information from the client; ADDRLEN length of the address information. -- Function Pointer: enum MHD_Result *MHD_AccessHandlerCallback (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) Invoked in the context of a connection to answer a request from the client. This callback must call MHD functions (example: the ‘MHD_Response’ ones) to provide content to give back to the client and return an HTTP status code (i.e. ‘200’ for OK, ‘404’, etc.). *note microhttpd-post::, for details on how to code this callback. Must return ‘MHD_YES’ if the connection was handled successfully, ‘MHD_NO’ if the socket must be closed due to a serious error while handling the request CLS custom value selected at callback registration time; URL the URL requested by the client; METHOD the HTTP method used by the client (‘GET’, ‘PUT’, ‘DELETE’, ‘POST’, etc.); VERSION the HTTP version string (i.e. ‘HTTP/1.1’); UPLOAD_DATA the data being uploaded (excluding headers): ‘POST’ data *will* be made available incrementally in UPLOAD_DATA; even if ‘POST’ data is available, the first time the callback is invoked there won't be upload data, as this is done just after MHD parses the headers. If supported by the client and the HTTP version, the application can at this point queue an error response to possibly avoid the upload entirely. If no response is generated, MHD will (if required) automatically send a 100 CONTINUE reply to the client. Afterwards, POST data will be passed to the callback to be processed incrementally by the application. The application may return ‘MHD_NO’ to forcefully terminate the TCP connection without generating a proper HTTP response. Once all of the upload data has been provided to the application, the application will be called again with 0 bytes of upload data. At this point, a response should be queued to complete the handling of the request. UPLOAD_DATA_SIZE set initially to the size of the UPLOAD_DATA provided; this callback must update this value to the number of bytes *NOT* processed; unless external select is used, the callback maybe required to process at least some data. If the callback fails to process data in multi-threaded or internal-select mode and if the read-buffer is already at the maximum size that MHD is willing to use for reading (about half of the maximum amount of memory allowed for the connection), then MHD will abort handling the connection and return an internal server error to the client. In order to avoid this, clients must be able to process upload data incrementally and reduce the value of ‘upload_data_size’. REQ_CLS reference to a pointer, initially set to ‘NULL’, that this callback can set to some address and that will be preserved by MHD for future calls for this request; since the access handler may be called many times (i.e., for a ‘PUT’/‘POST’ operation with plenty of upload data) this allows the application to easily associate some request-specific state; if necessary, this state can be cleaned up in the global ‘MHD_RequestCompletedCallback’ (which can be set with the ‘MHD_OPTION_NOTIFY_COMPLETED’). -- Function Pointer: void *MHD_RequestCompletedCallback (void *cls, struct MHD_Connectionconnection, void **req_cls, enum MHD_RequestTerminationCode toe) Signature of the callback used by MHD to notify the application about completed requests. CLS custom value selected at callback registration time; CONNECTION connection handle; REQ_CLS value as set by the last call to the ‘MHD_AccessHandlerCallback’; TOE reason for request termination see ‘MHD_OPTION_NOTIFY_COMPLETED’. -- Function Pointer: enum MHD_Result *MHD_KeyValueIterator (void *cls, enum MHD_ValueKind kind, const char *key, const char *value, size_t value_size) Iterator over key-value pairs. This iterator can be used to iterate over all of the cookies, headers, or ‘POST’-data fields of a request, and also to iterate over the headers that have been added to a response. CLS custom value specified when iteration was triggered; KIND kind of the header we are looking at KEY key for the value, can be an empty string VALUE value corresponding value, can be NULL VALUE_SIZE number of bytes in ‘value’. This argument was introduced in ‘MHD_VERSION’ 0x00096301 to allow applications to use binary zeros in values. Applications using this argument must ensure that they are using a sufficiently recent version of MHD, i.e. by testing ‘MHD_get_version()’ for values above or equal to 0.9.64. Applications that do not need zeros in values and that want to compile without warnings against newer versions of MHD should not declare this argument and cast the function pointer argument to ‘MHD_KeyValueIterator’. Return ‘MHD_YES’ to continue iterating, ‘MHD_NO’ to abort the iteration. -- Function Pointer: ssize_t *MHD_ContentReaderCallback (void *cls, uint64_t pos, char *buf, size_t max) Callback used by MHD in order to obtain content. The callback has to copy at most MAX bytes of content into BUF. The total number of bytes that has been placed into BUF should be returned. Note that returning zero will cause MHD to try again. Thus, returning zero should only be used in conjunction with ‘MHD_suspend_connection()’ to avoid busy waiting. While usually the callback simply returns the number of bytes written into BUF, there are two special return value: ‘MHD_CONTENT_READER_END_OF_STREAM’ (-1) should be returned for the regular end of transmission (with chunked encoding, MHD will then terminate the chunk and send any HTTP footers that might be present; without chunked encoding and given an unknown response size, MHD will simply close the connection; note that while returning ‘MHD_CONTENT_READER_END_OF_STREAM’ is not technically legal if a response size was specified, MHD accepts this and treats it just as ‘MHD_CONTENT_READER_END_WITH_ERROR’. ‘MHD_CONTENT_READER_END_WITH_ERROR’ (-2) is used to indicate a server error generating the response; this will cause MHD to simply close the connection immediately. If a response size was given or if chunked encoding is in use, this will indicate an error to the client. Note, however, that if the client does not know a response size and chunked encoding is not in use, then clients will not be able to tell the difference between ‘MHD_CONTENT_READER_END_WITH_ERROR’ and ‘MHD_CONTENT_READER_END_OF_STREAM’. This is not a limitation of MHD but rather of the HTTP protocol. CLS custom value selected at callback registration time; POS position in the datastream to access; note that if an ‘MHD_Response’ object is re-used, it is possible for the same content reader to be queried multiple times for the same data; however, if an ‘MHD_Response’ is not re-used, MHD guarantees that POS will be the sum of all non-negative return values obtained from the content reader so far. Return ‘-1’ on error (MHD will no longer try to read content and instead close the connection with the client). -- Function Pointer: void *MHD_ContentReaderFreeCallback (void *cls) This method is called by MHD if we are done with a content reader. It should be used to free resources associated with the content reader. -- Function Pointer: enum MHD_Result *MHD_PostDataIterator (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) Iterator over key-value pairs where the value maybe made available in increments and/or may not be zero-terminated. Used for processing ‘POST’ data. CLS custom value selected at callback registration time; KIND type of the value; KEY zero-terminated key for the value; FILENAME name of the uploaded file, ‘NULL’ if not known; CONTENT_TYPE mime-type of the data, ‘NULL’ if not known; TRANSFER_ENCODING encoding of the data, ‘NULL’ if not known; DATA pointer to size bytes of data at the specified offset; OFF offset of data in the overall value; SIZE number of bytes in data available. Return ‘MHD_YES’ to continue iterating, ‘MHD_NO’ to abort the iteration. -- Function Pointer: void* *MHD_WebSocketMallocCallback (size_t buf_len) This callback function is used internally by many websocket functions for allocating data. By default ‘malloc’ is used. You can use your own allocation function with ‘MHD_websocket_stream_init2’ if you wish to. This can be useful for operating systems like Windows where ‘malloc’, ‘realloc’ and ‘free’ are compiler-dependent. You can call the associated ‘malloc’ callback of a websocket stream with ‘MHD_websocket_malloc’. BUF_LEN size of the buffer to allocate in bytes. Return the pointer of the allocated buffer or ‘NULL’ on failure. -- Function Pointer: void* *MHD_WebSocketReallocCallback (void *buf, size_t new_buf_len) This callback function is used internally by many websocket functions for reallocating data. By default ‘realloc’ is used. You can use your own reallocation function with ‘MHD_websocket_stream_init2’ if you wish to. This can be useful for operating systems like Windows where ‘malloc’, ‘realloc’ and ‘free’ are compiler-dependent. You can call the associated ‘realloc’ callback of a websocket stream with ‘MHD_websocket_realloc’. BUF current buffer, may be ‘NULL’; NEW_BUF_LEN new size of the buffer in bytes. Return the pointer of the reallocated buffer or ‘NULL’ on failure. On failure the old pointer must remain valid. -- Function Pointer: void *MHD_WebSocketFreeCallback (void *buf) This callback function is used internally by many websocket functions for freeing data. By default ‘free’ is used. You can use your own free function with ‘MHD_websocket_stream_init2’ if you wish to. This can be useful for operating systems like Windows where ‘malloc’, ‘realloc’ and ‘free’ are compiler-dependent. You can call the associated ‘free’ callback of a websocket stream with ‘MHD_websocket_free’. CLS current buffer to free, this may be ‘NULL’ then nothing happens. -- Function Pointer: size_t *MHD_WebSocketRandomNumberGenerator (void *cls, void* buf, size_t buf_len) This callback function is used for generating random numbers for masking payload data in client mode. If you use websockets in server mode with _libmicrohttpd_ then you don't need a random number generator, because the server doesn't mask its outgoing messages. However if you wish to use a websocket stream in client mode, you must pass this callback function to ‘MHD_websocket_stream_init2’. CLS closure specified in ‘MHD_websocket_stream_init2’; BUF buffer to fill with random values; BUF_LEN size of buffer in bytes. Return the number of generated random bytes. The return value should usually equal to buf_len.  File: libmicrohttpd.info, Node: microhttpd-init, Next: microhttpd-inspect, Prev: microhttpd-cb, Up: Top 5 Starting and stopping the server ********************************** -- Function: void MHD_set_panic_func (MHD_PanicCallback cb, void *cls) Set a handler for fatal errors. CB function to call if MHD encounters a fatal internal error. If no handler was set explicitly, MHD will call ‘abort’. CLS closure argument for cb; the other arguments are the name of the source file, line number and a string describing the nature of the fatal error (which can be ‘NULL’) -- Function: struct MHD_Daemon * MHD_start_daemon (unsigned int flags, unsigned short port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, ...) Start a webserver on the given port. FLAGS OR-ed combination of ‘MHD_FLAG’ values; PORT port to bind to; APC callback to call to check which clients will be allowed to connect; you can pass ‘NULL’ in which case connections from any IP will be accepted; APC_CLS extra argument to APC; DH default handler for all URIs; DH_CLS extra argument to DH. Additional arguments are a list of options (type-value pairs, terminated with ‘MHD_OPTION_END’). It is mandatory to use ‘MHD_OPTION_END’ as last argument, even when there are no additional arguments. Return ‘NULL’ on error, handle to daemon on success. -- Function: MHD_socket MHD_quiesce_daemon (struct MHD_Daemon *daemon) Stop accepting connections from the listening socket. Allows clients to continue processing, but stops accepting new connections. Note that the caller is responsible for closing the returned socket; however, if MHD is run using threads (anything but external select mode), it must not be closed until AFTER ‘MHD_stop_daemon’ has been called (as it is theoretically possible that an existing thread is still using it). This function is useful in the special case that a listen socket is to be migrated to another process (i.e. a newer version of the HTTP server) while existing connections should continue to be processed until they are finished. Return ‘-1’ on error (daemon not listening), the handle to the listen socket otherwise. -- Function: void MHD_stop_daemon (struct MHD_Daemon *daemon) Shutdown an HTTP daemon. -- Function: enum MHD_Result MHD_run (struct MHD_Daemon *daemon) Run webserver operations (without blocking unless in client callbacks). This method should be called by clients in combination with ‘MHD_get_fdset()’ if the client-controlled ‘select’-method is used. This function will work for external ‘poll’ and ‘select’ mode. However, if using external ‘select’ mode, you may want to instead use ‘MHD_run_from_select’, as it is more efficient. DAEMON daemon to process connections of Return ‘MHD_YES’ on success, ‘MHD_NO’ if this daemon was not started with the right options for this call. -- Function: enum MHD_Result MHD_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set) Run webserver operations given sets of ready socket handles. This method should be called by clients in combination with ‘MHD_get_fdset’ if the client-controlled (external) select method is used. You can use this function instead of ‘MHD_run’ if you called ‘select’ on the result from ‘MHD_get_fdset’. File descriptors in the sets that are not controlled by MHD will be ignored. Calling this function instead of ‘MHD_run’ is more efficient as MHD will not have to call ‘select’ again to determine which operations are ready. DAEMON daemon to process connections of READ_FD_SET set of descriptors that must be ready for reading without blocking WRITE_FD_SET set of descriptors that must be ready for writing without blocking EXCEPT_FD_SET ignored, can be NULL Return ‘MHD_YES’ on success, ‘MHD_NO’ on serious internal errors. -- Function: void MHD_add_connection (struct MHD_Daemon *daemon, int client_socket, const struct sockaddr *addr, socklen_t addrlen) Add another client connection to the set of connections managed by MHD. This API is usually not needed (since MHD will accept inbound connections on the server socket). Use this API in special cases, for example if your HTTP server is behind NAT and needs to connect out to the HTTP client, or if you are building a proxy. If you use this API in conjunction with a internal select or a thread pool, you must set the option ‘MHD_USE_ITC’ to ensure that the freshly added connection is immediately processed by MHD. The given client socket will be managed (and closed!) by MHD after this call and must no longer be used directly by the application afterwards. DAEMON daemon that manages the connection CLIENT_SOCKET socket to manage (MHD will expect to receive an HTTP request from this socket next). ADDR IP address of the client ADDRLEN number of bytes in addr This function will return ‘MHD_YES’ on success, ‘MHD_NO’ if this daemon could not handle the connection (i.e. malloc failed, etc). The socket will be closed in any case; 'errno' is set to indicate further details about the error.  File: libmicrohttpd.info, Node: microhttpd-inspect, Next: microhttpd-requests, Prev: microhttpd-init, Up: Top 6 Implementing external ‘select’ ******************************** -- Function: enum MHD_Result MHD_get_fdset (struct MHD_Daemon *daemon, fd_set * read_fd_set, fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd) Obtain the ‘select()’ sets for this daemon. The daemon's socket is added to READ_FD_SET. The list of currently existent connections is scanned and their file descriptors added to the correct set. When calling this function, FD_SETSIZE is assumed to be platform's default. If you changed FD_SETSIZE for your application, you should use ‘MHD_get_fdset2()’ instead. This function should only be called in when MHD is configured to use external select with ‘select()’ or with ‘epoll()’. In the latter case, it will only add the single ‘epoll()’ file descriptor used by MHD to the sets. After the call completed successfully: the variable referenced by MAX_FD references the file descriptor with highest integer identifier. The variable must be set to zero before invoking this function. Return ‘MHD_YES’ on success, ‘MHD_NO’ if: the arguments are invalid (example: ‘NULL’ pointers); this daemon was not started with the right options for this call. -- Function: enum MHD_Result MHD_get_fdset2 (struct MHD_Daemon *daemon, fd_set * read_fd_set, fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd, unsigned int fd_setsize) Like ‘MHD_get_fdset()’, except that you can manually specify the value of FD_SETSIZE used by your application. -- Function: enum MHD_Result MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout) Obtain timeout value for select for this daemon (only needed if connection timeout is used). The returned value is how many milliseconds ‘select’ should at most block, not the timeout value set for connections. This function must not be called if the ‘MHD_USE_THREAD_PER_CONNECTION’ mode is in use (since then it is not meaningful to ask for a timeout, after all, there is concurrenct activity). The function must also not be called by user-code if ‘MHD_USE_INTERNAL_POLLING_THREAD’ is in use. In the latter case, the behavior is undefined. DAEMON which daemon to obtain the timeout from. TIMEOUT will be set to the timeout (in milliseconds). Return ‘MHD_YES’ on success, ‘MHD_NO’ if timeouts are not used (or no connections exist that would necessitate the use of a timeout right now).  File: libmicrohttpd.info, Node: microhttpd-requests, Next: microhttpd-responses, Prev: microhttpd-inspect, Up: Top 7 Handling requests ******************* -- Function: int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) Get all the headers matching KIND from the request. The KIND argument can be a bitmask, ORing the various header kinds that are requested. The ITERATOR callback is invoked once for each header, with ITERATOR_CLS as first argument. After version 0.9.19, the headers are iterated in the same order as they were received from the network; previous versions iterated over the headers in reverse order. ‘MHD_get_connection_values’ returns the number of entries iterated over; this can be less than the number of headers if, while iterating, ITERATOR returns ‘MHD_NO’. ITERATOR can be ‘NULL’: in this case this function just counts and returns the number of headers. In the case of ‘MHD_GET_ARGUMENT_KIND’, the VALUE argument will be ‘NULL’ if the URL contained a key without an equals operator. For example, for a HTTP request to the URL "http://foo/bar?key", the VALUE argument is ‘NULL’; in contrast, a HTTP request to the URL "http://foo/bar?key=", the VALUE argument is the empty string. The normal case is that the URL contains "http://foo/bar?key=value" in which case VALUE would be the string "value" and KEY would contain the string "key". -- Function: enum MHD_Result MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value) This function can be used to append an entry to the list of HTTP headers of a connection (so that the ‘MHD_get_connection_values function’ will return them - and the MHD PostProcessor will also see them). This maybe required in certain situations (see Mantis #1399) where (broken) HTTP implementations fail to supply values needed by the post processor (or other parts of the application). This function MUST only be called from within the MHD_AccessHandlerCallback (otherwise, access maybe improperly synchronized). Furthermore, the client must guarantee that the key and value arguments are 0-terminated strings that are NOT freed until the connection is closed. (The easiest way to do this is by passing only arguments to permanently allocated strings.). CONNECTION is the connection for which the entry for KEY of the given KIND should be set to the given VALUE. The function returns ‘MHD_NO’ if the operation could not be performed due to insufficient memory and ‘MHD_YES’ on success. -- Function: const char * MHD_lookup_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key) Get a particular header value. If multiple values match the KIND, return one of them (the "first", whatever that means). KEY must reference a zero-terminated ASCII-coded string representing the header to look for: it is compared against the headers using (basically) ‘strcasecmp()’, so case is ignored. -- Function: const char * MHD_lookup_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr) Get a particular header value. If multiple values match the KIND, return one of them (the "first", whatever that means). KEY must reference an ASCII-coded string representing the header to look for: it is compared against the headers using (basically) ‘strncasecmp()’, so case is ignored. The VALUE_PTR is set to the address of the value found, and VALUE_SIZE_PTR is set to the number of bytes in the value.  File: libmicrohttpd.info, Node: microhttpd-responses, Next: microhttpd-flow, Prev: microhttpd-requests, Up: Top 8 Building responses to requests ******************************** Response objects handling by MHD is asynchronous with respect to the application execution flow. Instances of the ‘MHD_Response’ structure are not associated to a daemon and neither to a client connection: they are managed with reference counting. In the simplest case: we allocate a new ‘MHD_Response’ structure for each response, we use it once and finally we destroy it. MHD allows more efficient resources usages. Example: we allocate a new ‘MHD_Response’ structure for each response *kind*, we use it every time we have to give that response and we finally destroy it only when the daemon shuts down. * Menu: * microhttpd-response enqueue:: Enqueuing a response. * microhttpd-response create:: Creating a response object. * microhttpd-response headers:: Adding headers to a response. * microhttpd-response options:: Setting response options. * microhttpd-response inspect:: Inspecting a response object. * microhttpd-response upgrade:: Creating a response for protocol upgrades.  File: libmicrohttpd.info, Node: microhttpd-response enqueue, Next: microhttpd-response create, Up: microhttpd-responses 8.1 Enqueuing a response ======================== -- Function: enum MHD_Result MHD_queue_response (struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response) Queue a response to be transmitted to the client as soon as possible but only after MHD_AccessHandlerCallback returns. This function checks that it is legal to queue a response at this time for the given connection. It also increments the internal reference counter for the response object (the counter will be decremented automatically once the response has been transmitted). CONNECTION the connection identifying the client; STATUS_CODE HTTP status code (i.e. ‘200’ for OK); RESPONSE response to transmit. Return ‘MHD_YES’ on success or if message has been queued. Return ‘MHD_NO’: if arguments are invalid (example: ‘NULL’ pointer); on error (i.e. reply already sent). -- Function: void MHD_destroy_response (struct MHD_Response *response) Destroy a response object and associated resources (decrement the reference counter). Note that MHD may keep some of the resources around if the response is still in the queue for some clients, so the memory may not necessarily be freed immediately. An explanation of reference counting(1): 1. a ‘MHD_Response’ object is allocated: struct MHD_Response * response = MHD_create_response_from_buffer(...); /* here: reference counter = 1 */ 2. the ‘MHD_Response’ object is enqueued in a ‘MHD_Connection’: MHD_queue_response(connection, , response); /* here: reference counter = 2 */ 3. the creator of the response object discharges responsibility for it: MHD_destroy_response(response); /* here: reference counter = 1 */ 4. the daemon handles the connection sending the response's data to the client then decrements the reference counter by calling ‘MHD_destroy_response()’: the counter's value drops to zero and the ‘MHD_Response’ object is released. ---------- Footnotes ---------- (1) Note to readers acquainted to the Tcl API: reference counting on ‘MHD_Connection’ structures is handled in the same way as Tcl handles ‘Tcl_Obj’ structures through ‘Tcl_IncrRefCount()’ and ‘Tcl_DecrRefCount()’.  File: libmicrohttpd.info, Node: microhttpd-response create, Next: microhttpd-response headers, Prev: microhttpd-response enqueue, Up: microhttpd-responses 8.2 Creating a response object ============================== -- Function: struct MHD_Response * MHD_create_response_from_callback (uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc) Create a response object. The response object can be extended with header information and then it can be used any number of times. SIZE size of the data portion of the response, ‘-1’ for unknown; BLOCK_SIZE preferred block size for querying CRC (advisory only, MHD may still call CRC using smaller chunks); this is essentially the buffer size used for IO, clients should pick a value that is appropriate for IO and memory performance requirements; CRC callback to use to obtain response data; CRC_CLS extra argument to CRC; CRFC callback to call to free CRC_CLS resources. Return ‘NULL’ on error (i.e. invalid arguments, out of memory). -- Function: struct MHD_Response * MHD_create_response_from_fd (uint64_t size, int fd) Create a response object. The response object can be extended with header information and then it can be used any number of times. SIZE size of the data portion of the response (should be smaller or equal to the size of the file) FD file descriptor referring to a file on disk with the data; will be closed when response is destroyed; note that 'fd' must be an actual file descriptor (not a pipe or socket) since MHD might use 'sendfile' or 'seek' on it. The descriptor should be in blocking-IO mode. Return ‘NULL’ on error (i.e. invalid arguments, out of memory). -- Function: struct MHD_Response * MHD_create_response_from_pipe (int fd) Create a response object. The response object can be extended with header information and then it can be used ONLY ONCE. FD file descriptor of the read-end of the pipe; will be closed when response is destroyed. The descriptor should be in blocking-IO mode. Return ‘NULL’ on error (i.e. out of memory). -- Function: struct MHD_Response * MHD_create_response_from_fd_at_offset (size_t size, int fd, off_t offset) Create a response object. The response object can be extended with header information and then it can be used any number of times. Note that you need to be a bit careful about ‘off_t’ when writing this code. Depending on your platform, MHD is likely to have been compiled with support for 64-bit files. When you compile your own application, you must make sure that ‘off_t’ is also a 64-bit value. If not, your compiler may pass a 32-bit value as ‘off_t’, which will result in 32-bits of garbage. If you use the autotools, use the ‘AC_SYS_LARGEFILE’ autoconf macro and make sure to include the generated ‘config.h’ file before ‘microhttpd.h’ to avoid problems. If you do not have a build system and only want to run on a GNU/Linux system, you could also use #define _FILE_OFFSET_BITS 64 #include #include #include #include to ensure 64-bit ‘off_t’. Note that if your operating system does not support 64-bit files, MHD will be compiled with a 32-bit ‘off_t’ (in which case the above would be wrong). SIZE size of the data portion of the response (number of bytes to transmit from the file starting at offset). FD file descriptor referring to a file on disk with the data; will be closed when response is destroyed; note that 'fd' must be an actual file descriptor (not a pipe or socket) since MHD might use 'sendfile' or 'seek' on it. The descriptor should be in blocking-IO mode. OFFSET offset to start reading from in the file Return ‘NULL’ on error (i.e. invalid arguments, out of memory). -- Function: struct MHD_Response * MHD_create_response_from_buffer (size_t size, void *data, enum MHD_ResponseMemoryMode mode) Create a response object. The response object can be extended with header information and then it can be used any number of times. SIZE size of the data portion of the response; BUFFER the data itself; MODE memory management options for buffer; use MHD_RESPMEM_PERSISTENT if the buffer is static/global memory, use MHD_RESPMEM_MUST_FREE if the buffer is heap-allocated and should be freed by MHD and MHD_RESPMEM_MUST_COPY if the buffer is in transient memory (i.e. on the stack) and must be copied by MHD; Return ‘NULL’ on error (i.e. invalid arguments, out of memory). -- Function: struct MHD_Response * MHD_create_response_from_buffer_with_free_callback (size_t size, void *data, MHD_ContentReaderFreeCallback crfc) Create a response object. The buffer at the end must be free'd by calling the CRFC function. SIZE size of the data portion of the response; BUFFER the data itself; CRFC function to call at the end to free memory allocated at BUFFER. Return ‘NULL’ on error (i.e. invalid arguments, out of memory). -- Function: struct MHD_Response * MHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy) Create a response object. The response object can be extended with header information and then it can be used any number of times. This function is deprecated, use ‘MHD_create_response_from_buffer’ instead. SIZE size of the data portion of the response; DATA the data itself; MUST_FREE if true: MHD should free data when done; MUST_COPY if true: MHD allocates a block of memory and use it to make a copy of DATA embedded in the returned ‘MHD_Response’ structure; handling of the embedded memory is responsibility of MHD; DATA can be released anytime after this call returns. Return ‘NULL’ on error (i.e. invalid arguments, out of memory). Example: create a response from a statically allocated string: const char * data = "

    Error!

    "; struct MHD_Connection * connection = ...; struct MHD_Response * response; response = MHD_create_response_from_buffer (strlen(data), data, MHD_RESPMEM_PERSISTENT); MHD_queue_response(connection, 404, response); MHD_destroy_response(response); -- Function: struct MHD_Response * MHD_create_response_from_iovec (const struct MHD_IoVec *iov, int iovcnt, MHD_ContentReaderFreeCallback crfc, void *cls) Create a response object from an array of memory buffers. The response object can be extended with header information and then be used any number of times. IOV the array for response data buffers, an internal copy of this will be made; however, note that the data pointed to by the IOV is not copied and must be preserved unchanged at the given locations until the response is no longer in use and the CRFC is called; IOVCNT the number of elements in IOV; CRFC the callback to call to free resources associated with IOV; CLS the argument to CRFC; Return ‘NULL’ on error (i.e. invalid arguments, out of memory).  File: libmicrohttpd.info, Node: microhttpd-response headers, Next: microhttpd-response options, Prev: microhttpd-response create, Up: microhttpd-responses 8.3 Adding headers to a response ================================ -- Function: enum MHD_Result MHD_add_response_header (struct MHD_Response *response, const char *header, const char *content) Add a header line to the response. The strings referenced by HEADER and CONTENT must be zero-terminated and they are duplicated into memory blocks embedded in RESPONSE. Notice that the strings must not hold newlines, carriage returns or tab chars. MHD_add_response_header() prevents applications from setting a "Transfer-Encoding" header to values other than "identity" or "chunked" as other transfer encodings are not supported by MHD. Note that usually MHD will pick the transfer encoding correctly automatically, but applications can use the header to force a particular behavior. MHD_add_response_header() also prevents applications from setting a "Content-Length" header. MHD will automatically set a correct "Content-Length" header if it is possible and allowed. Return ‘MHD_NO’ on error (i.e. invalid header or content format or memory allocation error). -- Function: enum MHD_Result MHD_add_response_footer (struct MHD_Response *response, const char *footer, const char *content) Add a footer line to the response. The strings referenced by FOOTER and CONTENT must be zero-terminated and they are duplicated into memory blocks embedded in RESPONSE. Notice that the strings must not hold newlines, carriage returns or tab chars. You can add response footers at any time before signalling the end of the response to MHD (not just before calling 'MHD_queue_response'). Footers are useful for adding cryptographic checksums to the reply or to signal errors encountered during data generation. This call was introduced in MHD 0.9.3. Return ‘MHD_NO’ on error (i.e. invalid header or content format or memory allocation error). -- Function: enum MHD_Result MHD_del_response_header (struct MHD_Response *response, const char *header, const char *content) Delete a header (or footer) line from the response. Return ‘MHD_NO’ on error (arguments are invalid or no such header known).  File: libmicrohttpd.info, Node: microhttpd-response options, Next: microhttpd-response inspect, Prev: microhttpd-response headers, Up: microhttpd-responses 8.4 Setting response options ============================ -- Function: enum MHD_Result MHD_set_response_options (struct MHD_Response *response, enum MHD_ResponseFlags flags, ...) Set special flags and options for a response. Calling this functions sets the given flags and options for the response. RESPONSE which response should be modified; FLAGS flags to set for the response; Additional arguments are a list of options (type-value pairs, terminated with ‘MHD_RO_END’). It is mandatory to use ‘MHD_RO_END’ as last argument, even when there are no additional arguments. Return ‘MHD_NO’ on error, ‘MHD_YES’ on success.  File: libmicrohttpd.info, Node: microhttpd-response inspect, Next: microhttpd-response upgrade, Prev: microhttpd-response options, Up: microhttpd-responses 8.5 Inspecting a response object ================================ -- Function: int MHD_get_response_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls) Get all of the headers added to a response. Invoke the ITERATOR callback for each header in the response, using ITERATOR_CLS as first argument. Return number of entries iterated over. ITERATOR can be ‘NULL’: in this case the function just counts headers. ITERATOR should not modify the its key and value arguments, unless we know what we are doing. -- Function: const char * MHD_get_response_header (struct MHD_Response *response, const char *key) Find and return a pointer to the value of a particular header from the response. KEY must reference a zero-terminated string representing the header to look for. The search is case sensitive. Return ‘NULL’ if header does not exist or KEY is ‘NULL’. We should not modify the value, unless we know what we are doing.  File: libmicrohttpd.info, Node: microhttpd-response upgrade, Prev: microhttpd-response inspect, Up: microhttpd-responses 8.6 Creating a response for protocol upgrades ============================================= With RFC 2817 a mechanism to switch protocols within HTTP was introduced. Here, a client sends a request with a "Connection: Upgrade" header. The server responds with a "101 Switching Protocols" response header, after which the two parties begin to speak a different (non-HTTP) protocol over the TCP connection. This mechanism is used for upgrading HTTP 1.1 connections to HTTP2 or HTTPS, as well as for implementing WebSockets. Which protocol upgrade is performed is negotiated between server and client in additional headers, in particular the "Upgrade" header. MHD supports switching protocols using this mechanism only if the ‘MHD_ALLOW_SUSPEND_RESUME’ flag has been set when starting the daemon. If this flag has been set, applications can upgrade a connection by queueing a response (using the ‘MHD_HTTP_SWITCHING_PROTOCOLS’ status code) which must have been created with the following function: -- Function: enum MHD_Result MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, void *upgrade_handler_cls) Create a response suitable for switching protocols. Returns ‘MHD_YES’ on success. ‘upgrade_handler’ must not be ‘NULL’. When creating this type of response, the "Connection: Upgrade" header will be set automatically for you. MHD requires that you additionally set an "Upgrade:" header. The "Upgrade" header must simply exist, the specific value is completely up to the application. The ‘upgrade_handler’ argument to the above has the following type: -- Function Pointer: void *MHD_UpgradeHandler (void *cls, struct MHD_Connection *connection, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh) This function will be called once MHD has transmitted the header of the response to the connection that is being upgraded. At this point, the application is expected to take over the socket ‘sock’ and speak the non-HTTP protocol to which the connection was upgraded. MHD will no longer use the socket; this includes handling timeouts. The application must call ‘MHD_upgrade_action’ with an upgrade action of ‘MHD_UPGRADE_ACTION_CLOSE’ when it is done processing the connection to close the socket. The application must not call ‘MHD_stop_daemon’ on the respective daemon as long as it is still handling the connection. The arguments given to the ‘upgrade_handler’ have the following meaning: CLS matches the ‘upgrade_handler_cls’ that was given to ‘MHD_create_response_for_upgrade’ CONNECTION identifies the connection that is being upgraded; REQ_CLS last value left in '*req_cls' in the 'MHD_AccessHandlerCallback' EXTRA_IN buffer of bytes MHD read "by accident" from the socket already. This can happen if the client eagerly transmits more than just the HTTP request. The application should treat these as if it had read them from the socket. EXTRA_IN_SIZE number of bytes in ‘extra_in’ SOCK the socket which the application can now use directly for some bi-directional communication with the client. The application can henceforth use ‘recv()’ and ‘send()’ or ‘read()’ and ‘write()’ system calls on the socket. However, ‘ioctl()’ and ‘setsockopt()’ functions will not work as expected when using HTTPS. Such operations may be supported in the future via ‘MHD_upgrade_action’. Most importantly, the application must never call ‘close()’ on this socket. Closing the socket must be done using ‘MHD_upgrade_action’. However, while close is forbidden, the application may call ‘shutdown()’ on the socket. URH argument for calls to ‘MHD_upgrade_action’. Applications must eventually use this function to perform the ‘close()’ action on the socket. -- Function: enum MHD_Result MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, enum MHD_UpgradeAction action, ...) Perform special operations related to upgraded connections. URH identifies the upgraded connection to perform an action on ACTION specifies the action to perform; further arguments to the function depend on the specifics of the action. -- Enumeration: MHD_UpgradeAction Set of actions to be performed on upgraded connections. Passed as an argument to ‘MHD_upgrade_action()’. ‘MHD_UPGRADE_ACTION_CLOSE’ Closes the connection. Must be called once the application is done with the client. Takes no additional arguments. ‘MHD_UPGRADE_ACTION_CORK_ON’ Enable corking on the underlying socket. ‘MHD_UPGRADE_ACTION_CORK_OFF’ Disable corking on the underlying socket.  File: libmicrohttpd.info, Node: microhttpd-flow, Next: microhttpd-dauth, Prev: microhttpd-responses, Up: Top 9 Flow control. *************** Sometimes it may be possible that clients upload data faster than an application can process it, or that an application needs an extended period of time to generate a response. If ‘MHD_USE_THREAD_PER_CONNECTION’ is used, applications can simply deal with this by performing their logic within the thread and thus effectively blocking connection processing by MHD. In all other modes, blocking logic must not be placed within the callbacks invoked by MHD as this would also block processing of other requests, as a single thread may be responsible for tens of thousands of connections. Instead, applications using thread modes other than ‘MHD_USE_THREAD_PER_CONNECTION’ should use the following functions to perform flow control. -- Function: enum MHD_Result MHD_suspend_connection (struct MHD_Connection *connection) Suspend handling of network data for a given connection. This can be used to dequeue a connection from MHD's event loop (external select, internal select or thread pool; not applicable to thread-per-connection!) for a while. If you use this API in conjunction with a internal select or a thread pool, you must set the option ‘MHD_ALLOW_SUSPEND_RESUME’ to ensure that a resumed connection is immediately processed by MHD. Suspended connections continue to count against the total number of connections allowed (per daemon, as well as per IP, if such limits are set). Suspended connections will NOT time out; timeouts will restart when the connection handling is resumed. While a connection is suspended, MHD will not detect disconnects by the client. The only safe time to suspend a connection is from the ‘MHD_AccessHandlerCallback’ or from the respective ‘MHD_ContentReaderCallback’ (but in this case the response object must not be shared among multiple connections). When suspending from the ‘MHD_AccessHandlerCallback’ you MUST afterwards return ‘MHD_YES’ from the access handler callback (as MHD_NO would imply to both close and suspend the connection, which is not allowed). Finally, it is an API violation to call ‘MHD_stop_daemon’ while having suspended connections (this will at least create memory and socket leaks or lead to undefined behavior). You must explicitly resume all connections before stopping the daemon. CONNECTION the connection to suspend -- Function: enum MHD_Result MHD_resume_connection (struct MHD_Connection *connection) Resume handling of network data for suspended connection. It is safe to resume a suspended connection at any time. Calling this function on a connection that was not previously suspended will result in undefined behavior. If you are using this function in "external" select mode, you must make sure to run ‘MHD_run’ afterwards (before again calling ‘MHD_get_fdset’), as otherwise the change may not be reflected in the set returned by ‘MHD_get_fdset’ and you may end up with a connection that is stuck until the next network activity. You can check whether a connection is currently suspended using ‘MHD_get_connection_info’ by querying for ‘MHD_CONNECTION_INFO_CONNECTION_SUSPENDED’. CONNECTION the connection to resume  File: libmicrohttpd.info, Node: microhttpd-dauth, Next: microhttpd-post, Prev: microhttpd-flow, Up: Top 10 Utilizing Authentication *************************** MHD support three types of client authentication. Basic authentication uses a simple authentication method based on BASE64 algorithm. Username and password are exchanged in clear between the client and the server, so this method must only be used for non-sensitive content or when the session is protected with https. When using basic authentication MHD will have access to the clear password, possibly allowing to create a chained authentication toward an external authentication server. Digest authentication uses a one-way authentication method based on MD5 hash algorithm. Only the hash will transit over the network, hence protecting the user password. The nonce will prevent replay attacks. This method is appropriate for general use, especially when https is not used to encrypt the session. Client certificate authentication uses a X.509 certificate from the client. This is the strongest authentication mechanism but it requires the use of HTTPS. Client certificate authentication can be used simultaneously with Basic or Digest Authentication in order to provide a two levels authentication (like for instance separate machine and user authentication). A code example for using client certificates is presented in the MHD tutorial. * Menu: * microhttpd-dauth basic:: Using Basic Authentication. * microhttpd-dauth digest:: Using Digest Authentication.  File: libmicrohttpd.info, Node: microhttpd-dauth basic, Next: microhttpd-dauth digest, Up: microhttpd-dauth 10.1 Using Basic Authentication =============================== -- Function: void MHD_free (void *ptr) Free the memory given at ‘ptr’. Used to free data structures allocated by MHD. Calls ‘free(ptr)’. -- Function: char * MHD_basic_auth_get_username_password3 (struct MHD_Connection *connection) Get the username and password from the basic authorization header sent by the client. Return ‘NULL’ if no Basic Authorization header set by the client or if Base64 encoding is invalid; a pointer to the structure with username and password if found values set by the client. If returned value is not ‘NULL’, the value must be ‘MHD_free()’'ed. -- Function: enum MHD_Result MHD_queue_basic_auth_fail_response3 (struct MHD_Connection *connection, const char *realm, int prefer_utf8, struct MHD_Response *response) Queues a response to request basic authentication from the client. Return ‘MHD_YES’ if successful, otherwise ‘MHD_NO’. REALM must reference to a zero-terminated string representing the realm. PREFER_UTF8 if set to ‘MHD_YES’ then parameter ‘charset’ with value ‘UTF-8’ will be added to the response authentication header which indicates that UTF-8 encoding is preferred for username and password. RESPONSE a response structure to specify what shall be presented to the client with a 401 HTTP status.  File: libmicrohttpd.info, Node: microhttpd-dauth digest, Prev: microhttpd-dauth basic, Up: microhttpd-dauth 10.2 Using Digest Authentication ================================ MHD supports MD5 (deprecated by IETF) and SHA-256 hash algorithms for digest authentication. The ‘MHD_DigestAuthAlgorithm’ enumeration is used to specify which algorithm should be used. -- Enumeration: MHD_DigestAuthAlgorithm Which digest algorithm should be used. Must be used consistently. ‘MHD_DIGEST_ALG_AUTO’ Have MHD pick an algorithm currently considered secure. For now defaults to SHA-256. ‘MHD_DIGEST_ALG_MD5’ Force use of (deprecated, ancient, insecure) MD5. ‘MHD_DIGEST_ALG_SHA256’ Force use of SHA-256. -- Enumeration: MHD_DigestAuthResult The result of digest authentication of the client. ‘MHD_DAUTH_OK’ Authentication OK. ‘MHD_DAUTH_ERROR’ General error, like "out of memory". ‘MHD_DAUTH_WRONG_HEADER’ No "Authorization" header or wrong format of the header. ‘MHD_DAUTH_WRONG_USERNAME’ Wrong "username". ‘MHD_DAUTH_WRONG_REALM’ Wrong "realm". ‘MHD_DAUTH_WRONG_URI’ Wrong "URI" (or URI parameters). ‘MHD_DAUTH_NONCE_STALE’ The "nonce" is too old. Suggest the client to retry with the same username and password to get the fresh "nonce". The validity of the "nonce" may not be checked. ‘MHD_DAUTH_NONCE_WRONG’ The "nonce" is wrong. May indicate an attack attempt. ‘MHD_DAUTH_RESPONSE_WRONG’ The "response" is wrong. May indicate an attack attempt. -- Function: char * MHD_digest_auth_get_username (struct MHD_Connection *connection) Find and return a pointer to the username value from the request header. Return ‘NULL’ if the value is not found or header does not exist. If returned value is not ‘NULL’, the value must be ‘MHD_free()’'ed. -- Function: enum MHD_DigestAuthResult MHD_digest_auth_check3 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC7616. If valid return ‘MHD_DAUTH_OK’, otherwise return the error code. REALM must reference to a zero-terminated string representing the realm. USERNAME must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. PASSWORD must reference to a zero-terminated string representing the password, most probably it will be the result of a lookup of the username against a local database. NONCE_TIMEOUT the nonce validity duration in seconds. Most of the time it is sound to specify 300 seconds as its values. ALGO which digest algorithm should we use. -- Function: int MHD_digest_auth_check2 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC2716. If valid return ‘MHD_YES’, otherwise return ‘MHD_NO’. REALM must reference to a zero-terminated string representing the realm. USERNAME must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. PASSWORD must reference to a zero-terminated string representing the password, most probably it will be the result of a lookup of the username against a local database. NONCE_TIMEOUT is the amount of time in seconds for a nonce to be invalid. Most of the time it is sound to specify 300 seconds as its values. ALGO which digest algorithm should we use. -- Function: int MHD_digest_auth_check (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC2716. If valid return ‘MHD_YES’, otherwise return ‘MHD_NO’. Deprecated, use ‘MHD_digest_auth_check2’ instead. REALM must reference to a zero-terminated string representing the realm. USERNAME must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. PASSWORD must reference to a zero-terminated string representing the password, most probably it will be the result of a lookup of the username against a local database. NONCE_TIMEOUT is the amount of time in seconds for a nonce to be invalid. Most of the time it is sound to specify 300 seconds as its values. -- Function: enum MHD_DigestAuthResult MHD_digest_auth_check_digest3 (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t *digest, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC7616. If valid return ‘MHD_DAUTH_OK’, otherwise return the error code. REALM must reference to a zero-terminated string representing the realm. USERNAME must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. DIGEST the pointer to the binary digest for the precalculated hash value "username:realm:password" with specified ALGO. DIGEST_SIZE the number of bytes in DIGEST (the size must match ALGO!) NONCE_TIMEOUT the nonce validity duration in seconds. Most of the time it is sound to specify 300 seconds as its values. ALGO digest authentication algorithm to use. -- Function: int MHD_digest_auth_check_digest2 (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t *digest, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC2716. If valid return ‘MHD_YES’, otherwise return ‘MHD_NO’. REALM must reference to a zero-terminated string representing the realm. USERNAME must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. DIGEST pointer to the binary MD5 sum for the precalculated hash value "userame:realm:password". The size must match the selected ALGO! NONCE_TIMEOUT is the amount of time in seconds for a nonce to be invalid. Most of the time it is sound to specify 300 seconds as its values. ALGO digest authentication algorithm to use. -- Function: int MHD_digest_auth_check_digest (struct MHD_Connection *connection, const char *realm, const char *username, const unsigned char digest[MHD_MD5_DIGEST_SIZE], unsigned int nonce_timeout) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC2716. If valid return ‘MHD_YES’, otherwise return ‘MHD_NO’. Deprecated, use ‘MHD_digest_auth_check_digest2’ instead. REALM must reference to a zero-terminated string representing the realm. USERNAME must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. DIGEST pointer to the binary MD5 sum for the precalculated hash value "userame:realm:password" of ‘MHD_MD5_DIGEST_SIZE’ bytes. NONCE_TIMEOUT is the amount of time in seconds for a nonce to be invalid. Most of the time it is sound to specify 300 seconds as its values. -- Function: enum MHD_Result MHD_queue_auth_fail_response2 (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthAlgorithm algo) Queues a response to request authentication from the client, return ‘MHD_YES’ if successful, otherwise ‘MHD_NO’. REALM must reference to a zero-terminated string representing the realm. OPAQUE must reference to a zero-terminated string representing a value that gets passed to the client and expected to be passed again to the server as-is. This value can be a hexadecimal or base64 string. RESPONSE a response structure to specify what shall be presented to the client with a 401 HTTP status. SIGNAL_STALE a value that signals "stale=true" in the response header to indicate the invalidity of the nonce and no need to ask for authentication parameters and only a new nonce gets generated. ‘MHD_YES’ to generate a new nonce, ‘MHD_NO’ to ask for authentication parameters. ALGO which digest algorithm should we use. The same algorithm must then be selected when checking digests received from clients! -- Function: enum MHD_Result MHD_queue_auth_fail_response (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale) Queues a response to request authentication from the client, return ‘MHD_YES’ if successful, otherwise ‘MHD_NO’. REALM must reference to a zero-terminated string representing the realm. OPAQUE must reference to a zero-terminated string representing a value that gets passed to the client and expected to be passed again to the server as-is. This value can be a hexadecimal or base64 string. RESPONSE a response structure to specify what shall be presented to the client with a 401 HTTP status. SIGNAL_STALE a value that signals "stale=true" in the response header to indicate the invalidity of the nonce and no need to ask for authentication parameters and only a new nonce gets generated. ‘MHD_YES’ to generate a new nonce, ‘MHD_NO’ to ask for authentication parameters. Example: handling digest authentication requests and responses. #define PAGE "libmicrohttpd demoAccess granted" #define DENIED "libmicrohttpd demoAccess denied" #define OPAQUE "11733b200778ce33060f31c9af70a870ba96ddd4" static int ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **ptr) { struct MHD_Response *response; char *username; const char *password = "testpass"; const char *realm = "test@example.com"; int ret; static int already_called_marker; if (&already_called_marker != *req_cls) { /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; } username = MHD_digest_auth_get_username (connection); if (username == NULL) { response = MHD_create_response_from_buffer(strlen (DENIED), DENIED, MHD_RESPMEM_PERSISTENT); ret = MHD_queue_auth_fail_response2 (connection, realm, OPAQUE, response, MHD_NO, MHD_DIGEST_ALG_SHA256); MHD_destroy_response(response); return ret; } ret = MHD_digest_auth_check2 (connection, realm, username, password, 300, MHD_DIGEST_ALG_SHA256); MHD_free(username); if ( (ret == MHD_INVALID_NONCE) || (ret == MHD_NO) ) { response = MHD_create_response_from_buffer(strlen (DENIED), DENIED, MHD_RESPMEM_PERSISTENT); if (NULL == response) return MHD_NO; ret = MHD_queue_auth_fail_response2 (connection, realm, OPAQUE, response, (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO, MHD_DIGEST_ALG_SHA256); MHD_destroy_response(response); return ret; } response = MHD_create_response_from_buffer (strlen(PAGE), PAGE, MHD_RESPMEM_PERSISTENT); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response(response); return ret; }  File: libmicrohttpd.info, Node: microhttpd-post, Next: microhttpd-info, Prev: microhttpd-dauth, Up: Top 11 Adding a ‘POST’ processor **************************** * Menu: * microhttpd-post api:: Programming interface for the ‘POST’ processor. MHD provides the post processor API to make it easier for applications to parse the data of a client's ‘POST’ request: the ‘MHD_AccessHandlerCallback’ will be invoked multiple times to process data as it arrives; at each invocation a new chunk of data must be processed. The arguments UPLOAD_DATA and UPLOAD_DATA_SIZE are used to reference the chunk of data. When ‘MHD_AccessHandlerCallback’ is invoked for a new request: its ‘*REQ_CLS’ argument is set to ‘NULL’. When ‘POST’ data comes in the upload buffer it is *mandatory* to use the REQ_CLS to store a reference to per-request data. The fact that the pointer was initially ‘NULL’ can be used to detect that this is a new request. One method to detect that a new request was started is to set ‘*req_cls’ to an unused integer: int access_handler (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { static int old_connection_marker; int new_connection = (NULL == *req_cls); if (new_connection) { /* new connection with POST */ *req_cls = &old_connection_marker; } ... } In contrast to the previous example, for ‘POST’ requests in particular, it is more common to use the value of ‘*req_cls’ to keep track of actual state used during processing, such as the post processor (or a struct containing a post processor): int access_handler (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) { struct MHD_PostProcessor * pp = *req_cls; if (pp == NULL) { pp = MHD_create_post_processor(connection, ...); *req_cls = pp; return MHD_YES; } if (*upload_data_size) { MHD_post_process(pp, upload_data, *upload_data_size); *upload_data_size = 0; return MHD_YES; } else { MHD_destroy_post_processor(pp); return MHD_queue_response(...); } } Note that the callback from ‘MHD_OPTION_NOTIFY_COMPLETED’ should be used to destroy the post processor. This cannot be done inside of the access handler since the connection may not always terminate normally.  File: libmicrohttpd.info, Node: microhttpd-post api, Up: microhttpd-post 11.1 Programming interface for the ‘POST’ processor =================================================== -- Function: struct MHD_PostProcessor * MHD_create_post_processor (struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iterator, void *iterator_cls) Create a PostProcessor. A PostProcessor can be used to (incrementally) parse the data portion of a ‘POST’ request. CONNECTION the connection on which the ‘POST’ is happening (used to determine the ‘POST’ format); BUFFER_SIZE maximum number of bytes to use for internal buffering (used only for the parsing, specifically the parsing of the keys). A tiny value (256-1024) should be sufficient; do *NOT* use a value smaller than 256; for good performance, use 32k or 64k (i.e. 65536). ITERATOR iterator to be called with the parsed data; must *NOT* be ‘NULL’; ITERATOR_CLS custom value to be used as first argument to ITERATOR. Return ‘NULL’ on error (out of memory, unsupported encoding), otherwise a PP handle. -- Function: enum MHD_Result MHD_post_process (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len) Parse and process ‘POST’ data. Call this function when ‘POST’ data is available (usually during an ‘MHD_AccessHandlerCallback’) with the UPLOAD_DATA and UPLOAD_DATA_SIZE. Whenever possible, this will then cause calls to the ‘MHD_IncrementalKeyValueIterator’. PP the post processor; POST_DATA POST_DATA_LEN bytes of ‘POST’ data; POST_DATA_LEN length of POST_DATA. Return ‘MHD_YES’ on success, ‘MHD_NO’ on error (out-of-memory, iterator aborted, parse error). -- Function: enum MHD_Result MHD_destroy_post_processor (struct MHD_PostProcessor *pp) Release PostProcessor resources. After this function is being called, the PostProcessor is guaranteed to no longer call its iterator. There is no special call to the iterator to indicate the end of the post processing stream. After destroying the PostProcessor, the programmer should perform any necessary work to complete the processing of the iterator. Return ‘MHD_YES’ if processing completed nicely, ‘MHD_NO’ if there were spurious characters or formatting problems with the post request. It is common to ignore the return value of this function.  File: libmicrohttpd.info, Node: microhttpd-info, Next: microhttpd-util, Prev: microhttpd-post, Up: Top 12 Obtaining and modifying status information. ********************************************** * Menu: * microhttpd-info daemon:: State information about an MHD daemon * microhttpd-info conn:: State information about a connection * microhttpd-option conn:: Modify per-connection options  File: libmicrohttpd.info, Node: microhttpd-info daemon, Next: microhttpd-info conn, Up: microhttpd-info 12.1 Obtaining state information about an MHD daemon ==================================================== -- Function: const union MHD_DaemonInfo * MHD_get_daemon_info (struct MHD_Daemon *daemon, enum MHD_DaemonInfoType infoType, ...) Obtain information about the given daemon. This function is currently not fully implemented. DAEMON the daemon about which information is desired; INFOTYPE type of information that is desired ... additional arguments about the desired information (depending on infoType) Returns a union with the respective member (depending on infoType) set to the desired information), or ‘NULL’ in case the desired information is not available or applicable. -- Enumeration: MHD_DaemonInfoType Values of this enum are used to specify what information about a daemon is desired. ‘MHD_DAEMON_INFO_KEY_SIZE’ Request information about the key size for a particular cipher algorithm. The cipher algorithm should be passed as an extra argument (of type 'enum MHD_GNUTLS_CipherAlgorithm'). No longer supported, using this value will cause ‘MHD_get_daemon_info’ to return NULL. ‘MHD_DAEMON_INFO_MAC_KEY_SIZE’ Request information about the key size for a particular cipher algorithm. The cipher algorithm should be passed as an extra argument (of type 'enum MHD_GNUTLS_HashAlgorithm'). No longer supported, using this value will cause ‘MHD_get_daemon_info’ to return NULL. ‘MHD_DAEMON_INFO_LISTEN_FD’ Request the file-descriptor number that MHD is using to listen to the server socket. This can be useful if no port was specified and a client needs to learn what port is actually being used by MHD. No extra arguments should be passed. ‘MHD_DAEMON_INFO_EPOLL_FD’ Request the file-descriptor number that MHD is using for epoll. If the build is not supporting epoll, NULL is returned; if we are using a thread pool or this daemon was not started with ‘MHD_USE_EPOLL’, (a pointer to) -1 is returned. If we are using ‘MHD_USE_INTERNAL_POLLING_THREAD’ or are in 'external' select mode, the internal epoll FD is returned. This function must be used in external select mode with epoll to obtain the FD to call epoll on. No extra arguments should be passed. ‘MHD_DAEMON_INFO_CURRENT_CONNECTIONS’ Request the number of current connections handled by the daemon. No extra arguments should be passed and a pointer to a ‘union MHD_DaemonInfo’ value is returned, with the ‘num_connections’ member of type ‘unsigned int’ set to the number of active connections. Note that in multi-threaded or internal-select mode, the real number of current connections may already be different when ‘MHD_get_daemon_info’ returns. The number of current connections can be used (even in multi-threaded and internal-select mode) after ‘MHD_quiesce_daemon’ to detect whether all connections have been handled.  File: libmicrohttpd.info, Node: microhttpd-info conn, Next: microhttpd-option conn, Prev: microhttpd-info daemon, Up: microhttpd-info 12.2 Obtaining state information about a connection =================================================== -- Function: const union MHD_ConnectionInfo * MHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType infoType, ...) Obtain information about the given connection. CONNECTION the connection about which information is desired; INFOTYPE type of information that is desired ... additional arguments about the desired information (depending on infoType) Returns a union with the respective member (depending on infoType) set to the desired information), or ‘NULL’ in case the desired information is not available or applicable. -- Enumeration: MHD_ConnectionInfoType Values of this enum are used to specify what information about a connection is desired. ‘MHD_CONNECTION_INFO_CIPHER_ALGO’ What cipher algorithm is being used (HTTPS connections only). ‘NULL’ is returned for non-HTTPS connections. Takes no extra arguments. ‘MHD_CONNECTION_INFO_PROTOCOL,’ Allows finding out the TLS/SSL protocol used (HTTPS connections only). ‘NULL’ is returned for non-HTTPS connections. Takes no extra arguments. ‘MHD_CONNECTION_INFO_CLIENT_ADDRESS’ Returns information about the address of the client. Returns essentially a ‘struct sockaddr **’ (since the API returns a ‘union MHD_ConnectionInfo *’ and that union contains a ‘struct sockaddr *’). Takes no extra arguments. ‘MHD_CONNECTION_INFO_GNUTLS_SESSION,’ Takes no extra arguments. Allows access to the underlying GNUtls session, including access to the underlying GNUtls client certificate (HTTPS connections only). Takes no extra arguments. ‘NULL’ is returned for non-HTTPS connections. Takes no extra arguments. ‘MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT,’ Dysfunctional (never implemented, deprecated). Use MHD_CONNECTION_INFO_GNUTLS_SESSION to get the ‘gnutls_session_t’ and then call ‘gnutls_certificate_get_peers()’. ‘MHD_CONNECTION_INFO_DAEMON’ Returns information about ‘struct MHD_Daemon’ which manages this connection. Takes no extra arguments. ‘MHD_CONNECTION_INFO_CONNECTION_FD’ Returns the file descriptor (usually a TCP socket) associated with this connection (in the "connect-fd" member of the returned struct). Note that manipulating the descriptor directly can have problematic consequences (as in, break HTTP). Applications might use this access to manipulate TCP options, for example to set the "TCP-NODELAY" option for COMET-like applications. Note that MHD will set TCP-CORK after sending the HTTP header and clear it after finishing the footers automatically (if the platform supports it). As the connection callbacks are invoked in between, those might be used to set different values for TCP-CORK and TCP-NODELAY in the meantime. Takes no extra arguments. ‘MHD_CONNECTION_INFO_CONNECTION_SUSPENDED’ Returns pointer to an integer that is ‘MHD_YES’ if the connection is currently suspended (and thus can be safely resumed) and ‘MHD_NO’ otherwise. Takes no extra arguments. ‘MHD_CONNECTION_INFO_SOCKET_CONTEXT’ Returns the client-specific pointer to a ‘void *’ that was (possibly) set during a ‘MHD_NotifyConnectionCallback’ when the socket was first accepted. Note that this is NOT the same as the ‘req_cls’ argument of the ‘MHD_AccessHandlerCallback’. The ‘req_cls’ is fresh for each HTTP request, while the ‘socket_context’ is fresh for each socket. Takes no extra arguments. ‘MHD_CONNECTION_INFO_CONNECTION_TIMEOUT’ Returns pointer to an ‘unsigned int’ that is the current timeout used for the connection (in seconds, 0 for no timeout). Note that while suspended connections will not timeout, the timeout value returned for suspended connections will be the timeout that the connection will use after it is resumed, and thus might not be zero. Takes no extra arguments. ‘MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE’ Returns pointer to an ‘size_t’ that represents the size of the HTTP header received from the client. Only valid after the first callback to the access handler. Takes no extra arguments. ‘MHD_CONNECTION_INFO_HTTP_STATUS’ Returns the HTTP status code of the response that was queued. Returns NULL if no response was queued yet. Takes no extra arguments.  File: libmicrohttpd.info, Node: microhttpd-option conn, Prev: microhttpd-info conn, Up: microhttpd-info 12.3 Setting custom options for an individual connection ======================================================== -- Function: int MHD_set_connection_option (struct MHD_Connection *daemon, enum MHD_CONNECTION_OPTION option, ...) Set a custom option for the given connection. CONNECTION the connection for which an option should be set or modified; OPTION option to set ... additional arguments for the option (depending on option) Returns ‘MHD_YES’ on success, ‘MHD_NO’ for errors (i.e. option argument invalid or option unknown). -- Enumeration: MHD_CONNECTION_OPTION Values of this enum are used to specify which option for a connection should be changed. ‘MHD_CONNECTION_OPTION_TIMEOUT’ Set a custom timeout for the given connection. Specified as the number of seconds, given as an ‘unsigned int’. Use zero for no timeout.  File: libmicrohttpd.info, Node: microhttpd-util, Next: microhttpd-websocket, Prev: microhttpd-info, Up: Top 13 Utility functions. ********************* * Menu: * microhttpd-util feature:: Test supported MHD features * microhttpd-util unescape:: Unescape strings  File: libmicrohttpd.info, Node: microhttpd-util feature, Next: microhttpd-util unescape, Up: microhttpd-util 13.1 Testing for supported MHD features ======================================= -- Enumeration: MHD_FEATURE Values of this enum are used to specify what information about a daemon is desired. ‘MHD_FEATURE_MESSAGES’ Get whether messages are supported. If supported then in debug mode messages can be printed to stderr or to external logger. ‘MHD_FEATURE_SSL’ Get whether HTTPS is supported. If supported then flag MHD_USE_SSL and options MHD_OPTION_HTTPS_MEM_KEY, MHD_OPTION_HTTPS_MEM_CERT, MHD_OPTION_HTTPS_MEM_TRUST, MHD_OPTION_HTTPS_MEM_DHPARAMS, MHD_OPTION_HTTPS_CRED_TYPE, MHD_OPTION_HTTPS_PRIORITIES can be used. ‘MHD_FEATURE_HTTPS_CERT_CALLBACK’ Get whether option #MHD_OPTION_HTTPS_CERT_CALLBACK is supported. ‘MHD_FEATURE_IPv6’ Get whether IPv6 is supported. If supported then flag MHD_USE_IPv6 can be used. ‘MHD_FEATURE_IPv6_ONLY’ Get whether IPv6 without IPv4 is supported. If not supported then IPv4 is always enabled in IPv6 sockets and flag MHD_USE_DUAL_STACK if always used when MHD_USE_IPv6 is specified. ‘MHD_FEATURE_POLL’ Get whether ‘poll()’ is supported. If supported then flag MHD_USE_POLL can be used. ‘MHD_FEATURE_EPOLL’ Get whether ‘epoll()’ is supported. If supported then Flags MHD_USE_EPOLL and MHD_USE_EPOLL_INTERNAL_THREAD can be used. ‘MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET’ Get whether shutdown on listen socket to signal other threads is supported. If not supported flag MHD_USE_ITC is automatically forced. ‘MHD_FEATURE_SOCKETPAIR’ Get whether a ‘socketpair()’ is used internally instead of a ‘pipe()’ to signal other threads. ‘MHD_FEATURE_TCP_FASTOPEN’ Get whether TCP Fast Open is supported. If supported then flag MHD_USE_TCP_FASTOPEN and option MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE can be used. ‘MHD_FEATURE_BASIC_AUTH’ Get whether HTTP Basic authorization is supported. If supported then functions ‘MHD_basic_auth_get_username_password()’ and ‘MHD_queue_basic_auth_fail_response()’ can be used. ‘MHD_FEATURE_DIGEST_AUTH’ Get whether HTTP Digest authorization is supported. If supported then options MHD_OPTION_DIGEST_AUTH_RANDOM, MHD_OPTION_NONCE_NC_SIZE and functions ‘MHD_digest_auth_check()’, can be used. ‘MHD_FEATURE_POSTPROCESSOR’ Get whether postprocessor is supported. If supported then functions ‘MHD_create_post_processor()’, ‘MHD_post_process()’, ‘MHD_destroy_post_processor()’ can be used. ‘MHD_FEATURE_SENDFILE’ Get whether ‘sendfile()’ is supported. -- Function: int MHD_is_feature_supported (enum MHD_FEATURE feature) Get information about supported MHD features. Indicate that MHD was compiled with or without support for particular feature. Some features require additional support by the kernel. However, kernel support is not checked by this function. FEATURE type of requested information Returns ‘MHD_YES’ if the feature is supported, and ‘MHD_NO’ if not.  File: libmicrohttpd.info, Node: microhttpd-util unescape, Prev: microhttpd-util feature, Up: microhttpd-util 13.2 Unescape strings ===================== -- Function: size_t MHD_http_unescape (char *val) Process escape sequences ('%HH') Updates val in place; the result should be UTF-8 encoded and cannot be larger than the input. The result must also still be 0-terminated. VAL value to unescape (modified in the process), must be a 0-terminated UTF-8 string. Returns length of the resulting val (‘strlen(val)’ may be shorter afterwards due to elimination of escape sequences).  File: libmicrohttpd.info, Node: microhttpd-websocket, Next: GNU-LGPL, Prev: microhttpd-util, Up: Top 14 Websocket functions. *********************** Websocket functions provide what you need to use an upgraded connection as a websocket. These functions are only available if you include the header file ‘microhttpd_ws.h’ and compiled _libmicrohttpd_ with websockets. * Menu: * microhttpd-websocket handshake:: Websocket handshake functions * microhttpd-websocket stream:: Websocket stream functions * microhttpd-websocket decode:: Websocket decode functions * microhttpd-websocket encode:: Websocket encode functions * microhttpd-websocket memory:: Websocket memory functions  File: libmicrohttpd.info, Node: microhttpd-websocket handshake, Next: microhttpd-websocket stream, Up: microhttpd-websocket 14.1 Websocket handshake functions ================================== -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_check_http_version (const char* http_version) Checks the HTTP version of the incoming request. Websocket requests are only allowed for HTTP/1.1 or above. HTTP_VERSION The value of the ‘version’ parameter of your ‘access_handler’ callback. If you pass ‘NULL’ then this is handled like a not matching HTTP version. Returns 0 when the HTTP version is valid for a websocket request and a value less than zero when the HTTP version isn't valid for a websocket request. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_check_connection_header (const char* connection_header) Checks the value of the ‘Connection’ HTTP request header. Websocket requests require the token ‘Upgrade’ in the ‘Connection’ HTTP request header. CONNECTION_HEADER Value of the ‘Connection’ request header. You can get this request header value by passing ‘MHD_HTTP_HEADER_CONNECTION’ to ‘MHD_lookup_connection_value()’. If you pass ‘NULL’ then this is handled like a not matching ‘Connection’ header value. Returns 0 when the ‘Connection’ header is valid for a websocket request and a value less than zero when the ‘Connection’ header isn't valid for a websocket request. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_check_upgrade_header (const char* upgrade_header) Checks the value of the ‘Upgrade’ HTTP request header. Websocket requests require the value ‘websocket’ in the ‘Upgrade’ HTTP request header. UPGRADE_HEADER Value of the ‘Upgrade’ request header. You can get this request header value by passing ‘MHD_HTTP_HEADER_UPGRADE’ to ‘MHD_lookup_connection_value()’. If you pass ‘NULL’ then this is handled like a not matching ‘Upgrade’ header value. Returns 0 when the ‘Upgrade’ header is valid for a websocket request and a value less than zero when the ‘Upgrade’ header isn't valid for a websocket request. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_check_version_header (const char* version_header) Checks the value of the ‘Sec-WebSocket-Version’ HTTP request header. Websocket requests require the value ‘13’ in the ‘Sec-WebSocket-Version’ HTTP request header. VERSION_HEADER Value of the ‘Sec-WebSocket-Version’ request header. You can get this request header value by passing ‘MHD_HTTP_HEADER_SEC_WEBSOCKET_VERSION’ to ‘MHD_lookup_connection_value()’. If you pass ‘NULL’ then this is handled like a not matching ‘Sec-WebSocket-Version’ header value. Returns 0 when the ‘Sec-WebSocket-Version’ header is valid for a websocket request and a value less than zero when the ‘Sec-WebSocket-Version’ header isn't valid for a websocket request. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_create_accept_header (const char* sec_websocket_key, char* sec_websocket_accept) Checks the value of the ‘Sec-WebSocket-Key’ HTTP request header and generates the value for the ‘Sec-WebSocket-Accept’ HTTP response header. The generated value must be sent to the client. SEC_WEBSOCKET_KEY Value of the ‘Sec-WebSocket-Key’ request header. You can get this request header value by passing ‘MHD_HTTP_HEADER_SEC_WEBSOCKET_KEY’ to ‘MHD_lookup_connection_value()’. If you pass ‘NULL’ then this is handled like a not matching ‘Sec-WebSocket-Key’ header value. SEC_WEBSOCKET_ACCEPT Response buffer, which will receive the generated value for the ‘Sec-WebSocket-Accept’ HTTP response header. This buffer must be at least 29 bytes long and will contain the response value plus a terminating ‘NUL’ character on success. Must not be ‘NULL’. You can add this HTTP header to your response by passing ‘MHD_HTTP_HEADER_SEC_WEBSOCKET_ACCEPT’ to ‘MHD_add_response_header()’. Returns 0 when the ‘Sec-WebSocket-Key’ header was not empty and a result value for the ‘Sec-WebSocket-Accept’ was calculated. A value less than zero is returned when the ‘Sec-WebSocket-Key’ header isn't valid for a websocket request or when any error occurred. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’.  File: libmicrohttpd.info, Node: microhttpd-websocket stream, Next: microhttpd-websocket decode, Prev: microhttpd-websocket handshake, Up: microhttpd-websocket 14.2 Websocket stream functions =============================== -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_init (struct MHD_WebSocketStream **ws, int flags, size_t max_payload_size) Creates a new websocket stream, used for decoding/encoding. WS pointer a variable to fill with the newly created ‘struct MHD_WebSocketStream’, receives ‘NULL’ on error. May not be ‘NULL’. If not required anymore, free the created websocket stream with ‘MHD_websocket_stream_free()’. FLAGS combination of ‘enum MHD_WEBSOCKET_FLAG’ values to modify the behavior of the websocket stream. MAX_PAYLOAD_SIZE maximum size for incoming payload data in bytes. Use 0 to allow each size. Returns 0 on success, negative values on error. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_init2 (struct MHD_WebSocketStream **ws, int flags, size_t max_payload_size, MHD_WebSocketMallocCallback callback_malloc, MHD_WebSocketReallocCallback callback_realloc, MHD_WebSocketFreeCallback callback_free, void* cls_rng, MHD_WebSocketRandomNumberGenerator callback_rng) Creates a new websocket stream, used for decoding/encoding, but with custom memory functions for malloc, realloc and free. Also a random number generator can be specified for client mode. WS pointer a variable to fill with the newly created ‘struct MHD_WebSocketStream’, receives ‘NULL’ on error. Must not be ‘NULL’. If not required anymore, free the created websocket stream with ‘MHD_websocket_stream_free’. FLAGS combination of ‘enum MHD_WEBSOCKET_FLAG’ values to modify the behavior of the websocket stream. MAX_PAYLOAD_SIZE maximum size for incoming payload data in bytes. Use 0 to allow each size. CALLBACK_MALLOC callback function for allocating memory. Must not be ‘NULL’. The shorter ‘MHD_websocket_stream_init()’ passes a reference to ‘malloc’ here. CALLBACK_REALLOC callback function for reallocating memory. Must not be ‘NULL’. The shorter ‘MHD_websocket_stream_init()’ passes a reference to ‘realloc’ here. CALLBACK_FREE callback function for freeing memory. Must not be ‘NULL’. The shorter ‘MHD_websocket_stream_init()’ passes a reference to ‘free’ here. CLS_RNG closure for the random number generator. This is only required when ‘MHD_WEBSOCKET_FLAG_CLIENT’ is passed in ‘flags’. The given value is passed to the random number generator callback. May be ‘NULL’ if not needed. Should be ‘NULL’ when you are not using ‘MHD_WEBSOCKET_FLAG_CLIENT’. The shorter ‘MHD_websocket_stream_init’ passes ‘NULL’ here. CALLBACK_RNG callback function for a secure random number generator. This is only required when ‘MHD_WEBSOCKET_FLAG_CLIENT’ is passed in ‘flags’ and must not be ‘NULL’ then. Should be ‘NULL’ otherwise. The shorter ‘MHD_websocket_stream_init()’ passes ‘NULL’ here. Returns 0 on success, negative values on error. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_free (struct MHD_WebSocketStream *ws) Frees a previously allocated websocket stream WS websocket stream to free, this value may be ‘NULL’. Returns 0 on success, negative values on error. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_stream_invalidate (struct MHD_WebSocketStream *ws) Invalidates a websocket stream. After invalidation a websocket stream cannot be used for decoding anymore. Encoding is still possible. WS websocket stream to invalidate. Returns 0 on success, negative values on error. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_VALIDITY MHD_websocket_stream_is_valid (struct MHD_WebSocketStream *ws) Queries whether a websocket stream is valid. Invalidated websocket streams cannot be used for decoding anymore. Encoding is still possible. WS websocket stream to invalidate. Returns 0 if invalid, 1 if valid for all types or 2 if valid only for control frames. Can be compared with ‘enum MHD_WEBSOCKET_VALIDITY’.  File: libmicrohttpd.info, Node: microhttpd-websocket decode, Next: microhttpd-websocket encode, Prev: microhttpd-websocket stream, Up: microhttpd-websocket 14.3 Websocket decode functions =============================== -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_decode (struct MHD_WebSocketStream* ws, const char* streambuf, size_t streambuf_len, size_t* streambuf_read_len, char** payload, size_t* payload_len) Decodes a byte sequence for a websocket stream. Decoding is done until either a frame is complete or the end of the byte sequence is reached. WS websocket stream for decoding. STREAMBUF byte sequence for decoding. This is what you typically received via ‘recv()’. STREAMBUF_LEN length of the byte sequence in parameter ‘streambuf’. STREAMBUF_READ_LEN pointer to a variable, which receives the number of bytes, that has been processed by this call. This value may be less than the value of ‘streambuf_len’ when a frame is decoded before the end of the buffer is reached. The remaining bytes of ‘buf’ must be passed to the next call of this function. PAYLOAD pointer to a variable, which receives the allocated buffer with the payload data of the decoded frame. Must not be ‘NULL’. If no decoded data is available or an error occurred ‘NULL’ is returned. When the returned value is not ‘NULL’ then the buffer contains always ‘payload_len’ bytes plus one terminating ‘NUL’ character (regardless of the frame type). The caller must free this buffer using ‘MHD_websocket_free()’. If you passed the flag ‘MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR’ upon creation of the websocket stream and a decoding error occurred (function return value less than 0), then this buffer contains a generated close frame, which must be sent via the socket to the recipient. If you passed the flag ‘MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS’ upon creation of the websocket stream then this payload may only be a part of the complete message. Only complete UTF-8 sequences are returned for fragmented text frames. If necessary the UTF-8 sequence will be completed with the next text fragment. PAYLOAD_LEN pointer to a variable, which receives length of the result ‘payload’ buffer in bytes. Must not be ‘NULL’. This receives 0 when no data is available, when the decoded payload has a length of zero or when an error occurred. Returns a value greater than zero when a frame is complete. Compare with ‘enum MHD_WEBSOCKET_STATUS’ to distinguish the frame type. Returns 0 when the call succeeded, but no frame is available. Returns a value less than zero on errors. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_split_close_reason (const char* payload, size_t payload_len, unsigned short* reason_code, const char** reason_utf8, size_t* reason_utf8_len) Splits the payload of a decoded close frame. PAYLOAD payload of the close frame. This parameter may only be ‘NULL’ if ‘payload_len’ is 0. PAYLOAD_LEN length of ‘payload’. REASON_CODE pointer to a variable, which receives the numeric close reason. If there was no close reason, this is 0. This value can be compared with ‘enum MHD_WEBSOCKET_CLOSEREASON’. May be ‘NULL’. REASON_UTF8 pointer to a variable, which receives the literal close reason. If there was no literal close reason, this will be ‘NULL’. May be ‘NULL’. Please note that no memory is allocated in this function. If not ‘NULL’ the returned value of this parameter points to a position in the specified ‘payload’. REASON_UTF8_LEN pointer to a variable, which receives the length of the literal close reason. If there was no literal close reason, this is 0. May be ‘NULL’. Returns 0 on success or a value less than zero on errors. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’.  File: libmicrohttpd.info, Node: microhttpd-websocket encode, Next: microhttpd-websocket memory, Prev: microhttpd-websocket decode, Up: microhttpd-websocket 14.4 Websocket encode functions =============================== -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_text (struct MHD_WebSocketStream* ws, const char* payload_utf8, size_t payload_utf8_len, int fragmentation, char** frame, size_t* frame_len, int* utf8_step) Encodes an UTF-8 encoded text into websocket text frame WS websocket stream; PAYLOAD_UTF8 text to send. This must be UTF-8 encoded. If you don't want UTF-8 then send a binary frame with ‘MHD_websocket_encode_binary()’ instead. May be be ‘NULL’ if ‘payload_utf8_len’ is 0, must not be ‘NULL’ otherwise. PAYLOAD_UTF8_LEN length of ‘payload_utf8’ in bytes. FRAGMENTATION A value of ‘enum MHD_WEBSOCKET_FRAGMENTATION’ to specify the fragmentation behavior. Specify ‘MHD_WEBSOCKET_FRAGMENTATION_NONE’ or just 0 if you don't want to use fragmentation (default). FRAME pointer to a variable, which receives a buffer with the encoded text frame. Must not be ‘NULL’. The buffer contains what you typically send via ‘send()’ to the recipient. If no encoded data is available the variable receives ‘NULL’. If the variable is not ‘NULL’ then the buffer contains always ‘frame_len’ bytes plus one terminating ‘NUL’ character. The caller must free this buffer using ‘MHD_websocket_free()’. FRAME_LEN pointer to a variable, which receives the length of the encoded frame in bytes. Must not be ‘NULL’. UTF8_STEP If fragmentation is used (the parameter ‘fragmentation’ is not 0) then is parameter is required and must not be ‘NULL’. If no fragmentation is used, this parameter is optional and should be ‘NULL’. This parameter is a pointer to a variable which contains the last check status of the UTF-8 sequence. It is required to continue a previous UTF-8 sequence check when fragmentation is used, because a UTF-8 sequence could be split upon fragments. ‘enum MHD_WEBSOCKET_UTF8STEP’ is used for this value. If you start a new fragment using ‘MHD_WEBSOCKET_FRAGMENTATION_NONE’ or ‘MHD_WEBSOCKET_FRAGMENTATION_FIRST’ the old value of this variable will be discarded and the value of this variable will be initialized to ‘MHD_WEBSOCKET_UTF8STEP_NORMAL’. On all other fragmentation modes the previous value of the pointed variable will be used to continue the UTF-8 sequence check. Returns 0 on success or a value less than zero on errors. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_binary (struct MHD_WebSocketStream* ws, const char* payload, size_t payload_len, int fragmentation, char** frame, size_t* frame_len) Encodes binary data into websocket binary frame WS websocket stream; PAYLOAD binary data to send. May be be ‘NULL’ if ‘payload_len’ is 0, must not be ‘NULL’ otherwise. PAYLOAD_LEN length of ‘payload’ in bytes. FRAGMENTATION A value of ‘enum MHD_WEBSOCKET_FRAGMENTATION’ to specify the fragmentation behavior. Specify ‘MHD_WEBSOCKET_FRAGMENTATION_NONE’ or just 0 if you don't want to use fragmentation (default). FRAME pointer to a variable, which receives a buffer with the encoded binary frame. Must not be ‘NULL’. The buffer contains what you typically send via ‘send()’ to the recipient. If no encoded data is available the variable receives ‘NULL’. If the variable is not ‘NULL’ then the buffer contains always ‘frame_len’ bytes plus one terminating ‘NUL’ character. The caller must free this buffer using ‘MHD_websocket_free()’. FRAME_LEN pointer to a variable, which receives the length of the encoded frame in bytes. Must not be ‘NULL’. Returns 0 on success or a value less than zero on errors. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_ping (struct MHD_WebSocketStream* ws, const char* payload, size_t payload_len, char** frame, size_t* frame_len) Encodes a websocket ping frame. Ping frames are used to check whether a recipient is still available and what latency the websocket connection has. WS websocket stream; PAYLOAD binary ping data to send. May be ‘NULL’ if ‘payload_len’ is 0. PAYLOAD_LEN length of ‘payload’ in bytes. This may not exceed 125 bytes. FRAME pointer to a variable, which receives a buffer with the encoded ping frame. Must not be ‘NULL’. The buffer contains what you typically send via ‘send()’ to the recipient. If no encoded data is available the variable receives ‘NULL’. If the variable is not ‘NULL’ then the buffer contains always ‘frame_len’ bytes plus one terminating ‘NUL’ character. The caller must free this buffer using ‘MHD_websocket_free()’. FRAME_LEN pointer to a variable, which receives the length of the encoded frame in bytes. Must not be ‘NULL’. Returns 0 on success or a value less than zero on errors. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_pong (struct MHD_WebSocketStream* ws, const char* payload, size_t payload_len, char** frame, size_t* frame_len) Encodes a websocket pong frame. Pong frames are used to answer a previously received websocket ping frame. WS websocket stream; PAYLOAD binary pong data to send, which should be the decoded payload from the received ping frame. May be ‘NULL’ if ‘payload_len’ is 0. PAYLOAD_LEN length of ‘payload’ in bytes. This may not exceed 125 bytes. FRAME pointer to a variable, which receives a buffer with the encoded pong frame. Must not be ‘NULL’. The buffer contains what you typically send via ‘send()’ to the recipient. If no encoded data is available the variable receives ‘NULL’. If the variable is not ‘NULL’ then the buffer contains always ‘frame_len’ bytes plus one terminating ‘NUL’ character. The caller must free this buffer using ‘MHD_websocket_free()’. FRAME_LEN pointer to a variable, which receives the length of the encoded frame in bytes. Must not be ‘NULL’. Returns 0 on success or a value less than zero on errors. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’. -- Function: enum MHD_WEBSOCKET_STATUS MHD_websocket_encode_close (struct MHD_WebSocketStream* ws, unsigned short reason_code, const char* reason_utf8, size_t reason_utf8_len, char** frame, size_t* frame_len) Encodes a websocket close frame. Close frames are used to close a websocket connection in a formal way. WS websocket stream; REASON_CODE reason for close. You can use ‘enum MHD_WEBSOCKET_CLOSEREASON’ for typical reasons, but you are not limited to these values. The allowed values are specified in RFC 6455 7.4. If you don't want to enter a reason, you can specify ‘MHD_WEBSOCKET_CLOSEREASON_NO_REASON’ (or just 0) then no reason is encoded. REASON_UTF8 An UTF-8 encoded text reason why the connection is closed. This may be ‘NULL’ if ‘reason_utf8_len’ is 0. This must be ‘NULL’ if ‘reason_code’ equals to zero (‘MHD_WEBSOCKET_CLOSEREASON_NO_REASON’). REASON_UTF8_LEN length of the UTF-8 encoded text reason in bytes. This may not exceed 123 bytes. FRAME pointer to a variable, which receives a buffer with the encoded close frame. Must not be ‘NULL’. The buffer contains what you typically send via ‘send()’ to the recipient. If no encoded data is available the variable receives ‘NULL’. If the variable is not ‘NULL’ then the buffer contains always ‘frame_len’ bytes plus one terminating ‘NUL’ character. The caller must free this buffer using ‘MHD_websocket_free()’. FRAME_LEN pointer to a variable, which receives the length of the encoded frame in bytes. Must not be ‘NULL’. Returns 0 on success or a value less than zero on errors. Can be compared with ‘enum MHD_WEBSOCKET_STATUS’.  File: libmicrohttpd.info, Node: microhttpd-websocket memory, Prev: microhttpd-websocket encode, Up: microhttpd-websocket 14.5 Websocket memory functions =============================== -- Function: void* MHD_websocket_malloc (struct MHD_WebSocketStream* ws, size_t buf_len) Allocates memory with the associated ‘malloc()’ function of the websocket stream. The memory allocation function could be different for a websocket stream if ‘MHD_websocket_stream_init2()’ has been used for initialization. WS websocket stream; BUF_LEN size of the buffer to allocate in bytes. Returns the pointer of the allocated buffer or ‘NULL’ on failure. -- Function: void* MHD_websocket_realloc (struct MHD_WebSocketStream* ws, void* buf, size_t new_buf_len) Reallocates memory with the associated ‘realloc()’ function of the websocket stream. The memory reallocation function could be different for a websocket stream if ‘MHD_websocket_stream_init2()’ has been used for initialization. WS websocket stream; BUF current buffer, may be ‘NULL’; NEW_BUF_LEN new size of the buffer in bytes. Return the pointer of the reallocated buffer or ‘NULL’ on failure. On failure the old pointer remains valid. -- Function: void MHD_websocket_free (struct MHD_WebSocketStream* ws, void* buf) Frees memory with the associated ‘free()’ function of the websocket stream. The memory free function could be different for a websocket stream if ‘MHD_websocket_stream_init2()’ has been used for initialization. WS websocket stream; BUF buffer to free, this may be ‘NULL’ then nothing happens.  File: libmicrohttpd.info, Node: GNU-LGPL, Next: eCos License, Prev: microhttpd-websocket, Up: Top GNU-LGPL ******** Version 2.1, February 1999 Copyright © 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble -------- The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the “Lesser†General Public License because it does _Less_ to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION --------------------------------------------------------------- 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a. The modified work must itself be a software library. b. You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c. You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d. If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a. Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b. Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c. Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d. If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e. Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a. Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b. Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS --------------------------- How to Apply These Terms to Your New Libraries ---------------------------------------------- If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. ONE LINE TO GIVE THE LIBRARY'S NAME AND AN IDEA OF WHAT IT DOES. Copyright (C) YEAR NAME OF AUTHOR This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. SIGNATURE OF TY COON, 1 April 1990 Ty Coon, President of Vice That's all there is to it!  File: libmicrohttpd.info, Node: eCos License, Next: GNU-GPL, Prev: GNU-LGPL, Up: Top eCos License ************ GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 or (at your option) any later version. GNU libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU libmicrohttpd; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special exception, if other files instantiate templates or use macros or inline functions from this file, or you compile this file and link it with other works to produce a work based on this file, this file does not by itself cause the resulting work to be covered by the GNU General Public License. However the source code for this file must still be made available in accordance with section (3) of the GNU General Public License v2. This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License.  File: libmicrohttpd.info, Node: GNU-GPL, Next: GNU-FDL, Prev: eCos License, Up: Top GNU General Public License ************************** Version 2, June 1991 Copyright © 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble ======== The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION =============================================================== 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a. You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b. You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c. If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a. Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c. Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs ======================================================= If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. Copyright (C) YYYY NAME OF AUTHOR This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) YEAR NAME OF AUTHOR Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands ‘show w’ and ‘show c’ should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than ‘show w’ and ‘show c’; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. SIGNATURE OF TY COON, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.  File: libmicrohttpd.info, Node: GNU-FDL, Next: Concept Index, Prev: GNU-GPL, Up: Top GNU-FDL ******* Version 1.3, 3 November 2008 Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 0. PREAMBLE The purpose of this License is to make a manual, textbook, or other functional and useful document “free†in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others. This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software. We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference. 1. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you". You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law. A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language. A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none. The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words. A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not "Transparent" is called "Opaque". Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only. The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. The "publisher" means any person or entity that distributes copies of the Document to the public. A section "Entitled XYZ" means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as "Acknowledgements", "Dedications", "Endorsements", or "History".) To "Preserve the Title" of such a section when you modify the Document means that it remains a section "Entitled XYZ" according to this definition. The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License. 2. VERBATIM COPYING You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3. You may also lend copies, under the same conditions stated above, and you may publicly display copies. 3. COPYING IN QUANTITY If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects. If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. 4. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version: A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission. B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement. C. State on the Title page the name of the publisher of the Modified Version, as the publisher. D. Preserve all the copyright notices of the Document. E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices. F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below. G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice. H. Include an unaltered copy of this License. I. Preserve the section Entitled "History", Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence. J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission. K. For any section Entitled "Acknowledgements" or "Dedications", Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles. M. Delete any section Entitled "Endorsements". Such a section may not be included in the Modified Version. N. Do not retitle any existing section to be Entitled "Endorsements" or to conflict in title with any Invariant Section. O. Preserve any Warranty Disclaimers. If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles. You may add a section Entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard. You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. 5. COMBINING DOCUMENTS You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. In the combination, you must combine any sections Entitled "History" in the various original documents, forming one section Entitled "History"; likewise combine any sections Entitled "Acknowledgements", and any sections Entitled "Dedications". You must delete all sections Entitled "Endorsements." 6. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. 7. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an "aggregate" if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate. 8. TRANSLATION Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail. If a section in the Document is Entitled "Acknowledgements", "Dedications", or "History", the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title. 9. TERMINATION You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License. However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it. 10. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See . Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Document. 11. RELICENSING "Massive Multiauthor Collaboration Site" (or "MMC Site") means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A "Massive Multiauthor Collaboration" (or "MMC") contained in the site means any set of copyrightable works thus published on the MMC site. "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization. "Incorporate" means to publish or republish a Document, in whole or in part, as part of another Document. An MMC is "eligible for relicensing" if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008. The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing. ADDENDUM: How to use this License for your documents ==================================================== To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page: Copyright (C) YEAR YOUR NAME. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the "with...Texts." line with this: with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.  File: libmicrohttpd.info, Node: Concept Index, Next: Function and Data Index, Prev: GNU-FDL, Up: Top Concept Index ************* [index] * Menu: * ARM: microhttpd-intro. (line 285) * bind, restricting bind: microhttpd-const. (line 330) * bind, restricting bind <1>: microhttpd-const. (line 565) * cipher: microhttpd-const. (line 403) * clock: microhttpd-const. (line 105) * compilation: microhttpd-intro. (line 123) * connection, limiting number of connections: microhttpd-const. (line 209) * connection, limiting number of connections <1>: microhttpd-info daemon. (line 60) * cookie: microhttpd-const. (line 597) * cortex m3: microhttpd-intro. (line 285) * date: microhttpd-const. (line 105) * debugging: microhttpd-const. (line 31) * debugging <1>: microhttpd-const. (line 341) * deprecated: microhttpd-const. (line 61) * DH: microhttpd-const. (line 557) * digest auth: microhttpd-const. (line 442) * digest auth <1>: microhttpd-const. (line 453) * eCos, GNU General Public License with eCos Extension: eCos License. (line 6) * embedded systems: microhttpd-intro. (line 123) * embedded systems <1>: microhttpd-intro. (line 285) * embedded systems <2>: microhttpd-const. (line 105) * embedded systems <3>: microhttpd-const. (line 112) * embedded systems <4>: microhttpd-const. (line 541) * epoll: microhttpd-intro. (line 67) * epoll <1>: microhttpd-const. (line 77) * epoll <2>: microhttpd-info daemon. (line 49) * escaping: microhttpd-const. (line 524) * FD_SETSIZE: microhttpd-const. (line 70) * FD_SETSIZE <1>: microhttpd-const. (line 77) * foreign-function interface: microhttpd-const. (line 502) * HTTP2: microhttpd-response upgrade. (line 6) * IAR: microhttpd-intro. (line 285) * internationalization: microhttpd-const. (line 524) * IPv6: microhttpd-const. (line 45) * IPv6 <1>: microhttpd-const. (line 55) * license: GNU-LGPL. (line 6) * license <1>: eCos License. (line 6) * license <2>: GNU-GPL. (line 6) * license <3>: GNU-FDL. (line 6) * listen: microhttpd-const. (line 112) * listen <1>: microhttpd-const. (line 143) * listen <2>: microhttpd-const. (line 547) * listen <3>: microhttpd-info daemon. (line 43) * logging: microhttpd-const. (line 341) * logging <1>: microhttpd-const. (line 483) * long long: microhttpd-intro. (line 285) * memory: microhttpd-const. (line 201) * memory, limiting memory utilization: microhttpd-const. (line 193) * MHD_LONG_LONG: microhttpd-intro. (line 285) * microhttpd.h: microhttpd-intro. (line 224) * OCSP: microhttpd-const. (line 426) * options: microhttpd-const. (line 502) * performance: microhttpd-intro. (line 91) * performance <1>: microhttpd-const. (line 90) * performance <2>: microhttpd-const. (line 494) * performance <3>: microhttpd-info conn. (line 114) * poll: microhttpd-intro. (line 67) * poll <1>: microhttpd-const. (line 70) * poll <2>: microhttpd-init. (line 74) * portability: microhttpd-intro. (line 123) * portability <1>: microhttpd-intro. (line 224) * POST method: microhttpd-const. (line 601) * POST method <1>: microhttpd-struct. (line 22) * POST method <2>: microhttpd-cb. (line 48) * POST method <3>: microhttpd-post. (line 6) * POST method <4>: microhttpd-post api. (line 6) * proxy: microhttpd-const. (line 112) * PSK: microhttpd-const. (line 436) * pthread: microhttpd-const. (line 541) * PUT method: microhttpd-cb. (line 48) * query string: microhttpd-const. (line 341) * quiesce: microhttpd-const. (line 119) * quiesce <1>: microhttpd-init. (line 51) * random: microhttpd-const. (line 442) * replay attack: microhttpd-const. (line 453) * reusing listening address: microhttpd-const. (line 565) * RFC2817: microhttpd-response upgrade. (line 6) * select: microhttpd-intro. (line 67) * select <1>: microhttpd-const. (line 70) * select <2>: microhttpd-const. (line 77) * select <3>: microhttpd-init. (line 74) * select <4>: microhttpd-init. (line 89) * signals: microhttpd-intro. (line 246) * SNI: microhttpd-const. (line 411) * SNI <1>: microhttpd-const. (line 426) * SSL: microhttpd-const. (line 34) * SSL <1>: microhttpd-const. (line 364) * SSL <2>: microhttpd-const. (line 370) * SSL <3>: microhttpd-const. (line 380) * SSL <4>: microhttpd-const. (line 386) * SSL <5>: microhttpd-const. (line 398) * SSL <6>: microhttpd-const. (line 403) * SSL <7>: microhttpd-const. (line 411) * SSL <8>: microhttpd-const. (line 426) * SSL <9>: microhttpd-const. (line 436) * SSL <10>: microhttpd-const. (line 557) * stack: microhttpd-const. (line 541) * systemd: microhttpd-const. (line 476) * testing: microhttpd-const. (line 319) * thread: microhttpd-const. (line 541) * timeout: microhttpd-const. (line 247) * timeout <1>: microhttpd-inspect. (line 39) * timeout <2>: microhttpd-option conn. (line 6) * TLS: microhttpd-const. (line 34) * TLS <1>: microhttpd-const. (line 364) * TLS <2>: microhttpd-const. (line 370) * TLS <3>: microhttpd-const. (line 380) * TLS <4>: microhttpd-const. (line 386) * TLS <5>: microhttpd-const. (line 398) * TLS <6>: microhttpd-const. (line 403) * TLS <7>: microhttpd-const. (line 411) * TLS <8>: microhttpd-const. (line 426) * TLS <9>: microhttpd-const. (line 436) * TLS <10>: microhttpd-const. (line 557) * upgrade: microhttpd-const. (line 148) * Upgrade: microhttpd-response upgrade. (line 6) * websocket: microhttpd-const. (line 708) * websocket <1>: microhttpd-const. (line 773) * websocket <2>: microhttpd-const. (line 805) * websocket <3>: microhttpd-const. (line 999) * websocket <4>: microhttpd-const. (line 1064) * websocket <5>: microhttpd-const. (line 1122) * websocket <6>: microhttpd-struct. (line 31) * websocket <7>: microhttpd-cb. (line 243) * websocket <8>: microhttpd-cb. (line 259) * websocket <9>: microhttpd-cb. (line 278) * websocket <10>: microhttpd-cb. (line 292) * websocket <11>: microhttpd-websocket handshake. (line 8) * websocket <12>: microhttpd-websocket handshake. (line 24) * websocket <13>: microhttpd-websocket handshake. (line 42) * websocket <14>: microhttpd-websocket handshake. (line 60) * websocket <15>: microhttpd-websocket handshake. (line 80) * websocket <16>: microhttpd-websocket stream. (line 9) * websocket <17>: microhttpd-websocket stream. (line 36) * websocket <18>: microhttpd-websocket stream. (line 91) * websocket <19>: microhttpd-websocket stream. (line 101) * websocket <20>: microhttpd-websocket stream. (line 113) * websocket <21>: microhttpd-websocket decode. (line 10) * websocket <22>: microhttpd-websocket decode. (line 70) * websocket <23>: microhttpd-websocket encode. (line 10) * websocket <24>: microhttpd-websocket encode. (line 70) * websocket <25>: microhttpd-websocket encode. (line 109) * websocket <26>: microhttpd-websocket encode. (line 143) * websocket <27>: microhttpd-websocket encode. (line 178) * websocket <28>: microhttpd-websocket memory. (line 8) * websocket <29>: microhttpd-websocket memory. (line 23) * websocket <30>: microhttpd-websocket memory. (line 42) * WebSockets: microhttpd-response upgrade. (line 6)  File: libmicrohttpd.info, Node: Function and Data Index, Next: Type Index, Prev: Concept Index, Up: Top Function and Data Index *********************** [index] * Menu: * *MHD_ContentReaderCallback: microhttpd-cb. (line 150) * *MHD_ContentReaderFreeCallback: microhttpd-cb. (line 197) * *MHD_RequestCompletedCallback: microhttpd-cb. (line 96) * *MHD_UpgradeHandler: microhttpd-response upgrade. (line 37) * *MHD_WebSocketFreeCallback: microhttpd-cb. (line 277) * *MHD_WebSocketMallocCallback: microhttpd-cb. (line 241) * *MHD_WebSocketRandomNumberGenerator: microhttpd-cb. (line 290) * *MHD_WebSocketReallocCallback: microhttpd-cb. (line 257) * MHD_add_connection: microhttpd-init. (line 115) * MHD_basic_auth_get_username_password3: microhttpd-dauth basic. (line 10) * MHD_create_post_processor: microhttpd-post api. (line 6) * MHD_create_response_from_buffer: microhttpd-response create. (line 104) * MHD_create_response_from_buffer_with_free_callback: microhttpd-response create. (line 125) * MHD_create_response_from_callback: microhttpd-response create. (line 6) * MHD_create_response_from_data: microhttpd-response create. (line 143) * MHD_create_response_from_fd: microhttpd-response create. (line 32) * MHD_create_response_from_fd_at_offset: microhttpd-response create. (line 62) * MHD_create_response_from_iovec: microhttpd-response create. (line 179) * MHD_create_response_from_pipe: microhttpd-response create. (line 50) * MHD_destroy_response: microhttpd-response enqueue. (line 29) * MHD_digest_auth_check: microhttpd-dauth digest. (line 111) * MHD_digest_auth_check_digest: microhttpd-dauth digest. (line 185) * MHD_digest_auth_check_digest2: microhttpd-dauth digest. (line 160) * MHD_digest_auth_check2: microhttpd-dauth digest. (line 86) * MHD_digest_auth_get_username: microhttpd-dauth digest. (line 55) * MHD_DigestAuthResult: microhttpd-dauth digest. (line 62) * MHD_DigestAuthResult <1>: microhttpd-dauth digest. (line 134) * MHD_free: microhttpd-dauth basic. (line 6) * MHD_get_connection_info: microhttpd-info conn. (line 6) * MHD_get_connection_values: microhttpd-requests. (line 6) * MHD_get_daemon_info: microhttpd-info daemon. (line 6) * MHD_get_response_header: microhttpd-response inspect. (line 18) * MHD_get_response_headers: microhttpd-response inspect. (line 6) * MHD_http_unescape: microhttpd-util unescape. (line 6) * MHD_is_feature_supported: microhttpd-util feature. (line 77) * MHD_lookup_connection_value: microhttpd-requests. (line 58) * MHD_lookup_connection_value_n: microhttpd-requests. (line 67) * MHD_queue_basic_auth_fail_response3: microhttpd-dauth basic. (line 19) * MHD_quiesce_daemon: microhttpd-init. (line 50) * MHD_Result: microhttpd-cb. (line 6) * MHD_Result <1>: microhttpd-cb. (line 19) * MHD_Result <2>: microhttpd-cb. (line 116) * MHD_Result <3>: microhttpd-cb. (line 202) * MHD_Result <4>: microhttpd-init. (line 70) * MHD_Result <5>: microhttpd-init. (line 86) * MHD_Result <6>: microhttpd-inspect. (line 6) * MHD_Result <7>: microhttpd-inspect. (line 31) * MHD_Result <8>: microhttpd-inspect. (line 37) * MHD_Result <9>: microhttpd-requests. (line 35) * MHD_Result <10>: microhttpd-response enqueue. (line 6) * MHD_Result <11>: microhttpd-response headers. (line 6) * MHD_Result <12>: microhttpd-response headers. (line 30) * MHD_Result <13>: microhttpd-response headers. (line 47) * MHD_Result <14>: microhttpd-response options. (line 6) * MHD_Result <15>: microhttpd-response upgrade. (line 23) * MHD_Result <16>: microhttpd-response upgrade. (line 91) * MHD_Result <17>: microhttpd-flow. (line 20) * MHD_Result <18>: microhttpd-flow. (line 56) * MHD_Result <19>: microhttpd-dauth digest. (line 208) * MHD_Result <20>: microhttpd-dauth digest. (line 235) * MHD_Result <21>: microhttpd-post api. (line 33) * MHD_Result <22>: microhttpd-post api. (line 52) * MHD_set_connection_option: microhttpd-option conn. (line 6) * MHD_set_panic_func: microhttpd-init. (line 6) * MHD_start_daemon: microhttpd-init. (line 18) * MHD_stop_daemon: microhttpd-init. (line 67) * MHD_websocket_check_connection_header: microhttpd-websocket handshake. (line 21) * MHD_websocket_check_http_version: microhttpd-websocket handshake. (line 6) * MHD_websocket_check_upgrade_header: microhttpd-websocket handshake. (line 39) * MHD_websocket_check_version_header: microhttpd-websocket handshake. (line 57) * MHD_websocket_create_accept_header: microhttpd-websocket handshake. (line 77) * MHD_websocket_decode: microhttpd-websocket decode. (line 6) * MHD_websocket_encode_binary: microhttpd-websocket encode. (line 66) * MHD_websocket_encode_close: microhttpd-websocket encode. (line 174) * MHD_websocket_encode_ping: microhttpd-websocket encode. (line 106) * MHD_websocket_encode_pong: microhttpd-websocket encode. (line 140) * MHD_websocket_encode_text: microhttpd-websocket encode. (line 6) * MHD_websocket_free: microhttpd-websocket memory. (line 40) * MHD_websocket_malloc: microhttpd-websocket memory. (line 6) * MHD_websocket_realloc: microhttpd-websocket memory. (line 21) * MHD_websocket_split_close_reason: microhttpd-websocket decode. (line 66) * MHD_websocket_stream_free: microhttpd-websocket stream. (line 89) * MHD_websocket_stream_init: microhttpd-websocket stream. (line 6) * MHD_websocket_stream_init2: microhttpd-websocket stream. (line 30) * MHD_websocket_stream_invalidate: microhttpd-websocket stream. (line 99) * MHD_websocket_stream_is_valid: microhttpd-websocket stream. (line 111)  File: libmicrohttpd.info, Node: Type Index, Prev: Function and Data Index, Up: Top Type Index ********** [index] * Menu: * MHD_Connection: microhttpd-struct. (line 9) * MHD_CONNECTION_OPTION: microhttpd-option conn. (line 22) * MHD_ConnectionInfo: microhttpd-struct. (line 24) * MHD_ConnectionInfoType: microhttpd-info conn. (line 25) * MHD_Daemon: microhttpd-struct. (line 6) * MHD_DaemonInfo: microhttpd-struct. (line 27) * MHD_DaemonInfoType: microhttpd-info daemon. (line 25) * MHD_DigestAuthAlgorithm: microhttpd-dauth digest. (line 10) * MHD_DigestAuthResult: microhttpd-dauth digest. (line 23) * MHD_FEATURE: microhttpd-util feature. (line 6) * MHD_FLAG: microhttpd-const. (line 6) * MHD_IoVec: microhttpd-struct. (line 18) * MHD_OPTION: microhttpd-const. (line 184) * MHD_OptionItem: microhttpd-const. (line 576) * MHD_PostProcessor: microhttpd-struct. (line 21) * MHD_RequestTerminationCode: microhttpd-const. (line 614) * MHD_Response: microhttpd-struct. (line 15) * MHD_ResponseFlags: microhttpd-const. (line 654) * MHD_ResponseMemoryMode: microhttpd-const. (line 632) * MHD_ResponseOptions: microhttpd-const. (line 699) * MHD_UpgradeAction: microhttpd-response upgrade. (line 103) * MHD_ValueKind: microhttpd-const. (line 589) * MHD_WEBSOCKET_CLOSEREASON: microhttpd-const. (line 998) * MHD_WEBSOCKET_FLAG: microhttpd-const. (line 707) * MHD_WEBSOCKET_FRAGMENTATION: microhttpd-const. (line 772) * MHD_WEBSOCKET_STATUS: microhttpd-const. (line 804) * MHD_WEBSOCKET_UTF8STEP: microhttpd-const. (line 1063) * MHD_WEBSOCKET_VALIDITY: microhttpd-const. (line 1121) * MHD_WebSocketStream: microhttpd-struct. (line 30)  Tag Table: Node: Top814 Node: microhttpd-intro3147 Ref: fig:performance8058 Ref: tbl:supported9030 Node: microhttpd-const17455 Node: microhttpd-struct75236 Node: microhttpd-cb76174 Node: microhttpd-init89473 Node: microhttpd-inspect95351 Node: microhttpd-requests98128 Node: microhttpd-responses102178 Node: microhttpd-response enqueue103377 Ref: microhttpd-response enqueue-Footnote-1105702 Node: microhttpd-response create105937 Node: microhttpd-response headers113947 Node: microhttpd-response options116421 Node: microhttpd-response inspect117304 Node: microhttpd-response upgrade118525 Node: microhttpd-flow123867 Node: microhttpd-dauth127419 Node: microhttpd-dauth basic128979 Node: microhttpd-dauth digest130570 Node: microhttpd-post144181 Node: microhttpd-post api147165 Node: microhttpd-info149833 Node: microhttpd-info daemon150249 Node: microhttpd-info conn153697 Node: microhttpd-option conn158956 Node: microhttpd-util160036 Node: microhttpd-util feature160315 Node: microhttpd-util unescape163901 Node: microhttpd-websocket164545 Node: microhttpd-websocket handshake165264 Node: microhttpd-websocket stream170429 Node: microhttpd-websocket decode175469 Node: microhttpd-websocket encode179967 Node: microhttpd-websocket memory189392 Node: GNU-LGPL191217 Node: eCos License219315 Node: GNU-GPL220706 Node: GNU-FDL239968 Node: Concept Index265037 Node: Function and Data Index278223 Node: Type Index288548  End Tag Table  Local Variables: coding: utf-8 End: libmicrohttpd-1.0.1/doc/stamp-vti0000644000175000017500000000014314566140214012453 @set UPDATED 29 January 2024 @set UPDATED-MONTH January 2024 @set EDITION 1.0.1 @set VERSION 1.0.1 libmicrohttpd-1.0.1/doc/Makefile.am0000644000175000017500000000400214441373361012641 # This Makefile.am is in the public domain dist_man_MANS = libmicrohttpd.3 SUBDIRS = . doxygen if BUILD_EXAMPLES SUBDIRS += examples endif DISTCLEANFILES = \ libmicrohttpd.cps \ libmicrohttpd.dvi \ libmicrohttpd-tutorial.cps \ libmicrohttpd-tutorial.dvi info_TEXINFOS = \ libmicrohttpd.texi \ libmicrohttpd-tutorial.texi microhttpd_TEXINFOS = \ lgpl.texi \ ecos.texi \ gpl-2.0.texi \ fdl-1.3.texi microhttpd_tutorial_TEXINFOS = \ chapters/basicauthentication.inc \ chapters/bibliography.inc \ chapters/exploringrequests.inc \ chapters/hellobrowser.inc \ chapters/introduction.inc \ chapters/largerpost.inc \ chapters/processingpost.inc \ chapters/responseheaders.inc \ chapters/tlsauthentication.inc \ chapters/sessions.inc \ chapters/websocket.inc EXTRA_DIST = \ $(microhttpd_TEXINFOS) $(microhttpd_tutorial_TEXINFOS) \ libmicrohttpd_performance_data.png \ libmicrohttpd_performance_data.eps install-info-local: @echo " $(MKDIR_P) '$(DESTDIR)$(infodir)'"; \ $(MKDIR_P) "$(DESTDIR)$(infodir)" || exit 1; \ echo " $(INSTALL_DATA) libmicrohttpd_performance_data.png '$(DESTDIR)$(infodir)'"; \ $(INSTALL_DATA) '$(srcdir)/libmicrohttpd_performance_data.png' "$(DESTDIR)$(infodir)" || exit 1; install-html-local: @if test -n "$(htmldir)"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/libmicrohttpd.html'"; \ $(MKDIR_P) "$(DESTDIR)$(htmldir)/libmicrohttpd.html" || exit 1; \ echo " $(INSTALL_DATA) libmicrohttpd_performance_data.png '$(DESTDIR)$(htmldir)/libmicrohttpd.html'"; \ $(INSTALL_DATA) '$(srcdir)/libmicrohttpd_performance_data.png' "$(DESTDIR)$(htmldir)/libmicrohttpd.html" || exit 1; \ else : ; fi uninstall-local: @if test -d "$(DESTDIR)$(infodir)"; then \ echo " rm -f '$(DESTDIR)$(infodir)/libmicrohttpd_performance_data.png'"; \ rm -f "$(DESTDIR)$(infodir)/libmicrohttpd_performance_data.png" \ else : ; fi update-stamp: @rm -f '$(srcdir)/stamp-vti' '$(srcdir)/version.texi' && \ $(MAKE) $(AM_MAKEFLAGS) '$(srcdir)/version.texi' .PHONY: update-stamp libmicrohttpd-1.0.1/doc/libmicrohttpd.texi0000644000175000017500000053622614555767064014403 \input texinfo @setfilename libmicrohttpd.info @documentencoding UTF-8 @include version.texi @settitle The GNU libmicrohttpd Reference Manual @c Unify all the indices into concept index. @syncodeindex vr cp @syncodeindex ky cp @syncodeindex pg cp @copying This manual is for GNU libmicrohttpd (version @value{VERSION}, @value{UPDATED}), a library for embedding an HTTP(S) server into C applications. Copyright @copyright{} 2007--2019 Christian Grothoff @quotation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". @end quotation @end copying @dircategory Software libraries @direntry * libmicrohttpd: (libmicrohttpd). Embedded HTTP server library. @end direntry @c @c Titlepage @c @titlepage @title The GNU libmicrohttpd Reference Manual @subtitle Version @value{VERSION} @subtitle @value{UPDATED} @author Marco Maggi (@email{marco.maggi-ipsu@@poste.it}) @author Christian Grothoff (@email{christian@@grothoff.org}) @page @vskip 0pt plus 1filll @insertcopying @end titlepage @summarycontents @contents @c ------------------------------------------------------------ @ifnottex @node Top @top The GNU libmicrohttpd Library @insertcopying @end ifnottex @menu * microhttpd-intro:: Introduction. * microhttpd-const:: Constants. * microhttpd-struct:: Structures type definition. * microhttpd-cb:: Callback functions definition. * microhttpd-init:: Starting and stopping the server. * microhttpd-inspect:: Implementing external @code{select}. * microhttpd-requests:: Handling requests. * microhttpd-responses:: Building responses to requests. * microhttpd-flow:: Flow control. * microhttpd-dauth:: Utilizing Authentication. * microhttpd-post:: Adding a @code{POST} processor. * microhttpd-info:: Obtaining and modifying status information. * microhttpd-util:: Utilities. * microhttpd-websocket:: Websockets. Appendices * GNU-LGPL:: The GNU Lesser General Public License says how you can copy and share almost all of `libmicrohttpd'. * eCos License:: The eCos License says how you can copy and share some parts of `libmicrohttpd'. * GNU-GPL:: The GNU General Public License (with eCos extension) says how you can copy and share some parts of `libmicrohttpd'. * GNU-FDL:: The GNU Free Documentation License says how you can copy and share the documentation of `libmicrohttpd'. Indices * Concept Index:: Index of concepts and programs. * Function and Data Index:: Index of functions, variables and data types. * Type Index:: Index of data types. @end menu @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-intro @chapter Introduction @noindent All symbols defined in the public API start with @code{MHD_}. MHD is a small HTTP daemon library. As such, it does not have any API for logging errors (you can only enable or disable logging to stderr). Also, it may not support all of the HTTP features directly, where applicable, portions of HTTP may have to be handled by clients of the library. The library is supposed to handle everything that it must handle (because the API would not allow clients to do this), such as basic connection management. However, detailed interpretations of headers, such as range requests, are left to the main application. In particular, if an application developer wants to support range requests, he needs to explicitly indicate support in responses and also explicitly parse the range header and generate a response (for example, using the @code{MHD_create_response_from_fd_at_offset} call to serve ranges from a file). MHD does understands headers that control connection management (specifically, @code{Connection: close} and @code{Expect: 100 continue} are understood and handled automatically). @code{Connection: upgrade} is supported by passing control over the socket (or something that behaves like the real socket in the case of TLS) to the application (after sending the desired HTTP response header). MHD largely ignores the semantics of the different HTTP methods, so clients are left to handle those. One exception is that MHD does understand @code{HEAD} and will only send the headers of the response and not the body, even if the client supplied a body. (In fact, clients do need to construct a response with the correct length, even for @code{HEAD} request.) MHD understands @code{POST} data and is able to decode certain formats (at the moment only @code{application/x-www-form-urlencoded} and @code{multipart/form-data}) using the post processor API. The data stream of a POST is also provided directly to the main application, so unsupported encodings could still be processed, just not conveniently by MHD. The header file defines various constants used by the HTTP protocol. This does not mean that MHD actually interprets all of these values. The provided constants are exported as a convenience for users of the library. MHD does not verify that transmitted HTTP headers are part of the standard specification; users of the library are free to define their own extensions of the HTTP standard and use those with MHD. All functions are guaranteed to be completely reentrant and thread-safe. MHD checks for allocation failures and tries to recover gracefully (for example, by closing the connection). Additionally, clients can specify resource limits on the overall number of connections, number of connections per IP address and memory used per connection to avoid resource exhaustion. @section Scope MHD is currently used in a wide range of implementations. Examples based on reports we've received from developers include: @itemize @item Embedded HTTP server on a cortex M3 (128 KB code space) @item Large-scale multimedia server (reportedly serving at the simulator limit of 7.5 GB/s) @item Administrative console (via HTTP/HTTPS) for network appliances @c If you have other interesting examples, please let us know @end itemize @section Thread modes and event loops @cindex poll @cindex epoll @cindex select MHD supports four basic thread modes and up to three event loop styles. The four basic thread modes are external sockets polling (MHD creates no threads, event loop is fully managed by the application), internal polling (MHD creates one thread for all connections), polling in thread pool (MHD creates a thread pool which is used to process all connections) and thread-per-connection (MHD creates one thread for listen sockets and then one thread per accepted connection). These thread modes are then combined with the evet loop styles (polling function type). MHD support select, poll and epoll. select is available on all platforms, epoll and poll may not be available on some platforms. Note that it is possible to combine MHD using epoll with an external select-based event loop. The default (if no other option is passed) is ``external select''. The highest performance can typically be obtained with a thread pool using @code{epoll}. Apache Benchmark (ab) was used to compare the performance of @code{select} and @code{epoll} when using a thread pool and a large number of connections. @ref{fig:performance} shows the resulting plot from the @code{benchmark.c} example, which measures the latency between an incoming request and the completion of the transmission of the response. In this setting, the @code{epoll} thread pool with four threads was able to handle more than 45,000 connections per second on loopback (with Apache Benchmark running three processes on the same machine). @cindex performance @float Figure,fig:performance @image{libmicrohttpd_performance_data,400pt,300pt,Data,.png} @caption{Performance measurements for select vs. epoll (with thread-pool).} @end float Not all combinations of thread modes and event loop styles are supported. This is partially to keep the API simple, and partially because some combinations simply make no sense as others are strictly superior. Note that the choice of style depends first of all on the application logic, and then on the performance requirements. Applications that perform a blocking operation while handling a request within the callbacks from MHD must use a thread per connection. This is typically rather costly. Applications that do not support threads or that must run on embedded devices without thread-support must use the external mode. Using @code{epoll} is only supported on some platform, thus portable applications must at least have a fallback option available. @ref{tbl:supported} lists the sane combinations. @float Table,tbl:supported @multitable {@b{thread-per-connection}} {@b{select}} {@b{poll}} {@b{epoll}} @item @tab @b{select} @tab @b{poll} @tab @b{epoll} @item @b{external} @tab yes @tab no @tab yes @item @b{internal} @tab yes @tab yes @tab yes @item @b{thread pool} @tab yes @tab yes @tab yes @item @b{thread-per-connection} @tab yes @tab yes @tab no @end multitable @caption{Supported combinations of event styles and thread modes.} @end float @section Compiling GNU libmicrohttpd @cindex compilation @cindex embedded systems @cindex portability MHD uses the standard GNU system where the usual build process involves running @verbatim $ ./configure $ make $ make install @end verbatim MHD supports various options to be given to configure to tailor the binary to a specific situation. Note that some of these options will remove portions of the MHD code that are required for binary-compatibility. They should only be used on embedded systems with tight resource constraints and no concerns about library versioning. Standard distributions including MHD are expected to always ship with all features enabled, otherwise unexpected incompatibilities can arise! Here is a list of MHD-specific options that can be given to configure (canonical configure options such as ``--prefix'' are also supported, for a full list of options run ``./configure --help''): @table @code @item ``--disable-curl'' disable running testcases using libcurl @item ``--disable-largefile'' disable support for 64-bit files @item ``--disable-messages'' disable logging of error messages (smaller binary size, not so much fun for debugging) @item ``--disable-https'' disable HTTPS support, even if GNUtls is found; this option must be used if eCOS license is desired as an option (in all cases the resulting binary falls under a GNU LGPL-only license) @item ``--disable-postprocessor'' do not include the post processor API (results in binary incompatibility) @item ``--disable-dauth'' do not include the authentication APIs (results in binary incompatibility) @item ``--disable-httpupgrade'' do not build code for HTTP ``Upgrade'' (smaller binary size, binary incompatible library) @item ``--disable-epoll'' do not include epoll support, even if it supported (minimally smaller binary size, good for portability testing) @item ``--enable-coverage'' set flags for analysis of code-coverage with gcc/gcov (results in slow, large binaries) @item ``--with-threads=posix,w32,none,auto'' sets threading library to use. With use ``none'' to not support threads. In this case, MHD will only support the ``external'' threading modes and not perform any locking of data structures! Use @code{MHD_is_feature_supported(MHD_FEATURE_THREADS)} to test if threads are available. Default is ``auto''. @item ``--with-gcrypt=PATH'' specifies path to libgcrypt installation @item ``--with-gnutls=PATH'' specifies path to libgnutls installation @end table To cross-compile MHD for Android, install the Android NDK and use: @verbatim ./configure --target=arm-linux-androideabi --host=arm-linux-androideabi --disable-doc --disable-examples make @end verbatim Similar build commands should work for cross-compilation to other platforms. Note that you may have to first cross-compile GnuTLS to get MHD with TLS support. @section Validity of pointers MHD will give applications access to its internal data structures via pointers via arguments and return values from its API. This creates the question as to how long those pointers are assured to stay valid. Most MHD data structures are associated with the connection of an HTTP client. Thus, pointers associated with a connection are typically valid until the connection is finished, at which point MHD will call the @code{MHD_RequestCompletedCallback} if one is registered. Applications that have such a callback registered may assume that keys and values from the @code{MHD_KeyValueIterator}, return values from @code{MHD_lookup_connection_value} and the @code{url}, @code{method} and @code{version} arguments to the @code{MHD_AccessHandlerCallback} will remain valid until the respective @code{MHD_RequestCompletedCallback} is invoked. In contrast, the @code{upload_data} argument of @code{MHD_RequestCompletedCallback} as well as all pointers from the @code{MHD_PostDataIterator} are only valid for the duration of the callback. Pointers returned from @code{MHD_get_response_header} are valid as long as the response itself is valid. @section Including the microhttpd.h header @cindex portability @cindex microhttpd.h Ideally, before including "microhttpd.h" you should add the necessary includes to define the @code{va_list}, @code{size_t}, @code{ssize_t}, @code{intptr_t}, @code{off_t}, @code{uint8_t}, @code{uint16_t}, @code{int32_t}, @code{uint32_t}, @code{int64_t}, @code{uint64_t}, @code{fd_set}, @code{socklen_t} and @code{struct sockaddr} data types. Which specific headers are needed may depend on your platform and your build system might include some tests to provide you with the necessary conditional operations. For possible suggestions consult @code{platform.h} and @code{configure.ac} in the MHD distribution. Once you have ensured that you manually (!) included the right headers for your platform before "microhttpd.h", you should also add a line with @code{#define MHD_PLATFORM_H} which will prevent the "microhttpd.h" header from trying (and, depending on your platform, failing) to include the right headers. If you do not define MHD_PLATFORM_H, the "microhttpd.h" header will automatically include headers needed on GNU/Linux systems (possibly causing problems when porting to other platforms). @section SIGPIPE @cindex signals MHD does not install a signal handler for SIGPIPE. On platforms where this is possible (such as GNU/Linux), it disables SIGPIPE for its I/O operations (by passing MSG_NOSIGNAL or similar). On other platforms, SIGPIPE signals may be generated from network operations by MHD and will cause the process to die unless the developer explicitly installs a signal handler for SIGPIPE. Hence portable code using MHD must install a SIGPIPE handler or explicitly block the SIGPIPE signal. MHD does not do so in order to avoid messing with other parts of the application that may need to handle SIGPIPE in a particular way. You can make your application handle SIGPIPE by calling the following function in @code{main}: @verbatim static void catcher (int sig) { } static void ignore_sigpipe () { struct sigaction oldsig; struct sigaction sig; sig.sa_handler = &catcher; sigemptyset (&sig.sa_mask); #ifdef SA_INTERRUPT sig.sa_flags = SA_INTERRUPT; /* SunOS */ #else sig.sa_flags = SA_RESTART; #endif if (0 != sigaction (SIGPIPE, &sig, &oldsig)) fprintf (stderr, "Failed to install SIGPIPE handler: %s\n", strerror (errno)); } @end verbatim @section MHD_UNSIGNED_LONG_LONG @cindex long long @cindex MHD_LONG_LONG @cindex IAR @cindex ARM @cindex cortex m3 @cindex embedded systems Some platforms do not support @code{long long}. Hence MHD defines a macro @code{MHD_UNSIGNED LONG_LONG} which will default to @code{unsigned long long}. For standard desktop operating systems, this is all you need to know. However, if your platform does not support @code{unsigned long long}, you should change "platform.h" to define @code{MHD_LONG_LONG} and @code{MHD_UNSIGNED_LONG_LONG} to an appropriate alternative type and also define @code{MHD_LONG_LONG_PRINTF} and @code{MHD_UNSIGNED_LONG_LONG_PRINTF} to the corresponding format string for printing such a data type. Note that the ``signed'' versions are deprecated. Also, for historical reasons, @code{MHD_LONG_LONG_PRINTF} is without the percent sign, whereas @code{MHD_UNSIGNED_LONG_LONG_PRINTF} is with the percent sign. Newly written code should only use the unsigned versions. However, you need to define both in "platform.h" if you need to change the definition for the specific platform. @section Portability to W32 libmicrohttpd in general ported well to W32. Most libmicrohttpd features are supported. W32 do not support some functions, like epoll and corresponding MHD features are not available on W32. @section Portability to z/OS To compile MHD on z/OS, extract the archive and run @verbatim iconv -f UTF-8 -t IBM-1047 contrib/ascebc > /tmp/ascebc.sh chmod +x /tmp/ascebc.sh for n in `find * -type f` do /tmp/ascebc.sh $n done @end verbatim to convert all source files to EBCDIC. Note that you must run @code{configure} from the directory where the configure script is located. Otherwise, configure will fail to find the @code{contrib/xcc} script (which is a wrapper around the z/OS c89 compiler). @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-const @chapter Constants @deftp {Enumeration} MHD_FLAG Options for the MHD daemon. Note that MHD will run automatically in background thread(s) only if @code{MHD_USE_INTERNAL_POLLING_THREAD} is used. Otherwise caller (application) must use @code{MHD_run} or @code{MHD_run_from_select} to have MHD processed network connections and data. Starting the daemon may also fail if a particular option is not implemented or not supported on the target platform (i.e. no support for @acronym{TLS}, threads or IPv6). TLS support generally depends on options given during MHD compilation. @table @code @item MHD_NO_FLAG No options selected. @item MHD_USE_ERROR_LOG If this flag is used, the library should print error messages and warnings to stderr (or to custom error printer if it's specified by options). Note that for this run-time option to have any effect, MHD needs to be compiled with messages enabled. This is done by default except you ran configure with the @code{--disable-messages} flag set. @item MHD_USE_DEBUG @cindex debugging Currently the same as @code{MHD_USE_ERROR_LOG}. @item MHD_USE_TLS @cindex TLS @cindex SSL Run in HTTPS-mode. If you specify @code{MHD_USE_TLS} and MHD was compiled without SSL support, @code{MHD_start_daemon} will return NULL. @item MHD_USE_THREAD_PER_CONNECTION Run using one thread per connection. @item MHD_USE_INTERNAL_POLLING_THREAD Run using an internal thread doing @code{SELECT}. @item MHD_USE_IPv6 @cindex IPv6 Run using the IPv6 protocol (otherwise, MHD will just support IPv4). If you specify @code{MHD_USE_IPV6} and the local platform does not support it, @code{MHD_start_daemon} will return NULL. If you want MHD to support IPv4 and IPv6 using a single socket, pass MHD_USE_DUAL_STACK, otherwise, if you only pass this option, MHD will try to bind to IPv6-only (resulting in no IPv4 support). @item MHD_USE_DUAL_STACK @cindex IPv6 Use a single socket for IPv4 and IPv6. Note that this will mean that IPv4 addresses are returned by MHD in the IPv6-mapped format (the 'struct sockaddr_in6' format will be used for IPv4 and IPv6). @item MHD_USE_PEDANTIC_CHECKS @cindex deprecated Deprecated (use @code{MHD_OPTION_STRICT_FOR_CLIENT}). Be pedantic about the protocol. Specifically, at the moment, this flag causes MHD to reject HTTP 1.1 connections without a @code{Host} header. This is required by the standard, but of course in violation of the ``be as liberal as possible in what you accept'' norm. It is recommended to turn this @strong{ON} if you are testing clients against MHD, and @strong{OFF} in production. @item MHD_USE_POLL @cindex FD_SETSIZE @cindex poll @cindex select Use @code{poll()} instead of @code{select()}. This allows sockets with descriptors @code{>= FD_SETSIZE}. This option currently only works in conjunction with @code{MHD_USE_INTERNAL_POLLING_THREAD} (at this point). If you specify @code{MHD_USE_POLL} and the local platform does not support it, @code{MHD_start_daemon} will return NULL. @item MHD_USE_EPOLL @cindex FD_SETSIZE @cindex epoll @cindex select Use @code{epoll()} instead of @code{poll()} or @code{select()}. This allows sockets with descriptors @code{>= FD_SETSIZE}. This option is only available on some systems and does not work in conjunction with @code{MHD_USE_THREAD_PER_CONNECTION} (at this point). If you specify @code{MHD_USE_EPOLL} and the local platform does not support it, @code{MHD_start_daemon} will return NULL. Using @code{epoll()} instead of @code{select()} or @code{poll()} can in some situations result in significantly higher performance as the system call has fundamentally lower complexity (O(1) for @code{epoll()} vs. O(n) for @code{select()}/@code{poll()} where n is the number of open connections). @item MHD_USE_TURBO @cindex performance Enable optimizations to aggressively improve performance. Currently, the optimizations this option enables are based on opportunistic reads and writes. Basically, MHD will simply try to read or write or accept on a socket before checking that the socket is ready for IO using the event loop mechanism. As the sockets are non-blocking, this may fail (at a loss of performance), but generally MHD does this in situations where the operation is likely to succeed, in which case performance is improved. Setting the flag should generally be safe (even though the code is slightly more experimental). You may want to benchmark your application to see if this makes any difference for you. @item MHD_USE_SUPPRESS_DATE_NO_CLOCK @cindex date @cindex clock @cindex embedded systems Suppress (automatically) adding the 'Date:' header to HTTP responses. This option should ONLY be used on systems that do not have a clock and that DO provide other mechanisms for cache control. See also RFC 2616, section 14.18 (exception 3). @item MHD_USE_NO_LISTEN_SOCKET @cindex listen @cindex proxy @cindex embedded systems Run the HTTP server without any listen socket. This option only makes sense if @code{MHD_add_connection} is going to be used exclusively to connect HTTP clients to the HTTP server. This option is incompatible with using a thread pool; if it is used, @code{MHD_OPTION_THREAD_POOL_SIZE} is ignored. @item MHD_USE_ITC @cindex quiesce Force MHD to use a signal inter-thread communication channel to notify the event loop (of threads) of our shutdown and other events. This is required if an application uses @code{MHD_USE_INTERNAL_POLLING_THREAD} and then performs @code{MHD_quiesce_daemon} (which eliminates our ability to signal termination via the listen socket). In these modes, @code{MHD_quiesce_daemon} will fail if this option was not set. Also, use of this option is automatic (as in, you do not even have to specify it), if @code{MHD_USE_NO_LISTEN_SOCKET} is specified. In "external" select mode, this option is always simply ignored. Using this option also guarantees that MHD will not call @code{shutdown()} on the listen socket, which means a parent process can continue to use the socket. @item MHD_ALLOW_SUSPEND_RESUME Enables using @code{MHD_suspend_connection} and @code{MHD_resume_connection}, as performing these calls requires some additional inter-thred communication channels to be created, and code not using these calls should not pay the cost. @item MHD_USE_TCP_FASTOPEN @cindex listen Enable TCP_FASTOPEN on the listen socket. TCP_FASTOPEN is currently supported on Linux >= 3.6. On other systems using this option with cause @code{MHD_start_daemon} to fail. @item MHD_ALLOW_UPGRADE @cindex upgrade This option must be set if you want to upgrade connections (via ``101 Switching Protocols'' responses). This requires MHD to allocate additional resources, and hence we require this special flag so we only use the resources that are really needed. @item MHD_USE_AUTO Automatically select best event loop style (polling function) depending on requested mode by other MHD flags and functions available on platform. If application doesn't have requirements for any specific polling function, it's recommended to use this flag. This flag is very convenient for multiplatform applications. @item MHD_USE_POST_HANDSHAKE_AUTH_SUPPORT Tell the TLS library to support post handshake client authentication. Only useful in combination with @code{MHD_USE_TLS}. This option will only work if the underlying TLS library supports it (i.e. GnuTLS after 3.6.3). If the TLS library does not support it, MHD may ignore the option and proceed without supporting this features. @item MHD_USE_INSECURE_TLS_EARLY_DATA Tell the TLS library to support TLS v1.3 early data (0-RTT) with the resulting security drawbacks. Only enable this if you really know what you are doing. MHD currently does NOT enforce that this only affects GET requests! You have been warned. This option will only work if the underlying TLS library supports it (i.e. GnuTLS after 3.6.3). If the TLS library does not support it, MHD may ignore the option and proceed without supporting this features. @end table @end deftp @deftp {Enumeration} MHD_OPTION MHD options. Passed in the varargs portion of @code{MHD_start_daemon()}. @table @code @item MHD_OPTION_END No more options / last option. This is used to terminate the VARARGs list. @item MHD_OPTION_CONNECTION_MEMORY_LIMIT @cindex memory, limiting memory utilization Maximum memory size per connection (followed by a @code{size_t}). The default is 32 kB (32*1024 bytes) as defined by the internal constant @code{MHD_POOL_SIZE_DEFAULT}. Values above 128k are unlikely to result in much benefit, as half of the memory will be typically used for IO, and TCP buffers are unlikely to support window sizes above 64k on most systems. @item MHD_OPTION_CONNECTION_MEMORY_INCREMENT @cindex memory Increment to use for growing the read buffer (followed by a @code{size_t}). The default is 1024 (bytes). Increasing this value will make MHD use memory for reading more aggressively, which can reduce the number of @code{recvfrom} calls but may increase the number of @code{sendto} calls. The given value must fit within MHD_OPTION_CONNECTION_MEMORY_LIMIT. @item MHD_OPTION_CONNECTION_LIMIT @cindex connection, limiting number of connections Maximum number of concurrent connections to accept (followed by an @code{unsigned int}). The default is @code{FD_SETSIZE - 4} (the maximum number of file descriptors supported by @code{select} minus four for @code{stdin}, @code{stdout}, @code{stderr} and the server socket). In other words, the default is as large as possible. If the connection limit is reached, MHD's behavior depends a bit on other options. If @code{MHD_USE_ITC} was given, MHD will stop accepting connections on the listen socket. This will cause the operating system to queue connections (up to the @code{listen()} limit) above the connection limit. Those connections will be held until MHD is done processing at least one of the active connections. If @code{MHD_USE_ITC} is not set, then MHD will continue to @code{accept()} and immediately @code{close()} these connections. Note that if you set a low connection limit, you can easily get into trouble with browsers doing request pipelining. For example, if your connection limit is ``1'', a browser may open a first connection to access your ``index.html'' file, keep it open but use a second connection to retrieve CSS files, images and the like. In fact, modern browsers are typically by default configured for up to 15 parallel connections to a single server. If this happens, MHD will refuse to even accept the second connection until the first connection is closed --- which does not happen until timeout. As a result, the browser will fail to render the page and seem to hang. If you expect your server to operate close to the connection limit, you should first consider using a lower timeout value and also possibly add a ``Connection: close'' header to your response to ensure that request pipelining is not used and connections are closed immediately after the request has completed: @example MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, "close"); @end example @item MHD_OPTION_CONNECTION_TIMEOUT @cindex timeout After how many seconds of inactivity should a connection automatically be timed out? (followed by an @code{unsigned int}; use zero for no timeout). The default is zero (no timeout). @item MHD_OPTION_NOTIFY_COMPLETED Register a function that should be called whenever a request has been completed (this can be used for application-specific clean up). Requests that have never been presented to the application (via @code{MHD_AccessHandlerCallback()}) will not result in notifications. This option should be followed by @strong{TWO} pointers. First a pointer to a function of type @code{MHD_RequestCompletedCallback()} and second a pointer to a closure to pass to the request completed callback. The second pointer maybe @code{NULL}. @item MHD_OPTION_NOTIFY_CONNECTION Register a function that should be called when the TCP connection to a client is opened or closed. The registered callback is called twice per TCP connection, with @code{MHD_CONNECTION_NOTIFY_STARTED} and @code{MHD_CONNECTION_NOTIFY_CLOSED} respectively. An additional argument can be used to store TCP connection specific information, which can be retrieved using @code{MHD_CONNECTION_INFO_SOCKET_CONTEXT} during the lifetime of the TCP connection. Note @code{MHD_OPTION_NOTIFY_COMPLETED} and the @code{req_cls} argument to the @code{MHD_AccessHandlerCallback} are per HTTP request (and there can be multiple HTTP requests per TCP connection). This option should be followed by @strong{TWO} pointers. First a pointer to a function of type @code{MHD_NotifyConnectionCallback()} and second a pointer to a closure to pass to the request completed callback. The second pointer maybe @code{NULL}. @item MHD_OPTION_PER_IP_CONNECTION_LIMIT Limit on the number of (concurrent) connections made to the server from the same IP address. Can be used to prevent one IP from taking over all of the allowed connections. If the same IP tries to establish more than the specified number of connections, they will be immediately rejected. The option should be followed by an @code{unsigned int}. The default is zero, which means no limit on the number of connections from the same IP address. @item MHD_OPTION_LISTEN_BACKLOG_SIZE Set the size of the @code{listen()} back log queue of the TCP socket. Takes an @code{unsigned int} as the argument. Default is the platform-specific value of @code{SOMAXCONN}. @item MHD_OPTION_STRICT_FOR_CLIENT Specify how strict we should enforce the HTTP protocol. Takes an @code{int} as the argument. Default is zero. If set to 1, MHD will be strict about the protocol. Specifically, at the moment, this flag uses MHD to reject HTTP 1.1 connections without a "Host" header. This is required by the standard, but of course in violation of the "be as liberal as possible in what you accept" norm. It is recommended to set this to 1 if you are testing clients against MHD, and 0 in production. If set to -1 MHD will be permissive about the protocol, allowing slight deviations that are technically not allowed by the RFC. Specifically, at the moment, this flag causes MHD to allow spaces in header field names. This is disallowed by the standard. It is not recommended to set it to -1 on publicly available servers as it may potentially lower level of protection. @item MHD_OPTION_SERVER_INSANITY @cindex testing Allows the application to disable certain sanity precautions in MHD. With these, the client can break the HTTP protocol, so this should never be used in production. The options are, however, useful for testing HTTP clients against "broken" server implementations. This argument must be followed by an @code{unsigned int}, corresponding to an @code{enum MHD_DisableSanityCheck}. Right now, no sanity checks can be disabled. @item MHD_OPTION_SOCK_ADDR @cindex bind, restricting bind Bind daemon to the supplied socket address. This option should be followed by a @code{struct sockaddr *}. If @code{MHD_USE_IPv6} is specified, the @code{struct sockaddr*} should point to a @code{struct sockaddr_in6}, otherwise to a @code{struct sockaddr_in}. If this option is not specified, the daemon will listen to incoming connections from anywhere. If you use this option, the 'port' argument from @code{MHD_start_daemon} is ignored and the port from the given @code{struct sockaddr *} will be used instead. @item MHD_OPTION_URI_LOG_CALLBACK @cindex debugging @cindex logging @cindex query string Specify a function that should be called before parsing the URI from the client. The specified callback function can be used for processing the URI (including the options) before it is parsed. The URI after parsing will no longer contain the options, which maybe inconvenient for logging. This option should be followed by two arguments, the first one must be of the form @example void * my_logger(void * cls, const char * uri, struct MHD_Connection *con) @end example where the return value will be passed as @code{*req_cls} in calls to the @code{MHD_AccessHandlerCallback} when this request is processed later; returning a value of @code{NULL} has no special significance; (however, note that if you return non-@code{NULL}, you can no longer rely on the first call to the access handler having @code{NULL == *req_cls} on entry) @code{cls} will be set to the second argument following MHD_OPTION_URI_LOG_CALLBACK. Finally, @code{uri} will be the 0-terminated URI of the request. Note that during the time of this call, most of the connection's state is not initialized (as we have not yet parsed he headers). However, information about the connecting client (IP, socket) is available. @item MHD_OPTION_HTTPS_MEM_KEY @cindex SSL @cindex TLS Memory pointer to the private key to be used by the HTTPS daemon. This option should be followed by an "const char*" argument. This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_CERT'. @item MHD_OPTION_HTTPS_KEY_PASSWORD @cindex SSL @cindex TLS Memory pointer to the password that decrypts the private key to be used by the HTTPS daemon. This option should be followed by an "const char*" argument. This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_KEY'. The password (or passphrase) is only used immediately during @code{MHD_start_daemon()}. Thus, the application may want to erase it from memory afterwards for additional security. @item MHD_OPTION_HTTPS_MEM_CERT @cindex SSL @cindex TLS Memory pointer to the certificate to be used by the HTTPS daemon. This option should be followed by an "const char*" argument. This should be used in conjunction with 'MHD_OPTION_HTTPS_MEM_KEY'. @item MHD_OPTION_HTTPS_MEM_TRUST @cindex SSL @cindex TLS Memory pointer to the CA certificate to be used by the HTTPS daemon to authenticate and trust clients certificates. This option should be followed by an "const char*" argument. The presence of this option activates the request of certificate to the client. The request to the client is marked optional, and it is the responsibility of the server to check the presence of the certificate if needed. Note that most browsers will only present a client certificate only if they have one matching the specified CA, not sending any certificate otherwise. @item MHD_OPTION_HTTPS_CRED_TYPE @cindex SSL @cindex TLS Daemon credentials type. Either certificate or anonymous, this option should be followed by one of the values listed in "enum gnutls_credentials_type_t". @item MHD_OPTION_HTTPS_PRIORITIES @cindex SSL @cindex TLS @cindex cipher SSL/TLS protocol version and ciphers. This option must be followed by an "const char *" argument specifying the SSL/TLS protocol versions and ciphers that are acceptable for the application. The string is passed unchanged to gnutls_priority_init. If this option is not specified, ``NORMAL'' is used. @item MHD_OPTION_HTTPS_CERT_CALLBACK @cindex SSL @cindex TLS @cindex SNI Use a callback to determine which X.509 certificate should be used for a given HTTPS connection. This option should be followed by a argument of type "gnutls_certificate_retrieve_function2 *". This option provides an alternative to MHD_OPTION_HTTPS_MEM_KEY and MHD_OPTION_HTTPS_MEM_CERT. You must use this version if multiple domains are to be hosted at the same IP address using TLS's Server Name Indication (SNI) extension. In this case, the callback is expected to select the correct certificate based on the SNI information provided. The callback is expected to access the SNI data using gnutls_server_name_get(). Using this option requires GnuTLS 3.0 or higher. @item MHD_OPTION_HTTPS_CERT_CALLBACK2 @cindex SSL @cindex TLS @cindex SNI @cindex OCSP Use a callback to determine which X.509 certificate should be used for a given HTTPS connection. This option should be followed by a argument of type `gnutls_certificate_retrieve_function3 *`. This option provides an alternative/extension to #MHD_OPTION_HTTPS_CERT_CALLBACK. You must use this version if you want to use OCSP stapling. Using this option requires GnuTLS 3.6.3 or higher. @item MHD_OPTION_GNUTLS_PSK_CRED_HANDLER @cindex SSL @cindex TLS @cindex PSK Use pre-shared key for TLS credentials. Pass a pointer to callback of type @code{MHD_PskServerCredentialsCallback} and a closure. The function will be called to retrieve the shared key for a given username. @item MHD_OPTION_DIGEST_AUTH_RANDOM @cindex digest auth @cindex random Digest Authentication nonce's seed. This option should be followed by two arguments. First an integer of type "size_t" which specifies the size of the buffer pointed to by the second argument in bytes. Note that the application must ensure that the buffer of the second argument remains allocated and unmodified while the daemon is running. For security, you SHOULD provide a fresh random nonce when using MHD with Digest Authentication. @item MHD_OPTION_NONCE_NC_SIZE @cindex digest auth @cindex replay attack Size of an array of nonce and nonce counter map. This option must be followed by an "unsigned int" argument that have the size (number of elements) of a map of a nonce and a nonce-counter. If this option is not specified, a default value of 4 will be used (which might be too small for servers handling many requests). If you do not use digest authentication at all, you can specify a value of zero to save some memory. You should calculate the value of NC_SIZE based on the number of connections per second multiplied by your expected session duration plus a factor of about two for hash table collisions. For example, if you expect 100 digest-authenticated connections per second and the average user to stay on your site for 5 minutes, then you likely need a value of about 60000. On the other hand, if you can only expect only 10 digest-authenticated connections per second, tolerate browsers getting a fresh nonce for each request and expect a HTTP request latency of 250 ms, then a value of about 5 should be fine. @item MHD_OPTION_LISTEN_SOCKET @cindex systemd Listen socket to use. Pass a listen socket for MHD to use (systemd-style). If this option is used, MHD will not open its own listen socket(s). The argument passed must be of type "int" and refer to an existing socket that has been bound to a port and is listening. @item MHD_OPTION_EXTERNAL_LOGGER @cindex logging Use the given function for logging error messages. This option must be followed by two arguments; the first must be a pointer to a function of type 'void fun(void * arg, const char * fmt, va_list ap)' and the second a pointer of type 'void*' which will be passed as the "arg" argument to "fun". Note that MHD will not generate any log messages without the MHD_USE_ERROR_LOG flag set and if MHD was compiled with the "--disable-messages" flag. @item MHD_OPTION_THREAD_POOL_SIZE @cindex performance Number (unsigned int) of threads in thread pool. Enable thread pooling by setting this value to to something greater than 1. Currently, thread mode must be MHD_USE_INTERNAL_POLLING_THREAD if thread pooling is enabled (@code{MHD_start_daemon} returns @code{NULL} for an unsupported thread mode). @item MHD_OPTION_ARRAY @cindex options @cindex foreign-function interface This option can be used for initializing MHD using options from an array. A common use for this is writing an FFI for MHD. The actual options given are in an array of 'struct MHD_OptionItem', so this option requires a single argument of type 'struct MHD_OptionItem'. The array must be terminated with an entry @code{MHD_OPTION_END}. An example for code using MHD_OPTION_ARRAY is: @example struct MHD_OptionItem ops[] = @{ @{ MHD_OPTION_CONNECTION_LIMIT, 100, NULL @}, @{ MHD_OPTION_CONNECTION_TIMEOUT, 10, NULL @}, @{ MHD_OPTION_END, 0, NULL @} @}; d = MHD_start_daemon(0, 8080, NULL, NULL, dh, NULL, MHD_OPTION_ARRAY, ops, MHD_OPTION_END); @end example For options that expect a single pointer argument, the second member of the @code{struct MHD_OptionItem} is ignored. For options that expect two pointer arguments, the first argument must be cast to @code{intptr_t}. @item MHD_OPTION_UNESCAPE_CALLBACK @cindex internationalization @cindex escaping Specify a function that should be called for unescaping escape sequences in URIs and URI arguments. Note that this function will NOT be used by the MHD_PostProcessor. If this option is not specified, the default method will be used which decodes escape sequences of the form "%HH". This option should be followed by two arguments, the first one must be of the form @example size_t my_unescaper(void * cls, struct MHD_Connection *c, char *s) @end example where the return value must be @code{strlen(s)} and @code{s} should be updated. Note that the unescape function must not lengthen @code{s} (the result must be shorter than the input and still be 0-terminated). @code{cls} will be set to the second argument following MHD_OPTION_UNESCAPE_CALLBACK. @item MHD_OPTION_THREAD_STACK_SIZE @cindex stack @cindex thread @cindex pthread @cindex embedded systems Maximum stack size for threads created by MHD. This option must be followed by a @code{size_t}). Not specifying this option or using a value of zero means using the system default (which is likely to differ based on your platform). @item MHD_OPTION_TCP_FASTQUEUE_QUEUE_SIZE @cindex listen When the flag @code{MHD_USE_TCP_FASTOPEN} is used, this option sets the connection handshake queue size for the TCP FASTOPEN connections. Note that a TCP FASTOPEN connection handshake occupies more resources than a TCP handshake as the SYN packets also contain DATA which is kept in the associate state until handshake is completed. If this option is not given the queue size is set to a default value of 10. This option must be followed by a @code{unsigned int}. @item MHD_OPTION_HTTPS_MEM_DHPARAMS @cindex TLS @cindex SSL @cindex DH Memory pointer for the Diffie-Hellman parameters (dh.pem) to be used by the HTTPS daemon for key exchange. This option must be followed by a @code{const char *} argument. The argument would be a zero-terminated string with a PEM encoded PKCS3 DH parameters structure suitable for passing to @code{gnutls_dh_parms_import_pkcs3}. @item MHD_OPTION_LISTENING_ADDRESS_REUSE @cindex bind, restricting bind @cindex reusing listening address This option must be followed by a @code{unsigned int} argument. If this option is present and true (nonzero) parameter is given, allow reusing the address:port of the listening socket (using @code{SO_REUSEPORT} on most platforms, and @code{SO_REUSEADDR} on Windows). If a false (zero) parameter is given, disallow reusing the the address:port of the listening socket (this usually requires no special action, but @code{SO_EXCLUSIVEADDRUSE} is needed on Windows). If this option is not present @code{SO_REUSEADDR} is used on all platforms except Windows so reusing of address:port is disallowed. @end table @end deftp @deftp {C Struct} MHD_OptionItem Entry in an MHD_OPTION_ARRAY. See the @code{MHD_OPTION_ARRAY} option argument for its use. The @code{option} member is used to specify which option is specified in the array. The other members specify the respective argument. Note that for options taking only a single pointer, the @code{ptr_value} member should be set. For options taking two pointer arguments, the first pointer must be cast to @code{intptr_t} and both the @code{value} and the @code{ptr_value} members should be used to pass the two pointers. @end deftp @deftp {Enumeration} MHD_ValueKind The @code{MHD_ValueKind} specifies the source of the key-value pairs in the HTTP protocol. @table @code @item MHD_HEADER_KIND HTTP header. @item MHD_COOKIE_KIND @cindex cookie Cookies. Note that the original HTTP header containing the cookie(s) will still be available and intact. @item MHD_POSTDATA_KIND @cindex POST method @code{POST} data. This is available only if a content encoding supported by MHD is used (currently only @acronym{URL} encoding), and only if the posted content fits within the available memory pool. Note that in that case, the upload data given to the @code{MHD_AccessHandlerCallback()} will be empty (since it has already been processed). @item MHD_GET_ARGUMENT_KIND @code{GET} (URI) arguments. @item MHD_FOOTER_KIND HTTP footer (only for http 1.1 chunked encodings). @end table @end deftp @deftp {Enumeration} MHD_RequestTerminationCode The @code{MHD_RequestTerminationCode} specifies reasons why a request has been terminated (or completed). @table @code @item MHD_REQUEST_TERMINATED_COMPLETED_OK We finished sending the response. @item MHD_REQUEST_TERMINATED_WITH_ERROR Error handling the connection (resources exhausted, other side closed connection, application error accepting request, etc.) @item MHD_REQUEST_TERMINATED_TIMEOUT_REACHED No activity on the connection for the number of seconds specified using @code{MHD_OPTION_CONNECTION_TIMEOUT}. @item MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN We had to close the session since MHD was being shut down. @end table @end deftp @deftp {Enumeration} MHD_ResponseMemoryMode The @code{MHD_ResponeMemoryMode} specifies how MHD should treat the memory buffer given for the response in @code{MHD_create_response_from_buffer}. @table @code @item MHD_RESPMEM_PERSISTENT Buffer is a persistent (static/global) buffer that won't change for at least the lifetime of the response, MHD should just use it, not free it, not copy it, just keep an alias to it. @item MHD_RESPMEM_MUST_FREE Buffer is heap-allocated with @code{malloc} (or equivalent) and should be freed by MHD after processing the response has concluded (response reference counter reaches zero). @item MHD_RESPMEM_MUST_COPY Buffer is in transient memory, but not on the heap (for example, on the stack or non-malloc allocated) and only valid during the call to @code{MHD_create_response_from_buffer}. MHD must make its own private copy of the data for processing. @end table @end deftp @deftp {Enumeration} MHD_ResponseFlags Response-specific flags. Passed as an argument to @code{MHD_set_response_options()}. @table @code @item MHD_RF_NONE No special handling. @item MHD_RF_HTTP_VERSION_1_0_ONLY Only respond in conservative HTTP 1.0-mode. In particular, do not (automatically) sent "Connection" headers and always close the connection after generating the response. By default, MHD will respond using the same HTTP version which was set in the request. You can also set the @code{MHD_RF_HTTP_VERSION_1_0_RESPONSE} flag to force version 1.0 in the response. @item MHD_RF_HTTP_VERSION_1_0_RESPONSE Only respond in HTTP 1.0-mode. Contrary to the @code{MHD_RF_HTTP_VERSION_1_0_ONLY} flag, the response's HTTP version will always be set to 1.0 and ``Connection'' headers are still supported. You can even combine this option with MHD_RF_HTTP_VERSION_1_0_ONLY to change the response's HTTP version while maintaining strict compliance with HTTP 1.0 regarding connection management. This solution is not perfect as this flag is set on the response which is created after header processing. So MHD will behave as a HTTP 1.1 server until the response is queued. It means that an invalid HTTP 1.1 request will fail even if the response is sent with HTTP 1.0 and the request would be valid if interpreted with this version. For example, this request will fail in strict mode: @verbatim GET / HTTP/1.1 @end verbatim as the ``Host'' header is missing and is mandatory in HTTP 1.1, but it should succeed when interpreted with HTTP 1.0. @item MHD_RF_INSANITY_HEADER_CONTENT_LENGTH Disable sanity check preventing clients from manually setting the HTTP content length option. @end table @end deftp @deftp {Enumeration} MHD_ResponseOptions Response-specific options. Passed in the varargs portion of @code{MHD_set_response_options()}. @table @code @item MHD_RO_END No more options / last option. This is used to terminate the VARARGs list. @end table @end deftp @deftp {Enumeration} MHD_WEBSOCKET_FLAG @cindex websocket Options for the MHD websocket stream. This is used for initialization of a websocket stream when calling @code{MHD_websocket_stream_init} or @code{MHD_websocket_stream_init2} and alters the behavior of the websocket stream. Note that websocket streams are only available if you include the header file @code{microhttpd_ws.h} and compiled @emph{libmicrohttpd} with websockets. @table @code @item MHD_WEBSOCKET_FLAG_SERVER The websocket stream is initialized in server mode (default). Thus all outgoing payload will not be masked. All incoming payload must be masked. This flag cannot be used together with @code{MHD_WEBSOCKET_FLAG_CLIENT}. @item MHD_WEBSOCKET_FLAG_CLIENT The websocket stream is initialized in client mode. You will usually never use that mode in combination with @emph{libmicrohttpd}, because @emph{libmicrohttpd} provides a server and not a client. In client mode all outgoing payload will be masked (XOR-ed with random values). All incoming payload must be unmasked. If you use this mode, you must always call @code{MHD_websocket_stream_init2} instead of @code{MHD_websocket_stream_init}, because you need to pass a random number generator callback function for masking. This flag cannot be used together with @code{MHD_WEBSOCKET_FLAG_SERVER}. @item MHD_WEBSOCKET_FLAG_NO_FRAGMENTS You don't want to get fragmented data while decoding (default). Fragmented frames will be internally put together until they are complete. Whether or not data is fragmented is decided by the sender of the data during encoding. This cannot be used together with @code{MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS}. @item MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS You want fragmented data, if it appears while decoding. You will receive the content of the fragmented frame, but if you are decoding text, you will never get an unfinished UTF-8 sequence (if the sequence appears between two fragments). Instead the text will end before the unfinished UTF-8 sequence. With the next fragment, which finishes the UTF-8 sequence, you will get the complete UTF-8 sequence. This cannot be used together with @code{MHD_WEBSOCKET_FLAG_NO_FRAGMENTS}. @item MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR If the websocket stream becomes invalid during decoding due to protocol errors, a matching close frame will automatically be generated. The close frame will be returned via the parameters @code{payload} and @code{payload_len} of @code{MHD_websocket_decode} and the return value is negative (a value of @code{enum MHD_WEBSOCKET_STATUS}). The generated close frame must be freed by the caller with @code{MHD_websocket_free}. @end table @end deftp @deftp {Enumeration} MHD_WEBSOCKET_FRAGMENTATION @cindex websocket This enumeration is used to specify the fragmentation behavior when encoding of data (text/binary) for a websocket stream. This is used with @code{MHD_websocket_encode_text} or @code{MHD_websocket_encode_binary}. Note that websocket streams are only available if you include the header file @code{microhttpd_ws.h} and compiled @emph{libmicrohttpd} with websockets. @table @code @item MHD_WEBSOCKET_FRAGMENTATION_NONE You don't want to use fragmentation. The encoded frame consists of only one frame. @item MHD_WEBSOCKET_FRAGMENTATION_FIRST You want to use fragmentation. The encoded frame is the first frame of a series of data frames of the same type (text or binary). You may send control frames (ping, pong or close) between these data frames. @item MHD_WEBSOCKET_FRAGMENTATION_FOLLOWING You want to use fragmentation. The encoded frame is not the first frame of the series of data frames, but also not the last one. You may send control frames (ping, pong or close) between these data frames. @item MHD_WEBSOCKET_FRAGMENTATION_LAST You want to use fragmentation. The encoded frame is the last frame of the series of data frames, but also not the first one. After this frame, you may send all types of frames again. @end table @end deftp @deftp {Enumeration} MHD_WEBSOCKET_STATUS @cindex websocket This enumeration is used for the return value of almost every websocket stream function. Errors are negative and values equal to or above zero mean a success. Positive values are only used by @code{MHD_websocket_decode}. Note that websocket streams are only available if you include the header file @code{microhttpd_ws.h} and compiled @emph{libmicrohttpd} with websockets. @table @code @item MHD_WEBSOCKET_STATUS_OK The call succeeded. Especially for @code{MHD_websocket_decode} this means that no error occurred, but also no frame has been completed yet. For other functions this means simply a success. @item MHD_WEBSOCKET_STATUS_TEXT_FRAME @code{MHD_websocket_decode} has decoded a text frame. The parameters @code{payload} and @code{payload_len} are filled with the decoded text (if any). You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_BINARY_FRAME @code{MHD_websocket_decode} has decoded a binary frame. The parameters @code{payload} and @code{payload_len} are filled with the decoded binary data (if any). You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_CLOSE_FRAME @code{MHD_websocket_decode} has decoded a close frame. This means you must close the socket using @code{MHD_upgrade_action} with @code{MHD_UPGRADE_ACTION_CLOSE}. You may respond with a close frame before closing. The parameters @code{payload} and @code{payload_len} are filled with the close reason (if any). The close reason starts with a two byte sequence of close code in network byte order (see @code{enum MHD_WEBSOCKET_CLOSEREASON}). After these two bytes a UTF-8 encoded close reason may follow. You can call @code{MHD_websocket_split_close_reason} to split that close reason. You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_PING_FRAME @code{MHD_websocket_decode} has decoded a ping frame. You should respond to this with a pong frame. The pong frame must contain the same binary data as the corresponding ping frame (if it had any). The parameters @code{payload} and @code{payload_len} are filled with the binary ping data (if any). You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_PONG_FRAME @code{MHD_websocket_decode} has decoded a pong frame. You should usually only receive pong frames if you sent a ping frame before. The binary data should be equal to your ping frame and can be used to distinguish the response if you sent multiple ping frames. The parameters @code{payload} and @code{payload_len} are filled with the binary pong data (if any). You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT @code{MHD_websocket_decode} has decoded a text frame fragment. The parameters @code{payload} and @code{payload_len} are filled with the decoded text (if any). This is like @code{MHD_WEBSOCKET_STATUS_TEXT_FRAME}, but it can only appear if you specified @code{MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS} during the call of @code{MHD_websocket_stream_init} or @code{MHD_websocket_stream_init2}. You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT @code{MHD_websocket_decode} has decoded a binary frame fragment. The parameters @code{payload} and @code{payload_len} are filled with the decoded binary data (if any). This is like @code{MHD_WEBSOCKET_STATUS_BINARY_FRAME}, but it can only appear if you specified @code{MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS} during the call of @code{MHD_websocket_stream_init} or @code{MHD_websocket_stream_init2}. You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_TEXT_NEXT_FRAGMENT @code{MHD_websocket_decode} has decoded the next text frame fragment. The parameters @code{payload} and @code{payload_len} are filled with the decoded text (if any). This is like @code{MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT}, but it appears only after the first and before the last fragment of a series of fragments. It can only appear if you specified @code{MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS} during the call of @code{MHD_websocket_stream_init} or @code{MHD_websocket_stream_init2}. You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_BINARY_NEXT_FRAGMENT @code{MHD_websocket_decode} has decoded the next binary frame fragment. The parameters @code{payload} and @code{payload_len} are filled with the decoded binary data (if any). This is like @code{MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT}, but it appears only after the first and before the last fragment of a series of fragments. It can only appear if you specified @code{MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS} during the call of @code{MHD_websocket_stream_init} or @code{MHD_websocket_stream_init2}. You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_TEXT_LAST_FRAGMENT @code{MHD_websocket_decode} has decoded the last text frame fragment. The parameters @code{payload} and @code{payload_len} are filled with the decoded text (if any). This is like @code{MHD_WEBSOCKET_STATUS_TEXT_FIRST_FRAGMENT}, but it appears only for the last fragment of a series of fragments. It can only appear if you specified @code{MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS} during the call of @code{MHD_websocket_stream_init} or @code{MHD_websocket_stream_init2}. You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_BINARY_LAST_FRAGMENT @code{MHD_websocket_decode} has decoded the last binary frame fragment. The parameters @code{payload} and @code{payload_len} are filled with the decoded binary data (if any). This is like @code{MHD_WEBSOCKET_STATUS_BINARY_FIRST_FRAGMENT}, but it appears only for the last fragment of a series of fragments. It can only appear if you specified @code{MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS} during the call of @code{MHD_websocket_stream_init} or @code{MHD_websocket_stream_init2}. You must free the returned @code{payload} after use with @code{MHD_websocket_free}. @item MHD_WEBSOCKET_STATUS_PROTOCOL_ERROR The call failed and the stream is invalid now for decoding. You must close the websocket now using @code{MHD_upgrade_action} with @code{MHD_UPGRADE_ACTION_CLOSE}. You may send a close frame before closing. This is only used by @code{MHD_websocket_decode} and happens if the stream contains errors (i. e. invalid byte data). @item MHD_WEBSOCKET_STATUS_STREAM_BROKEN You tried to decode something, but the stream has already been marked invalid. You must close the websocket now using @code{MHD_upgrade_action} with @code{MHD_UPGRADE_ACTION_CLOSE}. You may send a close frame before closing. This is only used by @code{MHD_websocket_decode} and happens if you call @code{MDM_websocket_decode} again after has been invalidated. You can call @code{MHD_websocket_stream_is_valid} at any time to check whether a stream is invalid or not. @item MHD_WEBSOCKET_STATUS_MEMORY_ERROR A memory allocation failed. The stream remains valid. If this occurred while decoding, the decoding could be possible later if enough memory is available. This could happen while decoding if you received a too big data frame. You could try to specify max_payload_size during the call of @code{MHD_websocket_stream_init} or @code{MHD_websocket_stream_init2} to avoid this and close the websocket instead. @item MHD_WEBSOCKET_STATUS_PARAMETER_ERROR You passed invalid parameters during the function call (i. e. a NULL pointer for a required parameter). The stream remains valid. @item MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED The maximum payload size has been exceeded. If you got this return code from @code{MHD_websocket_decode} then the stream becomes invalid and the websocket must be closed using @code{MHD_upgrade_action} with @code{MHD_UPGRADE_ACTION_CLOSE}. You may send a close frame before closing. The maximum payload size is specified during the call of @code{MHD_websocket_stream_init} or @code{MHD_websocket_stream_init2}. This can also appear if you specified 0 as maximum payload size when the message is greater than the maximum allocatable memory size (i. e. more than 4 GiB on 32 bit systems). If you got this return code from @code{MHD_websocket_encode_close}, @code{MHD_websocket_encode_ping} or @code{MHD_websocket_encode_pong} then you passed to much payload data. The stream remains valid then. @item MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR An UTF-8 sequence is invalid. If you got this return code from @code{MHD_websocket_decode} then the stream becomes invalid and you must close the websocket using @code{MHD_upgrade_action} with @code{MHD_UPGRADE_ACTION_CLOSE}. You may send a close frame before closing. If you got this from @code{MHD_websocket_encode_text} or @code{MHD_websocket_encode_close} then you passed invalid UTF-8 text. The stream remains valid then. @item MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER A check routine for the HTTP headers came to the conclusion that the header value isn't valid for a websocket handshake request. This value can only be returned from the following functions: @code{MHD_websocket_check_http_version}, @code{MHD_websocket_check_connection_header}, @code{MHD_websocket_check_upgrade_header}, @code{MHD_websocket_check_version_header}, @code{MHD_websocket_create_accept_header} @end table @end deftp @deftp {Enumeration} MHD_WEBSOCKET_CLOSEREASON @cindex websocket Enumeration of possible close reasons for websocket close frames. The possible values are specified in RFC 6455 7.4.1 These close reasons here are the default set specified by RFC 6455, but also other close reasons could be used. The definition is for short: @itemize @bullet @item 0-999 are never used (if you pass 0 in @code{MHD_websocket_encode_close} then no close reason is used). @item 1000-2999 are specified by RFC 6455. @item 3000-3999 are specified by libraries, etc. but must be registered by IANA. @item 4000-4999 are reserved for private use. @end itemize Note that websocket streams are only available if you include the header file @code{microhttpd_ws.h} and compiled @emph{libmicrohttpd} with websockets. @table @code @item MHD_WEBSOCKET_CLOSEREASON_NO_REASON This value is used as placeholder for @code{MHD_websocket_encode_close} to tell that you don't want to specify any reason. If you use this value then no reason text may be used. This value cannot be a result of decoding, because this value is not a valid close reason for the websocket protocol. @item MHD_WEBSOCKET_CLOSEREASON_REGULAR You close the websocket because it fulfilled its purpose and shall now be closed in a normal, planned way. @item MHD_WEBSOCKET_CLOSEREASON_GOING_AWAY You close the websocket because you are shutting down the server or something similar. @item MHD_WEBSOCKET_CLOSEREASON_PROTOCOL_ERROR You close the websocket because a protocol error occurred during decoding (i. e. invalid byte data). @item MHD_WEBSOCKET_CLOSEREASON_UNSUPPORTED_DATATYPE You close the websocket because you received data which you don't accept. For example if you received a binary frame, but your application only expects text frames. @item MHD_WEBSOCKET_CLOSEREASON_MALFORMED_UTF8 You close the websocket because it contains malformed UTF-8. The UTF-8 validity is automatically checked by @code{MHD_websocket_decode}, so you don't need to check it on your own. UTF-8 is specified in RFC 3629. @item MHD_WEBSOCKET_CLOSEREASON_POLICY_VIOLATED You close the websocket because you received a frame which is too big to process. You can specify the maximum allowed payload size during the call of @code{MHD_websocket_stream_init} or @code{MHD_websocket_stream_init2}. @item MHD_WEBSOCKET_CLOSEREASON_MISSING_EXTENSION This status code can be sent by the client if it expected a specific extension, but this extension hasn't been negotiated. @item MHD_WEBSOCKET_CLOSEREASON_UNEXPECTED_CONDITION The server closes the websocket because it encountered an unexpected condition that prevented it from fulfilling the request. @end table @end deftp @deftp {Enumeration} MHD_WEBSOCKET_UTF8STEP @cindex websocket Enumeration of possible UTF-8 check steps for websocket functions These values are used during the encoding of fragmented text frames or for error analysis while encoding text frames. Its values specify the next step of the UTF-8 check. UTF-8 sequences consist of one to four bytes. This enumeration just says how long the current UTF-8 sequence is and what is the next expected byte. Note that websocket streams are only available if you include the header file @code{microhttpd_ws.h} and compiled @emph{libmicrohttpd} with websockets. @table @code @item MHD_WEBSOCKET_UTF8STEP_NORMAL There is no open UTF-8 sequence. The next byte must be 0x00-0x7F or 0xC2-0xF4. @item MHD_WEBSOCKET_UTF8STEP_UTF2TAIL_1OF1 The second byte of a two byte UTF-8 sequence. The first byte was 0xC2-0xDF. The next byte must be 0x80-0xBF. @item MHD_WEBSOCKET_UTF8STEP_UTF3TAIL1_1OF2 The second byte of a three byte UTF-8 sequence. The first byte was 0xE0. The next byte must be 0xA0-0xBF. @item MHD_WEBSOCKET_UTF8STEP_UTF3TAIL2_1OF2 The second byte of a three byte UTF-8 sequence. The first byte was 0xED. The next byte must by 0x80-0x9F. @item MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_1OF2 The second byte of a three byte UTF-8 sequence. The first byte was 0xE1-0xEC or 0xEE-0xEF. The next byte must be 0x80-0xBF. @item MHD_WEBSOCKET_UTF8STEP_UTF3TAIL_2OF2 The third byte of a three byte UTF-8 sequence. The next byte must be 0x80-0xBF. @item MHD_WEBSOCKET_UTF8STEP_UTF4TAIL1_1OF3 The second byte of a four byte UTF-8 sequence. The first byte was 0xF0. The next byte must be 0x90-0xBF. @item MHD_WEBSOCKET_UTF8STEP_UTF4TAIL2_1OF3 The second byte of a four byte UTF-8 sequence. The first byte was 0xF4. The next byte must be 0x80-0x8F. @item MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_1OF3 The second byte of a four byte UTF-8 sequence. The first byte was 0xF1-0xF3. The next byte must be 0x80-0xBF. @item MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_2OF3 The third byte of a four byte UTF-8 sequence. The next byte must be 0x80-0xBF. @item MHD_WEBSOCKET_UTF8STEP_UTF4TAIL_3OF3 The fourth byte of a four byte UTF-8 sequence. The next byte must be 0x80-0xBF. @end table @end deftp @deftp {Enumeration} MHD_WEBSOCKET_VALIDITY @cindex websocket Enumeration of validity values of a websocket stream These values are used for @code{MHD_websocket_stream_is_valid} and specify the validity status. Note that websocket streams are only available if you include the header file @code{microhttpd_ws.h} and compiled @emph{libmicrohttpd} with websockets. @table @code @item MHD_WEBSOCKET_VALIDITY_INVALID The stream is invalid. It cannot be used for decoding anymore. @item MHD_WEBSOCKET_VALIDITY_VALID The stream is valid. Decoding works as expected. @item MHD_WEBSOCKET_VALIDITY_ONLY_VALID_FOR_CONTROL_FRAMES The stream has received a close frame and is partly invalid. You can still use the stream for decoding, but if a data frame is received an error will be reported. After a close frame has been sent, no data frames may follow from the sender of the close frame. @end table @end deftp @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-struct @chapter Structures type definition @deftp {C Struct} MHD_Daemon Handle for the daemon (listening on a socket for HTTP traffic). @end deftp @deftp {C Struct} MHD_Connection Handle for a connection / HTTP request. With HTTP/1.1, multiple requests can be run over the same connection. However, MHD will only show one request per TCP connection to the client at any given time. @end deftp @deftp {C Struct} MHD_Response Handle for a response. @end deftp @deftp {C Struct} MHD_IoVec An element of an array of memory buffers. @end deftp @deftp {C Struct} MHD_PostProcessor @cindex POST method Handle for @code{POST} processing. @end deftp @deftp {C Union} MHD_ConnectionInfo Information about a connection. @end deftp @deftp {C Union} MHD_DaemonInfo Information about an MHD daemon. @end deftp @deftp {C Struct} MHD_WebSocketStream @cindex websocket Information about a MHD websocket stream. @end deftp @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-cb @chapter Callback functions definition @deftypefn {Function Pointer} enum MHD_Result {*MHD_AcceptPolicyCallback} (void *cls, const struct sockaddr * addr, socklen_t addrlen) Invoked in the context of a connection to allow or deny a client to connect. This callback return @code{MHD_YES} if connection is allowed, @code{MHD_NO} if not. @table @var @item cls custom value selected at callback registration time; @item addr address information from the client; @item addrlen length of the address information. @end table @end deftypefn @deftypefn {Function Pointer} enum MHD_Result {*MHD_AccessHandlerCallback} (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) Invoked in the context of a connection to answer a request from the client. This callback must call MHD functions (example: the @code{MHD_Response} ones) to provide content to give back to the client and return an HTTP status code (i.e. @code{200} for OK, @code{404}, etc.). @ref{microhttpd-post}, for details on how to code this callback. Must return @code{MHD_YES} if the connection was handled successfully, @code{MHD_NO} if the socket must be closed due to a serious error while handling the request @table @var @item cls custom value selected at callback registration time; @item url the URL requested by the client; @item method the HTTP method used by the client (@code{GET}, @code{PUT}, @code{DELETE}, @code{POST}, etc.); @item version the HTTP version string (i.e. @code{HTTP/1.1}); @item upload_data the data being uploaded (excluding headers): @cindex POST method @cindex PUT method @code{POST} data @strong{will} be made available incrementally in @var{upload_data}; even if @code{POST} data is available, the first time the callback is invoked there won't be upload data, as this is done just after MHD parses the headers. If supported by the client and the HTTP version, the application can at this point queue an error response to possibly avoid the upload entirely. If no response is generated, MHD will (if required) automatically send a 100 CONTINUE reply to the client. Afterwards, POST data will be passed to the callback to be processed incrementally by the application. The application may return @code{MHD_NO} to forcefully terminate the TCP connection without generating a proper HTTP response. Once all of the upload data has been provided to the application, the application will be called again with 0 bytes of upload data. At this point, a response should be queued to complete the handling of the request. @item upload_data_size set initially to the size of the @var{upload_data} provided; this callback must update this value to the number of bytes @strong{NOT} processed; unless external select is used, the callback maybe required to process at least some data. If the callback fails to process data in multi-threaded or internal-select mode and if the read-buffer is already at the maximum size that MHD is willing to use for reading (about half of the maximum amount of memory allowed for the connection), then MHD will abort handling the connection and return an internal server error to the client. In order to avoid this, clients must be able to process upload data incrementally and reduce the value of @code{upload_data_size}. @item req_cls reference to a pointer, initially set to @code{NULL}, that this callback can set to some address and that will be preserved by MHD for future calls for this request; since the access handler may be called many times (i.e., for a @code{PUT}/@code{POST} operation with plenty of upload data) this allows the application to easily associate some request-specific state; if necessary, this state can be cleaned up in the global @code{MHD_RequestCompletedCallback} (which can be set with the @code{MHD_OPTION_NOTIFY_COMPLETED}). @end table @end deftypefn @deftypefn {Function Pointer} void {*MHD_RequestCompletedCallback} (void *cls, struct MHD_Connectionconnection, void **req_cls, enum MHD_RequestTerminationCode toe) Signature of the callback used by MHD to notify the application about completed requests. @table @var @item cls custom value selected at callback registration time; @item connection connection handle; @item req_cls value as set by the last call to the @code{MHD_AccessHandlerCallback}; @item toe reason for request termination see @code{MHD_OPTION_NOTIFY_COMPLETED}. @end table @end deftypefn @deftypefn {Function Pointer} enum MHD_Result {*MHD_KeyValueIterator} (void *cls, enum MHD_ValueKind kind, const char *key, const char *value, size_t value_size) Iterator over key-value pairs. This iterator can be used to iterate over all of the cookies, headers, or @code{POST}-data fields of a request, and also to iterate over the headers that have been added to a response. @table @var @item cls custom value specified when iteration was triggered; @item kind kind of the header we are looking at @item key key for the value, can be an empty string @item value value corresponding value, can be NULL @item value_size number of bytes in @code{value}. This argument was introduced in @code{MHD_VERSION} 0x00096301 to allow applications to use binary zeros in values. Applications using this argument must ensure that they are using a sufficiently recent version of MHD, i.e. by testing @code{MHD_get_version()} for values above or equal to 0.9.64. Applications that do not need zeros in values and that want to compile without warnings against newer versions of MHD should not declare this argument and cast the function pointer argument to @code{MHD_KeyValueIterator}. @end table Return @code{MHD_YES} to continue iterating, @code{MHD_NO} to abort the iteration. @end deftypefn @deftypefn {Function Pointer} ssize_t {*MHD_ContentReaderCallback} (void *cls, uint64_t pos, char *buf, size_t max) Callback used by MHD in order to obtain content. The callback has to copy at most @var{max} bytes of content into @var{buf}. The total number of bytes that has been placed into @var{buf} should be returned. Note that returning zero will cause MHD to try again. Thus, returning zero should only be used in conjunction with @code{MHD_suspend_connection()} to avoid busy waiting. While usually the callback simply returns the number of bytes written into @var{buf}, there are two special return value: @code{MHD_CONTENT_READER_END_OF_STREAM} (-1) should be returned for the regular end of transmission (with chunked encoding, MHD will then terminate the chunk and send any HTTP footers that might be present; without chunked encoding and given an unknown response size, MHD will simply close the connection; note that while returning @code{MHD_CONTENT_READER_END_OF_STREAM} is not technically legal if a response size was specified, MHD accepts this and treats it just as @code{MHD_CONTENT_READER_END_WITH_ERROR}. @code{MHD_CONTENT_READER_END_WITH_ERROR} (-2) is used to indicate a server error generating the response; this will cause MHD to simply close the connection immediately. If a response size was given or if chunked encoding is in use, this will indicate an error to the client. Note, however, that if the client does not know a response size and chunked encoding is not in use, then clients will not be able to tell the difference between @code{MHD_CONTENT_READER_END_WITH_ERROR} and @code{MHD_CONTENT_READER_END_OF_STREAM}. This is not a limitation of MHD but rather of the HTTP protocol. @table @var @item cls custom value selected at callback registration time; @item pos position in the datastream to access; note that if an @code{MHD_Response} object is re-used, it is possible for the same content reader to be queried multiple times for the same data; however, if an @code{MHD_Response} is not re-used, MHD guarantees that @var{pos} will be the sum of all non-negative return values obtained from the content reader so far. @end table Return @code{-1} on error (MHD will no longer try to read content and instead close the connection with the client). @end deftypefn @deftypefn {Function Pointer} void {*MHD_ContentReaderFreeCallback} (void *cls) This method is called by MHD if we are done with a content reader. It should be used to free resources associated with the content reader. @end deftypefn @deftypefn {Function Pointer} enum MHD_Result {*MHD_PostDataIterator} (void *cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size) Iterator over key-value pairs where the value maybe made available in increments and/or may not be zero-terminated. Used for processing @code{POST} data. @table @var @item cls custom value selected at callback registration time; @item kind type of the value; @item key zero-terminated key for the value; @item filename name of the uploaded file, @code{NULL} if not known; @item content_type mime-type of the data, @code{NULL} if not known; @item transfer_encoding encoding of the data, @code{NULL} if not known; @item data pointer to size bytes of data at the specified offset; @item off offset of data in the overall value; @item size number of bytes in data available. @end table Return @code{MHD_YES} to continue iterating, @code{MHD_NO} to abort the iteration. @end deftypefn @deftypefn {Function Pointer} void* {*MHD_WebSocketMallocCallback} (size_t buf_len) @cindex websocket This callback function is used internally by many websocket functions for allocating data. By default @code{malloc} is used. You can use your own allocation function with @code{MHD_websocket_stream_init2} if you wish to. This can be useful for operating systems like Windows where @code{malloc}, @code{realloc} and @code{free} are compiler-dependent. You can call the associated @code{malloc} callback of a websocket stream with @code{MHD_websocket_malloc}. @table @var @item buf_len size of the buffer to allocate in bytes. @end table Return the pointer of the allocated buffer or @code{NULL} on failure. @end deftypefn @deftypefn {Function Pointer} void* {*MHD_WebSocketReallocCallback} (void *buf, size_t new_buf_len) @cindex websocket This callback function is used internally by many websocket functions for reallocating data. By default @code{realloc} is used. You can use your own reallocation function with @code{MHD_websocket_stream_init2} if you wish to. This can be useful for operating systems like Windows where @code{malloc}, @code{realloc} and @code{free} are compiler-dependent. You can call the associated @code{realloc} callback of a websocket stream with @code{MHD_websocket_realloc}. @table @var @item buf current buffer, may be @code{NULL}; @item new_buf_len new size of the buffer in bytes. @end table Return the pointer of the reallocated buffer or @code{NULL} on failure. On failure the old pointer must remain valid. @end deftypefn @deftypefn {Function Pointer} void {*MHD_WebSocketFreeCallback} (void *buf) @cindex websocket This callback function is used internally by many websocket functions for freeing data. By default @code{free} is used. You can use your own free function with @code{MHD_websocket_stream_init2} if you wish to. This can be useful for operating systems like Windows where @code{malloc}, @code{realloc} and @code{free} are compiler-dependent. You can call the associated @code{free} callback of a websocket stream with @code{MHD_websocket_free}. @table @var @item cls current buffer to free, this may be @code{NULL} then nothing happens. @end table @end deftypefn @deftypefn {Function Pointer} size_t {*MHD_WebSocketRandomNumberGenerator} (void *cls, void* buf, size_t buf_len) @cindex websocket This callback function is used for generating random numbers for masking payload data in client mode. If you use websockets in server mode with @emph{libmicrohttpd} then you don't need a random number generator, because the server doesn't mask its outgoing messages. However if you wish to use a websocket stream in client mode, you must pass this callback function to @code{MHD_websocket_stream_init2}. @table @var @item cls closure specified in @code{MHD_websocket_stream_init2}; @item buf buffer to fill with random values; @item buf_len size of buffer in bytes. @end table Return the number of generated random bytes. The return value should usually equal to buf_len. @end deftypefn @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-init @chapter Starting and stopping the server @deftypefun {void} MHD_set_panic_func (MHD_PanicCallback cb, void *cls) Set a handler for fatal errors. @table @var @item cb function to call if MHD encounters a fatal internal error. If no handler was set explicitly, MHD will call @code{abort}. @item cls closure argument for cb; the other arguments are the name of the source file, line number and a string describing the nature of the fatal error (which can be @code{NULL}) @end table @end deftypefun @deftypefun {struct MHD_Daemon *} MHD_start_daemon (unsigned int flags, unsigned short port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, ...) Start a webserver on the given port. @table @var @item flags OR-ed combination of @code{MHD_FLAG} values; @item port port to bind to; @item apc callback to call to check which clients will be allowed to connect; you can pass @code{NULL} in which case connections from any @acronym{IP} will be accepted; @item apc_cls extra argument to @var{apc}; @item dh default handler for all URIs; @item dh_cls extra argument to @var{dh}. @end table Additional arguments are a list of options (type-value pairs, terminated with @code{MHD_OPTION_END}). It is mandatory to use @code{MHD_OPTION_END} as last argument, even when there are no additional arguments. Return @code{NULL} on error, handle to daemon on success. @end deftypefun @deftypefun MHD_socket MHD_quiesce_daemon (struct MHD_Daemon *daemon) @cindex quiesce Stop accepting connections from the listening socket. Allows clients to continue processing, but stops accepting new connections. Note that the caller is responsible for closing the returned socket; however, if MHD is run using threads (anything but external select mode), it must not be closed until AFTER @code{MHD_stop_daemon} has been called (as it is theoretically possible that an existing thread is still using it). This function is useful in the special case that a listen socket is to be migrated to another process (i.e. a newer version of the HTTP server) while existing connections should continue to be processed until they are finished. Return @code{-1} on error (daemon not listening), the handle to the listen socket otherwise. @end deftypefun @deftypefun void MHD_stop_daemon (struct MHD_Daemon *daemon) Shutdown an HTTP daemon. @end deftypefun @deftypefun enum MHD_Result MHD_run (struct MHD_Daemon *daemon) Run webserver operations (without blocking unless in client callbacks). This method should be called by clients in combination with @code{MHD_get_fdset()} if the client-controlled @code{select}-method is used. @cindex select @cindex poll This function will work for external @code{poll} and @code{select} mode. However, if using external @code{select} mode, you may want to instead use @code{MHD_run_from_select}, as it is more efficient. @table @var @item daemon daemon to process connections of @end table Return @code{MHD_YES} on success, @code{MHD_NO} if this daemon was not started with the right options for this call. @end deftypefun @deftypefun enum MHD_Result MHD_run_from_select (struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set) Run webserver operations given sets of ready socket handles. @cindex select This method should be called by clients in combination with @code{MHD_get_fdset} if the client-controlled (external) select method is used. You can use this function instead of @code{MHD_run} if you called @code{select} on the result from @code{MHD_get_fdset}. File descriptors in the sets that are not controlled by MHD will be ignored. Calling this function instead of @code{MHD_run} is more efficient as MHD will not have to call @code{select} again to determine which operations are ready. @table @var @item daemon daemon to process connections of @item read_fd_set set of descriptors that must be ready for reading without blocking @item write_fd_set set of descriptors that must be ready for writing without blocking @item except_fd_set ignored, can be NULL @end table Return @code{MHD_YES} on success, @code{MHD_NO} on serious internal errors. @end deftypefun @deftypefun void MHD_add_connection (struct MHD_Daemon *daemon, int client_socket, const struct sockaddr *addr, socklen_t addrlen) Add another client connection to the set of connections managed by MHD. This API is usually not needed (since MHD will accept inbound connections on the server socket). Use this API in special cases, for example if your HTTP server is behind NAT and needs to connect out to the HTTP client, or if you are building a proxy. If you use this API in conjunction with a internal select or a thread pool, you must set the option @code{MHD_USE_ITC} to ensure that the freshly added connection is immediately processed by MHD. The given client socket will be managed (and closed!) by MHD after this call and must no longer be used directly by the application afterwards. @table @var @item daemon daemon that manages the connection @item client_socket socket to manage (MHD will expect to receive an HTTP request from this socket next). @item addr IP address of the client @item addrlen number of bytes in addr @end table This function will return @code{MHD_YES} on success, @code{MHD_NO} if this daemon could not handle the connection (i.e. malloc failed, etc). The socket will be closed in any case; 'errno' is set to indicate further details about the error. @end deftypefun @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ----------------------------------------------------------- @node microhttpd-inspect @chapter Implementing external @code{select} @deftypefun enum MHD_Result MHD_get_fdset (struct MHD_Daemon *daemon, fd_set * read_fd_set, fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd) Obtain the @code{select()} sets for this daemon. The daemon's socket is added to @var{read_fd_set}. The list of currently existent connections is scanned and their file descriptors added to the correct set. When calling this function, FD_SETSIZE is assumed to be platform's default. If you changed FD_SETSIZE for your application, you should use @code{MHD_get_fdset2()} instead. This function should only be called in when MHD is configured to use external select with @code{select()} or with @code{epoll()}. In the latter case, it will only add the single @code{epoll()} file descriptor used by MHD to the sets. After the call completed successfully: the variable referenced by @var{max_fd} references the file descriptor with highest integer identifier. The variable must be set to zero before invoking this function. Return @code{MHD_YES} on success, @code{MHD_NO} if: the arguments are invalid (example: @code{NULL} pointers); this daemon was not started with the right options for this call. @end deftypefun @deftypefun enum MHD_Result MHD_get_fdset2 (struct MHD_Daemon *daemon, fd_set * read_fd_set, fd_set * write_fd_set, fd_set * except_fd_set, int *max_fd, unsigned int fd_setsize) Like @code{MHD_get_fdset()}, except that you can manually specify the value of FD_SETSIZE used by your application. @end deftypefun @deftypefun enum MHD_Result MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout) @cindex timeout Obtain timeout value for select for this daemon (only needed if connection timeout is used). The returned value is how many milliseconds @code{select} should at most block, not the timeout value set for connections. This function must not be called if the @code{MHD_USE_THREAD_PER_CONNECTION} mode is in use (since then it is not meaningful to ask for a timeout, after all, there is concurrenct activity). The function must also not be called by user-code if @code{MHD_USE_INTERNAL_POLLING_THREAD} is in use. In the latter case, the behavior is undefined. @table @var @item daemon which daemon to obtain the timeout from. @item timeout will be set to the timeout (in milliseconds). @end table Return @code{MHD_YES} on success, @code{MHD_NO} if timeouts are not used (or no connections exist that would necessitate the use of a timeout right now). @end deftypefun @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ----------------------------------------------------------- @node microhttpd-requests @chapter Handling requests @deftypefun int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) Get all the headers matching @var{kind} from the request. The @var{kind} argument can be a bitmask, ORing the various header kinds that are requested. The @var{iterator} callback is invoked once for each header, with @var{iterator_cls} as first argument. After version 0.9.19, the headers are iterated in the same order as they were received from the network; previous versions iterated over the headers in reverse order. @code{MHD_get_connection_values} returns the number of entries iterated over; this can be less than the number of headers if, while iterating, @var{iterator} returns @code{MHD_NO}. @var{iterator} can be @code{NULL}: in this case this function just counts and returns the number of headers. In the case of @code{MHD_GET_ARGUMENT_KIND}, the @var{value} argument will be @code{NULL} if the URL contained a key without an equals operator. For example, for a HTTP request to the URL ``http://foo/bar?key'', the @var{value} argument is @code{NULL}; in contrast, a HTTP request to the URL ``http://foo/bar?key='', the @var{value} argument is the empty string. The normal case is that the URL contains ``http://foo/bar?key=value'' in which case @var{value} would be the string ``value'' and @var{key} would contain the string ``key''. @end deftypefun @deftypefun enum MHD_Result MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value) This function can be used to append an entry to the list of HTTP headers of a connection (so that the @code{MHD_get_connection_values function} will return them -- and the MHD PostProcessor will also see them). This maybe required in certain situations (see Mantis #1399) where (broken) HTTP implementations fail to supply values needed by the post processor (or other parts of the application). This function MUST only be called from within the MHD_AccessHandlerCallback (otherwise, access maybe improperly synchronized). Furthermore, the client must guarantee that the key and value arguments are 0-terminated strings that are NOT freed until the connection is closed. (The easiest way to do this is by passing only arguments to permanently allocated strings.). @var{connection} is the connection for which the entry for @var{key} of the given @var{kind} should be set to the given @var{value}. The function returns @code{MHD_NO} if the operation could not be performed due to insufficient memory and @code{MHD_YES} on success. @end deftypefun @deftypefun {const char *} MHD_lookup_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key) Get a particular header value. If multiple values match the @var{kind}, return one of them (the ``first'', whatever that means). @var{key} must reference a zero-terminated ASCII-coded string representing the header to look for: it is compared against the headers using (basically) @code{strcasecmp()}, so case is ignored. @end deftypefun @deftypefun {const char *} MHD_lookup_connection_value_n (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr) Get a particular header value. If multiple values match the @var{kind}, return one of them (the ``first'', whatever that means). @var{key} must reference an ASCII-coded string representing the header to look for: it is compared against the headers using (basically) @code{strncasecmp()}, so case is ignored. The @var{value_ptr} is set to the address of the value found, and @var{value_size_ptr} is set to the number of bytes in the value. @end deftypefun @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-responses @chapter Building responses to requests @noindent Response objects handling by MHD is asynchronous with respect to the application execution flow. Instances of the @code{MHD_Response} structure are not associated to a daemon and neither to a client connection: they are managed with reference counting. In the simplest case: we allocate a new @code{MHD_Response} structure for each response, we use it once and finally we destroy it. MHD allows more efficient resources usages. Example: we allocate a new @code{MHD_Response} structure for each response @strong{kind}, we use it every time we have to give that response and we finally destroy it only when the daemon shuts down. @menu * microhttpd-response enqueue:: Enqueuing a response. * microhttpd-response create:: Creating a response object. * microhttpd-response headers:: Adding headers to a response. * microhttpd-response options:: Setting response options. * microhttpd-response inspect:: Inspecting a response object. * microhttpd-response upgrade:: Creating a response for protocol upgrades. @end menu @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-response enqueue @section Enqueuing a response @deftypefun enum MHD_Result MHD_queue_response (struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response) Queue a response to be transmitted to the client as soon as possible but only after MHD_AccessHandlerCallback returns. This function checks that it is legal to queue a response at this time for the given connection. It also increments the internal reference counter for the response object (the counter will be decremented automatically once the response has been transmitted). @table @var @item connection the connection identifying the client; @item status_code HTTP status code (i.e. @code{200} for OK); @item response response to transmit. @end table Return @code{MHD_YES} on success or if message has been queued. Return @code{MHD_NO}: if arguments are invalid (example: @code{NULL} pointer); on error (i.e. reply already sent). @end deftypefun @deftypefun void MHD_destroy_response (struct MHD_Response *response) Destroy a response object and associated resources (decrement the reference counter). Note that MHD may keep some of the resources around if the response is still in the queue for some clients, so the memory may not necessarily be freed immediately. @end deftypefun An explanation of reference counting@footnote{Note to readers acquainted to the Tcl API: reference counting on @code{MHD_Connection} structures is handled in the same way as Tcl handles @code{Tcl_Obj} structures through @code{Tcl_IncrRefCount()} and @code{Tcl_DecrRefCount()}.}: @enumerate @item a @code{MHD_Response} object is allocated: @example struct MHD_Response * response = MHD_create_response_from_buffer(...); /* here: reference counter = 1 */ @end example @item the @code{MHD_Response} object is enqueued in a @code{MHD_Connection}: @example MHD_queue_response(connection, , response); /* here: reference counter = 2 */ @end example @item the creator of the response object discharges responsibility for it: @example MHD_destroy_response(response); /* here: reference counter = 1 */ @end example @item the daemon handles the connection sending the response's data to the client then decrements the reference counter by calling @code{MHD_destroy_response()}: the counter's value drops to zero and the @code{MHD_Response} object is released. @end enumerate @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-response create @section Creating a response object @deftypefun {struct MHD_Response *} MHD_create_response_from_callback (uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc) Create a response object. The response object can be extended with header information and then it can be used any number of times. @table @var @item size size of the data portion of the response, @code{-1} for unknown; @item block_size preferred block size for querying @var{crc} (advisory only, MHD may still call @var{crc} using smaller chunks); this is essentially the buffer size used for @acronym{IO}, clients should pick a value that is appropriate for @acronym{IO} and memory performance requirements; @item crc callback to use to obtain response data; @item crc_cls extra argument to @var{crc}; @item crfc callback to call to free @var{crc_cls} resources. @end table Return @code{NULL} on error (i.e. invalid arguments, out of memory). @end deftypefun @deftypefun {struct MHD_Response *} MHD_create_response_from_fd (uint64_t size, int fd) Create a response object. The response object can be extended with header information and then it can be used any number of times. @table @var @item size size of the data portion of the response (should be smaller or equal to the size of the file) @item fd file descriptor referring to a file on disk with the data; will be closed when response is destroyed; note that 'fd' must be an actual file descriptor (not a pipe or socket) since MHD might use 'sendfile' or 'seek' on it. The descriptor should be in blocking-IO mode. @end table Return @code{NULL} on error (i.e. invalid arguments, out of memory). @end deftypefun @deftypefun {struct MHD_Response *} MHD_create_response_from_pipe (int fd) Create a response object. The response object can be extended with header information and then it can be used ONLY ONCE. @table @var @item fd file descriptor of the read-end of the pipe; will be closed when response is destroyed. The descriptor should be in blocking-IO mode. @end table Return @code{NULL} on error (i.e. out of memory). @end deftypefun @deftypefun {struct MHD_Response *} MHD_create_response_from_fd_at_offset (size_t size, int fd, off_t offset) Create a response object. The response object can be extended with header information and then it can be used any number of times. Note that you need to be a bit careful about @code{off_t} when writing this code. Depending on your platform, MHD is likely to have been compiled with support for 64-bit files. When you compile your own application, you must make sure that @code{off_t} is also a 64-bit value. If not, your compiler may pass a 32-bit value as @code{off_t}, which will result in 32-bits of garbage. If you use the autotools, use the @code{AC_SYS_LARGEFILE} autoconf macro and make sure to include the generated @file{config.h} file before @file{microhttpd.h} to avoid problems. If you do not have a build system and only want to run on a GNU/Linux system, you could also use @verbatim #define _FILE_OFFSET_BITS 64 #include #include #include #include @end verbatim to ensure 64-bit @code{off_t}. Note that if your operating system does not support 64-bit files, MHD will be compiled with a 32-bit @code{off_t} (in which case the above would be wrong). @table @var @item size size of the data portion of the response (number of bytes to transmit from the file starting at offset). @item fd file descriptor referring to a file on disk with the data; will be closed when response is destroyed; note that 'fd' must be an actual file descriptor (not a pipe or socket) since MHD might use 'sendfile' or 'seek' on it. The descriptor should be in blocking-IO mode. @item offset offset to start reading from in the file @end table Return @code{NULL} on error (i.e. invalid arguments, out of memory). @end deftypefun @deftypefun {struct MHD_Response *} MHD_create_response_from_buffer (size_t size, void *data, enum MHD_ResponseMemoryMode mode) Create a response object. The response object can be extended with header information and then it can be used any number of times. @table @var @item size size of the data portion of the response; @item buffer the data itself; @item mode memory management options for buffer; use MHD_RESPMEM_PERSISTENT if the buffer is static/global memory, use MHD_RESPMEM_MUST_FREE if the buffer is heap-allocated and should be freed by MHD and MHD_RESPMEM_MUST_COPY if the buffer is in transient memory (i.e. on the stack) and must be copied by MHD; @end table Return @code{NULL} on error (i.e. invalid arguments, out of memory). @end deftypefun @deftypefun {struct MHD_Response *} MHD_create_response_from_buffer_with_free_callback (size_t size, void *data, MHD_ContentReaderFreeCallback crfc) Create a response object. The buffer at the end must be free'd by calling the @var{crfc} function. @table @var @item size size of the data portion of the response; @item buffer the data itself; @item crfc function to call at the end to free memory allocated at @var{buffer}. @end table Return @code{NULL} on error (i.e. invalid arguments, out of memory). @end deftypefun @deftypefun {struct MHD_Response *} MHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy) Create a response object. The response object can be extended with header information and then it can be used any number of times. This function is deprecated, use @code{MHD_create_response_from_buffer} instead. @table @var @item size size of the data portion of the response; @item data the data itself; @item must_free if true: MHD should free data when done; @item must_copy if true: MHD allocates a block of memory and use it to make a copy of @var{data} embedded in the returned @code{MHD_Response} structure; handling of the embedded memory is responsibility of MHD; @var{data} can be released anytime after this call returns. @end table Return @code{NULL} on error (i.e. invalid arguments, out of memory). @end deftypefun Example: create a response from a statically allocated string: @example const char * data = "

    Error!

    "; struct MHD_Connection * connection = ...; struct MHD_Response * response; response = MHD_create_response_from_buffer (strlen(data), data, MHD_RESPMEM_PERSISTENT); MHD_queue_response(connection, 404, response); MHD_destroy_response(response); @end example @deftypefun {struct MHD_Response *} MHD_create_response_from_iovec (const struct MHD_IoVec *iov, int iovcnt, MHD_ContentReaderFreeCallback crfc, void *cls) Create a response object from an array of memory buffers. The response object can be extended with header information and then be used any number of times. @table @var @item iov the array for response data buffers, an internal copy of this will be made; however, note that the data pointed to by the @var{iov} is not copied and must be preserved unchanged at the given locations until the response is no longer in use and the @var{crfc} is called; @item iovcnt the number of elements in @var{iov}; @item crfc the callback to call to free resources associated with @var{iov}; @item cls the argument to @var{crfc}; @end table Return @code{NULL} on error (i.e. invalid arguments, out of memory). @end deftypefun @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-response headers @section Adding headers to a response @deftypefun enum MHD_Result MHD_add_response_header (struct MHD_Response *response, const char *header, const char *content) Add a header line to the response. The strings referenced by @var{header} and @var{content} must be zero-terminated and they are duplicated into memory blocks embedded in @var{response}. Notice that the strings must not hold newlines, carriage returns or tab chars. MHD_add_response_header() prevents applications from setting a ``Transfer-Encoding'' header to values other than ``identity'' or ``chunked'' as other transfer encodings are not supported by MHD. Note that usually MHD will pick the transfer encoding correctly automatically, but applications can use the header to force a particular behavior. MHD_add_response_header() also prevents applications from setting a ``Content-Length'' header. MHD will automatically set a correct ``Content-Length'' header if it is possible and allowed. Return @code{MHD_NO} on error (i.e. invalid header or content format or memory allocation error). @end deftypefun @deftypefun enum MHD_Result MHD_add_response_footer (struct MHD_Response *response, const char *footer, const char *content) Add a footer line to the response. The strings referenced by @var{footer} and @var{content} must be zero-terminated and they are duplicated into memory blocks embedded in @var{response}. Notice that the strings must not hold newlines, carriage returns or tab chars. You can add response footers at any time before signalling the end of the response to MHD (not just before calling 'MHD_queue_response'). Footers are useful for adding cryptographic checksums to the reply or to signal errors encountered during data generation. This call was introduced in MHD 0.9.3. Return @code{MHD_NO} on error (i.e. invalid header or content format or memory allocation error). @end deftypefun @deftypefun enum MHD_Result MHD_del_response_header (struct MHD_Response *response, const char *header, const char *content) Delete a header (or footer) line from the response. Return @code{MHD_NO} on error (arguments are invalid or no such header known). @end deftypefun @c ------------------------------------------------------------ @node microhttpd-response options @section Setting response options @deftypefun enum MHD_Result MHD_set_response_options (struct MHD_Response *response, enum MHD_ResponseFlags flags, ...) Set special flags and options for a response. Calling this functions sets the given flags and options for the response. @table @var @item response which response should be modified; @item flags flags to set for the response; @end table Additional arguments are a list of options (type-value pairs, terminated with @code{MHD_RO_END}). It is mandatory to use @code{MHD_RO_END} as last argument, even when there are no additional arguments. Return @code{MHD_NO} on error, @code{MHD_YES} on success. @end deftypefun @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-response inspect @section Inspecting a response object @deftypefun int MHD_get_response_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls) Get all of the headers added to a response. Invoke the @var{iterator} callback for each header in the response, using @var{iterator_cls} as first argument. Return number of entries iterated over. @var{iterator} can be @code{NULL}: in this case the function just counts headers. @var{iterator} should not modify the its key and value arguments, unless we know what we are doing. @end deftypefun @deftypefun {const char *} MHD_get_response_header (struct MHD_Response *response, const char *key) Find and return a pointer to the value of a particular header from the response. @var{key} must reference a zero-terminated string representing the header to look for. The search is case sensitive. Return @code{NULL} if header does not exist or @var{key} is @code{NULL}. We should not modify the value, unless we know what we are doing. @end deftypefun @c ------------------------------------------------------------ @node microhttpd-response upgrade @section Creating a response for protocol upgrades @cindex WebSockets @cindex Upgrade @cindex HTTP2 @cindex RFC2817 With RFC 2817 a mechanism to switch protocols within HTTP was introduced. Here, a client sends a request with a ``Connection: Upgrade'' header. The server responds with a ``101 Switching Protocols'' response header, after which the two parties begin to speak a different (non-HTTP) protocol over the TCP connection. This mechanism is used for upgrading HTTP 1.1 connections to HTTP2 or HTTPS, as well as for implementing WebSockets. Which protocol upgrade is performed is negotiated between server and client in additional headers, in particular the ``Upgrade'' header. MHD supports switching protocols using this mechanism only if the @code{MHD_ALLOW_SUSPEND_RESUME} flag has been set when starting the daemon. If this flag has been set, applications can upgrade a connection by queueing a response (using the @code{MHD_HTTP_SWITCHING_PROTOCOLS} status code) which must have been created with the following function: @deftypefun enum MHD_Result MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, void *upgrade_handler_cls) Create a response suitable for switching protocols. Returns @code{MHD_YES} on success. @code{upgrade_handler} must not be @code{NULL}. When creating this type of response, the ``Connection: Upgrade'' header will be set automatically for you. MHD requires that you additionally set an ``Upgrade:'' header. The ``Upgrade'' header must simply exist, the specific value is completely up to the application. @end deftypefun The @code{upgrade_handler} argument to the above has the following type: @deftypefn {Function Pointer} void {*MHD_UpgradeHandler} (void *cls, struct MHD_Connection *connection, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh) This function will be called once MHD has transmitted the header of the response to the connection that is being upgraded. At this point, the application is expected to take over the socket @code{sock} and speak the non-HTTP protocol to which the connection was upgraded. MHD will no longer use the socket; this includes handling timeouts. The application must call @code{MHD_upgrade_action} with an upgrade action of @code{MHD_UPGRADE_ACTION_CLOSE} when it is done processing the connection to close the socket. The application must not call @code{MHD_stop_daemon} on the respective daemon as long as it is still handling the connection. The arguments given to the @code{upgrade_handler} have the following meaning: @table @var @item cls matches the @code{upgrade_handler_cls} that was given to @code{MHD_create_response_for_upgrade} @item connection identifies the connection that is being upgraded; @item req_cls last value left in `*req_cls` in the `MHD_AccessHandlerCallback` @item extra_in buffer of bytes MHD read ``by accident'' from the socket already. This can happen if the client eagerly transmits more than just the HTTP request. The application should treat these as if it had read them from the socket. @item extra_in_size number of bytes in @code{extra_in} @item sock the socket which the application can now use directly for some bi-directional communication with the client. The application can henceforth use @code{recv()} and @code{send()} or @code{read()} and @code{write()} system calls on the socket. However, @code{ioctl()} and @code{setsockopt()} functions will not work as expected when using HTTPS. Such operations may be supported in the future via @code{MHD_upgrade_action}. Most importantly, the application must never call @code{close()} on this socket. Closing the socket must be done using @code{MHD_upgrade_action}. However, while close is forbidden, the application may call @code{shutdown()} on the socket. @item urh argument for calls to @code{MHD_upgrade_action}. Applications must eventually use this function to perform the @code{close()} action on the socket. @end table @end deftypefn @deftypefun enum MHD_Result MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, enum MHD_UpgradeAction action, ...) Perform special operations related to upgraded connections. @table @var @item urh identifies the upgraded connection to perform an action on @item action specifies the action to perform; further arguments to the function depend on the specifics of the action. @end table @end deftypefun @deftp {Enumeration} MHD_UpgradeAction Set of actions to be performed on upgraded connections. Passed as an argument to @code{MHD_upgrade_action()}. @table @code @item MHD_UPGRADE_ACTION_CLOSE Closes the connection. Must be called once the application is done with the client. Takes no additional arguments. @item MHD_UPGRADE_ACTION_CORK_ON Enable corking on the underlying socket. @item MHD_UPGRADE_ACTION_CORK_OFF Disable corking on the underlying socket. @end table @end deftp @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-flow @chapter Flow control. @noindent Sometimes it may be possible that clients upload data faster than an application can process it, or that an application needs an extended period of time to generate a response. If @code{MHD_USE_THREAD_PER_CONNECTION} is used, applications can simply deal with this by performing their logic within the thread and thus effectively blocking connection processing by MHD. In all other modes, blocking logic must not be placed within the callbacks invoked by MHD as this would also block processing of other requests, as a single thread may be responsible for tens of thousands of connections. Instead, applications using thread modes other than @code{MHD_USE_THREAD_PER_CONNECTION} should use the following functions to perform flow control. @deftypefun enum MHD_Result MHD_suspend_connection (struct MHD_Connection *connection) Suspend handling of network data for a given connection. This can be used to dequeue a connection from MHD's event loop (external select, internal select or thread pool; not applicable to thread-per-connection!) for a while. If you use this API in conjunction with a internal select or a thread pool, you must set the option @code{MHD_ALLOW_SUSPEND_RESUME} to ensure that a resumed connection is immediately processed by MHD. Suspended connections continue to count against the total number of connections allowed (per daemon, as well as per IP, if such limits are set). Suspended connections will NOT time out; timeouts will restart when the connection handling is resumed. While a connection is suspended, MHD will not detect disconnects by the client. The only safe time to suspend a connection is from the @code{MHD_AccessHandlerCallback} or from the respective @code{MHD_ContentReaderCallback} (but in this case the response object must not be shared among multiple connections). When suspending from the @code{MHD_AccessHandlerCallback} you MUST afterwards return @code{MHD_YES} from the access handler callback (as MHD_NO would imply to both close and suspend the connection, which is not allowed). Finally, it is an API violation to call @code{MHD_stop_daemon} while having suspended connections (this will at least create memory and socket leaks or lead to undefined behavior). You must explicitly resume all connections before stopping the daemon. @table @var @item connection the connection to suspend @end table @end deftypefun @deftypefun enum MHD_Result MHD_resume_connection (struct MHD_Connection *connection) Resume handling of network data for suspended connection. It is safe to resume a suspended connection at any time. Calling this function on a connection that was not previously suspended will result in undefined behavior. If you are using this function in ``external'' select mode, you must make sure to run @code{MHD_run} afterwards (before again calling @code{MHD_get_fdset}), as otherwise the change may not be reflected in the set returned by @code{MHD_get_fdset} and you may end up with a connection that is stuck until the next network activity. You can check whether a connection is currently suspended using @code{MHD_get_connection_info} by querying for @code{MHD_CONNECTION_INFO_CONNECTION_SUSPENDED}. @table @var @item connection the connection to resume @end table @end deftypefun @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-dauth @chapter Utilizing Authentication @noindent MHD support three types of client authentication. Basic authentication uses a simple authentication method based on BASE64 algorithm. Username and password are exchanged in clear between the client and the server, so this method must only be used for non-sensitive content or when the session is protected with https. When using basic authentication MHD will have access to the clear password, possibly allowing to create a chained authentication toward an external authentication server. Digest authentication uses a one-way authentication method based on MD5 hash algorithm. Only the hash will transit over the network, hence protecting the user password. The nonce will prevent replay attacks. This method is appropriate for general use, especially when https is not used to encrypt the session. Client certificate authentication uses a X.509 certificate from the client. This is the strongest authentication mechanism but it requires the use of HTTPS. Client certificate authentication can be used simultaneously with Basic or Digest Authentication in order to provide a two levels authentication (like for instance separate machine and user authentication). A code example for using client certificates is presented in the MHD tutorial. @menu * microhttpd-dauth basic:: Using Basic Authentication. * microhttpd-dauth digest:: Using Digest Authentication. @end menu @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-dauth basic @section Using Basic Authentication @deftypefun {void} MHD_free (void *ptr) Free the memory given at @code{ptr}. Used to free data structures allocated by MHD. Calls @code{free(ptr)}. @end deftypefun @deftypefun {char *} MHD_basic_auth_get_username_password3 (struct MHD_Connection *connection) Get the username and password from the basic authorization header sent by the client. Return @code{NULL} if no Basic Authorization header set by the client or if Base64 encoding is invalid; a pointer to the structure with username and password if found values set by the client. If returned value is not @code{NULL}, the value must be @code{MHD_free()}'ed. @end deftypefun @deftypefun {enum MHD_Result} MHD_queue_basic_auth_fail_response3 (struct MHD_Connection *connection, const char *realm, int prefer_utf8, struct MHD_Response *response) Queues a response to request basic authentication from the client. Return @code{MHD_YES} if successful, otherwise @code{MHD_NO}. @var{realm} must reference to a zero-terminated string representing the realm. @var{prefer_utf8} if set to @code{MHD_YES} then parameter @code{charset} with value @code{UTF-8} will be added to the response authentication header which indicates that UTF-8 encoding is preferred for username and password. @var{response} a response structure to specify what shall be presented to the client with a 401 HTTP status. @end deftypefun @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-dauth digest @section Using Digest Authentication MHD supports MD5 (deprecated by IETF) and SHA-256 hash algorithms for digest authentication. The @code{MHD_DigestAuthAlgorithm} enumeration is used to specify which algorithm should be used. @deftp {Enumeration} MHD_DigestAuthAlgorithm Which digest algorithm should be used. Must be used consistently. @table @code @item MHD_DIGEST_ALG_AUTO Have MHD pick an algorithm currently considered secure. For now defaults to SHA-256. @item MHD_DIGEST_ALG_MD5 Force use of (deprecated, ancient, insecure) MD5. @item MHD_DIGEST_ALG_SHA256 Force use of SHA-256. @end table @end deftp @deftp {Enumeration} MHD_DigestAuthResult The result of digest authentication of the client. @table @code @item MHD_DAUTH_OK Authentication OK. @item MHD_DAUTH_ERROR General error, like ``out of memory''. @item MHD_DAUTH_WRONG_HEADER No ``Authorization'' header or wrong format of the header. @item MHD_DAUTH_WRONG_USERNAME Wrong ``username''. @item MHD_DAUTH_WRONG_REALM Wrong ``realm''. @item MHD_DAUTH_WRONG_URI Wrong ``URI'' (or URI parameters). @item MHD_DAUTH_NONCE_STALE The ``nonce'' is too old. Suggest the client to retry with the same username and password to get the fresh ``nonce''. The validity of the ``nonce'' may not be checked. @item MHD_DAUTH_NONCE_WRONG The ``nonce'' is wrong. May indicate an attack attempt. @item MHD_DAUTH_RESPONSE_WRONG The ``response'' is wrong. May indicate an attack attempt. @end table @end deftp @deftypefun {char *} MHD_digest_auth_get_username (struct MHD_Connection *connection) Find and return a pointer to the username value from the request header. Return @code{NULL} if the value is not found or header does not exist. If returned value is not @code{NULL}, the value must be @code{MHD_free()}'ed. @end deftypefun @deftypefun enum MHD_DigestAuthResult MHD_digest_auth_check3 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC7616. If valid return @code{MHD_DAUTH_OK}, otherwise return the error code. @var{realm} must reference to a zero-terminated string representing the realm. @var{username} must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. @var{password} must reference to a zero-terminated string representing the password, most probably it will be the result of a lookup of the username against a local database. @var{nonce_timeout} the nonce validity duration in seconds. Most of the time it is sound to specify 300 seconds as its values. @var{algo} which digest algorithm should we use. @end deftypefun @deftypefun int MHD_digest_auth_check2 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC2716. If valid return @code{MHD_YES}, otherwise return @code{MHD_NO}. @var{realm} must reference to a zero-terminated string representing the realm. @var{username} must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. @var{password} must reference to a zero-terminated string representing the password, most probably it will be the result of a lookup of the username against a local database. @var{nonce_timeout} is the amount of time in seconds for a nonce to be invalid. Most of the time it is sound to specify 300 seconds as its values. @var{algo} which digest algorithm should we use. @end deftypefun @deftypefun int MHD_digest_auth_check (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC2716. If valid return @code{MHD_YES}, otherwise return @code{MHD_NO}. Deprecated, use @code{MHD_digest_auth_check2} instead. @var{realm} must reference to a zero-terminated string representing the realm. @var{username} must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. @var{password} must reference to a zero-terminated string representing the password, most probably it will be the result of a lookup of the username against a local database. @var{nonce_timeout} is the amount of time in seconds for a nonce to be invalid. Most of the time it is sound to specify 300 seconds as its values. @end deftypefun @deftypefun enum MHD_DigestAuthResult MHD_digest_auth_check_digest3 (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t *digest, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC7616. If valid return @code{MHD_DAUTH_OK}, otherwise return the error code. @var{realm} must reference to a zero-terminated string representing the realm. @var{username} must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. @var{digest} the pointer to the binary digest for the precalculated hash value ``username:realm:password'' with specified @var{algo}. @var{digest_size} the number of bytes in @var{digest} (the size must match @var{algo}!) @var{nonce_timeout} the nonce validity duration in seconds. Most of the time it is sound to specify 300 seconds as its values. @var{algo} digest authentication algorithm to use. @end deftypefun @deftypefun int MHD_digest_auth_check_digest2 (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t *digest, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC2716. If valid return @code{MHD_YES}, otherwise return @code{MHD_NO}. @var{realm} must reference to a zero-terminated string representing the realm. @var{username} must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. @var{digest} pointer to the binary MD5 sum for the precalculated hash value ``userame:realm:password''. The size must match the selected @var{algo}! @var{nonce_timeout} is the amount of time in seconds for a nonce to be invalid. Most of the time it is sound to specify 300 seconds as its values. @var{algo} digest authentication algorithm to use. @end deftypefun @deftypefun int MHD_digest_auth_check_digest (struct MHD_Connection *connection, const char *realm, const char *username, const unsigned char digest[MHD_MD5_DIGEST_SIZE], unsigned int nonce_timeout) Checks if the provided values in the WWW-Authenticate header are valid and sound according to RFC2716. If valid return @code{MHD_YES}, otherwise return @code{MHD_NO}. Deprecated, use @code{MHD_digest_auth_check_digest2} instead. @var{realm} must reference to a zero-terminated string representing the realm. @var{username} must reference to a zero-terminated string representing the username, it is usually the returned value from MHD_digest_auth_get_username. @var{digest} pointer to the binary MD5 sum for the precalculated hash value ``userame:realm:password'' of @code{MHD_MD5_DIGEST_SIZE} bytes. @var{nonce_timeout} is the amount of time in seconds for a nonce to be invalid. Most of the time it is sound to specify 300 seconds as its values. @end deftypefun @deftypefun enum MHD_Result MHD_queue_auth_fail_response2 (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthAlgorithm algo) Queues a response to request authentication from the client, return @code{MHD_YES} if successful, otherwise @code{MHD_NO}. @var{realm} must reference to a zero-terminated string representing the realm. @var{opaque} must reference to a zero-terminated string representing a value that gets passed to the client and expected to be passed again to the server as-is. This value can be a hexadecimal or base64 string. @var{response} a response structure to specify what shall be presented to the client with a 401 HTTP status. @var{signal_stale} a value that signals "stale=true" in the response header to indicate the invalidity of the nonce and no need to ask for authentication parameters and only a new nonce gets generated. @code{MHD_YES} to generate a new nonce, @code{MHD_NO} to ask for authentication parameters. @var{algo} which digest algorithm should we use. The same algorithm must then be selected when checking digests received from clients! @end deftypefun @deftypefun enum MHD_Result MHD_queue_auth_fail_response (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale) Queues a response to request authentication from the client, return @code{MHD_YES} if successful, otherwise @code{MHD_NO}. @var{realm} must reference to a zero-terminated string representing the realm. @var{opaque} must reference to a zero-terminated string representing a value that gets passed to the client and expected to be passed again to the server as-is. This value can be a hexadecimal or base64 string. @var{response} a response structure to specify what shall be presented to the client with a 401 HTTP status. @var{signal_stale} a value that signals "stale=true" in the response header to indicate the invalidity of the nonce and no need to ask for authentication parameters and only a new nonce gets generated. @code{MHD_YES} to generate a new nonce, @code{MHD_NO} to ask for authentication parameters. @end deftypefun Example: handling digest authentication requests and responses. @example #define PAGE "libmicrohttpd demoAccess granted" #define DENIED "libmicrohttpd demoAccess denied" #define OPAQUE "11733b200778ce33060f31c9af70a870ba96ddd4" static int ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **ptr) @{ struct MHD_Response *response; char *username; const char *password = "testpass"; const char *realm = "test@@example.com"; int ret; static int already_called_marker; if (&already_called_marker != *req_cls) @{ /* Called for the first time, request not fully read yet */ *req_cls = &already_called_marker; /* Wait for complete request */ return MHD_YES; @} username = MHD_digest_auth_get_username (connection); if (username == NULL) @{ response = MHD_create_response_from_buffer(strlen (DENIED), DENIED, MHD_RESPMEM_PERSISTENT); ret = MHD_queue_auth_fail_response2 (connection, realm, OPAQUE, response, MHD_NO, MHD_DIGEST_ALG_SHA256); MHD_destroy_response(response); return ret; @} ret = MHD_digest_auth_check2 (connection, realm, username, password, 300, MHD_DIGEST_ALG_SHA256); MHD_free(username); if ( (ret == MHD_INVALID_NONCE) || (ret == MHD_NO) ) @{ response = MHD_create_response_from_buffer(strlen (DENIED), DENIED, MHD_RESPMEM_PERSISTENT); if (NULL == response) return MHD_NO; ret = MHD_queue_auth_fail_response2 (connection, realm, OPAQUE, response, (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO, MHD_DIGEST_ALG_SHA256); MHD_destroy_response(response); return ret; @} response = MHD_create_response_from_buffer (strlen(PAGE), PAGE, MHD_RESPMEM_PERSISTENT); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response(response); return ret; @} @end example @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-post @chapter Adding a @code{POST} processor @cindex POST method @menu * microhttpd-post api:: Programming interface for the @code{POST} processor. @end menu @noindent MHD provides the post processor API to make it easier for applications to parse the data of a client's @code{POST} request: the @code{MHD_AccessHandlerCallback} will be invoked multiple times to process data as it arrives; at each invocation a new chunk of data must be processed. The arguments @var{upload_data} and @var{upload_data_size} are used to reference the chunk of data. When @code{MHD_AccessHandlerCallback} is invoked for a new request: its @code{*@var{req_cls}} argument is set to @code{NULL}. When @code{POST} data comes in the upload buffer it is @strong{mandatory} to use the @var{req_cls} to store a reference to per-request data. The fact that the pointer was initially @code{NULL} can be used to detect that this is a new request. One method to detect that a new request was started is to set @code{*req_cls} to an unused integer: @example int access_handler (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) @{ static int old_connection_marker; int new_connection = (NULL == *req_cls); if (new_connection) @{ /* new connection with POST */ *req_cls = &old_connection_marker; @} ... @} @end example @noindent In contrast to the previous example, for @code{POST} requests in particular, it is more common to use the value of @code{*req_cls} to keep track of actual state used during processing, such as the post processor (or a struct containing a post processor): @example int access_handler (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls) @{ struct MHD_PostProcessor * pp = *req_cls; if (pp == NULL) @{ pp = MHD_create_post_processor(connection, ...); *req_cls = pp; return MHD_YES; @} if (*upload_data_size) @{ MHD_post_process(pp, upload_data, *upload_data_size); *upload_data_size = 0; return MHD_YES; @} else @{ MHD_destroy_post_processor(pp); return MHD_queue_response(...); @} @} @end example Note that the callback from @code{MHD_OPTION_NOTIFY_COMPLETED} should be used to destroy the post processor. This cannot be done inside of the access handler since the connection may not always terminate normally. @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-post api @section Programming interface for the @code{POST} processor @cindex POST method @deftypefun {struct MHD_PostProcessor *} MHD_create_post_processor (struct MHD_Connection *connection, size_t buffer_size, MHD_PostDataIterator iterator, void *iterator_cls) Create a PostProcessor. A PostProcessor can be used to (incrementally) parse the data portion of a @code{POST} request. @table @var @item connection the connection on which the @code{POST} is happening (used to determine the @code{POST} format); @item buffer_size maximum number of bytes to use for internal buffering (used only for the parsing, specifically the parsing of the keys). A tiny value (256-1024) should be sufficient; do @strong{NOT} use a value smaller than 256; for good performance, use 32k or 64k (i.e. 65536). @item iterator iterator to be called with the parsed data; must @strong{NOT} be @code{NULL}; @item iterator_cls custom value to be used as first argument to @var{iterator}. @end table Return @code{NULL} on error (out of memory, unsupported encoding), otherwise a PP handle. @end deftypefun @deftypefun enum MHD_Result MHD_post_process (struct MHD_PostProcessor *pp, const char *post_data, size_t post_data_len) Parse and process @code{POST} data. Call this function when @code{POST} data is available (usually during an @code{MHD_AccessHandlerCallback}) with the @var{upload_data} and @var{upload_data_size}. Whenever possible, this will then cause calls to the @code{MHD_IncrementalKeyValueIterator}. @table @var @item pp the post processor; @item post_data @var{post_data_len} bytes of @code{POST} data; @item post_data_len length of @var{post_data}. @end table Return @code{MHD_YES} on success, @code{MHD_NO} on error (out-of-memory, iterator aborted, parse error). @end deftypefun @deftypefun enum MHD_Result MHD_destroy_post_processor (struct MHD_PostProcessor *pp) Release PostProcessor resources. After this function is being called, the PostProcessor is guaranteed to no longer call its iterator. There is no special call to the iterator to indicate the end of the post processing stream. After destroying the PostProcessor, the programmer should perform any necessary work to complete the processing of the iterator. Return @code{MHD_YES} if processing completed nicely, @code{MHD_NO} if there were spurious characters or formatting problems with the post request. It is common to ignore the return value of this function. @end deftypefun @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-info @chapter Obtaining and modifying status information. @menu * microhttpd-info daemon:: State information about an MHD daemon * microhttpd-info conn:: State information about a connection * microhttpd-option conn:: Modify per-connection options @end menu @c ------------------------------------------------------------ @node microhttpd-info daemon @section Obtaining state information about an MHD daemon @deftypefun {const union MHD_DaemonInfo *} MHD_get_daemon_info (struct MHD_Daemon *daemon, enum MHD_DaemonInfoType infoType, ...) Obtain information about the given daemon. This function is currently not fully implemented. @table @var @item daemon the daemon about which information is desired; @item infoType type of information that is desired @item ... additional arguments about the desired information (depending on infoType) @end table Returns a union with the respective member (depending on infoType) set to the desired information), or @code{NULL} in case the desired information is not available or applicable. @end deftypefun @deftp {Enumeration} MHD_DaemonInfoType Values of this enum are used to specify what information about a daemon is desired. @table @code @item MHD_DAEMON_INFO_KEY_SIZE Request information about the key size for a particular cipher algorithm. The cipher algorithm should be passed as an extra argument (of type 'enum MHD_GNUTLS_CipherAlgorithm'). No longer supported, using this value will cause @code{MHD_get_daemon_info} to return NULL. @item MHD_DAEMON_INFO_MAC_KEY_SIZE Request information about the key size for a particular cipher algorithm. The cipher algorithm should be passed as an extra argument (of type 'enum MHD_GNUTLS_HashAlgorithm'). No longer supported, using this value will cause @code{MHD_get_daemon_info} to return NULL. @item MHD_DAEMON_INFO_LISTEN_FD @cindex listen Request the file-descriptor number that MHD is using to listen to the server socket. This can be useful if no port was specified and a client needs to learn what port is actually being used by MHD. No extra arguments should be passed. @item MHD_DAEMON_INFO_EPOLL_FD @cindex epoll Request the file-descriptor number that MHD is using for epoll. If the build is not supporting epoll, NULL is returned; if we are using a thread pool or this daemon was not started with @code{MHD_USE_EPOLL}, (a pointer to) -1 is returned. If we are using @code{MHD_USE_INTERNAL_POLLING_THREAD} or are in 'external' select mode, the internal epoll FD is returned. This function must be used in external select mode with epoll to obtain the FD to call epoll on. No extra arguments should be passed. @item MHD_DAEMON_INFO_CURRENT_CONNECTIONS @cindex connection, limiting number of connections Request the number of current connections handled by the daemon. No extra arguments should be passed and a pointer to a @code{union MHD_DaemonInfo} value is returned, with the @code{num_connections} member of type @code{unsigned int} set to the number of active connections. Note that in multi-threaded or internal-select mode, the real number of current connections may already be different when @code{MHD_get_daemon_info} returns. The number of current connections can be used (even in multi-threaded and internal-select mode) after @code{MHD_quiesce_daemon} to detect whether all connections have been handled. @end table @end deftp @c ------------------------------------------------------------ @node microhttpd-info conn @section Obtaining state information about a connection @deftypefun {const union MHD_ConnectionInfo *} MHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType infoType, ...) Obtain information about the given connection. @table @var @item connection the connection about which information is desired; @item infoType type of information that is desired @item ... additional arguments about the desired information (depending on infoType) @end table Returns a union with the respective member (depending on infoType) set to the desired information), or @code{NULL} in case the desired information is not available or applicable. @end deftypefun @deftp {Enumeration} MHD_ConnectionInfoType Values of this enum are used to specify what information about a connection is desired. @table @code @item MHD_CONNECTION_INFO_CIPHER_ALGO What cipher algorithm is being used (HTTPS connections only). @code{NULL} is returned for non-HTTPS connections. Takes no extra arguments. @item MHD_CONNECTION_INFO_PROTOCOL, Allows finding out the TLS/SSL protocol used (HTTPS connections only). @code{NULL} is returned for non-HTTPS connections. Takes no extra arguments. @item MHD_CONNECTION_INFO_CLIENT_ADDRESS Returns information about the address of the client. Returns essentially a @code{struct sockaddr **} (since the API returns a @code{union MHD_ConnectionInfo *} and that union contains a @code{struct sockaddr *}). Takes no extra arguments. @item MHD_CONNECTION_INFO_GNUTLS_SESSION, Takes no extra arguments. Allows access to the underlying GNUtls session, including access to the underlying GNUtls client certificate (HTTPS connections only). Takes no extra arguments. @code{NULL} is returned for non-HTTPS connections. Takes no extra arguments. @item MHD_CONNECTION_INFO_GNUTLS_CLIENT_CERT, Dysfunctional (never implemented, deprecated). Use MHD_CONNECTION_INFO_GNUTLS_SESSION to get the @code{gnutls_session_t} and then call @code{gnutls_certificate_get_peers()}. @item MHD_CONNECTION_INFO_DAEMON Returns information about @code{struct MHD_Daemon} which manages this connection. Takes no extra arguments. @item MHD_CONNECTION_INFO_CONNECTION_FD Returns the file descriptor (usually a TCP socket) associated with this connection (in the ``connect-fd'' member of the returned struct). Note that manipulating the descriptor directly can have problematic consequences (as in, break HTTP). Applications might use this access to manipulate TCP options, for example to set the ``TCP-NODELAY'' option for COMET-like applications. Note that MHD will set TCP-CORK after sending the HTTP header and clear it after finishing the footers automatically (if the platform supports it). As the connection callbacks are invoked in between, those might be used to set different values for TCP-CORK and TCP-NODELAY in the meantime. Takes no extra arguments. @item MHD_CONNECTION_INFO_CONNECTION_SUSPENDED Returns pointer to an integer that is @code{MHD_YES} if the connection is currently suspended (and thus can be safely resumed) and @code{MHD_NO} otherwise. Takes no extra arguments. @item MHD_CONNECTION_INFO_SOCKET_CONTEXT Returns the client-specific pointer to a @code{void *} that was (possibly) set during a @code{MHD_NotifyConnectionCallback} when the socket was first accepted. Note that this is NOT the same as the @code{req_cls} argument of the @code{MHD_AccessHandlerCallback}. The @code{req_cls} is fresh for each HTTP request, while the @code{socket_context} is fresh for each socket. Takes no extra arguments. @item MHD_CONNECTION_INFO_CONNECTION_TIMEOUT Returns pointer to an @code{unsigned int} that is the current timeout used for the connection (in seconds, 0 for no timeout). Note that while suspended connections will not timeout, the timeout value returned for suspended connections will be the timeout that the connection will use after it is resumed, and thus might not be zero. Takes no extra arguments. @item MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE @cindex performance Returns pointer to an @code{size_t} that represents the size of the HTTP header received from the client. Only valid after the first callback to the access handler. Takes no extra arguments. @item MHD_CONNECTION_INFO_HTTP_STATUS Returns the HTTP status code of the response that was queued. Returns NULL if no response was queued yet. Takes no extra arguments. @end table @end deftp @c ------------------------------------------------------------ @node microhttpd-option conn @section Setting custom options for an individual connection @cindex timeout @deftypefun {int} MHD_set_connection_option (struct MHD_Connection *daemon, enum MHD_CONNECTION_OPTION option, ...) Set a custom option for the given connection. @table @var @item connection the connection for which an option should be set or modified; @item option option to set @item ... additional arguments for the option (depending on option) @end table Returns @code{MHD_YES} on success, @code{MHD_NO} for errors (i.e. option argument invalid or option unknown). @end deftypefun @deftp {Enumeration} MHD_CONNECTION_OPTION Values of this enum are used to specify which option for a connection should be changed. @table @code @item MHD_CONNECTION_OPTION_TIMEOUT Set a custom timeout for the given connection. Specified as the number of seconds, given as an @code{unsigned int}. Use zero for no timeout. @end table @end deftp @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-util @chapter Utility functions. @menu * microhttpd-util feature:: Test supported MHD features * microhttpd-util unescape:: Unescape strings @end menu @c ------------------------------------------------------------ @node microhttpd-util feature @section Testing for supported MHD features @deftp {Enumeration} MHD_FEATURE Values of this enum are used to specify what information about a daemon is desired. @table @code @item MHD_FEATURE_MESSAGES Get whether messages are supported. If supported then in debug mode messages can be printed to stderr or to external logger. @item MHD_FEATURE_SSL Get whether HTTPS is supported. If supported then flag MHD_USE_SSL and options MHD_OPTION_HTTPS_MEM_KEY, MHD_OPTION_HTTPS_MEM_CERT, MHD_OPTION_HTTPS_MEM_TRUST, MHD_OPTION_HTTPS_MEM_DHPARAMS, MHD_OPTION_HTTPS_CRED_TYPE, MHD_OPTION_HTTPS_PRIORITIES can be used. @item MHD_FEATURE_HTTPS_CERT_CALLBACK Get whether option #MHD_OPTION_HTTPS_CERT_CALLBACK is supported. @item MHD_FEATURE_IPv6 Get whether IPv6 is supported. If supported then flag MHD_USE_IPv6 can be used. @item MHD_FEATURE_IPv6_ONLY Get whether IPv6 without IPv4 is supported. If not supported then IPv4 is always enabled in IPv6 sockets and flag MHD_USE_DUAL_STACK if always used when MHD_USE_IPv6 is specified. @item MHD_FEATURE_POLL Get whether @code{poll()} is supported. If supported then flag MHD_USE_POLL can be used. @item MHD_FEATURE_EPOLL Get whether @code{epoll()} is supported. If supported then Flags MHD_USE_EPOLL and MHD_USE_EPOLL_INTERNAL_THREAD can be used. @item MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET Get whether shutdown on listen socket to signal other threads is supported. If not supported flag MHD_USE_ITC is automatically forced. @item MHD_FEATURE_SOCKETPAIR Get whether a @code{socketpair()} is used internally instead of a @code{pipe()} to signal other threads. @item MHD_FEATURE_TCP_FASTOPEN Get whether TCP Fast Open is supported. If supported then flag MHD_USE_TCP_FASTOPEN and option MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE can be used. @item MHD_FEATURE_BASIC_AUTH Get whether HTTP Basic authorization is supported. If supported then functions @code{MHD_basic_auth_get_username_password()} and @code{MHD_queue_basic_auth_fail_response()} can be used. @item MHD_FEATURE_DIGEST_AUTH Get whether HTTP Digest authorization is supported. If supported then options MHD_OPTION_DIGEST_AUTH_RANDOM, MHD_OPTION_NONCE_NC_SIZE and functions @code{MHD_digest_auth_check()}, can be used. @item MHD_FEATURE_POSTPROCESSOR Get whether postprocessor is supported. If supported then functions @code{MHD_create_post_processor()}, @code{MHD_post_process()}, @code{MHD_destroy_post_processor()} can be used. @item MHD_FEATURE_SENDFILE Get whether @code{sendfile()} is supported. @end table @end deftp @deftypefun {int} MHD_is_feature_supported (enum MHD_FEATURE feature) Get information about supported MHD features. Indicate that MHD was compiled with or without support for particular feature. Some features require additional support by the kernel. However, kernel support is not checked by this function. @table @var @item feature type of requested information @end table Returns @code{MHD_YES} if the feature is supported, and @code{MHD_NO} if not. @end deftypefun @c ------------------------------------------------------------ @node microhttpd-util unescape @section Unescape strings @deftypefun {size_t} MHD_http_unescape (char *val) Process escape sequences ('%HH') Updates val in place; the result should be UTF-8 encoded and cannot be larger than the input. The result must also still be 0-terminated. @table @var @item val value to unescape (modified in the process), must be a 0-terminated UTF-8 string. @end table Returns length of the resulting val (@code{strlen(val)} may be shorter afterwards due to elimination of escape sequences). @end deftypefun @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ------------------------------------------------------------ @node microhttpd-websocket @chapter Websocket functions. @noindent Websocket functions provide what you need to use an upgraded connection as a websocket. These functions are only available if you include the header file @code{microhttpd_ws.h} and compiled @emph{libmicrohttpd} with websockets. @menu * microhttpd-websocket handshake:: Websocket handshake functions * microhttpd-websocket stream:: Websocket stream functions * microhttpd-websocket decode:: Websocket decode functions * microhttpd-websocket encode:: Websocket encode functions * microhttpd-websocket memory:: Websocket memory functions @end menu @c ------------------------------------------------------------ @node microhttpd-websocket handshake @section Websocket handshake functions @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_check_http_version (const char* http_version) @cindex websocket Checks the HTTP version of the incoming request. Websocket requests are only allowed for HTTP/1.1 or above. @table @var @item http_version The value of the @code{version} parameter of your @code{access_handler} callback. If you pass @code{NULL} then this is handled like a not matching HTTP version. @end table Returns 0 when the HTTP version is valid for a websocket request and a value less than zero when the HTTP version isn't valid for a websocket request. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_check_connection_header (const char* connection_header) @cindex websocket Checks the value of the @code{Connection} HTTP request header. Websocket requests require the token @code{Upgrade} in the @code{Connection} HTTP request header. @table @var @item connection_header Value of the @code{Connection} request header. You can get this request header value by passing @code{MHD_HTTP_HEADER_CONNECTION} to @code{MHD_lookup_connection_value()}. If you pass @code{NULL} then this is handled like a not matching @code{Connection} header value. @end table Returns 0 when the @code{Connection} header is valid for a websocket request and a value less than zero when the @code{Connection} header isn't valid for a websocket request. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_check_upgrade_header (const char* upgrade_header) @cindex websocket Checks the value of the @code{Upgrade} HTTP request header. Websocket requests require the value @code{websocket} in the @code{Upgrade} HTTP request header. @table @var @item upgrade_header Value of the @code{Upgrade} request header. You can get this request header value by passing @code{MHD_HTTP_HEADER_UPGRADE} to @code{MHD_lookup_connection_value()}. If you pass @code{NULL} then this is handled like a not matching @code{Upgrade} header value. @end table Returns 0 when the @code{Upgrade} header is valid for a websocket request and a value less than zero when the @code{Upgrade} header isn't valid for a websocket request. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_check_version_header (const char* version_header) @cindex websocket Checks the value of the @code{Sec-WebSocket-Version} HTTP request header. Websocket requests require the value @code{13} in the @code{Sec-WebSocket-Version} HTTP request header. @table @var @item version_header Value of the @code{Sec-WebSocket-Version} request header. You can get this request header value by passing @code{MHD_HTTP_HEADER_SEC_WEBSOCKET_VERSION} to @code{MHD_lookup_connection_value()}. If you pass @code{NULL} then this is handled like a not matching @code{Sec-WebSocket-Version} header value. @end table Returns 0 when the @code{Sec-WebSocket-Version} header is valid for a websocket request and a value less than zero when the @code{Sec-WebSocket-Version} header isn't valid for a websocket request. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_create_accept_header (const char* sec_websocket_key, char* sec_websocket_accept) @cindex websocket Checks the value of the @code{Sec-WebSocket-Key} HTTP request header and generates the value for the @code{Sec-WebSocket-Accept} HTTP response header. The generated value must be sent to the client. @table @var @item sec_websocket_key Value of the @code{Sec-WebSocket-Key} request header. You can get this request header value by passing @code{MHD_HTTP_HEADER_SEC_WEBSOCKET_KEY} to @code{MHD_lookup_connection_value()}. If you pass @code{NULL} then this is handled like a not matching @code{Sec-WebSocket-Key} header value. @item sec_websocket_accept Response buffer, which will receive the generated value for the @code{Sec-WebSocket-Accept} HTTP response header. This buffer must be at least 29 bytes long and will contain the response value plus a terminating @code{NUL} character on success. Must not be @code{NULL}. You can add this HTTP header to your response by passing @code{MHD_HTTP_HEADER_SEC_WEBSOCKET_ACCEPT} to @code{MHD_add_response_header()}. @end table Returns 0 when the @code{Sec-WebSocket-Key} header was not empty and a result value for the @code{Sec-WebSocket-Accept} was calculated. A value less than zero is returned when the @code{Sec-WebSocket-Key} header isn't valid for a websocket request or when any error occurred. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @c ------------------------------------------------------------ @node microhttpd-websocket stream @section Websocket stream functions @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_stream_init (struct MHD_WebSocketStream **ws, int flags, size_t max_payload_size) @cindex websocket Creates a new websocket stream, used for decoding/encoding. @table @var @item ws pointer a variable to fill with the newly created @code{struct MHD_WebSocketStream}, receives @code{NULL} on error. May not be @code{NULL}. If not required anymore, free the created websocket stream with @code{MHD_websocket_stream_free()}. @item flags combination of @code{enum MHD_WEBSOCKET_FLAG} values to modify the behavior of the websocket stream. @item max_payload_size maximum size for incoming payload data in bytes. Use 0 to allow each size. @end table Returns 0 on success, negative values on error. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_stream_init2 (struct MHD_WebSocketStream **ws, int flags, size_t max_payload_size, MHD_WebSocketMallocCallback callback_malloc, MHD_WebSocketReallocCallback callback_realloc, MHD_WebSocketFreeCallback callback_free, void* cls_rng, MHD_WebSocketRandomNumberGenerator callback_rng) @cindex websocket Creates a new websocket stream, used for decoding/encoding, but with custom memory functions for malloc, realloc and free. Also a random number generator can be specified for client mode. @table @var @item ws pointer a variable to fill with the newly created @code{struct MHD_WebSocketStream}, receives @code{NULL} on error. Must not be @code{NULL}. If not required anymore, free the created websocket stream with @code{MHD_websocket_stream_free}. @item flags combination of @code{enum MHD_WEBSOCKET_FLAG} values to modify the behavior of the websocket stream. @item max_payload_size maximum size for incoming payload data in bytes. Use 0 to allow each size. @item callback_malloc callback function for allocating memory. Must not be @code{NULL}. The shorter @code{MHD_websocket_stream_init()} passes a reference to @code{malloc} here. @item callback_realloc callback function for reallocating memory. Must not be @code{NULL}. The shorter @code{MHD_websocket_stream_init()} passes a reference to @code{realloc} here. @item callback_free callback function for freeing memory. Must not be @code{NULL}. The shorter @code{MHD_websocket_stream_init()} passes a reference to @code{free} here. @item cls_rng closure for the random number generator. This is only required when @code{MHD_WEBSOCKET_FLAG_CLIENT} is passed in @code{flags}. The given value is passed to the random number generator callback. May be @code{NULL} if not needed. Should be @code{NULL} when you are not using @code{MHD_WEBSOCKET_FLAG_CLIENT}. The shorter @code{MHD_websocket_stream_init} passes @code{NULL} here. @item callback_rng callback function for a secure random number generator. This is only required when @code{MHD_WEBSOCKET_FLAG_CLIENT} is passed in @code{flags} and must not be @code{NULL} then. Should be @code{NULL} otherwise. The shorter @code{MHD_websocket_stream_init()} passes @code{NULL} here. @end table Returns 0 on success, negative values on error. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_stream_free (struct MHD_WebSocketStream *ws) @cindex websocket Frees a previously allocated websocket stream @table @var @item ws websocket stream to free, this value may be @code{NULL}. @end table Returns 0 on success, negative values on error. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_stream_invalidate (struct MHD_WebSocketStream *ws) @cindex websocket Invalidates a websocket stream. After invalidation a websocket stream cannot be used for decoding anymore. Encoding is still possible. @table @var @item ws websocket stream to invalidate. @end table Returns 0 on success, negative values on error. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_VALIDITY} MHD_websocket_stream_is_valid (struct MHD_WebSocketStream *ws) @cindex websocket Queries whether a websocket stream is valid. Invalidated websocket streams cannot be used for decoding anymore. Encoding is still possible. @table @var @item ws websocket stream to invalidate. @end table Returns 0 if invalid, 1 if valid for all types or 2 if valid only for control frames. Can be compared with @code{enum MHD_WEBSOCKET_VALIDITY}. @end deftypefun @c ------------------------------------------------------------ @node microhttpd-websocket decode @section Websocket decode functions @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_decode (struct MHD_WebSocketStream* ws, const char* streambuf, size_t streambuf_len, size_t* streambuf_read_len, char** payload, size_t* payload_len) @cindex websocket Decodes a byte sequence for a websocket stream. Decoding is done until either a frame is complete or the end of the byte sequence is reached. @table @var @item ws websocket stream for decoding. @item streambuf byte sequence for decoding. This is what you typically received via @code{recv()}. @item streambuf_len length of the byte sequence in parameter @code{streambuf}. @item streambuf_read_len pointer to a variable, which receives the number of bytes, that has been processed by this call. This value may be less than the value of @code{streambuf_len} when a frame is decoded before the end of the buffer is reached. The remaining bytes of @code{buf} must be passed to the next call of this function. @item payload pointer to a variable, which receives the allocated buffer with the payload data of the decoded frame. Must not be @code{NULL}. If no decoded data is available or an error occurred @code{NULL} is returned. When the returned value is not @code{NULL} then the buffer contains always @code{payload_len} bytes plus one terminating @code{NUL} character (regardless of the frame type). The caller must free this buffer using @code{MHD_websocket_free()}. If you passed the flag @code{MHD_WEBSOCKET_FLAG_GENERATE_CLOSE_FRAMES_ON_ERROR} upon creation of the websocket stream and a decoding error occurred (function return value less than 0), then this buffer contains a generated close frame, which must be sent via the socket to the recipient. If you passed the flag @code{MHD_WEBSOCKET_FLAG_WANT_FRAGMENTS} upon creation of the websocket stream then this payload may only be a part of the complete message. Only complete UTF-8 sequences are returned for fragmented text frames. If necessary the UTF-8 sequence will be completed with the next text fragment. @item payload_len pointer to a variable, which receives length of the result @code{payload} buffer in bytes. Must not be @code{NULL}. This receives 0 when no data is available, when the decoded payload has a length of zero or when an error occurred. @end table Returns a value greater than zero when a frame is complete. Compare with @code{enum MHD_WEBSOCKET_STATUS} to distinguish the frame type. Returns 0 when the call succeeded, but no frame is available. Returns a value less than zero on errors. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_split_close_reason (const char* payload, size_t payload_len, unsigned short* reason_code, const char** reason_utf8, size_t* reason_utf8_len) @cindex websocket Splits the payload of a decoded close frame. @table @var @item payload payload of the close frame. This parameter may only be @code{NULL} if @code{payload_len} is 0. @item payload_len length of @code{payload}. @item reason_code pointer to a variable, which receives the numeric close reason. If there was no close reason, this is 0. This value can be compared with @code{enum MHD_WEBSOCKET_CLOSEREASON}. May be @code{NULL}. @item reason_utf8 pointer to a variable, which receives the literal close reason. If there was no literal close reason, this will be @code{NULL}. May be @code{NULL}. Please note that no memory is allocated in this function. If not @code{NULL} the returned value of this parameter points to a position in the specified @code{payload}. @item reason_utf8_len pointer to a variable, which receives the length of the literal close reason. If there was no literal close reason, this is 0. May be @code{NULL}. @end table Returns 0 on success or a value less than zero on errors. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @c ------------------------------------------------------------ @node microhttpd-websocket encode @section Websocket encode functions @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_encode_text (struct MHD_WebSocketStream* ws, const char* payload_utf8, size_t payload_utf8_len, int fragmentation, char** frame, size_t* frame_len, int* utf8_step) @cindex websocket Encodes an UTF-8 encoded text into websocket text frame @table @var @item ws websocket stream; @item payload_utf8 text to send. This must be UTF-8 encoded. If you don't want UTF-8 then send a binary frame with @code{MHD_websocket_encode_binary()} instead. May be be @code{NULL} if @code{payload_utf8_len} is 0, must not be @code{NULL} otherwise. @item payload_utf8_len length of @code{payload_utf8} in bytes. @item fragmentation A value of @code{enum MHD_WEBSOCKET_FRAGMENTATION} to specify the fragmentation behavior. Specify @code{MHD_WEBSOCKET_FRAGMENTATION_NONE} or just 0 if you don't want to use fragmentation (default). @item frame pointer to a variable, which receives a buffer with the encoded text frame. Must not be @code{NULL}. The buffer contains what you typically send via @code{send()} to the recipient. If no encoded data is available the variable receives @code{NULL}. If the variable is not @code{NULL} then the buffer contains always @code{frame_len} bytes plus one terminating @code{NUL} character. The caller must free this buffer using @code{MHD_websocket_free()}. @item frame_len pointer to a variable, which receives the length of the encoded frame in bytes. Must not be @code{NULL}. @item utf8_step If fragmentation is used (the parameter @code{fragmentation} is not 0) then is parameter is required and must not be @code{NULL}. If no fragmentation is used, this parameter is optional and should be @code{NULL}. This parameter is a pointer to a variable which contains the last check status of the UTF-8 sequence. It is required to continue a previous UTF-8 sequence check when fragmentation is used, because a UTF-8 sequence could be split upon fragments. @code{enum MHD_WEBSOCKET_UTF8STEP} is used for this value. If you start a new fragment using @code{MHD_WEBSOCKET_FRAGMENTATION_NONE} or @code{MHD_WEBSOCKET_FRAGMENTATION_FIRST} the old value of this variable will be discarded and the value of this variable will be initialized to @code{MHD_WEBSOCKET_UTF8STEP_NORMAL}. On all other fragmentation modes the previous value of the pointed variable will be used to continue the UTF-8 sequence check. @end table Returns 0 on success or a value less than zero on errors. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_encode_binary (struct MHD_WebSocketStream* ws, const char* payload, size_t payload_len, int fragmentation, char** frame, size_t* frame_len) @cindex websocket Encodes binary data into websocket binary frame @table @var @item ws websocket stream; @item payload binary data to send. May be be @code{NULL} if @code{payload_len} is 0, must not be @code{NULL} otherwise. @item payload_len length of @code{payload} in bytes. @item fragmentation A value of @code{enum MHD_WEBSOCKET_FRAGMENTATION} to specify the fragmentation behavior. Specify @code{MHD_WEBSOCKET_FRAGMENTATION_NONE} or just 0 if you don't want to use fragmentation (default). @item frame pointer to a variable, which receives a buffer with the encoded binary frame. Must not be @code{NULL}. The buffer contains what you typically send via @code{send()} to the recipient. If no encoded data is available the variable receives @code{NULL}. If the variable is not @code{NULL} then the buffer contains always @code{frame_len} bytes plus one terminating @code{NUL} character. The caller must free this buffer using @code{MHD_websocket_free()}. @item frame_len pointer to a variable, which receives the length of the encoded frame in bytes. Must not be @code{NULL}. @end table Returns 0 on success or a value less than zero on errors. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_encode_ping (struct MHD_WebSocketStream* ws, const char* payload, size_t payload_len, char** frame, size_t* frame_len) @cindex websocket Encodes a websocket ping frame. Ping frames are used to check whether a recipient is still available and what latency the websocket connection has. @table @var @item ws websocket stream; @item payload binary ping data to send. May be @code{NULL} if @code{payload_len} is 0. @item payload_len length of @code{payload} in bytes. This may not exceed 125 bytes. @item frame pointer to a variable, which receives a buffer with the encoded ping frame. Must not be @code{NULL}. The buffer contains what you typically send via @code{send()} to the recipient. If no encoded data is available the variable receives @code{NULL}. If the variable is not @code{NULL} then the buffer contains always @code{frame_len} bytes plus one terminating @code{NUL} character. The caller must free this buffer using @code{MHD_websocket_free()}. @item frame_len pointer to a variable, which receives the length of the encoded frame in bytes. Must not be @code{NULL}. @end table Returns 0 on success or a value less than zero on errors. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_encode_pong (struct MHD_WebSocketStream* ws, const char* payload, size_t payload_len, char** frame, size_t* frame_len) @cindex websocket Encodes a websocket pong frame. Pong frames are used to answer a previously received websocket ping frame. @table @var @item ws websocket stream; @item payload binary pong data to send, which should be the decoded payload from the received ping frame. May be @code{NULL} if @code{payload_len} is 0. @item payload_len length of @code{payload} in bytes. This may not exceed 125 bytes. @item frame pointer to a variable, which receives a buffer with the encoded pong frame. Must not be @code{NULL}. The buffer contains what you typically send via @code{send()} to the recipient. If no encoded data is available the variable receives @code{NULL}. If the variable is not @code{NULL} then the buffer contains always @code{frame_len} bytes plus one terminating @code{NUL} character. The caller must free this buffer using @code{MHD_websocket_free()}. @item frame_len pointer to a variable, which receives the length of the encoded frame in bytes. Must not be @code{NULL}. @end table Returns 0 on success or a value less than zero on errors. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @deftypefun {enum MHD_WEBSOCKET_STATUS} MHD_websocket_encode_close (struct MHD_WebSocketStream* ws, unsigned short reason_code, const char* reason_utf8, size_t reason_utf8_len, char** frame, size_t* frame_len) @cindex websocket Encodes a websocket close frame. Close frames are used to close a websocket connection in a formal way. @table @var @item ws websocket stream; @item reason_code reason for close. You can use @code{enum MHD_WEBSOCKET_CLOSEREASON} for typical reasons, but you are not limited to these values. The allowed values are specified in RFC 6455 7.4. If you don't want to enter a reason, you can specify @code{MHD_WEBSOCKET_CLOSEREASON_NO_REASON} (or just 0) then no reason is encoded. @item reason_utf8 An UTF-8 encoded text reason why the connection is closed. This may be @code{NULL} if @code{reason_utf8_len} is 0. This must be @code{NULL} if @code{reason_code} equals to zero (@code{MHD_WEBSOCKET_CLOSEREASON_NO_REASON}). @item reason_utf8_len length of the UTF-8 encoded text reason in bytes. This may not exceed 123 bytes. @item frame pointer to a variable, which receives a buffer with the encoded close frame. Must not be @code{NULL}. The buffer contains what you typically send via @code{send()} to the recipient. If no encoded data is available the variable receives @code{NULL}. If the variable is not @code{NULL} then the buffer contains always @code{frame_len} bytes plus one terminating @code{NUL} character. The caller must free this buffer using @code{MHD_websocket_free()}. @item frame_len pointer to a variable, which receives the length of the encoded frame in bytes. Must not be @code{NULL}. @end table Returns 0 on success or a value less than zero on errors. Can be compared with @code{enum MHD_WEBSOCKET_STATUS}. @end deftypefun @c ------------------------------------------------------------ @node microhttpd-websocket memory @section Websocket memory functions @deftypefun {void*} MHD_websocket_malloc (struct MHD_WebSocketStream* ws, size_t buf_len) @cindex websocket Allocates memory with the associated @code{malloc()} function of the websocket stream. The memory allocation function could be different for a websocket stream if @code{MHD_websocket_stream_init2()} has been used for initialization. @table @var @item ws websocket stream; @item buf_len size of the buffer to allocate in bytes. @end table Returns the pointer of the allocated buffer or @code{NULL} on failure. @end deftypefun @deftypefun {void*} MHD_websocket_realloc (struct MHD_WebSocketStream* ws, void* buf, size_t new_buf_len) @cindex websocket Reallocates memory with the associated @code{realloc()} function of the websocket stream. The memory reallocation function could be different for a websocket stream if @code{MHD_websocket_stream_init2()} has been used for initialization. @table @var @item ws websocket stream; @item buf current buffer, may be @code{NULL}; @item new_buf_len new size of the buffer in bytes. @end table Return the pointer of the reallocated buffer or @code{NULL} on failure. On failure the old pointer remains valid. @end deftypefun @deftypefun {void} MHD_websocket_free (struct MHD_WebSocketStream* ws, void* buf) @cindex websocket Frees memory with the associated @code{free()} function of the websocket stream. The memory free function could be different for a websocket stream if @code{MHD_websocket_stream_init2()} has been used for initialization. @table @var @item ws websocket stream; @item buf buffer to free, this may be @code{NULL} then nothing happens. @end table @end deftypefun @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @c ********************************************************** @c ******************* Appendices ************************* @c ********************************************************** @node GNU-LGPL @unnumbered GNU-LGPL @cindex license @include lgpl.texi @node eCos License @unnumbered eCos License @cindex license @include ecos.texi @node GNU-GPL @unnumbered GNU General Public License @cindex license @include gpl-2.0.texi @node GNU-FDL @unnumbered GNU-FDL @cindex license @include fdl-1.3.texi @node Concept Index @unnumbered Concept Index @printindex cp @node Function and Data Index @unnumbered Function and Data Index @printindex fn @node Type Index @unnumbered Type Index @printindex tp @bye libmicrohttpd-1.0.1/doc/doxygen/0000755000175000017500000000000014566140217012346 5libmicrohttpd-1.0.1/doc/doxygen/Makefile.am0000644000175000017500000000061614441373361014325 # This Makefile.am is in the public domain all: @echo -e \ "Generate doxygen additional documentation:\n" \ "\tmake full - full documentation with dependency graphs (slow)\n" \ "\tmake fast - fast mode without dependency graphs" full: libmicrohttpd.doxy doxygen $< fast: libmicrohttpd.doxy sed 's/\(HAVE_DOT.*=\).*/\1 NO/' $< | doxygen - clean: rm -rf html EXTRA_DIST = libmicrohttpd.doxy libmicrohttpd-1.0.1/doc/doxygen/libmicrohttpd.doxy.in0000644000175000017500000032217414417460232016452 # Doxyfile 1.8.13 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a double hash (##) is considered a comment and is placed in # front of the TAG it is preceding. # # All text after a single hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all text # before the first occurrence of this tag. Doxygen uses libiconv (or the iconv # built into libc) for the transcoding. See http://www.gnu.org/software/libiconv # for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by # double-quotes, unless you are using Doxywizard) that should identify the # project for which the documentation is generated. This name is used in the # title of most generated pages and in a few other places. # The default value is: My Project. PROJECT_NAME = "GNU libmicrohttpd" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. PROJECT_NUMBER = @PACKAGE_VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. OUTPUT_DIRECTORY = . # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and # will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes # performance problems for the file system. # The default value is: NO. CREATE_SUBDIRS = YES # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode # U+3044. # The default value is: NO. ALLOW_UNICODE_NAMES = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, # Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), # Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, # Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), # Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, # Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, # Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, # Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # description of a member or function before the detailed description # # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. # The default value is: YES. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator that is # used to form the text in various listings. Each string in this list, if found # as the leading text of the brief description, will be stripped from the text # and the result, after processing the whole list, is used as the annotated # text. Otherwise, the brief description is used as-is. If left blank, the # following values are used ($name is automatically replaced with the name of # the entity):The $name class, The $name widget, The $name file, is, provides, # specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # doxygen will generate a detailed section even if there is only a brief # description. # The default value is: NO. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. # The default value is: NO. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the # shortest path that makes the file name unique will be used # The default value is: YES. FULL_PATH_NAMES = YES # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand # part of the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the path to # strip. # # Note that you can specify absolute paths here, but also relative paths, which # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. STRIP_FROM_PATH = ../.. # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which # header file to include in order to use a class. If left blank only the name of # the header file containing the class definition is used. Otherwise one should # specify the list of include paths that are normally passed to the compiler # using the -I flag. STRIP_FROM_INC_PATH = ../../src/include \ src/include # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't # support long names like on DOS, Mac, or CD-ROM. # The default value is: NO. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the # first line (until the first dot) of a Javadoc-style comment as the brief # description. If set to NO, the Javadoc-style will behave just like regular Qt- # style comments (thus requiring an explicit @brief command for a brief # description.) # The default value is: NO. JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus # requiring an explicit \brief command for a brief description.) # The default value is: NO. QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a # multi-line C++ special comment block (i.e. a block of //! or /// comments) as # a brief description. This used to be the default behavior. The new default is # to treat a multi-line C++ comment block as a detailed description. Set this # tag to YES if you prefer the old behavior instead. # # Note that setting this tag to YES also means that rational rose comments are # not recognized any more. # The default value is: NO. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. INHERIT_DOCS = NO # If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new # page for each member. If set to NO, the documentation of a member will be part # of the file/class/namespace that contains it. # The default value is: NO. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen # uses this value to replace tabs by spaces in code fragments. # Minimum value: 1, maximum value: 16, default value: 4. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that act as commands in # the documentation. An alias has the form: # name=value # For example adding # "sideeffect=@par Side Effects:\n" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" # will allow you to use the command class in the itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all # members will be omitted, etc. # The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored # for that language. For instance, namespaces will be presented as packages, # qualified scopes will look different, etc. # The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources. Doxygen will then generate output that is tailored for Fortran. # The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for VHDL. # The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and # language is one of the parsers supported by doxygen: IDL, Java, Javascript, # C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: # FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: # Fortran. In the later case the parser tries to guess whether the code is fixed # or free formatted code, this is the default for Fortran type files), VHDL. For # instance to make doxygen treat .inc files as Fortran files (default is PHP), # and .f files as C (default is Fortran), use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. # The default value is: YES. MARKDOWN_SUPPORT = YES # When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up # to that level are automatically included in the table of contents, even if # they do not have an id attribute. # Note: This feature currently applies only to Markdown headings. # Minimum value: 0, maximum value: 99, default value: 0. # This tag requires that the tag MARKDOWN_SUPPORT is set to YES. TOC_INCLUDE_HEADINGS = 0 # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should set this # tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); # versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. # The default value is: NO. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. # The default value is: NO. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES will make # doxygen to replace the get and set methods by a property in the documentation. # This will only work if the methods are indeed getting or setting a simple # type. If this is not the case, or you want to show the methods anyway, you # should set this option to NO. # The default value is: YES. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. # The default value is: NO. DISTRIBUTE_GROUP_DOC = NO # If one adds a struct or class to a group and this option is enabled, then also # any nested class or struct is added to the same group. By default this option # is disabled and one has to add nested compounds explicitly via \ingroup. # The default value is: NO. GROUP_NESTED_COMPOUNDS = NO # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that # type (e.g. under the Public Functions section). Set it to NO to prevent # subgrouping. Alternatively, this can be done per class using the # \nosubgrouping command. # The default value is: YES. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions # are shown inside the group in which they are included (e.g. using \ingroup) # instead of on a separate page (for HTML and Man pages) or section (for LaTeX # and RTF). # # Note that this feature does not work in combination with # SEPARATE_MEMBER_PAGES. # The default value is: NO. INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions # with only public data fields or simple typedef fields will be shown inline in # the documentation of the scope in which they are defined (i.e. file, # namespace, or group documentation), provided this scope is documented. If set # to NO, structs, classes, and unions are shown on a separate page (for HTML and # Man pages) or section (for LaTeX and RTF). # The default value is: NO. INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically be # useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. # The default value is: NO. TYPEDEF_HIDES_STRUCT = NO # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This # cache is used to resolve symbols given their name and scope. Since this can be # an expensive process and often the same symbol appears multiple times in the # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small # doxygen will become slower. If the cache is too large, memory is wasted. The # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range # is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 # symbols. At the end of a run doxygen will report the cache usage and suggest # the optimal cache size from a speed point of view. # Minimum value: 0, maximum value: 9, default value: 0. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in # documentation are documented, even if no documentation was available. Private # class members and static file members will be hidden unless the # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. # Note: This will also disable the warnings about undocumented members that are # normally produced when WARNINGS is set to YES. # The default value is: NO. EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES, all static members of a file will be # included in the documentation. # The default value is: NO. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, # only classes defined in header files are included. Does not have any effect # for Java sources. # The default value is: YES. EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are # included in the documentation. If set to NO, only methods in the interface are # included. # The default value is: NO. EXTRACT_LOCAL_METHODS = YES # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base name of # the file that contains the anonymous namespace. By default anonymous namespace # are hidden. # The default value is: NO. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation # section is generated. This option has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option # has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # (class|struct|union) declarations. If set to NO, these declarations will be # included in the documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any # documentation blocks found inside the body of a function. If set to NO, these # blocks will be appended to the function's detailed documentation block. # The default value is: NO. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation that is typed after a # \internal command is included. If the tag is set to NO then the documentation # will be excluded. Set it to YES to include the internal documentation. # The default value is: NO. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file # names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. # The default value is: system dependent. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the # scope will be hidden. # The default value is: NO. HIDE_SCOPE_NAMES = NO # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will # append additional text to a page's title, such as Class Reference. If set to # YES the compound reference will be hidden. # The default value is: NO. HIDE_COMPOUND_REFERENCE= NO # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. SHOW_INCLUDE_FILES = YES # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each # grouped member an include statement to the documentation, telling the reader # which file to include in order to use the member. # The default value is: NO. SHOW_GROUPED_MEMB_INC = NO # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include # files with double quotes in the documentation rather than with sharp brackets. # The default value is: NO. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the # documentation for inline members. # The default value is: YES. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the # (detailed) documentation of file and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. # The default value is: YES. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. Note that # this will also influence the order of the classes in the class list. # The default value is: NO. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the # (brief and detailed) documentation of class members so that constructors and # destructors are listed first. If set to NO the constructors will appear in the # respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. # Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief # member documentation. # Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting # detailed member documentation. # The default value is: NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy # of group names into alphabetical order. If set to NO the group names will # appear in their defined order. # The default value is: NO. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will # be sorted only by class name, not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the alphabetical # list. # The default value is: NO. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper # type resolution of all parameters of a function it will reject a match between # the prototype and the implementation of a member function even if there is # only one candidate or it is obvious which candidate to choose by doing a # simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still # accept a match between prototype and implementation in such cases. # The default value is: NO. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo # list. This list is created by putting \todo commands in the documentation. # The default value is: YES. GENERATE_TODOLIST = NO # The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test # list. This list is created by putting \test commands in the documentation. # The default value is: YES. GENERATE_TESTLIST = NO # The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug # list. This list is created by putting \bug commands in the documentation. # The default value is: YES. GENERATE_BUGLIST = NO # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) # the deprecated list. This list is created by putting \deprecated commands in # the documentation. # The default value is: YES. GENERATE_DEPRECATEDLIST= NO # The ENABLED_SECTIONS tag can be used to enable conditional documentation # sections, marked by \if ... \endif and \cond # ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the # documentation. If the initializer consists of more lines than specified here # it will be hidden. Use a value of 0 to hide initializers completely. The # appearance of the value of individual variables and macros / defines can be # controlled using \showinitializer or \hideinitializer command in the # documentation regardless of this setting. # Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at # the bottom of the documentation of classes and structs. If set to YES, the # list will mention the files that were used to generate the documentation. # The default value is: YES. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This # will remove the Files entry from the Quick Index and from the Folder Tree View # (if specified). # The default value is: YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # page. This will remove the Namespaces entry from the Quick Index and from the # Folder Tree View (if specified). # The default value is: YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command command input-file, where command is the value of the # FILE_VERSION_FILTER tag, and input-file is the name of an input file provided # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml # will be used as the name of the layout file. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool # to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated to # standard output by doxygen. If QUIET is set to YES this implies that the # messages are off. # The default value is: NO. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated to standard error (stderr) by doxygen. If WARNINGS is set to YES # this implies that the warnings are on. # # Tip: Turn warnings on while writing the documentation. # The default value is: YES. WARNINGS = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag # will automatically be disabled. # The default value is: YES. WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters # in a documented function, or documenting parameters that don't exist or using # markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete # parameter documentation, but not about the absence of documentation. # The default value is: NO. WARN_NO_PARAMDOC = NO # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. # The default value is: NO. WARN_AS_ERROR = NO # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) # The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard # error (stderr). WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag is used to specify the files and/or directories that contain # documented source files. You may enter file names like myfile.cpp or # directories like /usr/src/myproject. Separate the files or directories with # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. INPUT = ../.. # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: http://www.gnu.org/software/libiconv) for the list of # possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, # *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. FILE_PATTERNS = *.c \ *.h # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. # The default value is: NO. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. # The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* EXCLUDE_PATTERNS = */test_* \ */.svn/* \ */perf_* \ */tls_test_* \ */examples/* \ */testcurl/* \ */testzzuf/* \ */platform/* \ */symbian/* \ MHD_config.h \ microhttpd2.h # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = MHD_DLOG # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and # *.h) to filter out the source-files in the directories. If left blank all # files are included. EXAMPLE_PATTERNS = * # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude commands # irrespective of the value of the RECURSIVE tag. # The default value is: NO. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or directories # that contain images that are to be included in the documentation (see the # \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command: # # # # where is the value of the INPUT_FILTER tag, and is the # name of an input file. Doxygen will then use the output that the filter # program writes to standard output. If FILTER_PATTERNS is specified, this tag # will be ignored. # # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: pattern=filter # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will also be used to filter the input files that are used for # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). # The default value is: NO. FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) and # it is also possible to disable source filtering for a specific pattern using # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will be # generated. Documented entities will be cross-referenced with these sources. # # Note: To get rid of all source code in the generated output, make sure that # also VERBATIM_HEADERS is set to NO. # The default value is: NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body of functions, # classes and enums directly into the documentation. # The default value is: NO. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any # special comment blocks from generated source code fragments. Normal C, C++ and # Fortran comments will always remain visible. # The default value is: YES. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented # function all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES then for each documented function # all documented entities called/used by that function will be listed. # The default value is: NO. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set # to YES then the hyperlinks from functions in REFERENCES_RELATION and # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will # link to the documentation. # The default value is: YES. REFERENCES_LINK_SOURCE = YES # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the # source code will show a tooltip with additional information such as prototype, # brief description and links to the definition and documentation. Since this # will make the HTML file larger and loading of large files a bit slower, you # can opt to disable this feature. # The default value is: YES. # This tag requires that the tag SOURCE_BROWSER is set to YES. SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system # (see http://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global # - Enable SOURCE_BROWSER and USE_HTAGS in the config file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # # Doxygen will invoke htags (and that will in turn invoke gtags), so these # tools must be available from the command line (i.e. in the search path). # # The result: instead of the source browser generated by doxygen, the links to # source code will now point to the output of htags. # The default value is: NO. # This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a # verbatim copy of the header file for each class for which an include is # specified. Set to NO to disable this. # See also: Section \class. # The default value is: YES. VERBATIM_HEADERS = NO # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the # clang parser (see: http://clang.llvm.org/) for more accurate parsing at the # cost of reduced performance. This can be particularly helpful with template # rich C++ code for which doxygen's built-in parser lacks the necessary type # information. # Note: The availability of this option depends on whether or not doxygen was # generated with the -Duse-libclang=ON option for CMake. # The default value is: NO. CLANG_ASSISTED_PARSING = NO # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that # the include paths will already be set by doxygen for the files and directories # specified with INPUT and INCLUDE_PATH. # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. CLANG_OPTIONS = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all # compounds will be generated. Enable this if the project contains a lot of # classes, structs, unions or interfaces. # The default value is: YES. ALPHABETICAL_INDEX = YES # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in # which the alphabetical index list will be split. # Minimum value: 1, maximum value: 20, default value: 5. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). # The default value is: .html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a user-defined HTML header file for # each generated HTML page. If the tag is left blank doxygen will generate a # standard header. # # To get valid HTML the header file that includes any scripts and style sheets # that doxygen needs, which is dependent on the configuration options used (e.g. # the setting GENERATE_TREEVIEW). It is highly recommended to start with a # default header using # doxygen -w html new_header.html new_footer.html new_stylesheet.css # YourConfigFile # and then modify the file new_header.html. See also section "Doxygen usage" # for information on how to generate the default header that doxygen normally # uses. # Note: The header is subject to change so you typically have to regenerate the # default header when upgrading to a newer version of doxygen. For a description # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard # footer. See HTML_HEADER for more information on how to generate a default # footer and what special commands can be used inside the footer. See also # section "Doxygen usage" for information on how to generate the default footer # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of # the HTML output. If left blank doxygen will generate a default style sheet. # See also section "Doxygen usage" for information on how to generate the style # sheet that doxygen normally uses. # Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as # it is more robust and this tag (HTML_STYLESHEET) will in the future become # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the # standard style sheet and is therefore more robust against future updates. # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that the # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see # http://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors # in the HTML output. For a value of 0 the output will use grayscales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the # luminance component of the colors in the HTML output. Values below 100 # gradually make the output lighter, whereas values above 100 make the output # darker. The value divided by 100 is the actual gamma applied, so 80 represents # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not # change the gamma. # Minimum value: 40, maximum value: 240, default value: 80. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this # to YES can help to show when doxygen was last run and thus if the # documentation is up to date. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand # and collapse entries dynamically later on. Doxygen will expand the tree to # such a level that at most the specified number of entries are visible (unless # a fully collapsed tree already exceeds this amount). So setting the number of # entries 1 will produce a full collapsed tree by default. 0 is a special value # representing an infinite number of entries and will result in a full expanded # tree by default. # Minimum value: 0, maximum value: 9999, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development # environment (see: http://developer.apple.com/tools/xcode/), introduced with # OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO # This tag determines the name of the docset feed. A documentation feed provides # an umbrella under which multiple documentation sets from a single provider # (such as a company or product suite) can be grouped. # The default value is: Doxygen generated docs. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project # The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. # The default value is: org.doxygen.Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. # The default value is: Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop # (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on # Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML # files are now used as the Windows 98 help format, and will replace the old # Windows help format (.hlp) on all Windows platforms in the future. Compressed # HTML files also contain an index, a table of contents, and you can search for # words in the documentation. The HTML workshop also contains a viewer for # compressed HTML files. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO # The CHM_FILE tag can be used to specify the file name of the resulting .chm # file. You can add a path in front of the file if the result should not be # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler (hhc.exe). If non-empty, # doxygen will try to run the HTML help compiler on the generated index.hhp. # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated # (YES) or that it should be included in the master .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO # The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it # enables the Previous and Next buttons. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members to # the table of contents of the HTML help documentation and to the tree view. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help # (.qch) of the generated HTML documentation. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify # the file name of the resulting .qch file. The path specified is relative to # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace # (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual # Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- # folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To # install this plugin and make it available under the help contents menu in # Eclipse, the contents of the directory containing the HTML and XML files needs # to be copied into the plugins directory of eclipse. The name of the directory # within the plugins directory should be the same as the ECLIPSE_DOC_ID value. # After copying Eclipse needs to be restarted before the help appears. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO # A unique identifier for the Eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have this # name. Each documentation set should have its own identifier. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project # If you want full control over the layout of the generated HTML pages it might # be necessary to disable the index and replace it with your own. The # DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top # of each HTML page. A value of NO enables the index and the value YES disables # it. Since the tabs in the index contain the same information as the navigation # tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. If the tag # value is set to YES, a side panel will be generated containing a tree-like # index structure (just like the one that is generated for HTML Help). For this # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can # further fine-tune the look of the index. As an example, the default style # sheet generated by doxygen has an example that shows how to put an image at # the root of the tree instead of the PROJECT_NAME. Since the tree basically has # the same information as the tab index, you could consider setting # DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = YES # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # # Note that a value of 0 will completely suppress the enum values from appearing # in the overview section. # Minimum value: 0, maximum value: 20, default value: 4. # This tag requires that the tag GENERATE_HTML is set to YES. ENUM_VALUES_PER_LINE = 4 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used # to set the initial width (in pixels) of the frame in which the tree is shown. # Minimum value: 0, maximum value: 1500, default value: 250. # This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 250 # If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to # external symbols imported via tag files in a separate window. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML # output directory to force them to be regenerated. # Minimum value: 8, maximum value: 50, default value: 10. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # # Note that when changing this option you need to delete any form_*.png files in # the HTML output directory before the changes have effect. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # http://www.mathjax.org) which uses client side Javascript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path # to it using the MATHJAX_RELPATH option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: # http://docs.mathjax.org/en/latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the HTML # output directory using the MATHJAX_RELPATH option. The destination directory # should contain the MathJax.js script. For instance, if the mathjax directory # is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from http://www.mathjax.org before deployment. # The default value is: http://cdn.mathjax.org/mathjax/latest. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site # (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and # should work on any modern browser. Note that when using HTML help # (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) # there is already a search function so this one should typically be disabled. # For large projects the javascript based search engine can be slow, then # enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to # search using the keyboard; to jump to the search box use + S # (what the is depends on the OS and browser, but it is typically # , /